|
|
|
@ -136,7 +136,7 @@ CPhoneDevice::CPhoneCamera::CPhoneCamera(CPhoneDevice* dev, int32_t width, int32
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::CPhoneCamera::on_image(const cv::Mat& rgb) const
|
|
|
|
|
bool CPhoneDevice::CPhoneCamera::on_image(const cv::Mat& rgb)
|
|
|
|
|
{
|
|
|
|
|
if (m_dev != NULL)
|
|
|
|
|
{
|
|
|
|
@ -146,7 +146,7 @@ bool CPhoneDevice::CPhoneCamera::on_image(const cv::Mat& rgb) const
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::CPhoneCamera::on_error(const std::string& msg) const
|
|
|
|
|
void CPhoneDevice::CPhoneCamera::on_error(const std::string& msg)
|
|
|
|
|
{
|
|
|
|
|
if (m_dev != NULL)
|
|
|
|
|
{
|
|
|
|
@ -353,7 +353,7 @@ bool CPhoneDevice::EnableGPS(bool enabled)
|
|
|
|
|
if (!res)
|
|
|
|
|
{
|
|
|
|
|
ALOGE("Failed to get JNI Env");
|
|
|
|
|
return 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
jboolean jenabled = enabled ? JNI_TRUE : JNI_FALSE;
|
|
|
|
|
env->CallVoidMethod(m_javaService, mEnableGpsMid, jenabled);
|
|
|
|
@ -361,6 +361,8 @@ bool CPhoneDevice::EnableGPS(bool enabled)
|
|
|
|
|
{
|
|
|
|
|
m_vm->DetachCurrentThread();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::RequestPosition()
|
|
|
|
@ -371,7 +373,7 @@ bool CPhoneDevice::RequestPosition()
|
|
|
|
|
if (!res)
|
|
|
|
|
{
|
|
|
|
|
ALOGE("Failed to get JNI Env");
|
|
|
|
|
return 0;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
jboolean ret = env->CallBooleanMethod(m_javaService, mRequestPositionMid);
|
|
|
|
@ -579,15 +581,23 @@ bool CPhoneDevice::TakePhoto(const IDevice::PHOTO_INFO& photoInfo, const vector<
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::CloseCamera()
|
|
|
|
|
{
|
|
|
|
|
if (mCamera != NULL)
|
|
|
|
|
// if (mCamera != NULL)
|
|
|
|
|
{
|
|
|
|
|
delete mCamera;
|
|
|
|
|
mCamera = NULL;
|
|
|
|
|
// mCamera->close();
|
|
|
|
|
// delete mCamera;
|
|
|
|
|
// mCamera = NULL;
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::OnImageReady(const cv::Mat& mat) const
|
|
|
|
|
void CPhoneDevice::CloseCamera2(CPhoneDevice::CPhoneCamera* camera)
|
|
|
|
|
{
|
|
|
|
|
std::this_thread::sleep_for(std::chrono::milliseconds(16));
|
|
|
|
|
camera->close();
|
|
|
|
|
delete camera;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CPhoneDevice::OnImageReady(const cv::Mat& mat)
|
|
|
|
|
{
|
|
|
|
|
int baseline = 0;
|
|
|
|
|
cv::Size textSize, textSize2;
|
|
|
|
@ -640,6 +650,7 @@ bool CPhoneDevice::OnImageReady(const cv::Mat& mat) const
|
|
|
|
|
compression_params.push_back(cv::IMWRITE_JPEG_QUALITY);
|
|
|
|
|
compression_params.push_back(mPhotoInfo.quality);
|
|
|
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
|
if (!std::filesystem::exists(std::filesystem::path(mPath)))
|
|
|
|
|
{
|
|
|
|
|
bool res = cv::imwrite(mPath.c_str(), mat, compression_params);
|
|
|
|
@ -652,27 +663,33 @@ bool CPhoneDevice::OnImageReady(const cv::Mat& mat) const
|
|
|
|
|
ALOGI("Succeeded to write photo: %s", mPath.c_str());
|
|
|
|
|
}
|
|
|
|
|
TakePhotoCb(res, mPhotoInfo, mPath, time(NULL));
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ALOGI("Photo file exists: %s", mPath.c_str());
|
|
|
|
|
}
|
|
|
|
|
// mCamera->close();
|
|
|
|
|
// delete mCamera;
|
|
|
|
|
// mCamera = NULL;
|
|
|
|
|
return true;
|
|
|
|
|
CPhoneCamera* pCamera = mCamera;
|
|
|
|
|
mCamera = NULL;
|
|
|
|
|
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, pCamera);
|
|
|
|
|
closeThread.detach();
|
|
|
|
|
|
|
|
|
|
return res;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CPhoneDevice::onError(const std::string& msg) const
|
|
|
|
|
void CPhoneDevice::onError(const std::string& msg)
|
|
|
|
|
{
|
|
|
|
|
// XFLOG(XFLOG_SEVERITY_ERROR, "Failed to Take Photo: %s", msg.c_str());
|
|
|
|
|
|
|
|
|
|
ALOGE("Failed to Take Photo: %s", msg.c_str());
|
|
|
|
|
|
|
|
|
|
// mCamera->close();
|
|
|
|
|
CPhoneCamera* pCamera = mCamera;
|
|
|
|
|
mCamera = NULL;
|
|
|
|
|
|
|
|
|
|
TakePhotoCb(false, mPhotoInfo, mPath, 0);
|
|
|
|
|
|
|
|
|
|
std::thread closeThread(&CPhoneDevice::CloseCamera2, pCamera);
|
|
|
|
|
closeThread.detach();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
std::string CPhoneDevice::GetFileName() const
|
|
|
|
|