http://www.opencv.org.cn/opencvdoc/2.3.2/html/doc/tutorials/objdetect/cascade_classifier/cascade_classifier.html#cascade-classifier 一文中 的代码在我的VS2010中能通过编译,但是打开摄像头之后,一片灰色,然后就没然后了,或者出现下图,点击确定之后,停止运行程序。

OpenCV objdetect人脸识别例子校正

后来我分析可能是摄像头打开方式在我电脑上不好使,原来代码中有这么几句 :

CvCapture* capture;

capture = cvCaptureFromCAM( -1 );

frame = cvQueryFrame( capture ); //mat frame

这几句的意思是用CvCapture 类的capture对象打开摄像头,然后将捕获到到的画面赋给frame。

通过cout << frame << endl;这一句测试,发现值全是205,也就是画面没捕获成功。

 

找到问题所在之后,用VideoCapture cap(0); cap >> frame; 代替上面的以上的摄像头打开方式,和frame 数据赋值方式,然后就成功了。


相关文章:

  • 2021-09-20
  • 2021-12-06
  • 2021-05-15
  • 2021-10-06
  • 2021-12-25
  • 2021-12-22
  • 2021-09-14
猜你喜欢
  • 2021-11-30
  • 2021-12-10
  • 2021-06-26
相关资源
相似解决方案