Forum

Applying Masks to MultiframeLayout Images

Started by skearney, April 28, 2018, 10:27:59 PM

Previous topic - Next topic

skearney

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:

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

Update:

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

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