Would it be possible to perform the canny edge detection just inside a roi?

I’m starting to play with the OpenMV (thanks for that great project, I’m super newbie in Python, MicroPython and also in Machine Vision).

I have noticed that if I try to run the canny edge detection example with VGA resolution the IDE shows the following message:

MemoryError: FB Alloc Collision

Is it possible to bypass this by performing the canny edge detection just in a part of the image?


Technically, there’s no limit for this. However, we don’t have a method yet to resize/crop a part of an image (one isn’t there because we’ve been feature creeping to basically have full blown OpenCV on the camera). Anyway, please create a feature request for this on github to make sure it makes it into the firmware.

That said, you can use sensor.set_windowing((x, y, w, h)) to set a cropped part of the VGA image. This gives you just one smaller image and will let you use the method. If that works for you… i.e. you just wanted a lot of detail then just do that. Otherwise, if you need to canny the full image it’s not possible given our limited RAM.

Hi, there’s a bug in Canny edge ROI, the code allocates the gradient array for the whole image (regardless of ROI). It’s now fixed and I confirmed it works on OMV3, 4 and will be included in the next release.

The thing is that I’m not sure if Canny Edge would be the best solution for my project.

As the OpenMV doesn’t need a computer or an Arduino to control a relay, I wanted to use it to control the production of a machine.

I have recorded two little videos of the machine working (one with good pieces after a process and one with a bad one):

In this example I’m using the IR leds, but they shine too much, I guess that I’ll have to use an external IR light source)

This one would be an example of a malformed spring after the process. I want to activate a relay when the camera gets something different to an empty hole or a hole with deformed springs:

I’ve tried with the circle detection, but I guess that my searching area is too big and it crashes if I want to use QVGA resolution.

I don’t know if comparing the image with a pattern would be effective, as there are holes without springs (and it’s ok).

Any recommendation would be truly appreciated.

This is a great example where the problem can be easily solved. Is there a particular area under which you want to do the detection? If so, capture the picture when everything is perfectly aligned and then use template matching to compare against an empty hole. If the hole is not empty… I.e. a template is not found to match… then you you activate the relay.

You just need to align the machine to the area you want to detect and then save a cropped part of the image where the spring is. Then, execute the find_template method on that same cropped area.

Also, turn your exposure up to get rid of the highlights.

Thanks for the answer.

I just need to check one hole at time, so my ROI could be something like this (or even smaller):

I’m doubting about the triggering. I’ll have to test if I can use the find_circle feature to determinate if there’s a whole hole in a certain region, take the picture of that area and then compare it against a template.

Oh, I didn’t noticed that there was an exposure setting. Cheers!

Greets from Barcelona

Only the new global shutter camera on the H7 can trigger. It’s designed for what you are doing however versus the OV7725 camera which is the default (and only camera on the M7).

Anyway, think of the camera as a sensor… so, if you control where the pixels you care about are it’s quite easy to make it reliable and good at detecting stuff.