用opencv的库函数的话非常简单,
#include "cv.h"
#include "highgui.h"
int main(int argc, char** argv) {
cvNamedWindow("win");
CvCapture* capture = cvCreateCameraCapture(0);
IplImage* frame;
while(1) {
frame = cvQueryFrame(capture);
if(!frame) break;
cvShowImage("win", frame);
char c = cvWaitKey(50);
if(c==27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("win");
return 0;
}
以上是代码,具体opencv库的安装配置网上很多的,你自己搜下配置好就可以。
温馨提示:答案为网友推荐,仅供参考