Fellow Our Code reader Andrea shares the latest update on video tracking project built with RaspPi in today’s Part II post. In the first part of series, Andrea detailed her planning process, sharing logistics on materials, networking, and getting the microcontroller to connect. Click here to read Part I.
Where I was at the end of my last post: I had a pineapple, and a Raspberry Pi B+ [along with the camera module], which I had programmed to take a photo at a given time three times each day. I was testing the idea of using a power pack to provide power to the Raspberry Pi.
Using my power pack turned out to be a bit of a fail. It was a power pack I’d been given for free as a promotion by a mobile network, so I didn’t have the highest of hopes for it. While it did supply adequate power to run the Pi without the rainbow square in the corner (which indicates not enough power to the Pi), it didn’t hold enough power for it to run for more than a short amount of time. It was more in terms of hours, than days. Weeks would have been the best scenario for a portable power supply. I ended up moving an existing extension lead, and used a charging cable I had for a previous phone, secured with a bit of Blu-tack to make sure it wouldn’t move the Pi around at all. Plugged in, I left the Raspberry Pi running for a few days to see what it would produce.
I also had to play around with the placement of the Raspberry Pi. I’ve played around with cameras a lot, but I wasn’t sure what the camera module would be like. The official documentation told me that the camera was fixed focus, with the depth of field being from 1m in front of the lens to infinity. You can read a little about focal length and depth of field here.
Placing the pineapple 1m in front of the lens wasn’t going to work. For one thing, my window sill wasn’t that long, and it would make the pineapple much too small in each photo. It was time to get creative! I knew other people must have had the same issue; time lapse photography is a pretty popular Raspberry Pi project, so I took to the internet to see how they were dealing with it.
A few sites and forum posts tried to reassure me that I could in fact change the focal length of the lens by delicately turning it, but considering I’d just managed to snap the small plastic frame I’d bought to hold the camera module, I wasn’t about to go anywhere near the lens with a pair of pliers! Some of the more DIY Raspberry Pi discussions online introduced me to the idea of using a lens from a cheap pair of reading glasses. Suddenly it was like the clouds were parting above me! I consider photography a hobby of mine, so I was familiar with the idea of using lenses to bring a subject in closer and fill the frame. I also knew of a camera shop around the corner from where I work, so I decided to drop in and discuss what I wanted to do with someone.
I prefaced my explanation with “Now, this may sounds a bit odd, just bear with me!..” Thankfully the guy had heard of the Raspberry Pi before, and thought my project sounded kind of cool! He wasn’t too familiar with the camera module itself, but when I explained that the lens was pretty small, (around 1cm wide- just estimating), he pulled out a drawer of various lenses. For someone who loves photography, the sight of that drawer was pretty sweet! I explained that the depth of field started around 1m but I wanted to bring that in to probably about half that distance, but that I wasn’t completely sure exactly how close the subject would be. I ended up getting two Hoya lenses, a +2 dioptre lens, and a +4 dioptre lens- because the effect of the lenses is cumulative, that meant I would be able to get the effect of +2, +4, or +6, depending on how far I decided to sit the subject from the camera. You can read about dioptres here.
Because I’ve positioned the camera module inside the Raspberry Pi case, I had no real way to attach the new lenses. There are small clips at the top/front to hold it, which is quite nice–keeps it all together. The Raspberry Pi inside the case and the cables were already Blu-tack’ed into place, so I thought that Blu-tack’ing the lens to the front of the case seemed like an okay solution. I had previously considered using black electrical tape, thinking that it also might cut down on any glare, but was worried that it might leave a residue on the Pi case and also on the lenses, so decided against it.
I attached the +2 lens to the front of the Pi case and the difference was obvious! I was super impressed with the images that were being produced! It felt great to have images that were so well-focused on the first try after fighting with the camera module for so long to get ones that were almost okay. I stayed with the +2 lens: the subject filled the frame nicely and the lines and edges in the image were crisp.
The HDMI cable I used to connect the Pi to the TV I was using as a monitor doesn’t get left in place when I’m not using it- it’s a pretty awkward location, and the cable is quite thick. Whenever I’m finished tinkering around with the Pi for a while I unplug the cable, and then use my phone as an overpriced level to make sure that the Pi’s case (and the camera inside!) are level. This just makes sure that the photos are as consistent as possible when I stitch them together to make a video. It would be kind of funny/weird if someone got seasick from watching it though!
Now I had to leave the Raspberry Pi and the pineapple, cross my fingers and hope for the best!
A Kulbaba: When she’s not playing with sugar or getting covered in chocolate in my day job as a pastry chef, she’s busy with all sorts of geekery! Andrea blogs mainly about learning to be a front-end web developer, and her tinkerings with a raspberry pi. Follow her on Twitter @AKulbaba and read her blog Part Timer here.