2017-02-28 23 views
0

我試圖檢測與QR碼索尼smarteyeglass索尼Smarteyeglass檢測QR碼JPEG視頻流

當我使用CAMERA_MODE_STILL我可以拍攝一張照片,並檢測條形碼在正常工作!

現在,當我更改錄製模式CAMERA_MODE_JPG_STREAM_LOW_RATE

我必須將分辨率設置爲CAMERA_RESOLUTION_QVGA其他setCameraMode拋出「決議具有非法值」,因爲在SmartEyeglassControlUtils流支持只包含QVGA

private static final List<Integer> CAMERA_JPEG_STREAM_SUPPORT_RESOLUTION = Arrays.asList(
      SmartEyeglassControl.Intents.CAMERA_RESOLUTION_QVGA 
); 

我已經嘗試過修改,但後來相機不再工作了。

那麼如何檢測QR碼而不必實際捕捉圖片並將其發送到zxing庫?有沒有辦法提高質量,仍然使用流?還是必須使用Stillmode並實際拍攝照片才能使用3M分辨率?

回答

0

對不起,延遲迴復。您應該可以使用CAMERA_MODE_JPG_STREAM_LOW_RATE選項並逐幀捕獲所需的圖像並將它們發送到zing。如果您從SampleCameraControl示例開始並打開「SampleCameraControl.java」文件,則可以修改SampleCameraControl構造函數中的偵聽器,如下所示:

// Initialize listener for camera events 
    SmartEyeglassEventListener listener = new SmartEyeglassEventListener() { 
     // When camera operation has succeeded 
     // handle result according to current recording mode 
     @Override 
     public void onCameraReceived(final CameraEvent event) { 

      /* 
      * Turn over full control of the streamed video to the barcode scanner library 
      * */ 
      byte[] bitmapdata = event.getData(); 

      //Convert the camera data to a bitmap 
      Bitmap originalBitmap = BitmapFactory.decodeByteArray(bitmapdata, 0, bitmapdata.length); 

      //Create a blank bitmap canvas so we can draw text 
      Bitmap mainBitMap = Bitmap.createBitmap(WIDTH, HEIGHT, Bitmap.Config.ARGB_8888);  
      Canvas mainCanvas = new Canvas(mainBitMap); 

      //Add the main bitmap to the new blank canvas 
      mainCanvas.drawBitmap(originalBitmap, 0, 0, new Paint()); 

      mainCanvas = drawScanText(mainCanvas, "Scan:null"); 

      //Scan the barcode with Zxing 
      scanBarcodeTask = new scanBarcodeTask().execute(originalBitmap); 

     } 
     // Called when camera operation has failed 
     // We just log the error 
     @Override 
     public void onCameraErrorReceived(final int error) { 
      Log.d(Constants.LOG_TAG, "onCameraErrorReceived: " + error); 
     } 
     // When camera is set to record image to a file, 
     // log the operation and clean up 
     @Override 
     public void onCameraReceivedFile(final String filePath) { 
      Log.d(Constants.LOG_TAG, "onCameraReceivedFile: " + filePath); 
      mode.closeCamera(utils); 
     } 
    };