o
    i6                     @   s4   d dl mZ d dlmZ d dlZG dd deZdS )    )absolute_import)protobuf_helpersNc                   @   s*   e Zd ZdZddddddZdd ZdS )	VisionHelpersa!  A set of convenience methods to make the Vision GAPIC easier to use.

    This class should be considered abstract; it is used as a superclass
    in a multiple-inheritance construction alongside the applicable GAPIC.
    See the :class:`~google.cloud.vision_v1.ImageAnnotatorClient`.
    N )retrytimeoutmetadatac          
      C   s  t |tjs^t|d}t |tjs^t|dr/| }t|di  t|d| t|d}tj|ddd}|r^t|d}t|d|  t|dd W d   n1 sYw   Y  t |tjsnt	|d	| 
  nt|jd
krz| 
 |_| j|g|||d}	|	jd
 S )a  Run image detection and annotation for an image.

        Example:
            >>> from google.cloud.vision_v1 import ImageAnnotatorClient
            >>> client = ImageAnnotatorClient()
            >>> request = {
            ...     'image': {
            ...         'source': {'image_uri': 'https://foo.com/image.jpg'},
            ...     },
            ... }
            >>> response = client.annotate_image(request)

        Args:
            request (:class:`~.vision_v1.AnnotateImageRequest`)
            retry (google.api_core.retry.Retry): Designation of what errors, if any,
                should be retried.
            timeout (float): The timeout for this request.
            metadata (Sequence[Tuple[str, str]]): Strings which should be
                sent along with the request as metadata.

        Returns:
            :class:`~.vision_v1.AnnotateImageResponse` The API response.
        imagereadzimage.contentzsource.filenameN)defaultrbzimage.sourcefeaturesr   )requestsr   r   r   )
isinstanceprotoMessageprotobufgethasattrr
   setopen
setdefault_get_all_featureslenr   batch_annotate_images	responses)
selfrequestr   r   r   r	   	img_bytesfilenameimg_filerr   r   _/var/www/edux/Edux_v2/venv/lib/python3.10/site-packages/google/cloud/vision_helpers/__init__.pyannotate_image   s,   



zVisionHelpers.annotate_imagec                 C   s   dd | j jD S )zmReturn a list of all features.

        Returns:
            list: A list of all available features.
        c                 S   s   g | ]
}|d krd|iqS )r   type_r   ).0featurer   r   r"   
<listcomp>W   s    z3VisionHelpers._get_all_features.<locals>.<listcomp>)FeatureType)r   r   r   r"   r   Q   s   zVisionHelpers._get_all_features)__name__
__module____qualname____doc__r#   r   r   r   r   r"   r      s    4r   )
__future__r   google.api_corer   r   r   objectr   r   r   r   r"   <module>   s   