Time Lapse Photography With RPI and Pi Camera

4,774

116

17

I am an Hardcore fan of electronic stuffs and my passion is to build new projects and that is how...

Hey guys, how are you?.This weekend is special as the new RPI 3 is released with more power processing capabilities and to get to know it abilities there is nothing good like testing a real project on it.

I am a amateur photographer and for me ,taking photos of the nature gives me immense pleasure . Time lapse photography is a great way to see the changes in the nature and enjoy it, but there are some impediments like heavy bulky camera with very low battery backup and the most important " Security" of the Camera, Come on who would dare to leave 2000$ camera open in the wild for days??

So here is the solution yes you guessed it right, RPI 3 with Pi camera an excellent and cheap technique to take time lapse photography. and enjoy nature while forgetting all the unnecessary worries which get us bogged down

So folks get ready and tighten your seatbelts and lets dive into the world of time lapse photography !!!

Step 1: Materials Required

You will need a couple of things. Here I have used the latest RPI 3 version, but it can be used with other predecessor boards also. So here is the following list

1. RPI 3 ( with latest NOOBS package)

2.Power Adapter (If you are using RPI 3 make sure that you power it up with at least 2.5 A adapter)

3. PI camera.( I am using a NOIR camera, basically it does not have an IR filter)

4. HDMI to VGA converter (for displaying the output of RPI in PC monitor)

5. PC standard size monitor

6. Keyboard and Mouse

7. And yup the most important of all 60 Minutes of your precious time for building this project :)

*Note: The instructable assumes that the user has some knowledge on how to install raspbian OS from the NOOBS package.

Step 2: Enabling the Pi Camera

This is the foremost step , in the process of building the project is to enable the Pi camera .

1. Connect your Pi camera to RPI carefully.

Do not forget to peel of the blue lens cover of the camera , if your camera is new!!

2. Boot your RPI

3. Open your Terminal and type the following:

sudo raspi-config

And after that select Enable, then Finish and Yes to reboot.

(see the screenshot for better understanding.)

Step 3: Installing Python Support

Now we will install the python support for the Pi camera

1. Type the following command:

sudo apt-get install python-picamera python3-picamera

sudo apt-get install ffmpeg

2. Once done , start the python environment

sudo idle &

This will bring up the python environment. Python is a easy language to learn and understand and that is why the whole project is based on it.

Step 4: Testing the Camera

So we have installed all the necessary files. Now lets see if the camera is ready!!

1. Go to the File menu of the Python Environment opened

2. Select a new file. A blank environment will be opened.

3. Now type in the code for testing camera

(Note : Code is attached down below)

4.Save and Press F5

5. You will see the preview for a very few seconds and then a .png file will be saved in the Desktop

Step 5: Code Explaination:

# The time and picamera files have been imported

import time

import picamera

# The parameters such as No of days the camera should be active, frames per hour and total no of frames

NO_OF_DAYS = 1

FRAMES_PER_HOUR = 60

FRAMES = FRAMES_PER_HOUR * 24 * NO_OF_DAYS

#Pi camera as the source

def capture_frame(frame):

with picamera.PiCamera() as cam:

time.sleep(2)

#The frame is captured and saved into the Desktop

cam.capture('/home/pi/Desktop/frame%03d.jpg' % frame)

# Capture the images

for frame in range(FRAMES):

# Note the time before the capture

start = time.time()

capture_frame(frame)

# Wait for the next capture. Note that we take into account the length of time it took to capture the image when calculating the delay

time.sleep(
int(60 * 60 / FRAMES_PER_HOUR) - (time.time() - start)

)

Step 6: The Result!!!

Awesome we have reached the last step and now follow the below step

Type below command in terminal

sudo idle &

1. Go to the File menu of the Python Environment opened
2. Select a new file. A blank environment will be opened.

3. Now type in the code for timelapse(Note : Code is attached down below)

4.Save and Press F5 (To Execute)

5. Then just see your destination folder. The photos will appear in a systematic order thus creating a Time Lapse.

6. Open a Image Viewer and see the photos one after the other and Enjoy !!:)

To Stop the execution in Python IDLE press Ctrl+F6

Now start enjoying the Nature with this simple time lapse set up with RPI

Have fun guys and Happy Inventing!!! See you next weekend with more exciting project:)

Share

    Recommendations

    • First Time Author

      First Time Author
    • Toys Contest

      Toys Contest
    • Big and Small Contest

      Big and Small Contest

    17 Discussions

    0
    None
    calebv4

    2 years ago

    Is it required that I have a Raspberry Pi 3, or would a 1 or 2 work just fine?

    2 replies
    0
    None
    VIVEK GRcalebv4

    Reply 2 years ago

    Raspberry Pi 1 or 2 would do fine. RPi 3 has an inbuilt Wifi so , It was easier for me to download all the necessary libraries from the internet. :)

    0
    None
    ThomasW193

    2 years ago

    Is this for Python 2 or 3 because it sure doesn't work with 3. Also, as others have said ffmpeg no longer is available. Camera never turns on and the error says the location with 001.jpg doesn't exist.

    1 reply
    0
    None
    VIVEK GRThomasW193

    Reply 2 years ago

    Hi , this is with python 3. You can try reinstalling the python libs and for ffmpeg, it has become obsolete.

    0
    None
    NorCalAl

    2 years ago

    When I tried to install ffmpeg, I was told the install source no longer existed. Went to the ffmpeg site and was presented an uncompiled version (which is something I've not done). Is ffmpeg tied to having included a certain source for install packages?

    1 reply
    0
    None
    VIVEK GRNorCalAl

    Reply 2 years ago

    Sorry , I guess ffmpeg has become obsolete!

    0
    None
    JagmeetS13

    2 years ago

    It's great. A must read for all Raspberry Pi fans!

    0
    None
    adashh

    2 years ago

    are the connections same for rpi2?

    0
    None
    Aravind.

    2 years ago

    Awesome !!

    0
    None
    Dr H

    2 years ago

    Nice.
    Just FYI: They have released a new RPi camera today with 8 M and a new sensor.

    Is there a tool for the RPi to connect the JPGs to a movie?

    3 replies
    0
    None
    VIVEK GRDr H

    Reply 2 years ago

    Thank you Dr H for the information. Regarding the question could you be more specific

    0
    None
    Dr HVIVEK GR

    Reply 2 years ago

    Sorry, I should have been more precise.

    I am not sure, but I guess I saw somewhere a tool to generate a movie out of individual images. But I can't remember any details.

    So I hoped you might have a hint, preferably for something working on the Pi.

    0
    None
    VIVEK GRDr H

    Reply 2 years ago

    Yes Now I understand Dr H, yes you can compile those images to form a kind off video.

    For that just install omxplayer and type in the following command

    ffmpeg -y -f image2 -i /home/pi/Desktop/frame%03d.jpg -r 24 -vcodec libx264 -profile high -preset slow /home/pi/Desktop/timelapse.mp4

    Then :

    omxplayer timelapse.mp4

    0
    None
    belaltweets

    2 years ago

    This is so great I think others could benefit from learning about it.

    2 replies