gpt4 book ai didi

android - TextRecognizer 只能检测 TextBlocks

转载 作者:行者123 更新时间:2023-11-29 17:16:16 24 4
gpt4 key购买 nike

我首先按照 Text API 教程来检测 TextBlock,效果很好。但是我现在想检测文本行,遇到了问题。

// TODO: Create the TextRecognizer
TextRecognizer textRecognizer = new TextRecognizer.Builder(context).build();

// TODO: Set the TextRecognizer's Processor.
textRecognizer.setProcessor(new OcrDetectorProcessor(mGraphicOverlay));

textRecognizer.setProcessor 只能使用TextBlock。有什么方法可以检测线吗?

最佳答案

点击Here , 阅读完整代码。希望对您有所帮助。

   Bitmap bitmap = decodeBitmapUri(this, imageUri);
if (detector.isOperational() && bitmap != null) {
Frame frame = new Frame.Builder().setBitmap(bitmap).build();
SparseArray<TextBlock> textBlocks = detector.detect(frame);
String blocks = "";
String lines = "";
String words = "";
for (int index = 0; index < textBlocks.size(); index++) {
//extract scanned text blocks here
TextBlock tBlock = textBlocks.valueAt(index);
blocks = blocks + tBlock.getValue() + "\n" + "\n";
for (Text line : tBlock.getComponents()) {
//extract scanned text lines here
lines = lines + line.getValue() + "\n";
for (Text element : line.getComponents()) {
//extract scanned text words here
words = words + element.getValue() + ", ";
}
}

关于android - TextRecognizer 只能检测 TextBlocks,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38770803/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com