自宅監視 @ Vaio Type P

motionを使って、自宅監視してみようと思います。
今回は下記環境を使います。

  • Vaio Type P と 内蔵のカメラ(Motion EYE)
  • Ubuntu 10.04
  • motion (動体感知キャプチャソフト)

監視システムはこんな感じで構築してみようかと思います。


まず、motionをインストールします。

$ sudo aptitude install motion


次に、motionの設定をします。
/etc/motion/motion.confを修正します。

変更内容は下記の通りです。

  • フレームレートの変更
  • 画像を保存しないように変更
  • 動画のフォーマットの変更
  • 動きがあった箇所を枠で囲む描画をON
  • 動きがあったピクセル数の描画をON
  • ファイル保存場所の変更
  • 各種ファイル名の変更
--- motion.conf.org     2010-05-09 17:29:02.684051177 +0900
+++ motion.conf 2010-05-09 20:01:46.299053148 +0900
@@ -74,7 +74,8 @@
 
 # Maximum number of frames to be captured per second.
 # Valid range: 2-100. Default: 100 (almost no limit).
-framerate 2
+#framerate 2
+framerate 30
 
 # Minimum time in seconds between capturing picture frames from the camera.
 # Default: 0 = disabled - the capture rate is given by the camera framerate.
@@ -224,7 +225,8 @@
 # Picture with most motion of an event is saved when set to 'best'.
 # Picture with motion nearest center of picture is saved when set to 'center'.
 # Can be used as preview shot for the corresponding movie.
-output_normal on
+#output_normal on
+output_normal off
 
 # Output pictures with only the pixels moving object (ghost images) (default: off)
 output_motion off
@@ -279,7 +281,8 @@
 # flv - gives you a flash video with extension .flv
 # ffv1 - FF video codec 1 for Lossless Encoding ( experimental )
 # mov - QuickTime ( testing )
-ffmpeg_video_codec swf
+#ffmpeg_video_codec swf
+ffmpeg_video_codec mpeg4
 
 # Use ffmpeg to deinterlace video. Necessary if you use an analog camera
 # and see horizontal combing on moving objects in video or pictures.
@@ -311,7 +314,8 @@
 # Locate and draw a box around the moving object.
 # Valid values: on, off and preview (default: off)
 # Set to 'preview' will only draw a box in preview_shot pictures.
-locate off
+#locate off
+locate on
 
 # Draws the timestamp using same options as C function strftime(3)
 # Default: %Y-%m-%d\n%T = date in ISO format and time in 24 hour clock
@@ -326,7 +330,8 @@
 # Draw the number of changed pixed on the images (default: off)
 # Will normally be set to off except when you setup and adjust the motion settings
 # Text is placed in upper right corner
-text_changes off
+#text_changes off
+text_changes on
 
 # This option defines the value of the special event conversion specifier %C
 # You can use any conversion specifier in this option except %C. Date and time
@@ -356,7 +361,8 @@
 
 # Target base directory for pictures and films
 # Recommended to use absolute path. (Default: current working directory)
-target_dir /tmp/motion
+#target_dir /tmp/motion
+target_dir /home/mon/cap
 
 # File path for snapshots (jpeg or ppm) relative to target_dir
 # Default: %v-%Y%m%d%H%M%S-snapshot
@@ -365,7 +371,8 @@
 # File extension .jpg or .ppm is automatically added so do not include this.
 # Note: A symbolic link called lastsnap.jpg created in the target_dir will always
 # point to the latest snapshot, unless snapshot_filename is exactly 'lastsnap'
-snapshot_filename %v-%Y%m%d%H%M%S-snapshot
+#snapshot_filename %v-%Y%m%d%H%M%S-snapshot
+snapshot_filename %t-%Y%m%d%H%M%S-snapshot
 
 # File path for motion triggered images (jpeg or ppm) relative to target_dir
 # Default: %v-%Y%m%d%H%M%S-%q
@@ -374,7 +381,8 @@
 # File extension .jpg or .ppm is automatically added so do not include this
 # Set to 'preview' together with best-preview feature enables special naming
 # convention for preview shots. See motion guide for details
-jpeg_filename %v-%Y%m%d%H%M%S-%q
+#jpeg_filename %v-%Y%m%d%H%M%S-%q
+jpeg_filename %t-%Y%m%d%H%M%S-%q
 
 # File path for motion triggered ffmpeg films (mpeg) relative to target_dir
 # Default: %v-%Y%m%d%H%M%S
@@ -382,7 +390,8 @@
 # For Motion 3.0 compatible mode choose: %Y/%m/%d/%H%M%S
 # File extension .mpg or .avi is automatically added so do not include this
 # This option was previously called ffmpeg_filename
-movie_filename %v-%Y%m%d%H%M%S
+#movie_filename %v-%Y%m%d%H%M%S
+movie_filename %t-%Y%m%d%H%M%S
 
 # File path for timelapse mpegs relative to target_dir
 # Default: %Y%m%d-timelapse

最後に動作確認として、motionを起動します。

$ sudo motion
... ログ出力されます ...

設定ファイルで設定したディレクトリにaviファイルが出来てるはずです。

止める時は、でOKです。


とりあえず、今日はここまでにします。


参考サイトはこちら