mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-29 10:17:27 +02:00
Merge pull request #1509 from alicevision/dev/offsetFromCenter
Optical center relative to the image center
This commit is contained in:
commit
1a506f81fa
2 changed files with 22 additions and 7 deletions
|
@ -330,10 +330,15 @@ class ListAttribute(Attribute):
|
|||
self.extend(newValue)
|
||||
self.requestGraphUpdate()
|
||||
|
||||
def upgradeValue(self, exportedValue):
|
||||
values = exportedValue if isinstance(exportedValue, list) else [exportedValue]
|
||||
def upgradeValue(self, exportedValues):
|
||||
if not isinstance(exportedValues, list):
|
||||
if isinstance(exportedValues, ListAttribute) or Attribute.isLinkExpression(exportedValues):
|
||||
self._set_value(exportedValues)
|
||||
return
|
||||
raise RuntimeError("ListAttribute.upgradeValue: the given value is of type " + str(type(exportedValues)) + " but a 'list' is expected.")
|
||||
|
||||
attrs = []
|
||||
for v in values:
|
||||
for v in exportedValues:
|
||||
a = attributeFactory(self.attributeDesc.elementDesc, None, self.isOutput, self.node, self)
|
||||
a.upgradeValue(v)
|
||||
attrs.append(a)
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
__version__ = "5.0"
|
||||
__version__ = "6.0"
|
||||
|
||||
import os
|
||||
import json
|
||||
|
@ -255,12 +255,22 @@ The metadata needed are:
|
|||
]
|
||||
|
||||
def upgradeAttributeValues(self, attrValues, fromVersion):
|
||||
if fromVersion <= Version(4, 0):
|
||||
# Starting with version 5, the focal length is now split on x and y
|
||||
if fromVersion < Version(5, 0):
|
||||
for intrinsic in attrValues['intrinsics']:
|
||||
# focal length is now split on x and y
|
||||
pxFocalLength = intrinsic['pxFocalLength']
|
||||
if not isinstance(pxFocalLength, dict):
|
||||
intrinsic['pxFocalLength'] = {"x": pxFocalLength, "y": pxFocalLength}
|
||||
|
||||
# Starting with version 6, the principal point is now relative to the image center
|
||||
if fromVersion < Version(6, 0):
|
||||
for intrinsic in attrValues['intrinsics']:
|
||||
principalPoint = intrinsic['principalPoint']
|
||||
intrinsic['principalPoint'] = {
|
||||
"x": int(principalPoint["x"] - 0.5 * intrinsic['width']),
|
||||
"y": int(principalPoint["y"] - 0.5 * intrinsic['height'])
|
||||
}
|
||||
|
||||
return attrValues
|
||||
|
||||
def readSfMData(self, sfmFile):
|
||||
|
@ -328,7 +338,7 @@ The metadata needed are:
|
|||
view['metadata'] = json.loads(view['metadata'])
|
||||
|
||||
sfmData = {
|
||||
"version": [1, 2, 0],
|
||||
"version": [1, 2, 1],
|
||||
"views": views + newViews,
|
||||
"intrinsics": intrinsics,
|
||||
"featureFolder": "",
|
||||
|
|
Loading…
Add table
Reference in a new issue