• Stars
    star
    256
  • Rank 159,219 (Top 4 %)
  • Language
    Python
  • Created over 12 years ago
  • Updated about 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Python/OpenCV script that detect motion on webcam and allow record it to a file

Motion-detection-OpenCV

Python/OpenCV script that detect motion on webcam and allow record it to a file.

The simple way

The trivial idea is to compute the difference between two frames apply a threshold the separate pixels that have changed from the others and then count all the black pixels. Then the average is calculated with this count and the total number of pixels and depending of the ceil the event is triggered or not.

Additional informations:

  • initRecorder: initialise the recorder with an arbitrary codec it can be changed with problems
  • in the run method no motion can be detected in the first 5 second because it is almost the time needed for the webcam to adjust the focus and the luminosity which imply lot's of changes on the image
  • processImage: contains all the images operations applied to the image
  • somethingHasMoved: The image iteration to count black pixels is contained in this method

The result of applying it can be seen here: https://www.youtube.com/watch?v=-RUu3EcielI

The smart way

Iis way to operate is less trivial than the previous one, but the results are identical if not more accurate in the previous method. I inspired myself of the Motion-tracker by Matt Williamson for the operations and filters to apply on the image but all the rest is different. The idea in this method is to find the contours of the moving objects and calculate the area of all of them. Then the average of the surface changing is compared with the total surface of the image and the alarm is triggered if it exceed the given threshold. Note the code shown below does not implement the recording system as it is the case on the previous example, but it can be made easily.

The result of applying it can be seen here: https://www.youtube.com/watch?v=sRIdyfh3054

More Repositories

1

LSB-Steganography

Python program to steganography files into images using the Least Significant Bit.
Python
879
star
2

Pytesser

Python wrapper for the tesseract OCR engine. The module is based on OpenCV
Python
178
star
3

idasec

IDA plugin for reverse-engineering and dynamic interactions with the Binsec platform
Python
115
star
4

pydes

Basic but pure DES implementation in Python
Python
67
star
5

pyADS

Python module to manipulate NTFS Alternate Data Stream (ADS) in Python
Python
55
star
6

Captcha-basic-recognition

Python module that intent to crack basic captcha engines using OpenCV and Pytesser
Python
39
star
7

OpenCV-tutorials

Contain the hole source code of my OpenCV tutorial
Python
33
star
8

pystack

Pystack, is a python framework that allow to create small TCP/IP stacks in an easy manner in order to obtain a wanted behavior.
Python
27
star
9

checksec

Bash script to test executable properties like (PIE, RELRO, PaX, Canaries, ASLR). (Version derivated from the original one trapkit.de/tools/checksec.html
Shell
20
star
10

Python-programs

Contains various python programs and proof of concept.
Python
10
star
11

pytts

Text-To-Speech multi-platform in python. It uses Google translate as engine.
Python
8
star
12

breach_compilation_utils

BreachCompilation utils for iterating logins and passwords
Python
5
star
13

lsbbrute

Script to bruteforce the LSB of an image to find file signatures (in every channel permutation, rotation etc..)
Python
5
star
14

pydimacs

Python module to manipulate CNF DIMACS formulas (using z3)
Python
4
star
15

LyricsTagger

Python program, that automaticaly tag lyrics in MP3 files.
Python
3
star
16

Cryptoid

ryptoid is a toy app to apply weak ciphers on plain text. (Mostly developped to learn how to develop an app).
Java
2
star
17

RobinDavid.github.io

My Github pages
HTML
2
star
18

Python-samples

Contains few python scripts for everything and nothing
Python
2
star
19

Bash-network-game

This project is a fully working 2 player network game written in bash. It intents to show the possibilities of bash which is not a simple script program.
Shell
2
star
20

RobinDavid

1
star
21

codeql-uboot

CodeQL
1
star