diff --git a/radio.py b/radio.py index 8b65d01..b957b91 100644 --- a/radio.py +++ b/radio.py @@ -7,6 +7,7 @@ RED = [0, 0, 255] def draw_rectangles(frame): + """ Draw some rectangles on top of the image """ height, width, d = frame.shape n = DENSITY m = math.ceil(n * (height / width)) @@ -19,17 +20,17 @@ def draw_rectangles(frame): return frame -camera = cv2.VideoCapture(0) +if __name__ == '__main__': + 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) + while True: + ret, frame = camera.read() + frame = draw_rectangles(frame) + cv2.imshow('Input', frame) - c = cv2.waitKey(1) - if c == 27: - break + c = cv2.waitKey(1) + if c == 27: + break -camera.release() -cv2.destroyAllWindows() + camera.release() + cv2.destroyAllWindows()