0

I want to detect the letters in the image of the following detective's answer.source here.

I answered it with kanren logic code:

from kanren import run, eq, conde, var, Relation, facts
from kanren import run, var, fact, Relation

x = var()

murderer = Relation()
# Murder suspects
facts(murderer ,("Mr Ronald", "Jack Green"),
           ("Mr Ronald", "John jacobson"),
           ("Mr Ronald", "June Green"))

sol = run(3,x,murderer("Mr Ronald",x))


findings = Relation()

facts(findings,("First of","January"),
        ("Fourth of","October"),
        ("Fifth of","March"),
        ("Third of","June"))

January = run(1,x,findings ("First of",x))
October = run(1,x,findings("Fourth of",x))
March = run(1,x,findings ("Fifth of",x))
June = run(1,x, findings("Third of",x))

print(January[0][0])
print(October[0][3])
print(March[0][4])
print(June[0][2])

So, Kanren's logic answered that the culprit was: John

So when I want to detect letters that match opencv it fails and keeps on failing. I study here and here.

I want the output to be like this image, and it matches the answer from kanren's logic which is: John

Thank you, any help will be highly appreciated.

original image here

2
  • all the "kanren" stuff is irrelevant to "detecting letters", which is called Optical Character Recognition (OCR). are you asking to be recommended an OCR library? please take the tour and review How to Ask and minimal reproducible example. Commented Oct 25, 2022 at 7:59
  • sorry, I didn't know that ocr was included in the tag Commented Oct 25, 2022 at 8:17

1 Answer 1

1

EasyOCR can be a good choice of reading this kind of texts. Its accurate and give you the position of each letter in the text image.

When I tried the code below with your image:

import easyocr
reader = easyocr.Reader(['ch_sim','en'])
result = reader.readtext('/ur/img/dir/img.jpg')
print(result)

I get the output:

  • [([[190, 99], [525, 99], [525, 156], [190, 156]], 'Firstof Jahuary', 0.8845715173000117),

  • ([[173, 152], [544, 152], [544, 204], [173, 204]], 'Fburthof October', 0.8176276380919366),

  • ([[212, 208], [504, 208], [504, 258], [212, 258]], 'Fifthof March', 0.7889743493622021),

  • ([[224, 264], [494, 264], [494, 314], [224, 314]], 'Thirdof Juhe', 0.8849983221023138)]

I can say it is a %95 accurate result.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.