LoginSignup
6
10

More than 5 years have passed since last update.

Raspberry PiでCamera Moduleを使う

Last updated at Posted at 2016-05-15

参考: The MagPi #45

  • Raspberry Pi 2 Model B (Raspbian Jessie)
  • Raspberry Pi Camera Module V2.1

Raspbery Piを更新する

上下左右の向きがおかしいバグがある(Camera v2 - Images horizontally flipped by default)のでrpi-updateでカーネル、ファームウェアを更新する。

sudo rpi-update

カメラをつなぐ

  • Raspberry PiをシャットダウンしてからCamera Moduleをつなぐ
  • リボンケーブルの向きはコネクタがHDMIポートの方

カメラソフトウェアを有効にする

デスクトップのProgram Menu > Preferences > Raspberry Pi Configuration > Interfaces タブ でCameraを有効にする (再起動が必要)

コマンドラインの場合 sudo raspi-config6 Enable Camera を選択する。

静止画の撮影

raspistillコマンドで撮影できる。gpicviewで表示を確認できる。

raspistill -o firstpic.jpg
gpicview firstpic.jpg

raspistillコマンドはリモートでも実行できたが、gpicviewはリモートではoption parsing failed: Cannot open displayというエラーになった。

上下反転する場合は-vfオプションを使って raspistill -vf -o firstpic.jpg とする。

  • 15秒後に撮影: raspistill -t 15000 -o newpic.jpg

詳細: https://www.raspberrypi.org/wp-content/uploads/2013/07/RaspiCam-Documentation.pdf

動画の撮影

raspividコマンドで撮影できる。

  • 10秒間の動画を撮影: raspivid -t 10000 -o testvideo.h264
  • fpsや解像度を変更して撮影: raspivid -w 640 -h 480 -fps 90 -t 10000 -o test90fps.h264
6
10
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
10