Hello adrian,
Please check the following script example that prints out for each marker either the existing projection coordinates (pinned = green flag, unpinned = blue flag) or expected projection location (undefined = gray flag):
import Metashape
def get_markers_projections(chunk):
print("Script started...")
for marker in chunk.markers:
if (not len(marker.projections.keys()) and not marker.position):
continue
for camera in chunk.cameras:
if camera in marker.projections.keys():
x, y, z = marker.projections[camera].coord
if marker.projections[camera].pinned:
print(marker.label, camera.label, "pinned", x, y)
else:
print(marker.label, camera.label, "unpinned", x, y)
else:
if not marker.position:
continue
if not camera.transform:
continue
point = marker.position
if camera.project(point):
x, y = camera.project(point)
if (0 <= x < camera.sensor.width) and (0 <= y < camera.sensor.height):
print(marker.label, camera.label, "undefined", x, y)
print("Script finished")
return 1
chunk = Metashape.app.document.chunk
get_markers_projections(chunk)
The sample output for such script will look like the following:
2022-12-14 13:14:52 Script started...
2022-12-14 13:14:52 point 2 DSC03649.JPG unpinned 1917.0135498046875 1528.13916015625
2022-12-14 13:14:52 point 2 DSC03650.JPG undefined 1647.1464515201335 349.7973120066963
2022-12-14 13:14:52 point 2 DSC03663.JPG unpinned 644.6650390625 945.0457153320312
2022-12-14 13:14:52 point 2 DSC03664.JPG unpinned 494.5836181640625 942.4381103515625
2022-12-14 13:14:52 point 2 DSC03683.JPG pinned 142.2118377685547 786.333251953125
2022-12-14 13:14:52 Script finished