Przeglądaj źródła

Can now grid things up

tags/kitchen
Pete Shadbolt 3 lat temu
rodzic
commit
46b34494bc
1 zmienionych plików z 21 dodań i 0 usunięć
  1. +21
    -0
      radio.py

+ 21
- 0
radio.py Wyświetl plik

@@ -1,9 +1,30 @@
import cv2
import math
import itertools as it

DENSITY = 5
RED = [0, 0, 255]


def draw_rectangles(frame):
height, width, d = frame.shape
n = DENSITY
m = math.ceil(n * (height / width))
dx = width / n
dy = height / m
for x, y in it.product(range(n), range(n)):
sp = (int(x * dx), int(y * dy))
ep = (int(x * dx + dx), int(y * dy + dy))
frame = cv2.rectangle(frame, sp, ep, (255, 0, 0))
return frame


camera = cv2.VideoCapture(0)

while True:
ret, frame = camera.read()
frame = draw_rectangles(frame)
frame = cv2.rectangle(frame, (0, 0), (100, 100), (255, 0, 0), 2)
cv2.imshow('Input', frame)

c = cv2.waitKey(1)


Ładowanie…
Anuluj
Zapisz