sync
This commit is contained in:
parent
91b2eb58f9
commit
f80c02e923
Binary file not shown.
After Width: | Height: | Size: 140 KiB |
18
ocr.py
18
ocr.py
|
@ -3,7 +3,8 @@ import pytesseract
|
|||
import numpy as np
|
||||
from pytesseract import Output
|
||||
|
||||
img_source = cv2.imread('images/coffee.jpg')
|
||||
# img_source = cv2.VideoCapture(0)
|
||||
img_source = cv2.imread('./coffee-ocr.jpg')
|
||||
|
||||
|
||||
def get_grayscale(image):
|
||||
|
@ -23,13 +24,16 @@ def canny(image):
|
|||
return cv2.Canny(image, 100, 200)
|
||||
|
||||
|
||||
gray = get_grayscale(img_source)
|
||||
thresh = thresholding(gray)
|
||||
opening = opening(gray)
|
||||
canny = canny(gray)
|
||||
def test_performance():
|
||||
gray = get_grayscale(img_source)
|
||||
thresh = thresholding(gray)
|
||||
opening = opening(gray)
|
||||
canny = canny(gray)
|
||||
|
||||
for img in [img_source, gray, thresh, opening, canny]:
|
||||
for img in [img_source, gray, thresh, opening, canny]:
|
||||
d = pytesseract.image_to_data(img, output_type=Output.DICT)
|
||||
print(d.keys())
|
||||
|
||||
n_boxes = len(d['text'])
|
||||
|
||||
# back to RGB
|
||||
|
@ -46,3 +50,5 @@ for img in [img_source, gray, thresh, opening, canny]:
|
|||
|
||||
cv2.imshow('img', img)
|
||||
cv2.waitKey(0)
|
||||
|
||||
print(pytesseract.image_to_data(img_source, output_type=Output.DICT)['text'])
|
Loading…
Reference in New Issue