Why does Tesseract not recognize the text on the licence plate while easyocr does?
I'm kind of curious why did you use bilateralFilter
, Canny
, findContours
etc.? Did you see the result of each method?
Anyway, if you set the page-segmentation-mode
to 6 which is:
Assume a single uniform block of text.
The result will be:
34 DUA34
Code:
import cv2
import pytesseract
# Load the image
img = cv2.imread("vHQ5q.jpg")
# Convert to the gray-scale
gry = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
# OCR
print(pytesseract.image_to_string(gry, config="--psm 6"))
# Display
cv2.imshow("", gry)
cv2.waitKey(0)
You should know the Page segmentation method.
I've got the result using pytesseract-version-0.3.7.
character recognition from license plate with opencv python
Use easyocr
. It uses Deep Learning models:
# install using python -m pip install easyocr
import easyocr
# create reader
reader = easyocr.Reader(['en'])
# read characters
img = "https://i.stack.imgur.com/2Kzu8.png"
characters = reader.readtext(img, detail=0)
print(characters)
# ['ZG', '8524AF']
See documentation for more details, parameters and languages
Update & Results from Colab
To avoid capturing of none plate numbers character use allowlist parameter
#Narrowing characters
import string
ALLOWED_LIST = string.ascii_uppercase+string.digits
characters = reader.readtext(img, detail=0, allowlist=ALLOWED_LIST )
print(characters)
# ['ZG', '8524AF']
My results from Google Colab
How to tune tesseract for identifying number plate of a car more accurately?
You are using tesseract as a general model for your problem you can tune your model for that you need to generate synthetic data for your number plates with this
https://github.com/Belval/TextRecognitionDataGenerator
and then you can tune your model using the steps provided
https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00---Finetune
https://github.com/tesseract-ocr/tesseract/wiki/TrainingTesseract-4.00
I've tuned the tesseract on synthetic data and it works like a charm, tried CNN models and tesseract both and tesseract trains better with lesser data and gives better performance.
Related Topics
Change Button Image When Play Completes Swift
Differencebetween Embedded Binaries and Linked Frameworks
How to Get Distance of Object from iPhone Camera Using Image Exif Meta Data
Flutter: How to Create a New Project
Improper Advertising Identifier [Idfa] Usage
Uiscrollview Adjusts Contentoffset When Contentsize Changes
Using Global Variables in Objective-C
Objective C - Pass by Value and Pass by Reference
How to Extract a Url from a Sentence That Is in a Nsstring
iOS 7.1 Uitableviewcell Content Overlaps with Ones Below
How to Parse This JSON in Swift
Uicollectionview Horizontal Paging - How to Use Flow Layout
Launch a Local Notification at a Specific Time in iOS
Color in Storyboard Not Matching Uicolor
How to Convert .Dae to .Scn Files in Scenekit
What Does Warning "Mapping Architecture Arm64 to X86_64" Mean