优化代码

streaming
Matthew 4 months ago
parent d6dc5729fe
commit e27cd3e5fe

@ -3603,6 +3603,7 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
replaceAll(tmpPath, "/photos/", "/tmp/"); replaceAll(tmpPath, "/photos/", "/tmp/");
#if 1 #if 1
// Save photo to temporary file and then rename to right path
bool res = cv::imwrite(tmpPath.c_str(), mat, params); bool res = cv::imwrite(tmpPath.c_str(), mat, params);
size_t imgFileSize = getFileSize(tmpPath); size_t imgFileSize = getFileSize(tmpPath);
if (res && imgFileSize > 0) if (res && imgFileSize > 0)
@ -3618,27 +3619,6 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
bool res = cv::imwrite(fullPath.c_str(), mat, params); bool res = cv::imwrite(fullPath.c_str(), mat, params);
size_t imgFileSize = getFileSize(fullPath); size_t imgFileSize = getFileSize(fullPath);
#endif #endif
#if 0
std::string bakPath = fullPath;
replaceAll(bakPath, "/photos/", "/backup/");
// cv::imwrite(bakPath.c_str(), mat, params);
vector<unsigned char> inImage;
imencode(".jpg", mat, inImage);
size_t bytesWrtten = 0;
if (!inImage.empty())
writeFile((bakPath + ".dat"), (const unsigned char*)&inImage[0], inImage.size());
bytesWrtten = getFileSize(bakPath + ".dat");
// #ifdef _DEBUG
size_t photoFileSize = getFileSize(fullPath);
XYLOG(XYLOG_SEVERITY_ERROR, "Photo File %s Size=%u BufSize=%u DataFileSize=%u", fullPath.c_str() + m_appPath.size(), (uint32_t)photoFileSize,
(uint32_t)inImage.size(), (uint32_t)bytesWrtten);
// #endif
#endif
if (!res) if (!res)
{ {
XYLOG(XYLOG_SEVERITY_ERROR, "Failed to Write File: %s", fullPath.c_str() + m_appPath.size()); XYLOG(XYLOG_SEVERITY_ERROR, "Failed to Write File: %s", fullPath.c_str() + m_appPath.size());

Loading…
Cancel
Save