Arducam_64mp autofocus via libcamera-still

OK. so I’ve done some experiments and have a list of commands that worked fine for me and some interesting observations. NOTE I have tried this on then 0.11 version of the drivers not newer ones. I may test them later.

Short story is with no preview I can consistently capture a 9152x6944 image with autofocus. Previews with a small preview size at full res dont allocate enough memory and fail but resolution above 4576 but lower than 9152 could work.

If I flushed the buffer by running a no preview and no image taking at all then I could run a full size capture with a small preview. Might not be consistent but it worked for me 3 times in a row,

The picamera2 python libraries are something I’m yet to play with (they talk to libcamera with more controls) but the documentation there mentions being able to allocate and shift buffers as well as previewing then closing it down to take a photo. The libcamera terminal commands are a pretty limited hook into the libcamera apps so once if can get a basic version of them working like my working commands below you might consider looking at using piCamera2

My test commands below with my notes…

-works, autofocuses and saves to home directory. No preview
libcamera-still -t 10000 -n --autofocus-mode auto --width 9152 --height 6944 -o PiCam1.jpg

-Same as above but letting there be a preview of default size. Unable to request 1 buffers: Cannot allocate memory
libcamera-still -t 10000 --autofocus-mode auto --width 9152 --height 6944 -o PiCam1.jpg

-tried lowering previewsize still failed.Unable to request 1 buffers: Cannot allocate memory
libcamera-still -t 10000 -p 100,100,400,300 --autofocus-mode auto --width 9152 --height 6944 -o PiCam1.jpg

-works fine, half res with small preview… pretty sure default preview works here too.
libcamera-still -t 10000 -p 100,100,400,300 --autofocus-mode auto --width 4576 --height 3472 -o PiCam1.jpg

-works - tried upping the res a little
libcamera-still -t 10000 -p 100,100,400,300 --autofocus-mode auto --width 6864 --height 5208 -o PiCam1.jpg

-fails to allocate buffers again
libcamera-still -t 10000 -p 100,100,400,300 --autofocus-mode auto --width 9000 --height 6828 -o PiCam1.jpg

-back to no preview but trying autofocus on capture. seemed to work but the focus might be off a little
libcamera-still -t 10000 -n --autofocus-on-capture --width 9152 --height 6944 -o PiCam1.jpg

Now an intersting thing came up.
If I ran just

libcamera-still -t 10000 -n

to clear the buffer then it would work the next time I ran a full size capture with a small preview window such as

libcamera-still -t 10000 -p 100,100,400,300 --autofocus-mode auto --width 9152 --height 6944 -o PiCam1.jpg