Opencv调用摄像头采集图像

首先需要提起学习者的兴趣:

#include
#include
#include
#include

using namespace std;
using namespace cv;

int main()
{
	VideoCapture capture(0);
	Mat frame, grayImage;

	while (waitKey(30) != 27)
	{
		capture >> frame;

		//canny边缘检测
		cvtColor(frame, grayImage, CV_BGR2GRAY);
		blur(grayImage, grayImage, Size(7, 7));
		Canny(grayImage, grayImage, 128, 255);

		imshow("【摄像头】", grayImage);
	}

	return 0;
}
运行结果不方便贴出来,敬请谅解!

你可能感兴趣的:(opencv学习之路)