From dd10d364cdbbba1d2d1350403edb7ad8d044d328 Mon Sep 17 00:00:00 2001 From: Matthew Date: Sat, 21 Oct 2023 19:22:24 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=9C=AC=E5=9C=B0=E7=85=A7?= =?UTF-8?q?=E7=89=87=E5=91=BD=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/cpp/MicroPhoto.cpp | 2 +- app/src/main/cpp/PhoneDevice.cpp | 15 +++++++++------ app/src/main/cpp/PhoneDevice.h | 3 +-- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/app/src/main/cpp/MicroPhoto.cpp b/app/src/main/cpp/MicroPhoto.cpp index 135b72a2..a027244f 100644 --- a/app/src/main/cpp/MicroPhoto.cpp +++ b/app/src/main/cpp/MicroPhoto.cpp @@ -117,7 +117,7 @@ Java_com_xypower_mpapp_MicroPhotoService_init( device->SetListener(pTerminal); pTerminal->InitServerInfo(appPathStr, cmdidStr, ipStr, port, udpOrTcp); - pTerminal->SetPacketSize(1 * 1024); // 1K + // pTerminal->SetPacketSize(1 * 1024); // 1K bool res = pTerminal->Startup(device); env->ReleaseStringUTFChars(appPath, appPathStr); diff --git a/app/src/main/cpp/PhoneDevice.cpp b/app/src/main/cpp/PhoneDevice.cpp index d5be5008..2273b263 100644 --- a/app/src/main/cpp/PhoneDevice.cpp +++ b/app/src/main/cpp/PhoneDevice.cpp @@ -19,6 +19,7 @@ #define LOG_TAG "CameraTestHelpers" #include #include "PhoneDevice.h" +#include #include #include @@ -552,7 +553,7 @@ IDevice::timer_uid_t CPhoneDevice::RegisterHeartbeat(unsigned int timerType, uns return uid; } -bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector& osds, const string& path) +bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector& osds, const std::string& path) { if (mCamera != NULL) { @@ -599,6 +600,7 @@ void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera) bool CPhoneDevice::OnImageReady(const cv::Mat& mat) { + mPhotoInfo.photoTime = time(NULL); int baseline = 0; cv::Size textSize, textSize2; double fontScale = 1; // base 1024 @@ -651,18 +653,19 @@ bool CPhoneDevice::OnImageReady(const cv::Mat& mat) compression_params.push_back(mPhotoInfo.quality); bool res = false; - if (!std::filesystem::exists(std::filesystem::path(mPath))) + std::string fullPath = mPath + CTerminal::BuildPhotoFileName(mPhotoInfo); + if (!std::filesystem::exists(std::filesystem::path(fullPath))) { - bool res = cv::imwrite(mPath.c_str(), mat, compression_params); + bool res = cv::imwrite(fullPath.c_str(), mat, compression_params); if (!res) { - ALOGE("Failed to write photo: %s", mPath.c_str()); + ALOGE("Failed to write photo: %s", fullPath.c_str()); } else { - ALOGI("Succeeded to write photo: %s", mPath.c_str()); + ALOGI("Succeeded to write photo: %s", fullPath.c_str()); } - TakePhotoCb(res, mPhotoInfo, mPath, time(NULL)); + TakePhotoCb(res, mPhotoInfo, fullPath, time(NULL)); } else { diff --git a/app/src/main/cpp/PhoneDevice.h b/app/src/main/cpp/PhoneDevice.h index 522e294c..a5de9c54 100644 --- a/app/src/main/cpp/PhoneDevice.h +++ b/app/src/main/cpp/PhoneDevice.h @@ -50,7 +50,7 @@ public: virtual bool EnableGPS(bool enabled); virtual bool RequestPosition(); virtual timer_uid_t RegisterHeartbeat(unsigned int timerType, unsigned int timeout); - virtual bool TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector& osds, const string& path); + virtual bool TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector& osds, const std::string& path); virtual bool CloseCamera(); virtual timer_uid_t RegisterTimer(unsigned int timerType, unsigned int timeout, unsigned long times = 0); virtual bool UnregisterTimer(timer_uid_t uid); @@ -113,7 +113,6 @@ protected: atomic_ulong m_wakelockIdFeed; std::map mTimers; - mutable CPhoneCamera* mCamera; time_t mHeartbeatStartTime;