Hi All,
I am facing an issue while trying to read the text in image.
I am using the aspose-ocr-23.7.1.jar & onnxruntime-1.11.0.jar
below is my sample code:
import jpype
import os
from glob import glob
lib_path='../img_lib/'
#Start JVM
jpype.startJVM(jpype.getDefaultJVMPath(), "-ea")
#Load Library
for f in glob(lib_path + "*.jar"):
print("Loading",f)
jpype.addClassPath(os.path.abspath(f))
img_path='./'
AsposeOCR=jpype.JClass("com.aspose.ocr.AsposeOCR")
asposeocr = AsposeOCR()
Language=jpype.JClass("com.aspose.ocr.Language")
RecognitionSettings = jpype.JClass("com.aspose.ocr.RecognitionSettings")
settings = RecognitionSettings(detectAreas=True, autoSkew=True)
settings.setLanguage(Language.Eng)
data2 = asposeocr.RecognizePage(img_path+"aspose_sample_jpg_1.jpg", settings)
print(data2.recognitionText)
aspose_sample_jpg_1.jpg (33.8 KB)
@kathirmsc85
Can you please share if you are using the API with valid or 30-days free temporary license?
@asad.ali I think Trial License only using it.
will it not sufficient to do the POC?.
@kathirmsc85
We used below code snippet in our environment and obtained the attached results.
AsposeOCR api = new AsposeOCR();
RecognitionSettings set = new RecognitionSettings();
set.setDetectAreasMode(DetectAreasMode.NONE);
OcrInput input = new OcrInput(InputType.SingleImage, filters);
input.add(file);
ArrayList<RecognitionResult> results = api.Recognize(input, set);
System.out.println(results.get(0).recognitionText);
javaNone.zip (582 Bytes)
Yes, that would be sufficient.
@asad.ali
Kindly share the import statements for above snippet.
Still i am getting the part of the image data only
Thanks.
@kathirmsc85
In the above code, we used filters as well. We will be sharing complete information with you shortly.
@kathirmsc85
Sorry for the confusion. We did not use any filters. It was just an empty collection. Furthermore, you would only need “com.aspose.ocr” namespace to access all these classes. Can you please share some more details like the result you are getting. What version of JPype are you using, etc. We will test the scenario in our environment and address it accordingly.
@asad.ali
aspose-ocr-23.7.1.jar
onnxruntime-1.11.0.jar
Python 3.8.17 (default, Jul 5 2023, 21:04:15)
JPype1 1.2.1
Please find the code snippet.
import jpype
import os
from glob import glob
lib_path=’…/img_lib/’
Start JVM
jpype.startJVM(jpype.getDefaultJVMPath(), “-ea”)
#Load Library
for f in glob(lib_path + “*.jar”):
print(“Loading”,f)
jpype.addClassPath(os.path.abspath(f))
img_path=’./’
InputType = jpype.JClass(“com.aspose.ocr.InputType”)
DetectAreasMode = jpype.JClass(“com.aspose.ocr.DetectAreasMode”)
AsposeOCR=jpype.JClass(“com.aspose.ocr.AsposeOCR”)
asposeocr = AsposeOCR()
OcrInput=jpype.JClass(“com.aspose.ocr.OcrInput”)
Language=jpype.JClass(“com.aspose.ocr.Language”)
RecognitionSettings = jpype.JClass(“com.aspose.ocr.RecognitionSettings”)
settings = RecognitionSettings()
settings.setDetectAreasMode(DetectAreasMode.NONE)
settings.setLanguage(Language.Eng)
ocrinput = OcrInput(InputType.SingleImage)
ocrinput.add(img_path+“aspose_sample_jpg_1.jpg”)
data2 = asposeocr.Recognize(ocrinput, settings)
Output:
print(data2.get(0).recognitionText)
Name: kathirh Age 38
Masters Yes Degree M$g(C.S)
University Bbarathi4 Location Coimbatore
Short Name: masferafsrience
Full Name: MASTER OF SCIENCE
Abbreviation
Requesting
Business:
B2B, MARKET n
Country India
Known As:
Govt Affiliated: Yes
Affiliated Colleges Y Location Coimbatore
Entertainment Cult
************* Trial Licenses *************
Please check and let me know. why unable to extract the full image?
Thanks,
Kathiresh
@kathirmsc85
It looks like you are using the API without any license. Can you please try to set your license as well before using any method from the API? In case issue still persists, please let us know.