Forum

Author Topic: Placeing markers for georeferencing with python.  (Read 2388 times)

hombre20022000

  • Newbie
  • *
  • Posts: 6
    • View Profile
Placeing markers for georeferencing with python.
« on: May 24, 2017, 10:07:34 PM »
Hello,
I used this code that you posted for the marker georeferencing with python.
The code runs without error but I have no marker placed in my interface. can you help me?
I use Agisoft 1.2.6


#markers batch import script
#compatibility PhotoScan Professional 1.2.5

#camera_label #marker_label  #px_x #px_y #world_x #world_y #altitude

import PhotoScan
import os

doc = PhotoScan.app.document
chunk = doc.chunk

path = PhotoScan.app.getOpenFileName("Specify the path to the file:") #"D:/input.txt"
file = open(path, "rt")   #input file

eof = False
line = file.readline() #reading the line in input file

while not eof:   

   photos_total = len(chunk.cameras)       #number of photos in chunk
   markers_total = len(chunk.markers)       #number of markers in chunk
      
   sp_line = line.rsplit("\t", 6)   #splitting read line by four parts
   camera_name = sp_line[0]      #camera label
   marker_name = sp_line[1]      #marker label
   x = float(sp_line[2])         #x- coordinate of the current projection in pixels
   y = float(sp_line[3])         #y- coordinate of the current projection in pixels
   cx = float(sp_line[4])         #world x- coordinate of the current marker
   cy = float(sp_line[5])         #world y- coordinate of the current marker
   cz = float(sp_line[6])         #world z- coordinate of the current marker

   flag = 0
   for i in range (0, photos_total):   
   
      if chunk.cameras.label == camera.name:
         for marker in chunk.markers:   #searching for the marker (comparing with all the marker labels in chunk)
            if marker.label == marker_name:
               marker.projections[chunk.cameras] = (x,y)      #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] = (x,y)
            
         marker.reference.location = PhotoScan.Vector([cx, cy, cz])
         
         break
         
   line = file.readline()      #reading the line in input file
   if len(line) == 0:
      eof = True
      break # EOF

file.close()         
chunk.updateTransform()

print("Import finished.")  #information message

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Placeing markers for georeferencing with python.
« Reply #1 on: May 24, 2017, 10:23:53 PM »
Hello hombre20022000,

Can you please post the example of the lines in the file that you are using and the screenshot of the workspace or photos pane where camera labels are fully visible?
Best regards,
Alexey Pasumansky,
Agisoft LLC

hombre20022000

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Placeing markers for georeferencing with python.
« Reply #2 on: May 24, 2017, 10:56:29 PM »
This is the informations you ask
Thanks

hombre20022000

  • Newbie
  • *
  • Posts: 6
    • View Profile
Re: Placeing markers for georeferencing with python.
« Reply #3 on: May 24, 2017, 10:59:03 PM »
This is cameras label

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14846
    • View Profile
Re: Placeing markers for georeferencing with python.
« Reply #4 on: May 24, 2017, 10:59:21 PM »
Hello hombre20022000,

You need to use image filenames in the text file (with the extension) or add it in the script, for example:

Code: [Select]
if chunk.cameras.label == camera_name[:-4]
Best regards,
Alexey Pasumansky,
Agisoft LLC