From 882226ae7d6bad1289fd75ea81e45c4b78503ac8 Mon Sep 17 00:00:00 2001 From: BlueMatthew Date: Wed, 17 Jan 2024 18:02:36 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=8B=8D=E7=85=A7=E6=97=A5?= =?UTF-8?q?=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/PhoneDevice.cpp | 18 ++++++++++-------- app/src/main/cpp/PhoneDevice.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index 297dc403..500ee14f 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -760,7 +760,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< mCamera = NULL; } - ALOGI("TAKE_PHOTO: CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId); + XYLOG(XYLOG_SEVERITY_INFO, "TAKE_PHOTO: CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId); mPhotoInfo = photoInfo; mPath = path; mOsds = osds; @@ -797,9 +797,11 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector< mCamera = new CPhoneCamera(this, photoInfo.width, photoInfo.height, params); if (mCamera->open(to_string(mPhotoInfo.cameraId)) == 0) { + XYLOG(XYLOG_SEVERITY_DEBUG, "TP: Succeeded to OpenCamera CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId); } else { + XYLOG(XYLOG_SEVERITY_DEBUG, "TP: Failed to OpenCamera CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId); delete mCamera; mCamera = NULL; res = false; @@ -831,8 +833,10 @@ bool CPhoneDevice::CloseCamera() return true; } -void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera, bool turnOffOtg) +void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera, unsigned int photoId, bool turnOffOtg) { + XYLOG(XYLOG_SEVERITY_DEBUG, "TP: CloseCamera PHOTOID=%u", photoId); + // std::this_thread::sleep_for(std::chrono::milliseconds(16)); if (camera != NULL) { @@ -1066,7 +1070,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat) mCamera = NULL; bool turnOffOtg = (mPhotoInfo.usbCamera != 0); - std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, turnOffOtg); + std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg); closeThread.detach(); return res; @@ -1086,7 +1090,7 @@ bool CPhoneDevice::OnVideoReady(bool result, const char* path, unsigned int phot TakePhotoCb(result, mPhotoInfo, fullPath, time(NULL), objs); bool turnOffOtg = (mPhotoInfo.usbCamera != 0); - std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, turnOffOtg); + std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg); closeThread.detach(); return result; @@ -1094,14 +1098,12 @@ bool CPhoneDevice::OnVideoReady(bool result, const char* path, unsigned int phot void CPhoneDevice::onError(const std::string& msg) { - // XFLOG(XFLOG_SEVERITY_ERROR, "Failed to Take Photo: %s", msg.c_str()); - if (mCamera == NULL) { int aa = 0; return; } - ALOGE("Failed to Take Photo: %s", msg.c_str()); + XYLOG(XYLOG_SEVERITY_ERROR, "Failed to Take Photo (IMGID=%u): %s", mPhotoInfo.photoId, msg.c_str()); CPhoneCamera* pCamera = mCamera; mCamera = NULL; @@ -1109,7 +1111,7 @@ void CPhoneDevice::onError(const std::string& msg) TakePhotoCb(false, mPhotoInfo, mPath, 0); bool turnOffOtg = (mPhotoInfo.usbCamera != 0); - std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, turnOffOtg); + std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg); closeThread.detach(); } diff --git a/app/src/main/cpp/PhoneDevice.h b/app/src/main/cpp/PhoneDevice.h index dd9f3f30..f941cde9 100644 --- a/app/src/main/cpp/PhoneDevice.h +++ b/app/src/main/cpp/PhoneDevice.h @@ -232,7 +232,7 @@ protected: bool OnImageReady(cv::Mat& mat); void onError(const std::string& msg); - void CloseCamera2(CPhoneCamera* camera, bool turnOffOtg); + void CloseCamera2(CPhoneCamera* camera, unsigned int photoId, bool turnOffOtg); void TurnOnCameraPower(JNIEnv* env); void TurnOffCameraPower(JNIEnv* env);