|
|
@ -3645,16 +3645,44 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
|
|
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
#if 1
|
|
|
|
// Save photo to temporary file and then rename to right path
|
|
|
|
// Save photo to temporary file and then rename to right path
|
|
|
|
bool res = cv::imwrite(tmpPath.c_str(), mat, params);
|
|
|
|
std::vector<uint8_t> imgContents;
|
|
|
|
size_t imgFileSize = getFileSize(tmpPath);
|
|
|
|
size_t imgFileSize = 0;
|
|
|
|
if (res && imgFileSize > 0)
|
|
|
|
bool res = cv::imencode(".jpg", mat, imgContents, params);
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
res = (rename(tmpPath.c_str(), fullPath.c_str()) == 0);
|
|
|
|
int errcode = 0;
|
|
|
|
|
|
|
|
res = writeFile(tmpPath.c_str(), &imgContents[0], imgContents.size(), errcode);
|
|
|
|
|
|
|
|
if (res)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (existsFile(tmpPath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
imgFileSize = getFileSize(tmpPath);
|
|
|
|
|
|
|
|
if (imgFileSize == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Empty File Written: %s errno=%d", tmpPath.c_str() + m_appPath.size(), errcode);
|
|
|
|
|
|
|
|
remove(tmpPath.c_str());
|
|
|
|
|
|
|
|
res = false;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Failed to Write File: %s errno=%d", tmpPath.c_str() + m_appPath.size(), errcode);
|
|
|
|
|
|
|
|
if (existsFile(tmpPath))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
remove(tmpPath.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
remove(tmpPath.c_str());
|
|
|
|
int errcode = errno;
|
|
|
|
res = false;
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Failed to Encode Image CH=%u PR=%u IMGID=%u, errno=%d", (uint32_t)photoInfo.channel, (uint32_t)photoInfo.preset, (uint32_t)photoInfo.photoId, errcode);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// bool res = cv::imwrite(tmpPath.c_str(), mat, params);
|
|
|
|
|
|
|
|
if (res/* && imgFileSize > 0*/)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
res = (rename(tmpPath.c_str(), fullPath.c_str()) == 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#else
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|