app.py 文件源码

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

项目:async_face_recognition 作者: dpdornseifer 项目源码 文件源码
def _cascade_detect(self, raw_image):
        ''' use opencv cascades to recognize objects on the incomming images '''
        cascade = cv2.CascadeClassifier(self._cascade)
        image = np.asarray(bytearray(raw_image), dtype="uint8")

        gray_image = cv2.imdecode(image, cv2.IMREAD_GRAYSCALE)
        color_image = cv2.imdecode(image, cv2.IMREAD_ANYCOLOR)

        coordinates = cascade.detectMultiScale(
            gray_image,
            scaleFactor=1.15,
            minNeighbors=5,
            minSize=(30, 30)
        )

        for (x, y, w, h) in coordinates:
            cv2.rectangle(color_image, (x, y), (x + w, y + h), (0, 255, 0), 2)
            self._logger.debug("face recognized at: x: {}, y: {}, w: {}, h: {}".format(x, y, w, h))

        return color_image, self._tojson(coordinates)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号