I want to extract text from image on windows 8 using eclipse

i want to extract text from image using eclipse so what should be the proper source code nd what apis and jdk should i use?

Hi Moon,

Thank you for your inquiry.

You can use Aspose.OCR for Java APIs to extract text from a scanned image. Following are the easy steps to extract the data from a scanned image:

  • Create an instance of OcrEngine.
  • Set the image file on which you want to perform OCR using property OcrEngine.Image.
  • Call the OcrEngine.process method.
  • If OcrEngine.process method returns true, get the recognized text using property OcrEngine.Text.

Sample Code:

//Initialize an instance of OcrEngine
OcrEngine ocrEngine = new OcrEngine();
//Set the Image property by loading the image from file path location
ocrEngine.setImage(ImageStream.fromFile(imagePath));
//Process the image
if (ocrEngine.process())
{
//Display the recognized text
System.out.println(ocrEngine.getText());
}


For more details, please follow the link. You can download the latest version of Aspose.OCR for Java by accessing this link.

Hope the above information helps. In case of any issues, need further clearance please be sure to let us know, we will be glad to assist you.

i did this but i dnt understand whts going wrong i already checked ur tutorials…

im using aspose aspose-ocr-2.3.0 but …

public static void main(String[] args) {

{

// TODO code application logic here

OcrEngine ocr = new OcrEngine();

String image=“C:\Users\g.jpg”;

String resource=“C:\ocr\aspose-ocr-2.3.0”;

[//ocr.setResource](https://ocr.setresource/)(new FileInputStream(resource));

ocr.setImage(ImageStream.fromFile(image));

// Ilanguage language = language(language(language)).load(“English”);

ocr.getLanguageContainer().addLanguage((ILanguage) language(language));

ocr.process();

System.out.print(ocr.getText());

}

public static Ilanguage language(Ilanguage language) {

return language;

}

private static class Ilanguage {

public Ilanguage() {

}

private Ilanguage load(String english) {

throw new UnsupportedOperationException(“Not supported yet.”); //To change body of generated methods, choose Tools | Templates.

}

}

}

out put coming

java.lang.ExceptionInInitializerError

Caused by: java.lang.RuntimeException: Uncompilable source code - method language(ocr.Ocr.Ilanguage) is already defined in class ocr.Ocr

at ocr.Ocr.(Ocr.java:47)

Exception in thread “main” Java Result: 1

Hi Moon,

First of all, you are using a very old revision (2.3.0) of Aspose.OCR for Java where the latest is v2.7.0. Secondly, while using the recent revisions of Aspose.OCR for Java, you do not need to set the language or resources in your code because the resources (for English language) have been embedded in the Jar it self and English has been set as default language to perform OCR operation. We strongly recommend you to upgrade the API and retest the scenario with upgraded API. In case the presented problem persists, we require your environment details as follow for thorough investigation on our side.

  • Operating system version & architecture
  • JDK vendor & version
  • Sample image on which you are performing the OCR operation

error occur in resource set proprty nd in get language here is a source code…

package oculus;
import com.aspose.ocr.ILanguuage;
import java.io.FileInputStream;
//import com.aspose.ocr.ILanguage;
//import com.aspose.ocr.ImageStream;
import com.aspose.ocr.OcrEngine;
import java.io.FileNotFoundException;



public class Oculus {

/**
* @param args the command line arguments
* @throws java.io.FileNotFoundException
*/
public static void main(String[] args) throws FileNotFoundException {
// TODO code application logic here
OcrEngine ocr=new OcrEngine();
String image=“Desktop\Sample.bmp”;
String resource=“C:\ocr\Aspose-OCR-2.3.0-javadoc\resources,zip”;
ocr.setResource(new FileInputStream(resource));
com.aspose.ocr.ILanguuage language= Language.load(“English”);
ocr.getLanguage().addLanguage(language);
ocr.process();
System.out.print(ocr.getText());
}

private static class Language {

private static ILanguuage load(String english) {
throw new UnsupportedOperationException(“Not supported yet.”); //To change body of generated methods, choose Tools | Templates.
}

public Language() {
}
}
}



errors are these:
at oculus.Oculus.main(Oculus.java:28)
Caused by: java.lang.ClassNotFoundException: com.aspose.ocr.internal.aux
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:425)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:358)
… 18 more

Hi Moon,


I am afraid, we can not evaluate the case with previous revisions of Aspose.OCR for Java, this is because the latest version 2.7.0 does not exhibit the said problem. Please check the following code, you will notice that you do not need to set the resource file as well as the language (in case of English) in your code any more. Please try it on your side while using the latest version of Aspose.OCR for Java 2.7.0 and let us know if you still face any difficulty.

Java

//Initialize an instance of OcrEngine
OcrEngine ocrEngine = new OcrEngine();

//Set the Image property by loading the image from file path location
ocrEngine.setImage(ImageStream.fromFile(imagePath));

//Process the image
if (ocrEngine.process())
{
//Display the recognized text
System.out.println(ocrEngine.getText());
}

Thank you for the aspose team :slight_smile: for being respond so quickly

Hi Moon,


You are most welcome.

We hope that the presented problem has been resolved while using the latest revision of Aspose.OCR for Java API. Please feel free to contact us back in case you need our further assistance with Aspose APIs.

salam… as u said aspose apis reads 300dpi image but my name plate instead of 300 dpi is not properly read by code?

Hi Moon,

Please, forward us the number plate image samples for testing. We will evaluate the scenario at our end and will update you accordingly about our findings.


from getting text by using java apis now i want to send this text to the mob users on their phone… how it would b possible??

Hi Moon,

Please, note that functionality of Aspose.OCR is to recognize the characters. For your particular requirement, you have to consult the respective vendor, website or some programming forum.

i want to send text to the mobiles using your apis how it can be achievE?

Hi Moon,

Thank you for your inquiry.

Please, note that using Aspose.OCR it is not possible to send text as mobile message. The functionality of Aspose.OCR is to recognize the characters only not to send any type of message.