opencv实现视频录制
来源:互联网 发布:js location 新窗口 编辑:程序博客网 时间:2024/04/29 05:26
// Program to display a video from attached default camera device
// Author: Samarth Manoj Brahmbhatt, University of Pennsylvania
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
// Create a VideoCapture object to read from video file
// 0 is the ID of the built-in laptop camera, change if you want to use other camera
VideoCapture cap(0);
//check if the file was opened properly
if(!cap.isOpened())
{
cout << "Capture could not be opened succesfully" << endl;
return -1;
}
Size S = Size((int)cap.get(CV_CAP_PROP_FRAME_WIDTH), (int)cap.get(CV_CAP_PROP_FRAME_HEIGHT));
VideoWriter put("output.mpg", CV_FOURCC('M', 'P', 'E', 'G'), 30, S);
if (!put.isOpened())
{
cout << "File could not be created for writing.Check permissions" << endl;
return -1;
}
namedWindow("Video");
// Play the video in a loop till it ends
while(char(waitKey(1)) != 'q' && cap.isOpened())
{
Mat frame;
cap >> frame;
// Check if the video is over
if(frame.empty())
{
cout << "Video over" << endl;
break;
}
imshow("Video", frame);
put << frame;
}
return 0;
}
// Author: Samarth Manoj Brahmbhatt, University of Pennsylvania
#include <opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main()
{
// Create a VideoCapture object to read from video file
// 0 is the ID of the built-in laptop camera, change if you want to use other camera
VideoCapture cap(0);
//check if the file was opened properly
if(!cap.isOpened())
{
cout << "Capture could not be opened succesfully" << endl;
return -1;
}
Size S = Size((int)cap.get(CV_CAP_PROP_FRAME_WIDTH), (int)cap.get(CV_CAP_PROP_FRAME_HEIGHT));
VideoWriter put("output.mpg", CV_FOURCC('M', 'P', 'E', 'G'), 30, S);
if (!put.isOpened())
{
cout << "File could not be created for writing.Check permissions" << endl;
return -1;
}
namedWindow("Video");
// Play the video in a loop till it ends
while(char(waitKey(1)) != 'q' && cap.isOpened())
{
Mat frame;
cap >> frame;
// Check if the video is over
if(frame.empty())
{
cout << "Video over" << endl;
break;
}
imshow("Video", frame);
put << frame;
}
return 0;
}
1 0
- opencv实现视频录制
- opencv视频录制
- opencv录制视频
- OpenCV 视频录制codec
- OpenCV 摄像头录制视频
- OpenCV 录制视频
- OpenCV 录制视频
- OpenCV Python 录制视频
- opencv录制视频
- opencv调用摄像头录制视频
- android实现视频录制
- 实现语音视频录制
- android录制视频实现
- iOS实现视频录制
- Android实现录制视频
- opencv录制视频并保存视频
- opencv录制与播放视频设置
- PyQt+OpenCV 录制保存、播放视频
- android-类学习之AppCompatActivity
- 数据库存储效率优化实战:从50PB到32PB(超大容量优化策略)
- 最短路径 vijos P1406古韵之鹊桥相会
- Java并发2——内存可见性
- 微信小程序精品demo完工:We重邮
- opencv实现视频录制
- centos7 ambari启动成功,但不能在页面显示?
- oracle OJDBC版本的区别
- 安卓的整个权限管理:文章整理
- Linux安装配置JDK和Eclipse的步骤
- Python2.7.10以上pip更新及其他包安装
- Pandas 创建空的DataFrame
- mysql
- img-circle、img-responsive 图片剪裁(Bootstrap)