Forum

Author Topic: Using python to load multiple photos and apply individual masks  (Read 3780 times)

lvargo13

  • Newbie
  • *
  • Posts: 14
    • View Profile
Hi everyone

I'm trying to load a subset of images in a folder into photoscan (DSC_1700.tiff - DSC_1750.tiff), and then apply a different mask to each image (DSC_1700_mask.png - DSC_1750_mask.png). The addPhotos line in the loop works, and the images are loaded. But the importMasks line is not working (I think every time importMask is called, it's applying that mask to all of the photos that are currently read in). Is there a way to specify the image to be masked? Or another way to loop through a subset of photos and apply an individual mask to each?

Thanks!

Code: [Select]
#!/usr/bin/python

# python script for photoscan
# reads in and masks specified photos (startphoto through endphoto)

import PhotoScan
doc = PhotoScan.app.document
chunk = PhotoScan.app.document.addChunk()

# loop to read in photos
startphoto=1700
endphoto=1750

for x in range(startphoto, endphoto + 1):
     chunk.addPhotos(['/Volumes/arc_01/FIELD_DATA/SFM/EOSS/PHOTOS_EOSS_20160330/106D800E/TIFF/DSC_%s.tiff' % x])
     chunk.importMasks(path='/Volumes/arc_01/FIELD_DATA/SFM/EOSS/PHOTOS_EOSS_20160330/106D800E/TIFF/DSC_%s_mask.png' % x,method='file',operation='union',tolerance=10)

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14843
    • View Profile
Re: Using python to load multiple photos and apply individual masks
« Reply #1 on: August 09, 2016, 10:21:27 AM »
Hello lvargo13,

You can use cameras argument for the importMasks() function and pass the list of cameras.

If you are using filename template for the mask import, you can use this function after the photo adding loop.
Best regards,
Alexey Pasumansky,
Agisoft LLC