Forum

Author Topic: Importing 2D marker positions on photos  (Read 2683 times)

Rita

  • Newbie
  • *
  • Posts: 1
    • View Profile
Importing 2D marker positions on photos
« on: March 05, 2018, 07:17:22 PM »
Hi,

I have a file which looks like this

MARKER_NAME     Easting     Northing     Altitude

And a file which looks like this

MARKER_NAME     IMAGE_NAME     IMAGE_X_COORDINATE     IMAGE_Y_COORDINATE

I am wondeering how one would go about importing this into PhotoScan?

I don't mind manually editing the files to make it easier for PhotoScan to read the information.

Any help would be much appreicated.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Importing 2D marker positions on photos
« Reply #1 on: March 22, 2018, 01:29:15 PM »
Hello Rita,

You can use the following code as a reference for your script:


Code: [Select]
import PhotoScan
chunk = PhotoScan.app.document.chunk
file = open(path, "rt") #input file

eof = False
line = file.readline()
if not len(line):
eof = True

while not eof:

sp_line = line.rsplit(",", 3)   #splitting read line by four parts
y = float(sp_line[3]) #y- coordinate of the current projection in pixels
x = float(sp_line[2]) #x- coordinate of the current projection in pixels
path = sp_line[1] #camera label
marker_name = sp_line[0] #marker label

flag = 0
for i in range (len(chunk.cameras)):

if chunk.cameras[i].label == path: #searching for the camera

for j in range (len(chunk.markers)): #searching for the marker (comparing with all the marker labels in chunk)
if chunk.markers[j].label == marker_name:
chunk.markers[j].projections[chunk.cameras[i]] =  PhotoScan.Marker.Projection(PhotoScan.Vector([x,y]), True) #setting up marker projection of the correct photo)
flag = 1
break

if not flag:
marker = chunk.addMarker()
marker.label = marker_name
marker.projections[chunk.cameras[i]] =  PhotoScan.Marker.Projection(PhotoScan.Vector([x,y]), True)
break

line = file.readline() #reading the line from input file
if not len(line):
eof = True
break # EOF

file.close()
print ("Markers import finished.\n")


Best regards,
Alexey Pasumansky,
Agisoft LLC