Open10

Raspberry Pi 5にカメラを接続する

horie-thorie-t

まず、カメラの認識から

$ libcamera-hello --list-camera
No cameras available!

認識してないのか・・・

horie-thorie-t

https://forums.raspberrypi.com/viewtopic.php?t=366847

camera_auto_detect=1 only works for genuine Pi cameras, which yours isn't.
(和訳: camera_auto_detect=1は純正のPiカメラにしか使えません。)

との事。

If you do not use an official Raspberry Pi camera, you need to configure the "config.txt " file. If you use the latest Bookworm system, you need to configure /boot/firmware/config.txt.

sudo nano /boot/config.txt
#If using the bookworm system
sudo nano /boot/firmware/config.txt

Find "camera-auto-detect=1" and modify it to "camera_auto_detect=0".

At the end of the file, add the following setting statements according to the camera model.
IMX219 dtoverlay=imx219
和訳
公式のRaspberry Piカメラを使用しない場合は、"config.txt"ファイルを設定する必要があります。最新のBookwormシステムを使用する場合は、/boot/firmware/config.txtを設定する必要があります。
sudo nano/boot/config.txt
#bookwormシステムを使用している場合
sudo nano/boot/firmware/config.txt"

camera-auto-detect=1"を探し、"camera_auto_detect=0"に変更します。
ファイルの最後に、カメラのモデルに応じて次の設定文を追加します。
IMX219 dtoverlay=imx219

horie-thorie-t

公式サイトを確認。(初めから見ればよかった。)

sudo nano /boot/firmware/config.txt 
#Find the line: camera_auto_detect=1, update it to:
camera_auto_detect=0
#Find the line: [all], add the following item under it:
dtoverlay=imx219,cam0
#Save and reboot.
horie-thorie-t

カメラの情報取得

$ rpicam-hello --list-cameras 
Available cameras
-----------------
0 : imx219 [3280x2464 10-bit RGGB] (/base/axi/pcie@120000/rp1/i2c@88000/imx219@10)
    Modes: 'SRGGB10_CSI2P' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                             1640x1232 [41.85 fps - (0, 0)/3280x2464 crop]
                             1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                             3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]
           'SRGGB8' : 640x480 [206.65 fps - (1000, 752)/1280x960 crop]
                      1640x1232 [83.70 fps - (0, 0)/3280x2464 crop]
                      1920x1080 [47.57 fps - (680, 692)/1920x1080 crop]
                      3280x2464 [21.19 fps - (0, 0)/3280x2464 crop]

赤みがどうしても取れないので、自動オートホワイトバランスを無効化して、手動で調整。ちょっと青みが強い気がするけど。

rpicam-jpeg --awbgains 0.90,1.60 --width 1640 --height 1232 --metering average --output test.jpg

カメラの色の校正
ファイル

horie-thorie-t

Pythonで使いたい時は、 Picamera2 を使う。

$ apt list --installed | grep picamera2
python3-picamera2/stable,stable,now 0.3.18-1 all [installed]

既にインストール済みだった。

マニュアルはこちら