NX二次开发-基于OpenCV摄像头录制视频
NX9+VS2012+Opencv2.4.9
#include <opencv2/opencv.hpp> #include <iostream> using namespace std; using namespace cv; int main(int argc, char** argv) { VideoCapture capture(0); if (!capture.isOpened()) { printf("could not load video data...\n"); return -1; } //获取帧的属性 //double fps = capture.get(CV_CAP_PROP_FPS); Size size = Size(capture.get(CV_CAP_PROP_FRAME_WIDTH), capture.get(CV_CAP_PROP_FRAME_HEIGHT)); //printf("FPS:%f",fps); VideoWriter writer("D:\\123\\AAA.avi", CV_FOURCC(\'D\',\'I\',\'V\',\'X\'),15.0,size,true); //创建窗口 Mat frame; namedWindow("video-demo", CV_WINDOW_AUTOSIZE); //写入 while (capture.read(frame)) { imshow("video-demo", frame); writer.write(frame); char c = waitKey(100); if (c == \'q\') { break; } } waitKey(0); return 0; } Caesar卢尚宇 2020年7月5日
原始GIG有50M大,帧数很多。但博客园只能上传10M以内,所以将GIF降低帧数压缩成9M了。不清晰了,但是还是能看出大概样子的。
参考资料
https://www.bilibili.com/video/BV16J411A7k6?p=108
https://blog.csdn.net/Young__Fan/article/details/80022860