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

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( )


Hi, @ac86074

We have implemented autofocus control on picamera2, all libcamera python libraries will still be out of maintenance.

Recently, we will release new versions of libcamera-dev and libcamera-apps packages.

You can choose to use picamera2. It is produced by Raspberry Pi, is fully functional and will be maintained for a long time.

Hi, Could you please show us how you have used Picamera2 with autofocus. Cheers

Hi, @jackzd

We will release the libcamera-dev and libcamera-apps packages for version 0.0.8 today.

At this time, you need to install the 0.0.8 version of libcamera-dev and the latest version of picamera2.

Then, set the AfTrigger to control the autofocus as you set the controls in the picamera2 example.

picam2.set_controls({"AfTrigger": 0})

Thanks for that. Is there a way to control where the focus point is?