Giter Club home page Giter Club logo

motiondetector's Introduction

Motion Detector

Motion Detector detects when significant movement has occurs in a parsed video, an image is then saved along with the timestamp when a movement event has occured. The processing image showing what has moved in the frame is also saved. This code was was originally written to detect when a level crossing was down and a train went pass in a video that was several hours long without having to waste time watching the entire video. Don't ask, related to some friends university project.

It operates using the frame difference across the current frame and previous two frames. The difference frame is given by the maximum of the difference between the current frame and either of the previous two.

def frame_diff(img_vold, img_old, new_img):
    img_diff0 = cv2.absdiff(new_img, img_old)
    img_diff1 = cv2.absdiff(img_old, img_vold)
    return cv2.bitwise_or(img_diff0, img_diff1)

The average value of the frame is taken, this is added to an array consisting of the last n_sample, by default 1000, if the current average exists offset times the standard deviation then an event is said to off occured. A frame will only be saved once initally triggered, the trigger will be set back to false when the critical conditions are no longer met.

Setup & Quick Start

Getting the app to run is pretty easy. MotionDetector requires OpenCV and Numpy, to install OpenCV. It also requires a path to the video file to process which must be an AVI or mp4 video, this is parsed via the -v/--video_path argument. To save the event images the -u/--dump_path argument should be parsed with a valid directory along with the -i/--dump_images command. To display the images the -d/--display argument should be parsed, and to set the logger to debug mode -e. To display help messages then the -h argument should be parsed.

git clone https://github.com/WillBrennan/MotionDetector MotionDetector
cd MotionDetector

python main.py -v <path to avi/mp4 video file> -u /media/psf/Will/datasets/MotionDetector -i -d -e

Demonstration

Demo on Level Crossing

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.