Go to the documentation of this file.00001 #include <face_contour_detector/filters/GaussianBlur.h>
00002 #include <opencv/cv.h>
00003
00004 namespace face_contour_detector {
00005 namespace filters {
00006
00007 GaussianBlur::GaussianBlur() {
00008 ResetParameters();
00009 }
00010
00011 std::vector<Parameter> GaussianBlur::GetParameters() {
00012 std::vector<Parameter> re;
00013 std::string name("blurwidth");
00014 re.push_back(Parameter(name, &m_blurWidth, 3, 51));
00015 name = std::string("blurheight");
00016 re.push_back(Parameter(name, &m_blurHeight, 3, 51));
00017 return re;
00018 }
00019
00020 void GaussianBlur::Apply(const cv::Mat& input, cv::Mat& result) {
00021 int width = m_blurWidth;
00022 int height = m_blurHeight;
00023 if (input.cols < width) {
00024 width = (input.cols/2) * 2 - 1;
00025 }
00026 if (input.rows < height) {
00027 height = (input.rows/2) * 2 - 1;
00028 }
00029 if (width%2 == 0) {
00030 width++;
00031 }
00032 if (height%2 == 0) {
00033 height++;
00034 }
00035 cv::GaussianBlur(input, result, cv::Size(width,height), 0, 0);
00036 }
00037
00038 void GaussianBlur::ResetParameters() {
00039 m_blurWidth = 11;
00040 m_blurHeight = 11;
00041 }
00042
00043 const std::string& GaussianBlur::GetFilterName() {
00044 return m_filterName;
00045 }
00046
00047
00048 std::string GaussianBlur::m_filterName = std::string("GaussianBlur");
00049
00050 }
00051 }