o
    ,h!                     @   s6   d dl Z d dlZdd Zdd Zedkre  dS dS )    Nc                  C   s  t jdd} | jddddtdd | jd	tdd
gddd | jdtd dd | jdtd dd | jdtddd | jdtdd
gddd | jdtdd
gddd | jdtdd
gddd | jdtdd
gddd | jdtdd
gddd | jdd dtd!d" | jd#tg d$d%d&d | jd'td(d)d | jd*td+d,d | jd-td.d/d | jd0td d1d | jd2td d3d | jd4td.d+gd+d5d | jd6td d7d | jd8tdd
gd
d9d | jd:td;d<d | jd=td>d?d | jd@tdAdBd | jdCtdDdEd | jdFtdGdHd | jdItdGdJd | jdKtdLdMd | jdNtdOdPd | jdQtd>dRd | jdStdAdTd | jdUtdAdVd | jdWtdAdXd | jdYtdAdZd | jd[tdOd\d | jd]td>d^d | jd_tg d`ddad |  }|S )bNzProcess EasyOCR.)descriptionz-lz--lang+Tzfor languages)nargsrequiredtypehelpz--gpuFzUsing GPU (default: True))r   choicesdefaultr   z--model_storage_directoryzDirectory for model (.pth) file)r   r	   r   z--user_network_directoryz"Directory for custom network filesz--recog_networkstandardzRecognition networksz--download_enabledzEnable Downloadz
--detectorzInitialize text detector modulez--recognizerz!Initialize text recognizer modulez	--verbosezPrint detail/warningz
--quantizezUse dynamic quantizationz-fz--filez
input file)r   r   r   z	--decoder)greedy
beamsearchwordbeamsearchr   zdecoder algorithmz--beamWidth   zsize of beam searchz--batch_size   
batch_sizez	--workersr   znumber of processing cpu coresz--allowlistz4Force EasyOCR to recognize only subset of charactersz--blocklistzOBlock subset of character. This argument will be ignored if allowlist is given.z--detailzsimple output (default: 1)z--rotation_infozAllow EasyOCR to rotate each text box and return the one with the best confident score. Eligible values are 90, 180 and 270. For example, try [90, 180 ,270] for all possible text orientations.z--paragraphzCombine result into paragraphz
--min_size   z3Filter text box smaller than minimum value in pixelz--contrast_thsg?zText box with contrast lower than this value will be passed into model 2 times. First is with original image and second with contrast adjusted to 'adjust_contrast' value. The one with more confident level will be returned as a result.z--adjust_contrastg      ?z/target contrast level for low contrast text boxz--text_thresholdgffffff?zText confidence thresholdz
--low_textg?zText low-bound scorez--link_thresholdzLink confidence thresholdz--canvas_sizei 
  zFMaximum image size. Image bigger than this value will be resized down.z--mag_ratiog      ?zImage magnification ratioz--slope_thszfMaximum slope (delta y/delta x) to considered merging. Low value means tiled boxes will not be merged.z--ycenter_thszNMaximum shift in y direction. Boxes with different level should not be merged.z--height_thsz[Maximum different in box height. Boxes with very different text size should not be merged. z--width_thsz+Maximum horizontal distance to merge boxes.z--y_thszAMaximum vertical distance to merge boxes (when paragraph = True).z--x_thszCMaximum horizontal distance to merge boxes (when paragraph = True).z--add_marginzxExtend bounding boxes in all direction by certain value. This is important for language with complex script (E.g. Thai).z--output_format)r
   dictjsonzoutput format.)	argparseArgumentParseradd_argumentstrboolintlistfloat
parse_args)parserargs r   F/var/www/html/scripts/venv/lib/python3.10/site-packages/easyocr/cli.pyr      s  r   c                  C   s"  t  } tj| j| j| j| j| j| j| j	| j
| j| jd
}|j| jfi d| jd| jd| jd| jd| jd| jd| jd	| jd
| jd| jd| jd| jd| jd| jd| jd| jd| jd| j d| j!d| j"d| j#d| j$d| j%d| j&d| j'D ]}t(| qd S )N)
	lang_listgpumodel_storage_directoryuser_network_directoryrecog_networkdownload_enableddetector
recognizerverbosequantizedecoder	beamWidthr   workers	allowlist	blocklistdetailrotation_info	paragraphmin_sizecontrast_thsadjust_contrasttext_thresholdlow_textlink_thresholdcanvas_size	mag_ratio	slope_thsycenter_ths
height_ths	width_thsy_thsx_ths
add_marginoutput_format))r   easyocrReaderlangr"   r#   r$   r%   r&   r'   r(   r)   r*   readtextfiler+   r,   r   r-   r.   r/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   print)r   readerliner   r   r    main   s   
	

rK   __main__)r   rC   r   rK   __name__r   r   r   r    <module>   s     m)
