mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-04-30 10:47:34 +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.extend(newValue)
|
||||||
self.requestGraphUpdate()
|
self.requestGraphUpdate()
|
||||||
|
|
||||||
def upgradeValue(self, exportedValue):
|
def upgradeValue(self, exportedValues):
|
||||||
values = exportedValue if isinstance(exportedValue, list) else [exportedValue]
|
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 = []
|
attrs = []
|
||||||
for v in values:
|
for v in exportedValues:
|
||||||
a = attributeFactory(self.attributeDesc.elementDesc, None, self.isOutput, self.node, self)
|
a = attributeFactory(self.attributeDesc.elementDesc, None, self.isOutput, self.node, self)
|
||||||
a.upgradeValue(v)
|
a.upgradeValue(v)
|
||||||
attrs.append(a)
|
attrs.append(a)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
__version__ = "5.0"
|
__version__ = "6.0"
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import json
|
import json
|
||||||
|
@ -255,12 +255,22 @@ The metadata needed are:
|
||||||
]
|
]
|
||||||
|
|
||||||
def upgradeAttributeValues(self, attrValues, fromVersion):
|
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']:
|
for intrinsic in attrValues['intrinsics']:
|
||||||
# focal length is now split on x and y
|
|
||||||
pxFocalLength = intrinsic['pxFocalLength']
|
pxFocalLength = intrinsic['pxFocalLength']
|
||||||
if not isinstance(pxFocalLength, dict):
|
if not isinstance(pxFocalLength, dict):
|
||||||
intrinsic['pxFocalLength'] = {"x": pxFocalLength, "y": pxFocalLength}
|
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
|
return attrValues
|
||||||
|
|
||||||
def readSfMData(self, sfmFile):
|
def readSfMData(self, sfmFile):
|
||||||
|
@ -328,7 +338,7 @@ The metadata needed are:
|
||||||
view['metadata'] = json.loads(view['metadata'])
|
view['metadata'] = json.loads(view['metadata'])
|
||||||
|
|
||||||
sfmData = {
|
sfmData = {
|
||||||
"version": [1, 2, 0],
|
"version": [1, 2, 1],
|
||||||
"views": views + newViews,
|
"views": views + newViews,
|
||||||
"intrinsics": intrinsics,
|
"intrinsics": intrinsics,
|
||||||
"featureFolder": "",
|
"featureFolder": "",
|
||||||
|
|
Loading…
Add table
Reference in a new issue