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?
- 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.
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());
}
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…
Hi Moon,
//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 for being respond so quickly
Hi Moon,
salam… as u said aspose apis reads 300dpi image but my name plate instead of 300 dpi is not properly read by code?
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??
i want to send text to the mobiles using your apis how it can be achievE?