Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated README.md #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
Motion-detection-OpenCV
=======================

Python/OpenCV script that detect motion on webcam and allow record it to a file.
Python/OpenCV script that detects motion on webcam and allows it to record on 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.
The simple and commonly used idea is to compute the difference between two frames by applying a threshold to 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 ceiling the event is triggered or not.

**Additional informations:**

Expand All @@ -15,11 +15,13 @@ The trivial idea is to compute the difference between two frames apply a thresho
* 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 result of applying it can be seen here in this video: 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]("https://github.com/mattwilliamson/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.
This 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 by the [Motion-tracker]("https://github.com/mattwilliamson/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