OCR.Space extension

with the OCR call in it the app crashes, if i remove the ocr call it doesnt it just displays teh path to the file with was 72kb

Yes I registered and received the apiKey

The exstension create a log file if there is an exception, search for FileStackLog.txt.
So I can understand what happens (I hope).

FileStackLog.txt (18.0 KB)

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?

Ciao
Marco

This worked for me on Android 10 and 13 with companion app

filePath:
/storage/emulated/0/Android/data/edu.mit.appinventor.aicompanion3/files/ctiImage.jpg

Note: slash at beginning of saveAs filename, full path given for objectLocation, and fileType = JPG not jpg

I had already tried both JPG and jpg.
Looks like the path may be the issue, ill try later and update on results.

Is these extension support marathi language?

Check if the language is listed here.

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

1 Like

I already read ocr space docs, but Thank you for spending time to reply me :hugs:.

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

Hi Alexandre,
in the next few days I will check and try to add these parameters.
Best Regards
Marco

Grazie mille Marco!

Ciao a tutti,

ocrFromFile
I added two parameters

isTable can be true or false
detectOrientation can be true or false

OCRAPI here You can find when to use it

OCRSpace.aix (18.3 KB)
OCR.aia (23.6 KB)

Best Regards
Marco Perrone

2 Likes

6 posts were split to a new topic: Send OCR output to TextToSpeech?

Hello thanks for the extension but when i am testing my app on my phone it is not working. When i take a picture it just shows me the image it does not give any text. If you can help please do. Can you do it fast pls i need it for my project and we dont have a lot of time.

Hi @Hikari did You follow the instruction at the beginning.
Register to have your api key, and then add your api key in the OCRKey variable in the project
I think this is your problem.
Best Regards
Marco

$r = $client->request('POST', 'http://api.ocr.space/parse/image',[
'headers' => ['apiKey' => 'KEY', 'OCREngine'=> 2 ],
'multipart' => [
[
'name' => 'file',
'contents' => $fileData

        ]
    ]
], ['file' => $fileData],  ['OCREngine'=> 4 ] );
$response =  json_decode($r->getBody(),true);

Please help me to put correctly OCREngine