loading

My 4 year old son wanted to see how his dinosaur egg hatches.... The ideal excuse for making a timelaps video with a Raspberry Pi!

I already have my tripod from my first instructable ever: https://www.instructables.com/id/Smartphone-Tripod-...

I'll use this one to position the camera on the egg.

All I need now is a script:

  • to make the pictures every 10 minutes and save them on a ubs stick
  • to bring all those pictures together in a gif file

Materials:

  • Raspberry Pi: I used the B+ model. But you can also use the raspberry pi 2 or 3
  • Raspberry Pi Camera Module (https://www.raspberrypi.org/products/camera-module... )
  • a usb stick
  • a tripod
  • adhesive tape
  • Optional: a computer, screen and keyboard
  • and of course: a dinosaur egg! (https://www.amazon.com/Dino-World-Grow-Egg-Dinosau...)

Let's get started!

Step 1: Setting Up the Pi and Camera

I'll start under the assumption you have a Raspberry Pi up and running.

Make sure you have the camera module well connected and enabled on the pi. This is a very good tutorial: https://www.raspberrypi.org/documentation/usage/ca...

I attached the camera on my pi with some adhesive tape.

Take some time to make your setup with the object or landscape you want to film and install the pi on the tripod. Make sure it is stable and avoid moving the tripod.

Make some testpictures or make a very short timelaps video with the script that comes in the next step. Adjust your setup untill it is perfect!!

Now, let's go to the software side of the story.

Step 2: Shooting the Pictures

I've made the following script for taking the pictures.

Let's take a closer look at it!

  • First we import some necessary libraries

import os
from picamera import PiCamera
from os import system
from time import sleep

  • we prepare the camera and you can set a resolution of your choise. The # in front of the second line means that the line won't be used. Delete the # to change the resolution

camera = PiCamera()
#camera.resolution = (1024, 768)

  • we will mount an usb-stick to save the pictures on, in the folder 'images'

os.system("sudo mkdir /mnt/images")
os.system("sudo mount /dev/sda1 /mnt/images")
os.system("ls /mnt/images")
os.chdir('/mnt/images/')

The line 'os.system("ls /mnt/images")' will show all the files in the folder, so you can check if you are in the right place!

  • This part of the code let you make 10 pictures with a time interval of 10 seconds. You can adjust this by changing the amount of pinctures (change the number after range) or the interval (change the number after sleep). It all depends on how many photo's you want and the period of time.

for i in range(10):
camera.capture('image{0:04d}.jpg'.format(i))
sleep(10)

  • This line will print 'Done' to the screen when all the pictures have been taken

print('Done')

You can download the script here. It is ready to use!

Type sudo python timelaps.py to start the process


Step 3: Bring It Together in a Timelaps Video

After we have taken our pictures, it is time to bring it all together in a timelaps gif!

This is the script for making the gif:

  • Again, we start with importing some libraries

import os
from picamera import PiCamera
from os import system

  • Again, we mount the usb-stick to save everything on, in the folder 'images'

os.system("sudo mkdir /mnt/images")
os.system("sudo mount /dev/sda1 /mnt/images")
os.system("ls /mnt/images")
os.chdir('/mnt/images/')

  • This command 'glues' the pictures together. The number after '-delay' tells you how long each photo will be shown. This is in milliseconds. So here, every picture is shown 20 milliseconds

system('convert -delay 20 -loop 0 image*.jpg animation.gif')

  • When your gif is ready, you will see the message 'done'

print('done')

Attention!

  • Depeding on the amount of pictures you use and the resolution of them, it can take some time, for the process to be finished. Be patient!!
  • You might get an error because the 'images' folder already exists. No worry, it won't stop the process!

You can download the file here.

Type python make.py to start the process

Step 4: A Dinosaur Egg Hatching!

TADA!!! My son goes crazy when he sees the video!

Bear in mind that this is shot in our livingroom, without good lights! You will also notice that a round object (the egg) does not always stays stable om its position :-)

This 35 sec long video has 707 pictures in it, each one displayed 50 milliseconds. The pictures have been taken with an interval of 10 minutes over a period of approx. 130 hours. This amount of pictures is to much for the make.py script, so I used MovieMaker (Microsoft) to make the video. It took a few seconds to put it together!

Resources used to make this project:

I hope you like it and get timelapsing!!

cool dino

About This Instructable

324views

10favorites

Bio: Amateur tinkerer from Belgium. Loves tinkering, IoT, hacking, soldering, Raspberry Pi, Arduino,.... But this doesn't mean I'm good at it :-)
More by Tinker-Bel:Timelaps a Dinosaur Egg With Raspberry Pi! Build an Alexa With Raspio Pro Hat and Raspberry Pi Smartphone tripod from recycled selfie stick and handycam tripod 
Add instructable to: