-
Notifications
You must be signed in to change notification settings - Fork 17
/
Video.py
35 lines (30 loc) · 791 Bytes
/
Video.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
32
33
34
35
import cv2 as cv
import numpy as np
cap = cv.VideoCapture(0)
i=0
while True:
ret, frame = cap.read()
blank = np.zeros(frame.shape[:2], dtype='uint8')
b,g,r = cv.split(frame)
i = i+ (1/3)
if 0<i<=1:
blue = cv.merge([b, blank, blank])
cv.imshow('frame', blue)
elif 1<i<=2:
mid1 = cv.merge([b,g,blank])
cv.imshow('frame', mid1)
elif 2<i<=3:
green = cv.merge([blank, g , blank])
cv.imshow('frame', green)
elif 3<i<=4:
mid2 = cv.merge([blank, g, r])
cv.imshow('frame', mid2)
else:
red = cv.merge([blank, blank, r])
cv.imshow('frame', red)
if i>5:
i=0
if cv.waitKey(1) & 0xFF==ord('q'):
break
cap.release()
cv.destroyAllWindows()