2017-03-08 152 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 ... –