How to get clean output from easyocr
Question:
This is from a opencv+easyocr number plate recognition script opencv crops the image to number plate and gives,clean great output to the easyocr. but what are these bunch of numbers its reading
result = reader.readtext(opencv(mypath))
Result: [([[0, 0], [163, 0], [163, 31], [0, 31]], ‘SPHJ > 3764’, 0.5565279612963627)]
I know I can get a clean output by this but the thing is it differs from a picture to picture.
is there any way only to get the number plate
result = result[0][-2]
Result: SPHJ > 3764
Answers:
The output will be in a list format, each item represents a bounding
box, the text detected and confident level, respectively.
It’s the coordinates of the box where the text is located. And the last item is the confidence level.
[[0, 0], [163, 0], [163, 31], [0, 31]]
-> the coordinates of the 4
corners
'SPHJ > 3764'
-> the text
0.5565279612963627
-> confidence level
Just use result[0][1]
to get the text. Note, result may have multiple text boxes detect, so you need to access by index or iterate over it.
for item in result:
print(item[1])
I think the question is to get "pure" texts without position and confidence, then simply add ‘detail=0’ to readtext()
result = reader.readtext(opencv(mypath), detail=0)
# output: result = ['SPHJ > 3764'] or multiple items if the image contains more texts
This is from a opencv+easyocr number plate recognition script opencv crops the image to number plate and gives,clean great output to the easyocr. but what are these bunch of numbers its reading
result = reader.readtext(opencv(mypath))
Result: [([[0, 0], [163, 0], [163, 31], [0, 31]], ‘SPHJ > 3764’, 0.5565279612963627)]
I know I can get a clean output by this but the thing is it differs from a picture to picture.
is there any way only to get the number plate
result = result[0][-2]
Result: SPHJ > 3764
The output will be in a list format, each item represents a bounding
box, the text detected and confident level, respectively.
It’s the coordinates of the box where the text is located. And the last item is the confidence level.
[[0, 0], [163, 0], [163, 31], [0, 31]]
-> the coordinates of the 4
corners'SPHJ > 3764'
-> the text0.5565279612963627
-> confidence level
Just use result[0][1]
to get the text. Note, result may have multiple text boxes detect, so you need to access by index or iterate over it.
for item in result:
print(item[1])
I think the question is to get "pure" texts without position and confidence, then simply add ‘detail=0’ to readtext()
result = reader.readtext(opencv(mypath), detail=0)
# output: result = ['SPHJ > 3764'] or multiple items if the image contains more texts