// opencv_test.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <stdio.h>
#pragma comment(lib,"opencv_core246d.lib")
#pragma comment(lib,"opencv_highgui246d.lib")
#pragma comment(lib,"opencv_imgproc246d.lib")
int test()
{
int i;
IplImage* img=NULL;
CvCapture* capture=cvCaptureFromCAM(0);
cvWaitKey(1);
printf("after capturing\n");
cvNamedWindow("result",1);
for(i=0;i<10000;++i)
{
printf("frame %d\n",i);
img=cvRetrieveFrame(capture);
cvShowImage("result",img);
cvWaitKey(1);
}
printf("done\n");
cvWaitKey(3000);
cvReleaseCapture(&capture);
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
test();
return 0;
}
//
#include "stdafx.h"
#include "opencv/cv.h"
#include "opencv/highgui.h"
#include <stdio.h>
#pragma comment(lib,"opencv_core246d.lib")
#pragma comment(lib,"opencv_highgui246d.lib")
#pragma comment(lib,"opencv_imgproc246d.lib")
int test()
{
int i;
IplImage* img=NULL;
CvCapture* capture=cvCaptureFromCAM(0);
cvWaitKey(1);
printf("after capturing\n");
cvNamedWindow("result",1);
for(i=0;i<10000;++i)
{
printf("frame %d\n",i);
img=cvRetrieveFrame(capture);
cvShowImage("result",img);
cvWaitKey(1);
}
printf("done\n");
cvWaitKey(3000);
cvReleaseCapture(&capture);
return 0;
}
int _tmain(int argc, _TCHAR* argv[])
{
test();
return 0;
}

这是一个简单的C++程序,它利用OpenCV库来从摄像头捕获视频。通过`cvCaptureFromCAM(0)`初始化捕获设备,然后使用`cvRetrieveFrame`获取每一帧,并显示在名为'result'的窗口中。程序会连续显示视频帧,直到运行结束。
最低0.47元/天 解锁文章
774

被折叠的 条评论
为什么被折叠?



