update ocr.py and yolo.ipynb

This commit is contained in:
Maciej Czajka 2023-01-27 22:49:28 +01:00
parent 90b44a6581
commit dadca174b8
2 changed files with 25 additions and 1198 deletions

25
ocr.py
View File

@ -1,30 +1,5 @@
import easyocr
import cv2 as cv
import keras_ocr
import pytesseract
def keras_ocr_func():
pipeline = keras_ocr.pipeline.Pipeline()
images = [
keras_ocr.tools.read(img) for img in ['img0.png', ]
]
prediction_groups = pipeline.recognize(images)
car_numbers = ''
try:
for i in prediction_groups[0]:
car_numbers += i[0]
except:
print('no detection')
return car_numbers
def tesseract_ocr():
img = cv.imread('img0.png')
res = pytesseract.image_to_string(img,
lang='eng',
config='--oem 3 --psm 6 -c tessedit_char_whitelist=ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
return res
def get_text_from_image(img_path, cut=7):
text = ''

1198
yolo.ipynb

File diff suppressed because it is too large Load Diff