|
|
@ -760,7 +760,7 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
mCamera = NULL;
|
|
|
|
mCamera = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
ALOGI("TAKE_PHOTO: CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "TAKE_PHOTO: CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
mPhotoInfo = photoInfo;
|
|
|
|
mPhotoInfo = photoInfo;
|
|
|
|
mPath = path;
|
|
|
|
mPath = path;
|
|
|
|
mOsds = osds;
|
|
|
|
mOsds = osds;
|
|
|
@ -797,9 +797,11 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
mCamera = new CPhoneCamera(this, photoInfo.width, photoInfo.height, params);
|
|
|
|
mCamera = new CPhoneCamera(this, photoInfo.width, photoInfo.height, params);
|
|
|
|
if (mCamera->open(to_string(mPhotoInfo.cameraId)) == 0)
|
|
|
|
if (mCamera->open(to_string(mPhotoInfo.cameraId)) == 0)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "TP: Succeeded to OpenCamera CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "TP: Failed to OpenCamera CH=%u PR=%u PHOTOID=%u\n", (unsigned int)photoInfo.channel, (unsigned int)photoInfo.preset, photoInfo.photoId);
|
|
|
|
delete mCamera;
|
|
|
|
delete mCamera;
|
|
|
|
mCamera = NULL;
|
|
|
|
mCamera = NULL;
|
|
|
|
res = false;
|
|
|
|
res = false;
|
|
|
@ -831,8 +833,10 @@ bool CPhoneDevice::CloseCamera()
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera, bool turnOffOtg)
|
|
|
|
void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera, unsigned int photoId, bool turnOffOtg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "TP: CloseCamera PHOTOID=%u", photoId);
|
|
|
|
|
|
|
|
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
|
|
|
// std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
|
|
|
if (camera != NULL)
|
|
|
|
if (camera != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -1066,7 +1070,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
mCamera = NULL;
|
|
|
|
mCamera = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, turnOffOtg);
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
closeThread.detach();
|
|
|
|
closeThread.detach();
|
|
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
return res;
|
|
|
@ -1086,7 +1090,7 @@ bool CPhoneDevice::OnVideoReady(bool result, const char* path, unsigned int phot
|
|
|
|
TakePhotoCb(result, mPhotoInfo, fullPath, time(NULL), objs);
|
|
|
|
TakePhotoCb(result, mPhotoInfo, fullPath, time(NULL), objs);
|
|
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, turnOffOtg);
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
closeThread.detach();
|
|
|
|
closeThread.detach();
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
return result;
|
|
|
@ -1094,14 +1098,12 @@ bool CPhoneDevice::OnVideoReady(bool result, const char* path, unsigned int phot
|
|
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::onError(const std::string& msg)
|
|
|
|
void CPhoneDevice::onError(const std::string& msg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// XFLOG(XFLOG_SEVERITY_ERROR, "Failed to Take Photo: %s", msg.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (mCamera == NULL)
|
|
|
|
if (mCamera == NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int aa = 0;
|
|
|
|
int aa = 0;
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ALOGE("Failed to Take Photo: %s", msg.c_str());
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Failed to Take Photo (IMGID=%u): %s", mPhotoInfo.photoId, msg.c_str());
|
|
|
|
|
|
|
|
|
|
|
|
CPhoneCamera* pCamera = mCamera;
|
|
|
|
CPhoneCamera* pCamera = mCamera;
|
|
|
|
mCamera = NULL;
|
|
|
|
mCamera = NULL;
|
|
|
@ -1109,7 +1111,7 @@ void CPhoneDevice::onError(const std::string& msg)
|
|
|
|
TakePhotoCb(false, mPhotoInfo, mPath, 0);
|
|
|
|
TakePhotoCb(false, mPhotoInfo, mPath, 0);
|
|
|
|
|
|
|
|
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
bool turnOffOtg = (mPhotoInfo.usbCamera != 0);
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, turnOffOtg);
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, this, pCamera, mPhotoInfo.photoId, turnOffOtg);
|
|
|
|
closeThread.detach();
|
|
|
|
closeThread.detach();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|