วันพฤหัสบดีที่ 23 มีนาคม พ.ศ. 2560

C++ opencv Smooth Image

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>

#include <iostream>
#include <conio.h>

using namespace cv;
using namespace std;

/// Global Variables
int DELAY_CAPTION = 1500;
int DELAY_BLUR = 100;
int MAX_KERNEL_LENGTH = 31;

Mat frame;
Mat dst;

int main(int argc, char** argv)
{
VideoCapture cap(0);
while (1)
{
cap >> frame;
dst = frame.clone();
namedWindow("Original image", CV_WINDOW_AUTOSIZE);
imshow("Original image", frame);

blur(frame, dst, Size(25, 25), Point(-1, -1));

namedWindow("Homogeneous Blur", CV_WINDOW_AUTOSIZE);
imshow("Homogeneous Blur", dst);

/// Applying Gaussian Blur
GaussianBlur(frame, dst, Size(25, 25), 0, 0);

namedWindow("Gaussian Blur", CV_WINDOW_AUTOSIZE);
imshow("Gaussian Blur", dst);

/// Applying Median blur

medianBlur(frame, dst, 25);

namedWindow("Median Blur", CV_WINDOW_AUTOSIZE);
imshow("Median Blur", dst);

/// Applying Bilateral Filter

bilateralFilter(frame, dst, 25, 25 * 2, 25 / 2);

namedWindow("Bilateral Blur", CV_WINDOW_AUTOSIZE);
imshow("Bilateral Blur", dst);

if (waitKey(30) == 27)
break;
}
return 0;
}

ไม่มีความคิดเห็น:

แสดงความคิดเห็น