0

$ Hello, I am using an app I found on Github https://github.com/simsor/SmartEyeglassQRCode/blob/master/AndroidApp/app/src/main/java/com/example/sony/smarteyeglass/extension/helloworld/HelloWorldControl.java, which is a qr code reader for Sony's SmartEyeglass. But for some reason it is not working. When I scan a QRcode, it either says "QR code not found" or "please wait" for a very long time, without ever showing the result. I tried a few things, but nothing changed. Does any of you maybe know what's going on ?

 public void processPicture(CameraEvent event) {
        updateLayout("Please wait...");

        if (event.getIndex() == 0) {
            if (event.getData() != null && event.getData().length > 0) {
                byte[] data = event.getData();
                Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);

                int[] intArray = new int[bitmap.getWidth() * bitmap.getHeight()];
                //copy pixel data from the Bitmap into the 'intArray' array
                bitmap.getPixels(intArray, 0, bitmap.getWidth(), 0, 0, bitmap.getWidth(), bitmap.getHeight());

                LuminanceSource source = new RGBLuminanceSource(bitmap.getWidth(), bitmap.getHeight(), intArray);

                BinaryBitmap bbmap = new BinaryBitmap(new HybridBinarizer(source));
                Reader reader = new QRCodeReader();
                int DelayTime = 5000;
                boolean error = false;
                try {

                    Result result = reader.decode(bbmap);
                    Log.d(Constants.LOG_TAG, result.getText());


                    doWebsiteCommunication(result.getText());
                } catch (NotFoundException e) {
                    updateLayout("QR Code Not Found");
                    error = true;
                    e.printStackTrace();
                } catch (ChecksumException e) {
                    e.printStackTrace();
                    updateLayout(new String[] {
                            "QR Code looks corrupted",
                            "Maybe try again?"
                    });
                    error = true;
                } catch (FormatException e) {
                    e.printStackTrace();
                    updateLayout("That's not a QR Code");
                    error = true;
                }

                if (error) {
                    try {
                        Thread.sleep(DelayTime);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    currentlyTakingPicture = false;
                    updateLayout(DEFAULT_TEXT);
                }
            }
        }
    }
Kat Dale
  • 27
  • 2

1 Answers1

0

The problem is the

doWebsiteCommunication(result.getText());

Just replace it with

updateLayout(result.getText());

This should work fine

PS: the doWebsiteCommunication was meant to update an external Website with the scandata, but since you just wanna read the qr code you dont need it

stackg91
  • 584
  • 7
  • 25
  • No problem I am struggeling myself abit with this, I am trying to create pictures without the user having to tap. But when using the stream options the quality is to low to detect the barcode... – stackg91 Mar 09 '17 at 09:14
  • I hope it works out! Do you know by any chance a way for the result displayed to be an image ? I have a qr code that when scanned it should show an image, but since the result.getText() is a string, it is only showing the url... – Kat Dale Mar 09 '17 at 11:55
  • Mh I am Not sure Havent worked with Images but You Can Check Out the Layout examples maybe There are images – stackg91 Mar 09 '17 at 13:18