openwrt也成功挂载摄像头,那么前一篇提到的家庭安防就完美了

安装 usbutils 模块,完成后执行lsusb 命令将会显示摄像头的相关信息,如下图:

安装kmod-input-core模块;kmod-video-uvc 模块,如下图:(如果摄像头不支持UVC,此步可略过)

安装 kmod-i2c-core 模块;kmod-usb-video 模块;kmod-video-gspca-core 模块。

我因为已经装过了上面的一些驱动,就直接装了下面的

opkg install kmod-video-uvc
ls /dev,如果有vedio的话,说明驱动安装成功(前提是要把摄像头插上)
opkg install mjpg-streamer
mjpg_streamer -b -i "input_uvc.so /dev/video0 -r 640x480 -yuv" -o "output_http.so -p 8080 -w /web"
# -b 表示后台运行,一开始最好不要,不然出错信息都没法看到。-yuv 表示改成YUV格式
在Firefox或者Chrome中查看:
192.168.0.2:8080/?action=stream(动态视频)
192.168.0.2:8080/?action=snapshot(静态图像)可以设置mpjg_streamer的自动运行,参考http://www.igee.cn/read.php?tid=5324&page=1 ,添加一个启动脚本。这时可以使用-b参数。

调用启动命令参考

  • uvc摄像头参数
mjpg_streamer -i "input_uvc.so -r 352x288 -f 15 -q 80 -y"  -o "output_http.so -p 8080 -w /www"
  • 301摄像头参数 [4]
mjpg_streamer -i "input_uvc.so -r 640x480 -f 30"  -o "output_http.so -p 8080 -w /www"

安装motion

装好后先运行一次生成/etc.motion.conf

 

有异常行为时发邮件及短信

opkg install mutt msmtp

配置msmtp
要先去注册一个126的邮箱,这里是通过126的邮箱来发送邮件。
cat /etc/msmtprc
account default
host smtp.126.com
auth login
user 3gcomet
password 123456
auto_from off
from  3gcomet@126.com
syslog LOG_MAIL
logfile /var/log/msmtp.log

也可以使用ssmtp

首先安装mutt  ssmtp,设置/etc/ssmtp/ssmtp.conf 以gmail为例:

#
# /etc/ssmtp.conf — a config file for sSMTP sendmail.
#

# The person who gets all mail for userids < 1000
# Make this empty to disable rewriting.
root=YOURemail@gmail.com

# The place where the mail goes. The actual machine name is required
# no MX records are consulted. Commonly mailhosts are named mail.domain.com
# The example will fit if you are in domain.com and your mailhub is so named.
mailhub=smtp.gmail.com:465

# Example for SMTP port number 2525
# mailhub=mail.your.domain:2525
# Example for SMTP port number 25 (Standard/RFC)
# mailhub=mail.your.domain
# Example for SSL encrypted connection
# mailhub=mail.your.domain:465

# Where will the mail seem to come from?
rewriteDomain=gmail.com

# The full hostname
hostname=gmail.com

# Set this to never rewrite the “From:” line (unless not given) and to
# use that address in the “from line” of the envelope.
FromLineOverride=YES

# Use SSL/TLS to send secure messages to server.
UseTLS=YES

# Use SSL/TLS certificate to authenticate against smtp host.
#UseTLSCert=YES

# Use this RSA certificate.
#TLSCert=/etc/ssl/certs/ssmtp.pem

# Get enhanced (*really* enhanced) debugging information in the logs
# If you want to have debugging of the config file parsing, move this option
# to the top of the config file and uncomment
#Debug=YES

编辑.muttrc 并copy到etc目录下改名为muttrc

# The file/directory where your incoming mail will be spooled to
# (same as ‘set spoolfile’ below)
mailboxes /tmp/mail

# Mail account setup.  I know nothing about IMAP, so you’re
# on your own there.
set sendmail=”/usr/sbin/ssmtp -v -au YOURemail@gmail.com -ap password”
set from=”YOURemail@gmail.com”

# Mail folder setup.
set folder=/tmp/mail
set mbox_type=mbox
set spoolfile=+inbox
set mbox=+received
set postponed=+postponed
set record=+sent

发送邮件指令

echo "This is the message body" | mutt -a "/path/to/file.to.attach" -s "subject of message" -- recipient@domain.com

 

分享到:

1 条评论

昵称
  1. Pingback: 完善版的家庭安防监控 | fusion for Future