现在的位置: 首页 > 综合 > 正文

opencv 获取摄像头信息 并 显示

2012年10月20日 ⁄ 综合 ⁄ 共 545字 ⁄ 字号 评论关闭
#include "stdafx.h"
#include "opencv/cv.h"
#include <opencv/cxcore.h>
#include <opencv/highgui.h>

#ifdef DEBUG
	#pragma comment(lib, "opencv_highgui244d.lib")
#else
	#pragma comment(lib, "opencv_highgui244.lib")
#endif

int _tmain(int argc, _TCHAR* argv[])
{
	IplImage *pFrame = NULL;
	//获取摄像头
	CvCapture *pCapture = cvCreateCameraCapture(-1);

	while(1)
	{
		//获取一帧
		pFrame = cvQueryFrame(pCapture);
		if (!pFrame){
			break;
		}
	
		cvShowImage("videoShow", pFrame);
		char c = cvWaitKey(33);
		if (c == 27)
		{
			break;
		}
	}

	cvReleaseCapture(&pCapture);
	cvDestroyWindow("video");
	return 0;
}

库文件:opencv_core244.dll 、opencv_highgui244.dll

抱歉!评论已关闭.