package com.ocr;
import java.io.FileInputStream;
import java.io.IOException;
import com.aspose.ocr.AsposeLicenseException;
import com.aspose.ocr.ILanguage;
import com.aspose.ocr.ImageStream;
import com.aspose.ocr.Language;
import com.aspose.ocr.License;
import com.aspose.ocr.OcrEngine;
import com.aspose.ocr.RecognitionBlock;
public class AsposeOCRDemo {
public static String myDir = "c:/temp/";
public static void main(String args[]) throws IOException{
// Instantiate an instance of license and set the license file through its path
License license = new License();
try {
license.setLicense("/OCR/Aspose.OCR.lic");
} catch (AsposeLicenseException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
try{
// Set the paths
String imagePath = "/OCR/Sample.png";
// I Just changed the Resource file name to AsposeResources.zip
String resourcesFolderPath = "/OCR/AsposeResources.zip";
// Create an instance of OcrEngine
OcrEngine ocr = new OcrEngine();
// Set Resources for OcrEngine
ocr.setResource(new FileInputStream(resourcesFolderPath));
// Set NeedRotationCorrection property to false
//ocr.getConfig().setNeedRotationCorrection(false);
// Set image file
ocr.setImage(ImageStream.fromFile(imagePath));
// Add language
ILanguage language = Language.load("English");
ocr.getLanguages().addLanguage(language);
// Perform OCR and get extracted text
try {
if (ocr.process()) {
System.out.println("\ranswer -> " + ocr.getText());
}
} catch (Exception e) {
e.printStackTrace();
}
}catch(Exception e){
e.printStackTrace();
}
}
}
I tried to convert this PNG and iam getting the value converted to : answer -> naullowan
Let me know why this issue is happening, i got the Temp license also applied to the same