Agisoft Metashape

Agisoft Metashape => Python and Java API => Topic started by: Paulo on March 25, 2020, 06:58:16 PM

Title: Export Masks
Post by: Paulo on March 25, 2020, 06:58:16 PM
Hi all,

I am trying to develop a script to Export masks as in GUI:

- file type set to Single channel mask image;
- file name template set to {filename}mask.png;
- apply to All cameras;
- and set to  C:\Users\paul.pelletier\Downloads\ASV_Demo4-5m-blurred\Out folder.

In Python reference, I can only find Tasks.ExportMasks.

for this I define:
Code: [Select]
task = Metashape.Tasks.ExportMasks()and define the cameras to apply task to with:
Code: [Select]
task.cameras = [camera.key for camera in chunk.cameras]and try to define path as:
Code: [Select]
task.path =’C:\Users\paul.pelletier\Downloads\ASV_Demo4-5m-blurred\Out\{filename}_mask.png’but i get following error:
task.path =’C:\Users\paul.pelletier\Downloads\ASV_Demo4-5m-blurred\Out\{filename}_mask.png’
                ^
SyntaxError: invalid character in identifier

and where do I define file type^?

Please help as I am lost....
Title: Re: Export Masks
Post by: Alexey Pasumansky on March 25, 2020, 08:26:56 PM
Hello Paul,

I recommend to use "/" or "\\" instead of "\" (single backslash) symbol in the path string.

Also make sure that the quotes sign are conventional symbols and are not some special characters.

Try this line instead:
Code: [Select]
task.path = "C:/Users/paul.pelletier/Downloads/ASV_Demo4-5m-blurred/Out/{filename}_mask.png"
Title: Re: Export Masks
Post by: Paulo on March 25, 2020, 10:56:24 PM
Thanks a lot, Alexey,

that was the problem!