1

I have much trouble with xzing and decoding QR Code on a Google glass. The code works fine with starting the camera an calling the decoding method for the camera preview. The decoding always throws a "NotFoundExecption". The Test QRCode works fine on http://zxing.org/w/decode.jspx. I have tried many hints from other posts, but the problem always exists. I have taken the example from the zxing glass folder.

Here is my code for the method decode:

private void decode(byte[] data) {
  Result rawResult = null;

  int subtendedWidth = width / CameraConfigurationManager.ZOOM;
  int subtendedHeight = height / CameraConfigurationManager.ZOOM;
  int excessWidth = width - subtendedWidth;
  int excessHeight = height - subtendedHeight;

  //long start = System.currentTimeMillis();
  PlanarYUVLuminanceSource source =
      new PlanarYUVLuminanceSource(data,
                                   width, height,
                                   excessWidth / 2, excessHeight / 2,
                                   subtendedWidth, subtendedHeight,
                                   false);

  BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));

  try {
    rawResult = new MultiFormatReader().decode(bitmap, hints);
    //rawResult = new QRCodeReader().decode(bitmap, hints);
  } catch (ReaderException re) {
      // continue
      Log.i(TAG,"Decode Result: " + re.getMessage());
  }

  //long end = System.currentTimeMillis();
  //Log.i(TAG, "Decode in " + (end - start));
  Handler handler = getHandler();
  Message message;
  if (rawResult == null) {
    message = handler.obtainMessage(R.id.decode_failed);
  } else {
    Log.i(TAG, "Decode succeeded: " + rawResult.getText());
    message = handler.obtainMessage(R.id.decode_succeeded, rawResult);
  }
  message.sendToTarget();
}

And here my code on the preview call:

public void onPreviewFrame(byte[] data, Camera camera) {
if (running) {
  getHandler().obtainMessage(R.id.decode, data).sendToTarget();
}

}

The Constructor for my handler sets the following DecodingHints:

DecodeHandler() {
  hints = new EnumMap<>(DecodeHintType.class);
  hints.put(DecodeHintType.POSSIBLE_FORMATS,
      Arrays.asList(BarcodeFormat.AZTEC, BarcodeFormat.QR_CODE, BarcodeFormat.DATA_MATRIX));
  hints.put(DecodeHintType.TRY_HARDER, Boolean.TRUE);
  hints.put(DecodeHintType.PURE_BARCODE, Boolean.TRUE);
}

Does anybody see what my problem is?

Alex K
  • 8,269
  • 9
  • 39
  • 57
  • Can you post the content of your LogCat error? with the line numbers and all? That'll really help. – Alex K Apr 14 '15 at 12:15
  • Content from LogCat: "Decode Result: Null" But why? – Tobias Korch Apr 14 '15 at 20:01
  • The FULL trace - all of the lines. Should be 10-20 lines – Alex K Apr 14 '15 at 21:27
  • 04-21 14:06:21.709 1747-1747/com.myondemand.myfirstglass I/CameraConfiguration﹕ Enabling video stabilization... 04-21 14:06:21.709 1747-1747/com.myondemand.myfirstglass E/Camera﹕ Invalid area string=null 04-21 14:06:21.709 1747-1747/com.myondemand.myfirstglass I/CameraConfiguration﹕ Old metering areas: null May be here's the error? The Stacktrace is NULL too, so I can't show you more. – Tobias Korch Apr 21 '15 at 12:11
  • Can I send you the Project for analysing? I seems to work, but the exception is always a checksum error, but the codes can be read by other devices. – Tobias Korch Jun 10 '15 at 06:42

0 Answers0