§
    �Øj÷  ã                   óT   — d Z ddlZddlmZ dad„ Zdej        fd„Zdej        fd„Z	dS )aŒ  
rapidocr_onnxruntime_backend.py
Backend for RapidOCR-ONNXRuntime
Unified interface for:
  - full_ocr(img)  -> List[(rect, text, score)]
  - det_only(img)  -> List[(rect, score)]
The engine is initialized exactly once.
Note: RapidOCR-ONNXRuntime can disable recognition.
      We therefore can use different ways to perform
      recognition on the detected text regions, for instance Tesseract.
é    N)ÚRapidOCRc                  ó:   — t           €t          ¦   «         a t           S )z;
    Initializes the ONNX Runtime Engine exactly once.
    )ÚENGINEr   © ó    úš/Users/tedpeters/Documents/Projects/Claude Projects/Misc Tools/notename-sheets/.venv/lib/python3.11/site-packages/pymupdf4llm/ocr/rapidocr_onnx_backend.pyÚinit_enginer	      s   € õ
 €~Ý‘”ˆÝ€Mr   Úimgc                 óR   — t          ¦   «         } || ¦  «        \  }}d„ |D ¦   «         S )z-
    Returns list of (rect, text, score)
    c                 ó:   — g | ]\  }}}||t          |¦  «        f‘ŒS r   )Úfloat)Ú.0ÚboxÚtextÚscores       r   ú
<listcomp>zfull_ocr.<locals>.<listcomp>)   s,   € ÐFÐFÐFÑ*:¨#¨t°UˆS�$�˜e™œÐ%ÐFÐFÐFr   ©r	   )r
   ÚengineÚresultsÚtimess       r   Úfull_ocrr   !   s5   € õ ‰]Œ]€FØ�V˜C‘[”[�N€GˆUð GÐF¸gÐFÑFÔFÐFr   c                 óf   — t          ¦   «         } || ddd¬¦  «        \  }}|€g S d„ |D ¦   «         }|S )z'
    Returns list of (rect, score)
    TF)Úuse_detÚuse_clsÚuse_recNc                 ó   — g | ]}|d f‘ŒS )g      ð?r   )r   r   s     r   r   zdet_only.<locals>.<listcomp>@   s   € Ð.Ð.Ð.˜c��SˆzÐ.Ð.Ð.r   r   )r
   r   Údt_boxesÚ	_det_timer   s        r   Údet_onlyr   /   s]   € õ ‰]Œ]€Fð !˜&ØØØØð	ñ ô Ñ€Hˆið ÐØˆ	ð /Ð. XÐ.Ñ.Ô.€Gà€Nr   )
Ú__doc__ÚnumpyÚnpÚrapidocr_onnxruntimer   r   r	   Úndarrayr   r   r   r   r   ú<module>r%      sŽ   ðð
ð 
ð Ð Ð Ð Ø )Ð )Ð )Ð )Ð )Ð )ð 
€ðð ð ðG�"”*ð Gð Gð Gð Gð�"”*ð ð ð ð ð ð r   