Skip to content

Commit cf707ac

Browse files
committed
add new coding files
1 parent b3aaff7 commit cf707ac

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

Readme.md

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
* face_detection_opencv.py
3636
* harris_corner_detection.py
3737
* shi_tomasi_corner_detection.py
38+
* background_subtraction_opencv.py
3839

3940
## Helpful Documentations⭐:
4041
* OpenCV : https://docs.opencv.org/master/

background_subtraction_opencv.py

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
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+

0 commit comments

Comments
 (0)