{"id":428,"date":"2020-11-27T12:55:59","date_gmt":"2020-11-27T12:55:59","guid":{"rendered":"https:\/\/carson.fenimorefamily.com\/?p=428"},"modified":"2020-11-27T12:57:09","modified_gmt":"2020-11-27T12:57:09","slug":"architecture-for-diy-ai-driven-home-security","status":"publish","type":"post","link":"https:\/\/carson.fenimorefamily.com\/?p=428","title":{"rendered":"Architecture For DIY AI-Driven Home Security"},"content":{"rendered":"\n<p>The raspberry pi&#8217;s ecosystem makes it a tempting platform for building computer vision projects such as home security systems.  For around $80, one can assemble a pi (with sd card, camera, case, and power) that can capture video and suppress dead scenes using motion detection &#8211; typically with <a href=\"https:\/\/motion-project.github.io\">motion<\/a> or <a href=\"https:\/\/raspberry-valley.azurewebsites.net\/MotionEye-OS\/\">MotionEye<\/a>.  This low-effort, low-cost solution seems attractive until one considers some of  its shortfalls:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>False detection events.  The algorithm used to detect motion is suseptible to false positives &#8211; tree branches waving in the wind, clouds, etc.  A user works around this by tweeking motion parameters (how BIG must an object be) or masking out regions (don&#8217;t look at the sky, just the road) <\/li><li>Lack of high level understanding.  Even in tweeking the motion parameters anything that is moving is deemed of concern.  There is no way to discriminate between a moving dog and a moving person.  <\/li><\/ul>\n\n\n\n<p>The net result of these flaws &#8211; which all stem from a lack of real understanding &#8211; is wasted time.  At a minimum the user is annoyed.  Worse they are fatigue and miss events or neglect responding entirely.  <\/p>\n\n\n\n<p>By applying current state of the art AI techniques such as object detection, facial detection\/recognition, one can vastly reduce the load on the user.  To do this at full frame rate one needs to add an accelerator, such as the Coral TPU.  <\/p>\n\n\n\n<p>In testing we&#8217;ve found fairly good accuracy at almost full frame rate.   Although Coral claims &#8220;400 fps&#8221; of speed &#8211; this is inference, not the full cycle of loading the image, running inference, and then examining the results.  In real-world testing we found the full-cycle results closer to 15fps.  This is still significantly better than the 2-3 fps one obtains by running in software.<\/p>\n\n\n\n<p>In terms of scalability, running inference on the pi means we can scale endlessly.  The server&#8217;s job is simply to log the video and metadata (object information, motion masks, etc.).<\/p>\n\n\n\n<p>Here&#8217;s a rough sketch of such a system:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"587\" height=\"1024\" src=\"https:\/\/carson.fenimorefamily.com\/wp-content\/uploads\/2020\/11\/Screen-Shot-2020-11-27-at-6.35.59-AM-587x1024.png\" alt=\"\" class=\"wp-image-429\" srcset=\"https:\/\/carson.fenimorefamily.com\/wp-content\/uploads\/2020\/11\/Screen-Shot-2020-11-27-at-6.35.59-AM-587x1024.png 587w, https:\/\/carson.fenimorefamily.com\/wp-content\/uploads\/2020\/11\/Screen-Shot-2020-11-27-at-6.35.59-AM-172x300.png 172w, https:\/\/carson.fenimorefamily.com\/wp-content\/uploads\/2020\/11\/Screen-Shot-2020-11-27-at-6.35.59-AM-768x1339.png 768w, https:\/\/carson.fenimorefamily.com\/wp-content\/uploads\/2020\/11\/Screen-Shot-2020-11-27-at-6.35.59-AM.png 874w\" sizes=\"auto, (max-width: 587px) 100vw, 587px\" \/><\/figure>\n\n\n\n<p>This approach is currently working successfully to provide the following, per rpi camera:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>moving \/ static object detection<\/li><li>facial recognition<\/li><li>3d object mapping  &#8211; speed \/ location determination<\/li><\/ul>\n\n\n\n<p>This is all done at around 75% CPU utilization on a 2GB Rpi 4B.  The imagery and metadata are streamed to a central server which performs no processing other than to archive the data from the cameras and serve it to clients (connected via an app or web page).<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The raspberry pi&#8217;s ecosystem makes it a tempting platform for building computer vision projects such as home security systems. For around $80, one can assemble a pi (with sd card, camera, case, and power) that can capture video and suppress dead scenes using motion detection &#8211; typically with motion or MotionEye. This low-effort, low-cost solution &hellip; <a href=\"https:\/\/carson.fenimorefamily.com\/?p=428\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Architecture For DIY AI-Driven Home Security<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,18,14,10],"tags":[],"class_list":["post-428","post","type-post","status-publish","format-standard","hentry","category-computer-vision","category-deep-learning","category-raspberry-pi","category-web-programming"],"_links":{"self":[{"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=\/wp\/v2\/posts\/428","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=428"}],"version-history":[{"count":2,"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=\/wp\/v2\/posts\/428\/revisions"}],"predecessor-version":[{"id":431,"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=\/wp\/v2\/posts\/428\/revisions\/431"}],"wp:attachment":[{"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=428"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=428"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/carson.fenimorefamily.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=428"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}