Using Zxing library on PreviewFrame for Augmented Reality

Can someone tell me how can I use the Zxing library for augmented reality applications? I know that the easiest way to use Zxing is through Intent, but I need a camera view, so I cannot use the barcode application.

I have a SurfaceHolder.Callback that is added to the main activity and overwrites the following method:

 @Override public void surfaceCreated(SurfaceHolder holder) { mCamera = Camera.open(); try { mCamera.setPreviewDisplay(holder); } catch (IOException e) { Log.d(TAG, "Can not set surface holder"); } mCamera.startPreview(); Parameters parameters = mCamera.getParameters(); parameters.setPreviewSize(1280, 720); parameters.setPictureSize(1280, 720); mCamera.setParameters(parameters); QrCodeReader reader = new QrCodeReader(); mCamera.setPreviewCallback(reader); } 

The set image size must be available as it is in the parameters.getSupportedPictureSizes() list.

And this method is in the QrCodeReader class that implements PreviewCallback :

 private Result result; private MultiFormatReader reader = new MultiFormatReader(); private boolean init = false; public QrCodeReader(){ Hashtable<DecodeHintType, Object> hints = new Hashtable<DecodeHintType, Object>(); hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE); reader.setHints(hints); } @Override public void onPreviewFrame(byte[] data, Camera camera) { PlanarYUVLuminanceSource source = new PlanarYUVLuminanceSource(data, 1280, 720, 0, 0, 1280, 720, true); HybridBinarizer hybBin = new HybridBinarizer(source); BinaryBitmap bitmap = new BinaryBitmap(hybBin); try { result = reader.decodeWithState(bitmap); Log.d("Result", "Result found!"); } catch (NotFoundException e) { Log.d(TAG, "NotFoundException"); } finally { reader.reset(); } } 

Logcat only displays a NotFoundException .

+4
source share
1 answer

NotFoundException is normal. If there is no barcode in the frame, this is the result. This does not mean that something is wrong in itself. Continue scanning.

+1
source

All Articles