|
|
@ -941,10 +941,10 @@ void DrawOutlineText(cv::Ptr<cv::ft::FreeType2> ft2, cv::Mat& mat, const std::st
|
|
|
|
textSize = ft2->getTextSize(*it, fontSize, thickness, &baseline);
|
|
|
|
textSize = ft2->getTextSize(*it, fontSize, thickness, &baseline);
|
|
|
|
lineHeight = std::max(lineHeight, textSize.height);
|
|
|
|
lineHeight = std::max(lineHeight, textSize.height);
|
|
|
|
|
|
|
|
|
|
|
|
ft2->putText(mat, *it, pt, fontSize, clr, thickness, cv::LINE_AA, false);
|
|
|
|
ft2->putText(mat, *it, pt, fontSize, clr, thickness, cv::LINE_AA, false, true);
|
|
|
|
|
|
|
|
|
|
|
|
pt.x = startPoint.x;
|
|
|
|
pt.x = startPoint.x;
|
|
|
|
pt.y += lineHeight > 0 ? (lineHeight + 2) : 0;
|
|
|
|
pt.y += lineHeight > 0 ? (lineHeight + fontSize / 5) : 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -958,13 +958,11 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
|
|
|
|
|
|
|
mPhotoInfo.photoTime = time(NULL);
|
|
|
|
mPhotoInfo.photoTime = time(NULL);
|
|
|
|
int baseline = 0;
|
|
|
|
int baseline = 0;
|
|
|
|
cv::Size textSize, textSize2;
|
|
|
|
cv::Size textSize;
|
|
|
|
double fontScale = 1; // base 1024
|
|
|
|
|
|
|
|
double height = mat.size().height;
|
|
|
|
double height = mat.size().height;
|
|
|
|
double width = mat.size().width;
|
|
|
|
double width = mat.size().width;
|
|
|
|
// double ratio = std::min(height / 1024, width / 1920);
|
|
|
|
// double ratio = std::min(height / 1024, width / 1920);
|
|
|
|
double ratio = std::sqrt((height * width) / (1024.0 * 1920.0));
|
|
|
|
double ratio = height / 1024.0;
|
|
|
|
fontScale = fontScale * ratio;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cv::Rect rc(0, 0, mat.cols, mat.rows);
|
|
|
|
// cv::Rect rc(0, 0, mat.cols, mat.rows);
|
|
|
|
// cv::rectangle (mat, rc, cv::Scalar(255, 255, 255), cv::FILLED);
|
|
|
|
// cv::rectangle (mat, rc, cv::Scalar(255, 255, 255), cv::FILLED);
|
|
|
@ -1023,13 +1021,25 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int thickness = 4 * ratio;
|
|
|
|
int thickness = (int)(4.0 * ratio);
|
|
|
|
if (thickness < 2) thickness = 2;
|
|
|
|
if (thickness < 2) thickness = 2;
|
|
|
|
|
|
|
|
|
|
|
|
cv::Scalar scalar(255, 255, 255); // white
|
|
|
|
cv::Scalar scalar(255, 255, 255); // white
|
|
|
|
|
|
|
|
|
|
|
|
int fontSize = 24;
|
|
|
|
int fontSize = (int)(24.0 * ratio);
|
|
|
|
std::string fontPath = m_appPath+ "fonts/Noto.ttf";
|
|
|
|
std::string fontPath;
|
|
|
|
|
|
|
|
if (existsFile("/system/fonts/NotoSansCJK-Regular.ttc"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fontPath = "/system/fonts/NotoSansCJK-Regular.ttc";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (existsFile("/system/fonts/NotoSerifCJK-Regular.ttc"))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fontPath = "/system/fonts/NotoSerifCJK-Regular.ttc";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
fontPath = m_appPath+ "fonts/Noto.otf";
|
|
|
|
|
|
|
|
}
|
|
|
|
cv::Ptr<cv::ft::FreeType2> ft2;
|
|
|
|
cv::Ptr<cv::ft::FreeType2> ft2;
|
|
|
|
ft2 = cv::ft::createFreeType2();
|
|
|
|
ft2 = cv::ft::createFreeType2();
|
|
|
|
ft2->loadFontData(fontPath.c_str(), 0);
|
|
|
|
ft2->loadFontData(fontPath.c_str(), 0);
|
|
|
@ -1040,7 +1050,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
|
|
|
|
|
|
|
NdkCamera::CAPTURE_RESULT captureResult = mCamera->getCaptureResult();
|
|
|
|
NdkCamera::CAPTURE_RESULT captureResult = mCamera->getCaptureResult();
|
|
|
|
char str[128] = { 0 };
|
|
|
|
char str[128] = { 0 };
|
|
|
|
snprintf(str, sizeof(str), "AE=%u EXPS=%ums ISO=%d AF=%u FD=%.3f AFS=%u HDR=%d", captureResult.autoExposure,
|
|
|
|
snprintf(str, sizeof(str), "通道 AE=%u EXPS=%ums ISO=%d AF=%u FD=%.3f AFS=%u HDR=%d", captureResult.autoExposure,
|
|
|
|
(unsigned int)(captureResult.exposureTime / 1000000),
|
|
|
|
(unsigned int)(captureResult.exposureTime / 1000000),
|
|
|
|
captureResult.sensitibity,
|
|
|
|
captureResult.sensitibity,
|
|
|
|
captureResult.autoFocus,
|
|
|
|
captureResult.autoFocus,
|
|
|
@ -1050,8 +1060,8 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
// 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, scalar, thickness1, cv::LINE_AA);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ft2->putText(mat, str, cv::Point(0, mat.rows - 48),
|
|
|
|
ft2->putText(mat, str, cv::Point(0, mat.rows - fontSize - 20),
|
|
|
|
fontSize, scalarRed, thickness, cv::LINE_AA, false);
|
|
|
|
fontSize, scalarRed, -1, cv::LINE_AA, false);
|
|
|
|
|
|
|
|
|
|
|
|
// text.putText(mat, str.c_str(), cv::Point(0, mat.rows - 20), scalar);
|
|
|
|
// text.putText(mat, str.c_str(), cv::Point(0, mat.rows - 20), scalar);
|
|
|
|
|
|
|
|
|
|
|
@ -1062,7 +1072,7 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
cv::Point pt1, pt2;
|
|
|
|
cv::Point pt;
|
|
|
|
for (vector<OSD_INFO>::const_iterator it = mOsds.cbegin(); it != mOsds.cend(); ++it)
|
|
|
|
for (vector<OSD_INFO>::const_iterator it = mOsds.cbegin(); it != mOsds.cend(); ++it)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (it->text.empty())
|
|
|
|
if (it->text.empty())
|
|
|
@ -1070,38 +1080,37 @@ bool CPhoneDevice::OnImageReady(cv::Mat& mat)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _DEBUG
|
|
|
|
|
|
|
|
if (it->alignment == OSD_ALIGNMENT_BOTTOM_RIGHT)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
int aa = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
textSize = ft2->getTextSize(it->text, fontSize, thickness, &baseline);
|
|
|
|
textSize = ft2->getTextSize(it->text, fontSize, thickness, &baseline);
|
|
|
|
|
|
|
|
XYLOG(XYLOG_SEVERITY_DEBUG, "%s font Size=%d height: %d baseline=%d", it->text.c_str(), fontSize, textSize.height, baseline);
|
|
|
|
|
|
|
|
|
|
|
|
if (it->alignment == OSD_ALIGNMENT_TOP_LEFT)
|
|
|
|
if (it->alignment == OSD_ALIGNMENT_TOP_LEFT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pt1.x = it->x * ratio;
|
|
|
|
pt.x = it->x * ratio;
|
|
|
|
pt1.y = it->y * ratio + textSize.height;
|
|
|
|
pt.y = it->y * ratio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (it->alignment == OSD_ALIGNMENT_TOP_RIGHT)
|
|
|
|
else if (it->alignment == OSD_ALIGNMENT_TOP_RIGHT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pt1.x = width - textSize.width - it->x * ratio;
|
|
|
|
pt.x = width - textSize.width - it->x * ratio;
|
|
|
|
pt1.y= it->y * ratio + textSize.height;
|
|
|
|
pt.y= it->y * ratio;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (it->alignment == OSD_ALIGNMENT_BOTTOM_RIGHT)
|
|
|
|
else if (it->alignment == OSD_ALIGNMENT_BOTTOM_RIGHT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pt1.x = width - textSize.width - it->x * ratio;
|
|
|
|
pt.x = width - textSize.width - it->x * ratio;
|
|
|
|
pt1.y = height - it->y * ratio;
|
|
|
|
pt.y = height - it->y * ratio - textSize.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (it->alignment == OSD_ALIGNMENT_BOTTOM_LEFT)
|
|
|
|
else if (it->alignment == OSD_ALIGNMENT_BOTTOM_LEFT)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
pt1.x = it->x * ratio;
|
|
|
|
pt.x = it->x * ratio;
|
|
|
|
pt1.y = height - it->y * ratio;
|
|
|
|
pt.y = height - it->y * ratio - textSize.height;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
DrawOutlineText(ft2, mat, it->text, pt, fontSize, scalar, thickness);
|
|
|
|
cv::Point pt = pt1;
|
|
|
|
|
|
|
|
pt.x += textSize.width;
|
|
|
|
|
|
|
|
pt.y -= textSize.height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cv::rectangle(mat, pt1, pt, scalar2, -1);
|
|
|
|
|
|
|
|
pt2 = pt1;
|
|
|
|
|
|
|
|
pt2.y += textSize.height;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
DrawOutlineText(ft2, mat, it->text, pt1, fontScale, scalar, thickness);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
vector <int> params;
|
|
|
|
vector <int> params;
|
|
|
|