ラズパイ+ウェブカメラC200+motionで動体検知して撮影する
変化があったときだけ撮影。
参考
IPアドレス確認
$ ip a
motion
インストール
$ sudo apt install motion
この操作後に追加で 4,144 kB のディスク容量が消費されます。
準備
$ sudo chmod 777 /var/lib/motion
motionが画像や動画を保存するディレクトリ。誰でも編集できるようにする。
起動
$ sudo motion -n
表示
- ブラウザを起動する
- URL欄に
http://localhost:8081/
を入力する
カメラのライブ映像が見れるはず。
動画再生
/var/lib/motion
配下にjpgやaviファイルができている。動画aviを再生するにはVLCをインストールすればいい。
$ sudo apt install vlc
参考
ログ
$ sudo motion -n [0] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motion/motion.conf [0] [ALR] [ALL] conf_cmdparse: Unknown config option "sdl_threadnr" [0] [NTC] [ALL] motion_startup: Motion 3.2.12+git20140228 Started [0] [NTC] [ALL] motion_startup: Logging to syslog [0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (NTC) [0] [NTC] [ENC] ffmpeg_init: ffmpeg LIBAVCODEC_BUILD 3670016 LIBAVFORMAT_BUILD 3670272 [0] [NTC] [ALL] main: Thread 1 is from /etc/motion/motion.conf [0] [NTC] [ALL] main: Thread 1 is device: /dev/video0 input -1 [0] [NTC] [ALL] main: Stream port 8081 [0] [NTC] [ALL] main: Waiting for threads to finish, pid: 2019 [1] [NTC] [ALL] motion_init: Thread 1 started , motion detection Enabled [1] [NTC] [VID] vid_v4lx_start: Using videodevice /dev/video0 and input -1 [0] [NTC] [STR] httpd_run: motion-httpd testing : IPV4 addr: 127.0.0.1 port: 8080 [0] [NTC] [STR] httpd_run: motion-httpd Bound : IPV4 addr: 127.0.0.1 port: 8080 [0] [NTC] [STR] httpd_run: motion-httpd/3.2.12+git20140228 running, accepting connections [0] [NTC] [STR] httpd_run: motion-httpd: waiting for data on 127.0.0.1 port TCP 8080 [1] [NTC] [VID] v4l2_get_capability: ------------------------ cap.driver: "uvcvideo" cap.card: "UVC Camera (046d:0802)" cap.bus_info: "usb-3f980000.usb-1.3.4" 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] [WRN] [VID] v4l2_select_input: Device doesn't support VIDIOC_G_STD [1] [NTC] [VID] v4l2_set_pix_format: Config palette index 17 (YU12) doesn't work. [1] [NTC] [VID] v4l2_set_pix_format: Supported palettes: [1] [NTC] [VID] v4l2_set_pix_format: (0) YUYV (YUYV 4:2:2) [1] [NTC] [VID] v4l2_set_pix_format: 0 - YUYV 4:2:2 (compressed : 0) (0x56595559) [1] [NTC] [VID] v4l2_set_pix_format: (1) MJPG (Motion-JPEG) [1] [NTC] [VID] v4l2_set_pix_format: 1 - Motion-JPEG (compressed : 1) (0x47504a4d) [1] [NTC] [VID] v4l2_set_pix_format Selected palette YUYV [1] [NTC] [VID] v4l2_do_set_pix_format: Testing palette YUYV (320x240) [1] [NTC] [VID] v4l2_do_set_pix_format: Using palette YUYV (320x240) bytesperlines 640 sizeimage 153600 colorspace 00000008 [1] [NTC] [VID] v4l2_scan_controls: found control 0x00980900, "Brightness", range 0,255 [1] [NTC] [VID] v4l2_scan_controls: "Brightness", default -8193, current 128 [1] [NTC] [VID] v4l2_scan_controls: found control 0x00980901, "Contrast", range 0,255 [1] [NTC] [VID] v4l2_scan_controls: "Contrast", default 57343, current 32 [1] [NTC] [VID] v4l2_scan_controls: found control 0x00980902, "Saturation", range 0,255 [1] [NTC] [VID] v4l2_scan_controls: "Saturation", default 57343, current 38 [1] [NTC] [VID] v4l2_scan_controls: found control 0x00980913, "Gain", range 0,255 [1] [NTC] [VID] v4l2_scan_controls: "Gain", default 57343, current 0 [1] [NTC] [VID] vid_v4lx_start: Using V4L2 [1] [NTC] [ALL] image_ring_resize: Resizing pre_capture buffer to 1 items [1] [NTC] [STR] http_bindsock: motion-stream testing : IPV4 addr: 127.0.0.1 port: 8081 [1] [NTC] [STR] http_bindsock: motion-stream Bound : IPV4 addr: 127.0.0.1 port: 8081 [1] [NTC] [ALL] motion_init: Started motion-stream server in port 8081 auth Disabled [1] [NTC] [EVT] event_new_video FPS 2 [1] [NTC] [EVT] event_newfile: File of type 8 saved to: /var/lib/motion/01-20180913151902.avi [1] [NTC] [ALL] motion_detected: Motion detected - starting event 1 [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151902-00.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151902-01.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151903-00.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151903-01.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151904-00.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151904-01.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151905-00.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151905-01.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151906-00.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151906-01.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151907-00.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151907-01.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151908-00.jpg [1] [NTC] [EVT] event_newfile: File of type 1 saved to: /var/lib/motion/01-20180913151908-01.jpg