Time: 20 minutes
Difficulty: Easy
You Will Need:
- A Raspberry Pi.
- Some way to access it's terminal. You can use SSH, Remote Desktop, or keyboard and mouse.
- A USB webcam.
Steps:
- Plug in your USB webcam before powering on your Pi.
- Power on your Pi and open the terminal.
- Type sudo apt-get install fswebcam. This is a simple way to use a webcam with your pi. You can test it by typing fswebcam /home/pi/Desktop/this_is_my_test_picture.jpg. You will see your picture
- Type mkdir /home/pi/Desktop/Timelapse
- We will now write a bash script to take the pictures.
- Type sudo nano /home/pi/Desktop/timelapse.sh
- In the nano editor, type DATE=$ (date +"%Y-%m-%d_%H%M")
- On the next line type fswebcam /home/pi/Desktop/Timelapse.
- Press CTRL+X, then y, and then Enter to exit nano.
- Right now all our script does is take a picture. We want it to take lots of pictures at specified intervals. To do this, we will use cron, a way of scheduling tasks to run on the Pi at certain intervals.
- To edit your crontab (the place where cron looks to find out which command to run) type crontab -e in the command line. You will see this window.
- In the bottom, in a new line, type * * * * * /home/pi/Desktop/timelapse.sh. Save with CTRL+X, Y, and Enter. You should then the message "crontab: installing new crontab"
- If everything is set up correctly, you should start to see pictures in your Timelapse folder.
- You can use any video editor to turn your stills into a video. According to the Raspberry Pi website, you can use the following commands to convert the pictures on the Pi.
- sudo apt-get install mencoder
- cd /home/pi/Desktop/Timelapse
- ls *.jpg > stills.txt
- mencoder -nosound -ovc lavc -lavcopts vcodec=mpeg4:aspect=16/9:vbitrate=8000000 -vf scale=1920:1080 -o timelapse.avi mf type=jpeg:fps=24 mf://@stills.txt
No comments:
Post a Comment