o
    OZŽhK  ã                   @   sf   d Z ddlZdd„ Zdd„ Zdd„ ZG d	d
„ d
ƒZedkr1ddlZeej_eej_ej	j 
¡  dS dS )zÈpygame.camera.Camera implementation using the videocapture module for windows.

http://videocapture.sourceforge.net/

Binary windows wheels:
  https://www.lfd.uci.edu/~gohlke/pythonlibs/#videocapture
é    Nc                   C   s   dgS )z[Always only lists one camera.

    Functionality not supported in videocapture module.
    r   © r   r   r   úH/var/www/auris/lib/python3.10/site-packages/pygame/_camera_vidcapture.pyÚlist_cameras   s   r   c                  C   s8   z	dd l } W | a d S  ty   ddlm }  Y | a d S w )Nr   ©Úvidcap)r   ÚImportErrorZVideoCapture)Úvcr   r   r   Úinit   s   
þþr	   c                   C   s   d a d S ©Nr   r   r   r   r   Úquit'   s   r   c                   @   sb   e Zd Zddd„Zdd„ Zdd	„ Zd
d„ Zdd„ Zdd„ Zdd„ Z	dd„ Z
ddd„Zddd„ZdS )ÚCamerar   ©i€  ià  ÚRGBc                 C   s(   t  ||¡| _|\}}| j ||¡ dS )að  device:  VideoCapture enumerates the available video capture devices
                 on your system.  If you have more than one device, specify
                 the desired one here.  The device number starts from 0.

        show_video_window: 0 ... do not display a video window (the default)
                           1 ... display a video window

                         Mainly used for debugging, since the video window
                         can not be closed or moved around.
        N)r   Znew_DevÚdevÚsetresolution)ÚselfZdeviceÚsizeÚmodeZshow_video_windowÚwidthÚheightr   r   r   Ú__init__.   s   zCamera.__init__c                 C   ó   | j  ¡  dS )z²Displays a dialog containing the property page of the capture filter.

        For VfW drivers you may find the option to select the resolution most
        likely here.
        N)r   Zdisplaycapturefilterproperties©r   r   r   r   Ú!display_capture_filter_properties=   ó   z(Camera.display_capture_filter_propertiesc                 C   r   )z¯Displays a dialog containing the property page of the capture pin.

        For WDM drivers you may find the option to select the resolution most
        likely here.
        N)r   Zdisplaycapturepinpropertiesr   r   r   r   Údisplay_capture_pin_propertiesE   r   z%Camera.display_capture_pin_propertiesc                 C   s   | j  ||¡ dS )z-Sets the capture resolution. (without dialog)N)r   r   )r   r   r   r   r   r   Úset_resolutionM   s   zCamera.set_resolutionc                 C   s
   | j  ¡ S )z/Returns a string containing the raw pixel data.)r   Ú	getbufferr   r   r   r   Ú
get_bufferQ   ó   
zCamera.get_bufferc                 C   ó   dS ©zNot implemented.Nr   r   r   r   r   ÚstartU   ó    zCamera.startc                 K   r    r!   r   )r   Úkwargsr   r   r   Úset_controlsX   r#   zCamera.set_controlsc                 C   r    r!   r   r   r   r   r   Ústop[   r#   zCamera.stopNc                 C   s
   |   |¡S )ú )Úget_surface)r   Ú	dest_surfr   r   r   Ú	get_image^   r   zCamera.get_imagec                 C   sV   |   ¡ \}}}|sdS tj |||fd¡}tj |dd¡}|r'| |d¡ |S |}|S )zReturns a pygame Surface.NZBGRr   é   )r   r   )r   ÚpygameÚimageZ
frombufferZ	transformÚflipZblit)r   r)   Zabufferr   r   Zsurfr   r   r   r(   b   s   ÿzCamera.get_surface)r   r   r   r   r
   )Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r   r"   r%   r&   r*   r(   r   r   r   r   r   ,   s    

r   Ú__main__)Ú__doc__r,   r   r	   r   r   r/   Zpygame.examples.cameraÚcameraZexamplesÚmainr   r   r   r   Ú<module>   s    	Eû