Bora and I were really excited about the gif making capacities of Raspberry Pi. We both happen to have a love for plants and thought it would be cool to make a project that does the following:
- Launches a python file from the Terminal
- Takes one photo of a plant every two minutes for two hours, resulting in 60 photos
- When this process is done, automatically generate a gif from the images
- When the gif is complete, open and play the gif in the browser
Then we discovered a tutorial on the Raspberry Pi website that tells you how to take the photos and generate the gif. We decided to begin by following this tutorial with the intension to add onto the project to differ it from the instructions.
This was not as simple as we expected. After many hours of trying to get avconv to work, we switched to another media making library. ffmpeg had its issues as well. We spent the next day wading through forums, trying to find a command that would create the gif. Here are a couple of our attempts. They seem simple but neither of us are proficient at python so each took a very long time – between 2 – 5 hours of finessing.
Finally we found something that would work. We paired it with some code that would run it in the terminal and one more line that would open the video in the browser.
Then we ran a series of super short tests that compiled around 10 images into a gif.
Foolishly we deleted these to make space for our final gif so sadly we can’t attach any of our test gifs. They worked very well so we felt confident that things would work in our two hours setting.
So we set up the scene. We chose a plant that we thought would be most likely to move as the sun set. We also tried to select based on how dry the soil was. We thought that a nice drink of water would perk up the plant and also create more movement.
Then we took a test image so that we could see what the pi saw.
We ran the code from the Terminal and let it go!
The spoiler is that it didn’t work 😦
Two hours later, we checked the system and found an error disclaiming that there was a “kernal error”. Our best guess was that the amount of space we assigned the final gif did not match the overall size of the large images that were being taken. This caused a fatal glitch at the end of the process.
As you can see from this snippet, it took the photos but our gif doesn’t open.
So, after giving it a valiant effort, we compiled the gif manually in an editing software. In this process we learned (the hard way) that, after flashing the drive with pi software, you can’t grab files from it off of a computer as though it was a drive. Good to know!
Here’s what the gif looked like.
Overall, it was a lot of fun to work on! We learned so much and will take this on to our other projects. We’ve both also developed a love for python and are looking forward to exploring it further.