笔记本有内置摄像头。Windows7驱动已经安装成功,利用QQ测试摄像头正常。但是利用OpenCV简单的摄像头操作后,就会出现ERROT: SampleCB() - buffer sizes do not match的问题。下面是代码:
#include<iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp> using namespace cv;#include "highgui.h"int main()
{CvCapture* pCap = cvCreateCameraCapture(1);IplImage *frame = NULL;if (cvCreateCameraCapture == NULL){return(0);}cvNamedWindow("Camera", CV_WINDOW_FULLSCREEN);while ((frame = cvQueryFrame(pCap)) != 0 && cvWaitKey(20) != 27){frame = cvQueryFrame(pCap);cvShowImage("Camera", frame);}cvReleaseCapture(&pCap);cvDestroyWindow("Camera");return (0);
}
问题主要是摄像头摄取的图片大小超过了OpenCV最大限度,所以造成了缓冲区大小不匹配,http://www.me.sie.dendai.ac.jp/labWiki/wiki.cgi?page=*%C3%ED%B0%D5%BD%F1%A4%AD-USB%A5%AB%A5%E1%A5%E9%A4%CE%BB%C8%CD%D1 这个网站上有明确的说明。