当前位置:网站首页>5. [opencv writes recorded video]
5. [opencv writes recorded video]
2022-08-07 17:25:00 【Lee is struggling...】
opencv视频保存
(一)、What is video save?
本次课程讲:If we save the code of the video recorded by the computer camera to our file,And determine whether the image we loaded was successfully entered.
(二)、知道什么APL?
(1)、VideoWriter 类:Multiple video frames can be saved as a file.
1.1参数一为:输出文件(路径);
"E:\\视频\\out.mp4"
1.2参数二为:多媒体文件格式(int型);
JPMG(.mp4)、XVID(.val)
int coder = VideoWriter::fourcc('J','P','M','G');
1.3参数三为:video frame rate (int型);25/24
1.4参数四为:清晰度(Size型(wideth,height));
Get the clarity of the native computer:
int width = cap.get(CAP_PROP_FRAME_WIDTH);
int height = cap.get(CAP_PROP_FRAME_HEIGHT);
1.5参数五为:色彩 (bool型)(true为真.0为假);
1.6总结:
VideoWriter vw("E:\\视频\\out.mp4",coder,25.0,Size(width, height),true);
(2)、write方法、写入文件(把frame写入文件中去)、and compressed encoding.
Videowrite的对象.write(图像);
vw.write(fram1);
(3)、release在关闭文件的时候,And forcibly output the data in the buffer to the disk.
Videowrite的对象.release()
(三)、What is the idea of the article?
首先我们要设置opencv的头文件、Then make window settings,Then build againVideoCaptureObject gets our camera,然后设置VideoWriter保存文件对象、Do constructor padding、然后进行whileThe loop judges whether the opening of the photographic device is successful,If successful, read the data frame,Then judge whether to read the data frame,If reading in a data frame,Then help start showing the image,并进行写入操作,Then set the keyboard wait time to 25,进行录制,最后
Turn off photographic equipment、Close the read-in device.
(四)、实战项目:
1.代码展现:
#include <iostream>
#include <string.h>
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
Mat fram1;
namedWindow("视频", WINDOW_AUTOSIZE);
VideoCapture cap(0);
int coder = VideoWriter::fourcc('J','P','M','G');
int width = cap.get(CAP_PROP_FRAME_WIDTH);
int height = cap.get(CAP_PROP_FRAME_HEIGHT);
VideoWriter vw("E:\\视频\\out.mp4",coder,25.0,Size(width, height),true); //
while (cap.isOpened()) //True if it is opened
{
//cap >> fram1;
cap.read(fram1);
if (fram1.empty())break;
imshow("视频", fram1);
vw.write(fram1);
if (waitKey(25) == 27)break;
}
cout << "已经退出程序!" << endl;
cap.release();
vw.release();
return 0;
}
2.效果展现
代码展现
边栏推荐
猜你喜欢
![would dispatch back to the current handler URL [/getOssToken] again. Check your ViewResolver setup!](/img/a6/f1dd7a603f267d977400aed9b318dc.png)
would dispatch back to the current handler URL [/getOssToken] again. Check your ViewResolver setup!

Chrome scroll bar style modification how to operate Chrome browser scroll bar style customization method

co_fun 社区提供 微软秋招笔试 8.6 题解

笔记本电脑自动关机是什么原因 笔记本总自动关机的解决步骤

电脑看视频卡怎么解决 电脑看视频一卡一卡的解决教程

台式机怎么连接路由器 台式机如何连接路由器上网图解

win7添加字体怎么添加_win7添加字体步骤图解

Which software is easy to use for reinstalling the system, which is the best software for reinstalling the computer system

qq聊天截图怎么截长图 使用qq长截图的图文步骤

How to format Windows 7 laptop How to format Windows 7 laptop
随机推荐
win7安全模式进不去怎么办 win7无法进入安全模式如何解决
MySQL面试必备(四)锁篇
笔记本接显卡怎么操作 笔记本外接显卡详细教程
图文教你Word2003中怎么添加水印
电脑删不掉文件夹怎么办 电脑文件夹老是删不掉解决方法
使用C语言实现静态顺序表
特征工程介绍
would dispatch back to the current handler URL [/getOssToken] again. Check your ViewResolver setup!
电脑怎样安装读卡器驱动 电脑无法识别读卡器驱动安装步骤
w7电脑格式化怎么弄 笔记本电脑如何格式化win7
How to format Windows 7 laptop How to format Windows 7 laptop
基于FPGA温湿度采集(AHT10)
笔记本能连接手机热点吗 笔记本电脑连接手机个人热点的步骤
服务主机:本地服务网络受限怎么办_服务主机本地系统网络受限的解决方法
苹果笔记本电脑系统好用吗 苹果笔记本电脑系统好用不好用
电脑上怎么打符号 电脑上怎么输入特殊符号
win7添加字体怎么添加_win7添加字体步骤图解
JNI学习
启动win7系统开机黑屏提示0xc000000f错误代码怎么办
tiup cluster scale-in