def from_api_repr(cls, response):
        """Factory: construct ``CropHint`` from Vision API response.

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

        :rtype: :class:`~google.cloud.vision.crop_hint.CropHint`
        :returns: Instance of ``CropHint``.
        """
        bounds = Bounds.from_api_repr(response.get('boundingPoly'))
        confidence = response.get('confidence', 0.0)
        importance_fraction = response.get('importanceFraction', 0.0)
        return cls(bounds, confidence, importance_fraction)
    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)
示例#3
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)