0
我使用googlesample創建相機Android應用程序。我需要該攝像機重新關注視頻錄製開始以及每次錄製視頻時用戶按下對焦按鈕。我在哪裏可以找到如何實施它的例子?如何在使用Camera 2 Android錄製視頻期間按下按鈕時重新對焦相機?
這是我Camera2VideoFragment,它的parent類
我使用googlesample創建相機Android應用程序。我需要該攝像機重新關注視頻錄製開始以及每次錄製視頻時用戶按下對焦按鈕。我在哪裏可以找到如何實施它的例子?如何在使用Camera 2 Android錄製視頻期間按下按鈕時重新對焦相機?
這是我Camera2VideoFragment,它的parent類
你需要添加捕捉回調將焦點控件添加到您的相機會話。
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);