From 1673e591f746b530980e37ddb6831bd15b7141f9 Mon Sep 17 00:00:00 2001 From: se1exin Date: Fri, 13 May 2022 20:09:37 +1000 Subject: [PATCH] Add check for image --- README.md | 7 +++++++ tracker.py | 18 +++++++++++------- 2 files changed, 18 insertions(+), 7 deletions(-) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..cd1ec62 --- /dev/null +++ b/README.md @@ -0,0 +1,7 @@ + + +Install on Raspberry Pi + +https://github.com/superuser789/MediaPipe-on-RaspberryPi/issues/10#issuecomment-1079703581 + +sudo apt install python3-opencv \ No newline at end of file diff --git a/tracker.py b/tracker.py index 3d2fdc3..a2911a1 100644 --- a/tracker.py +++ b/tracker.py @@ -43,14 +43,18 @@ class Tracker(object): self.img = img def detect_face(self): - img, face_bboxs = self.face_detector.findFaces(self.img, draw=self.show_img) - if face_bboxs: - if self.show_img: - center = face_bboxs[0]["center"] - cv2.circle(self.img, center, 5, (255, 0, 255), cv2.FILLED) + if self.img: + img, face_bboxs = self.face_detector.findFaces(self.img, draw=self.show_img) + if face_bboxs: + if self.show_img: + self.img = img + center = face_bboxs[0]["center"] + cv2.circle(self.img, center, 5, (255, 0, 255), cv2.FILLED) - score = face_bboxs[0]["score"][0] - return score >= self.min_face_score + score = face_bboxs[0]["score"][0] + return score >= self.min_face_score + else: + print('Image not usable') return False def loop(self):