o
    0j                     @   s8   d dl mZ d dlZddlmZmZ G dd deZdS )    )DictN   )BaseCVResult	JsonMixinc                   @   sT   e Zd ZdZdeeejf fddZdeeef fddZ	deeef fddZ
d	S )
SealRecognitionResultzSeal Recognition Resultreturnc           	      C   s   i }| d }t |dkr|jd |d< | d }|d r&|jdi | d j tt | d D ]}| d | }|d }|j}d	| }|d
 ||< q.|S )Nlayout_det_resr   resmodel_settingsuse_doc_preprocessordoc_preprocessor_resseal_res_listseal_region_idZseal_res_regionZocr_res_img )lenZimgupdaterange)	selfZres_img_dictr   r
   snoseal_resr   Zsub_seal_res_dictkeyr   r   t/var/www/html/Deteccion_Ine/venv/lib/python3.10/site-packages/paddlex/inference/pipelines/seal_recognition/result.py_to_img   s   
zSealRecognitionResult._to_imgc                 O   s   i }| d |d< | d |d< | d d r| d j d |d< t| d dkr.| d j d |d< g |d< tt| d D ]}| d | }|d |j d  q:tj|g|R i |S )	ax  Converts the instance's attributes to a dictionary and then to a string.

        Args:
            *args: Additional positional arguments passed to the base class method.
            **kwargs: Additional keyword arguments passed to the base class method.

        Returns:
            Dict[str, str]: A dictionary with the instance's attributes converted to strings.
        
input_pathr
   r   r   r	   r   r   r   )strr   r   appendr   _to_strr   argskwargsdatar   r   r   r   r   r   +   s   
zSealRecognitionResult._to_strc                 O   s   i }| d |d< | d |d< | d |d< | d d r#| d j d |d< t| d dkr4| d j d |d< g |d	< tt| d	 D ]}| d	 | }|d	 |j d  q@tj|g|R i |S )
a[  
        Converts the object's data to a JSON dictionary.

        Args:
            *args: Positional arguments passed to the JsonMixin._to_json method.
            **kwargs: Keyword arguments passed to the JsonMixin._to_json method.

        Returns:
            Dict[str, str]: A dictionary containing the object's data in JSON format.
        r   Z
page_indexr
   r   r   r	   r   r   r   )jsonr   r   r   r   _to_jsonr   r   r   r   r"   B   s   zSealRecognitionResult._to_jsonN)__name__
__module____qualname____doc__r   r   npZndarrayr   r   r"   r   r   r   r   r      s
    r   )typingr   numpyr'   Zcommon.resultr   r   r   r   r   r   r   <module>   s   