diff --git a/kuukar/kuukar_cv.py b/kuukar/kuukar_cv.py index 3a82684..3705b55 100644 --- a/kuukar/kuukar_cv.py +++ b/kuukar/kuukar_cv.py @@ -1,17 +1,30 @@ from kuukar.kuukar_lcd import lcd from kuukar.kuukar_leds import leds +import threading +import multiprocessing +import cv2 + class cv: def __init__(self, lcd: lcd, leds: leds) -> None: self.lcd = lcd self.leds = leds + self.camera = cv2.VideoCapture(0) + threading.Thread(target=self._cv_loop).start() + + def _cv_loop(self): + while True: + img = self.capture_image() + stop_sign = self.detect_sign(img) + def capture_image(self): - pass - - def detect_face(self, image): - pass - - def handle_face_detected(self): - pass + ret, frame = self.camera.read() + return frame + def detect_sign(self, frame): + stopsign_cascade = cv2.CascadeClassifier('./stopsign_good.xml') + image = frame.array + gray_img=cv2.cvtColor(image,cv2.COLOR_BGR2GRAY) + found_stopsigns=stopsign_cascade.detectMultiScale(gray_img,1.1,5) + return found_stopsigns diff --git a/requirements.txt b/requirements.txt index 13733fb..e03d07c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,4 @@ telemetrix-rpi-pico pyaudio -flask \ No newline at end of file +flask +opencv-python \ No newline at end of file