-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBinary_Image_Classification_Video_Viewer.py
More file actions
56 lines (54 loc) · 1.88 KB
/
Binary_Image_Classification_Video_Viewer.py
File metadata and controls
56 lines (54 loc) · 1.88 KB
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
from collections import deque
import numpy as np
import cv2
filename = 'Video_CV_Project\MOVI00'
num = '07'
filetype = '.avi'
cap = cv2.VideoCapture(filename+num+filetype)
Last100 = deque()
framecount = 0
Toggle = True
Tempframe = 0
while (cap.isOpened()):
testingthing = cv2.waitKey(1)
if (testingthing & 0xFF == ord(' ')):
Toggle = not Toggle
if (Toggle):
if (Tempframe == 0): # If we are in real time
framecount = framecount + 1
print(framecount)
ret, frame = cap.read() #reads 1 frame, presumably
if (frame is None):
print("Done!")
exit()
cv2.imshow('frame', frame)
Last100.append(frame)
elif (Tempframe > 0):
print("FUCK")
else: # If we are in the previous 100 frames
Tempframe = Tempframe + 1
print(framecount + Tempframe, ":", Tempframe)
if (Tempframe != 0):
cv2.imshow('frame', Last100[100+Tempframe])
if (not Toggle):
if (testingthing & 0xFF == ord('o')):
Tempframe = len(Last100) * -1
print(framecount + Tempframe)
cv2.imshow('frame', Last100[100+Tempframe])
if (testingthing & 0xFF == ord('l')):
if (Tempframe < -1):
Tempframe = Tempframe + 1
print(framecount + Tempframe, ":", Tempframe)
cv2.imshow('frame', Last100[100+Tempframe])
else:
framecount = framecount + 1
print(framecount)
ret, frame = cap.read() #reads 1 frame, presumably
cv2.imshow('frame', frame)
Last100.append(frame)
while (len(Last100) > 100):
Last100.popleft()
if (testingthing & 0xFF == ord('q')):
break
cap.release()
cv2.destroyAllWindows()