Forum

Author Topic: Export Masks  (Read 5365 times)

Paulo

  • Hero Member
  • *****
  • Posts: 1381
    • View Profile
Export Masks
« 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....
Best Regards,
Paul Pelletier,
Surveyor

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15236
    • View Profile
Re: Export Masks
« Reply #1 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"
Best regards,
Alexey Pasumansky,
Agisoft LLC

Paulo

  • Hero Member
  • *****
  • Posts: 1381
    • View Profile
Re: Export Masks
« Reply #2 on: March 25, 2020, 10:56:24 PM »
Thanks a lot, Alexey,

that was the problem!
Best Regards,
Paul Pelletier,
Surveyor

Rach3d

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Export Masks
« Reply #3 on: May 15, 2024, 12:39:24 PM »
Hello, I'm trying to write a script to export masks but i'm newbie in python scripting. I'm interested if you have already wrote something to do so  ? thanks

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 15236
    • View Profile
Re: Export Masks
« Reply #4 on: May 15, 2024, 04:00:29 PM »
Hello Rach3d,

Are there any requirements for mask export (file naming, image format and etc.)?
Best regards,
Alexey Pasumansky,
Agisoft LLC