Forum

Author Topic: AlignChunks runtime error  (Read 7849 times)

osima

  • Newbie
  • *
  • Posts: 16
    • View Profile
AlignChunks runtime error
« on: December 11, 2013, 02:11:27 PM »
Hi,
I am a beginner in Python, but managed pretty well so far.

At least until I got this cryptic message thrown by the console:

Quote
Traceback (most recent call last):
  File "//tsclient/D/Tools/ownScripts/Python_PhotoScan/first_test_multiple_chunks_oneCalibration.py", line 50, in <module>
    PhotoScan.alignChunks(doc.chunks,doc.chunks[1], method="points", accuracy="high", preselection=False, filter_mask=False, point_limit=40000)
RuntimeError: More keyword list entries (7) than format specifiers (5)

This is the code that I use:

Code: [Select]
#PhotoScan 0.9.1 build 1703 (64bit)
import PhotoScan
import os, os.path
import string

doc = PhotoScan.Document()

path="X:/FirstData/Chunks/"  #path to the image folder
cameraCalibPath = "CamCalibration.xml" #path to the camera calibration file
cameraCalibration = PhotoScan.Calibration()
cameraCalibration.load(path + cameraCalibPath)
print (cameraCalibration.width)

#For every folder with image subsets
for root, dirs, files in os.walk(path):


    for name in dirs:
        photos_list = os.listdir(os.path.join(root, name))
        chunk = PhotoScan.Chunk()
        chunk.label = name
        doc.chunks.add(chunk) #add a new chunk
        sensor = PhotoScan.Sensor()
        sensor.width = cameraCalibration.width
        sensor.height = cameraCalibration.height
        sensor.user_calib = cameraCalibration
        sensor.fixed = True
       
        for photo_name in photos_list:     #add all images from the folder
            camera = PhotoScan.Camera()
            camera.open(os.path.join(root, name) + "/" + photo_name)
            if (photo_name.rsplit(".",1)[1] =="jpg") :
               camera.label = camera.path.rsplit("/",1)[1]
               camera.sensor = sensor 
               chunk.sensors.add(sensor)
               chunk.photos.add(camera)

doc.save("X:/FirstData/Chunks/proj1.psz")

#Align Photos in every chunk
for chunk in doc.chunks:
    chunk.matchPhotos(accuracy = "high", preselection="disabled", filter_mask=False, point_limit=40000)
    chunk.alignPhotos()   
    #Build Geometry
    chunk.buildDepth(quality="high", filter="aggressive", gpu_mask=0, cpu_cores_inactive=1)
    chunk.buildModel(object="height field", geometry="smooth", faces=0, filter_threshold=0, hole_threshold=10)   
    doc.save("X:/FirstData/Chunks/proj1.psz")

#Align chunks
PhotoScan.alignChunks(doc.chunks,doc.chunks[1], method="points", accuracy="high", preselection=False, filter_mask=False, point_limit=40000)
PhotoScan.mergeChunks(doc.chunks, merge_models=False, merge_markers=False)



Could anyone shed some light on what I do wrong?

Best regards,

Ola


Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15171
    • View Profile
Re: AlignChunks runtime error
« Reply #1 on: December 11, 2013, 02:28:19 PM »
Hello Ola,

Seems like it is 0.9.1 issue. The script line works fine in 1.0.0 pre-release.
Best regards,
Alexey Pasumansky,
Agisoft LLC

osima

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: AlignChunks runtime error
« Reply #2 on: December 11, 2013, 03:04:14 PM »
Hi Alexey,

Thank you for your prompt response. I will try version 1.0.

Best,
Ola

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15171
    • View Profile
Re: AlignChunks runtime error
« Reply #3 on: December 11, 2013, 03:06:46 PM »
Hello Ola,

Note that there were some changes in the processing steps, so instead of .buildDepth you need to use .buildDenseCloud, and some arguments in .buildModel have been changed.
Best regards,
Alexey Pasumansky,
Agisoft LLC

osima

  • Newbie
  • *
  • Posts: 16
    • View Profile
Re: AlignChunks runtime error
« Reply #4 on: December 11, 2013, 03:13:18 PM »
Hi Alexey,

Thanks a lot! I noticed this change in the change log. Good stuff :)

Best,
Ola

Lily

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: AlignChunks runtime error
« Reply #5 on: February 03, 2016, 01:09:03 PM »
Code: [Select]
for photo_name in photos_list:     #add all images from the folder
            camera = PhotoScan.Camera()
            camera.open(os.path.join(root, name) + "/" + photo_name)
            if (photo_name.rsplit(".",1)[1] =="jpg") :
               camera.label = camera.path.rsplit("/",1)[1]
               camera.sensor = sensor
               chunk.sensors.add(sensor)
               chunk.photos.add(camera)

Hi Alexey and osima,
I have many sets of photos in folder1,2,3,… and I want a python file to help me to add all the photos into a photoscan file automatically.That is,let the photos in folder1 all added to  chunk1 ,photos in folder2 all added to  chunk2,…
I know little about python script, I searched this forum and found this topic.How fortunate I am!  You are brilliant ! However, the code couldn't do well in  version1.1.6. So I write this to ask if  you mind to help me “translate” the code attached above into version1.1.6?Thank you very much and I'm looking forward to your reply.

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15171
    • View Profile
Re: AlignChunks runtime error
« Reply #6 on: February 03, 2016, 04:24:13 PM »
Hello Lily,

Is there any reason, why you don't wish to use the version 1.2.3?

in this case you can pass the list of paths to the image files to chunk.addPhotos() function and it will load all the images and create all the sensors automatically.
Best regards,
Alexey Pasumansky,
Agisoft LLC