[英]Not able to capture image Opencv
Not able to capture Image, works in other laptop, my webcam is not able to open.But it works in other laptop.The output is "Error:Capture is Null" 无法捕获图像,在其他笔记本电脑上工作,我的网络摄像头无法打开。但它可以在其他笔记本电脑上工作。输出为“错误:捕获是空的”
#include "cv.h"
#include "highgui.h"
#include <stdio.h>
// A Simple Camera Capture Framework
int main() {
CvCapture* capture = cvCaptureFromCAM( CV_CAP_ANY );
if ( !capture ) {
fprintf( stderr, "ERROR: capture is NULL \n" );
getchar();
return -1;
}
// Create a window in which the captured images will be presented
cvNamedWindow( "mywindow", CV_WINDOW_AUTOSIZE );
// Show the image captured from the camera in the window and repeat
while ( 1 ) {
// Get one frame
IplImage* frame = cvQueryFrame( capture );
if ( !frame ) {
fprintf( stderr, "ERROR: frame is null...\n" );
getchar();
break;
}
cvShowImage( "mywindow", frame );
// Do not release the frame!
//If ESC key pressed, Key=0x10001B under OpenCV 0.9.7(linux version),
//remove higher bits using AND operator
if ( (cvWaitKey(10) & 255) == 27 ) break;
}
// Release the capture device housekeeping
cvReleaseCapture( &capture );
cvDestroyWindow( "mywindow" );
return 0;
}
You may try different numbers in the place of CV_CAP_ANY. 您可以在CV_CAP_ANY的位置尝试不同的数字。
It is also possible that your OpenCV is not installed appropriately, then you should reinstall it with libv4l as it is suggested here . 您的OpenCV也可能没有正确安装,那么您应该按照此处的建议使用libv4l重新安装它。
There is a slight chance that your camera is not compatible with OpenCV. 您的相机很可能与OpenCV不兼容 。
尝试传递-1
而不是CV_CAP_ANY
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.