Advertisement
Guest User

Untitled

a guest
Apr 5th, 2022
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. def open_videowin(file_location):
  2.     video = cv2.VideoCapture(file_location)
  3.     success, video_image = video.read()
  4.     fps = video.get(cv2.CAP_PROP_FPS)
  5.  
  6.     window = pygame.display.set_mode(video_image.shape[1::-1])
  7.     clock = pygame.time.Clock()
  8.  
  9.     run = success
  10.     while run:
  11.         clock.tick(fps)
  12.         for event in pygame.event.get():
  13.             if event.type == pygame.QUIT:
  14.                 run = False
  15.  
  16.         success, video_image = video.read()
  17.         if success:
  18.             video_surf = pygame.image.frombuffer(
  19.                 video_image.tobytes(), video_image.shape[1::-1], "BGR")
  20.         else:
  21.             run = False
  22.         window.blit(video_surf, (0, 0))
  23.         pygame.display.flip()
  24.  
  25.     pygame.quit()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement