goncalopp / simple-ocr-opencv

A simple python OCR engine using opencv
GNU Affero General Public License v3.0
524 stars 175 forks source link

Accuracy exception #34

Closed Jambon1510 closed 5 years ago

Jambon1510 commented 5 years ago

Context Hello I tried the below image passwordpad

with Python 3

current behavior When grounding via example_grounding.py the image above then launching example.py by the same above image, I got below exception

Traceback (most recent call last):
  File "example_amundi.py", line 17, in <module>
    print("accuracy:", accuracy(test_image.ground.classes, test_classes))
  File "/mnt/Documents/jb/Dev/python/projects/moneygator/test/castor/ocr/simple-ocr-opencv-master/simpleocr/ocr.py", line 36, in accuracy
    raise Exception("expected " + str(expected.shape) + ", got " + str(result.shape))
Exception: expected (10, 1), got (18, 1)

expected behavior it should not trigger the exception except if I am doing something bad (does that need more numbers for grounding?)

goncalopp commented 5 years ago

What that exception is telling you is that the number of recognized segments is different from the expected. In this case, it expected 10 segments from grounding (which makes sense for the image), but it detected 18 in the image. If you used the algorithm for the grounding (as opposed to manually calculating rectangles), then it's likely that it's due to different settings used when running both.

You can try to figure out what's happening by running with show_steps=True (see example.py)

Jambon1510 commented 5 years ago

Ok got it thanks, I managed to make it work when I put any char on the 8 non number (q for example, I did put a space before and I had the description issue).

accuracy: 1.0 OCRed text: 32158qqqqqqqq70946

However it still not working whenever the image is different and the number are in a different place. Let me open another ticket for that