by blagie · 3y ago · 0 comments
Many (perhaps most) off-the-shelf webcams do allow you to control focus, but aren't C-mount, and you're stuck with their lens and their preprocessing.
For what I do, webcam preprocessing makes it almost useless for my applications. Almost all are auto-something, and I don't need exposure or white balance changing once I've calibrated lighting and a machine vision pipeline. Many do nominally have manual exposure and white balance controls, but I've had poor luck finding ones where I have consistency at the level of a module like an ELP.
If you're willing to hack or forgo OpenCV integration, it's ridiculously easy to control C-mount lenses with electronic focus control. That's what I did when I needed to do this. You can look on eBay for something like a vintage Computar TV Zoom Lens (and documentation on Computar's web site still existed when I did this). Prices vary, but when contractors rip out ancient surveillance systems, these can be had for a song.
Or you can splurge, and get a 20x zoom f/1.8.
The ones I bought, it's literally just applying a voltage to a pair of wires to make it zoom or focus in one direction or the other. You just need a few GPIO pins, and to step up the voltage to what it needs (I'm inclined to say 12V, but it might be 5V; it's been a while -- but from not recalling, you can see how easy this was; if this was a week project, I'd remember).
What you really want is a module with the same interface as something like the Computar, which I know exist, but I've never used, so I can't recommend them one way or the other.
And it'd be easy to hack into OpenCV if you really wanted.