Pan/Tilt + Motorized zoom


I am in the planning stages of a project that will track a ball that travels parallel to the field of view (as opposed to across it.) Imagine the camera is mounted to the top of a soccer/football goal and it is tracking a ball kicked by the goalkeeper. I’d like to use the OpenMV camera to track the ball as it flies using a Pan/Tilt mechanism and a motorized zoom lens like this:

Is this feasible? The pan/tilt mechanism would try to keep the ball in the center of the FOV. The lens has three separate motors that control the iris, zoom and focus. In looking through the documentation, I’m thinking the zoom and iris control should be pretty straight forward. I’m wondering what I’d use to maintain focus on the ball through its flight. Do you have any suggestions for this, or comments on the overall approach and/or concept in general?


Hi, this is really easy. You just use find blobs and track the largest blob. Then you have a PID loop on the X/Y and pixels within the blob that control pan, tilt, and zoom.

As for the service control we sell a pan and tilt shield that you just have to add power to and a mounting system with the servos. The OpenMV Cam can control the service directly.

Thanks so much for the response. That’s what I gathered. As for adjusting the focus as the zoom increases while the ball flies, is there any functionality that could detect the “blurriness” of the blob? Also, since the motors driving the lens motors are regular 8 VDC motors, I would have to control them with a separate interface, right? And, is there a minimum blob size to maintain? After the lens runs out of zoom, the bob will continue to get smaller. Increasing zoom increases lens cost, so I’d like to understand if the blob size has a lower limit.

Thanks again!

Um, actually, I plan to add back a method called get_fft_histogram() which can be used to detect the sharpness of an ROI. I wrote the code for someone on the forums before but it never made it into a release. I’m doing firmware updates right now so I’ll make this something to fix. Please get a GitHub issue for me to remember to add this back.

Basically, you can calculate the image MTF which is a score for blurryness. Then, you just try to maintain a zoom that keeps the score at an optimal setpoint. That said, this is an unstable system. I.e. you can’t tell how to change the zoom (+/- focal length increase) to make the image not blurry. You can only tell when it gets worse and better. So this is a slightly more complex PID loop based on the dervative of the MTF over time.

Ok, cool. Thanks! So the MFT is one of the results of the FFT calculation? Good point re: the instability. This will require some tweaking, but hopefully since the zoom and focus are separately controlled it may make it easier to manage. Also, the fact that the ball will always be moving away from the camera should help as well.

Is there a minimum blob size for which this will stop working? After the camera can’t zoom anymore, the ball will start to get smaller and smaller. I can buy a bigger lens but want to limit cost if I can.

Thanks for the detailed and quick responses!

Plus one from me for the blurriness functionality i.e. get_fft_histogram() over an ROI

Give me a bit then to add this.