main.py 703 B

12345678910111213141516171819202122232425262728
  1. import cv2
  2. import numpy as np
  3. video = cv2.VideoCapture(r'pictures/pictures.mp4')
  4. counter = 0
  5. if video.isOpened():
  6. while True:
  7. ret, frame = video.read()
  8. if not ret:
  9. print("Video doesn't open")
  10. break
  11. x, y = np.where(np.all(frame==np.array([0,0,0]), axis=2))
  12. if len(x) + len(y) > 100000 and len(x) + len(y) < 110000:
  13. counter+=1
  14. print('mine')
  15. # cv2.namedWindow('videoFrame', cv2.WINDOW_NORMAL)
  16. # cv2.imshow('videoFrame', frame)
  17. # key = cv2.waitKey(0)
  18. # while key != ord('q'):
  19. # cv2.destroyAllWindows()
  20. video.release()
  21. cv2.destroyAllWindows()
  22. # 86
  23. print(counter)