|
|
|
@ -48,6 +48,30 @@ extern bool GetJniEnv(JavaVM *vm, JNIEnv **env, bool& didAttachThread);
|
|
|
|
|
// are normalized to eight bits.
|
|
|
|
|
static const int kMaxChannelValue = 262143;
|
|
|
|
|
|
|
|
|
|
bool WriteMatToFile(const std::string& fileName, const cv::InputArray& img, const std::vector<int>& params = std::vector<int>())
|
|
|
|
|
{
|
|
|
|
|
std::vector<uint8_t> imgContents;
|
|
|
|
|
size_t imgFileSize = 0;
|
|
|
|
|
std::string ext;
|
|
|
|
|
auto pos = fileName.rfind('.');
|
|
|
|
|
if (pos != std::string::npos)
|
|
|
|
|
{
|
|
|
|
|
ext = fileName.substr(pos);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ext = ".jpg";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool res = cv::imencode(ext, img, imgContents, params);
|
|
|
|
|
if (res)
|
|
|
|
|
{
|
|
|
|
|
res = writeFile(fileName.c_str(), &imgContents[0], imgContents.size());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
class ByteArraysPointer
|
|
|
|
|
{
|
|
|
|
|
public:
|
|
|
|
@ -2705,7 +2729,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat mat)
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(std::filesystem::path(fullPath)))
|
|
|
|
|
{
|
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
|
bool res = WriteMatToFile(fullPath.c_str(), mat, params);
|
|
|
|
|
if (!res)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Failed to write photo: %s", fullPath.c_str());
|
|
|
|
@ -2956,7 +2980,7 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
|
|
|
|
|
char log[256] = { 0 };
|
|
|
|
|
strcpy(log, fullPath.c_str());
|
|
|
|
|
#endif
|
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
|
bool res = WriteMatToFile(fullPath.c_str(), mat, params);
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
if (getFileSize(fullPath.c_str()) == 0)
|
|
|
|
|
{
|
|
|
|
|