From 93d3a4d554b7d56eaab204fad3a55a9618b1da29 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 20 Jul 2024 11:37:26 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9B=9D=E5=85=89=E6=97=B6?= =?UTF-8?q?=E9=97=B4=E8=AE=BE=E7=BD=AE=E7=9A=84=E5=8D=95=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 12 ++++++------ app/src/main/cpp/camera2/ndkcamera.cpp | 6 +++--- app/src/main/cpp/camera2/ndkcamera.h | 3 +-- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 5c867b55..98a00b22 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1171,7 +1171,6 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< params.autoExposure = mPhotoInfo.autoExposure; params.focusTimeout = mPhotoInfo.focusTimeout * 1000; params.exposureTime = mPhotoInfo.exposureTime; - params.expsTimeUs = mPhotoInfo.expsTimeUs; params.sensitivity = mPhotoInfo.sensitivity; params.compensation = mPhotoInfo.compensation; params.orientation = mPhotoInfo.orientation; @@ -1184,16 +1183,17 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< params.requestTemplate = 2; } +#if 0 if (photoInfo.ldrEnabled) { if (GpioControl::getLightAdc() > 1400) { params.autoExposure = 0; - params.exposureTime = 1200; - params.expsTimeUs = 0; + params.exposureTime = 1200000000; params.sensitivity = 1200; } } +#endif // GpioControl::EnableGpio(CMD_SET_CAM_3V3_EN_STATE, true); bool res = false; @@ -1509,12 +1509,12 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) photoInfo.autoExposure = 0; if (captureResult.avgY == 0) { - photoInfo.exposureTime = 600; + photoInfo.exposureTime = 600000000; photoInfo.sensitivity = 2500; } else if (captureResult.avgY <= 6) { - photoInfo.exposureTime = captureResult.exposureTime / 1000000 * 150 / captureResult.avgY; + photoInfo.exposureTime = captureResult.exposureTime * 150 / captureResult.avgY; photoInfo.sensitivity = photoInfo.sensitivity * 80 / captureResult.avgY; if (photoInfo.sensitivity < captureResult.sensitivity) { @@ -1527,7 +1527,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) } else { - photoInfo.exposureTime = captureResult.exposureTime / 1000000 * 120 / captureResult.avgY; + photoInfo.exposureTime = captureResult.exposureTime * 120 / captureResult.avgY; photoInfo.sensitivity = photoInfo.sensitivity * 60 / captureResult.avgY; if (photoInfo.sensitivity < captureResult.sensitivity) { diff --git a/app/src/main/cpp/camera2/ndkcamera.cpp b/app/src/main/cpp/camera2/ndkcamera.cpp index 530ea5da..341b3a28 100644 --- a/app/src/main/cpp/camera2/ndkcamera.cpp +++ b/app/src/main/cpp/camera2/ndkcamera.cpp @@ -704,10 +704,10 @@ int NdkCamera::open(const std::string& cameraId) { int32_t sensitivity = m_params.sensitivity; status = ACaptureRequest_setEntry_i32(capture_request, ACAMERA_SENSOR_SENSITIVITY, 1, &sensitivity); } - if (m_params.exposureTime > 0 || m_params.expsTimeUs > 0) + if (m_params.exposureTime > 0) { - int64_t exposureTime = ((int64_t)m_params.exposureTime) * 1000000; - exposureTime += ((int64_t)m_params.expsTimeUs) * 1000; + int64_t exposureTime = m_params.exposureTime; + status = ACaptureRequest_setEntry_i64(capture_request, ACAMERA_SENSOR_EXPOSURE_TIME, 1, &exposureTime); } } diff --git a/app/src/main/cpp/camera2/ndkcamera.h b/app/src/main/cpp/camera2/ndkcamera.h index c5c488a6..260a8e78 100644 --- a/app/src/main/cpp/camera2/ndkcamera.h +++ b/app/src/main/cpp/camera2/ndkcamera.h @@ -77,8 +77,7 @@ public: unsigned int zoom : 1; unsigned int wait3ALocked : 1; unsigned int reserved : 6; - unsigned int exposureTime; // ms - unsigned short expsTimeUs; // μs + int64_t exposureTime; unsigned int sensitivity; int compensation; float zoomRatio;