Extraction of text from image


#1

Hello,


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

#2
Hi Naradamahamuni,

Thank you for your inquiry.

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



#3

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

Can u provide me a solution.

#4
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.


#5

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%3A%3BWzJs3u86gl9biM%3Bhttp%253A%252F%252Fwww.thecarexpert.co.uk%252Fhow-does-the-uk-number-plate-system-work%252F&source=iu&pf=m&fir=0fDufi3FrFa_HM%3A%2CWzJs3u86gl9biM%2C_&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%3A%3BWzJs3u86gl9biM%3Bhttp%253A%252F%252Fwww.thecarexpert.co.uk%252Fhow-does-the-uk-number-plate-system-work%252F&source=iu&pf=m&fir=0fDufi3FrFa_HM%3A%2CWzJs3u86gl9biM%2C&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%3A%3BWzJs3u86gl9biM%3Bhttp%253A%252F%252Fwww.thecarexpert.co.uk%252Fhow-does-the-uk-number-plate-system-work%252F&source=iu&pf=m&fir=0fDufi3FrFa_HM%3A%2CWzJs3u86gl9biM%2C&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.

#6
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.


#7

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)

#8
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.


#9
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.


#10

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.

#11
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.


#13

Hi,

Unable to get the text from the below image URL.


#14

@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.


#15

Asad any updates on the query which i have sent.


#16

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
}
}


#17

@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.


#18

Hi,

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

test.DPI_300.png (150.3 KB)


#19

@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.