您的位置:首页 > 运维架构

OpenCV学习笔记【6】:从摄像机读入数据

2014-07-31 20:44 441 查看
从摄像设备读入数据。

// example_p30.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include "cv.h"
#include "highgui.h"

int _tmain(int argc, _TCHAR* argv[])
{
	CvCapture* capture;
	if( argc ==1 )
		capture = cvCreateCameraCapture(0);
	else
		capture = cvCreateFileCapture( "1.avi" );
	IplImage* frame;
	cvNamedWindow("Example6", CV_WINDOW_AUTOSIZE);
	while(1)
	{
		frame = cvQueryFrame( capture );
		if(!frame)
			break;
		cvShowImage("Example6", frame );
		char c = cvWaitKey(33);
		if(c == 27 )
			break;
	}
	assert( capture!=NULL );
	return 0;
}


效果如下图:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: