Resize.cpp
Go to the documentation of this file.
00001 #include <face_contour_detector/filters/Resize.h>
00002 #include <string>
00003 #include <opencv/cv.h>
00004 
00005 namespace face_contour_detector {
00006         namespace filters {
00007 
00008                 Resize::Resize() {
00009                         ResetParameters();
00010                 }
00011 
00012                 std::vector<Parameter> Resize::GetParameters() {
00013                         std::vector<Parameter> re;
00014                         std::string name("maxWidth");
00015                         re.push_back(Parameter(name, &m_maxWidth));
00016                         name = std::string("maxHeight");
00017                         re.push_back(Parameter(name, &m_maxHeight));
00018                         return re;
00019                 }
00020 
00021                 void Resize::Apply(const cv::Mat& input, cv::Mat& result) {
00022                         if (m_maxWidth < 0) {
00023                                 m_maxWidth = 1;
00024                         }
00025                         if (m_maxHeight < 0) {
00026                                 m_maxHeight = 1;
00027                         }
00028                         double widthFactor = double(input.rows)/double(m_maxWidth);
00029                         double heightFactor = double(input.cols)/double(m_maxHeight);
00030                         if (widthFactor > heightFactor && widthFactor > 1.0) {
00031                                 cv::resize(input, result, cv::Size(0,0), 1.0/widthFactor, 1.0/widthFactor);
00032                         } else if (heightFactor > 1.0) {
00033                                 cv::resize(input, result, cv::Size(0,0), 1.0/heightFactor, 1.0/heightFactor);
00034                         } else {
00035                                 result = input;
00036                         }
00037                 }
00038 
00039                 void Resize::ResetParameters() {
00040                         m_maxWidth = 1024;
00041                         m_maxHeight = 768;
00042                 }
00043 
00044                 const std::string& Resize::GetFilterName() {
00045                         return m_filterName;
00046                 }
00047 
00048                 //static
00049                 std::string Resize::m_filterName = std::string("Resize");
00050         } //namespace filters
00051 
00052 } //namespace face_contour_detector
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends


face_contour_detector
Author(s): Fabian Wenzelmann and Julian Schmid
autogenerated on Wed Dec 26 2012 16:18:17