我正在将Google vision API集成到我现有的Android应用程序中。该应用程序确实识别QR码,但我需要实现UI功能,其中用户在条形码上显示图形轮廓。
答案 0 :(得分:5)
此代码示例包括在条形码上显示图形轮廓:
从探测器到图形的关联是这样的:
mGraphicOverlay = (GraphicOverlay<BarcodeGraphic>) findViewById(R.id.graphicOverlay);
// A barcode detector is created to track barcodes. An associated multi-processor instance
// is set to receive the barcode detection results, track the barcodes, and maintain
// graphics for each barcode on screen. The factory is used by the multi-processor to
// create a separate tracker instance for each barcode.
BarcodeDetector barcodeDetector = new BarcodeDetector.Builder(context).build();
BarcodeTrackerFactory barcodeFactory = new BarcodeTrackerFactory(mGraphicOverlay);
barcodeDetector.setProcessor(
new MultiProcessor.Builder<>(barcodeFactory).build());
GraphicOverlay包含在上面的代码示例中。此实用程序可以轻松添加在相机预览之上呈现的图形对象。请参阅此处的代码:
在此示例中,条形码工厂管理图形对象的创建,该图形对象为检测到的条形码绘制矩形和标签。请参阅此处定义的BarcodeGraphic类: