0

$ 你好,我正在使用我在 Github 上找到的应用程序https://github.com/simsor/SmartEyeglassQRCode/blob/master/AndroidApp/app/src/main/java/com/example/sony/smarteyeglass/extension/helloworld/ HelloWorldControl.java是索尼 SmartEyeglass 的二维码阅读器。但由于某种原因,它不起作用。当我扫描二维码时,它要么显示“未找到二维码”,要么显示“请稍候”很长时间,但从未显示结果。我尝试了一些东西,但没有任何改变。你们中有人知道发生了什么吗?

 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);
                }
            }
        }
    }
4

1 回答 1

0

问题是

doWebsiteCommunication(result.getText());

只需将其替换为

updateLayout(result.getText());

这应该可以正常工作

PS:doWebsiteCommunication 旨在使用扫描数据更新外部网站,但由于您只想阅读二维码,因此不需要它

于 2017-03-09T08:16:43.107 回答