【发布时间】:2013-03-27 13:15:24
【问题描述】:
我被要求创建一个使用 OCR 和 Zxing 扫描代码栏的 Android 应用程序。 结果应该在 ImageView 中包含“代码栏图像”,在 TextView 中包含“扫描结果”和“OCR 结果”。
由于我是 Android 开发新手,谁能解释一下如何做。
我在zxing2.1的captureActivity中添加了如下代码。我还将 Tess-two.jar 添加到 Zxing。当我执行应用程序时停止。谁能告诉我如何将OCR代码添加到zxing。 这是我添加到 Zxing 的代码。
private void handleDecodeInternally(Result rawResult, ResultHandler resultHandler, Bitmap barcode) {
statusView.setVisibility(View.GONE);
viewfinderView.setVisibility(View.GONE);
resultView.setVisibility(View.VISIBLE);
String textocrResult;
ImageView barcodeImageView = (ImageView) findViewById(R.id.barcode_image_view);
if (barcode == null) {
barcodeImageView.setImageBitmap(BitmapFactory.decodeResource(getResources(),
R.drawable.launcher_icon));
} else {
barcodeImageView.setImageBitmap(barcode);
baseApi.setImage(ReadFile.readBitmap(barcode));
textocrResult = baseApi.getUTF8Text();
ocrResult = new OcrResult();
ocrResult.setText(textocrResult);
ocrResult.setBitmap(barcode);
TextView ocrResultTextView = (TextView) findViewById(R.id.ocr_result_text_view);
ocrResultTextView.setText(textocrResult);
}
【问题讨论】:
-
我已经将 zxing 2.1 导入到 eclipse 并添加了 core.jar。当我执行它时,我得到了条形码图像和扫描结果的结果。现在我可以将 OCR 功能添加到同一个 Zxing2.1 中吗?如果是这样怎么做。提前致谢。它很紧急..请你们任何人帮忙。
-
你的问题是什么?
-
Qadir Hussain,我的问题是如何从 Zxing Appli 获取 OCR 结果。我已经得到了 Barcode 的图像结果和使用 zxing 的条形码的扫描结果。现在如何使用相同的图像结果读取条形码下方的数字。上面是我用来 OCR 图像结果的代码,但它失败了。如果可以,请帮助我。请非常紧急。