อ่านตัวเลขบนภาพด้วย Tesseract + OpenCV โดยใช้ Python (Implementing Optical Character Recognition (OCR) using pytesseract)
วิธีนี้เป็นวิธีที่ง่าย ซึ่งเราไม่จำเป็นต้องใช้ Tensorflow เลย
ขั้นตอนแรกทำการติดตั้ง pytesseract โดยใช้บรรทัดนี้
pip install pytesseract
ขั้นที่ 2 ทำการลงโปรแกรม tesseract-ocr โดยใช้ link ข้างล่าง
https://github.com/UB-Mannheim/tesseract/wiki
ขั้นที่ 3 ทำการเขียนโค้ด python
import cv2
import numpy as np
import matplotlib.pyplot as plt
import imutils
import pytesseract
pytesseract.pytesseract.tesseract_cmd = r”C:\Program Files\Tesseract-OCR\tesseract.exe”
img1 = cv2.imread(‘Capture1.png’)
img = cv2.cvtColor(img1, cv2.COLOR_BGR2GRAY)
# Adding custom options
custom_config = r’ — oem 3 — psm 6'
aa = pytesseract.image_to_string(img1, config=custom_config)
print(aa)
cv2.imshow(‘img1’, img1)
cv2.waitKey(0)
cv2.destroyAllWindows()
ผลลัพธ์
หมายเหตุท้าย:
หากคุณชอบบทความนี้อย่าลืมคลิก❤ด้านล่างเพื่อแนะนำและถ้าคุณมีคำถามใด ๆ แสดงความคิดเห็นและฉันจะพยายามอย่างดีที่สุดที่จะตอบ คุณสามารถติดตามฉันบน
facebook page (https://www.facebook.com/nextsoftwarehousethailand/)
website : www.nextsoftwarethailand.com
และสามารถส่งอีเมลถึงฉัน