-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFrameDivide.py
56 lines (52 loc) · 1.4 KB
/
FrameDivide.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import numpy as np
import cv2
import time
def frame():
vidcap = cv2.VideoCapture('Cars.mp4')
success,image = vidcap.read()
count = 0
success = True
k=0
while True:
if k%5==0:
while success:
success,image = vidcap.read()
print('Read a new frame: ', success)
cv2.imwrite("frame%d.jpg" % count, image) # save frame as JPEG file
count += 1
if count==70:
success=False
break
if k==100:
break
k+=1
return True
def frame1():
cap = cv2.VideoCapture(0)
count=0
k=0
success = True
while(True):
if k%5==0:
while success:
# Capture frame-by-frame
ret, frame = cap.read()
# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
cv2.imshow('frame',frame)
print('Read a new frame: ', True)
cv2.imwrite("frame%d.jpg" % count, frame) # save frame as JPEG file
count += 1
if count==20:
success=False
break
if k==100:
break
k+=1
# Display the resulting frame
if cv2.waitKey(1) & 0xFF == ord('q'):
break
return True
# When everything done, release the capture
cap.release()
cv2.destroyAllWindows()