#include <opencv2/opencv.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
#if 0
//腐蚀
int main() {
Mat srcImage = imread("C:\\pics\\index.jpg");
imshow("srcpic", srcImage);
Mat element = getStructuringElement(MORPH_RECT, Size(15, 15));
Mat dstImage;
erode(srcImage, dstImage, element);
imshow("dstpic", dstImage);
waitKey(0);
return 0;
}
#endif
#if 0
int main() {
Mat srcImage = imread("C:\\pics\\index.jpg");
imshow("均值滤波[原图]", srcImage);
Mat dstImage;
blur(srcImage, dstImage, Size(7, 7));
imshow("均值滤波[效果图]", dstImage);
waitKey(0);
}
int main() {
Mat srcImage = imread("C:\\pics\\index.jpg");
imshow("均值滤波[原图]", srcImage);
Mat edge,grayImage;
cvtColor(srcImage, grayImage, CV_BGR2GRAY);
blur(grayImage, edge, Size(3, 3));
Canny(edge, edge, 3, 9, 3);
imshow("均值滤波[效果图1]", edge);
Canny(edge, edge, 5, 9, 3);
imshow("均值滤波[效果图2]", edge);
waitKey(0);
}
#endif
int main() {
VideoCapture capture(1);
Mat edges;
while (1) {
Mat frame;
capture >> frame;
cvtColor(frame, edges, COLOR_BGR2GRAY);
blur(edges, edges, Size(7, 7));
Canny(edges, edges, 0, 30, 3);
imshow("canny后的视频", edges);
if (waitKey(30) >= 0) break;
}
return 0;
}