Skip to content

Commit ead0a6f

Browse files
Added OpenCV Background Detector with 2 examples
1 parent ac36e58 commit ead0a6f

File tree

5 files changed

+22
-0
lines changed

5 files changed

+22
-0
lines changed
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import numpy as np
2+
import cv2
3+
4+
# Uses Read video.py
5+
myVideo = cv2.VideoCapture('Sevilla.mp4')
6+
7+
# Choose 100 random frames
8+
myFrames = myVideo.get(cv2.CAP_PROP_FRAME_COUNT) * np.random.uniform(size=100)
9+
10+
frames = []
11+
for f in myFrames:
12+
myVideo.set(cv2.CAP_PROP_POS_FRAMES, f)
13+
ret, frame = myVideo.read()
14+
frames.append(frame)
15+
16+
# Average of frames
17+
bgFrame = np.median(frames, axis=0).astype(dtype=np.uint8)
18+
cv2.imwrite("Sevilla_background.jpg",bgFrame)
19+
20+
# Uses Readimg.py
21+
cv2.imshow('frame',bgFrame)
22+
cv2.waitKey(0)

OpenCV/Background_Detector/Car.mp4

1.46 MB
Binary file not shown.
45.6 KB
Loading
1.9 MB
Binary file not shown.
68.5 KB
Loading

0 commit comments

Comments
 (0)