|
|
@ -450,6 +450,7 @@ void CPhoneDevice::CJpegCamera::onImageAvailable(AImageReader* reader)
|
|
|
|
if (!(status == AMEDIA_OK && planeCount == 1))
|
|
|
|
if (!(status == AMEDIA_OK && planeCount == 1))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// LOGE("Error: getNumberOfPlanes() planeCount = %d", planeCount);
|
|
|
|
// LOGE("Error: getNumberOfPlanes() planeCount = %d", planeCount);
|
|
|
|
|
|
|
|
AImage_delete(image);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -1740,6 +1741,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (photoInfo.cameraType == CAM_TYPE_PLZ)
|
|
|
|
else if (photoInfo.cameraType == CAM_TYPE_PLZ)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "PTZ PWR turned ON");
|
|
|
|
if(mPhotoInfo.scheduleTime == 0)
|
|
|
|
if(mPhotoInfo.scheduleTime == 0)
|
|
|
|
powerCtrlPtr = std::shared_ptr<PowerControl>(new PlzCameraPowerCtrl(mPhotoInfo.closeDelayTime));
|
|
|
|
powerCtrlPtr = std::shared_ptr<PowerControl>(new PlzCameraPowerCtrl(mPhotoInfo.closeDelayTime));
|
|
|
|
else
|
|
|
|
else
|
|
|
@ -2246,7 +2248,7 @@ bool CPhoneDevice::onOneCapture(std::shared_ptr<ACameraMetadata> characteristics
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CPhoneDevice* pThis = this;
|
|
|
|
CPhoneDevice* pThis = this;
|
|
|
|
std::thread th([pThis, characteristics, result, photoInfo, osds, path, rgb, facing, sensorOrientation, ldr, duration, takingTime]()mutable
|
|
|
|
std::thread th([pThis, characteristics, result, photoInfo, osds, path, rgb, facing, sensorOrientation, ldr, duration, takingTime]()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
std::string cameraInfo;
|
|
|
|
std::string cameraInfo;
|
|
|
|
if (photoInfo.outputDbgInfo != 0)
|
|
|
|
if (photoInfo.outputDbgInfo != 0)
|
|
|
@ -3332,6 +3334,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat mat)
|
|
|
|
|
|
|
|
|
|
|
|
#endif // OUTPUT_CAMERA_DBG_INFO
|
|
|
|
#endif // OUTPUT_CAMERA_DBG_INFO
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(std::filesystem::path(fullPath)) || getFileSize(fullPath) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
if (!res)
|
|
|
|
if (!res)
|
|
|
@ -3590,27 +3593,61 @@ bool CPhoneDevice::PostProcessPhoto(const PHOTO_INFO& photoInfo, const vector<ID
|
|
|
|
bool res = false;
|
|
|
|
bool res = false;
|
|
|
|
std::string fullPath = endsWith(path, ".jpg") ? path : (path + CTerminal::BuildPhotoFileName(photoInfo));
|
|
|
|
std::string fullPath = endsWith(path, ".jpg") ? path : (path + CTerminal::BuildPhotoFileName(photoInfo));
|
|
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(std::filesystem::path(fullPath)))
|
|
|
|
if (!std::filesystem::exists(std::filesystem::path(fullPath)) || getFileSize(fullPath) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
#ifdef _DEBUG
|
|
|
|
#ifdef _DEBUG
|
|
|
|
char log[256] = { 0 };
|
|
|
|
char log[256] = { 0 };
|
|
|
|
strcpy(log, fullPath.c_str());
|
|
|
|
strcpy(log, fullPath.c_str());
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
std::string tmpPath = fullPath;
|
|
|
|
#ifdef _DEBUG
|
|
|
|
replaceAll(tmpPath, "/photos/", "/tmp/");
|
|
|
|
if (getFileSize(fullPath.c_str()) == 0)
|
|
|
|
|
|
|
|
|
|
|
|
#if 1
|
|
|
|
|
|
|
|
bool res = cv::imwrite(tmpPath.c_str(), mat, params);
|
|
|
|
|
|
|
|
size_t imgFileSize = getFileSize(tmpPath);
|
|
|
|
|
|
|
|
if (res && imgFileSize > 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int aa = 0;
|
|
|
|
res = (rename(tmpPath.c_str(), fullPath.c_str()) == 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
remove(tmpPath.c_str());
|
|
|
|
|
|
|
|
res = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
|
|
|
|
size_t imgFileSize = getFileSize(fullPath);
|
|
|
|
|
|
|
|
#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
|
|
|
|
#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());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Succeeded to Write File: %s", fullPath.c_str() + m_appPath.size());
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Succeeded to Write File: %s, FileSize=%u", fullPath.c_str() + m_appPath.size(), (uint32_t)imgFileSize);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(1000));
|
|
|
|
TakePhotoCb(res ? 2 : 0, photoInfo, fullPath, photoInfo.photoTime, objs);
|
|
|
|
TakePhotoCb(res ? 2 : 0, photoInfo, fullPath, photoInfo.photoTime, objs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|