先提起学习者的兴趣:
#include<opencv2/opencv.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<iostream>
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;
}