HOME
  Security
   Software
    Hardware
  
FPGA
  CPU
   Android
    Raspberry Pi
  
nLite
  Xcode
   etc.
    ALL
  
LINK
BACK
 

2016/05/14

Raspberry Pi 3でネットワーク ライブカメラを構築する方法 Motion編 Raspberry Pi 3でネットワーク ライブカメラを構築する方法 Motion編

(ラズパイのカメラで遠隔監視カメラ(ネットワークカメラ、ライブカメラ))

Tags: [Raspberry Pi], [電子工作]





● Raspberry Pi 3 Model Bを遂に購入

 Raspberry Pi3 Model B RPI2 RPI3

 大人気の CPUボードの Raspberry Piに WiFiと Bluetoothが搭載されたモデルが新発売となりました。
 以前から Raspberry Pi 2を買おうかどうか迷っていましたが、Raspberry Pi 3 Model Bの発売を機に購入を決意してラズベリアンになる事にしました。

 ※ ラズパイの OS Raspbianはバージョンが上がる毎に過去の版と OSの内部の作りが変わり、過去に書かれた製作記事(例えば Raspbian Wheezyの時代の記事)がそのままではエラーが出たりして動かない事が有ります。
 ※ 当方のホームページのラズパイ記事は全て Raspberry Pi 3 Model Bと Raspbian Jessieの組み合わせで動作確認をしております。
(ただし、将来的に新しい Raspbian OSが出た場合に、当方の Raspbian Jessieを基にした内容がそのままでは動かない可能性が有ります。)
 ※ 2017/08/16から Raspbian OSは Raspbian Jessieから Raspbian Stretchに変わりました。
 ※ 2019/06/20から Raspbian OSは Raspbian Stretchから Raspbian Busterに変わりました。

Download Raspbian for Raspberry Pi

ちなみに、歴代のバージョンと名称は
Debianコードネーム年月備考(参考)Ubuntuでの該当名称
Debian 11Bullseye2021/08/14~2021/11からラズパイにリリースFocal Fossa 20.04 LTS ?
Debian 10Buster2019/06/20~2019/06からラズパイ4対応Bionic 18.04 LTS
Debian 9Stretch2017/08/16~2018/03からラズパイ3B+対応Xenial 16.04 LTS
Debian 8Jessie2015~2016/02からラズパイ3対応Trusty 14.04 LTS
Debian 7Wheezy2013~2016
Debian 6.0Squeeze2011~2014
Debian GNU/Linux 5.0Lenny2009~2012


● カメラモジュール CAMERA接続 for Raspberry Pi

Raspberry Pi ビデオ カメラ モジュール HD Video Camera Module
ASIN: B010O7KZ6W

Raspberry Pi 用 赤外線カメラモジュール Pi NoIR
ASIN: B00HZDR544
※微妙にカメラ部分の基板外形が異なる品種が有る様です。


●ラズパイ専用カメラのインストール方法

2016/05/14
Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法
Raspberry Pi 3 Model Bに専用カメラモジュール RaspiCamを接続する方法

  ラズパイに専用カメラモジュールを接続して Raspbianで写真の静止画撮影や動画を録画する方法


● Raspberry Pi 3 Model Bで遠隔監視カメラ(ネットワークカメラ、ライブカメラ)

 Raspberry Pi 3 Model Bにカメラを接続して、遠隔監視カメラ(ネットワークカメラ、ライブカメラ)を作ります。
 作ると言っても、既にソフトが有るのでそれをインストールするだけでネットワークカメラにできます。

 ここでは 2種類のライブカメラアプリを試してみます。
 ・Motion
Motion - Web Home
 Welcome to the home of Motion, a software motion detector.
 Latest version: 3.2.12

motion SourceForge
 Description
 Motion monitors the video signal from one or more cameras (video4linux interface) and is able to detect if a significant part of the picture has changed. Features: interval snapshots, live streaming webcam, mpeg generation, database interface, OSD etc.

lowflyerUK/motion mmal-test branch
https://github.com/lowflyerUK/motion.git

 ・MJPG-Streamer
MJPG-streamer SourceForge
 Description
 MJPG-streamer takes JPGs from Linux-UVC compatible webcams, filesystem or other input plugins and streams them as M-JPEG via HTTP to webbrowsers, VLC and other software. It is the successor of uvc-streamer, a Linux-UVC streaming application with Pan/Tilt

jacksonliam/mjpg-streamer
 mjpg-streamer-experimental

2016/05/14
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 MJPG-streamer編
Raspberry Pi 3でネットワーク ライブカメラを構築する方法 MJPG-streamer編

  ラズパイのカメラで遠隔監視カメラ(ネットワークカメラ、ライブカメラ)


● Motionを Raspberry Pi 3 Model Bで使用する

 結論から言うと、Motionを Raspberry Pi 3 Model Bで使用する場合は下記の by lowflyer » Sat Dec 19, 2015 10:29 amの書き込みの方法でコンパイルするか、バイナリをインストールします。
 ※それ以外の Motionでは RASPBIAN JESSIEに対応していない。
 ※ USB接続のウェブカメラを使用する場合は普通の Motionで大丈夫。
Motion - MMAL camera

● RASPBIAN JESSIEに対応の Motionのコンパイル済みバイナリを使用する場合
wget https://www.dropbox.com/s/6ruqgv1h65zufr6/motion-mmal-lowflyerUK-20151114.tar.gz
tar -zxvf motion-mmal-lowflyerUK-20151114.tar.gz
./motion -c motion-mmalcam-both.conf

● RASPBIAN JESSIEに対応の Motionのコンパイル方法
sudo raspi-config

sudo apt-get update
sudo apt-get install -y libjpeg-dev libavformat56 libavformat-dev libavcodec56 libavcodec-dev libavutil54 libavutil-dev libc6-dev zlib1g-dev libmysqlclient18 libmysqlclient-dev libpq5 libpq-dev

sudo apt-get -y install git
sudo apt-get -y install cmake

cd
git clone https://github.com/raspberrypi/userland
git clone https://github.com/lowflyerUK/motion.git
cd ./motion/
git checkout mmal-test
USERLANDPATH=/home/pi/userland cmake .
make
cd
cd ./motion/
sudo ./motion -c ./configs/motion-mmalcam.conf

ブラウザで
http://192.168.1.10:8080/ で管理画面になります。
http://192.168.1.10:8085/ でライブ映像の画面になります。

192.168.1.10はラズパイの IPアドレス

● ./configs/motion-mmalcam.confの初期設定

width = 256
height = 144
stream_port = 8085
webcontrol_port = 8080

http://192.168.1.10:8080/
All -> config -> set -> width = 640
All -> config -> set -> height = 480
All -> config -> write -> Yes
All -> action -> restart

・motion-mmalcam.conf Motion設定方法
motion-mmalcam.conf Motion設定方法


・motion-mmalcam.conf Motion設定方法
motion-mmalcam.conf Motion設定方法


・motion-mmalcam.conf Motion設定方法
motion-mmalcam.conf Motion設定方法


・motion-mmalcam.conf Motion設定方法
motion-mmalcam.conf Motion設定方法



 初期設定のライブ画像の大きさは 256x144
・motion-mmalcam.conf Motion設定方法
motion-mmalcam.conf Motion設定方法


 上記の設定変更でライブ画像の大きさが 640x480になります。
・motion-mmalcam.conf Motion設定方法
motion-mmalcam.conf Motion設定方法





● Motionを Raspberry Pi 3 Model Bで使用する USBウェブカメラを使用する場合

 専用カメラの様なコンパイルとか面倒な手順は不要で apt-getでパッケージをインストールするだけで動く物ができ上がります。

sudo apt-get install motion

sudo nano /etc/motion/motion.conf
daemon offを daemon onに変更すると自動で起動するう。

sudo cat /etc/motion/motion.conf | grep port
# The mini-http server listens to this port for requests (default: 0 = disabled)
stream_port 8081
# TCP/IP port for the http server to listen on (default: 0 = disabled)
webcontrol_port 8080

motion
 で起動する。

Unknown config option "sdl_threadnr"
# Number of motion thread to show in SDL Window (default: 0 = disabled)
sdl_threadnr 0

sdl_threadnr 0
 を
# sdl_threadnr 0
 にコメント化する。

------------------------
cap.driver: "uvcvideo"
cap.card: "USB2.0 PC CAMERA"
cap.bus_info: "usb-3f980000.usb-1.2"
cap.capabilities=0x84200001
------------------------
[1] [NTC] [VID] v4l2_get_capability: - VIDEO_CAPTURE
[1] [NTC] [VID] v4l2_get_capability: - STREAMING
[1] [NTC] [VID] v4l2_select_input: name = "Camera 1", type 0x00000002, status 00000000
[1] [NTC] [VID] v4l2_select_input: - CAMERA
[1] [ERR] [VID] v4l2_select_input: Error selecting input 0 VIDIOC_S_INPUT:
[1] [NTC] [VID] vid_v4lx_start: Using V4L1
[1] [ERR] [ALL] motion_loop: Video device fatal error - Closing video device
[1] [NTC] [VID] vid_close: Closing video device /dev/video0
 Error selecting input 0 VIDIOC_S_INPUT:
 は再起動する。

 動体検知で画像を保存している。
[1] [NTC] [ALL] motion_detected: Motion detected - starting event 1
[1] [NTC] [EVT] event_newfile: File of type 1 saved to: ./01-20160519132732-08.jpg
[1] [NTC] [EVT] event_newfile: File of type 1 saved to: ./01-20160519132745-20.jpg
[1] [NTC] [EVT] event_newfile: File of type 1 saved to: ./01-20160519132746-00.jpg
[1] [NTC] [ALL] motion_loop: End of event 1

 ブラウザに http://192.168.1.10:8080/ で見れる。はずだが見れない??
 ブラウザに http://192.168.1.10:8081/ で見れる。はずだが見れない??
 ※ 192.168.1.10はラズパイの IPアドレスです。

?? sudo service motion start




Tags: [Raspberry Pi], [電子工作]



[HOME] | [BACK]
リンクフリー(連絡不要、ただしトップページ以外は Web構成の変更で移動する場合があります)
Copyright (c) 2016 FREE WING,Y.Sakamoto
Powered by 猫屋敷工房 & HTML Generator

http://www.neko.ne.jp/~freewing/raspberry_pi/raspberry_pi_3_camera_motion/