Opencv VideoCapture实时捕捉摄像头信息
2024-09-29 15:06:07
#include "opencv2/highgui/highgui.hpp"
#include <iostream> using namespace cv;
using namespace std; int main(int argc, char* argv[])
{
VideoCapture cap(); // open the video camera no. 0 if (!cap.isOpened()) // if not success, exit program
{
cout << "Cannot open the video cam" << endl;
return -;
} double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); //get the width of frames of the video
double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT); //get the height of frames of the video cout << "Frame size : " << dWidth << " x " << dHeight << endl; namedWindow("MyVideo",CV_WINDOW_AUTOSIZE); //create a window called "MyVideo" while ()
{
Mat frame; //bool bSuccess = cap.read(frame); // read a new frame from video // if (!bSuccess) //if not success, break loop
//{
// cout << "Cannot read a frame from video stream" << endl;
// break;
//}
cap>>frame;
imshow("MyVideo", frame); //show the frame in "MyVideo" window if (waitKey() == ) //wait for 'esc' key press for 30ms. If 'esc' key is pressed, break loop
{
cout << "esc key is pressed by user" << endl;
break;
}
}
return ; }
另外注明下,本人曾经想用手机来充当摄像头,利用DroidCam软件,但是貌似Opencv不支持这种方式,虽然运行代码后能够找到摄像头,但是始终无法正常显示图像,后来换了一个摄像头就完全可以正常显示了。不知道有哪位大大给解释下
最新文章
- java 泛型
- 序列化Image到byte[]
- poj 3311 tsp入门
- ==与equals()的区别
- linux 下的使用 ln 创建 软链接 和 硬链接
- C++拾遗(四)指针相关
- jquery正则表达式显示文本框输入范围 只能输入数字、小数、汉字、英文字母的方法
- (原)Eclipse中将JNI生成的so打包成jar的步骤
- fineui webform
- java8 快速实现List转map 、分组、过滤等操作
- kettle 在javascrip代码组件中使用fireToDB()函数实现自定义数据库查询
- SQL SERVER 查看数据库安装时间
- JavaScript原生秒表、计时器
- Oracle简单触发器应用
- (转)Maven学习总结(八)——使用Maven构建多模块项目
- ps 如何将视频转换成gif?
- 插件PageHelper实现分页查询
- JavaScript总结(三)
- C#汉字转拼音,可识别多音字,带声调,提供正向、逆向、双向分词算法的小程序
- 如何在MyEclipse中建立一个代理服务器