import pickle
import cv2
def recording():
cap = cv2.VideoCapture(0)
imgs = []
counter = 0
num_recoding = 300
recoding = False
while(True):
result, frame = cap.read()
cv2.imshow('capture image', frame)
if cv2.waitKey(30) == 32:
recoding = True
if recoding:
imgs.append(frame)
print(counter)
counter += 1
if counter >= num_recoding:
break
with open('frames.dat', 'wb') as f:
pickle.dump(imgs, f)
def show():
with open('frames.dat', 'rb') as f:
imgs = pickle.load(f)
for img in imgs:
cv2.imshow('recorded image', img)
cv2.waitKey(1)
if __name__ == '__main__':
# recording()
show()