Lid Detection Project

Hey, for school I am working on a project to open and pour a beer can in to a cup. For the opening of the beer can the lid needs to get detected so that it can get rotated in the right direction to get opened. To detect the lid we are using an Arduino Nicla Vision and I want to use either Edge Impulse for smart detection or detect the lid in Python by using the edges of the lid. But I am facing some problems. First the output of the GPIO pins is too low to trigger a relay and I’ve also tried an optocoupler but I couldn’t figure it out. Then for the detection I tried using detecting the oval shape inside the lid but the light incidence is a bit of a problem. Another option I had was Edge Impulse by creating a model of beer can lids, but this is quite time consuming and not sure if it even works so if anyone knows another solution/can help me that would be great!

Thanks in advance :slight_smile:

Hi, you can use find_circles() to find the lid. To deal with the angle issue I suggest using the: image — machine vision — MicroPython 1.19 documentation

There are some examples showing off what it can do. But, basically it can rotate the image such that the angle that you are looking at the can from is removed from the image. In particular, use the corners feature that has a snippet of example code in the documentation. What you want to do is called a bird’s eye view transform.

As for driving the motor, I believe I answered that in your other post.

Hi, I tried detecting the lid using OpenCV and got it working but i just found out that this is not compatible with the Nicla Vision and I want to rewrite my opencv code to openmv by using the find_circles() function but it can’t detect the lid and I don’t really know which parameters I need to adjust.
Here is my current code: (1.2 KB)

Hi Koen,

I can’t debug a script for you. You need to ask a question about what exactly is wrong. The find_circles() method works based on a Hough transform. The parameters for the method are all related to the edge strength.

So, if you turn the edge detection thresholds down you should see it find a lot of circles. Starting from that you can tune the parameters.

This kinda needs to be done by you live an iteratively. I don’t really have the ability to help other than to clarify things.