
用opencv读取摄像头显示,但显示区域一片黑而不是摄像头的内容
程序如下//L2_2.cpp:Definestheentrypointfortheconsoleapplication.//#include"stdafx.h"#incl...
程序如下
// L2_2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include"highgui.h"
int main(int argc, char* argv[])
{
cvNamedWindow("Example2",CV_WINDOW_AUTOSIZE);
//读取摄像头
CvCapture* capture =cvCreateCameraCapture(-1);
IplImage *frame;
while(1)
{
frame=cvQueryFrame(capture);
if(!frame) break;
cvShowImage("Example2",frame);
char c=cvWaitKey(33);
if(c==27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Example2");
return 0;
}
编译成功,且摄像头已经装好驱动 展开
// L2_2.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "cv.h"
#include "cxcore.h"
#include"highgui.h"
int main(int argc, char* argv[])
{
cvNamedWindow("Example2",CV_WINDOW_AUTOSIZE);
//读取摄像头
CvCapture* capture =cvCreateCameraCapture(-1);
IplImage *frame;
while(1)
{
frame=cvQueryFrame(capture);
if(!frame) break;
cvShowImage("Example2",frame);
char c=cvWaitKey(33);
if(c==27) break;
}
cvReleaseCapture(&capture);
cvDestroyWindow("Example2");
return 0;
}
编译成功,且摄像头已经装好驱动 展开
1个回答
展开全部
你用的是opencv哪个版本呢?貌似你用的是vc++6.0搭载opencv1.0,如果是这样的话,那么可能不能用CvCapture capture* = cvCreateCameraCapture(0);来获得摄像头,opencv1.0有一种老式的获得摄像头的方法(这个看别人用过,但具体不清楚),目前主流是用visual studio 搭建opencv2.x(2.0版本以上的),试试更高的版本吧。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询