### Install EasyOCR from source Source: https://www.jaided.ai/easyocr/install Installs the latest development version directly from the GitHub repository. ```bash pip install git+https://github.com/JaidedAI/EasyOCR.git ``` -------------------------------- ### Install EasyOCR via pip Source: https://www.jaided.ai/easyocr/install Installs the latest stable EasyOCR release from PyPI. Recommended for most users. ```bash pip install easyocr ``` -------------------------------- ### Get simple text output with detail=0 Source: https://www.jaided.ai/easyocr/tutorial The detail=0 parameter turns off the default detailed output, returning only a list of recognized text strings. ```python reader.readtext('chinese_tra.jpg', detail=0) # ['高鐵左營站', 'HSR', 'Station', '汽車臨停接送區', 'Kiss', 'Car', 'and', 'Ride'] ``` -------------------------------- ### Import easyocr Source: https://www.jaided.ai/easyocr/tutorial Imports the EasyOCR library. ```python import easyocr ``` -------------------------------- ### Sample reader.readtext output Source: https://www.jaided.ai/easyocr/tutorial Shows the standard output format of reader.readtext: a list of tuples with text box coordinates, text, and confidence. ```python [([[448, 111], [917, 111], [917, 243], [448, 243]], '高鐵左營站', 0.9247), ([[454, 214], [629, 214], [629, 290], [454, 290]], 'HSR', 0.9931), ([[664, 222], [925, 222], [925, 302], [664, 302]], 'Station', 0.3260), ...] ``` -------------------------------- ### Use EasyOCR to read text from an image Source: https://www.jaided.ai/easyocr Import EasyOCR, create a Reader for Chinese simplified and English, and read text from an image file. ```python import easyocr reader = easyocr.Reader(['ch_sim','en']) result = reader.readtext('image.jpg') ``` -------------------------------- ### recognize method Source: https://www.jaided.ai/easyocr/documentation Recognize characters from text boxes. If no boxes are given, the whole image is treated as one text box. ```APIDOC ## recognize method ### Description Recognize characters from text boxes. If no boxes are given, the whole image is treated as one text box. ### Parameters - **image** (string, numpy array, or bytes) - Required - Input image. - **horizontal_list** (list, default `None`) - Optional - See output of `detect`. - **free_list** (list, default `None`) - Optional - See output of `detect`. - **decoder** - Optional - Same as `readtext`. - **beamWidth** - Optional - Same as `readtext`. - **batch_size** - Optional - Same as `readtext`. - **workers** - Optional - Same as `readtext`. - **allowlist** - Optional - Same as `readtext`. - **blocklist** - Optional - Same as `readtext`. - **detail** - Optional - Same as `readtext`. - **paragraph** - Optional - Same as `readtext`. - **contrast_ths** - Optional - Same as `readtext`. - **adjust_contrast** - Optional - Same as `readtext`. ### Returns List of results. ``` -------------------------------- ### Create EasyOCR Reader for Chinese Traditional and English Source: https://www.jaided.ai/easyocr/tutorial Initializes the EasyOCR Reader to recognize Traditional Chinese and English by passing a list of language codes. ```python reader = easyocr.Reader(['ch_tra', 'en']) ``` -------------------------------- ### Read from numpy array, bytes, and URL Source: https://www.jaided.ai/easyocr/tutorial Demonstrates how to pass a numpy array (from OpenCV), a bytes object, or a URL to readtext. ```python img = cv2.imread('chinese_tra.jpg') result = reader.readtext(img) with open("chinese_tra.jpg", "rb") as f: img = f.read() result = reader.readtext(img) result = reader.readtext('https://example.com/chinese_tra.jpg') ``` -------------------------------- ### detect method Source: https://www.jaided.ai/easyocr/documentation Detect text boxes only. Returns horizontal and free-form bounding boxes. ```APIDOC ## detect method ### Description Detect text boxes only. Returns horizontal and free-form bounding boxes. ### Parameters - **image** (string, numpy array, or bytes) - Required - Input image. - **min_size** - Optional - Same as `readtext`. - **text_threshold** - Optional - Same as `readtext`. - **low_text** - Optional - Same as `readtext`. - **link_threshold** - Optional - Same as `readtext`. - **canvas_size** - Optional - Same as `readtext`. - **mag_ratio** - Optional - Same as `readtext`. - **slope_ths** - Optional - Same as `readtext`. - **ycenter_ths** - Optional - Same as `readtext`. - **height_ths** - Optional - Same as `readtext`. - **width_ths** - Optional - Same as `readtext`. - **add_margin** - Optional - Same as `readtext`. - **optimal_num_chars** (int, default `None`) - Optional - If specified, boxes with estimated number of characters near this value are returned first. ### Returns `horizontal_list, free_list`. `horizontal_list` is a list of rectangular boxes `[x_min, x_max, y_min, y_max]`. `free_list` is a list of free-form boxes `[[x1,y1],[x2,y2],[x3,y3],[x4,y4]]`. ``` -------------------------------- ### Reader class Source: https://www.jaided.ai/easyocr/documentation Base class for EasyOCR. Initializes the OCR engine with language support, GPU usage, model storage, and network configuration. ```APIDOC ## Reader class ### Description Base class for EasyOCR. Initializes the OCR engine with language support, GPU usage, model storage, and network configuration. ### Parameters - **lang_list** (list) - Required - List of language codes to recognize, e.g., `['ch_sim','en']`. - **gpu** (bool or string, default `True`) - Optional - Enable GPU. - **model_storage_directory** (string, default `None`) - Optional - Path to directory for model data. If not specified, models are read from `EASYOCR_MODULE_PATH` (preferred), `MODULE_PATH`, or `~/.EasyOCR/`. - **download_enabled** (bool, default `True`) - Optional - Enable automatic model download. - **user_network_directory** (string, default `None`) - Optional - Path to user-defined recognition network. Default: `MODULE_PATH + '/user_network'`. - **recog_network** (string, default `'standard'`) - Optional - Name of recognition network. - **detector** (bool, default `True`) - Optional - Load detection model into memory. - **recognizer** (bool, default `True`) - Optional - Load recognition model into memory. ### Attributes - **lang_char** - All available characters in the current model. ``` -------------------------------- ### Paragraph mode with paragraph=True Source: https://www.jaided.ai/easyocr/tutorial The paragraph=True option combines recognized text into paragraphs, grouping them into lines. ```python reader.readtext('chinese_tra.jpg', detail=0, paragraph=True) # ['高鐵左營站 HSR Station 汽車臨停接送區 Car Kiss and Ride'] ``` -------------------------------- ### readtext method Source: https://www.jaided.ai/easyocr/documentation Main method for a Reader object. Performs text detection and recognition on an image, returning a list of results. ```APIDOC ## readtext method ### Description Main method for a Reader object. Performs text detection and recognition on an image, returning a list of results. ### Parameters #### General - **image** (string, numpy array, or bytes) - Required - Input image. - **decoder** (string, default `'greedy'`) - Optional - Options: `'greedy'`, `'beamsearch'`, `'wordbeamsearch'`. - **beamWidth** (int, default `5`) - Optional - How many beams to keep when using beam search. - **batch_size** (int, default `1`) - Optional - Larger batch is faster but uses more memory. - **workers** (int, default `0`) - Optional - Number of dataloader threads. - **allowlist** (string) - Optional - Force EasyOCR to recognize only a subset of characters. - **blocklist** (string) - Optional - Block a subset of characters. Ignored if `allowlist` is given. - **detail** (int, default `1`) - Optional - Set to `0` for simple output. - **paragraph** (bool, default `False`) - Optional - Combine result into paragraphs. - **min_size** (int, default `10`) - Optional - Filter text boxes smaller than this (pixels). - **rotation_info** (list, default `None`) - Optional - Rotate each text box and keep the best result. E.g., `[90, 180, 270]`. #### Contrast - **contrast_ths** (float, default `0.1`) - Optional - Low-contrast boxes are processed twice. - **adjust_contrast** (float, default `0.5`) - Optional - Target contrast for low-contrast boxes. #### Text Detection (from CRAFT) - **text_threshold** (float, default `0.7`) - Optional - Text confidence threshold. - **low_text** (float, default `0.4`) - Optional - Text low-bound score. - **link_threshold** (float, default `0.4`) - Optional - Link confidence threshold. - **canvas_size** (int, default `2560`) - Optional - Maximum image size. - **mag_ratio** (float, default `1`) - Optional - Image magnification ratio. #### Bounding Box Merging - **slope_ths** (float, default `0.1`) - Optional - Max slope for merging. - **ycenter_ths** (float, default `0.5`) - Optional - Max shift in y direction. - **height_ths** (float, default `0.5`) - Optional - Max difference in box height. - **width_ths** (float, default `0.5`) - Optional - Max horizontal distance to merge boxes. - **add_margin** (float, default `0.1`) - Optional - Extend bounding boxes in all directions. Important for complex scripts like Thai. - **x_ths** (float, default `1.0`) - Optional - Max horizontal distance to merge text boxes when `paragraph=True`. - **y_ths** (float, default `0.5`) - Optional - Max vertical distance to merge text boxes when `paragraph=True`. ### Returns List of results. ``` -------------------------------- ### Read text from image file using reader.readtext Source: https://www.jaided.ai/easyocr/tutorial Reads text from an image file using the reader's readtext method. ```python result = reader.readtext('chinese_tra.jpg') ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.