home github email bird of the day (site last updated on 10/29/21)

Bird of the Day

posted on 5/7/21

I have lots of birds in my yard here in Texas so I was thinking one day how it would be cool if something could tell me roughly how many birds were in my yard chowing down on some of the excellent bird seed I buy for them. In the past I've worked with computer vision and machine learning tools so I figured I could put a computer to work to do the hard stuff of monitoring my yard and alerting me when the never-ending-eating-birds were back. I had a few Raspberry Pis on hand already that would fulfill that role nicely.

I began searching for a weather proof case I could purchase to put one of the Pis in but wasn't too successful. I then decided to browse sites that host 3d printable models and found a great case called the RainBerry. Definitely worth the few bucks since I have a 3d printer. Small adjustments were necessary due to the power supply I decided to use. I wanted the viewing device to run on solar. I bought the excellent PiJuice along with a PiJuice 12 watt solar panel. I modified the source 3d model files in Blender until I had something that fit all of the electronics snugly. Additional parts were required to weather proof the printed case like rubber o-rings and rubber tubing that I acquired from McMaster. You can find all of the details here on the construction.

Once the case for Raspberry Pi that will be mounted outside was finished I went to work attaching it to my bird house that I already had out in my front yard. It was a good choice for mounting the computer and I attached an extra piece of post that I cut a slight angle out of to secure the solar panel. A few wood screws later and the front yard was all set to start observing birds. The program that I wrote to occasionally snap photos is written in Python and run recurringly via crontab. For the identification of birds in the photo all of that work is done by Azure's Computer Vision Service. An incredibly easy Python library is provided from Microsoft so it didn't take long at all to finish implementing that part of the program. Every 20 seconds a photo is captured, sent to Azure for object detection and then all of the coordinates of birds is returned, if any.

With all of the required data I set about constructing the other computer which will be sent all of this bird related info. My Raspberry Pi Zero W board is a great small size computer that will do the work of showing me the bird count. I really like 7 segment displays so I found a super easy to control one from SparkFun that I could communicate with via i2c. Connecting that 7 segment board to the Pi only required a couple wires soldered directly in since this device would be permanent. The software I wrote for this computer was again Python and it too runs recurringly via crontab. It checks every 15 seconds for a bird_count file scp'd from the computer outside and then reads that file and sends the number to the 7 segment display. Nothing fancy. Once again I utilized my 3d printer to build a very simple case to house the bird counter.

For extra fun when the time reaches 5:00 PM the outside computer randomly selects a photo of birds that was taken earlier, randomly picks a set of saved coordinates for a single bird in the chosen photo, crops to that chosen bird and then transmits the photo to the inside computer which continues to pass it along to Twilio that texts me the photo to my phone. Pretty cool. I deem the selected photo the "Bird of the Day" and store those on my website here.

I enjoyed putting this all together and enjoyed even more finishing it. I may do occasional tweaking to the bird count or computer vision settings to optimize the bird detection in the future. Here are some photos that highlight the project:

go back