Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: fengkan on February 25, 2014, 10:17:41 AM

Title: how to add mask
Post by: fengkan on February 25, 2014, 10:17:41 AM
I am wondering whether I can add different masks to photos.
something Like,

Code: [Select]
chunk.cameras.add("01.jpg")
chunk.cameras.setMask("01_mask.jpg")
chunk.cameras.add("02.jpg")
chunk.cameras.setMask("02_mask.jpg")

And what format is Mask image supposed to be?


Title: Re: how to add mask
Post by: fengkan on February 25, 2014, 12:58:35 PM
I figured the mask format out by exporting the existing ones.

And as for the script, I think below may do the work.

Code: [Select]
new_chunk = PhotoScan.Chunk()
p = PhotoScan.Camera()
p.open("/01_1.jpg")
m = PhotoScan.Image()
m.load("/01_1_mask.png")
p.setMask(m)
new_chunk.cameras.add(p)
new_chunk.matchPhotos(filter_mask = True)

Although I am not sure whether this is a standard way to do that.

Wish there were some samples about this.