Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Drive OCR Android

I've downloaded Google drive sdk for Android, the API is not well documented, so I didn't manage to get to conclusion if what I want to do is possible. I want to capture an image with the camera convert it to black and white pdf, and then perform OCR on it to get the fields I need as String. Do I need to send a server request for it or maybe I can Do it on the client side only using Drive api? sample code will be helpful.

like image 954
BoazGarty Avatar asked Feb 16 '23 10:02

BoazGarty


1 Answers

Google's docs don't specify what happens to an uploaded file when you request OCR, specifically, they don't tell you if there is a response string.

However, a little experimenting shows that the only way to get the OCR data is to lookup the document after OCR is complete and grab the text.

You'll find the data structure for 'Files' here: https://developers.google.com/drive/v2/reference/files#resource - what your are after will be in "indexableText" as a string.

Unfortunately, it won't parse out any sort of 'fields'. That would require an understanding of the content... Also, it doesn't seem to capture any email addresses, which is an issue if you are trying to do business cards.

BTW, you will have to wait some time, upto 2 minutes, before the data is available. I'm not entirely sure, but it could also be that object id will not be available for that amount of time, so you might have to either run a background process or do something else.

like image 79
ckm Avatar answered Feb 26 '23 20:02

ckm