Ok I got it working with the code below. Now to figure out how to import fiducial markers
import Metashape
def find_marker(label, chunk):
for marker in chunk.markers:
if label == marker.label:
return marker
return None
def getCameras(name):
marker = find_marker(name, chunk)
if not marker:
print("Fiducial " + name + " not found.")
return
if not marker.position:
print("Fiducial " + name + " is not defined in 3D, skipping...")
return
return marker.projections.keys()
FILEPATH = "C:\\Temp\\raw_data.txt"
chunk = Metashape.app.document.chunk
print("Script started...")
fiducialCameras = getCameras("1") # get all cameras that have fiducial 1 in it, assume that other fiducials are located in camera too..
fid1=find_marker("1", chunk)
fid2=find_marker("2", chunk)
fid3=find_marker("3", chunk)
fid4=find_marker("4", chunk)
f = open(FILEPATH, 'w')
for camera in fiducialCameras:
f.write(camera.label + ',' + str(fid1.projections[camera].coord.x) + ',' + str(fid1.projections[camera].coord.y) + ',' + str(fid2.projections[camera].coord.x) + ',' + str(fid2.projections[camera].coord.y) + ','+ str(fid3.projections[camera].coord.x) + ','+ str(fid3.projections[camera].coord.y) + ','+ str(fid4.projections[camera].coord.x) + ',' + str(fid4.projections[camera].coord.y) + '\n')
f.close
print("Script finished")