Time-Lapse with Raspberry Pi
Jun 17, 2023
Use Raspberry Pi and OpenCV to create time-lapse videos.
Jul 1, 2023 06:14 PM
Taking time-lapse videos with Raspberry Pi is not a new idea but it is a great opportunity to get to know your Raspberry Pi better as a beginner.
Before following the instructions below, be sure that you have completed the Raspberry Pi OS installation and Python OpenCV installation steps.
If everything is ready, let’s get started;
After connecting to the Raspberry Pi with ssh, we need to clone the time-lapse project to the Raspberry Pi local file system from GitHub.
git clone https://github.com/canberkdurmus/time-lapse.git cd time-lapse
Before running the project we can customize the parameters of our time-lapse video. We can use
nanoto edit the
- The first parameter is the capture period in seconds. If it is set to 1, the program will be capturing a new photo every 1 second.
max_frames: Maximum number of frames that are going to be captured. If the period is set to 1 second and max_frames is 240; the Pi is going to capture photos for 4 minutes.
resolution: Resolution of the captured images and the final video.
fps: FPS of the final video. If the period is 1 second and
max_framesis 240, the program will be using 24 frames to create one second of the video so we will have a video of 10 seconds in length.
data_folder: The name of the folder in which the images are going to be saved and read.
You can exit from nano after editing the main.py by pressing
Control+Xfor Mac) and pressing
Ywhen nano asks if you want to save the changes.
You can run the program with
It will start capturing and saving images to the data folder. In the end, it will be exporting a video to the
You can copy the video from the Raspberry Pi to your computer with ssh. You should run the line below on your local terminal, not on the Raspberry Pi terminal. Replace the IP address of the Raspberry Pi. Replace the path and the name of the video by checking it out on the terminal that you connected to the Raspberry Pi using ssh with
scp [email protected]:/home/pi/time-lapse/video/2021-12-15-14-38-06.avi .
This is the result of my first test with two minutes, converted to a gif and heavily compressed. Yeah, the weather is not the best.