# KNN OCR Confidence

My program scans an image and is able to identify a string of numbers. It crops and rotates the image to include only the area of interest. Unfortunately, given the circumstances I have no way of knowing whether the image is upside down or rightside up. However, I do know that it is one of the two, and is not sideways or angled.

The only way I can know if the image is upright is if the numbers indicate that it is. So I am trying to figure out a method of determining confidence for KNN OCR so that I can decide to rotate 180 degrees or not.

The test would go something like this:

randomly take 10 bounding rects

call k nearest on each

save confidence for whole as a single number "A"

rotate bounding rects 180 degrees

call k nearest on each

save confidence for whole as a single number "B"

if B is greater than A, rotate ROI by 180 degrees

Any advice on getting that confidence value?

edit retag close merge delete

Sort by ยป oldest newest most voted

Hi,

if the numbers are 0,1,..., 9, what do you think about considering the number of digits detected with the rectangles and their version rotated by 180 degrees as a confidence metric? If there are no just 0, 1, 6, 9 (that could be undetermined, depending on the font type), it should work, if I understood well your problem.

more