栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > C/C++/C#

C++

C/C++/C# 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

C++

参考:C++ 获取当前时间,并转换成string类型https://blog.csdn.net/G_66_hero/article/details/97487543


#include
#include//解决CV_RGB2GRAY:无法解析的标识符
#include 
#include 
#include 
#include 
#include

#include 
#include 
#include 
#include 

using namespace cv;
using namespace std;

int main()
{
	//1.从摄像头读入视频
	VideoCapture cap(0);

	//2.循环显示每一帧
	while (1)
	{
		Mat cam;
		cap >> cam;//获取相机当前帧图像

		auto t = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());

		//转为字符串
		std::stringstream ss;
		// 可以分别以不同的形式进行显示
		ss << std::put_time(std::localtime(&t), "%m-%d_%H:%M:%S");
		//ss << std::put_time(std::localtime(&t), "%Y年%m月%d日%H时%M分%S秒");
		//ss << std::put_time(std::localtime(&t), "%Y%m%d%H%M%S");

		std::string str_time = ss.str();

		//添加文本到图像
		putText(cam, str_time, Point(50, 50), CV_FONT_HERSHEY_COMPLEX, 2, Scalar(25, 255, 25), 3);

		imshow("Camera", cam);//显示当前图像
		waitKey(1);//延时
	}
	return 0;
}

 

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/893404.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号