Can I control camera focus, disable autofocus, and set focus distance via Python?

Hi, I’ve got an Arducam B0478C USB3 UVC camera and I’m trying to control the focus from a Python script. Can autofocus be disabled? Can I set focus to a specific distance? Also, are there any other focus settings I can change through Python? I haven’t found a clear answer, so hoping someone can point me in the right direction.

Welcome! Before I point you anywhere, can you share a bit about your setup? OS, Python version, OpenCV version, and how you’re opening the camera would all help. Also, if you’ve got any code you’ve tried or error messages, paste them so we can see what’s happening.

Sorry, I don’t have much to share yet. I haven’t really written anything because I wanted to make sure focus control was possible first. No code or logs to paste, and I’ve only done some basic VideoCapture tests. Just trying to figure out the right approach before I start.

No worries. Focus on the B0478C is exposed through UVC, so it should be reachable from OpenCV. The official Arducam docs cover this in the Python OpenCV demo section of the USB3 UVC Camera Kit Quick Start Guide for Windows: Start USB3 UVC Camera on Windows - Arducam Wiki

Thanks, I’ll go through that demo and see what I can get working.

Sounds good. To summarize what you’re looking for: the Python/OpenCV demo in that guide covers the focus-control options for the B0478C UVC camera, including disabling autofocus and setting a fixed focus distance. Work through it and you should get the properties and values you need from your script. If you run into a specific error once you’ve got code going, post it here and we can dig into it.