Hi
I'm trying to export the image coordinates and coordinates in a projected reference system for each marker to one text file. I started piecing together some bits of code from around the forum but I am having some trouble. My plan in the code below is to write two text files (one with img coordinates, one with reference system coordinates) and then piece them together in pandas.
The first bit is moving along fine.
Here's the code so far:
path = r"path\to\project\folder"
f_img = open(path + "\img_coords.txt", 'wt')
f_img.write("camera_label, " + "marker_label, " + "x, " + "y, " + "key" + "\n")
for camera in chunk.cameras:
for marker in chunk.markers:
if not marker.projections[camera]:
key = 0
x0, y0 = camera.project(marker.position)
else:
key = 1
x0, y0 = marker.projections[camera].coord
f_img.write("{}, {}, {:.4f}, {:.4f}, {}".format(camera.label, marker.label, x0, y0, key) + "\n")
f_img.close()
f_gcp = open(path + "\gcp_coords.txt", "wt")
f_gcp.write("camera_label, " + "marker_label, " + "x_crs, " + "y_crs, " + "\n")
# Loop for writing to file:
f_gcp.close()
print("Finished")
I guess there is a much more elegant way to do this but I am struggling a little with the api documentation. Some tutorials to help understand the structure would be much appreciated!