Forum

Author Topic: [1.2.x] How to load the Markes XML file  (Read 3509 times)

Simon_

  • Newbie
  • *
  • Posts: 11
    • View Profile
[1.2.x] How to load the Markes XML file
« on: March 09, 2016, 08:11:45 PM »
Hello,

I am trying to load my exported Markers back into the application via python.

My code so far:

Code: [Select]
import PhotoScan
import os

doc = PhotoScan.app.document
chunk = PhotoScan.app.document.addChunk()
chunk.label = "autoChunk"

# ChangeToYourPath
path_photos = YourPathToPhotos

image_list = os.listdir(path_photos)
for photo in image_list:
if ("jpg" or "jpeg" or "tif" or "png") in photo.lower():
print(path_photos + photo)
chunk.addPhotos([path_photos + photo])

PhotoScan.app.update()

chunk.crs = PhotoScan.CoordinateSystem("EPSG::4326")

# ChangeToYourPath
MarkersXML = YourMarkersXML

boolOut = chunk.loadReference(MarkersXML, "xml")

print("Does it work? -- " + str(boolOut))

chunk.updateTransform()

PhotoScan.app.update()

With the Dialog: Tools >> Import >> Import Markers... the program loads my XML file correctly.

The script above does not.

Whos spots the mistake?

Thanks!
Simon

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14890
    • View Profile
Re: [1.2.x] How to load the Markes XML file
« Reply #1 on: March 09, 2016, 08:23:15 PM »
Hello Simon,

First of all I need to comment that one of the lines is not working properly in your script (actually, it's my fault as I have originally posted that line before in some scripts here):
Code: [Select]
("jpg" or "jpeg" or "tif" or "png") in photo.lower():should be corrected to the following, for example:
Code: [Select]
photo.lower()[-3:] in ["jpg", "jpeg","tif","png"]:
As for the .loadReference() function - it is an equivalent to the Reference pane -> Import button. So you need to use chunk.importMarkers() function instead.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Simon_

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: [1.2.x] How to load the Markes XML file
« Reply #2 on: March 14, 2016, 06:50:39 PM »
Thanks Alexey, its working now!