API Documentation

Reader class

Base class for EasyOCR.

Parameters

  • lang_list (list) — list of language codes to recognize, e.g., ['ch_sim','en']. See the supported language codes.
  • gpu (bool or string, default True) — enable GPU.
  • model_storage_directory (string, default None) — 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) — enable automatic model download.
  • user_network_directory (string, default None) — path to user-defined recognition network. Default: MODULE_PATH + '/user_network'.
  • recog_network (string, default 'standard') — name of recognition network.
  • detector (bool, default True) — load detection model into memory.
  • recognizer (bool, default True) — load recognition model into memory.

Attributes

  • lang_char — all available characters in the current model.

readtext method

Main method for a Reader object. Parameters are grouped into General, Contrast, Text Detection, and Bounding Box Merging.

General

  • image (string, numpy array, or bytes) — input image.
  • decoder (string, default 'greedy') — options: 'greedy', 'beamsearch', 'wordbeamsearch'.
  • beamWidth (int, default 5) — how many beams to keep when using beam search.
  • batch_size (int, default 1) — larger batch is faster but uses more memory.
  • workers (int, default 0) — number of dataloader threads.
  • allowlist (string) — force EasyOCR to recognize only a subset of characters.
  • blocklist (string) — block a subset of characters. Ignored if allowlist is given.
  • detail (int, default 1) — set to 0 for simple output.
  • paragraph (bool, default False) — combine result into paragraphs.
  • min_size (int, default 10) — filter text boxes smaller than this (pixels).
  • rotation_info (list, default None) — rotate each text box and keep the best result. E.g., [90, 180, 270].

Contrast

  • contrast_ths (float, default 0.1) — low-contrast boxes are processed twice.
  • adjust_contrast (float, default 0.5) — target contrast for low-contrast boxes.

Text Detection (from CRAFT)

  • text_threshold (float, default 0.7) — text confidence threshold.
  • low_text (float, default 0.4) — text low-bound score.
  • link_threshold (float, default 0.4) — link confidence threshold.
  • canvas_size (int, default 2560) — maximum image size.
  • mag_ratio (float, default 1) — image magnification ratio.

Bounding Box Merging

Controls when adjacent bounding boxes merge. Except for slope_ths, units are in box height.

  • slope_ths (float, default 0.1) — max slope for merging.
  • ycenter_ths (float, default 0.5) — max shift in y direction.
  • height_ths (float, default 0.5) — max difference in box height.
  • width_ths (float, default 0.5) — max horizontal distance to merge boxes.
  • add_margin (float, default 0.1) — extend bounding boxes in all directions. Important for complex scripts like Thai.
  • x_ths (float, default 1.0) — max horizontal distance to merge text boxes when paragraph=True.
  • y_ths (float, default 0.5) — max vertical distance to merge text boxes when paragraph=True.

Returns: list of results.

detect method

Detect text boxes only.

Parameters

  • image (string, numpy array, or bytes) — input image.
  • min_size, text_threshold, low_text, link_threshold, canvas_size, mag_ratio, slope_ths, ycenter_ths, height_ths, width_ths, add_margin — same as readtext.
  • optimal_num_chars (int, default None) — 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]].

recognize method

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) — input image.
  • horizontal_list (list, default None) — see output of detect.
  • free_list (list, default None) — see output of detect.
  • decoder, beamWidth, batch_size, workers, allowlist, blocklist, detail, paragraph, contrast_ths, adjust_contrast — same as readtext.

Returns: list of results.