Hi all, hoping someone can point me in the right direction. I’m running several Arducam IMX219 8MP Autofocus USB Camera Modules (3280×2464@30fps) on a Raspberry Pi 4B with Raspberry Pi OS bullseye, capturing with fswebcam.
The problem is out-of-focus images. Some cameras come out blurry even with focus_automatic_continuous=0 and focus_absolute=0 set. One camera isn’t detected in the device list at all. Another one that’s tilted downward on a pole at about 7 ft can’t get a clear image using autofocus.
Setting focus_automatic_continuous=1, capturing a few pictures, then setting focus_automatic_continuous=0. That got most cameras to produce clear images, but not all of them.
Same camera and settings give the image I want on my laptop, but not on the Pi 4B.
I reduced the tilt to zero angle from the vertical pole and moved the camera to ~5 ft. Clearer, but still not as clear as the lower-mounted cameras.
Tested the USB cable with another camera - cable is fine.
Thanks for laying all that out. The trick you found - let autofocus run (focus_automatic_continuous=1), take a few frames, then lock focus_automatic_continuous=0 - is a pretty standard way to get these modules to land on a sharp position, so it’s not surprising most units improved.
For the camera that isn’t detected at all, can you plug it in and check lsusb and dmesg | tail? That should tell us whether the board is enumerating at all or throwing errors.
The tilted one is interesting. 7 ft is a long working distance for this lens, and reducing the angle/height helping suggests the unit is struggling to settle in its focus range, not a cable or host problem. Do the units that do show up have any other symptoms?
Separate but related issue on the same IMX219 modules. With auto exposure the images are a lot brighter than when I use manual exposure with max exposure time. I’ve looked around but there’s not much out there about manual exposure and the exposure time/value controls on the IMX219.
I reproduced this on the same module and I’m seeing the same thing - auto exposure is much brighter than manual exposure with max exposure time. My current theory is that auto exposure is also bumping the gain value, not just the exposure time, so the overall brightness ends up higher. That probably needs more analysis to pin down, but it matches the behavior.
The -S part you found is the important bit. In the first few frames the camera is still doing exposure-related settling, and after a few frames the picture becomes stable. So skipping the initial frames before the capture is exactly the right approach for manual exposure.
and add the -S flag to skip the first few frames (something like -S 5 or -S 10) before the actual capture - same idea as the article you linked. Manual exposure still may not match auto brightness exactly because of the gain difference, but the result should be stable.
Going back to the focus problem - I’ve noticed that on some of these IMX219 cameras, absolute focus just doesn’t give as good an image as the other IMX219 cameras at the same distance. While I was using a GUI to adjust the focus value, I saw that during the brief transition when changing the focus value from 0 to 1, the image looked better than it does sitting at either 0 or 1.
That transition effect is a good clue. Every focus motor can’t be set to the exact same physical position - there’s unavoidable machine error in these lens assemblies, so the same focus_absolute value doesn’t land at the same focal distance on every unit.
What we’ve seen across these IMX219 modules is that most units get sharp in the 0-1 range, but a small number need the 1-2 range. The brief ‘better’ image you saw between 0 and 1 is the lens passing through its true sharp position before settling slightly off it.
So the practical fix is to calibrate focus per camera instead of using one fixed value for all of them. Use a GUI to find the optimal focus value for each unit - start with 0-1, and if a camera still isn’t clear there, try 1-2. There’s no single universal focus value that works across all IMX219 units.