Motorized IMX477 Reporting no AF algorithm

I am trying to run a IMX477 purchased from Arducam, but when I try to use picamera2 module in Python I keep getting a warning:
WARN IPARPI ipa_base.cpp:817 Could not set AF_MODE - no AF algorithm
WARN IPARPI ipa_base.cpp:1441 Could not set LENS_POSITION - no AF algorithm

I am trying to run on a new Raspberry Pi 5:

uname -a
Linux raspberrypi 6.12.47+rpt-rpi-2712 #1 SMP PREEMPT Debian 1:6.12.47-1+rpt1 (2025-09-16) aarch64 GNU/Linux

I have configured my /boot/firmware/config according to the guide here (I don’t use cam0, just dtoverlay=imx477,vcm):
https://docs.arducam.com/Raspberry-Pi-Camera/Motorized-Focus-Camera/Quick-Start-Guide/IMX477-Motorized-Focus-Camera/#hardware

And I set up the pivariety files with:

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

Which yields the following:

dpkg -l | grep libcamera
ii  libcamera-apps                       1.9.1-1                              all          transitional package
ii  libcamera-dev                        0.5.2+rpt20250909-2                  arm64        complex camera support library (development files)
ii  libcamera-ipa:arm64                  0.5.2+rpt20250909-2                  arm64        complex camera support library (IPA modules)
ii  libcamera-tools                      0.5.2+rpt20250903-1+b1               arm64        complex camera support library (tools)
ii  libcamera-v4l2:arm64                 0.5.2+rpt20250903-1+b1               arm64        complex camera support library (V4L2 module)
ii  libcamera0.5:arm64                   0.5.2+rpt20250909-2                  arm64        complex camera support library
ii  python3-libcamera                    0.5.2+rpt20250903-1+b1               arm64        complex camera support library (Python bindings)
ii  rpicam-apps                          1.9.1-2                              all          Camera based applications for Raspberry Pi using the libcamera framework
ii  rpicam-apps-core                     1.9.1-2                              arm64        Camera based applications for Raspberry Pi using the libcamera framework

I have tried a few variations of the following python file:

from picamera2 import Picamera2
from libcamera import controls
import time

picam2 = Picamera2()
picam2.configure(picam2.create_still_configuration())
picam2.start()

picam2.set_controls({"AfMode" : controls.AfModeEnum.Manual})
picam2.set_controls({"LensPosition" : 10.0})
time.sleep(3)
picam2.capture_file("test.jpg")

picam2.stop()
picam2.close()

But I get that warning mentioned above. I don’t seem to get the error when running from rpicam-still:

rpicam-still --immediate   --autofocus-mode manual --lens-position 5   --tuning-file /usr/share/libcamera/ipa/rpi/pisp/imx477_af.json   -o mf_5.jpg
[0:01:10.497276202] [1355]  INFO Camera camera_manager.cpp:330 libcamera v0.5.2+125-69c6546d-dirty (2025-10-10T01:59:59BST)
[0:01:10.511245091] [1360]  INFO RPI pisp.cpp:720 libpisp version 1.3.0
[0:01:10.863836542] [1360]  INFO IPAProxy ipa_proxy.cpp:180 Using tuning file /usr/share/libcamera/ipa/rpi/pisp/imx477_af.json
[0:01:10.882977035] [1360]  INFO Camera camera_manager.cpp:220 Adding camera '/base/axi/pcie@1000120000/rp1/i2c@80000/imx477@1a' for pipeline handler rpi/pisp
[0:01:10.883007553] [1360]  INFO RPI pisp.cpp:1180 Registered camera /base/axi/pcie@1000120000/rp1/i2c@80000/imx477@1a to CFE device /dev/media0 and ISP device /dev/media2 using PiSP variant BCM2712_D0
WARNING: Capture will not make use of temporal denoise
         Consider using the --zsl option for best results, for example:
         rpicam-still --zsl -o mf_5.jpg
Made X/EGL preview window
Made DRM preview window
Preview window unavailable
Mode selection for 4056:3040:12:P
    SRGGB10_CSI2P,1332x990/0 - Score: 10552.2
    SRGGB12_CSI2P,2028x1080/0 - Score: 8179.84
    SRGGB12_CSI2P,2028x1520/0 - Score: 7096
    SRGGB12_CSI2P,4056x3040/0 - Score: 0
Stream configuration adjusted
[0:01:11.087379978] [1355]  INFO Camera camera.cpp:1215 configuring streams: (0) 4056x3040-YUV420/sYCC (1) 4056x3040-BGGR_PISP_COMP1/RAW
[0:01:11.087518272] [1360]  INFO RPI pisp.cpp:1484 Sensor: /base/axi/pcie@1000120000/rp1/i2c@80000/imx477@1a - Selected sensor format: 4056x3040-SBGGR12_1X12/RAW - Selected CFE format: 4056x3040-PC1B/RAW
Still capture image received

And from what I can tell when I change the --lens-position value the focus is obviously changing. So I am not sure if something has changed in the Python syntax for the motorized version or if I am just doing something wrong with the deps/config?

Any help would be greatly appreciated.

-Raymond

I believe I just figured it out. I have to pass in the tuning file. I also notice I have to wait a bit when the camera first starts if not I may get all black images. New Python example file looks something like this

from picamera2 import Picamera2
from libcamera import controls
import time

# Pass tuning explicitly
picam2 = Picamera2(tuning="/usr/share/libcamera/ipa/rpi/pisp/imx477_af.json")
still_cfg = picam2.create_still_configuration()
picam2.configure(still_cfg)
picam2.start()
time.sleep(2.5)

picam2.set_controls({
    "AfMode": controls.AfModeEnum.Manual,
    "LensPosition": 0.0, 
})
time.sleep(0.75)  # let the lens move if not in position
picam2.capture_file("mf_0.jpg")

This indeed moves the lens and gets rid of the warning.

Also for reference if you need to wait till you hit the actual lens position location you can use

md = picam2.capture_metadata()
md.get("LensPosition")

And to see the min/max/step values of your camera model you can use

print(picam2.camera_controls["LensPosition"])

Which for the IMX477 outputs (0.0, 15.0, 1.0)

Hopefully this helps someone else in the future.

1 Like