Arducam IMX519 autofocus not focusing on Raspberry Pi 4B, libcamera AF warnings

Hey everyone, I’ve got an Arducam IMX519 16MP Autofocus camera on a Raspberry Pi 4B and it won’t focus — the image is just blurry no matter what I do.

When I test with:

libcamera-still -t 5000

I get these warnings before the frames appear:

WARN IPARPI Apo_base.cpp:732 Could not set AF_MODE - no AF algorithm [1937]
WARN IPARPI Apo_base.cpp:1114 Could not set AF_SPEED - no focus algorithm [1937]
WARN IPARPI Lpa_base.cpp:1090 Could not set AF_RANGE - no focus algorithm

Environment: Arducam IMX519 16MP Autofocus, Raspberry Pi 4B. I’ve been following 16MP IMX519 - Arducam Wiki

Those warnings are the clue here. ‘Could not set AF_MODE - no AF algorithm’ and the AF_SPEED/AF_RANGE ones mean the libcamera build you’re using doesn’t include the autofocus/focus algorithm support. For the IMX519 autofocus to work you need the Arducam libcamera package installed, not just the default one.

Can you follow the Arducam libcamera getting started guide at libcamera and rpicam-apps - Arducam Wiki and then rerun the same libcamera-still command?

I already have libcamera installed, but the camera still isn’t focusing. The same warnings show up.

Let’s confirm exactly which packages are installed. Can you run:

dpkg -l | grep libcamera

and post the output back here? That’ll show whether the correct Arducam build and the dev files are actually present.

I ran it. I’ve attached the output as an image.

I looked at your dpkg output. The libcamera installation didn’t complete successfully — the package set doesn’t match the correct Arducam libcamera list. I’ve sent you a reference image of the correct package list privately, so compare your output against that. If packages like the development files are missing, that indicates an incomplete install. You’ll need to reinstall using the correct steps.

Could I get the exact install steps? I’m on a Raspberry Pi 4 running Raspberry Pi OS Bookworm (Linux 12). I’ve followed the docs.arducam.com instructions several times already and it still doesn’t seem right.

For the Pivariety camera on Bookworm, use these commands:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps

The first installs the Arducam libcamera development package (libcamera_dev) and the second installs the application package (libcamera_apps). Both are needed for the camera and autofocus to work correctly.

I compared my dpkg -l | grep libcamera output against the reference image. The one that’s missing is:

Libcamera-dev: arm64 0.3.0+rpt20240618-1 arm64 complex camera support library (development files)

Is it possible to install those development files separately? I’ve tried the same install lines from the website multiple times.

That missing libcamera-dev package is likely why the focus/autofocus algorithm isn’t available. Were you actually able to download the installation script? Start with just the download:

wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh

If that succeeds, run chmod +x install_pivariety_pkgs.sh, then ./install_pivariety_pkgs.sh -p libcamera_dev and ./install_pivariety_pkgs.sh -p libcamera_apps.

Quick update: I finally re-downloaded the driver successfully on my PC. Before that I kept getting download failures on the Pi and on other devices — looked like the GitHub link was having issues, but it seems fixed now. I haven’t tested it on the Pi yet. I’ll try and report back.

Thanks for the update. To be clear, the autofocus issue isn’t verified as resolved yet. Once you get the script onto the Pi, run both install commands, then run dpkg -l | grep libcamera again and confirm libcamera-dev is now listed. After that, rerun libcamera-still -t 5000 and check whether those AF_MODE / AF_SPEED / AF_RANGE warnings are gone and the lens actually focuses. Let us know what you get.