I’ve been developing a 3D printed weatherproof enclosure for the Raspberry Pi HQ camera. It includes a stepper-motor driven mechanism for adjusting the lens focus and aperture remotely. The mechanism works very well, but I still have one problem left to solve and I am hoping that OpenCV might provide a solution.
I need to automatically detect and set the limits of travel so that the stepper motors don’t try to force the adjustment rings further than they can go. When you adjust the focus the entire image changes until you hit a stop, and then it will stop changing. So I’m wondering if I can use OpenCV to detect when that happens. The stepper motor limits would usually be set only when the system is powered on.
It seems to me that OpenCV would have to use the entire image to determine if the focus is changing, because the camera could be pointed at an object that’s moving. It also can’t be fooled so that it keeps operating the motors if the camera is operating in total darkness, or if the lens cap is on.
Could this be done relatively easily? If so, can you point to some resources that will help me implement this? I don’t have much experience with OpenCV, but I can usually figure things out if I get started on the right path.
BTW, next step after this will be figuring out how to use OpenCV to autofocus the camera.