高斯模糊能够将图像的高频成分滤掉,使图像显得平滑。其原理是将原始图像的矩阵同高斯函数做卷积。
与之对应的是锐化,将图像的低频成分滤掉,留下高频成分。后期详细原理再补充。
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/core/core.hpp>
using namespace cv;
int main()
{
VideoCapture cap(0);
if (!cap.isOpened())
{
return -1;
}
Mat frame;
Mat edges;
bool stop = false;
while (!stop)
{
cap >> frame;
cvtColor(frame, edges, CV_BGR2GRAY);
GaussianBlur(edges, edges, Size(31, 31), 25, 25);
imshow("gaosi视频", edges);
Canny(edges, edges, 0, 30, 3);
imshow("当前视频", edges);
if (waitKey(30) >= 0)
stop = true;
}
return 0;
}