def from_pb(cls, response):
        """Factory: construct ``CropHint`` from Vision gRPC response.

        :type response: :class:`google.cloud.vision_v1.proto.\
                        image_annotator_pb2.CropHint`
        :param response: gRPC response from Vision API with entity data.

        :rtype: :class:`~google.cloud.vision.crop_hint.CropHint`
        :returns: Instance of ``CropHint``.
        """
        bounds = Bounds.from_pb(response.bounding_poly)
        return cls(bounds, response.confidence, response.importance_fraction)
    def from_pb(cls, response):
        """Factory: construct entity from Vision gRPC response.

        :type response: :class:`~google.cloud.vision_v1.proto.\
                        image_annotator_pb2.AnnotateImageResponse`
        :param response: gRPC response from Vision API with entity data.

        :rtype: :class:`~google.cloud.vision.entity.EntityAnnotation`
        :returns: Instance of ``EntityAnnotation``.
        """
        bounds = Bounds.from_pb(response.bounding_poly)
        description = response.description
        locale = response.locale
        locations = [LocationInformation.from_pb(location)
                     for location in response.locations]
        mid = response.mid
        score = response.score
        return cls(bounds, description, locale, locations, mid, score)
Exemple #3
0
    def from_pb(cls, response):
        """Factory: construct entity from Vision gRPC response.

        :type response: :class:`~google.cloud.grpc.vision.v1.\
                        image_annotator_pb2.AnnotateImageResponse`
        :param response: gRPC response from Vision API with entity data.

        :rtype: :class:`~google.cloud.vision.entity.EntityAnnotation`
        :returns: Instance of ``EntityAnnotation``.
        """
        bounds = Bounds.from_pb(response.bounding_poly)
        description = response.description
        locale = response.locale
        locations = [LocationInformation.from_pb(location)
                     for location in response.locations]
        mid = response.mid
        score = response.score
        return cls(bounds, description, locale, locations, mid, score)