Hello willcodeforfoo,
Here's an example of the script that loads both projections of the markers on the corresponding photos and the 3D world coordinates:
#compatibility Agisoft PhotoScan Professional 1.2.1
#markers import script
#input file format:
#marker_label, camera_label, x-pixel, y_pixel,x-coord, y-coord, z-coord
#(TAB separator)
import PhotoScan
doc = PhotoScan.app.document
chunk = doc.chunk
path = PhotoScan.app.getOpenFileName("Specify input file with marker coordinates:")
print("Import started...") #informational message
file = open(path, "rt") #input file
photos_total = len(chunk.cameras) #number of photos in chunk
markers_total = len(chunk.markers) #number of markers in chunk
eof = False
line = file.readline()
if len(line) == 0:
eof = True
while not eof:
#print(line)
sp_line = line.split(",", 6) #splitting read line by four parts
y = float(sp_line[3]) #x- coordinate of the current projection in pixels
x = float(sp_line[2]) #y- coordinate of the current projection in pixels
x_coord = float(sp_line[4]) #x- coordinate of the marker
y_coord = float(sp_line[5]) #y- coordinate of the marker
z_coord = float(sp_line[6]) #x- coordinate of the marker
camera_label = sp_line[1] #camera label
marker_name = sp_line[0] #marker label
flag = 0
for camera in chunk.cameras:
if camera.label.upper() == camera_label.upper(): #searching for the image (comparing with all the photo paths in chunk)
for marker in chunk.markers: #searching for the marker (comparing with all the marker labels in chunk)
if marker.label == marker_name:
marker.projections[camera] = (x, y) #setting up marker projection of the correct photo)
flag = 1
break
if not flag: #adding new marker if no correspondence found
chunk.addMarker()
chunk.markers[-1].label = marker_name
chunk.markers[-1].projections[camera] = (x, y) #setting up marker projection of the correct photo)
if not marker.reference.location:
marker.reference.location = PhotoScan.Vector([x_coord, y_coord, z_coord])
break
line = file.readline() #reading the line in input file
if not len(line):
eof = True
break # End of File
print("Script finished") #information message
file.close()
Please pay attention to the input format and delimiter option in this example.