Forum

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - SensorFusion

Pages: [1]
1
Python and Java API / Re: Create custom mask
« on: March 24, 2020, 11:49:08 AM »
I found a workaround: Creating an image file as mask and set it to the camera. But perhaps it is possible to set the rectangle directly?
Code: [Select]
from PIL import Image, ImageDraw

def createFullMaskFor(camera):
    width = int(camera.photo.meta["File/ImageWidth"])
    height = int(camera.photo.meta["File/ImageHeight"])
    img = Image.new("RGB", (width, height))
    draw = ImageDraw.Draw(img)
    draw.rectangle(((0, 0), (width, height)), fill="black")
    name = "MASK.JPEG"
    img.save(name, "JPEG")
    newMask = Metashape.Mask()
    newMask.load(name)
    camera.mask = newMask

2
Python and Java API / Re: Create custom mask
« on: March 17, 2020, 11:10:30 AM »
Does anyone have an idea? Or do I need to create my masks as PNG-files and then load it? Is this the only way to create a mask?

3
Python and Java API / Re: Get Started with Python API
« on: March 12, 2020, 03:03:59 PM »
I need to "draw" it. I want to specify a rectangle on pixel base. Like this
Code: [Select]
Rect(left = 0, top = 0, right = 200, bottom = 200).and then add it to an image as mask.

4
Python and Java API / Create custom mask
« on: March 12, 2020, 12:47:35 PM »
I am just starting to use the python API and have some problems.

I wanted to test if i can add a custom masks to an image.
Code: [Select]
    doc = Metashape.Document()
    doc.open(pathToProject)

    for camera in doc.chunks[0].cameras:
        # create mask out of rectangle       
        newMask = Metashape.Mask()
        camera.mask = newMask

How can i create a custom mask? For example a rectangle. How would i do it?

If i want to see the signature of Mask() the following appears in my IDE:
Code: [Select]
def __init__(self, *args, **kwargs): # real signature unknown

Pages: [1]