首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在tess-two android中获取识别文本的每个单词和边界框

如何在tess-two android中获取识别文本的每个单词和边界框
EN

Stack Overflow用户
提问于 2014-03-23 18:31:15
回答 1查看 3.2K关注 0票数 1

我使用ResultIterator从图像中获取每个单词,但我的在调用iterator.begin()时出现错误。我也不知道原因。

这是我当前的代码,

代码语言:javascript
复制
//Global
ArrayList<String> words = new ArrayList<String>();

@Override
    public void onPreviewFrame(final byte[] data, Camera camera) {
        final SurfaceView surfaceView = (SurfaceView) getActivity().findViewById(R.id.cameraView);
        //get camera params for ocr
        Camera.Parameters cameraParams = _camera.getParameters();
        int width = surfaceView.getWidth();
        int height = surfaceView.getHeight();
        PixelFormat pixFormat = new PixelFormat();
        PixelFormat.getPixelFormatInfo(cameraParams.getPreviewFormat(), pixFormat);
        int bpp = pixFormat.bytesPerPixel;
        int bpl = bpp * width;

        //ocr
        ocr.setImage(data, width, height, bpp, bpl);
        ocr.setRectangle(0, 50, width, height - 50);

        // Iterate through the results.
        final ResultIterator iterator = ocr.getResultIterator();
        iterator.begin(); //crashes my app
        do {
            words.add(iterator.getUTF8Text(PageIteratorLevel.RIL_WORD));
        } while (iterator.next(PageIteratorLevel.RIL_WORD));
    }
EN

回答 1

Stack Overflow用户

发布于 2014-03-23 20:16:05

根据Tesseract的APIExample,在获得迭代器之前,您需要调用Recognize方法。您可能需要为tess-two实现此方法。

另一个地点是通过hOCR输出。参见Export HOCR output for tesseract OCR in android

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22589660

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档