Hi, I’m running an Arducam IMX219 8MP Autofocus USB Camera Module (3280x2464 @ 30fps with the single microphone) on a Raspberry Pi with Klipper. Video comes through fine and brightness/exposure respond, but the focus won’t move at all — neither manual focus nor autofocus changes anything. When I run v4l2-ctl the values change in the terminal, but the actual focus never does. I’ve been following RaspberryPi/Motorized_Focus_Camera at master · ArduCAM/RaspberryPi · GitHub. Current settings: auto_exposure=3, focus_automatic_continuous=0, brightness=100, focus_absolute=100.
Thanks for the details. The autofocus on this module is exposed through the UVC camera controls, so let’s start by confirming it responds at the control level. Can you install qv4l2 on the Pi and open it, then enable/disable autofocus in the camera controls and see if the focus physically moves? Something like sudo apt install qv4l2 on standard Pi OS. There’s a quick-start reference here: https://docs.arducam.com/UVC-Camera/USB3-UVC-Camera-Kit/Quick-Start-Guide-for-Linux/#qv4l2
So qv4l2 installed without errors, but my Klipper image has no GUI at all, so I can’t actually launch the qv4l2 window. I rebooted anyway and nothing changed. I also tried stepping focus_absolute from 255 down to 0 and the picture never changed, and autofocus does nothing either. focus_automatic_continuous shows as 1; setting it to 0 and then setting focus_absolute to any value in range produces no visible difference. It also feels intermittent/unstable overall. I tried pulling some extra files from the GitHub repo but couldn’t get picamera2 and opencv-python installed.
That helps narrow it down. Since qv4l2 needs a GUI and Klipper doesn’t have one, let’s verify the camera hardware on its own first. Connect the camera to a regular PC and test with AMcap.exe — check whether autofocus actually works there. That’ll tell us if it’s the camera itself or something on the Pi/Klipper side. I’ve sent you the AMcap download link in a private message.
OK, I tested it on a Windows PC with AMcap.exe. Autofocus showed as enabled in settings but wasn’t actually doing anything. I disabled it and then re-enabled it, and it started working in AMcap. So the hardware does autofocus. But my real setup is Klipper on a Pi with no GUI — the web interface is Mainsail — so I need a terminal-based way to control autofocus on Linux.
Good, that’s a strong clue — the autofocus needed to be toggled (disabled then re-enabled) before it kicked in. You can do the same from the terminal on the Pi. I tested this on a Pi here, and the sequence is:
v4l2-ctl -d 2 -c focus_automatic_continuous=0
v4l2-ctl -d 2 -c focus_absolute=255
v4l2-ctl -d 2 -c focus_automatic_continuous=1
v4l2-ctl -d 2 -c focus_absolute=255
First command disables autofocus, second sets max focus (the preview should go blurry), third re-enables autofocus (preview should refocus and clear up). The last one should now fail with ‘VIDIOC_S_EXT_CTRLS: failed: Permission denied Error setting controls: Permission denied’. That error is actually expected — while autofocus is on, setting focus_absolute is blocked, and it confirms autofocus mode is active. Try the same on Klipper; the preview should show up in the Mainsail web interface.
I ran those exact commands and there’s no change to the camera at any point. Focus never gets better or worse. Attached a screenshot of my terminal window.
The Permission denied on focus_absolute while autofocus is on is consistent, but if the image never changes then something in the Klipper/Mainsail setup may be interfering. A terminal screenshot alone doesn’t let me see what the camera is doing though. Could you attach the actual camera stream, not just the terminal? I’d also post this on the Klipper forum — we haven’t used Klipper ourselves, so I can’t tell whether its APIs block autofocus in the web interface, but others there may have hit the same thing. If nothing pans out, an M12 Lens UVC camera might be a more predictable option than the autofocus module for that setup.
Appreciate the help. I’ll look into the Klipper forum and the other options from here.