#include<atltime.h>
using namespace cv;
while (1)
{
Mat img = imread("123.bmp", -1);
if (img.empty())
{
return -1;
}
CTime m_StartTime1 = CTime::GetCurrentTime();
CString filename = m_StartTime1.Format(_T("%Y-%m-%d %H:%M:%S"));
std::string text();
text = filename.GetBuffer(0);
//开发环境使用的字符集不同,可能需要进行调整
//USES_CONVERSION;
//std::string strS(W2A(strCS));
int font_face = cv::FONT_HERSHEY_COMPLEX;
double font_scale = 1;
int thickness = 1;
int baseline;
cv::Size text_size = cv::getTextSize(text, font_face, font_scale, thickness, &baseline);
cv::Point origin;
origin.x = img.cols / 2 - text_size.width / 2;
origin.y = text_size.height;
cv::putText(img, text, origin, font_face, font_scale, cv::Scalar(0, 0, 255), thickness, 8, 0);
namedWindow("Example1", WINDOW_AUTOSIZE);
imshow("Example1", img);
waitKey(20);
}
return 0;
}
利用OpenCv叠加时间
最新推荐文章于 2022-08-30 12:49:14 发布