Giter Club home page Giter Club logo

trapcam's Introduction

trapcam

Experimental camera trap for linux mini computers such as Raspberry Pi, ODROID, Orange Pi, and similar.

  • Requires a USB webcam that provides MJPEG and has a microphone for audio input. One example is the Logitech HD Webcam C525.
  • Depends on libuvc and PortAudio.

Purpose

My intent was to capture short video clips of a frequent loud event in our neighborhood. The idea was that whenever the loud event happens, we can use the webcam's microphone to detect the event and trigger the camera.

Method

I wanted to capture video as close in time to the lound sound event. In order to do this, we power up the video camera at the start of the program and wait for the audio process to detect a loud sound.
When the audio process detects a loud sound, it sends a message via a pipe to the video process, which then immediately captures a short video clip and saves it.

Multiprocessing

We use python multiprocessing to keep the audio and video capture running in separate (child) processes. You could do all of the work in a single process or using eg python threads. Since the mini computer I used has multiple cores, I opted to take advantage of them.

Setup

Depending on your linux configuration you may need to install various audio and video libraries.

Results

Typically we're able to capture a frame or two of video from before the audio trigger happens, then the moment when the trigger happens, and then some number of frames after the trigger. Although we don't send the trigger message to the video process until after the audio event happens, the video capture driver is actually constantly receiving a video stream from the camera and some arbitrary amount of buffered video data is captured at the moment the trigger is sent. Your mileage may vary depending on the specific webcam, linux distribution, and mini computer hardware you're using.

Further work / customization

  • As configured, the audio process ignores loud noises that happen within a 3-second window after the most recent loud noise. This is an arbitrary setting to "debounce" the triggering noise.
  • We don't currently save the audio with the video. It might be possible to save the audio clips and then add them as an audio track with eg ffmpeg.
  • We're sending the timestamp of the audio trigger event to the video process. This could be used to fine-tune the video capture control, if we're concerned about audio trigger events arriving faster than the video process can capture.
  • The video camera is constantly powered up. If you're installing a camera trap in a remote location on eg battery power, you might find this burns too much power. You could modify the video recorder to only create a new Capture (cap = uvc.Capture) when triggered. This means there would be a much longer delay between the audio trigger and the start of video capture-- but maybe that's OK for your purpose.

trapcam's People

Contributors

tstellanova avatar

Watchers

James Cloos avatar  avatar  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.