Skip to content

Huawei HIAI Engine “General text recognition” is not detecting any text from an image

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.

Logs after using general text recognition on an provided image in the sample app Logs from custom made app, still same results



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);
        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

Sample image output

No result example log

6 People found this is helpful