Bladeren bron

Can now grid things up

tags/kitchen
Pete Shadbolt 3 jaren geleden
bovenliggende
commit
46b34494bc
1 gewijzigde bestanden met toevoegingen van 21 en 0 verwijderingen
  1. +21
    -0
      radio.py

+ 21
- 0
radio.py Bestand weergeven

@@ -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)


Laden…
Annuleren
Opslaan