Raspberry Pi WEBカメラで防犯カメラを自作 motion設定

IoT

こんにちは、カトーです。

少し前にRaspberry PiでWEBカメラを繋げて防犯カメラを自作する記事を書いたのですが、必要とするmotionが若干アップデートしているので忘備録として書いておきますね。

ちなみに動体検知などはできますが、画像加工はOpenCVが楽です。今回はmotionの設定についての説明ですよ。

 

motionとは?

About Motion
Motion is a highly configurable program that monitors video signals from many types of cameras.
Set it up to monitor your security cameras, watch birds, check in on your pet, create timelapse videos and more.
Create videos or save pictures of the activity
Passthrough recording from many IP cameras
View live stream of cameras
Invoke scripts when activities occur
Log activity into multiple types of databases
Fully customizable masks for privacy or motion detection
Full tls(https) support with authentication for webcontrol and streams

@See this https://motion-project.github.io/

ざっくり書くと、インストールも簡単に画像・動画の保存、それに伴いイベントWEBコントロールもできるという事です。

 

インストール

インストールは簡単

 

motion.log: Permission denied と出てますので、実際に運用に合わせて権限をあわせます。

 

設定

今回いれたバージョンは4.3.2です。公式を見ると2021-11-22時点、4.4.0もでているので最新版を入れたい場合はwgetで取得になります。

さて、設定を見ていきます。motioを入れた場所には、

camera1~4のcont とmotoin.confがあります。それぞれのカメラごとに設定もできますが、全体はmotion.confで設定します。

参考;https://motion-project.github.io/4.3.2/motion_config.html

$ cat motion.conf

全部で171行程しかありませんので、必要に応じて参考元の動作にパラメーターを加えていきます。

今回、防犯カメラという事でイベントは以下設定でしょうか?

Script Execution-General Info
https://motion-project.github.io/4.3.2/motion_config.html#OptDetail_Scripts
セキュリティの注意もあります。

Security Warning!
These features mean you have to pay attention to the following.
Anyone with access to the remote control port (http) can execute any command on your computer with the same privileges as the user running Motion. Anyone can access your control port if you have not either limited access to localhost or limited access using firewalls in the server. You should always have a router between a machine running Motion with remote control enabled and the Internet and make sure the Motion control port is not accessible from the outside.
If you limit control port to localhost you still need to take care of any user logging into the server with any kind of GUI or terminal session. All it takes is a browser or single command line execution to change settings in Motion.
It is a good idea to run Motion as a harmless user. Not as root!!

on_event_start
Type: String
Range / Valid values: Max 4095 characters
Default: Not defined

書き方としては、

また動体検知のところには

とすると検知ができます。

 

まとめ

さくっと設定するには本当に便利です。

現在は顔検出となるとOpenCVになるのでしょうけど、サクッと防犯カメラとして設置して動体検知後にメールを送付やリレーを使って電源管理するならこれで十分です。また最近のGPIOがある小型ボードであれば人感センサや圧力センサ、CO2センサなど使えば本格的な防犯システムもできそうです。もちろん電源やサービスが落ちてたなんてありそうなので、死活監視の必要ですが。

 

最新情報をチェックしよう!
>システム構築・保守に特化した会社です。

システム構築・保守に特化した会社です。

システムの構築・保守運用「システムガーディアン」 社内システム担当が欲しいが、専属で雇うほどの仕事量はない。 必要な時に必要なだけ頼りたいというお悩みを持つ企業様へ専門知識を持って対応を行っております。 サーバから各種システムまで自社・他社で構築されたシステムに対してサポートを行っております。

CTR IMG