From ad078882096fa55464a776bbfa0b3604eac62c0b Mon Sep 17 00:00:00 2001 From: yumoqing Date: Mon, 5 Oct 2020 10:29:55 +0800 Subject: [PATCH] bugfix --- kivyblocks/kivycamera.py | 9 +++++---- kivyblocks/newvideo.py | 1 + 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/kivyblocks/kivycamera.py b/kivyblocks/kivycamera.py index 5499967..3089668 100644 --- a/kivyblocks/kivycamera.py +++ b/kivyblocks/kivycamera.py @@ -38,13 +38,13 @@ class KivyCamera(Image): size = set_res(self.capture,self.width,self.height) print(size) - def add_face_detech(self,frame): + def add_face_detect(self,frame): frameGray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY) faces = self.faceCascade.detectMultiScale(frameGray, scaleFactor = 1.2, minNeighbors = 5) + print('add_face_detect(): faces=',faces) # THIS LINE RAISE ERROR # faces = self.faceCascade.detectMultiScale(frameGray, 1.1, 4) - # cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\objdetect\src\cascadedetect.cpp:1689: error: (-215:Assertion failed) !empty() in function 'cv::CascadeClassifier::detectMultiScale' for (x, y, w, h) in faces: # added cv2.rectangle(frame, (x, y), (x + w, y + h), (255, 0, 0), 2) return frame @@ -63,8 +63,9 @@ class KivyCamera(Image): interpolation=cv2.INTER_LINEAR) if self.faceCascade: try: - frame = self.add_face_detech(frame) - except: + frame = self.add_face_detect(frame) + except Exception as e: + print('Error, e=',e) pass # convert it to texture buf1 = cv2.flip(frame, 0) diff --git a/kivyblocks/newvideo.py b/kivyblocks/newvideo.py index 0a88513..2ca5abc 100644 --- a/kivyblocks/newvideo.py +++ b/kivyblocks/newvideo.py @@ -21,6 +21,7 @@ class NewVideo(Video): self.ffplayer = self._video._ffplayer def on_state(self,*args): + print('new state = ',self.state) if self.state == 'play': Window.allow_screensaver = False else: