__init__.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:garden.facelock 作者: kivy-garden 项目源码 文件源码
def face_recognize(self):
        cap = cv2.VideoCapture(self.index)

        face_cascade = cv2.CascadeClassifier(self.cascade)
        '''
        face_cascade: cascade is entered here for further use.
        '''

        while(True):
            ret, frame = cap.read()
            gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
            '''
            Converts coloured video to black and white(Grayscale).
            '''
            if np.any(face_cascade.detectMultiScale(gray, 1.3, 5)):

                print("Cascade found")

                self.dispatch('on_match')

                cv2.destroyAllWindows()
                for i in range(1, 5):
                    cv2.waitKey(1)
                break

            else:
                print("Not recognized")

            cv2.imshow('frame', frame)
            #Comment the above statement not to show the camera screen
            if cv2.waitKey(1) & 0xFF == ord('q'):
                print("Forcefully Closed")

                cv2.destroyAllWindows()
                for i in range(1, 5):
                    cv2.waitKey(1)
                break
        cap.release()
评论列表


问题


面经


文章

微信
公众号

扫码关注公众号