def show_image(title, img, detector=None, size=None): """ :param title: to use for title of image :param img: ndarray of image :param detector: detector to run image through """ if detector is None: display_img = img else: display_img = img.copy() detected = detector.detect(img) detectors.draw_detected(display_img, detected) if size is not None: display_img = cv2.resize(display_img, size) cv2.imshow(title, display_img)
def loop(): video_capture = cv2.VideoCapture(0) detector = detectors.Detector() while True: ret, img = video_capture.read() display_img = img.copy() detected = detector.detect(img) detectors.draw_detected(display_img, detected) cv2.imshow("Video", display_img) if cv2.waitKey(1) & 0xFF == ord('q'): break video_capture.release() cv2.destroyAllWindows()