yclee126

frames to the beat

Aug 9th, 2021 (edited)
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. # https://youtu.be/XJnKIaGFvgc
  2.  
  3. import cv2
  4. import numpy as np
  5. from glob import glob
  6. from time import time
  7.  
  8. files = glob('imgs/*') # running dog frames from https://youtu.be/Pqk86Oz6IXQ
  9. offset = 167
  10. start = 9 - 1
  11. end = 19 - 1
  12.  
  13. imgs = []
  14. for file in files:
  15. img = cv2.imread(file)
  16. img = cv2.resize(img, None, fx=0.5, fy=0.5)
  17. imgs.append(img)
  18.  
  19. bpm = 175
  20. start_time = time()
  21. mul = 1
  22.  
  23. while True:
  24. cur_time = time() - start_time
  25. cur_pos = (cur_time % (60 / bpm)) / (60 / bpm)
  26. cur_img = int(cur_pos * (end - start + 1)) + start
  27. cv2.imshow('win', imgs[cur_img])
  28. key = cv2.waitKey(1)
  29. if key == ord('s'):
  30. start_time = time()
  31. elif key == ord('x'):
  32. exit()
Add Comment
Please, Sign In to add comment