Color

日々の備忘録

Autofocus Camera for Raspberry Pi に Picamera2を導入

2022年08月17日 15時22分35秒 | Raspberry ...

◆Raspberry Pi用のPythonライブラリー「Picamera2」の導入手順

1.準備
●CPU : Raspberry Pi 4 Model B 4GB
●SSD : ASU650SS-120GT-R [ ADATA ]
●SATA-USB Adapter : OWL-PCSPS3U2 [ Owltech ]
●AC/DC : Google 30W USB-C 充電器
●Case : Raspberry Pi 4アルミニウムケース 冷却ファン付き
●Camera : 64-Megapixel Autofocus Camera for Raspberry Pi【超高解像度オートフォーカスカメラモジュール】
●Tripod : Pan Tilt Platform for Raspberry Pi【SKU:B0283】
●PC OS : Windows 10 Pro 64bit
●SSH Tool : TeraTerm-4.106
●VNC Tool : VNC Viewer 6.21.1109

2.OSの書込み

Raspberry Pi Imager を起動

Raspberry Pi OS(64-bit) を選択

PCにSSDを接続して、SSD を選択

カスタマイズオプション → いつも使う設定
SSHを有効、Wi-Fiを設定

<書き込む>

<はい>

Raspberry Pi Imager を終了、SSD をRaspberry Pi のUSBポートに接続して電源投入

PC の TeraTerm を起動
SSH接続で<OK>

<続行(C)>

パスフレーズ入力
<OK>

3.VNCの設定

~$ sudo raspi-config
Configuration Tool を起動
3 Inerface Options を選択

I3 Interface Options の選択

<Yes>

<OK>

<Finish>
PC で VNC Viewer を起動

<Continue>

Raspberri Pi と接続完了

4.ドライバーの導入
参照サイト
VCN上で LXTerminal を起動
#OS Update
~$ sudo apt update
~$ sudo apt full-upgrade -y
~$ sudo apt autoremove -y
~$ sudo apt clean
※2022年8月16日現在、ファームウェアがupgradeされるとドライバが認識されない。アップデートを禁止する。
#Download the bash scripts
~$ cd ~
~$ 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 64mp_pi_hawk_eye_kernel_driver
#Install libcamra-dev
~$ ./install_pivariety_pkgs.sh -p libcamera_dev
#Install libcamera-apps
~$ ./install_pivariety_pkgs.sh -p libcamera_apps

5.config.txt の設定
~$ sudo nano /boot/config.txt
----------------------------------
[all]
dtoverlay=arducam_64mp
dtoverlay=arducam_64mp,cam0
[pi4]
arm_boost=1
dtoverlay=vc4-kms-v3d,cma-512
----------------------------------
上書き保存で、テキストエディタを終了
#reboot
~$ sudo reboot
再起動を実行

6.カメラ動作確認

#List all cameras:

~$ libcamera-still --list-cameras
#Specify a camera: 
~$ libcamera-still -t 0 -camera 0
画像が表示される事を確認

7.Picamera2 の導入
#libcamera
~$ dpkg -l | grep libcamera
--------------------------------------------------------
ii  libcamera-apps 0.0.8 arm64 libcamera-apps
ii  libcamera-dev 0.0.8 arm64 libcamera
--------------------------------------------------------
#Installing Picamera2
~$ sudo apt install -y python3-kms++
~$ sudo apt install -y python3-pyqt5 python3-prctl libatlas-base-dev ffmpeg
~$ sudo pip3 install numpy --upgrade

~$ sudo pip3 install picamera2
エラーメッセージが多数表示される
sudo apt install -y python3-pyqt5 python3-prctl libatlas-base-dev ffmpeg --fix-missing などを実行して、再度、pip3 を実行
#Running Picamera2 Examples
~$ git clone https://github.com/raspberrypi/picamera2.git
~$ cd picamera2/examples

~$ python3 app_capture.py
64-Megapixel Autofocus Camera for Raspberry Pi の場合、遅延が酷い
リアルタイム処理は不向きである

─以上─