{"id":807,"date":"2012-11-17T14:35:21","date_gmt":"2012-11-17T14:35:21","guid":{"rendered":"https:\/\/zogspat.tk\/blog\/?p=807"},"modified":"2013-08-17T11:23:23","modified_gmt":"2013-08-17T11:23:23","slug":"motion-detection-and-raspberry-pi","status":"publish","type":"post","link":"https:\/\/the-plot.com\/blog\/?p=807","title":{"rendered":"Motion Detection, Raspberry Pi &#038; HP HD-2200"},"content":{"rendered":"<p>So, there is a fair amount of information floating around the web on this, and I&#8217;ve hit on a couple of wrinkles which are worth sharing.<\/p>\n<p>As I mentioned in my previous post, I had got the motion package up and running very quickly with my old EyeToy camera. As the picture quality was pretty awful, I ordered up an HP HD-2200, which arrived this morning. The over-riding principles for picking this camera are that it is <a title=\"RPI Verified Peripherals\" href=\"http:\/\/elinux.org\/RPi_VerifiedPeripherals\" target=\"_blank\">supported<\/a> [obviously!] and that it doesn&#8217;t need any external power.<\/p>\n<p>This produced images straight away too, but when I ran it on the \u00a0width and height parameters in the motion <a title=\"motion config\" href=\"http:\/\/www.lavrsen.dk\/foswiki\/bin\/view\/Motion\/ConfigFileOptions\" target=\"_blank\">configuration<\/a>\u00a0that I&#8217;d been using for the EyeToy [640 x 480], I was getting what looked like a scanning line at the bottom of the image and the motion software seemed to go into a loop [based on my horrible hacky configuration &#8211; more on this in a moment].<\/p>\n<p>The motion documentation indicated that this was probably an issue with the chosen resolution, so I started to chop and change it. This was the start of a couple of hours [EDIT: make that half a day!] of messing with various resolution settings, and researching the problem. The camera documentation refers you to the functionality of a Windows binary for adjusting this and, because I&#8217;m running on a Mac, this wasn&#8217;t an option. I found a list of width \/ height settings on a random shopping site selling the camera, and I went through all of them &#8211; I won&#8217;t link to it as none of them worked.<\/p>\n<p>I tried doubling the default resolution [still divisible by 16, as required by the motion software] and&#8230; This is inconclusive. It worked, then I changed the settings, and changed them back to 704 x 576, and it stopped working again. Continuing to mess with the settings caused the kernel to crash at one point. I also wasn&#8217;t seeing anything particularly helpful in \/var\/log\/messages &#8211; it just seemed to be a copy of standard out &#8211; i.e., what&#8217;s logged to the screen when you see when you start the motion from the command line.<\/p>\n<p>I did another reboot [a little more graceful this time] with the camera unplugged, reverted to 704 x 576, and it&#8217;s now working again, but I&#8217;m not convinced about the stability.<\/p>\n<p>One other quick point: there is a fair amount of documentation which refers to the motion configuration option on_event_start, which gives example setting for gMail. While I&#8217;m using some of the advanced authentication options for Google [being a security bore], I couldn&#8217;t get this to work &#8211; I kept getting an SSL error. The example I saw every time was of an email indicating that a file had been uploaded to an FTP server [which I also played with].<\/p>\n<p>I wanted to send the file via email. So I came up with another solution, which unfortunately won&#8217;t suit everyone&#8217;s needs as I created my own mail account on one of the domains I own. So I&#8217;ve created a sacrificial account for the sending of non-SSL emails [for now]. The incantation I&#8217;ve used to email the file is:<\/p>\n<p>on_picture_save sendEmail -f myacc@mydomain.com -t myacc@mydomain.com\u00a0-u &#8220;movement&#8221; -m &#8220;I&#8217;m at it again&#8221; -s smtp.mydomain.com -xu myacc@mydomain.com -xp my password -o tls=no -a %f.<\/p>\n<p>So your mileage may vary here, assuming that your smtp server requires authentication [which it should], and that it is also happy to not speak TLS [which it may not]. So the -a %f is what adds the image file as an attachment.<\/p>\n<p>This also uses sendEmail, which is a \u00a0Perl wrapper to sendmail, as it&#8217;s a bit easier to use from the command line.<\/p>\n<p>EDIT:\u00a0I&#8217;m coming to the conclusion that the HD-2200 won&#8217;t support a resolution higher than the default [352 x 288] the motion package. A more careful look at the logs, after yet another unexplained end to motion loading with my config, showed that it was resetting the resolution to 800 x 600. This is unsupported, as 600 will throw a modulo 16 error if you try to start with this width. That, at least, is reasonably consistent.<\/p>\n<p>I found a thread on a bulletin board in relation to another error I was seeing [Config palette index 8 (YU12) doesn&#8217;t work], and which required the install of a library,\u00a0libv4l-0. I duly installed this, and made the error go away, but still no joy with upping the resolution.<\/p>\n<p>Oh well, if the images being produced are smaller than on my old EyeToy, at least they are a darn sight clearer.<\/p>\n<p>[Final update on this]. I&#8217;ve been working on this for about 6 hours now, and am about to leave the field of play. I&#8217;ve tried doing some changes to the palette setting, based on running motion in setup mode [the -s flag on the command line]. If you do this at a resolution higher than the default but with the default setting for v4l2_palette [8]\u00a0you see the following:<\/p>\n<p>[1] Config palette index 8 (YU12) doesn&#8217;t work.<br \/>\n[1] Supported palettes:<br \/>\n[1] 0: YUYV (YUV 4:2:2 (YUYV))<br \/>\n[1] 1: MJPG (MJPEG)<\/p>\n<p>I&#8217;ve had a play around with the corresponding flags for these [2 and 6], and they both have problems at 640 x 480. My conclusion is that 352 x 288 is as high as a resolution as usable with the motion package. AKA I&#8217;m conceding defeat!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So, there is a fair amount of information floating around the web on this, and I&#8217;ve hit on a couple of wrinkles which are worth sharing. As I mentioned in my previous post, I had got the motion package up &hellip; <a href=\"https:\/\/the-plot.com\/blog\/?p=807\">Continue reading <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":[5],"tags":[],"class_list":["post-807","post","type-post","status-publish","format-standard","hentry","category-tech"],"_links":{"self":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=807"}],"version-history":[{"count":16,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/807\/revisions"}],"predecessor-version":[{"id":968,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/807\/revisions\/968"}],"wp:attachment":[{"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/the-plot.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}