Code Monkey home page Code Monkey logo

travelogger's Introduction

travelogger

TraveLogger is a Raspberry Pi (Zero) based configurable timelapse recorder written in Python. It is compatible with RPi camera modules as well as USB cameras.
Just set the input-time, the output-time, and the output frame-rate, and travelogger will do everything else on its own.


Dependencies and Packages

Debian

For RPi camera modules, the frames are captured using raspistill, and that for USB cameras using streamer.
Install them using sudo apt-get install raspistill streamer

Next, a few more packages need to be installed for stitching the frames together. This article by phamthanhnam on Raspberry Pi Forums advised that the OpenMAX plugin in gstreamer supports the Raspberry Pi GPU and can stitch the images much faster with far less CPU utilisation.

sudo sh -c 'echo deb http://vontaene.de/raspbian-updates/ . main >> /etc/apt/sources.list'

sudo apt-get update

sudo apt-get install libgstreamer1.0-0 liborc-0.4-0 gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 gstreamer1.0-alsa gstreamer1.0-omx gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-base-apps gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly gstreamer1.0-pulseaudio gstreamer1.0-tools gstreamer1.0-x libgstreamer-plugins-bad1.0-0 libgstreamer-plugins-base1.0-0

Python

The script uses
argparse for conventional argument parsing, and
psutil for getting available disk space

Install these using
pip3 install -u argparse psutil


Usage

For a quick test, run:

python3 recorder.py

On headless installations (with no GUI or X-session), run:

python3 recorder.py -fu

A new folder with the script's runtime-stamp will be created and all frames and the stitched video will be stored in it.

Configurables

Argument Short Default Value Description
--image-prefix -ip timelapse prefix for image name
--image-extension -ie jpeg image extension
--folder-prefix -fp timelapse prefix for folder name
--frame-size -fs 1280x720 resolution of captured frame
--input-time -it 1800 recording input time
--output-time -ot 60 recording output time
--total-frames -tf 1440 total frames
--out-frame-rate -ofps 24 output fps
--force-input -fi False force input from a video device
--forced-device -fd video0 custom input for video device

Examples

python3 recorder.py -fp ../timelapse -ip sunset -fs 640x480 -it 3600 -ot 30

sets and displays the following configuration:

In:	0.200 FPS	Out:	24.000 FPS
Total recording time = 1 hr 00 min 0.00 sec
Total timelapse time = 0 hr 00 min 30.00 sec
Factor (In : Out)    = 120.00
Estimated disk usage = 70.3125 MB (720 frames)
Avaliable disk space = 6745.21875 MB

and stores all files with the prefix sunset in a folder named timelapse outside the parent directory.

All examples can be repeated on headless installations by adding -fi flag.
A custom input video device can be selected by using the -fd flag.

python3 recorder.py -fp ../timelapse -ip sunset -fs 640x480 -it 3600 -ot 30 -fi -fd video2

Forcing total frames

python3 recorder.py -fp timelapse -ip sunset -fs 640x480 -tf 500 -ofps 30

sets and displays the following configuration:

In:	0.278 FPS	Out:	8.333 FPS
Total recording time = 0 hr 30 min 0.00 sec
Total timelapse time = 0 hr 00 min 60.00 sec
Factor (In : Out)    = 30.00
Estimated disk usage = 48.828125 MB (500 frames)
Avaliable disk space = 6743.77734375 MB

Notice that the set output frame-rate value was over-ridden with the set number of frames.


Problems

VCHIQ instances

* failed to open vchiq instance
is a known error prompt which is encountered while trying to use the GPU for stitching the images.
It is probable that the user running travelogger is not in the video group.

Add the user to the video group using:
sudo usermod -aG video $(whoami)

It is probably better from a perspective of security to make a separate user with video permissions and run travelogger through that user.

Root permissions

On headless installations with new users, reading the video device requires root privileges, which is difficult for setting up cron-jobs, essentially defeating the very utility of travelogger.
The solution, again, is adding the user to the video group as mentioned above.


travelogger's People

Contributors

thecurryspice avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.