Agisoft Metashape
Agisoft Metashape => Python and Java API => Topic started by: lmg on April 24, 2014, 06:57:51 PM
-
I wish to make automatic masks using always the same background color (blue) positioned on the back of the subjects.
I have seen in the python api the command "createDifferenceMask", that could create a mask from a pair of images or an image and specified color.
Please, could you explain and/or give an example on the use of the following parameters:
• image (Image) – Image to be masked.
• background (Image or color tuple) – Background image or color value.
• tolerance (int) – Tolerance value.
• fit_colors (boolean) – Enables white balance correction.
Do I need to create a template image with having only the background ("blutemplate.ipg") and then subtract this image from the subject image ("subject.ipg")? How to write in a python api this task?
-
Dear lmg,
You can use a tuple of three numbers to define the background color instead of using artificially generated background image. The color should be represented as follows (R, G, B), where each color is in 0 - 255 interval.
-
I have written 2 python scripts. The first one (prova_mask1.py) works with 1 camera and it works fine.
The second one (prova_mask4.py) works with 4 cameras, but in the chunk only last camera is included.
Alexey, Could you tell me where is the mistake in the scripts?
Thank you very much.
-
I think that happens since photo variable is not reset after each photo import step, so I suggest that photo = PhotoScan.Photo() line should be added prior to photo.open() function in the current implementation. But it would be better to use for statement reducing the code size.
-
Thank you Alexey,
problem solved. I have added the line photo = PhotoScan.Photo() prior to each photo.open() function, and now the script works well.
Bye