Hey guys,
Iam trying to set calbration for two sensors installed in an streoscopic setup:
# filling up number of sensors according to number of cameras
while len(project.chunk.sensors) != len(project.chunk.cameras):
project.chunk.addSensor()
# set parameters from sensor calibration file content
for camera in project.chunk.cameras:
sensor = camera.sensor
sensor.label = camera.label
camKey = sensor.label.split('_')[-1]
sensor.type = Metashape.Sensor.Type.Frame
sensor.focal_length = config['sensor'][camKey]['constant']
sensor.pixel_height = config['sensor'][camKey]['pix_size']
sensor.pixel_width = config['sensor'][camKey]['pix_size']
princ_x = config['sensor'][camKey]['princ_x']
princ_y = config['sensor'][camKey]['princ_y']
focal_len = config['sensor'][camKey]['constant']
pixel_size = config['sensor'][camKey]['pix_size']
cal = Metashape.Calibration()
cal.width = config['sensor'][camKey]['width']
cal.height = config['sensor'][camKey]['height']
cal.cx = princ_x/pixel_size
cal.cy = princ_y/pixel_size
cal.f = focal_len/pixel_size
sensor.user_calib = cal
sensor.fixed_calibration = True
until here, everything works obviously fine. console output:
for cam in StereoProject.doc.chunk.cameras:
print(f'camera: {cam.label}\n'
f'focal_length: {cam.sensor.focal_length}\n'
f'pixel_size: {cam.sensor.pixel_size}\n'
f'cx (px): {cam.sensor.calibration.cx}\n'
f'cy (px): {cam.sensor.calibration.cy}\n'
f'f (px): {cam.sensor.calibration.f}\n')
camera: distorted_stereoCam_E0
focal_length: 15.90096
pixel_size: Vector([0.00345, 0.00345])
cx (px): -24.07246376811594
cy (px): 22.217391304347824
f (px): 4608.973913043478
camera: distorted_stereoCam_E1
focal_length: 15.96475
pixel_size: Vector([0.00345, 0.00345])
cx (px): -11.518840579710144
cy (px): 27.91594202898551
f (px): 4627.463768115942
and now comes the beloved blackbox-moment.
I save the project via API using something like
project.doc.chunk.save()
and then I open it with the GUI.
Please have a look at the attachment (as I dont know how to embedd an image here).
As you can see, everything was saved but of the resolution, focal length and pixel size of only one camera....
I get desperate, pls help :-P Does anyone knows where my mistake is?
best,
Martin