Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: Simon_ 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:
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
-
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):
("jpg" or "jpeg" or "tif" or "png") in photo.lower():
should be corrected to the following, for example:
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.
-
Thanks Alexey, its working now!