Skip to content

Instantly share code, notes, and snippets.

@blueBye
Created April 9, 2023 18:45
Show Gist options
  • Save blueBye/cb7842adcbb351c24dcb84926fe63153 to your computer and use it in GitHub Desktop.
Save blueBye/cb7842adcbb351c24dcb84926fe63153 to your computer and use it in GitHub Desktop.
import cv2
import numpy as np
cap = cv2.VideoCapture('./blinker.mp4')
result = []
while(cap.isOpened()):
ret, frame = cap.read()
if ret == True:
if (np.average(frame) > 50):
result.append('1')
else:
result.append('0')
else:
break
cap.release()
cv2.destroyAllWindows()
with open('result.txt', 'w') as f:
f.write(''.join(result))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment