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)
Пример #2
0
    def from_api_repr(cls, response):
        """Factory: construct entity from Vision API response.

        :type response: dict
        :param response: Dictionary response from Vision API with entity data.

        :rtype: :class:`~google.cloud.vision.entity.EntityAnnotation`
        :returns: Instance of ``EntityAnnotation``.
        """
        bounds = Bounds.from_api_repr(response.get('boundingPoly'))
        description = response['description']
        locale = response.get('locale', None)
        locations = [LocationInformation.from_api_repr(location)
                     for location in response.get('locations', [])]
        mid = response.get('mid', None)
        score = response.get('score', None)

        return cls(bounds, description, locale, locations, mid, score)
    def from_api_repr(cls, response):
        """Factory: construct entity from Vision API response.

        :type response: dict
        :param response: Dictionary response from Vision API with entity data.

        :rtype: :class:`~google.cloud.vision.entity.EntityAnnotation`
        :returns: Instance of ``EntityAnnotation``.
        """
        bounds = Bounds.from_api_repr(response.get('boundingPoly'))
        description = response['description']
        locale = response.get('locale', None)
        locations = [LocationInformation.from_api_repr(location)
                     for location in response.get('locations', ())]
        mid = response.get('mid', None)
        score = response.get('score', None)

        return cls(bounds, description, locale, locations, mid, score)
Пример #4
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)