网上学习资料一大堆,但如果学到的知识不成体系,遇到问题时只是浅尝辄止,不再深入研究,那么很难做到真正的技术提升。
一个人可以走的很快,但一群人才能走的更远!不论你是正从事IT行业的老鸟或是对IT行业感兴趣的新人,都欢迎加入我们的的圈子(技术交流、学习资源、职场吐槽、大厂内推、面试辅导),让我们一起学习成长!
#include <opencv2/opencv.hpp>
#include <opencv2/highgui.hpp>
#include <opencv2/videoio.hpp>//for camera
#include <opencv2/video.hpp>
#include <opencv2/imgPRoc//imgproc.hpp>
#include <opencv2/ml/ml.hpp>
#include “opencv2/imgproc/imgproc.hpp”
#include “opencv2/ml/ml.hpp”
#include <time.h>
#include
#include
#include
using namespace std;
using namespace cv;
//一般的情况是不支持使用命名空间的
int main(int argc, char ** argv)
{
char filename[1024];
if (argc == 1)
sprintf(filename, “%s”, “camera1.avi”);
if (argc == 2)
sprintf(filename, “%s”, “123”);
VideoCapture capture;
capture.open(0);
if (!capture.isOpened())
{
cout << "Could not initialize capturing...\n" << endl;
return -1;
}
//按时间格式命名
time_t now = time(nullprt);获取1970.1.1至当前秒数time_t
struct tm * timeinfo = localtime(&now); //创建TimeDate,并转化为当地时间,
//struct tm * timeinfo = gmtime ( &currTime ); //创建TimeDate,并转化为GM时间,
char path[60];
strftime(path, 60, "%Y_%m_%d_%H_%M_%S", timeinfo);
char strPath[100];
sprintf(strPath, "%s.avi", path);//将创建文件的命令存入cmdchar中
//保存为avi格式视频
Mat frame;
VideoWriter writer;
writer.open(strPath, CV_FOURCC(