Dear all,
Iam relatively new in using Agisoft Metashape. And now I've stumbled across one thing that I don't quite understand.
Specifically:
I want to perform an alignment of several undistorted image pairs:
For test reasons I tryed once with the GUI and once with the API Python.
And here comes what I dont understand - the results are different.
What am I doing in the API is:
a) I choose 2 images from two different sensors installed in a stereo-capable arrangement, which are already undistorted.
b) I tell Agisoft some adjustments provided by a JSON-file. e.g. camera constant, sensor pixel size, img height/width, principle points, ...
c) I define a scalebar to tell Agisoft that camera 1 is installed at location [0,0,0] and camera 2 at [0.2,0,0] of my local coordinate system
...
MyProject.settingsFromJSON(filePath=JSONpath, stereoProject=True)
MyProject.addPhotosToChunk(
imageDir = imageDir,
fileType = ".tiff")
...
MyProject.chunk.remove(MyProject.chunk.sensors[0])
for i, camera in enumerate(MyProject.chunk.cameras):
camkey = list(MyProject.camArray.keys())[i]
sensor = MyProject.chunk.addSensor()
sensor.label = camkey
sensor.type = camera.sensor.type
sensor.calibration = camera.sensor.calibration
sensor.width = camera.sensor.width
sensor.height = camera.sensor.height
sensor.focal_length = MyProject.camArray[camkey]['camConstant']
sensor.pixel_height = MyProject.camArray[camkey]['pixelSize']
sensor.pixel_width = MyProject.camArray[camkey]['pixelSize']
sensor.fixed_calibration = True
camera.sensor = sensor
calib = Metashape.Calibration()
principleX = MyProject.camArray[camkey]['principleX']
principleY = MyProject.camArray[camkey]['principleY']
calib.cx = principleX/sensor.pixel_height
calib.cy = principleY/sensor.pixel_height
calib.f = sensor.focal_length/sensor.pixel_height
calib.height = MyProject.camArray[camkey]['imgHeight']
calib.width = MyProject.camArray[camkey]['imgWidth']
sensor.user_calib = calib
sensor.fixed_calibration = True
camera.sensor = sensor
scalebar = MyProject.chunk.addScalebar(MyProject.chunk.cameras[0],
MyProject.chunk.cameras[1])
scalebar.reference.distance = 0.2
scalebar.reference.accuracy = 0.1
...
d) I try to perform the steps matchPhotos and alignPhotos using the API
MyProject = PyExpress.photogrammicProcessing.processing.matchPhotos(
project = MyProject,
detailLevel = 0,
generic_preselection = False,
ref_preselection = False,
filter_stat_tie_pp = False,
keypoint_limit = 10000,
tiepoint_limit = 5000,
guided_matching = False)
--> which runs: project.chunk.matchPhotos(
downscale=detailLevel,
generic_preselection=generic_preselection,
reference_preselection=ref_preselection,
filter_mask=False,
mask_tiepoints=False,
filter_stationary_points=filter_stat_tie_pp,
keypoint_limit=keypoint_limit,
tiepoint_limit=tiepoint_limit,
guided_matching=guided_matching)
MyProject = PyExpress.photogrammicProcessing.processing.alignCameras(
project = MyProject,
adaptive_fitting = False,
reset_alignment = False)
e) Finally, I save everything in an Agisoft project using something like doc.save(path.psx).
__________
However, with some of my image-pairs this works pretty good. And with some not.
Now comes the blackbox-moment (also compare to the attachements pls):
- I open the created .psx-file in the GUI
- I understand that no alignment has been performed
- So I try alignment again by using Workflow/AlignPhotos within the GUI + checking the box "reset current alignment"
- Here it works, ...,
.
I ve tryed to implement exactly the same what the GUI is doing when running "Align Photos". Where am I missing something here?
I hope I have expressed myself clearly

Thank you very much in advance,
Martin