换一个表达,,我之前也是这样,,换一个就好了;;;用
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/ml/ml.hpp"
using namespace std;
using namespace cv;
int main(int argc,char *argv[])
{
int cameraNumber=0;
if (argc>1)
cameraNumber =atoi(argv[1]);
VideoCapture camera;
camera.open (cameraNumber );
if (!camera .isOpened ())
{
cerr<<"ERROPR"<
}
while(true)
{
Mat cameraFrame;
camera >>cameraFrame ;
if (cameraFrame .empty ())
{
cerr<<"ERROR1"<
}
imshow("woqu",cameraFrame );
char key=cv::waitKey (1000);
if (key==27)
{
break;
}
}
}
看这个,,然后改例程
检查摄像头是否可用,电脑管理软件是否将摄像头拦截。