Raspberry Pi 2でカメラモジュールを試してみる
記事を書くのを全く忘れていました・・・。 いまさらながらラズパイ2で、1年以上前に買って放置していていたカメラモジュールを試してみます。
前準備
- 事前にraspi-configのEnable Cameraでカメラモジュールを使えるようにしておく
- ラズパイにカメラモジュールを接続する
コマンド
- raspistill : 写真を撮る
- raspivid : ビデオを撮る
実行してみる
$ raspistill -o img.jpg mmal: Cannot read cameara info, keeping the defaults for OV5647 mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM) mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1) mmal: Failed to create camera component mmal: main: Failed to create camera component mmal: Camera is not detected. Please check carefully the camera module is installed correctly
root権限で実行してみる
$ sudo raspistill -o img.jpg mmal: Cannot read cameara info, keeping the defaults for OV5647 mmal: mmal_vc_component_create: failed to create component 'vc.ril.camera' (1:ENOMEM) mmal: mmal_component_create_core: could not create component 'vc.ril.camera' (1) mmal: Failed to create camera component mmal: main: Failed to create camera component mmal: Camera is not detected. Please check carefully the camera module is installed correctly
そもそも・・・
$ vcgencmd get_camera supported=1 detected=0
検出されていなかった。
カーネルが古いと失敗するようなのでアップデートする。
$ sudo rpi-update $ sudo reboot
$ vcgencmd get_camera supported=1 detected=1
いけた模様。
LANでストリーミング配信してみる
VLCをつかって配信する
準備
$ sudo apt-get update $ sudo apt-get install vlc
実行
ホスト
# HTTPで配信 $ raspivid -o - -t 9999999 -w 800 -h 600 --hflip | cvlc -vvv stream:///dev/stdin --sout '#standard{access=http,mux=ts,dst=:8080}' :demux=h264 #RTSPで配信 $ raspivid -o - -t 9999999 -w 800 -h 600 --hflip | cvlc -vvv stream:///dev/stdin --sout '#rtp{sdp=rtsp://:8080/}' :demux=h264
クライアント
#HTTPでの配信 <a href="http://RPI_IP:8080/" target="_blank" rel="noreferrer" style="cursor:help;display:inline !important;">http://RPI_IP:8080/</a> #RTSPでの配信 rtsp://RPI_IP:8080/