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

opencv 从摄像头显示视频

2014-04-09 20:39 411 查看
开始,视频不能正常显示,后来改动了网上代码的一个小部分,成功: capture = cvCreateCameraCapture( 1 );原来参数是0.

#include "stdafx.h"

#include "cv.h"

#include "highgui.h"

int _tmain(int argc, _TCHAR* argv[])

{

cvNamedWindow( "Example2_9", CV_WINDOW_AUTOSIZE );

CvCapture* capture;

if (argc==1) {

capture = cvCreateCameraCapture( 1 );

} else {

capture = cvCreateFileCapture( "E:\\tree1.avi" );

}

assert( capture != NULL );

IplImage* frame;

while(1) {

frame = cvQueryFrame( capture );

if( !frame ) break;

cvShowImage( "Example2_9", frame );

char c = cvWaitKey(10);

if( c == 27 ) break;

}

cvReleaseCapture( &capture );

cvDestroyWindow( "Example2_9" );

return 0;

}


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