Forum

Can't Load Photos

Started by abhilam@ksu.edu, February 27, 2017, 07:15:40 PM

Previous topic - Next topic

abhilam@ksu.edu

HI.
I am trying to write python code for launchhing Agisoft and import photos but I am getting error message of "Cant load photos".
Here is the code I have written

doc = PhotoScan.app.document # Create photoscan application
doc.save( os.path.join(Path,'NewBatch.psz')) # Create new photoscan project

chunk=doc.addChunk()
P2File=os.path.join(os.getcwd(),'ImageSYmple') # Path where image are located
abc=[f for f in os.listdir(P2File)] # List of Images to be imported
print (abc)
chunk.addPhotos(abc)


Thank you





Thibaud Capra

Hello,

Try this :


import os, PhotoScan

print(">>> Script Started <<<")

doc = PhotoScan.app.document
chunk = doc.addChunk()
path_photos = PhotoScan.app.getExistingDirectory("Specify folder containing photos")
path_photos += "\\"

image_list = os.listdir(path_photos)
photo_list = list()
for photo in image_list:
    if photo.rsplit(".",1)[1].upper() in ["JPG", "JPEG", "TIF", "PNG"]:
           photo_list.append(path_photos + photo)
           print(photo)
    else:
           print("No photo available.")
print(photo_list)
chunk.addPhotos(photo_list)
PhotoScan.app.update()

print(">>> Script Finished <<<")
Best regards.
--
Thibaud CAPRA
Master Student in Geodetic Engineering, Cartography & Surveying
Master Thesis in Automated Processing of UAV-based Photogrammetric Data (ResearchGate Link)
INSA de Strasbourg, FRANCE
--

Alexey Pasumansky

Hello abhilam,

Maybe you can also give the result of print(abc)?
Best regards,
Alexey Pasumansky,
Agisoft LLC

abhilam@ksu.edu

Dear Thibaud,
Thank you for your guidance. it is now working. It seems like i had problem with path management.

Appreciated.

Abhi