I'm trying to write a basic ocr android app using Google's Mobile Vision API, but I'm having difficulty actually getting the app to recognize text in a static image. I've looked through the codelabs tutorial, other people's questions, namely every single stackoverflow question with the android-vision tag, and the documentation, but I still haven't had any luck. I know someone else asked a similar question but the answer posted there doesn't work.
Here's an excerpt of my code
Bitmap photo = (Bitmap) extras.get("data");
pictureOcrView.setImageBitmap(photo);
Context context = getApplicationContext();
TextRecognizer ocrFrame = new TextRecognizer.Builder(context).build();
Frame frame = new Frame.Builder().setBitmap(photo).build();
if (ocrFrame.isOperational()){
Log.e(TAG, "Textrecognizer is operational");
}
SparseArray<TextBlock> textBlocks = ocrFrame.detect(frame);
for (int i = 0; i < textBlocks.size(); i++) {
TextBlock textBlock = textBlocks.get(textBlocks.keyAt(i));
Log.e(TAG, "something is happening");
}
I don't understand what the issue is. It's not like I'm getting garbled text, I'm just not receiving any text at all. When I test this application with a picture of text that functioned for the codelab tutorial I get nothing. It seems like the textBlock array isn't even being created, but I don't know why. I know I've created the frame because I can still run other frame methods like getHeight successfully, and the isOperational() has been returning true.
Any suggestions on what I'm doing wrong?