Friday, 28 March 2014

BirdBoxPiCam 2014: News from the Nest

The blue tits arrived at the beginning of March and continued to visit almost every morning for a few weeks.


However, they wasted too much time faffing around and lost their deposit. A pair of new comers arrived on Monday the 24th and took control.


This post provides an update on nesting activities and adds some technical details regarding operation and performance.


Box Move


On the drive back from Essex on Sunday the 23rd March, I took the decision to move the box. There were a number of reasons:-
  • the blue tits had only visited the box once that weekend
  • the box has a fairly large entrance hole (I think its 32mm...big enough for a nuthatch) but its position, so close to the house, would mean it was only likely to attract the gregarious blue tit, as in fact it had done for the last 5 seasons.
  • some of the local cats were showing an unhealthy interest in the activity at this site

So when I got home that night, I made use of the failing twilight and quickly moved the box from the archway to the pergola, effectively doubling the distance from the house, and moving it further away from the adjacent flat roof. This position has been used very successfully in previous years.

When I got home from work the next day, I checked the video clips and was surprised to see the black head of a great tit. Now these birds don't faff around. They normally arrive, check out the box and start building within 48 hours.


The great tit take-over

Nest Composition


With the excellent video quality of the PiCam, I've noticed a few nest building details.
  • The initial material includes a few dead leaves to bulk up the base of the nest (robins use lots of dead leaves, tits much less so).
  • They also bring in long straw like stems, which get pushed to the sides as more material is added to the nest. This creates a structure that holds the nest together, which hardly seems necessary, as the nest is fully contained by the walls of the box.
  • Moss from our lawn and the garage roof seems to make up the bulk of the nest, which is supplemented with dog hair (we have a giant clump hanging up) which is carefully pressed into the nest cup.

Its now Friday, and nest building has virtually stopped. The female (I presume) has been in a few times today with moss and dog hair, but I think she is satisfied with her work. I hope to see her spending the night in the box very soon, which will be an indication that the egg laying phase is about to start.

Technical Stuff


The great RaspberryPi news this month was the introduction of new Pi/PiCam firmware which gives full frame size video image and 90fps mode. So I'm no longer stuck with the restricted "zoomed in" view I had before. (Many thanks to James Hughes & co)

It also means I can ditch the idea of using Stills mode with Motion, as this was not proving very reliable.

RaspiVideo Mode


From my control program I can select regular video mode, effectively running a Linux command via Gambas which looks like this:-

Exec ["raspivid", "-w", "640", "-h", "480", "-b", "500000", "-t", "30000", "-o", strFileID]

Giving a 640x480 resolution, 500kb/s, 30 second h264 video clip like this:-


Note: This video looks a lot better running from the original file than it does on this blog page.
I view these h264 videos using VLC Media Player on my Lubuntu laptop, as I've had some problems with other players (...probably just due to missing support files/codecs). The file size is 1.8MB.

With a clear sky and the box lights turned off, I seem to get good results for most of the day. On very cloudy days it is more difficult to see detail in the box.

I did turn the lights on one morning ("dim mode" only), and when the female came back she hesitated before entering the box...so I haven't done it since!

High Speed, Slow Playback


The 90fps video mode takes video at a high rate and encodes it at about one third speed. So although this is not up to BBC standard, I do hope to get some interesting "slo-mo" when parents start feeding their chicks.

Raspi-Stills Mode


This mode is triggered from my control interface and runs a Linux command via Gambas like this:-

Exec ["raspistill", "-t", "30000", "-tl", "5000", "-w", "1280", "-h", "1024", "-q", "75", "-o", strFileID & "%02d.jpg"]

...which gives me 7 images over a 30 second period.

"OK, OK...that's way too much dog hair!"

These images have a 1280x1024 resolution, a jpeg quality of 75% and a file size of about 900kB.

Motion Capture


Most of the time the system is automatically capturing video using Kenneth Lavrsen's excellent software, called simply "motion".

Each motion capture video is just a series of jpegs stitched together and converted into an avi file.


This video is jerky because motion is just set to capture 4fps at the moment. Its on my to-do list to experiment with this further, but this is fine for background monitoring.

Although I haven't taken any real care in setting motion up, I don't seem to be getting too many false triggers. I have created a mask to limit detection to the centre (base) of the box. But because my software is the weak link at the moment, I haven't tried to use it (I'll explain later).

My method for creating a mask:-
  • take one of the still jpg images created by motion
  • open in The Gimp
  • draw a rectangular box to cover the area you want to detect activity in
  • paint within the box using white brush
  • paint outside the box using black brush
  • export the image as a raw/binary pgm file (portable Grey Map)
  • set motion config "mask_file" to point to this file

Once I've sorted out the problem with my Gambas app I'll give this a try.

Up until this year, my preferred method for monitoring video from the motion web server was to use the Firefox web browser. This just involved typing in the url: http://192.168.0.15:8081

Unfortunately Firefox seems to have developed a bug (a memory leak), so while the above method does work, it slowly consumes my RAM until the laptop grinds to a halt.

So once again its VLC Media Player to the rescue. The two methods of using this are:-
  • open VLC
  • select Media > Open Network Stream
  • enter the network url: http://192.168.0.15:8081 {or whatever yours is}
  • press Play

...or use the Linux command line:-

cvlc http://192.168.0.15:8081

Designed To Crash


Although my Gambas program is working well, I'm still having problems with my Settings file. The Gambas Settings object is supposed to make it easy to maintain your setting (ini) file. But when my system shuts down due to inactivity, about 1 in 5 times the settings file is wiped, so I lose my history of battery usage, box events, motion threshold & so on.

Putting this right is my next priority. I've got one more idea to fix this, and if this doesn't work I'll probably ditch the setting method and manage my own file.

Once this is fixed, I can start to use my motion detection mask file, and tune other motion settings.

Monica The Monitor


During the early weeks, when birds visit the box less frequently, its nice to get an alert when the system is triggered, if you happen to be in the house at the time.

So this year I dug out a network monitor program that I'd written in Gambas to monitor servers & switches at work. My colleagues call this "Monica the Monitor".

I created a modified version to perform 2 tasks:-
  1. Ping the garage server and alert if this is not reachable
  2. Ping the RaspberryPi bird box and alert if this IS reachable

This simple program uses eSpeak. So if we hear Monica say "Bird box, on" we can rush to the screen and view motion via VLC. If she says "Garage server, down" I rush to the garage with a big stick.

For more information take a look at "Giving your computer a voice".

BirdBox 2015


I'm already thinking ahead to the 2015 season.

I walked around our garden the other night using my Android phone to check wifi signal strength. I was pleasantly surprised to find good coverage over most of the garden. So next year I may deploy 3 or 4 RaspberryPi powered bird boxes.

One thing that has surprised me is the cost of my design. I drew up a parts list and added typical prices for everything excluding the wooded box itself, and this is just over £100.

In my mind I'd estimated it would be well under £100, but some post & package charges seem inevitable, especially for any Farnell or RS components. The best sources of supply include Spiratronics, sourcingmap and some other Amazon suppliers (especially if you can cut-out Amazon and deal direct).

Picking up the [real] time from the garage server has worked faultlessly since moving away from NTP. I may replace my Compaq D510 server with a RaspberryPi, in which case I'll have to add an RTC to just the Pi server.

This would also mean abandoning my existing analogue cameras as there still seems to be no way of getting either my EzCap or Somagic video devices working on the RaspberryPi. Although these guys have made great progress with the Somagic devices on Linux during the last 12 months.

One addition that would be useful is a battery voltage interface. Most of the time I just swap batteries well ahead of their discharged state, but if I have 3 or 4 to juggle next year, it might not be so easy.

Initial thoughts are to use a low cost LM393 dual comparator. Maybe one section to indicate that the battery should be replaced soon, and the other to hold the Pi power off if the voltage drops too low. At the moment I'm taking readings from my 12Ahr battery to see if this is feasible.

No comments:

Post a Comment