Forum

Author Topic: Can't Load Photos  (Read 4050 times)

abhilam@ksu.edu

  • Newbie
  • *
  • Posts: 4
    • View Profile
Can't Load Photos
« on: February 27, 2017, 07:15:40 PM »
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

  • Full Member
  • ***
  • Posts: 101
  • Master Student in Geodetic Engineering & Surveying
    • View Profile
    • INSA de Strasbourg, Topography Engineering (French)
Re: Can't Load Photos
« Reply #1 on: February 27, 2017, 07:23:46 PM »
Hello,

Try this :

Code: [Select]
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

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14847
    • View Profile
Re: Can't Load Photos
« Reply #2 on: February 27, 2017, 09:41:33 PM »
Hello abhilam,

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

abhilam@ksu.edu

  • Newbie
  • *
  • Posts: 4
    • View Profile
Re: Can't Load Photos
« Reply #3 on: February 28, 2017, 07:11:06 PM »
Dear Thibaud,
Thank you for your guidance. it is now working. It seems like i had problem with path management.

Appreciated.

Abhi