|
|
|
@ -1373,7 +1373,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
int thickness = round(1.4 * ratio);
|
|
|
|
|
if (thickness < 1) thickness = 1;
|
|
|
|
|
else if (thickness > 5) thickness = 5;
|
|
|
|
|
cv::Scalar scalar(255, 255, 255); // white
|
|
|
|
|
cv::Scalar scalarWhite(255, 255, 255); // white
|
|
|
|
|
int fontSize = (int)(28.0 * ratio);
|
|
|
|
|
cv::Point pt;
|
|
|
|
|
|
|
|
|
@ -1561,7 +1561,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
(unsigned int)captureResult.afState, (unsigned int)captureResult.aeState, captureResult.awbState,
|
|
|
|
|
captureResult.sceneMode, GpioControl::getLightAdc(), (unsigned int)captureResult.avgY, captureResult.zoomRatio,
|
|
|
|
|
(uint32_t)captureResult.duration, captureResult.frameDuration);
|
|
|
|
|
// cv::putText(mat, str, cv::Point(0, mat.rows - 20), cv::FONT_HERSHEY_COMPLEX, fontScale, scalar, thickness1, cv::LINE_AA);
|
|
|
|
|
// cv::putText(mat, str, cv::Point(0, mat.rows - 20), cv::FONT_HERSHEY_COMPLEX, fontScale, scalarWhite, thickness1, cv::LINE_AA);
|
|
|
|
|
|
|
|
|
|
int fs = fontSize * 2 / 3;
|
|
|
|
|
textSize = ft2->getTextSize(str, fs, -1, &baseline);
|
|
|
|
@ -1570,13 +1570,13 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
cv::Point rb(0 + textSize.width, lt2.y + textSize.height + 8 * ratio);
|
|
|
|
|
|
|
|
|
|
cv::Mat roi = mat(cv::Rect(lt2, rb));
|
|
|
|
|
cv::Mat clrMat(roi.size(), CV_8UC3, cv::Scalar(0, 255, 255));
|
|
|
|
|
cv::Mat clrMat(roi.size(), CV_8UC3, scalarWhite);
|
|
|
|
|
double alpha = 0.2;
|
|
|
|
|
cv::addWeighted(clrMat, alpha, roi, 1.0 - alpha, 0.0, roi);
|
|
|
|
|
|
|
|
|
|
// cv::rectangle(mat, lt2, rb,cv::Scalar(255, 255, 255), -1);
|
|
|
|
|
ft2->putText(mat, str, lt, fs, scalarRed, -1, cv::LINE_AA, false);
|
|
|
|
|
// DrawOutlineText(ft2, mat, str, cv::Point(0, mat.rows - fs - 20 * ratio), fs, scalar, 1);
|
|
|
|
|
// DrawOutlineText(ft2, mat, str, cv::Point(0, mat.rows - fs - 20 * ratio), fs, scalarWhite, 1);
|
|
|
|
|
|
|
|
|
|
#endif // OUTPUT_CAMERA_DBG_INFO
|
|
|
|
|
|
|
|
|
@ -1620,7 +1620,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
|
|
|
|
|
// cv::Rect rc(pt.x, pt.y, textSize.width, textSize.height);
|
|
|
|
|
// cv::rectangle(mat, rc, cv::Scalar(0,255,255), 2);
|
|
|
|
|
DrawOutlineText(ft2, mat, it->text, pt, fontSize, scalar, thickness);
|
|
|
|
|
DrawOutlineText(ft2, mat, it->text, pt, fontSize, scalarWhite, thickness);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
vector <int> params;
|
|
|
|
@ -1629,6 +1629,22 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
|
|
|
|
|
bool res = false;
|
|
|
|
|
std::string fullPath = endsWith(mPath, ".jpg") ? mPath : (mPath + CTerminal::BuildPhotoFileName(mPhotoInfo));
|
|
|
|
|
|
|
|
|
|
#ifdef OUTPUT_CAMERA_DBG_INFO
|
|
|
|
|
bool shouldRetry = false;
|
|
|
|
|
if (captureResult.avgY > 245 || captureResult.avgY < 10)
|
|
|
|
|
{
|
|
|
|
|
if (mPhotoInfo.retries < (DEFAULT_TAKE_PHOTO_RETRIES - 1))
|
|
|
|
|
{
|
|
|
|
|
shouldRetry = true;
|
|
|
|
|
replaceAll(fullPath, ".jpg", std::string("-") + std::to_string(mPhotoInfo.retries) + ".jpg");
|
|
|
|
|
replaceAll(fullPath, "/photos/", "/sentPhotos/");
|
|
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_ERROR, "Photo is TOO dark or light(LDR=%u), will RETRY it", (uint32_t)captureResult.avgY);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif // OUTPUT_CAMERA_DBG_INFO
|
|
|
|
|
|
|
|
|
|
if (!std::filesystem::exists(std::filesystem::path(fullPath)))
|
|
|
|
|
{
|
|
|
|
|
bool res = cv::imwrite(fullPath.c_str(), mat, params);
|
|
|
|
@ -1640,7 +1656,18 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
{
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_INFO, "Succeeded to write photo: %s", fullPath.c_str());
|
|
|
|
|
}
|
|
|
|
|
#ifdef OUTPUT_CAMERA_DBG_INFO
|
|
|
|
|
if (shouldRetry)
|
|
|
|
|
{
|
|
|
|
|
TakePhotoCb(false, mPhotoInfo, fullPath, takingTime, objs);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
TakePhotoCb(res, mPhotoInfo, fullPath, takingTime, objs);
|
|
|
|
|
}
|
|
|
|
|
#else
|
|
|
|
|
TakePhotoCb(res, mPhotoInfo, fullPath, takingTime, objs);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|