From c8ea613b0472ba5324f07f0947ef10fcfe5d5101 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Wed, 30 Sep 2020 14:09:53 +0800 Subject: [PATCH] bugfix --- kivyblocks/kivycamera.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/kivyblocks/kivycamera.py b/kivyblocks/kivycamera.py index 5d879c8..291059c 100644 --- a/kivyblocks/kivycamera.py +++ b/kivyblocks/kivycamera.py @@ -5,6 +5,9 @@ from kivy.graphics.texture import Texture from kivy.factory import Factory import cv2 +facefilepath=os.path.dirname(cv2.__file__) +facepattern = '%s/%s' % (facefilepath, \ + 'data/haarcascade/haarcascade_frontalface_default.xml') def set_res(cap, x,y): cap.set(cv2.CAP_PROP_FRAME_WIDTH, int(x)) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, int(y)) @@ -21,7 +24,7 @@ class KivyCamera(Image): self.camera_id = camera_id self.faceCascade = None if face_detect: - self.faceCascade = cv2.CascadeClassifier('data/haarcascade/haarcascade_frontalface_default.xml') + self.faceCascade = cv2.CascadeClassifier(facepattern) if not self.faceCascade: print('self.faceCascade is None')