From cabf000b472adce6122ccb10871d099e55b2db3c Mon Sep 17 00:00:00 2001 From: BlueMatthew Date: Sat, 3 Feb 2024 09:50:46 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E5=AF=B9=E7=84=A6=E7=9A=84?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 1 + app/src/main/cpp/camera2/ndkcamera.cpp | 4 ++-- app/src/main/cpp/camera2/ndkcamera.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index f2dd9534..cfa41aa8 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -784,6 +784,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< params.nightMode = mPhotoInfo.nightMode; params.autoFocus = mPhotoInfo.autoFocus; params.autoExposure = mPhotoInfo.autoExposure; + params.focusTimeout = mPhotoInfo.focusTimeout * 1000; params.exposureTime = mPhotoInfo.exposureTime; params.sensibility = mPhotoInfo.sensibility; params.orientation = mPhotoInfo.orientation; diff --git a/app/src/main/cpp/camera2/ndkcamera.cpp b/app/src/main/cpp/camera2/ndkcamera.cpp index c6f68b91..66e1d281 100644 --- a/app/src/main/cpp/camera2/ndkcamera.cpp +++ b/app/src/main/cpp/camera2/ndkcamera.cpp @@ -451,7 +451,7 @@ int NdkCamera::open(const std::string& cameraId) { status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_MODE, 1, &afMode); uint8_t trig = ACAMERA_CONTROL_AF_TRIGGER_START; - // status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig); + status = ACaptureRequest_setEntry_u8(capture_request, ACAMERA_CONTROL_AF_TRIGGER, 1, &trig); m_imagesCaptured = (status == ACAMERA_OK) ? ~0 : 0; } else @@ -859,7 +859,7 @@ void NdkCamera::onCaptureCompleted(ACameraCaptureSession* session, ACaptureReque else { unsigned long long ts = GetMicroTimeStamp(); - if (ts - m_startTime >= 1000) + if (ts - m_startTime >= m_params.focusTimeout) { ALOGD("onCaptureCompleted Timeout for AutoFocus And will Capture AF_STATE=%u", (unsigned int)afState); m_imagesCaptured = 0; diff --git a/app/src/main/cpp/camera2/ndkcamera.h b/app/src/main/cpp/camera2/ndkcamera.h index fc7f4133..887866f3 100644 --- a/app/src/main/cpp/camera2/ndkcamera.h +++ b/app/src/main/cpp/camera2/ndkcamera.h @@ -74,7 +74,8 @@ public: unsigned int autoFocus : 1; unsigned int autoExposure : 1; unsigned int orientation:3; - unsigned int reserved : 25; + unsigned int focusTimeout : 14; // milli-seconds 65535 / 4 + unsigned int reserved : 11; unsigned int exposureTime; // ms unsigned int sensibility; };