U
    Ic                     @   s*   d dl Z dZdd Zdd Zd
dd	ZdS )    N)i  i  i c            	      G   s   t | d  | d  g}t | d  | d  g}t| d  | d   }t| d  | d   }||d  }||d  }|}|}||||fS )zC" Calculates the relative bounding box from absolute pixel values. r            )minitemabs)	xyxy	bbox_leftbbox_topbbox_wbbox_hx_cy_cwh r   3/var/www/html/VideoAnalyticsDashboard/src/graphs.pybbox_rel   s    r   c                    s    fddt D }t|S )zF
    Simple function that adds fixed color depending on the class
    c                    s(   g | ] }t | d    d  d qS )r   r      int).0plabelr   r   
<listcomp>   s     z,compute_color_for_labels.<locals>.<listcomp>)palettetuple)r   colorr   r   r   compute_color_for_labels   s    r   r   r   c                 C   s  t |D ]
\}}dd |D \}}}}	||d 7 }||d 7 }||d 7 }|	|d 7 }	|d k	rlt|| nd}
t|
}dd|
}t|tjddd }t| ||f||	f|d t| ||f||d  d ||d  d	 f|d
 t| ||||d  d	 ftjddddgd q| S )Nc                 S   s   g | ]}t |qS r   r   )r   ir   r   r   r      s     zdraw_boxes.<locals>.<listcomp>r   r   z{}{:d} r   r      r   )		enumerater   r   formatcv2getTextSizeFONT_HERSHEY_PLAIN	rectangleputText)imgbbox
identitiesoffsetr!   boxx1y1x2y2idr   r   t_sizer   r   r   
draw_boxes   s:           r7   )Nr    )r'   r   r   r   r7   r   r   r   r   <module>   s   