o
    Y+i                     @   s.   d dl Zd dlmZ d dlmZ dddZdS )    N)	ImageClip  Fc                 C   s  |  d}| js|  } | j d}tj|dddddf \}}g }t|D ]$}||d |d f  dkr;q*||d |d f j|krIq*|	| q*t
t|dd d}	g }
t|	D ]U\}\}\}}	 t|jd |jd }t|jd |jd }|||f }|||f }||d k|||f  }t|||f }t|dd	|_t|j|jf|_|
	| q_|rddlm} td
|  |d\}}|d d |d | |d jt|gdd |d g  |  |
S )z 
    Returns a list of ImageClips representing each a separate object on
    the screen.
        
    rem_thr : all objects found with size < rem_Thr will be
         considered false positives and will be removed
    
    r   N   g?c                 S   s   | d d j S )Nr   )start)s r   Q/var/www/html/venv/lib/python3.10/site-packages/moviepy/video/tools/segmenting.py<lambda>"   s    zfindObjects.<locals>.<lambda>)keyT)ismaskzfound %d objects   offnearest)interpolation)	get_framemaskadd_maskndimeasurementslabelfind_objectsmeansizeappendsorted	enumerateslicer   stopr   nparray	screenposmatplotlib.pyplotpyplotprintsubplotsaxisimshowrange
set_yticksshow)cliprem_thrpreviewimager   labellednum_featuressliceseisliceslettersiindsysxletter	labletter
maskletterpltfigaxr   r   r   findObjects   sF   

"r>   )r   F)numpyr   scipy.ndimagendimager   moviepy.video.VideoClipr   r>   r   r   r   r   <module>   s    