Arducam 64mp Python Still Image Autofocus

I’m trying to capture an image with autofocus, does the AFTrigger only work in video mode? I tried throwing some sleeps in there, still blurry. Here is what I’m working with:

import time
from picamera2 import Picamera2
picam2 = Picamera2()

camera_config = picam2.create_still_configuration(main={"size": (1920, 1080)}, lores={"size": (640, 480)}, display="lores")
picam2.configure(camera_config)
picam2.start()
'time.sleep(1)'
picam2.set_controls({"AfTrigger":0})
'time.sleep(5)'
picam2.capture_file("test1.jpg")

What is the appropriate method for autofocusing still images?

1 Like

Take a look. If using 0.0.10 you have to set AfMode=1 also

Having same problem here…When I call the camera from the command line with:

libcamera-hello -t 0 --autofocus, I get this crisp, gorgeous HD image

but when I used the configuration command above, my pic is out of focus and it looks like minecraft for lack of a better word…

Does anyone have some pre-set settings to get the camera focused and working normally?

I tried AnotherDredd’s suggestion, didn’t see that in the repo, thank you. So I added:

picam2.set_controls({"AfMode": 1 ,"AfTrigger": 0})

to my initial code. You get about 3-4, camera failed to start errors. Eventually you will get a blurry picture, then you delete the ,“AfTrigger”: 0 part of that line. Then you may start getting clear pictures. But again, in between lots of failed camera starts. REboot the Pi and back to blurry. I’m trying a fresh install this morning, see how that goes, keep you posted.

Tried twice this morning from a fresh install. Do an install, upgrade system, follow instructions for libcamera from this site. After this I can no longer install any package, neither picamera2 or tightvncviewer. Get a broke dependencies error that I can’t correct.

I get the feeling after spending 2 days on this camera just to try and make it work is that it’s more of a novelty than something you’re going to use in a production environment anywhere.

I was thinking about writing a bash script to call the autofocus command, then calling the code that gets the shots. Then you can sort of automate it? I’m still kind of surprised there is not a set way to do this though.

I was going to use it to replace a 13mp Camera that is already written into a Python script, doing that seems backwards but if it’s the only way. I guess I could wait a bit and see if their Dev team actually supports this camera for Python in the future. It was released 6 months ago, think it would be a little more dialed in by now.

Afmode1 Aftrigger 0 initiates focus but you have to include a sleep 5 or something in order to get focused (you know, focusing lag)

There are several issues here.

  • Raspberrypi/Picamera2 library is poorly documented, for example signal callbacks, that would be solution for wait crashes.
  • arducam hawkeye has so much information to dump and rpi/debian has an issue with gpu memory alloc. That is, the only way to get fair results is booting on cli, or very low screen resolution. A solution could be slow streaming as far as the hardware could do it (i dunno)

So is there any method of reliably taking an autofocus still image with this camera?