Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import cv2
- import numpy as np
- import pygame
- pygame.init()
- wn = pygame.display.set_mode((600, 600))
- vid = cv2.VideoCapture(0)
- offset = 100
- class Boxes:
- def __init__(self):
- self.rects = np.array([[np.array([i + offset, j + offset, 1, 1]) for j in range(200)] for i in range(200)])
- def draw(self, array):
- for row, a in zip(self.rects, array):
- for col, b in zip(row, a):
- pygame.draw.rect(wn, b, col)
- boxes = Boxes()
- while True:
- ret, frame = vid.read()
- boxes.draw(frame[offset:offset+200,offset:offset+200])
- pygame.display.update()
- if cv2.waitKey(1) & 0xFF == ord('q'):
- break
- vid.release()
- cv2.destroyAllWindows()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement