LoginSignup
19
17

More than 5 years have passed since last update.

raspberry piとwebカメラでmotion検知&rubyでmail送信

Last updated at Posted at 2015-04-02

webカメラを接続

sudo apt-get update
sudo apt-get upgrade

lsusb

でwebカメラの接続を確認。upgradeしないとusbを認識しない模様

sudo apt-get install fswebcam
fswebcam ./tmp.jpg

で出力確認

motion検知のライブラリmotionのインストール

sudo apt-get install motion
sudo vim /etc/motion/motion.conf
sudo vim /etc/default/motion

でよしなに編集

sudo service motion start

ストップするか、設定を適切にしないと/tmp/motion/以下にファイルがたまり続けるので注意
デフォルトでは
localhost:8081
にアクセスするとstreamingが見れる

rubyでmail送信

gem install mail

これに時間かかる
sudo vim /etc/motion/motion.conf

on_event_startに~.shを登録
.shファイルに

ruby ~.rb

.rbファイルに

Mail.new
smtpの設定(gmailが楽)

次やりたいこと

lockファイルの作成
envにpasswordを移動
写真をメールに添付して送る

19
17
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
17