From db2ed7e436d66292b2b7f66d499cde29782bb924 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 21 Jul 2024 19:57:13 +0800 Subject: [PATCH] =?UTF-8?q?=E9=94=81=E5=AE=9A=E5=AF=B9=E7=84=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/camera2/ndkcamera.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/src/main/cpp/camera2/ndkcamera.cpp b/app/src/main/cpp/camera2/ndkcamera.cpp index 8ca866eb..c0d74e1d 100644 --- a/app/src/main/cpp/camera2/ndkcamera.cpp +++ b/app/src/main/cpp/camera2/ndkcamera.cpp @@ -1268,6 +1268,16 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AWB_MODE, &val); mResult.awbMode = (status == ACAMERA_OK) ? *(val.data.u8) : ACAMERA_CONTROL_AWB_MODE_OFF; + if (afSupported && (m_params.autoFocus != 0)) + { + if (mResult.afState == ACAMERA_CONTROL_AF_STATE_PASSIVE_FOCUSED) + { + uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START; + status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig); + XYLOG(XYLOG_SEVERITY_DEBUG, "Trigger AF AFS=%u", (uint32_t)mResult.afState); + } + } + unsigned long long ts = GetMicroTimeStamp(); XYLOG(XYLOG_SEVERITY_DEBUG, "3ASTATE: AES=%u AWBS=%u AFS=%u", (uint32_t)mResult.aeState, (uint32_t)mResult.awbState, (uint32_t)mResult.afState); @@ -1320,16 +1330,10 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque mResult.sensitivity = (status == ACAMERA_OK) ? (*(val.data.i32)) : 0; } - if (afSupported && (m_params.autoFocus != 0)) - { - val = { 0 }; - status = ACameraMetadata_getConstEntry(result, ACAMERA_CONTROL_AF_STATE, &val); - mResult.afState = (status == ACAMERA_OK) ? *(val.data.u8) : ACAMERA_CONTROL_AF_STATE_INACTIVE; - } + if (m_imagesCaptured == ~0) { - if (ts - m_startTime >= m_params.focusTimeout * 2) { XYLOG(XYLOG_SEVERITY_WARNING, "Prepare Capture Timeout for 3A And will Capture AFS=%u AES=%u AWBS=%u Time=%u",