How to use code to access libcamera(C++/Python)

Hi, I cant see an example of picamera2 using focus, please can you tell me which file it is or can you please provide an example. Otherwise all the photos are fuzzy.

Hi Hosken79,
I’m in the same situation as you are. I bought the 64mp on purpose for its autofocus but it seems we can’t use it in python script…but working fine in libcamera-app*.*
I talk with LibCamera dev team. They say they don’t have the knowledge from Arducam to code it…
The ball is in Arducam’s side.


After our test and ask the official of picamera2. There’s really no way to use the autofocus control.

We will continue to maintain our wrapped libcamera python library. This may take some time.

hi, @izd

The autofocus control code is what we added to libcamera. So it will only work if our libcamera-dev deb package is installed.

Regarding the problem of not being able to control autofocus in python, we will find the cause and solve it as soon as possible.

Hi yang,

Thanks you for answer.

So, I bought this camera for the 64mp sensor AND the autofocus.

The code to control the autofocus behavior exists in yours apps (libcamera-still/jpeg/raw/vid).
Where is the source code of these apps ?

Maybe I could hack something to go ahead in my project.

@izd @Hosken79

We found a solution that we can use Python to implement autofocus now.

I did a fresh install and followed the guide and then when i try running the example i get this :- python3
[0:03:13.476992651] [1167] WARN IPAManager ipa_manager.cpp:149 No IPA found in ‘/usr/local/lib/arm-linux-gnueabihf/libcamera’
[0:03:13.477407651] [1167] INFO Camera camera_manager.cpp:293 libcamera v0.0.0
Segmentation fault

hi, @Hosken79

Which version of Raspberry Pi system do you use? Bullseye or Buster?

You can use the following command to view:

uname -a
cat /etc /os-release

Which version did the libcamera Python library installed?

Hi, Everyone

Regarding the libcamera python library incompatibility with libcamera-dev 0.0.7 version, we have found the problem and solved it.

We updated the version number of the libcamera python library to 1.0.3. This version only supports Bullseye Raspberry Pi systems with kernel version greater than or equal to 5.10.92.

You can download it from the link below.

my version is this :-

and the one that was in the guide you siad to follow :- How to use arducam_64mp & arducam_64mp FQA - #19 by Edward
Ive also installed the 1.0.3 version and i still get the same message.

Could you not create a script, that does all the installing bits when its a fresh version OS on a PI ?

hi, @Hosken79

You can check the version of libcamera-dev with the command below.

dpkg -l | grep libcamera

The libcamera python 1.03 version library corresponds to the libcamera-dev 0.0.7 version, you can try to reinstall the libcamera-dev deb package.

Thanks for the heads up, we will consider integrating the installation process of the libcamera python library into the installation script.

Ive run the live above and it says this :-

What should i do next ?


I suggest you to reinstall libcamera-dev.

Just tried to reinstall and it says :-

I did this :-

wget -O
chmod +x
./ -p libcamera_dev
./ -p libcamera_apps

Which is in the manual.

I did fresh install and did eveything again and its working now.

Now my question is, once in Python and you run “cam.set(libcamera.AfTrigger, 1)” to auto focus.
how do you wait for the auto focus to finish before you can take a picture ?

hi, @Hosken79

You can achieve controllable autofocus and photography by responding to keyboard events.

What I want to do, is use the autofocus (as above) then once it’s focused on the person/object take a picture.
You can’t sent it to take a picture straight after as the autofocus is still adjusting, and adding a pause also doesn’t work.
How can I achieve this ? Any ideas ?

hi, @Hosken79

You can only take pictures after the autofocus is completed. There is no better idea at the moment.

So how do you detect that the autofocus has finished? Or is there no way to do this ATM ?

Once the libcamera is initialized only set() can be seen. For one of the post where one link was shared shared for controls, is there any plans to share some some sort of query or get calls with the libcamera python package? Or is there anyway to query the camera properties once it is started with

cam.startcamera( )