ROI processing

Discussion related to "under the hood" OpenMV topics.
Posts: 19
Joined: Thu Jan 10, 2019 9:40 pm

ROI processing

Postby Jivrik » Sun Jan 27, 2019 8:37 pm


Is it possible to apply some operations in the ROI after you have the image from img = sensor.snapshot()?

I mean : I draw a rectangle inside my img , and i only want to apply filters for everything inside the rectangle (ROI).

Thank you!
User avatar
Posts: 4434
Joined: Sun May 24, 2015 2:10 pm

Re: ROI processing

Postby kwagyeman » Sun Jan 27, 2019 9:50 pm

The best way to do this is to use the copy() method with an ROI to pull out the image patch. Given memory limits this is a challenge if the patch is large.

To make this easier I'm redoing the copy operation so you can target larger allocated frame buffers to allow for large images.

Otherwise, the only way to do this is to create a pixel mask for the image that has 1 pixels where you want to operate. Binary image functionality hasn't been fully released yet however. But, basically do this...

Code: Select all

bimg = img.to_bitmap(copy=True).clear().draw_rect(x, y, w, h, fill=True, color=1)
img.mean(2, mask=bimg)
Binary images are quite small so they might make the most sense. Since it's a mask you can select whatever pixels you want.
Posts: 19
Joined: Thu Jan 10, 2019 9:40 pm

Re: ROI processing

Postby Jivrik » Mon Jan 28, 2019 8:32 pm

Thank you! I will give this a try.

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests