Using the captures

Now that we have a set of recorded time-lapse frames, where each has a GPS position attached, there are a number of things that can be done with this data. Here, we will have a quick look at a couple of instances for which we can use the captured frames.

Creating a time-lapse video

The first and probably the most obvious thing that can be done with the images is you can create a time-lapse video in which, each time-lapse image is shown as a single frame of the video, and the length (or speed) of the video is controlled by changing the number of frames per second.

One of the simplest ways to do this is by using either the ffmpeg or avconv utility (depending on your version of Linux; the parameters to each are identical in our case). This utility is available on most Linux distributions, including Raspbian. There are also precompiled executables available for Mac and Windows. However, here I will only discuss using it on Linux, but rest assured, any instructions given here will also work on the Pi itself.

To create a time lapse, form a set of images. You can use the following command:

avconv -framerate FPS -i FILENAME -c:v libx264 -r 30 -pix_fmt yuv420p OUTPUT

Here, FPS is the number of the time-lapse frames you want to display every second, FILENAME is the filename format with %d that marks the frame number, and OUTPUT is the output's filename. This will give output similar to the following:

Creating a time-lapse video

Exporting GPS data as CSV

We can also extract GPS data from each of the captured time-lapse images and save it as a comma-separated value (CSV) file. This will allow us to import the data into third-party applications, such as Google Maps and Google Earth.

To do this, we can use the frames_to_gps_path.py Python script included in the code for this chapter. This takes the file format for the time-lapse frames and a name for the output file.

For example, to create a CSV file called gps_data.csv for images in the frame_%d.jpg format, you can use the following command:

python frames_to_gps_points.py -f frame_%d.jpg -o gps_points.csv
Exporting GPS data as CSV

The output is a CSV file in the following format:

[frame number],[latitude],[longitude],[image filename]

The script also has the option to restrict the maximum number of output points. Passing the --max-points N parameter will ensure that no more than N points are in the CSV file. This can be useful for importing data into applications that limit the number of points that can be imported.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.226.104.27