Forum

Author Topic: Applying Masks to MultiframeLayout Images  (Read 1957 times)

skearney

  • Newbie
  • *
  • Posts: 2
    • View Profile
Applying Masks to MultiframeLayout Images
« on: April 28, 2018, 10:27:59 PM »
Hello,

I'm trying to figure how to apply a different mask to each frame in a MultiframeLayout (ie, I have one camera, with N frames). My code is something like this:

Code: [Select]
listOfImages = [...] # images loaded from 'myPath/images/______.png'
chunk = PhotoScan.app.document.addChunk()
chunk.addPhotos(listOfImages, PhotoScan.MultiframeLayout)

pathToMasks = 'myPath/masks/{filename}_mask.png'

#attempt1
cam = chunk.cameras[0]
chunk.importMasks(path=pathToMasks, cameras=[cam], source=PhotoScan.MaskSource.MaskSourceFile)

#attempt2
chunk.importMasks(path=pathToMasks, cameras=chunk.cameras, source=PhotoScan.MaskSource.MaskSourceFile)

This will apply the mask to the first frame only, and no mask appears on the rest of the frames. If I select the following, in the GUI, it works as expected but I can't replicate this in python:
File -> Import -> Import Masks:
 - Apply to: All Cameras
 - Filename Template: {filename}_mask.png
 - Frames: All Frames

I don't see a way to replicate the "Frames" section in the GUI in python i.e. whether to apply to "All Frames", "Current Frame" or "custom range". I am using Photoscan 1.4.0.

skearney

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Applying Masks to MultiframeLayout Images
« Reply #1 on: April 30, 2018, 08:32:04 PM »
Update:

I didn't know how frames worked until now. I just needed the following:

Code: [Select]
for f in chunk.frames:
    f.importMasks(path=pathToMasks, cameras=[cam], source=PhotoScan.MaskSource.MaskSourceFile)