java - 华为 HIAI 引擎“通用文本识别”未检测到图像中的任何文本
问题描述
当使用 HIAI Engine 的“通用文本识别”时,我无法让它检测并返回任何文本。例如,对于示例图像,它返回空文本但代码为 200。我使用了 HIAI 文档中的示例程序,所以我不知道问题出在哪里。所以我从头开始创建了另一个应用程序,结果是一样的。
解决方案
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.
推荐阅读
- multilingual - Laravel 中的 Lang::get('locale') 和 __('locale') 有区别吗?
- javascript - 使用 Puppeteer 进行网页抓取。如果多次无法获得选择器,则转到另一个元素
- python - 如何构建正则表达式以仅将“//”之后的第一个“$”替换为“\$”?
- sql - 一个表中多个列的 SQL 计数
- ios - 在原生 iOS 应用程序中使用 Google Tag Manager 进行 Firebase 分析
- angular - NativeScript 中的本地图像未显示
- c++ - QTableView 比它的容器大
- android - Gallery App IndexOutOfBoundsException 使用 Firebase 数据库
- html - 父 flexbox 容器忽略孩子的 flexbox 最小宽度
- c# - 可枚举的 foreach 扩展