# 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?