Google愿景OCR阅读器无法检测小文本和倒像。

时间:2018-03-27 06:54:06

标签: android ocr android-camera2 google-vision

我使用Text Recognizer从图像中提取文本。我用camera2来捕捉图像。

TextRecognizer textRecognizer = TextRecognizerController.getControllerInstance().getTextRecognizerInstance(getContext(), getView());
        if (textRecognizer != null && textRecognizer.isOperational()) {
            Frame frame = new Frame.Builder().setBitmap(bitmap).build();
            SparseArray<TextBlock> detectedItems = textRecognizer.detect(frame);

            if (detectedItems != null && detectedItems.size() != 0) {
                getPresenter().extractText(detectedItems);
            } else {
                displaySnackbar(getContext().getResources().getString(R.string.Consult_MagicSearch_TextNotRecognizedErrorMessage));
            }
        } 



public void extractText(SparseArray<TextBlock> detectedItems) {
        TextBlock item = detectedItems.valueAt(0);
        String detectedText = item.getValue();
        contract.setTextRecognized(detectedText);
    }

0 个答案:

没有答案