Пример #1
0
    def from_api_repr(cls, landmark):
        """Factory: construct an instance of a Landmark from a response.

        :type landmark: dict
        :param landmark: Landmark representation from Vision API.

        :rtype: :class:`~google.cloud.vision.face.Landmark`
        :returns: Populated instance of ``Landmark``.
        """
        position = Position.from_api_repr(landmark['position'])
        landmark_type = LandmarkTypes[landmark['type']]
        return cls(position, landmark_type)
Пример #2
0
    def from_api_repr(cls, response_landmark):
        """Factory: construct an instance of a Landmark from a response.

        :type response_landmark: dict
        :param response_landmark: Landmark representation from Vision API.

        :rtype: :class:`~google.cloud.vision.face.Landmark`
        :returns: Populated instance of `Landmark`.
        """
        position = Position.from_api_repr(response_landmark['position'])
        landmark_type = getattr(FaceLandmarkTypes, response_landmark['type'])
        return cls(position, landmark_type)
Пример #3
0
    def from_pb(cls, landmark):
        """Factory: construct an instance of a Landmark from a response.

        :type landmark: :class:`~google.cloud.vision_v1.proto.\
                        image_annotator_pb.FaceAnnotation.Landmark`
        :param landmark: Landmark representation from Vision API.

        :rtype: :class:`~google.cloud.vision.face.Landmark`
        :returns: Populated instance of ``Landmark``.
        """
        position = Position.from_pb(landmark.position)
        landmark_type = LandmarkTypes(landmark.type)
        return cls(position, landmark_type)