Circle detection in a certain position

Hi everyone,

Let me begin by saying I have no electronic/programming background at all, and this is my first time near anything programmable. I’m a mechanical engineering student working on a group project at the moment.

What I am trying to do is get the camera to detect the hole of a rugby ball in a predefined position, once the hole is in the position the camera would send a signal to an Arduino Uno board, which will trigger some actuators to move. If anyone could point me in the right direction to achieve this it would be most appreciated.

Hi, you don’t need the Arduino in the the loop. The OpenMV Cam can directly control motors itself.

As for detecting the hole. We have a find_circles() example script which automatically searches the image for all circles and returns a list of them to you. Then you just need to filter out circles which are not in the right place and turn an I/O pin high or low to drive the motor.

Anyway, to start with please setup a test rig with the OpenMV Cam looking at what you want it to look at. Then, please provide me with some details on what you want to drive.

Thanks for getting back to me so quickly.

The reason for the Arduino I was told is because the actuators are 24V pneumatic and relays will be involved.


So this is the general set up (imagine that the picture frame, white tac and emery board are an aluminium frame)


This is what I am trying to detect,the hole in the centre.

What follows is the basic operation:

The camera, attached to one actuator, is in position above the holder for the ball. This holder is an XY table which will be adjusted to ensure the hole is in the correct position.


Once the hole is in the correct position, the actuator with the camera retracts, and the 2nd actuator now extends, inserting a needle into the hole.

After a certain amount of time has passed, the 2nd actuator retracts, and the camera returns to the home position.

Okay, great. So, see the pin control example script in the File->Examples->Board control directly and that’s how you can make an IO pin high or low. As for timing, see the pyb module documentation for how to delay for some number of seconds or milliseconds.

To control the actuator you need a relay or some type of amplifier. The OpenMV Cam can drive a wire to 3.3v or 0v. You need to use a transistor to control a relay to control the solenoid.

E.g. https://i.stack.imgur.com/sMX7r.png.

Raw would be 5v, and then you have the 24vdc isolated along with the solenoid on the other side of the relay so it can’t break anything. You’d have the OpenMV Cam drive into the resistors going to the transistor.

Note, you can buy circuits that have this all in one.

Do not connect 24vdc anywhere near the camera except on the other side of the relay. The OpenMV Cam is 5v tolerant… But will explode with 24vdc applied to any of it’s pins.

Please work to get to the point where you can get the OpenMV Cam turning the relay and the solenoid off and on in a loop. Once you’ve gotten to a point where you have good control over what you need we can move to the vision part.

This project is really interesting for me, I just need the same application, but instead of goes down with the needle, with an expandable shaft.

Is possible to get the code and a guide step by step?

Regards;