[英]displaying video from webcam in OpenCV
I have installed VS2008 and am able to run the demo codes "camshiftdemo and lkdemo " which comes in the opencv library. 我已经安装了VS2008,并且可以运行opencv库中的演示代码“camshiftdemo和lkdemo”。 With this done, now I am trying to run some simple codes from the internet to get acquainted with the OpenCV.
完成后,我现在尝试从互联网上运行一些简单的代码,以熟悉OpenCV。 I am just trying to display video from webcam and I am getting the following error..
我只是想从网络摄像头显示视频,我收到以下错误..
Error I am getting is : 我得到的错误是:
Unhandled exception at 0x5e7e3d10 (highgui200.dll) in opencv.exe: 0xC0000005: Access violation reading location 0x719b3856.
opencv.exe中0x5e7e3d10(highgui200.dll)的未处理异常:0xC0000005:访问冲突读取位置0x719b3856。
The code I am trying to run is : 我试图运行的代码是:
#include <cv.h>
#include <highgui.h>
void main(int argc,char *argv[])
{
int c;
IplImage* color_img;
CvCapture* cv_cap = cvCaptureFromCAM(-1); // -1 = only one cam or doesn't matter
cvNamedWindow("Video",1); // create window
for(;;) {
color_img = cvQueryFrame(cv_cap); // get frame
if(color_img != 0)
cvShowImage("Video", color_img); // show frame
c = cvWaitKey(10); // wait 10 ms or for key stroke
if(c == 27)
break; // if ESC, break and quit
}
/* clean up */
cvReleaseCapture( &cv_cap );
cvDestroyWindow("Video");
}
Any help in this will be greatly appreciated. 任何帮助都将非常感谢。
The following code compiles and works for me in VS2008 using OpenCV 2.1 以下代码使用OpenCV 2.1编译并在VS2008中为我工作
#include <cv.h>
#include <highgui.h>
void main(int argc,char *argv[])
{
int c;
IplImage* color_img;
CvCapture* cv_cap = cvCaptureFromCAM(0);
cvNamedWindow("Video",0); // create window
for(;;) {
color_img = cvQueryFrame(cv_cap); // get frame
if(color_img != 0)
cvShowImage("Video", color_img); // show frame
c = cvWaitKey(10); // wait 10 ms or for key stroke
if(c == 27)
break; // if ESC, break and quit
}
/* clean up */
cvReleaseCapture( &cv_cap );
cvDestroyWindow("Video");
}
I think you must delete the "cvReleaseCapture( &cv_cap );" 我想你必须删除“cvReleaseCapture(&cv_cap);” sentence.
句子。 I tried it.
我尝试过这个。 It can be work.
它可以工作。 Somehow, when you hit the ESC button, the capture is being released.
不知何故,当您按下ESC按钮时,捕获正在被释放。 It's worth to try.
值得一试。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.