jacklicn / tesseract-ocr

Automatically exported from code.google.com/p/tesseract-ocr
Other
0 stars 0 forks source link

cannot recognize a single char #581

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. just run tesseract and input the file(test.png)
2.
3.

What is the expected output? What do you see instead?
n
with test.png -> ''
with test2.png -> 'E'

What version of the product are you using? On what operating system?
3.0.1, win7 x64

Please provide any additional information below.

Original issue reported on code.google.com by elb...@zeroexistence.org on 21 Nov 2011 at 5:54

Attachments:

GoogleCodeExporter commented 9 years ago
did you try to use pagesegmode?

Original comment by zde...@gmail.com on 21 Nov 2011 at 8:55

GoogleCodeExporter commented 9 years ago
I tried to use 1, 2 and 10
(test2)
when I used 1, it said, too few character, then produce 'E'
when I used 2, it produce nothing
when I used 10, it produce H
{test}
when I used 1, it produce nothing
when I used 2, it produce nothing
when I used 10, it produce H

I only need to scan 1 character at 1 time, no need to ocr a word, only a 
character,
any suggestion?
Thanks

Original comment by elb...@zeroexistence.org on 21 Nov 2011 at 11:49

GoogleCodeExporter commented 9 years ago
I tried several tricks that usually help (increase of DPI + resizing image, 
adding border, inverting colors - to have white background, decreasing number 
of colors) but without success.

Maybe you should try to run traning for your images...

Original comment by zde...@gmail.com on 21 Nov 2011 at 3:46

GoogleCodeExporter commented 9 years ago
Finally, I create my own config file.
It only consist letter from a-z and all lowercase
The success rate is quite high, it only can't recognize some letter like 
'e'(becomes 'g')

iPhone$B$+$iAw?.(B

Original comment by elb...@zeroexistence.org on 21 Nov 2011 at 5:32

GoogleCodeExporter commented 9 years ago
Hi,
I have a similar problem with single character recognition, so maybe you can 
help me out.
I use tesseract on Android and set PageSeqMode to single character:
baseApi.setPageSegMode(TessBaseAPI.PSM_SINGLE_CHAR);

I pass a single black character on white background (thresholded using adaptive 
thresholding; added a two pixel wide white border; tried to enlarge and sharpen 
the image, used erosion to further increase the readability) to tesseract. 
For capital letters it returns quite good results, but for lower case letters 
like "e" or "a" i get only "." or ".." or sometimes numbers like 8 or 3 as 
result.

I tried to set the whitelist to lower case letters only like you did, using:
baseApi.setVariable("tessedit_char_whitelist", "abcdefghijklmnopqrstuvwxyz"); 
before
initialising tesseract, but there were no changes.

Maybe my problem comes from the fact that i do a lot of resizing with the 
image. I minimize the original image to increase speed of character location 
and after that i enlarge the images with the single characters again. Could it 
be that because of that there is too much noise in the image, allthough it 
looks quite good in the outputview, to correctly recognize the character?

When i pass the original color image to tesseract, it returns a better result 
for some reason.

THX for any help and kind regards
Markus

Original comment by markus.f...@gmail.com on 7 Feb 2012 at 11:19

GoogleCodeExporter commented 9 years ago
Hi markus, can you attach the image?
Maybe I can help you

First of all, after you set the whitelist character, what's the output?
When using windows cmd, you need to explicitly tell the tesseract to use the 
config,
I don't know how it is with Android version, should be the same

Best regards,
Elbert

Original comment by elb...@zeroexistence.org on 7 Feb 2012 at 2:04

GoogleCodeExporter commented 9 years ago
Hi Elbert!
Thanks for your reply!
Here is a short example what i do:
a_original.jpg is the testfile for my algorithm.

In the next step the picture is cropped by the user as he likes. 
If the cropped size is over 100px in width or height the picture gets minimized 
by 2 for faster location of the letter. The letter is located and a bounding 
box is drawn over it. 
Then i convert the detected letter to grayscale, add a 2px white border and do 
adaptive thresholding to get a black and white image of the letter.

a_not_Resized is the result of the location and preprocessing if the original 
picture is not resized.
Tesseract recognizes:
  original: "a" (PSM=standard)
  resized and Located version: "£1" (PSM=Single_char)

a_ResizedBy2 is the result after minimizing the picture by 2 and than later 
enlarge the located letter by 2 to get better results by tesseract.
Tesseract recognizes:
  original: "a" (PSM=standard)
  resized and Located version: "Cl" (PSM=Single_char)
  (minimized by 2 and resized by 3 or higher i get only "."

Now my questions:
  How many pixels whide should the white border be for good results?

  What pixel width & height should the letter have with an wihtout border?

  Can you imagine any other reason which could be causing my problems? 
  (instead of resizing)

In Android i pass the located letter as a 4 Channel ARGB8888 Color Bitmap to 
tesseract...

Thank you very much for your help!
regards 
Markus

Original comment by markus.f...@gmail.com on 7 Feb 2012 at 4:00

Attachments:

GoogleCodeExporter commented 9 years ago
Sorry i forgot about the white list. 
The FAQ of tesseract recommends to use
baseApi.setVariable("tessedit_char_whitelist", 
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
BEFORE init tesseract.
Sadly i found no other documentation.
For my application there is no difference with or without it... 

Original comment by markus.f...@gmail.com on 7 Feb 2012 at 4:05

GoogleCodeExporter commented 9 years ago
Now i've tried to use 
baseApi.setVariable(...)
after the baseApi.init() and now it recognizes the a as you mentioned above! 
But i have the same problem with "e" which is recognized as "G" and "g" results 
in "Q".
When i use setVariable() with lower case letters only than "g" and "e" are also 
correctly recognized, but naturally all capital letters are not recognized any 
more.

There has to be another solution for the problem, which offers better results, 
regarding letter- & bordersize or quality of the image or something else...

THX in advance!
Markus

Original comment by markus.f...@gmail.com on 7 Feb 2012 at 5:08

GoogleCodeExporter commented 9 years ago
Based on my experience, as long as the image shows the letter(no cut part) and 
the letter is neither deformed nor rotated, tesseract will give best result.

And higher resolution image is better than small image.

try to not resize the image too small

Original comment by elb...@zeroexistence.org on 8 Feb 2012 at 12:10

GoogleCodeExporter commented 9 years ago
Thx for the advice!

And how did you solve the issue with "e" recognized as "G" and "g" recognized 
in "Q"?
The problem with the whitelist is, if there are any numbers or other characters 
i think they will be recognized wrongly as letters or am i wrong? is there a 
possibility to ignore such cases?

Could it be if the image of a letter is too big, that it is also not recognized?

Original comment by markus.f...@gmail.com on 8 Feb 2012 at 3:49

GoogleCodeExporter commented 9 years ago
I don't think I can provide any help about that.
It's either you train the tesseract before or let the user train it on the 
go

I used tesseract to beat a game, so I used multiple sample(from different 
angle) and tried to find any possible letter from it.
Based on it, letter with curve or loop(like e, a, g) have a high chance to 
be misinterpreted, while letter like x, w, n are almost always correctly 
recognized by tesseract

Original comment by elb...@zeroexistence.org on 9 Feb 2012 at 4:39

GoogleCodeExporter commented 9 years ago
I am closing this issue because it look to me there is solution for reported 
problem (cannot recognize a single char).
For further discussion how to improve result I would suggest to use tesseract 
forums.

Original comment by zde...@gmail.com on 23 Feb 2012 at 8:33

GoogleCodeExporter commented 9 years ago
in tesseract,we text in given image is domains-tech and it gives donainsltcch 
and i have so many images andit give error 
please solve the error asa soon as possible
like in chrish.pol terreract gives the chrishopol 
in PROXY1686734 it gives PRUXYlBBBYBd etc

thanks in advance 
please solve my error as soon as possible on my id(singla.sam33@gmail.com)

Original comment by singla.s...@gmail.com on 21 Aug 2014 at 11:26

Attachments: