2017-03-08 49 views
0

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

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

回答

0

的问题是

doWebsiteCommunication(result.getText()); 

只是

updateLayout(result.getText()); 

更换这应该做工精细

PS:在doWebsiteCommunication是为了更新与外部网站scandata,但因为你只是想读取你不需要它的qr码

+0

谢谢!!!!!!!!!!!! –

+0

没问题我正在努力让自己适应这一点,我试图在没有用户点击的情况下创建图片。但是,当使用流选项的质量是低到检测条形码... – stackg91

+0

我希望它能解决!你有没有机会知道结果显示为图像?我有一个qr代码,扫描时它应该显示一个图像,但由于result.getText()是一个字符串,它只显示url ... –