├── README.md ├── data ├── test1.png ├── test2.png └── test3.png ├── main.py └── requirements.txt /README.md: -------------------------------------------------------------------------------- 1 | # text-detection-python-easyocr 2 | 3 | In this video I show you how to make an optical character recognition algorithm using Python, OpenCV and EasyOCR in 15 minutes! 4 | 5 | [![Watch the video](https://img.youtube.com/vi/n-8oCPjpEvM/0.jpg)](https://www.youtube.com/watch?v=n-8oCPjpEvM) 6 | -------------------------------------------------------------------------------- /data/test1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computervisioneng/text-detection-python-easyocr/f199a19f6285f77738d2b3fd12d4b956a2c7a949/data/test1.png -------------------------------------------------------------------------------- /data/test2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computervisioneng/text-detection-python-easyocr/f199a19f6285f77738d2b3fd12d4b956a2c7a949/data/test2.png -------------------------------------------------------------------------------- /data/test3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/computervisioneng/text-detection-python-easyocr/f199a19f6285f77738d2b3fd12d4b956a2c7a949/data/test3.png -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | import easyocr 3 | import matplotlib.pyplot as plt 4 | import numpy as np 5 | 6 | # read image 7 | image_path = '/home/phillip/Desktop/todays_tutorial/30_text_detection_easyocr/code/data/test2.png' 8 | 9 | img = cv2.imread(image_path) 10 | 11 | # instance text detector 12 | reader = easyocr.Reader(['en'], gpu=False) 13 | 14 | # detect text on image 15 | text_ = reader.readtext(img) 16 | 17 | threshold = 0.25 18 | # draw bbox and text 19 | for t_, t in enumerate(text_): 20 | print(t) 21 | 22 | bbox, text, score = t 23 | 24 | if score > threshold: 25 | cv2.rectangle(img, bbox[0], bbox[2], (0, 255, 0), 5) 26 | cv2.putText(img, text, bbox[0], cv2.FONT_HERSHEY_COMPLEX, 0.65, (255, 0, 0), 2) 27 | 28 | plt.imshow(cv2.cvtColor(img, cv2.COLOR_BGR2RGB)) 29 | plt.show() 30 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | easyocr==1.6.2 2 | matplotlib==3.7.1 3 | opencv-python-headless==4.5.4.60 4 | numpy==1.24.2 5 | --------------------------------------------------------------------------------