Picamera2
Introduction
Picamera2
is the libcamera-based replacement for Picamera which was a Python interface to the Raspberry Pi's legacy camera stack. Picamera2
also presents an easy to use Python API.
At Arducam, we have added autofocus control to the original.
Picamera2
is only supported on Raspberry Pi OS Bullseye (or later) images, both 32 and 64-bit. As of September 2022, Picamera2
is pre-installed on images downloaded from Raspberry Pi. It works on all Raspberry Pi boards right down to the Pi Zero, although performance in some areas may be worse on less powerful devices.
Picamera2
is not supported on:
- Images based on Buster or earlier releases.
- Raspberry Pi OS Legacy images.
- Bullseye (or later) images where the legacy camera stack has been re-enabled.
Getting Started
For the Pivariety cameras, you need to install the following steps:
Our Picamera2 is basically the same as the official one. However, because we added extra autofocus control, it resulted in a different installation.
You can also refer to the office documentation and demo, but the 2.1 and 2.2 sections in there need to be replaced with the following steps:
Pivariety cameras camera Board list:
Resolution | Camera Module |
---|---|
2MP | IMX462 |
2MP | OG02B10 |
2MP | OV2311 |
2.3MP | AR0234 |
16MP | IMX298 |
18MP | AR1820 |
21MP | IMX230 |
Step 1. Ensure that libcamera version 0.0.9 or higher is installed
If your version is lower than 0.0.9 please install the latest:
wget -O install_pivariety_pkgs.sh https://github.com/ArduCAM/Arducam-Pivariety-V4L2-Driver/releases/download/install_script/install_pivariety_pkgs.sh
chmod +x install_pivariety_pkgs.sh
./install_pivariety_pkgs.sh -p libcamera_dev
./install_pivariety_pkgs.sh -p libcamera_apps
Step 2. Installing Picamera2
dependencies
sudo apt install -y python3-kms++
sudo apt install -y python3-pyqt5 python3-prctl libatlas-base-dev ffmpeg python3-pip
sudo pip3 install numpy --upgrade
sudo pip3 install picamera2 --upgrade
Arducam picamera2 Autofocus control :
In picamera2, the autofocus trigger is controlled by picam2.set_controls, {"AfTrigger": 0} for single autofocus trigger and {"AfTrigger": 1} for continuous autofocus trigger.