From 81a413b02579423f73bd85abab4132dfae5df109 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sun, 11 Aug 2024 12:15:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=BA=9F=E5=BC=83=E7=9A=84?= =?UTF-8?q?=E7=85=A7=E7=89=87=EF=BC=88=E8=AE=BE=E7=BD=AE=E4=B8=BA=E4=B8=8D?= =?UTF-8?q?=E5=90=8C=E7=9A=84=E9=A2=84=E7=BD=AE=E4=BD=8D=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 69 ++++++-------------------------- 1 file changed, 12 insertions(+), 57 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 6b553287..b2185b11 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -1497,59 +1497,6 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) NdkCamera::CAPTURE_RESULT captureResult = mCamera->getCaptureResult(); -#if 0 - if (captureResult.avgY < 25 && mPhotoInfo.autoExposure != 0) - { - // Take another photo - CPhoneDevice* pThis = this; - std::string path = mPath; - IDevice::PHOTO_INFO photoInfo = mPhotoInfo; - std::vector osds = mOsds; - - photoInfo.photoId += 1; - photoInfo.autoExposure = 0; - if (captureResult.avgY == 0) - { - photoInfo.exposureTime = 600000000; - photoInfo.sensitivity = 2500; - } - else if (captureResult.avgY <= 6) - { - photoInfo.exposureTime = captureResult.exposureTime * 150 / captureResult.avgY; - photoInfo.sensitivity = photoInfo.sensitivity * 80 / captureResult.avgY; - if (photoInfo.sensitivity < captureResult.sensitivity) - { - photoInfo.sensitivity = captureResult.sensitivity; - } - else if (photoInfo.sensitivity > 3000) - { - photoInfo.sensitivity = 3000; - } - } - else - { - photoInfo.exposureTime = captureResult.exposureTime * 120 / captureResult.avgY; - photoInfo.sensitivity = photoInfo.sensitivity * 60 / captureResult.avgY; - if (photoInfo.sensitivity < captureResult.sensitivity) - { - photoInfo.sensitivity = captureResult.sensitivity; - } - else if (photoInfo.sensitivity > 3000) - { - photoInfo.sensitivity = 3000; - } - } - - std::thread t([=] - { - std::this_thread::sleep_for(std::chrono::milliseconds(5000)); - pThis->TakePhoto(photoInfo, osds, path); - }); - - t.detach(); - } -#endif // 0 - char extimeunit[4] = { 0 }; unsigned int extime = (captureResult.exposureTime >= 1000000) ? ((unsigned int)(captureResult.exposureTime / 1000000)) : ((unsigned int)(captureResult.exposureTime / 1000)); strcpy(extimeunit, (captureResult.exposureTime >= 1000000) ? "ms" : "μs"); @@ -1640,16 +1587,24 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) #ifdef OUTPUT_CAMERA_DBG_INFO bool shouldRetry = false; - if (captureResult.avgY > 230 || captureResult.avgY < 25) + if (captureResult.avgY > MAX_LIGHT_Y || captureResult.avgY < MIN_LIGHT_Y) { if (mPhotoInfo.retries < (DEFAULT_TAKE_PHOTO_RETRIES - 1)) { shouldRetry = true; - replaceAll(fullPath, ".jpg", std::string("-") + std::to_string(mPhotoInfo.retries) + ".jpg"); - replaceAll(fullPath, "/photos/", "/sentPhotos/"); - + // replaceAll(fullPath, ".jpg", std::string("-") + std::to_string(mPhotoInfo.retries) + ".jpg"); + replaceAll(fullPath, "_FF_", std::to_string(mPhotoInfo.retries)); XYLOG(XYLOG_SEVERITY_ERROR, "Photo is TOO dark or light(LDR=%u), will RETRY it", (uint32_t)captureResult.avgY); } + + if (captureResult.avgY > MAX_LIGHT_Y) + { + mPhotoInfo.compensation = -2 * ((int16_t)((uint16_t)captureResult.avgY)); + } + else + { + mPhotoInfo.compensation = 2 * captureResult.avgY; + } } #endif // OUTPUT_CAMERA_DBG_INFO