zoneminderは、やはり、liveCDすら、動かない。
けれど、ターミナルから、motionが一発起動。
ただし設定はGUIでなく、ヘタをするとホームフォルダが画像だらけになって大変なことになる。
設定は
sudo gedit /etc/motion/motion.conf
として行う。
起動はターミナルにて
motion
と打つだけ。
終了は
Ctrl+C
(デフォルト設定のまま、これを忘れると、ホームフォルダが、画像だらけになり、削除するにも、全てを表示することが、ファイルエクスプローラの限界を超えている、というような状況になる。)
Daemon動作時は?
sudo kill 2166
とする。
2166というのは
motion.pidに書いてある数字。
motion.pidは
/etc/motion/motion.conf
によれば
/var/run/motion/にあることになっているが、別の場所にしてしまうこともできる。
----------------------------------------
10行目 バックグラウンドで動作させるか否か
# Start in daemon (background) mode and release terminal (default: off)
daemon on
27行目
# Videodevice to be used for capturing (default /dev/video0)
# for FreeBSD default is /dev/bktr0
videodevice /dev/video1
70行目 縦横幅の設定
# Image width (pixels). Valid range: Camera dependent, default: 352
width 352
# Image height (pixels). Valid range: Camera dependent, default: 288
height 288
78行目
# Maximum number of frames to be captured per second.
# Valid range: 2-100. Default: 100 (almost no limit).
framerate 2
80行目
# Minimum time in seconds between capturing picture frames from the camera.
# Default: 0 = disabled - the capture rate is given by the camera framerate.
# This option is used when you want to capture images at a rate lower than 2 per second.
minimum_frame_time 0
109行目 自動調整
# Let motion regulate the brightness of a video device (default: off).
# The auto_brightness feature uses the brightness option as its target value.
# If brightness is zero auto_brightness will adjust to average brightness value 128.
# Only recommended for cameras without auto brightness
auto_brightness on
152行目 閾値の設定
# Threshold for number of changed pixels in an image that
# triggers motion detection (default: 1500)
threshold 4000
# Automatically tune the threshold down if possible (default: off)
threshold_tune off
# Noise threshold for the motion detection (default: 32)
noise_level 60
# Automatically tune the noise threshold (default: on)
noise_tune on
222行目 動体検知されたら画像保存
# Output 'normal' pictures when motion is detected (default: on)
# Valid values: on, off, first, best, center
# When set to 'first', only the first picture of an event is saved.
# 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
247行目 微速度撮影映像の作成とか
# Use ffmpeg to encode mpeg movies in realtime (default: off)
ffmpeg_cap_new on
# Use ffmpeg to make movies with only the pixels moving
# object (ghost images) (default: off)
ffmpeg_cap_motion off
# Use ffmpeg to encode a timelapse movie
# Default value 0 = off - else save frame every Nth second
ffmpeg_timelapse 5
# The file rollover mode of the timelapse video
# Valid values: hourly, daily (default), weekly-sunday, weekly-monday, monthly, manual
ffmpeg_timelapse_mode daily
296行目
snapshot_interval 360
312行目 動体を囲む四角い枠を表示するか否か
# 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 on
327行目
# 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 on
344行目から どこにどういう名前で保存するか
############################################################
# Target Directories and filenames For Images And Films
# For the options snapshot_, jpeg_, mpeg_ and timelapse_filename
# you can use conversion specifiers
# %Y = year, %m = month, %d = date,
# %H = hour, %M = minute, %S = second,
# %v = event, %q = frame number, %t = thread (camera) number,
# %D = changed pixels, %N = noise level,
# %i and %J = width and height of motion area,
# %K and %L = X and Y coordinates of motion center
# %C = value defined by text_event
# Quotation marks round string are allowed.
############################################################
# Target base directory for pictures and films
# Recommended to use absolute path. (Default: current working directory)
target_dir /tmp/motion
# File path for snapshots (jpeg or ppm) relative to target_dir
# Default: %v-%Y%m%d%H%M%S-snapshot
# Default value is equivalent to legacy oldlayout option
# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-snapshot
# 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
# File path for motion triggered images (jpeg or ppm) relative to target_dir
# Default: %v-%Y%m%d%H%M%S-%q
# Default value is equivalent to legacy oldlayout option
# For Motion 3.0 compatible mode choose: %Y/%m/%d/%H/%M/%S-%q
# 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
# File path for motion triggered ffmpeg films (mpeg) relative to target_dir
# Default: %v-%Y%m%d%H%M%S
# Default value is equivalent to legacy oldlayout option
# 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
# File path for timelapse mpegs relative to target_dir
# Default: %Y%m%d-timelapse
# Default value is near equivalent to legacy oldlayout option
# For Motion 3.0 compatible mode choose: %Y/%m/%d-timelapse
# File extension .mpg is automatically added so do not include this
timelapse_filename %Y%m%d-timelapse
358行目
# Target base directory for pictures and films
# Recommended to use absolute path. (Default: current working directory)
target_dir /tmp/motion
↑ただし、これだと、終了の時点でフォルダ毎消滅してしまう。それがtempということ。
405行目 公開方法
############################################################
# Live Webcam Server
############################################################
# The mini-http server listens to this port for requests (default: 0 = disabled)
webcam_port 8081
http://localhost:8081/ をみると出ているということ。
http://localhost:8080/ はApache Tomcat全般。
http://localhost/zm/index.php は、zoneminderの管理画面。
633行目から
##############################################################
# Thread config files - One for each camera.
# Except if only one camera - You only need this config file.
# If you have more than one camera you MUST define one thread
# config file for each camera in addition to this config file.
##############################################################
# Remember: If you have more than one camera you must have one
# thread file for each camera. E.g. 2 cameras requires 3 files:
# This motion.conf file AND thread1.conf and thread2.conf.
# Only put the options that are unique to each camera in the
# thread config files.
; thread /usr/local/etc/thread1.conf
; thread /usr/local/etc/thread2.conf
; thread /usr/local/etc/thread3.conf
; thread /usr/local/etc/thread4.conf
つまり、複数台設置したいならば、各カメラごとにthreadを書くということ。
ただし、 当初
/usr/local/etc/
にはなく、
/etc/motion/
に原型がつくってある。ので、それをsudo geditで編集して使う。
さらに一連の画像を一括し合成し一枚にして、メールで知らせるmotionmail.plについては
oops-do.jpn.org/linux/2009/12/30/linux-webcam-alert-mail.html のサイトに詳しい。
----------------------------------------
せっかく設定しても
$ motion
[0] could not open configfile /etc/motion/motion.conf: Permission denied
[0] Not config file to process using default values
[0] Motion 3.2.12 Started
となる、というときは、
$ sudo motion
さらに、
$ sudo motion
[sudo] password :
[0] Processing thread 0 - config file /etc/motion/motion.conf
[0] Motion 3.2.12 Started
[0] Motion going to daemon mode
[0] Exit motion, cannot create process id file (pid file) /var/run/motion/motion.pid: No such file or directory
といってきたら、
いつものように、
username@username:~$ sudo mkdir /var/run/motion/
とする。
◆ffmpegで動画にしたいときは
thunarなりkrenameなりで連番を付けて、
-i desktop/q/img1%03d.JPG
としてしまえばいい。
(これは
http://d.hatena.ne.jp/tettou77-2/20090527/1243405018
に詳しい。)
◆ApacheとかTomcatとかはSynapticからインストールしておけばいいけれど、
$ sudo gedit /var/www/testphp.php に
<?php phpinfo(); ?>
を記入すると、ブラウザから
http://localhost/testphp.php
にて、その状態の一覧が表示されるようになる。
http://www.ac.auone-net.jp/~ina/colinux/web-camera-2.htm
には自宅サーバーとしてweb公開の手順までが紹介されている。