o
    j                     @   s   d dl mZ d dlZd dlZd dlmZ d dlmZ d dlm	Z	 d dl
mZ d dl
mZ d dl
mZ d	d
 Zejdejejejejgejddddgfdddgfddg dfddg dfdddgfgdd Zejdejejejejgejdg ddd Zdd Zejddddddg dgd d! Zejd"dd#d#d$d$gd%d%ggd$d&gd%d'ggd&d&gd'd'gggfdd#d#d$d$gd&d&ggd$d%gd&d'ggd%d%gd'd'gggfdd(d(d$d$gd%d%gd)d)ggd$d&gd%d'gd)d*ggd$d+gd%d,gd)d-ggd&d&gd'd'gd*d*ggd&d+gd'd,gd*d-ggd+d+gd,d,gd-d-gggfdd(d(d$d$gd&d&gd+d+ggd$d%gd&d'gd+d,ggd$d)gd&d*gd+d-ggd%d%gd'd'gd,d,ggd%d)gd'd*gd,d-ggd)d)gd*d*gd-d-gggfdd#d#d$d$gd%d%gd'd'gd&d&gggfgd.d/ Zejd0d1d2gd3d4 ZdS )5    )shuffleN)assert_allclose)assert_array_equal)integral_image)haar_like_featurehaar_like_feature_coord)draw_haar_like_featurec               
   C   s   t jdt jd} t| }d}tt# t|dddd|d tdd|d t	| dddd|d W d    n1 s9w   Y  tddd\}}tt t|dddd|d d |d	 W d    d S 1 sfw   Y  d S )
N   r   dtypeZunknown_typer   r   feature_typetype-2-x   r   Zfeature_coord)
nponesfloat32r   pytestZraises
ValueErrorr   r   r	   )imgimg_iir   
feat_coord	feat_type r   `/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/skimage/feature/tests/test_haar.pytest_haar_like_feature_error   s   "r   r   z1feature_type,shape_feature,expected_feature_valuer   )T   g        type-2-ytype-3-x)*   )g      g      g       g      type-3-ytype-4)$   c                 C   sD   t jd|d}t|}t|dddd| d}tt t || d S )Nr
   r   r   r   r   )r   r   r   r   r   sortunique)r   Zshape_featureZexpected_feature_valuer   r   r   haar_featurer   r   r   test_haar_like_feature    s   r*   r   r   r    r!   r$   r%   c                 C   s`   t jd| d}t|}|j}d|jv rt |jdd}t|dddd|d}|j|ks.J d S )	Nr
   r   Zuintu r   r   r   )r   r   r   r   namereplacer   )r   r   r   r   Zexpected_dtyper)   r   r   r   !test_haar_like_feature_fused_type3   s   
r0   c                  C   sR   t jdt jd} t| }g d}t|dddd|d}t|dddd}t|| d S )Nr
   r   r+   r   r   r   )r   r   int8r   r   r   )r   r   r   Z	haar_listZhaar_allr   r   r   test_haar_like_feature_listC   s   r2   )r    r!   r%   c              	   C   s   t jdt jd}t|}t| tr+t|  tdd | D  \}}t |}t |}nt	dd| \}}t
|dddd||d}t
|dddd| }t|| d S )Nr
   r   c                 S   s   g | ]}t d d |qS )r   r   ).0Zfeat_tr   r   r   
<listcomp>_   s    z6test_haar_like_feature_precomputed.<locals>.<listcomp>r   r   r   )r   r   r1   r   
isinstancelistr   zipZconcatenater   r   r   )r   r   r   r   r   Zhaar_feature_precomputedr)   r   r   r   "test_haar_like_feature_precomputedL   s   

r8   z(feature_type,height,width,expected_coord   )r   r   )r      )r:   r   )r:   r:   r   )r   r9   )r:   r9   )r9   r   )r9   r:   )r9   r9   c                 C   sD   t ||| \}}tdd |D }t|| t|| ks J d S )Nc                 S   s   g | ]}|qS r   r   )r3   Zhfr   r   r   r4      s    z0test_haar_like_feature_coord.<locals>.<listcomp>)r   r   arrayr   all)r   heightwidthZexpected_coordr   r   r   r   r   test_haar_like_feature_coordl   s   :
r?   zmax_n_features,nnz_values)N.   )r:      c              
   C   st   t jdt jd}tddd\}}t|dddd|| dd}t|dddd|| dd |jdks/J t ||ks8J d S )Nr
   r   r   r%   r   )max_n_featuresrng)r   r   r   )r   Zzerosr   r   r	   shapeZcount_nonzero)rB   Z
nnz_valuesr   Zcoord_imager   r   r   test_draw_haar_like_feature   s   rG   )randomr   r   numpyr   Znumpy.testingr   r   Zskimage.transformr   Zskimage.featurer   r   r	   r   markZparametrizeZuint8r1   r   Zfloat64r*   r0   r2   r8   r?   rG   r   r   r   r   <module>   s    



	

9