Team Ai
Apppublic

kumarAnurag/ocr_image_file_processing

sourceHugging Faceupdated 2y agoView on Hugging Face
1likes
ocr_process.cpython-39.pyc9 linesDownload Raw Back to __pycache__
1a

2���fa�@s4ddlZddlZddlZdd�Zdd�Zdd�ZdS)�NcCst�||�dS)N)�cv2Zimwrite)�image�filename�r�YC:\Users\kumar\OneDrive\Desktop\Hugginface_space\ocr_image_file_processing\ocr_process.py�save_debug_imagesrcCsFt�|tj�}tjddd�}|�|�}t�|ddtjtj�\}}|S)Ng@)�r)Z	clipLimitZtileGridSizer��)rZcvtColorZCOLOR_BGR2GRAYZcreateCLAHE�apply�	thresholdZTHRESH_BINARY_INVZTHRESH_OTSU)�imgZgray_imgZclaheZenhanced_img�_Z3binary_imgrrr�!preprocess_image_for_segmentation4s56rcCs:tj|dddtjd�}t|�}t|d�tj|dd�}|S)N�)�fx�fy�
interpolationzfull_preprocessed_image.jpgzeng+hin)�lang)r�resizeZINTER_CUBICrr�pytesseract�image_to_string)rZpreprocessed_img�extracted_textrrr�extract_text_from_images78r)rr�numpy�nprrrrrrr�<module>s9