Reputation: 1223
When using "General text recognition" from HIAI Engine I can't make it detect and return any text. For instance for the sample image it returns empty text but with code 200. I used an example program from the HIAI documentation, so I don't know where the problem is. So i created another app from scratch and results are the same.
Upvotes: 1
Views: 312
Reputation: 34047
HiAI General Text Recognition Service limits the size of the input image. If the image size exceeds the specified range, error code 200 is returned.
You can also integrate Huawei ML Kit text recognition service with no restrictions on the image size. It applies to all Android phones without depending on the HMS.
Upvotes: 1
Reputation: 2035
I have figured something out, at least enough to make it work. Some of the images you are importing might be too large, and it throws a code 200, invalid format IE, the image height and width is too large. You will need to check if the height of the bitmap is over 2560 pixels and if the width is over 1440 and scale/crop it accordingly.
What I did:
Bitmap initClassifiedImg;
if(bitmap.getHeight()>2560 && bitmap.getWidth()>1440)
initClassifiedImg = Bitmap.createScaledBitmap(bitmap, 1440, 2560, true);
else if(bitmap.getHeight()>2560)
initClassifiedImg = Bitmap.createScaledBitmap(bitmap, bitmap.getWidth(), 2560, true);
else if (bitmap.getWidth()>1440)
initClassifiedImg = Bitmap.createScaledBitmap(bitmap, 1440, bitmap.getHeight(), true);
else
initClassifiedImg = Bitmap.createBitmap(bitmap);
Set this up to check for the bitmap and it should at the very least not generate a code 200 error Do note that certain images will still fail to generate results. If the resultcode is 0 with no result, that means it just isn't recognizing the text in the image.
Recognition image output example
Upvotes: 2
Reputation: 1
The basic capabilities of Huawei HIAI include face recognition, image recognition, natural language processing, language recognition, code detection and so on. If the text in the picture is not recognized, it is recommended to use the picture with high contrast.
Upvotes: 0