FaceRecognitionWebStreaming.py 文件源码

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

项目:CodeLabs 作者: TheIoTLearningInitiative 项目源码 文件源码
def get_frame(self):

        ret, self.image = self.cap.read()

        cv2.imwrite(self.temporal, self.image)

        faceCascade = cv2.CascadeClassifier("classifier/haarcascade_frontalface_alt.xml")
        image = cv2.imread(self.temporal)
        gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
        faces = faceCascade.detectMultiScale(
            gray,
            scaleFactor=1.1,
            minNeighbors=5,
            minSize=(30, 30),
            flags = cv2.cv.CV_HAAR_SCALE_IMAGE
        )
        print "Found {0} faces!".format(len(faces))

        for (x, y, w, h) in faces:
            cv2.rectangle(image, (x, y), (x+w, y+h), (0, 255, 0), 2)

    cv2.imwrite(self.faces,np.hstack((self.image,image)))
    return open(self.faces, 'rb').read()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号