IMX519 Autofocus and Picamera2

  1. Where did you get the camera module(s)?
  2. Model number of the product(s)?
    Arducam 16mp camera B0371
  3. What hardware/platform were you working on?
    Raspberry Pi Zero 2 W running Raspberry Pi OS (64 bit)
  4. Instructions you have followed. (link/manual/etc.)
    Picamera2 - Arducam Wiki
  5. Problems you were having?
    I cannot get the autofocus to work with picamera2. The picam2.set_controls({“AfTrigger”: 0}) code in the example appears to do nothing (the program just adds AfTrigger to the Controls dictionary). The autofocus works fine with a command such as “libcamera-still -t 0 --autofocus,” but it will not work with setting AfTrigger in picamera2. It appears that the latest version of picamera2 does not include the autofocus controls.
  6. The dmesg log from your hardware?
    [ 10.719088] imx519: loading out-of-tree module taints kernel.
    [ 10.755634] imx519 10-001a: Device found is imx519
    [ 10.756123] imx519 10-001a: Consider updating driver imx519 to match on endpoints
  7. Troubleshooting attempts you’ve made?
    I made sure the latest versions of picamera2 and other software are installed. I tried placing the AfTrigger command un different places in the code (e.g., before and after the start command). Picamera2 commands work fine otherwise.
  8. What help do you need?
    Is there a special version of picamera2 that includes the AfTrigger controls? I will appreciate any help or suggestions.

Please see the screenshot below:

You need to check if your libcamera version is 0.0.10:
dpkg -l | grep libcamera
If it shows 0.0.10, please modify the code:
picam2.set_controls({“AfMode”: 1 ,“AfTrigger”: 0})

1 Like

Why don’t you just update the documentation? It takes hours to figure out why autofocus doesn’t work. And then out of desperation accidentally find this post?

Thank you very much. That change appears to work.
Can a similar approach set continuous autofocus?
Perhaps you can publish the permissible values of AfMode and AfTrigger and what modes they set.

Hi fundix,
Oh boy, sorry for the bad experience. That’s really my fault.
I will add it to the Doc website.

Of course, you need to change the value of AFMod to 2.

We will add the documentation in the DOC website.

Thank you :slight_smile:

I generally struggle a lot with the camera and I think there were more changes.

Because in all the tutorials, the basic command libcamera-still -o demo.jpg library saves a 64Mpix photo. But the library only saves 16Mpix even if I choose -mode 9xxx:6xxx.

The only way to get 64Mpix was before python without autofocus. As soon as I turned on autofocus, the script froze on saving without any error.

If I used libcamera with -mode and -width the photo was just interpolated.

I tried all possible methods on Rpi 4b , 4G and 8G.