Add check for image
This commit is contained in:
parent
debef7771a
commit
1673e591f7
7
README.md
Normal file
7
README.md
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
|
||||||
|
|
||||||
|
Install on Raspberry Pi
|
||||||
|
|
||||||
|
https://github.com/superuser789/MediaPipe-on-RaspberryPi/issues/10#issuecomment-1079703581
|
||||||
|
|
||||||
|
sudo apt install python3-opencv
|
18
tracker.py
18
tracker.py
|
@ -43,14 +43,18 @@ class Tracker(object):
|
||||||
self.img = img
|
self.img = img
|
||||||
|
|
||||||
def detect_face(self):
|
def detect_face(self):
|
||||||
img, face_bboxs = self.face_detector.findFaces(self.img, draw=self.show_img)
|
if self.img:
|
||||||
if face_bboxs:
|
img, face_bboxs = self.face_detector.findFaces(self.img, draw=self.show_img)
|
||||||
if self.show_img:
|
if face_bboxs:
|
||||||
center = face_bboxs[0]["center"]
|
if self.show_img:
|
||||||
cv2.circle(self.img, center, 5, (255, 0, 255), cv2.FILLED)
|
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]
|
score = face_bboxs[0]["score"][0]
|
||||||
return score >= self.min_face_score
|
return score >= self.min_face_score
|
||||||
|
else:
|
||||||
|
print('Image not usable')
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def loop(self):
|
def loop(self):
|
||||||
|
|
Loading…
Reference in New Issue
Block a user