Advertisement
Guest User

Untitled

a guest
Mar 8th, 2021
25
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. import cv2
  2. import numpy as np
  3. import pygame
  4.  
  5. pygame.init()
  6.  
  7. wn = pygame.display.set_mode((600, 600))
  8. vid = cv2.VideoCapture(0)
  9.  
  10. offset = 100
  11.  
  12. class Boxes:
  13. def __init__(self):
  14. self.rects = np.array([[np.array([i + offset, j + offset, 1, 1]) for j in range(200)] for i in range(200)])
  15.  
  16. def draw(self, array):
  17. for row, a in zip(self.rects, array):
  18. for col, b in zip(row, a):
  19. pygame.draw.rect(wn, b, col)
  20.  
  21. boxes = Boxes()
  22.  
  23. while True:
  24. ret, frame = vid.read()
  25. boxes.draw(frame[offset:offset+200,offset:offset+200])
  26. pygame.display.update()
  27. if cv2.waitKey(1) & 0xFF == ord('q'):
  28. break
  29.  
  30. vid.release()
  31. cv2.destroyAllWindows()
  32.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement