Motion Detection, Raspberry Pi & HP HD-2200

So, there is a fair amount of information floating around the web on this, and I’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 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 supported [obviously!] and that it doesn’t need any external power.

This produced images straight away too, but when I ran it on the  width and height parameters in the motion configuration that I’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 – more on this in a moment].

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’m running on a Mac, this wasn’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 – I won’t link to it as none of them worked.

I tried doubling the default resolution [still divisible by 16, as required by the motion software] and… 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’t seeing anything particularly helpful in /var/log/messages – it just seemed to be a copy of standard out – i.e., what’s logged to the screen when you see when you start the motion from the command line.

I did another reboot [a little more graceful this time] with the camera unplugged, reverted to 704 x 576, and it’s now working again, but I’m not convinced about the stability.

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’m using some of the advanced authentication options for Google [being a security bore], I couldn’t get this to work – 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].

I wanted to send the file via email. So I came up with another solution, which unfortunately won’t suit everyone’s needs as I created my own mail account on one of the domains I own. So I’ve created a sacrificial account for the sending of non-SSL emails [for now]. The incantation I’ve used to email the file is:

on_picture_save sendEmail -f myacc@mydomain.com -t myacc@mydomain.com -u “movement” -m “I’m at it again” -s smtp.mydomain.com -xu myacc@mydomain.com -xp my password -o tls=no -a %f.

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.

This also uses sendEmail, which is a  Perl wrapper to sendmail, as it’s a bit easier to use from the command line.

EDIT: I’m coming to the conclusion that the HD-2200 won’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.

I found a thread on a bulletin board in relation to another error I was seeing [Config palette index 8 (YU12) doesn’t work], and which required the install of a library, libv4l-0. I duly installed this, and made the error go away, but still no joy with upping the resolution.

Oh well, if the images being produced are smaller than on my old EyeToy, at least they are a darn sight clearer.

[Final update on this]. I’ve been working on this for about 6 hours now, and am about to leave the field of play. I’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] you see the following:

[1] Config palette index 8 (YU12) doesn’t work.
[1] Supported palettes:
[1] 0: YUYV (YUV 4:2:2 (YUYV))
[1] 1: MJPG (MJPEG)

I’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’m conceding defeat!

Raspberry Pi – Yum!

Raspberry Pi

Raspberry Pi

A friend at work gave me one of these last week and, with the arrival of an HDMI / DVI cable yesterday, I was able to boot it up for the first time this afternoon. As an exercise in getting back into Debian package management, I set up motion, and successfully FTPed some horribly blurry pictures of our cat onto my website, care of a Sony EyeToy camera, which must be about 9 or 10 years old now.

I hope it rains next weekend :).

New Kit for China

I thought I’d use a kit oriented posting to wrap around a few more snaps that I took on holiday. Go on, my loyal readers, you both know who you are: treat yourselves.

I have been meaning to buy a new strap for about as long as I’ve been taking a DSLR on holiday. Of all of the pieces of kit I am going to talk about here, this was the standout. I took the plunge and bought a Black Rapid RS-7. Even I was baulking at the £50 price tag for a strap: it’s clearly very expensive, but it’s also massively – and reassuringly – over-engineered. I did do some digging around for cheaper equivalents [I nearly bought one at about £18] but came to the conclusion that buying a cheap strap was akin to walking into the SCUBA diving kit shop and saying ‘give me the cheapest regulator you’ve got’: potentially regrettable.

The headless ghost of Waibaidu Bridge

The headless ghost of Waibaidu Bridge

The one downside of straps such as the RS-7 is the strange lack-of-safety-net sensation you get when you take it off to attach the bracket for your tripod. But honestly, do yourself a favour: whatever manufacturer is your preferred religion, replace the cheesewire that your camera shipped with.

Advice for life

Advice for life

Another purchase specifically for the trip was one of these. The last couple of trips that I’ve taken my rucksack on, I’ve had to sling it into the outsize baggage when checking in. This may be a British airport peculiarity [because of the straps I was told], but it’s a real pain. I was really pleased with it, and it stood up to a bit of a battering. While I wasn’t carrying anything super-heavy to test the construction to the limit, it served me well and I can thoroughly recommend it.

Hard work

Hard work

As my pitch to my poor long suffering wife for the 16-35mm L lens failed to pass the first round of investment governance, the final piece of kit that I bought for the trip was one of these. OK, a USB chargeable torch isn’t exactly setting the world on fire, but weighing in at a mere £2.38, it has to have the highest feasible utility to price ratio.

Lazy / scruffy combo

Lazy / scruffy combo