Raspberry Pi カメラモジュール V2を使用し、pythonにより写真撮影をします。
前提
ラズパイ:Raspberry pi 4B
OS:Raspbian GNU/Linux 10 (buster)
使用言語:python3
事前準備
アップデート
# sudo apt-get update
# sudo apt-get upgrade
# sudo apt-get dist-upgrade
ラズパイカメラ接続有効化
# sudo raspi-config
5 Interfacing Options Configure connections to peripheralsを選択します。
![](https://growplants.jp/wp-content/uploads/2020/09/1_5-Interfacing-Options.png)
P1 Camera EnableDisable connection to the Raspberry Pi Cameraを選択します。
![](https://growplants.jp/wp-content/uploads/2020/09/2_P1-Camera-EnableDisable-connection-to-the-Raspberry-Pi-Camera.png)
Would you like the camera interface to be enabled <Yes>を選択します。
![](https://growplants.jp/wp-content/uploads/2020/09/3_Would-you-like-the-camera-interface-to-be-enabled.png)
The camera interface is enabledを確認します。
![](https://growplants.jp/wp-content/uploads/2020/09/4_The-camera-interface-is-enabled.png)
再起動して設定完了です。
ラズパイカメラ
ラズパイカメラ準備
amazonから購入しました。
カメラモジュール接続
こんな風に接続します。
![piカメラ接続前前](https://growplants.jp/wp-content/uploads/2020/09/064b066138ed5d1cc13ed2db37e1cad3-1-1024x768.jpeg)
![黒いポッチを引き上げる](https://growplants.jp/wp-content/uploads/2020/09/064b066138ed5d1cc13ed2db37e1cad3-2-1024x768.jpeg)
![カメラモジュール埋め込み](https://growplants.jp/wp-content/uploads/2020/09/246cb8587ba8038341894e0db8710413-768x1024.jpeg)
![](https://growplants.jp/wp-content/uploads/2020/09/0ea5ea54b66eb67394b2f818b2a2f6da-768x1024.jpeg)
接続確認
# vcgencmd get_camera
supported=1 detected=1
supported=1 detected=1となっていることを確認します。
ラズパイ
モジュール
至極簡単に実現しようとすると以下の3ステップです。
# vi sample.py
import picamera
cam = picamera.PiCamera()
cam.capture("test.jpg")
#python sample.py
sample.pyと同一フォルダにtest.jpgが作成されます。
コメント