Extraction of text from image

Hello,


I downloaded java ocr jar and add in my project of eclipse,i need some working sample code for this problem.

Hi Naradamahamuni,

Thank you for your inquiry.

Please follow the links below for details on how to extract text from image using JAVA.

I taken some vehicle number plate images but im unable to get that text as my o/p .

Can u provide me a solution.
Hi Naradamahamuni,

Thank you for writing us back.

Please share some sample images with us. We will try to get text from those samples and update you about our findings via this forum thread.

here is the sample images


1. https://www.google.co.in/search?q=car+with+number+plate&safe=active&biw=1366&bih=659&tbm=isch&imgil=0fDufi3FrFa_HM%253A%253BWzJs3u86gl9biM%253Bhttp%25253A%25252F%25252Fwww.thecarexpert.co.uk%25252Fhow-does-the-uk-number-plate-system-work%25252F&source=iu&pf=m&fir=0fDufi3FrFa_HM%253A%252CWzJs3u86gl9biM%252C_&usg=__XYNOHEHyKa2ZzbYYKNyHJs3aZt0%3D&ved=0ahUKEwiC4Lekv_fMAhWBFaYKHQ3iBXIQyjcISQ&ei=1spGV4KdGIGrmAWNxJeQBw#imgrc=hoFhQKB5WoMcOM%3A

Displayed Output ::
-
w -

2.
https://www.google.co.in/search?q=car+with+number+plate&safe=active&biw=1366&bih=659&tbm=isch&imgil=0fDufi3FrFa_HM%253A%253BWzJs3u86gl9biM%253Bhttp%25253A%25252F%25252Fwww.thecarexpert.co.uk%25252Fhow-does-the-uk-number-plate-system-work%25252F&source=iu&pf=m&fir=0fDufi3FrFa_HM%253A%252CWzJs3u86gl9biM%252C_&usg=__XYNOHEHyKa2ZzbYYKNyHJs3aZt0%3D&ved=0ahUKEwiC4Lekv_fMAhWBFaYKHQ3iBXIQyjcISQ&ei=1spGV4KdGIGrmAWNxJeQBw#imgrc=Tr8CCfj7U6fm6M%3A

Displayed Output::

= sssAA


3.
https://www.google.co.in/search?q=car+with+number+plate&safe=active&biw=1366&bih=659&tbm=isch&imgil=0fDufi3FrFa_HM%253A%253BWzJs3u86gl9biM%253Bhttp%25253A%25252F%25252Fwww.thecarexpert.co.uk%25252Fhow-does-the-uk-number-plate-system-work%25252F&source=iu&pf=m&fir=0fDufi3FrFa_HM%253A%252CWzJs3u86gl9biM%252C_&usg=__XYNOHEHyKa2ZzbYYKNyHJs3aZt0%3D&ved=0ahUKEwiC4Lekv_fMAhWBFaYKHQ3iBXIQyjcISQ&ei=1spGV4KdGIGrmAWNxJeQBw#imgrc=aKj6ST1VGTa3gM%3A


Displayed Output::

-=IL’LIP - M-lLILIP -V


May i known the reason why its not working with most of the images.


Thanks&Regards

Muni.

Hi Naradamahamuni,

Thank you for sharing samples with us.

This is to update you that the current implementation of the Aspose.OCR API works well with images having resolution of at least 300 DPI and the accuracy rate tends to decrease by decreasing the resolution. It will not be possible to get 100% accuracy if you wish to scan the complete image. On the other hand, if you intend to get some specific contents from a portion of the image, you can use the custom recognition blocks to get better accuracy.

Please note, the above mentioned solution is useful in scenario when you have documents/images following the similar structure, that is; the contents to be scanned are always on the same location for each image.

In your case I would suggest that you should pass boundaries of the license plate to the OCR engine [i.e. custom recognition blocks] rather than relying on automatic detection. Furthermore with defined boundaries you can further optimize processing by providing the list of possible characters in the plate as a whitelist in OcrConfig. The license plates usually have a restricted set of allowed characters that are only upper-case alphabets and digits from 0 to 1.

hello,


I am included this aspose ocr java jar in servlet class, im getting this kind of exception can u help me.thanks for ur support.
java.lang.ClassNotFoundException: com.aspose.ocr.OcrEngine
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1701)
org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1546)
com.igate.UploadServlet.doPost(UploadServlet.java:37)
javax.servlet.http.HttpServlet.service(HttpServlet.java:641)
javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
Hi Naradamahamuni,

Thank you for writing us back.

Please share the sample project/code along with sample file with us. We will try to recreate the issue at our end and update you accordingly about our findings.

Hi Naradamahamuni,

Thank you for sharing sample code with us.

We have investigated the issue at our end. Initial investigation shows that there is no issue with Aspose.OCR API. What we have found with the help of exception details and the sample code is that there is some issue with configurations. Please provide more details about your environment, what is the web/app server, example of config files and your environment settings.

In addition to above it seems that the problem is in config files of application in Tomcat or in location of Aspose.OCR JAR file.

hello ikram,


Thank u for ur support, i found the error and resolved this above issue.Can we convert IRecognized text to string is it possible.let me knw.

Thanks&Regards,

Muni.

Hi Naradamahamuni,

Thank you for writing us back.

Yes you can convert IRecognizedText to string. Converting it to string will return whole recognized text without formatting. For more information please visit the link Interface IRecognizedText.

Hi,

Unable to get the text from the below image URL.

@raor9300

Could you please share the code snippet with which you tried to extract text from the image. We will further test the scenario in our environment and address it accordingly.

Asad any updates on the query which i have sent.

public class PerformOCROnImage {

public static void main(String[] args) throws Exception {
// ExStart:PerformOCROnImage
// The path to the documents directory.
String dataDir = Utils.getSharedDataDir(PerformOCROnImage.class);

// The image path
String imagePath = dataDir + “Sample.jpg”;

// Create an instance of OcrEngine
OcrEngine ocr = new OcrEngine();

// Set the Image property
ocr.setImage(ImageStream.fromFile(imagePath));

// Perform OCR and get extracted text
try {
if (ocr.process()) {
System.out.println(ocr.getText());
}
} catch (Exception e) {
e.printStackTrace();
}
// ExEnd:PerformOCROnImage
}
}

@raor9300

Thanks for sharing sample code snippet.

We have tested the scenario in our environment and noticed that text was not recognized correctly. Furthermore, we have also noticed that your image is of 72 DPI. Please note that Aspose.OCR for .NET performs better and gives expected results with the images of 300 DPI minimum. Would you please try using image with greater DPIs and in case you still face any issue, please feel free to let us know.

Hi,

We have changed to 300 DPI and checked even no proper text data.

test.DPI_300.png (150.3 KB)

@raor9300

An issue with ID OCR-718 has been logged in our issue management system for it. We will surely look into details of the issue and keep you posted with the status of its correction. Please spare us little time.

We are sorry for the inconvenience.