face_recognizer.py 文件源码

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

项目:image_recognition 作者: tue-robotics 项目源码 文件源码
def update_with_categorical_distribution(self, recognition):
        """
        Update the recognition with a categorical distribution of the trained faces
        :param recognition: Input recognition
        :return: Output recognition with an updated categorical distribution
        """
        if self._trained_faces:
            # Try to get a representation of the detected face
            recognition_representation = None
            try:
                recognition_representation = self._get_representation(recognition.image)
            except Exception as e:
                print "Could not get representation of face image but detector found one: %s" % str(e)

            rospy.logdebug('recognition_representation: %s', recognition_representation)
            # If we have a representation, update with use of the l2 distance w.r.t. the face dict
            if recognition_representation is not None:
                recognition.l2_distances = [L2Distance(_get_min_l2_distance(
                    face.representations, recognition_representation), face.label) for face in self._trained_faces]

            # Sort l2 distances probabilities, lowest on index 0
            recognition.l2_distances = sorted(recognition.l2_distances, key=lambda x: x.distance)

        return recognition
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号