Forum

Author Topic: Disable photos based on list in CSV file  (Read 1889 times)

kwikstromjones

  • Newbie
  • *
  • Posts: 2
    • View Profile
Disable photos based on list in CSV file
« on: November 22, 2017, 03:07:57 AM »
Hi,

I ran a python script in IDLE to select every other photo in a folder and write the photo names to a CSV file. The CSV file looks like this:
CCH_4122.JPG   CCH_4124.JPG   CCH_4126.JPG
CCH_5121.JPG   CCH_5123.JPG   CCH_5125.JPG
CCH_6120.JPG   CCH_6122.JPG   CCH_6124.JPG

Now I want to read the CSV in Photoscan and disable the cameras that are listed in the CSV.

I looked at your previous response here: http://www.agisoft.com/forum/index.php?topic=2470.msg13128#msg13128
but I can't figure out how to get it to work.

Currently my script looks like this:

import PhotoScan
doc = PhotoScan.app.document
chunk = doc.chunk
camera_names = PhotoScan.app.getOpenFileName("photos_selection.csv")
for camera in chunk.cameras:
     if camera.label in camera_names:
          camera.enabled = False

I don't get any error message, just ">>>" and I don't see any disabled photos. Could you please help me?

Thanks a lot!

dobedobedo

  • Newbie
  • *
  • Posts: 31
    • View Profile
Re: Disable photos based on list in CSV file
« Reply #1 on: November 22, 2017, 05:04:22 AM »
Hi,
I think your script doesn't save the content in the csv file to camera_names. You could try to use the file IO methods in Python like:
Code: [Select]
camera_names = list()
with open(filename, 'r') as file:
    for line in file.readlines():
        Files = line.split(',')
        for File in Files:
            camera_names.append(File.strip('\n'))
Then the camera_names shall contains the filenames in your csv file.

kwikstromjones

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Disable photos based on list in CSV file
« Reply #2 on: November 22, 2017, 05:19:46 AM »
YAY! It works now! Thank you very much!