Retrieve crop/ROI subimage of Image

General discussion about topics related to OpenMV.
User avatar
kwiley
Posts: 107
Joined: Fri Dec 21, 2018 5:22 pm

Retrieve crop/ROI subimage of Image

Postby kwiley » Fri Jan 18, 2019 4:09 pm

There isn't a routine for retrieving a cropped portion (ROI) of an Image into a new Image, or an obvious way to pull a byte array out of an Image. I don't want to use sensor windowing. I want to display the larger image retrieved from the camera and only process a subportion in other ways. Ultimately, I need access to raw Image bytes, not necessarily for writing into an Image, which I realize may cause further challenges, but merely for pulling pixel values out for direct processing.

Thanks.
User avatar
kwiley
Posts: 107
Joined: Fri Dec 21, 2018 5:22 pm

Re: Retrieve crop/ROI subimage of Image

Postby kwiley » Fri Jan 18, 2019 4:12 pm

I see get_pixel(), but is there a fast way to grab runs of adjacent pixels?
User avatar
kwagyeman
Posts: 3339
Joined: Sun May 24, 2015 2:10 pm

Re: Retrieve crop/ROI subimage of Image

Postby kwagyeman » Fri Jan 18, 2019 11:10 pm

If you need to do pixel processing just edit the firmware in C. There's no fast way to do this in python. You can use the python get_pixel() if you want but it will be very slow. It doesn't even matter if you get a row of pixels at the same time, python can't deal with the array.

As for getting a subwindow of the image. See the copy method. This can create a crop of the main image. One of the upgrades for the H7 model I am going to do is make this also allow scaling too.

Please keep in mind you are on a microcontroller. Alot of our algorithms only work through careful coding in C to not run out of RAM. We don't really allow the most general utilization of RAM for images on purpose because when we started the project on the M4 the RAM was too small to hold really any image on the heap. On the M7 this restriction was eased and on the H7 (which is coming soon) the restriction is more or less reduced which is why I will be adding the feature.

...

Since you are a software programmer our C environment is actually nice and easy to use and edit the firmware to do what you want. It's not really that hard to add a new method that you can invoke in python and do whatever you want.

There are also plenty of examples in C from our image lib on how to write an algorithm that runs very fast. If you've got the camera and a USB cable this is all you need.
Nyamekye,
User avatar
kwiley
Posts: 107
Joined: Fri Dec 21, 2018 5:22 pm

Re: Retrieve crop/ROI subimage of Image

Postby kwiley » Sat Jan 19, 2019 2:40 am

Thank. I'm sure I'll get to the point where I push my routines down to lower levels, but at the tinkering stage, that would be a premature optimization. I don't yet know which methods I'll need. Right now, my bottleneck appears to be secondary SPI devices, so nothing much of the Python running on the M7 is of stark impact for the time being. I'm just fleshing out the basic algorithms at the current time.

Return to “General Topics”

Who is online

Users browsing this forum: No registered users and 1 guest