File tree Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Expand file tree Collapse file tree 2 files changed +23
-0
lines changed Original file line number Diff line number Diff line change 35
35
* face_detection_opencv.py
36
36
* harris_corner_detection.py
37
37
* shi_tomasi_corner_detection.py
38
+ * background_subtraction_opencv.py
38
39
39
40
## Helpful Documentations⭐:
40
41
* OpenCV : https://docs.opencv.org/master/
Original file line number Diff line number Diff line change
1
+ import cv2
2
+ import numpy as np
3
+
4
+ cap = cv2 .VideoCapture ('test_images/vtest.avi' )
5
+ # fgbg = cv2.createBackgroundSubtractorMOG2()
6
+ fgbg = cv2 .createBackgroundSubtractorKNN ()
7
+
8
+ while True :
9
+ ret , frame = cap .read ()
10
+ if frame is None :
11
+ break
12
+
13
+ fgmask = fgbg .apply (frame )
14
+ cv2 .imshow ('image' , frame )
15
+ cv2 .imshow ('FG mask' , fgmask )
16
+
17
+ if cv2 .waitKey (30 ) & 0xFF == ord ('q' ):
18
+ break
19
+
20
+ cap .release ()
21
+ cv2 .destroyAllWindows ()
22
+
You can’t perform that action at this time.
0 commit comments