Browse Source

Can now grid things up

tags/kitchen
Pete Shadbolt 3 years ago
parent
commit
46b34494bc
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      radio.py

+ 21
- 0
radio.py View File

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


Loading…
Cancel
Save