title: Use Zxing Library on PreviewFrame for Augmented Reality
body: <p>Can someone tell me how I can use the Zxing Library for an Augmented Reality App? I know the easiest way to use Zxing is via Intent, but I need the Camera View so I can not use the barcode App.</p>
  
  <p>I have a <code>SurfaceHolder.Callback</code> which is added to the main activity and overwrites following method:</p>
  
  <pre><code>@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);
  }
  </code></pre>
  
  <p>The setted picture size has to be available because it is in the list <code>parameters.getSupportedPictureSizes()</code>.</p>
  
  <p>And this method in the <code>QrCodeReader</code> class which implements <code>PreviewCallback</code>:</p>
  
  <pre><code>private Result result;
  private MultiFormatReader reader = new MultiFormatReader();
  private boolean init = false;
  
  public QrCodeReader(){
          Hashtable&lt;DecodeHintType, Object&gt; hints = new Hashtable&lt;DecodeHintType,
                Object&gt;();
      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();
      }
  }
  </code></pre>
  
  <p>The Logcat only shows <code>NotFoundException</code>.</p>