-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideoview.py
31 lines (22 loc) · 831 Bytes
/
videoview.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import cv2
import numpy as np
cap = cv2.VideoCapture(0)
while (cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
# Display the resulting frame
cv2.imshow('Frame', frame)
# conversion of BGR to grayscale is necessary to apply this operation
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
# adaptive thresholding to use different threshold
# values on different regions of the frame.
Thresh = cv2.adaptiveThreshold(gray, 255, cv2.ADAPTIVE_THRESH_MEAN_C,
cv2.THRESH_BINARY_INV, 11, 2)
cv2.imshow('Thresh', Thresh)
# define q as the exit button
if cv2.waitKey(25) & 0xFF == ord('q'):
break
# release the video capture object
cap.release()
# Closes all the windows currently opened.
cv2.destroyAllWindows()