How To Make A Raspberry Pi Timelapse Camera
How to Create a Time-Lapse With the Raspberry PI HQ Photographic camera
I recently bought a Raspberry PI HQ camera. I am always mesmerized past the sunsets in London. Therefore my offset ever project with the Raspberry PI HQ was to try and create a beautiful time-lapse with the Raspberry PI HQ.
Lense options with the Raspberry PI HQ
When y'all buy the Raspberry PI HQ photographic camera module, it doesn't come with a lens.
For £49.50, or $50 if you live in the United states, you only become the camera module.
You lot need to buy the lens separately. If you decide to buy the official lenses from Raspberry PI, you have two options:
- The 6mm 3MP Wide Bending Lens
- The 16mm 10MP Telephoto Lens
The 16mm 10MP telephoto lens was the one I went with, as I wanted to have the extra zoom adequacy. And you will come across why I was and then peachy on this lense.
What does MP hateful for a camera lens?
Why does the camera lens country the number of MP? Is it just a lens, zippo digital about it, correct? So why state the number of MP?
That is quite a good question to ask and the aforementioned question I had when writing this article.
Commencement a disclaimer, I am no expert in photography, just later on reading some articles on the web and on StackOverflow, I am going to give you my "expert" stance. Simply kidding… whatsoever I say next, take it with a pinch of salt, and please experience free to correct me if you think I said something wrong.
It turns out that digital video cameras are much powerful than their old equivalent analog video cameras. They have a much wider angle of view and they tin embrace several times the expanse that an old analog video camera used to exist able to cover.
For that reason, these cameras are much more than demanding in regard to the camera lens they back up. Because they have a much bigger zoom capability any imperfections in the lense are immediately obvious. The more MP a digital camera sensor has, the more obvious these imperfections are.
For this reason, manufacturers of lenses volition normally specify how many MP the lens supports. For example, a 3MP lens should support a photographic camera with up to 3MP in resolution. And a 10MP lens volition support a photographic camera with a resolution up to 10MP. All this tells y'all is that the manufacturing process for this lens is expert enough to support camera modules with upwards to the number of MP for which the lens is rated for. Exist careful though. The MP value is far from precise.
I would recommend some further reading on this. I have included a good commodity and a StackOverflow thread that should hopefully analyze things for yous.
Installation of the Camera Lens
If you bought the six-mm lens you can screw it directly into the camera module. On the other paw, if you bought the sixteen-mm lens you will need the C-Mount adapter that is supplied with the lens. If you forget to use it, merely like I did, you will know that it is missing because your video image will be forever out of focus, no thing what you practice.
Connecting the Raspberry PI HQ Camera to the Raspberry PI
The adjacent step is to connect the photographic camera to the PI using the blue and white ribbon provided. You lot can connect the Raspberry PI HQ Camera to all versions of the PI except that for the PI 0 yous need a small adapter.
Yous need to connect the ribbon to the CSI connector to the Raspberry PI board. The blue side facing the back of the board.
In one case you have connected the PI Camera to the Raspberry PI, it is time to switch on the PI and do some setup.
In one case the Raspberry PI is powered on, open up a terminal window.
And we execute:
$ sudo apt update
....
followed by $ sudo apt full upgrade
....
This is to ensure that the Raspberry PI is running the latest version of Raspbian and information technology has all the latest patches/updates available to date.
Subsequently this, nosotros demand to execute also in the last
sudo raspi-config
You lot will demand to select the Interfacing Options-P1 Camera. Then select Cease and Reboot.
Taking a moving picture using Raspistill
Now the Raspberry PI HQ Camera should be set up, permit's practise a quick examination with Raspistill. Allow'southward open a terminal window again and try the following:
raspistill -5 -o test.jpg
In my example I got this picture:
Nothing to worry about, the lens is out of focus. At present we know the photographic camera works, we tin can try to focus.
The all-time way to practice that, is to open a alive view of the photographic camera and then we tin adjust the focus accordingly.
Run the following control as the Pi user:
$ raspistill -t 0
Nosotros are passing -t 0 so that the window popup with the view of the camera remains open indefinitely.
Unscrew slightly the screws in the lense, which will allow you to set up first the Discontinuity, which controls how much light goes through the lense. Make sure it is bright plenty.
In one case you have set the Aperture, you tin modify the focus of the lens until the target you lot want to film becomes clear.
Creating a time-lapse with Raspistill
Permit's get down to business organization. Now that nosotros have done the hard work of setting up the PI Camera, it is time to create our time-lapse. And you lot won't believe how piece of cake it is.
You need two tools to create a time-lapse for the PI:
- Raspistill, already installed!
- Ffmpeg, also already installed!
Raspistill is a very versatile command with lots of options for a different number of scenarios. We are going to be relying on the -tl parameter, which unsurprisingly stands for time-lapse. There are a few other parameters that I will explain next.
Duration of time-lapse(-t)
To create a timelapse, commencement, think how long your timelapse is going to be recorded for. Is it for a few minutes, for a few hours, or even for days?
Convert whatever time-lapse you lot demand to the number of milliseconds. That volition exist our -t parameter
The interval between photos(-tl)
In society to create the time-lapse you need to specify how far apart each moving-picture show should be. Typically this interval will increase the longer the timelapse lasts. For instance, if you are doing a timelapse for a month, you desire to take a picture every hour. Or if you are doing a timelapse only for 24h you will want to accept pictures seconds autonomously. For my example, I decided to go with 2s.
Name of each epitome file generated(-o)
We need to choose a name for each prototype to exist generated and likewise a format for the image counter. Remember that nosotros are generating thousands of images. I went with a simple prefix of prototype and 4 digits for the image counter(%4d). For instance the first image will be image0001.jpg, and so on.
Width and Resolution(-w and -h)
Specifying a width and superlative is optional for the timelapse. If yous don't specify it, it will use the maximum resolution bachelor, and each image file will be large. Unless your Pi has a lot of gratis space, specify the resolution of the video time-lapse that you lot are planning to create. In my case, I went with 1920x1080p.
The last command volition look similar:
$ raspistill -t 864000000 -tl 2000 -o image%04d.jpg -w 1920 -h 1080
The command above will create a timelapse with a full duration of 24 hours and an interval of 2s betwixt each picture. All the images volition have a 1920x1080p resolution.
Later on the time-lapse has finished, from inside the binder where the timelapse pictures have been generated, run the following command in the final:
$ for f in *.jpg; do repeat "file '$f'" >> mylist.txt; done
This will create a text file with the file names of every unmarried photo in a text file every bit a sequence. This text file is important for the adjacent step, in which we create the video of the time-lapse using ffmpeg.
ffmpeg -r 320 -f concat -i mylist.txt -r twenty -vcodec libx264 -vf scale=1920:1080 -t ten output.mp4
- -r 320 is how fast we process the pictures in the timelapse. A higher value will make the timelapse go faster and a lower value it volition go slower.
- -f concat, basically tells ffmpeg to concatenate all the images in the list given by -i
- -r 20 the output framerate of the timelapse
- -vcodec the video codec nosotros ue
- and -vf scale controls the resolution
- -t controls how many seconds of video we want to create.
And that is it, subsequently you lot run ffmpeg it is time to enjoy the timelapse.
If y'all want to watch how my timelapse looks similar, you lot can watch this video:
Resource:
Source: https://medium.com/swlh/how-to-create-a-time-lapse-with-the-raspberry-pi-hq-camera-9db9549bb9f3
Posted by: blanfordhendis.blogspot.com
0 Response to "How To Make A Raspberry Pi Timelapse Camera"
Post a Comment