Forum

Author Topic: How to use the setMask() function ? [Solved]  (Read 4606 times)

Clement

  • Newbie
  • *
  • Posts: 3
    • View Profile
How to use the setMask() function ? [Solved]
« on: February 11, 2015, 05:11:11 PM »
Hello everyone,

I'm working on a project in which I need to create a pipeline to extract 3D points of an object.
My first script works, but now I would like to take in count some masks, my own masks files, before align cameras.

So, I have my photos in a folder, my masks in another, now I would like to apply  my masks on photos.

A solution, could be use the setMask() function : (http://www.agisoft.com/forum/index.php?topic=2101.msg11113#msg11113 , http://www.agisoft.com/forum/index.php?topic=2491.0  ; however I don't find it in the documentation 'photoscan_python_api_1_1_0.pdf'.  :-[

Thanks a lot for your help.

Clément.

PS. I'm working with Ubuntu and the Professional Edition of PhotoScan, and sorry for my approximative English.  ;D
« Last Edit: February 12, 2015, 04:39:44 PM by Clement »

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: How to use the setMask() function ?
« Reply #1 on: February 11, 2015, 06:54:12 PM »
Hello Clement,

I think it should be something like this:
Code: [Select]
for camera in chunk.cameras:
mask_path = camera.photo.path[:-4] + "_mask.png"
image = PhotoScan.Image()
image.open(mask_path)
mask = PhotoScan.Mask()
mask.setImage(image)
camera.frames[0].mask = mask
Best regards,
Alexey Pasumansky,
Agisoft LLC

Clement

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to use the setMask() function ?
« Reply #2 on: February 12, 2015, 12:26:04 PM »
Thank you for your fast response !

I have tried your solution, but an other problem appeared ...
a message error appear on the "setImage()" line : "Type Error: setImage(): 8bpc color depth required".

In fact, the problem seems to come from image opening, because the code  following code
Code: [Select]
image = PhotoScan.Image()
image.open(mask_path)
print('height = ' , image.height)
gives :
Code: [Select]
heigth = 0
My 'mask_path' is good: I can open this file with Ma....lab.

I have tried different options (layer, channels etc..., jpg, png), nothing ...
Did you ever see this ?

Thanks for your support,

Clément



Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: How to use the setMask() function ?
« Reply #3 on: February 12, 2015, 12:28:20 PM »
Hello Clément,

Could you please send any mask image to support@agisoft.com, we'll check it on our side.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Alexey Pasumansky

  • Agisoft Technical Support
  • Hero Member
  • *****
  • Posts: 14813
    • View Profile
Re: How to use the setMask() function ?
« Reply #4 on: February 12, 2015, 01:22:40 PM »
Hello Clément,

I think that using image = image.open(path) should fix the problem.
Best regards,
Alexey Pasumansky,
Agisoft LLC

Clement

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: How to use the setMask() function ?
« Reply #5 on: February 12, 2015, 04:39:24 PM »
Perfect, it works !

Thank you !

See you next time,

Clément