Sticky Backed Plastic …

… well, not quite. But a big long bit of wood, a (really) heavy planter (which I usu­ally use to sit on), and some par­cel tape. Noth­ing that the BBC Spring­watch tech-crew will feel too threat­ened by but I’m feel­ing pretty pleased with myself.

Some­times think­ing about things too much is a bad idea. I wanted the web­cam, away from the build­ing, point­ing at the nest­box. And I couldn’t work out how to do it. So I went for a walk. Around the gar­den, and around the garage. And 10 min­utes later …

Look­ing good but despite tweak­ing with mask files and exper­i­ment­ing with the con­fig­u­ra­tion for motion I still end up with over 10,000 images at the end of the day, a ran­dom snap­shot of which get upload to my flickr pho­to­stream.

housekeeping script to keep jpegs manageable

This crops up peri­od­i­cally and it sur­prises me that with all the free tools you get with linux that there’s noth­ing (that I can find, at least) that will allow me to keep a folder tree within a man­age­able size. I did write a shell script to do this but I’ve lost it. With a web­cam using motion often trig­ger­ing over 5000 images a day (four times that if it’s windy) I need to have some auto­mated house­keep­ing to purge the older images.

I think what I had before was some­thing that had a user-definable value (e.g. 5GB) and it would iter­a­tively recurse a direc­tory tree, delet­ing the older direc­to­ries until the space taken up dropped below the thresh­hold. There are prob­lems with this (e.g. acci­den­tally Tag­ging or touching an old jpeg) that causes the direc­tory time stamp to be updated. But all these thou­sands of jpegs are pil­ing up and I’ll have to address this some­time soon.

Mask files, sizes, and motion.conf tweaks

The tweaks don’t seem to be hav­ing much effect. Even with the lightswitch option set to 80, and the smart_mask_speed set to 10, it’s still pretty wild and windy out there.

# Dynamically create a mask file during operation (default: 0)
# Adjust speed of mask changes from 0 (off) to 10 (fast)
smart_mask_speed 10

# Ignore sudden massive light intensity changes given as a percentage of the picture
# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled
lightswitch 80

So it has to be the mask file. The way the mask file works is by using an iden­ti­cally sized image as the web­cam and mak­ing all areas to be mon­i­tored white, and all not to be mon­i­tored black. Or is it the other way around? I did this using the gimp and after a cou­ple of false starts it turned out to be pretty easy. Here’s my rough notes:

  1. Make a copy of an exist­ing web­cam image to use as the tem­plate. This way the dimen­sions of the image will be correct
  2. Use the Free Select Tool (it looks like the laso) to select an area that you want to be mon­i­tored for movement.
  3. Select Bucket Fill. Under the sec­tion for Affected Area make sure it’s ticked for Fill Whole Selec­tion. Make sure your fore­ground colour is white (I kept get­ting this wrong. It doesn’t mat­ter. Just click on the arrows to reverse foreground/background and do it again).
  4. Click on the area to be filled and it should fill with white.
  5. For the back­ground, go to Select -> Invert, then swap your fore­ground and back­ground colours. Click on the area you want to be black

You need to save this as a ‘pgm’ file. For some rea­son a pgm file is huge com­pared to a jpeg, e.g.

-rw-r--r-- 1 dougie dougie 691254 2011-05-25 14:24 mask1 - 25May2011_1407.54-00.pgm
-rw-r--r-- 1 dougie dougie  12639 2011-05-25 14:26 mask1 - 25May2011_1407.54-00.jpg

although I’m sure it’s pos­si­ble to reduce the size there doesn’t seem much need at the moment.

Mask File for motion

mask file

Now it’s just a mat­ter of point­ing the appro­pri­ate option in motion.conf at the mask file and see­ing what happens.

Here’s my first attempt:

 

 

motion.conf options

Hmmmm, there are a few options in the motion.conf file I haven’t seen before. Or at least, that I can’t recall hav­ing see­ing before. These look promising:

# Dynamically create a mask file during operation (default: 0)
# Adjust speed of mask changes from 0 (off) to 10 (fast)
smart_mask_speed 0

# Ignore sudden massive light intensity changes given as a percentage of the picture
# area that changed intensity. Valid range: 0 - 100 , default: 0 = disabled
lightswitch 0

The trou­ble with cre­at­ing a mask file is that it assumes the cam­era stays fixed in the same posi­tion, and that’s pretty unlikely. So I’ll try tweak­ing these set­tings and see what hap­pens. Far less effort. Cur­rently run­ning at about 1000 images an hour. Let’s see if I can get that down a bit …

 

controlling the loco-motion

So here’s the problem:

This is a USB web­cam point­ing at the nest­box. The soft­ware is motion, run­ning on a Linux Mint box, and upload­ing to my flickr pho­to­stream using flickr_upload. There are a cou­ple of home­brew shell scripts involved too.

The trou­ble is, even though the motion con­fig file can be tweaked and var­i­ous things twid­dled to adjust var­i­ous thresh­olds, most of which are black magic, all it needs is a windy day and I find I’ve got 40,000 or so JPEGS on my hard­drive. All of blades of grass blow­ing in the wind.

So I think I’m going to have to cre­ate a mask file. I can’t remem­ber how to do it, even though I’ve done it many times before. I’ll do that later. And I’ll write it down.