I'm developing an OCR app for Android using JNI and a code developed under C++ using OpenCV and Tesseract. It will be used to read a badge with an alphanumeric ID from a photo taken by the app.
I developed an code which handle with the preprocess of the image, in order to obtain a "readable image" as the one below:
I wrote the following function for "reading" the image using tesseract:
char* read_text(Mat input_image)
{
tesseract::TessBaseAPI text_recognizer;
text_recognizer.Init("/usr/share/tesseract-ocr/tessdata", "eng", tesseract::OEM_TESSERACT_ONLY);
text_recognizer.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
text_recognizer.SetImage((uchar*)input_image.data, input_image.cols, input_image.rows, input_image.channels(), input_image.step1());
text_recognizer.Recognize(NULL);
return text_recognizer.GetUTF8Text();
}
The expected result is "KQ 978 A3705", but what I get is "KO 978 H375".
I did all the recommendations for improving the quality of the image from https://github.com/tesseract-ocr/tesseract/wiki/ImproveQuality. In addition, reading the docs from https://github.com/tesseract-ocr/docs, I tryed using an approximation of the images using polygons in order to get "better" features. The image I used is one like this:
With this image, I get "KO 978 A3705". The result is clearly better than the previous one, but is not fine.
I think that the processed image I pass to tesseract is fine enought to get a good result and I don't get it. I don't know what else to do, so I ask you for ideas in order to solve this problem. I need an exact result and I think I could get it with the processed image I get. Ideas please! =)
I noticed that with some dilations, the result ORC result is improved incredible well! For me, it was the solution
Related
I am working on a project for which I need to combine few images, The end result is an Image with resolution (120849, 296). In my Project, I am trying to save this image to my local disk in the jpg format using the imwrite() function. But it is not working for me. No error or exception is given by my current code.
The only solution that worked for me was this one.
Solution 1
Which is not what I want. Can anyone tell me, how can I save the image in jpg format in OpenCV 4.5.5 using compression parameters? I think this might be the solution that I need.
I'm working on a project with openCV for real time goal detection from a video stream by OpenCV.
So i have first to detect & extract the scoreBox, then try to read (recognize) the score by tesseract-ocr.
My issue is when i proceed to read the score box by tesseract, it doesn't give me the correct result (score value)
Example: applying tesseract on this image, it gives me the result 5: 55:35 L ‘.
Any help, what I have to do? Should I train tesseract or write my own OCR code ?
I wouldn't recommend to rewrite an OCR, but it really looks like the trained package you are using may not be adequate for this application. It might be necessary to create new trained data, as you suggested, with the appropriate font.
As the title suggest, i want to build an ANPR application in windows. I am using Brazilian number plates. And i am using OpenCV for this.
So far i manged to extract the letters form the numberplate. Following images show some of the numbers i have extracted.
The problem i am facing is that how to recognize those letter. I tried to use Google tesseract. But it fails to recognize them sometimes. Then i tried to train an OCR data base using OpenCV i used about 10 images for each character. but it also did not work properly.
So i am stuck here. i need this for final year project.So can anybody help me?? i would really appreciate it.
Following site does it very nicely
https://www.anpronline.net/demo.html
Thank you..
you could train an ann or multi-class svm on the letter images, like here
Check out OpenALPR (http://www.openalpr.com). It already has the problem solved.
If you need to do it yourself, you really do need to train Tesseract. It will give you the best results. 10 images per character is not enough, you need dozens or hundreds. If you can find a font that is similar to your plate characters, a good approach is to print out a sheet of paper with all of the characters used multiple times. Then take 5-10 pictures of the page with your camera. These can then be your input for training Tesseract.
2 jpg images that look exactly the same (failing image above, no.jpg, resaved as yes.png) but one is not an Image according to IsImageFile function.
Run this code
#IsImageFile("http://fdiapp.com/ini/cms/file_uploads/yes.jpg")#
**
#IsImageFile("http://fdiapp.com/ini/cms/file_uploads/no.jpg")#
I think the problem is that is a CMYK jpeg. ColdFusion 9 uses ImageIO internally, which afaik only supports RGB. (While some of the java suggestions in that thread do work from ColdFusion - the colors in the resulting image are skewed.) What is probably happening is that ImageIO fails to even load the image file and that is why IsImageFile returns "no".
FWIW, IsImageFile returns "yes" in ColdFusion 10. However, it still has issues with CMYK. For example if you try and read the image, the final colors are all wrong ...
I think your best bet is to run it through a tool like ImageMagick and convert it to a format ColdFusion can handle properly.
I am trying to use the ImageNew function (coldfusion 8) to create an image object with a image URL link, e.g. <cfset myImage=ImageNew(evaluate( "http://.../../1.jpg" ))>
There are many links there and most of them are good, but for some of the image links, I got an error when I call the ImageNew function: An exception occurred while trying to read the image. javax.imageio.IIOException: Unsupported Image Type
Does it have something to do with the size of images? Does anybody have any idea?
Many thanks
Results: Finally, it's the CMYK/RGB issue. It seems CF8 has trouble in dealing with CMYK and CF8 doesn't support convertion from CMYK to RGB. I use ImageMagic to do the convertion.
To be fair, I have this issue sometimes. I don't think it has anything to do with your code, coldfusion's image processing utilities either cannot process a perfectly valid image, or they choke on an image that is not up to standards. When this happens it is typically a client uploading an image and my system throws an error. They send me the file, I resave it out using photoshop or something like that, and poof, coldfusion likes it.
The only solution I know if this is the problem, is to use a third party image processor instread of coldfusion's built in functions. I used to use cfx_imagecr
http://efflare.com/products/cfx_imagecr/
But that is not the only solution out there.