|
|
|
@ -19,6 +19,7 @@
|
|
|
|
|
#define LOG_TAG "CameraTestHelpers"
|
|
|
|
|
#include <AndroidHelper.h>
|
|
|
|
|
#include "PhoneDevice.h"
|
|
|
|
|
#include <Client/Terminal.h>
|
|
|
|
|
#include <Utils.h>
|
|
|
|
|
|
|
|
|
|
#include <opencv2/opencv.hpp>
|
|
|
|
@ -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<OSD_INFO>& osds, const string& path)
|
|
|
|
|
bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<OSD_INFO>& 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
|
|
|
|
|
{
|
|
|
|
|