Creating ROI mask of polygons drawn by image.draw_edges

Hi.

I would like to create a ROI mask of polygons produced from blob.min_corners(). I can currently draw these polygons using img.draw_edges() but I also want to fill the areas inside these polygons. Unlike the other drawing functions, img.draw_edges(…, fill=True) doesn’t fill the area formed by the edges but it does something else. I want to do this because I want to be able to extract the pixels inside these polygons by subtracting the mask from the image frame. Could you assist me in how to do this?

Thanks in advance

Ah, we don’t really have this feature right now. I have scheduled an overhaul to all drawing methods to improve speed and add anti-aliasing this year. I can add the ability to fill polygons too.

In the mean-time… mmm, yeah, there’s no fast way to do this in python. You’d have to write a for loop to iterate over the pixels in the area and extract them. Which will be very slow.

Are you comfortable editing the C code?

Hi.

Yes I’m able to edit C code, could you point me to the right direction on how to achieve it? Thanks

Get started here: openmv/src at master · openmv/openmv · GitHub

Once you have compile working you want to make a new method in src/omv/imlib/draw.c

Hi, it looks like the complexity of the source code is a lot higher than my experience with C/C++ which was quite a long time ago since I picked it up in the university. Actually, the application I have in Python uses the OpenCV.ApproxPolyDP() function to approximate a free form mask of an object detected using canny edge detection followed by erosion and dilation methods (closing). I found that most of the functions I used in Python have their equivalences in OpenMV except the ApproxPolyDP() function, and because I don’t have enough knowledge in C/C++ to understand the implementation of this function in OpenCV and to redo it in OpenMV, could you help enable that function in OpenMV? Thanks in advance and looking forwards to your reply.

Hi, this would be over a year out on the todo list. We have been overhauling drivers and more basic methods right now to achieve the maximum speed on the system. Higher level methods like this are going to be in waiting for a while.