void Widget::printTime(cv::Mat &img)
{
time_t now = time(nullptr);
cv::Ptr<cv::freetype::FreeType2> ft2;
ft2 = cv::freetype::createFreeType2();
ft2->loadFontData("/usr/share/fonts/winFonts/SIMYOU.TTF",0);
tm* t = localtime(&now);
string text_time = to_string(t->tm_year + 1900) + "年 " +
to_string(t->tm_mon + 1) + "月 " +
to_string(t->tm_mday) + "日 " +
to_string(t->tm_hour) + ": " +
to_string(t->tm_min) + ": " +
to_string(t->tm_sec) ;
int * baseline=0;
cv::Size size_time_text = getTextSize(text_time,FONT_HERSHEY_SIMPLEX,1,2,baseline);
ft2->putText(img, text_time,Point(img.cols - size_time_text.width+30, size_time_text.height),
size_time_text.height,Scalar(0,0,255),1,8,true);
}
C++11 time.h中的时间
猜你喜欢
转载自blog.csdn.net/weixin_45824067/article/details/131117350
今日推荐
周排行