Forum

Author Topic: Error: Can't load photos  (Read 8554 times)

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Error: Can't load photos
« on: March 25, 2016, 11:58:19 PM »
Hi All, I am trying to run a fairly simple script but for some reason I keep getting this error (Error: Can't load photos)

I'm not too sure why :? The script itself was written by Alexey Pasumansky a while back and changed slightly for the newest version of PhotoScan. Any tips as to why this error would come up would be appreciated. I am positive the file path is correct, and the images do exist.

Here is the script:

Code: [Select]
import PhotoScan
import os, sys
import time

startTime = time.time()

'''
Script adapted from:
http://www.agisoft.ru/forum/index.php?topic=669.msg3035#msg3035
Alexey Pasumansky
September 6, 2012
'''
path=sys.argv[1]  #path to the image folder
projectName = sys.argv[2]
outputLog = open("%s/%s_output_log.txt"%(path, projectName), 'w')
outputLog.write('Starting PhotoScan Python scripted run on project: %s\n'%projectName)
outputLog.write('Project Path: %s\n'%path)
outputLog.write('Starting set up: %s\n'%time.asctime())

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

photo_list = os.listdir(path)

for photo_name in photo_list:     #adding all files from the folder
    if photo_name.lower().endswith(('.png')):
        chunk.addPhotos(path + "\\" + photo_name)
        outputLog.write('Added Photo:'+photo_name+'\t\tPath: '+path + '\\' + photo_name+'\n')

#Align Photos
outputLog.write('Starting match photos: %s\n'%time.asctime())
chunk.matchPhotos(accuracy=PhotoScan.HighAccuracy, preselection=PhotoScan.GenericPreselection, filter_mask=False, keypoint_limit=40000)

outputLog.write('Starting align photos: %s\n'%time.asctime())
chunk.alignCameras()   

outputLog.write('Starting save and export points: %s\n'%time.asctime())
doc.save("%s/%s_points.psz"%(path, projectName))
chunk.exportPoints("%s/%s_points.ply"%(path, projectName), format='ply')

outputLog.write('Done: %s\n'%time.asctime())

timeElapsed = (time.time() - startTime)/60.
outputLog.write('Elapsed Time: %.2f minutes'%timeElapsed)

outputLog.close()

And here is the log:
 
Quote
2016-03-25 20:50:58 Agisoft PhotoScan Version: 1.2.4 build 2399 (64 bit)
2016-03-25 20:50:58 OpenGL Vendor: ATI Technologies Inc.
2016-03-25 20:50:58 OpenGL Renderer: AMD Radeon R7 200 Series
2016-03-25 20:50:58 OpenGL Version: 4.5.13430 Compatibility Profile Context 16.150.1009.0
2016-03-25 20:50:58 Maximum Texture Size: 16384
2016-03-25 20:50:58 Quad Buffered Stereo: not enabled
2016-03-25 20:50:58 ARB_vertex_buffer_object: supported
2016-03-25 20:50:58 ARB_texture_non_power_of_two: supported
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.002 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.002 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.002 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.002 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.002 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.002 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.002 sec (exit code 0)
2016-03-25 20:51:02 Loading photos...
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0.003 sec (exit code 0)
2016-03-25 20:51:02 Error: Can't load photos
2016-03-25 20:51:02 Finished processing in 0 sec (exit code 0)
2016-03-25 20:51:02 Estimating camera locations...
2016-03-25 20:51:02 Error: Not enough cameras
2016-03-25 20:51:02 Finished processing in 0.001 sec (exit code 0)
2016-03-25 20:51:02 Saving project...
2016-03-25 20:51:02 saved project in 0.005 sec
2016-03-25 20:51:02 Error: Can't align cameras
2016-03-25 20:51:02 Finished processing in 0.005 sec (exit code 1)
2016-03-25 20:51:02 Finished processing in 0 sec (exit code 0)
2016-03-25 20:51:02 Error: Null point cloud
>>>

jonathanH

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Error: Can't load photos
« Reply #1 on: March 26, 2016, 12:19:00 AM »
My Bad.

For anyone who has a similar problem, mine was fixed by changing this section:
Code: [Select]
for photo_name in photo_list:     #adding all files from the folder
    if photo_name.lower().endswith(('.png')):
        chunk.addPhotos(path + "\\" + photo_name)
        outputLog.write('Added Photo:'+photo_name+'\t\tPath: '+path + '\\' + photo_name+'\n')

To this:

Code: [Select]
newFile=""
for photo_name in photo_list:     #adding all files from the folder
    if photo_name.lower().endswith(('.png')):
        newFile = path + "\\" + photo_name
        chunk.addPhotos([newFile])
        outputLog.write('Added Photo:'+photo_name+'\t\tPath: '+newFile+'\n')

(The addPhotos method accepts an array if images, not a raw string filepath)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15472
    • View Profile
Re: Error: Can't load photos
« Reply #2 on: March 26, 2016, 01:00:09 AM »
Hello jonathanH,

I think you can just use:
Code: [Select]
chunk.addPhotos([path + "\\" + photo_name])
Best regards,
Alexey Pasumansky,
Agisoft LLC