利用opencv调用电脑摄像头,并实时显示。其实就是用cap.open(0)这一个语句就可以调用本机摄像头了。

#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;

int main()
{
	namedWindow("Example5",WINDOW_AUTOSIZE);

	VideoCapture cap;
	cap.open(0);
    //VideoCapture cap(0);这句话可以替代上面两个语句,效果是一致的。
	if (!cap.isOpened())
	{
		std::cerr << "Couldn't open capture." << std::endl;
		return -1;
	}

	Mat frame;
	while(1)
	{ 
		cap >> frame;
		if (frame.empty()) break;
		imshow("Example5",frame);
		if (waitKey(33) >= 0) break;
	}

	getchar();
	return 0;

}

如下图所示,,摄像头画质差,,人还。。嚇嚇,仅仅为了展示调用成功。
【opencv七】利用opencv调用电脑摄像头

本人csdn博客地址:https://blog.csdn.net/qiu931110/
本人微信公众号:yuanCruise
【opencv七】利用opencv调用电脑摄像头

相关文章:

  • 2021-11-19
  • 2021-10-18
  • 2021-08-30
  • 2021-12-09
  • 2022-12-23
  • 2022-12-23
  • 2021-12-15
  • 2021-08-24
猜你喜欢
  • 2022-02-25
  • 2021-12-23
  • 2021-09-23
  • 2022-12-23
  • 2021-04-09
  • 2021-08-15
  • 2022-12-23
相关资源
相似解决方案