Quantcast
Channel: CodeSection,代码区,网络安全 - CodeSec
Viewing all articles
Browse latest Browse all 12749

Home Automation and Security SystemOverview

$
0
0

I’ve done a lot of work on my DIY HomeAssistant-based home automation and security system since mylast post on it just over a month ago. While it was a lot of work and frustrating at times, I’m happy to say that I think I’ve finally gotten everything to a usable and working state, and I don’t currently have anything left on my to-do list for this project. I have four working security cameras that run both motion detection and object detection and notify me if a person is detected, a functional alarm system for unauthorized entry, and a few home automationconveniences.

Virtually all of the code and configuration backing this is available in my home-automation-configs GitHub repo but I want to use this post to go over each of the major components as well as some of the difficulties Iencountered.

About a month ago I purchased the two more security cameras I’d been thinking about, a pair of WiFi Amcrest IP2M -852W 1080P with a super-wide 128 field of view. After switching out the IPM -723W (960P / 92 FoV) on my front porch for one of them and mounting the other on the far side of the house, I now have a total of four cameras (three outside, one inside) and coverage of both entrances to my house and all meaningful approaches to theproperty.

One thing I didn’t take into account, unfortunately, was the signal strength from my aged (in-service 24x7 for ) 2.4GHz Ubiquiti Networks access point at the far corners of the house. After a sweaty, hot summer afternoon up on a ladder mounting a camera at the back corner of the house and attempting in vain to aim it using the stream over WiFi, I realized that the construction of my (rental) house causes severe signal shadows at the back corners. I spent a fruitless few hours trying to set up a Netgear WN3000RP “WiFi Range Extender” that I picked up at Best Buy (the setup process was horribly frustrating and error-prone even for someone who worked as a wireless network engineer) only to realize that it was actually a layer 3 router and nothing connected to the extended network could be accessed from my LAN .

After spending another afternoon considering some options - moving my AP or adding another, neither very feasible in a rented house that I don’t want to run permanent cabling in - I ended up using existing holes and wiring paths to hook up both cameras with wired Ethernet. In retrospect, I should have done either a proper wireless site survey or at least some spot tests with my phone or laptop beforehand. It would’ve been much faster if I’d known about the poor signal beforehand, and I also would’ve purchased PoE cameras instead of using the WiFi models which ended up requiring both Ethernet and power cables. On that note, my one complaint so far about the Amcrest cameras is that they are either wired Ethernet with PoE or WiFi with separate Ethernet and 12V DC power cables. I’m not quite sure why they were designed this way as opposed to all supporting PoE, but I assume there’s a manufacturing or costreason.

One thing that I have noticed in the past month of having both wireless and wired cameras is the difference in frame rate. While my one outdoor camera that’s actually using the 2.4GHz WiFi works acceptably well, ZoneMinder is all too happy to show me that it runs at between five and nine FPS , whereas the indoor WiFi and outdoor wired cameras run at the full configured 10FPS rate. If I had to do the camera installation over again, I would’ve spent much more time assessing the 2.4GHz coverage around my house from my existing AP and likely considered PoE cameras for all of the outdoorlocations.

Neural Network ObjectDetection

In my last post, Imentioned how I started passing still images from motion events through Joseph Redmon’s Darknet yolo3 neural network object detection library. With some caveats this has worked out extremely well. While I’ve decided that my cameras are mainly for remote monitoring and possible evidentiary value, and not really for use as an alarm, I’m still pushing notifications from them to my phone when my alarm is armed; I’m just not relying on them as a primary means of detecting aproblem.

One down side to my current setup is the “tiny” version of the yolov3 model that I’m forced to use because of my poor choice of graphics card. I got the feeling that the performance of the tiny model was significantly worse than the full version and, sure enough, comparison tests on the same images proved that. It seems reasonably good at detecting people, but has a relatively high number of false positives. To compensate for this, I’ve built functionality to ignore certain objects in certain locations in to my image processing scripts; I can now easily log but ignore when yolo detects a stump in my front yard as a cow, or my porch railing as abench.

My current code for handling ZoneMinder events, available on github implements what seems to me to be a reasonable workflow for my needs. When events are detected by ZoneMinder a selection of frames - first, last, and a variable number of high-motion (high-score) frames - are passed through yolov3-tiny object detection. Using the tiny model and 1920x1080 frames, this takes about 1/4 second per frame on my GPU . Once a list of detections is obtained (category, confidence level, and bounding boxes for each detected object) it parses the Notes field on the ZoneMinder event to determine what zones motion was detected in, then retrieves the coordinates of each zone on the monitor form ZoneMinder and calculates which zones contain each detected object. All of that information is used to evaluate - via a configuration file - which objects should be ignored. All of this information - the ZoneMinder Event details, object detections and their containing zones, etc. - is passed to HomeAssistant as an event, where it’s picked up by an AppDaemonapp.

Tie-In with AlarmSystem

Once the ZoneMinder events/alarms are sent to HomeAssistant as events they’re picked up by an AppDaemon app, zmevent_alarm_handler.py . This handles the logic behind whether or not to send me a notification for a given ZoneMinder alarm. The logic I’m currently using is asfollows:

If my alarm system is disarmed, nonotification. If no objects were detected by YOLO3 , nonotification. If the only motion was in the “Street” zones, no notification. I have distinct zones for the road in front of my property, and record motion there but don’t alert onit. Formulate a short string describing the objects detected and what zones they’re in, for use innotifications. If an input_boolean in HomeAssistant called “silence_cameras” is not on, send a Pushover notification to my phone containing the description of the alert and the highest-motion frame containing the detectedobject(s). Send an email containing all analyzed/detected frames as well as the full details of theevent. So far this is working quite well for me. I get very few false positives with the above logic combined with object detection, only get notified if my alarm system is armed, and as

Viewing all articles
Browse latest Browse all 12749

Trending Articles