OpenCV调用USB摄像头源码
2015-08-03 11:42
363 查看
#include"cv.h"
#include"highgui.h"
#include"iostream"
using namespace std;
int main(int argc,char* argv[])
{
CvCapture* cap;
cap=cvCaptureFromCAM(1);
if(!cap)
{
cout<<"create camera capture error"<<endl;
system("pause");
exit(-1);
}
cvNamedWindow("img",1);
IplImage* img;
while(1)
{
img=cvQueryFrame(cap);//捕获相机的视频帧,并进行解码操作
if(!img)
break;
if(img->origin==IPL_ORIGIN_TL)//如果图片原点在左上角,将其沿X轴翻转,使左下角
{
cvFlip(img,img);
}
cvShowImage("img",img);
cvWaitKey(3);
}
cvReleaseCapture(&cap);
cvDestroyAllWindows();
cvReleaseImage(&img);
return 0;
}
#include"highgui.h"
#include"iostream"
using namespace std;
int main(int argc,char* argv[])
{
CvCapture* cap;
cap=cvCaptureFromCAM(1);
if(!cap)
{
cout<<"create camera capture error"<<endl;
system("pause");
exit(-1);
}
cvNamedWindow("img",1);
IplImage* img;
while(1)
{
img=cvQueryFrame(cap);//捕获相机的视频帧,并进行解码操作
if(!img)
break;
if(img->origin==IPL_ORIGIN_TL)//如果图片原点在左上角,将其沿X轴翻转,使左下角
{
cvFlip(img,img);
}
cvShowImage("img",img);
cvWaitKey(3);
}
cvReleaseCapture(&cap);
cvDestroyAllWindows();
cvReleaseImage(&img);
return 0;
}
相关文章推荐
- Shell 学习22 - Shell 函数参数
- prefdm respawning too fast stopped
- Linux下清除DNS缓存
- vs2013下openSIFT的编译调试
- Shell 学习21 - Shell 函数
- CentOS6 下Vim安装和配置
- Nginx在CDN加速之后,获取用户真实IP做并发访问限制的方法
- XSHELL下直接下载文件到本地(Windows)
- Ubuntu 使用apt-get安装nginx服务器
- Ubuntu 使用apt-get安装nginx服务器
- Kinect+OpenNI+VS
- 谁登录了你的linux
- nginx下载限速
- sqoop的安装及使用
- java;jsp;tomcat;mysql;hibernate;j2ee 编码中文乱码全面解决方案
- Shell 学习20 - Shell 跳出循环
- linux串口的设定
- Windows API——SHFileOperation——文件操作
- 深入学习Tomcat----自己动手写服务器(附服务器源码)
- Shell 学习19 - Shell until 循环