U
    Per                     @   sH   d Z dZddlmZ ddlmZ ddlmZm	Z	m
Z
 G dd deZdS )a  
Camera
======

The :class:`Camera` widget is used to capture and display video from a camera.
Once the widget is created, the texture inside the widget will be automatically
updated. Our :class:`~kivy.core.camera.CameraBase` implementation is used under
the hood::

    cam = Camera()

By default, the first camera found on your system is used. To use a different
camera, set the index property::

    cam = Camera(index=1)

You can also select the camera resolution::

    cam = Camera(resolution=(320, 240))

.. warning::

    The camera texture is not updated as soon as you have created the object.
    The camera initialization is asynchronous, so there may be a delay before
    the requested texture is created.
)Camera    )Image)NumericPropertyListPropertyBooleanPropertyc                       sT   e Zd ZdZedZedZeddgZ	 fddZ
dd Zdd	 Zd
d Z  ZS )r   zACamera class. See module documentation for more information.
    Fc                    sR   d | _ tt| jf | | jdkr(d| _| j}| j}|d| |d| |  d S )Nr   r   index
resolution)_camerasuperr   __init__r   	_on_indexfbind)selfkwargsZon_indexr   	__class__ 3/tmp/pip-unpacked-wheel-xzebddm3/kivy/uix/camera.pyr   R   s    


zCamera.__init__c                 C   s&   |j  | _ }t|j| _| j  d S N)texturelistsizeZtexture_sizeZcanvasZ
ask_update)r   Zcamerar   r   r   r   on_tex]   s    zCamera.on_texc                 G   sz   d | _ | jdk rd S | jd dk s0| jd dk rBt| jdd| _ nt| j| jdd| _ | jrf| j   | j j| jd d S )Nr      T)r   stopped)r   r	   r   )Z
on_texture)r
   r   r	   
CoreCameraplaystartbindr   )r   largsr   r   r   r   b   s    
 
zCamera._on_indexc                 C   s(   | j s
d S |r| j   n
| j   d S r   )r
   r   stop)r   instancevaluer   r   r   on_playp   s
    zCamera.on_play)__name__
__module____qualname____doc__r   r   r   r   r   r	   r   r   r   r$   __classcell__r   r   r   r   r   $   s   r   N)r(   __all__Zkivy.uix.imager   Zkivy.core.camerar   r   Zkivy.propertiesr   r   r   r   r   r   r   <module>   s
   