Tutorial

This tutorial walks through the basic functions of EasyOCR. First, import it:

import easyocr

Next, tell EasyOCR which language(s) to read. EasyOCR can read multiple languages at once, as long as they're compatible. English works with all languages; languages sharing the same script (e.g., Latin) are compatible with each other.

To read Traditional Chinese and English, pass the language codes as a list:

reader = easyocr.Reader(['ch_tra', 'en'])

EasyOCR will download necessary model files automatically, then load them into memory. Once loaded, you can read as many images as you want without running this line again.

Optional Arguments

  • gpu (default True) — use GPU if available. Set False for CPU-only, or specify a device like 'cuda:0'.
  • model_storage_directory — where to store model files. Default: ~/.EasyOCR/model.

Reading an Image

result = reader.readtext('chinese_tra.jpg')

Standard output is a list. Each item contains text box coordinates, text, and confidence:

[([[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),
 ...]

You can also pass a numpy array (from OpenCV), bytes, or a URL:

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')

Simple Output

For simple text-only output, pass detail=0:

reader.readtext('chinese_tra.jpg', detail=0)
# ['高鐵左營站', 'HSR', 'Station', '汽車臨停接送區', 'Kiss', 'Car', 'and', 'Ride']

Paragraph Mode

Use paragraph=True to combine text into paragraphs:

reader.readtext('chinese_tra.jpg', detail=0, paragraph=True)
# ['高鐵左營站 HSR Station 汽車臨停接送區 Car Kiss and Ride']

For the complete list of optional arguments, see the API documentation.