You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This sample application is useful to see patterns of movement over time. For example, it could be used to see the usage of entrances to a factory floor over time, or patterns of shoppers in a store.
3
+
This sample application is useful to see movement patterns over time. For example, it could be used to see the usage of entrances to a factory floor over time, or patterns of shoppers in a store.
4
4
5
-
## What you’ll learn
6
-
*background subtraction
7
-
*application of a threshold
8
-
*accumulation of changed pixels over time
9
-
*add a color/heat map
5
+
## What you’ll learn
6
+
*Background subtraction
7
+
*Application of a threshold
8
+
*Accumulation of changed pixels over time
9
+
*Add a color/heat map
10
10
11
11
## Gather your materials
12
-
* Python 2.7 or greater
12
+
* Python\* 2.7 or greater
13
13
* OpenCV version 3.3.0 or greater
14
14
* The vtest.avi video from https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi
15
15
16
16
## Setup
17
-
1. You need the extra modules installed for the MOG background subtractor. This tutorial was tested on Windows, and the easiest way to install it was using
17
+
1. You need the extra modules installed for the MOG background subtractor. This tutorial was tested on Windows\*, and the easiest way to install it was using:
18
18
```
19
19
pip install opencv-contrib-python
20
20
```
21
21
2. Download the vtest.avi video from https://github.com/opencv/opencv/blob/master/samples/data/vtest.avi and put it in the same folder as the python script.
22
-
3. Run the python script. You should see a diff-overlay.jpg when it's done.
22
+
3. Run the python script. You should see a diff-overlay.jpg when it's done.
The application takes each frame and first applies background subtraction using the cv2.bgsegm.createBackgroundSubtractorMOG() object to create a mask. A threshold is then applied to the mask to remove small amounts of movement, and also to set the accumulation value for each iteration. The result of the threshold is added to an accumulation image (one that starts out at all zero and gets added to each iteration without removing anything), which is what records the motion. At the very end, a color map is applied to the accumulated image so it's easier to see the motion. This colored imaged is then combined with a copy of the first frame using cv2.addWeighted to accomplish the overlay.
41
+
The application takes each frame and first applies background subtraction using the cv2.bgsegm.createBackgroundSubtractorMOG() object to create a mask. A threshold is then applied to the mask to remove small amounts of movement, and also to set the accumulation value for each iteration. The result of the threshold is added to an accumulation image (one that starts out at all zero and gets added to each iteration without removing anything), which is what records the motion. At the very end, a color map is applied to the accumulated image so it's easier to see the motion. This colored imaged is then combined with a copy of the first frame using cv2.addWeighted to accomplish the overlay.
42
42
43
-
IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments.
43
+
IMPORTANT NOTICE: This software is sample software. It is not designed or intended for use in any medical, life-saving or life-sustaining systems, transportation systems, nuclear systems, or for any other mission-critical application in which the failure of the system could lead to critical injury or death. The software may not be fully tested and may contain bugs or errors; it may not be intended or suitable for commercial release. No regulatory approvals for the software have been obtained, and therefore software may not be certified for use in certain countries or environments.
0 commit comments