Hello everybody,
for my project I needed to convert images to text. I read the forum tutorials, but at the end I decided to write an extension.
For this purpose I used the API of ocr.space.
First step You have to register to have your free api key.
To get the text from a file in your phone
objectLocation: the file path in your phone
apiKey: your Api Key provided by OCRSpace
language: Language used for OCR (on ocr.space website you find the possible values)
fileType: supported image file formats (on ocr.space website you find the possible values)
scale: true or false, this can improve the OCR result
ocrEngine: 1,2 or 3 see specifications on Free OCR API
To get the text from a URL
url: the file position in the web
apiKey: your Api Key provided by OCRSpace
language: Language used for OCR (on ocr.space website you find the possible values)
If the responseCode is Ok you will find the OCR result on parsedText
here is an example of how to perform OCR with URL and File
How works the sample project:
Select Language (for FILE and URL), File Type and OCR Engine (only for FILE)
If You want an OCR from URL write the URL in the Text Box and then click on "Get URL OCR"
If You want an OCR from File take a pic with some text and then click on "Get FILE OCR"
Try scale On or OFF or different OCR Engine to see the difference
Hi @S11,
I don't know what You did,
Did You register on ocr.space to have your apikey?
Did You try my sample adding your apikey?
As You can see in my video I can use the extension without problem.
Best Regards
Marco
The log says: java.lang.NullPointerException: Attempt to invoke interface method 'void com.android.okhttp.internal.http.HttpStream.writeRequestHeaders(com.android.okhttp.Request)' on a null object reference
at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:606)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:475)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:411)
at com.android.okhttp.internal.huc.HttpURLConnectionImpl.getErrorStream(HttpURLConnectionImpl.java:154)
at com.android.okhttp.internal.huc.DelegatingHttpsURLConnection.getErrorStream(DelegatingHttpsURLConnection.java:98)
at com.android.okhttp.internal.huc.HttpsURLConnectionImpl.getErrorStream(HttpsURLConnectionImpl.java:30)
at OCRSpace.OCRSpace.PerformOCR(OCRSpace.java:278)
at OCRSpace.OCRSpace.OCRFromFile_Exec(OCRSpace.java:131)
at OCRSpace.OCRSpace$1.run(OCRSpace.java:99)
at java.lang.Thread.run(Thread.java:919)
I suppose this is related to path that could be wrong or permission denied.
Could I see the path value?
On my sample I save the image on the Pictures folder.
With my sample are You able to perform OCR?
Any suggestion from the path and permission experts, am I on the right way?
Hi @gopal_gopal
I searched on Free OCR API and on language I did not find reference to marathi language.
But if You use ocrEngine 3 with OCRFromFile You can use:
Hindi = hin
Kannada = kan
Telugu = tel
Tamil = tam
I hope this can be useful this for You?
Best Regards
Marco
Hi Marco,
I'm trying to use your extension for receipt recognition and it works!
But unfortunately you didn't include in the OCRFromFile call two important parameters that are present in the OCR API and could drastically improve the OCR quality: IsTable and DetectOrientation.
Is it possible to add these parameters?
Thank you
Alex