This commit is contained in:
yumoqing 2020-09-30 14:09:53 +08:00
parent 02e8a2b4eb
commit c8ea613b04

View File

@ -5,6 +5,9 @@ from kivy.graphics.texture import Texture
from kivy.factory import Factory from kivy.factory import Factory
import cv2 import cv2
facefilepath=os.path.dirname(cv2.__file__)
facepattern = '%s/%s' % (facefilepath, \
'data/haarcascade/haarcascade_frontalface_default.xml')
def set_res(cap, x,y): def set_res(cap, x,y):
cap.set(cv2.CAP_PROP_FRAME_WIDTH, int(x)) cap.set(cv2.CAP_PROP_FRAME_WIDTH, int(x))
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, int(y)) cap.set(cv2.CAP_PROP_FRAME_HEIGHT, int(y))
@ -21,7 +24,7 @@ class KivyCamera(Image):
self.camera_id = camera_id self.camera_id = camera_id
self.faceCascade = None self.faceCascade = None
if face_detect: if face_detect:
self.faceCascade = cv2.CascadeClassifier('data/haarcascade/haarcascade_frontalface_default.xml') self.faceCascade = cv2.CascadeClassifier(facepattern)
if not self.faceCascade: if not self.faceCascade:
print('self.faceCascade is None') print('self.faceCascade is None')