2017-01-22 58 views

回答

0

你需要添加捕捉回調將焦點控件添加到您的相機會話。

private boolean firstCaptureDone = false; 
private CameraCaptureSession.CaptureCallback captureCallback = null; 

captureCallback = new CameraCaptureSession.CaptureCallback() { 

      @Override 
      public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request, TotalCaptureResult result) { 
       super.onCaptureCompleted(session, request, result); 

      boolean cameraFocussed = false; 

      private void process(CaptureResult result) { 
       int afState = result.get(CaptureResult.CONTROL_AF_STATE); 
       if (CaptureResult.CONTROL_AF_TRIGGER_START == afState) { 
        if (cameraFocussed) { 
         if (firstCaptureDone) { 
          firstCaptureDone = true; 
          Log.d(TAG, "firstCapture Done with focus"); 
         } 
        } 
       } 
       if (CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED == afState) { 
        cameraFocussed = true; 
       } else { 
        cameraFocussed = false; 
       } 
      } 

     }; 


mPreviewSession.setRepeatingRequest(mPreviewBuilder.build(), captureCallback, mBackgroundHandler); 
相關問題