Forum

Author Topic: Loading Masks in Photoscan 1.3.0  (Read 2801 times)

2door

  • Newbie
  • *
  • Posts: 1
    • View Profile
Loading Masks in Photoscan 1.3.0
« on: February 11, 2017, 03:51:47 AM »
Hello everyone.

I am trying to load masks for a model such that I have my images in project/jpg/someimage_001.jpg and my masks in project/masks/someimage_001_mask.jpg. I looked at the API and found the importMasks function. I know that they can be loaded based on a naming convention but I can't quite get my head around it. Any help would be appreciated.

Code: [Select]
ImageDirectory = path + "/jpg/"
MasksDirectory = path + "/masks/"
images = []
for photo in os.listdir (ImageDirectory):
if ("jpg" in photo.lower()) or ("jpeg" in photo.lower()):
images.append(photo)

chunk.addPhotos(images)

for mask in os.listdir (MasksDirectory):
if ("jpg" in mask.lower()) or ("jpeg" in photo2.lower()):
chunk.importMasks(path=mask,source=PhotoScan.MaskSourceBackground,operation=PhotoScan.MaskOperationDifference,tolerance=10,cameras=chunk.cameras)


EDIT:
I found the API difference and edited my OP. How do you pass a file naming template in the path parameter? Also does the optional camera parameter work. The above code is what I presently have and it doesn't throw an error. Does the template act as a link between each image and corresponding mask or is it just to iterate through images.

Thanks,
« Last Edit: February 11, 2017, 05:24:50 AM by 2door »

gchaprnka

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Loading Masks in Photoscan 1.3.0
« Reply #1 on: June 14, 2017, 11:53:04 PM »
I'm having similiar issues here - 1.3.2. I'm trying to apply masks with identical filenames, just located in a folder called "mask".
Code: [Select]
maskPath = "C:\Temp\IMAGES\1Agisoft\mask\{filename}.jpg"

chunk.importMasks(path = maskPath, source=PhotoScan.MaskSourceBackground, operation=PhotoScan.MaskOperationDifference, tolerance=20)

It works in the gui with template "{filename}.jpg" after I pick the right /mask folder. Thoughts?