From 69a0fab10ef38b5c5523de1f277a0810affa1289 Mon Sep 17 00:00:00 2001 From: Jakub Uhlik Date: Tue, 3 Mar 2020 10:28:44 +0100 Subject: [PATCH] skip strange sensors and make sensor from calibration data only --- io_import_photoscan_cameras.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/io_import_photoscan_cameras.py b/io_import_photoscan_cameras.py index 7f92353..3974d87 100644 --- a/io_import_photoscan_cameras.py +++ b/io_import_photoscan_cameras.py @@ -193,6 +193,11 @@ def __init__(self, xml): # self.calibration['k2'] = float(cal.find("k2").text) # self.calibration['k3'] = float(cal.find("k3").text) + if('pixel_width' not in self.props): + self.props['pixel_width'] = self.calibration['resolution']['width'] + self.props['pixel_height'] = self.calibration['resolution']['height'] + self.props['focal_length'] = self.calibration['f'] + sw = 0 sh = 0 ver = 0 @@ -334,13 +339,19 @@ def __init__(self, xml, id): sens = self.xml.findall(".//sensor") for s in sens: - sd = PSCSensor(s) + try: + sd = PSCSensor(s) + except: + sd = None self.sensors.append(sd) self.cameras = [] cams = self.xml.findall(".//camera") for c in cams: sensor = self.sensors[int(c.attrib["sensor_id"])] + if(sensor is None): + # TODO: unparsed sensor, skip that, deal with that later somehow.. at least notify user + continue cam = PSCCamera(c, sensor) self.cameras.append(cam)