Running into a weird issue with my Arducam IMX477 12MP PTZ camera on a Raspberry Pi 4B with Raspberry Pi OS Bullseye 64-bit. Manual PTZ control via wasd works, manual zoom and focus work fine. But when I run FocuserAutoFocus.py, I hear a slight ringing and some faint grinding, but the lens never actually moves. The autofocus just doesn’t do anything. Has anyone else seen this?
Thanks for the report. Just to make sure we’re looking at the same thing, can you confirm the exact script and repository you’re running? There’s a FocuserExample.py (manual) and a FocuserAutoFocus.py in the PTZ-Camera-Controller repo. I’ve attached a screenshot of the one I think you mean. Also, does the manual focus in FocuserExample.py move the lens smoothly, or does it also sound rough?
Right, the repo is GitHub - ArduCAM/PTZ-Camera-Controller · GitHub and the failing script is FocuserAutoFocus.py. FocuserExample.py works for manual control — wasd, zoom, and manual focus all fine. Only the autofocus script misbehaves: faint ringing/grinding, no real movement, and it’s intermittent and unstable overall.
Here’s my full setup in case it helps. Clean Raspberry Pi 4B, Bullseye 64-bit (I need 64-bit):
sudo apt-get update
sudo apt-get upgrade
sudo apt-get full-upgrade
sudo reboot
sudo nano /boot/config.txt
In config.txt I disabled camera auto-detect and set the overlay. For IMX219 you’d use:
Automatically load overlays for detected cameras
camera_auto_detect=0
dtoverlay=imx219
For the IMX477:
Automatically load overlays for detected cameras
camera_auto_detect=0
dtoverlay=imx477
Then:
sudo reboot
dmesg | grep imx
libcamera-hello --version
sudo modprobe i2c-dev
sudo nano /boot/config.txt
and added at the end:
[all]
dtparam=i2c_vc=on
Then reboot and:
sudo apt-get update
sudo apt-get upgrade
sudo apt-get autoremove
sudo apt install -y python3-libcamera python3-kms++
sudo apt install -y python3-pyqt5 python3-prctl libatlas-base-dev ffmpeg python3-pip
pip3 install numpy --upgrade
pip3 install picamera2
sudo apt install -y python3-opencv
sudo apt install -y opencv-data
dmesg | grep imx gives:
[ 8.527510] imx477 10-001a: Device found is imx477
[ 8.528280] imx477 10-001a: Consider updating driver imx477 to match on endpoints
libcamera-hello --version gives:
libcamera-apps build: 35266e84043f 07-07-2022 (17:59:45)
libcamera build: v0.0.0+3700-f30ad033
So manual control works but autofocus doesn’t. Is FocuserAutoFocus.py actually compatible with Bullseye 64-bit, or is the autofocus logic assuming something else?
Thanks for the full dump, that’s helpful. The ‘Consider updating driver imx477 to match on endpoints’ line in dmesg is a known harmless warning and shouldn’t affect this. The fact that manual focus moves fine but autofocus only grinds suggests the script’s autofocus routine is sending very small steps or bouncing around the current position instead of doing a proper sweep.
Let me dig through the autofocus logic in the repo. Give me a little time to check the current code against what you’re running.
Just to be clear, the script I’m running is FocuserAutoFocus.py from GitHub - ArduCAM/PTZ-Camera-Controller · GitHub. The screenshot you posted earlier looked like it might be from a different repo — do you have a link to that one? I want to make sure I’m not looking at outdated or mismatched code. Happy to try whatever you suggest in the meantime.
Let me verify which branch/tag that screenshot came from and I’ll get back to you. In the meantime, could you run FocuserAutoFocus.py again and watch the console output? If it prints the focus position or step values while it’s making that grinding sound, paste that here. That’ll tell us whether it’s stuck in a loop instead of actually stepping through the focus range.
Still no luck with the autofocus. Manual PTZ control and taking pictures work, but AutoFocus still just makes that faint grinding sound and doesn’t move. I’m on aarch64 (Bullseye 64-bit) if that matters.
Separate question while I’m here: are there any STL or 3D print files for an enclosure for the IMX477 PTZ camera? I couldn’t find any.
I’ve updated the PTZ-Camera-Controller project on GitHub. Please redownload it from GitHub - ArduCAM/PTZ-Camera-Controller · GitHub and run FocuserAutoFocus.py again — the autofocus routine has been changed, so the behavior should be different from what you saw before. Let me know if it moves now or if you get different output.
On the enclosure: we don’t have 3D print files for the IMX477 PTZ camera, sorry.