【问题标题】:Getting wrong text sequence when image scanned by offline google mobile vision API离线谷歌移动视觉API扫描图像时出现错误的文本序列
【发布时间】:2018-12-03 09:54:39
【问题描述】:
 public StringBuilder scanImage(Bitmap bp)
    {
        StringBuilder sb=null;
        TextRecognizer tcx = new 
        TextRecognizer.Builder(getApplicationContext()).build();
        if (!tcx.isOperational())
        {
            Toast.makeText(getApplicationContext(), "could not get text", Toast.LENGTH_SHORT).show();

        } else
        {
            Frame fame = new Frame.Builder().setBitmap(bp).build();
            SparseArray<TextBlock> items = tcx.detect(fame);
             sb = new StringBuilder();

            for (int i = 0; i < items.size(); ++i)
            {
                TextBlock mytext = items.valueAt(i);
                sb.append(mytext.getValue());
                sb.append("\n");

            }


        }
            return sb;

    }

这是我的代码。我正在使用移动谷歌视觉 API。我只是传递图像位图进行扫描,但此方法以错误的顺序返回扫描的文本。请告诉我如何以正确的顺序获取文本。提前谢谢你

【问题讨论】:

    标签: java android api


    【解决方案1】:

    未按顺序提供检测到的块。您需要检查每个文本块的位置并进行一些数学运算来排列它们。

    使用myText.getBoundingBox()myText.getCornerPoints()等方法查找文本块的位置。

    【讨论】:

      猜你喜欢
      • 2017-03-12
      • 2018-07-05
      • 2016-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多