1
Python and Java API / Re: Export markers per image
« on: December 11, 2015, 05:44:51 PM »
Yes, of course it worked with the condition!
Thanks
Thanks

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
#markers import script
#input file format:
#camera_label marker_label x y z
#(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
sth={}
file = open(path, "rt") #input file
eof = False
line = file.readline()
if len(line) == 0:
eof = True
while not eof:
#print(line)
sp_line = line.rsplit(",", 4) #splitting read line by 5 parts
oid = sp_line[0]
z = float(sp_line[3])
y = float(sp_line[2]) #x- coordinate of the current projection in pixels
x = float(sp_line[1]) #y- coordinate of the current projection in pixels
camera_label = 82 #camera label1
photo_0 = chunk.cameras[int(camera_label)]
point3D = PhotoScan.Vector([x,y,z])
point_geocentric = chunk.crs.unproject(point3D)
point_internal = chunk.transform.matrix.inv().mulp(point_geocentric)
imgx, imgy = photo_0.project(point_internal)
print(str(oid),str(imgx),str(imgy))
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()