IMX519 16MP no AF algorithm AGAIN

RPi 4B+ Bookworm up-to-date
I had solved that issue some months ago.
In my notes I stated that both IMX708 and IMX519 worked good (only had to keep an eye on dtoverly at config.txt)
That time I had followed these instructions:
https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/16MP-IMX519/#supported-platforms-and-os
Now, installing this 16MP camera I get out of focus pictures and:

[0:04:59.285734146] [864] WARN IPARPI ipa_base.cpp:1237 Could not set LENS_POSITION - no AF algorithm
[0:04:59.285780313] [864] WARN IPARPI ipa_base.cpp:1162 Could not set AF_SPEED - no focus algorithm
[0:04:59.286044092] [864] WARN IPARPI ipa_base.cpp:1144 Could not set AF_RANGE - no focus algorithm
I guess this happens because of system updates.
I repeated the procedure but nothing has changed.
What can I fix that?
Thank you

Update 1:
./install_pivariety_pkgs.sh -p -l

dpkg-query: no packages found matching raspberrypi-kernel
dpkg: error: --compare-versions takes three arguments:

Type dpkg --help for help about installing and deinstalling packages [*];
Use ‘apt’ or ‘aptitude’ for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;

Options marked [*] produce a lot of output - pipe it through ‘less’ or ‘more’ !

Hardware Revision: c03114
Kernel Version: 6.6.74+rpt-rpi-v8
OS Codename: bookworm
ARCH: aarch64

kernel:6.6.74+rpt-rpi-v8
kernel version is: 6.6.74
Unsupported package.

Supported packages:
ov64a40_kernel_driver
imx519_kernel_driver_low_speed
imx708_kernel_driver
libcamera
64mp_pi_hawk_eye_kernel_driver
libcamera_bookworm
libcamera_apps
libcamera_apps_bookworm
imx708_b0311_kernel_driver
libcamera_dev
imx519_kernel_driver
kernel_driver

Hi Daniel,
We’ve already updated the installation script yesterday. If you run the commands below to install the Arducam custom libcamera, the IMX519 autofocus should work again.

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 -l
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps

You can also check if the libcamera software is installed successfully by the command below:

dpkg -l | grep libcamera

1 Like

That worked good, thank you.
Making some tests,
rpicam-vid --autofocus-mode continuous --timeout 0 --width 1000 --height 750 -o -| nc 192.168.1.33 5000
works good in all distance ranges

rpicam-vid --autofocus-mode manual --lens-position X --autofocus-range normal --timeout 0 --width 1000 --height 750 -o -| nc 192.168.1.33 5000
It works well if X>1 (or something), close distances. But if X<1, larger distances, focus is bad in the entire image, there’s no focus in any part of the image, close or far.

Same happens with rpicam-still

Another issue: Still images are good in autofocus auto mode from rpicam-still but they are out of focus from python script using libcamera2.

picam2.set_controls({"AfMetering": controls.AfMeteringEnum.Auto})
picam2.set_controls({"AfMode": controls.AfModeEnum.Auto})

And the image is stretched wide despite
camera_config = picam2.create_still_configuration({"size":(4656,3496)})

Hi! I have also installed the custom libcamera in my Pi Zero 2W and works fine with libcamera-hello and libcamera-vid

However, when I want to use it in mediamtx, it is always shown out of focus. When I run the program it tells:

[0:05:26.780437839] [1275] WARN IPARPI ipa_base.cpp:735 Could not set AF_MODE - no AF algorithm
[0:05:26.780601744] [1275] WARN IPARPI ipa_base.cpp:1118 Could not set AF_SPEED - no focus algorithm
[0:05:26.780818982] [1275] WARN IPARPI ipa_base.cpp:1171 Could not set AF_TRIGGER - no AF algorithm or not Auto
[0:05:26.781124605] [1275] WARN IPARPI ipa_base.cpp:1100 Could not set AF_RANGE - no focus algorithm

I am running the Pi headless and the OS is 32bit Bullseye lite v 6.1.21-v7+

To install Arducam software, I followed instructions at:

https://docs.arducam.com/Raspberry-Pi-Camera/Native-camera/16MP-IMX519/

I followed instructions for the corresponding OS and then I re installed all over again following your instructions above. However, the camera is still out of focus.

Is there anything else I should do?

I appreciate your comments, thank you

Update 10-MAR-25

Sometimes when I launch mediamtx, the camera is on focus… However, it won’t adjust the focus once mediamtx is started.

This does not happen when I record video with libcamera, but I would like to use mediamtx to stream video because it has little lag compared to VLC

When I installed arducam files from the link stated in my prior post, I also installed the following camera driver to enable the latest Hybrid Mode(PDAF + CDAF):

./install_pivariety_pkgs.sh -p imx519_low_speed_driver

Thank you.

I have just encountered the same issue. Is there a fix for the autofocus error using the 16MP alongside mediamtx?

./mediamtx 
2025/04/13 23:08:11 INF MediaMTX v1.11.3
2025/04/13 23:08:11 INF configuration loaded from /home/camera/bin/mediamtx.yml
2025/04/13 23:08:11 INF [path cam] [RPI Camera source] started
2025/04/13 23:08:11 INF [RTSP] listener opened on :8554 (TCP), :8000 (UDP/RTP), :8001 (UDP/RTCP)
2025/04/13 23:08:11 INF [RTMP] listener opened on :1935
2025/04/13 23:08:11 INF [HLS] listener opened on :8888
2025/04/13 23:08:11 INF [WebRTC] listener opened on :8889 (HTTP), :8189 (ICE/UDP)
2025/04/13 23:08:11 INF [SRT] listener opened on :8890 (UDP)
[119:10:05.920336028] [11359]  INFO Camera camera_manager.cpp:325 libcamera v0.3.2+27-7330f29b-dirty (2024-12-02T23:04:17UTC)
[119:10:05.993907826] [11360]  WARN RPiSdn sdn.cpp:40 Using legacy SDN tuning - please consider moving SDN inside rpi.denoise
[119:10:05.998870905] [11360]  INFO RPI vc4.cpp:447 Registered camera /base/soc/i2c0mux/i2c@1/imx519@1a to Unicam device /dev/media3 and ISP device /dev/media0
[119:10:06.000434656] [11359]  INFO Camera camera.cpp:1197 configuring streams: (0) 1280x720-YUV420
[119:10:06.001279918] [11360]  INFO RPI vc4.cpp:622 Sensor: /base/soc/i2c0mux/i2c@1/imx519@1a - Selected sensor format: 1280x720-SRGGB10_1X10 - Selected unicam format: 1280x720-pRAA using hardware H264 encoder
[119:10:06.036720894] [11364]  WARN IPARPI ipa_base.cpp:735 Could not set AF_MODE - no AF algorithm
[119:10:06.037067821] [11364]  WARN IPARPI ipa_base.cpp:1118 Could not set AF_SPEED - no focus algorithm
[119:10:06.037878239] [11364]  WARN IPARPI ipa_base.cpp:1100 Could not set AF_RANGE - no focus algorithm
2025/04/13 23:08:12 INF [path cam] [RPI Camera source] ready: 1 track (H264)

Hi,
What’s the kernel version of your Pi?

uname -a

Hi Dion

Linux version 6.12.20+rpt-rpi-v8 ([email protected]) (aarch64-linux-gnu-gcc-12 (Debian 12.2.0-14) 12.2.0, GNU ld (GNU Binutils for Debian) 2.40) #1 SMP PREEMPT Debian 1:6.12.20-1+rpt1~bpo12+1 (2025-03-19)

root@camera:/home/camera# uname -a
Linux camera 6.12.20+rpt-rpi-v8 #1 SMP PREEMPT Debian 1:6.12.20-1+rpt1~bpo12+1 (2025-03-19) aarch64 GNU/Linux

Hi @heitbaum
I will verify the compatibility of this version. It’s pretty new.

Hi Dion,

I got it working. Issue is that mediamtx needed to be compiled against the arducam libcamera version.

sudo apt edit-sources
#add the following line
#deb http://deb.debian.org/debian bookworm-backports main contrib non-free non-free-firmware

sudo apt-get update
sudo apt install -t bookworm-backports golang-go

sudo apt install -y g++ xxd wget git cmake meson pkg-config python3-jinja2 python3-yaml python3-ply
sudo apt install libx264-dev
sudo apt install libfreetype-dev
sudo apt install libjpeg-dev

wget https://github.com/bluenviron/mediamtx/archive/refs/tags/v1.12.0.tar.gz
wget https://github.com/bluenviron/mediamtx-rpicamera/archive/refs/tags/v2.4.0.tar.gz

cd mediamtx-1.12.0
go generate ./...
cd ..

cd mediamtx-rpicamera-2.4.0
meson setup --wrap-mode=default build && DESTDIR=./prefix ninja -C build install
cp build/mtxrpicam_64/* ../mediamtx-1.12.0/internal/staticsources/rpicamera/mtxrpicam_64/
cd ..

cd mediamtx-1.12.0
CGO_ENABLED=0 go build .