feat: fixed bug in camera code
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import configparser
|
import configparser
|
||||||
import os.path
|
import os.path
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
from pprint import pprint
|
||||||
from typing import NamedTuple, Optional, Tuple
|
from typing import NamedTuple, Optional, Tuple
|
||||||
|
|
||||||
import cv2
|
import cv2
|
||||||
@@ -46,7 +47,7 @@ class Camera:
|
|||||||
|
|
||||||
self.rotate = get_rotate_value(self.config['rotate'])
|
self.rotate = get_rotate_value(self.config['rotate'])
|
||||||
|
|
||||||
self.detect_face = False
|
self.detect_face = True
|
||||||
self.draw_face = self.config.getboolean('draw_face', fallback=False)
|
self.draw_face = self.config.getboolean('draw_face', fallback=False)
|
||||||
|
|
||||||
def get_image(self) -> Tuple[Optional[bytes], Optional[FacePos]]:
|
def get_image(self) -> Tuple[Optional[bytes], Optional[FacePos]]:
|
||||||
@@ -60,6 +61,7 @@ class Camera:
|
|||||||
if self.detect_face:
|
if self.detect_face:
|
||||||
image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
image_gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
|
||||||
faces = face_cascade.detectMultiScale(image_gray, 1.3, 5)
|
faces = face_cascade.detectMultiScale(image_gray, 1.3, 5)
|
||||||
|
if faces is not None and len(faces) > 0:
|
||||||
face = FacePos(*faces[0])
|
face = FacePos(*faces[0])
|
||||||
if self.draw_face:
|
if self.draw_face:
|
||||||
for (x, y, w, h) in faces:
|
for (x, y, w, h) in faces:
|
||||||
|
|||||||
Reference in New Issue
Block a user