Fawkes API
Fawkes Development Version
|
00001 00002 /*************************************************************************** 00003 * gauss.cpp - Implementation of a Gauss filter 00004 * 00005 * Created: Thu May 12 09:33:55 2005 00006 * Copyright 2005-2012 Tim Niemueller [www.niemueller.de] 00007 ****************************************************************************/ 00008 00009 /* This program is free software; you can redistribute it and/or modify 00010 * it under the terms of the GNU General Public License as published by 00011 * the Free Software Foundation; either version 2 of the License, or 00012 * (at your option) any later version. A runtime exception applies to 00013 * this software (see LICENSE.GPL_WRE file mentioned below for details). 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU Library General Public License for more details. 00019 * 00020 * Read the full text in the LICENSE.GPL_WRE file in the doc directory. 00021 */ 00022 00023 #include <fvfilters/gauss.h> 00024 00025 #include <cstddef> 00026 00027 #ifdef HAVE_IPP 00028 # include <ippi.h> 00029 #elif defined(HAVE_OPENCV) 00030 # include <cv.h> 00031 #else 00032 # error "Neither IPP nor OpenCV available" 00033 #endif 00034 00035 namespace firevision { 00036 #if 0 /* just to make Emacs auto-indent happy */ 00037 } 00038 #endif 00039 00040 /** @class FilterGauss <fvfilters/gauss.h> 00041 * Gaussian filter. 00042 * Applies Gaussian linear filter to image (blur effect). 00043 */ 00044 00045 /** Constructor. */ 00046 FilterGauss::FilterGauss() 00047 : Filter("FilterGauss") 00048 { 00049 } 00050 00051 00052 void 00053 FilterGauss::apply() 00054 { 00055 #if defined(HAVE_IPP) 00056 IppiSize size; 00057 size.width = src_roi[0]->width; 00058 size.height = src_roi[0]->height; 00059 00060 /* IppStatus status = */ ippiFilterGauss_8u_C1R( src[0] + (src_roi[0]->start.y * src_roi[0]->line_step) + (src_roi[0]->start.x * src_roi[0]->pixel_step), src_roi[0]->line_step, 00061 dst + (dst_roi->start.y * dst_roi->line_step) + (dst_roi->start.x * dst_roi->pixel_step), dst_roi->line_step, 00062 size, 00063 ippMskSize5x5 ); 00064 00065 /* 00066 cout << "FilterGauss: ippiFilterGauss exit code: " << flush; 00067 switch (status) { 00068 case ippStsNoErr: 00069 cout << "ippStsNoErr"; 00070 break; 00071 case ippStsNullPtrErr: 00072 cout << "ippStsNullPtrErr"; 00073 break; 00074 case ippStsSizeErr: 00075 cout << "ippStsSizeErr"; 00076 break; 00077 case ippStsStepErr: 00078 cout << "ippStsStepErr"; 00079 break; 00080 case ippStsMaskSizeErr: 00081 cout << "ippStsMaskSizeErr"; 00082 break; 00083 default: 00084 cout << "Unknown status"; 00085 } 00086 cout << endl; 00087 */ 00088 00089 #elif defined(HAVE_OPENCV) 00090 cv::Mat srcm(src_roi[0]->height, src_roi[0]->width, CV_8UC1, 00091 src[0] + 00092 (src_roi[0]->start.y * src_roi[0]->line_step) + 00093 (src_roi[0]->start.x * src_roi[0]->pixel_step), 00094 src_roi[0]->line_step); 00095 00096 if (dst == NULL) { dst = src[0]; dst_roi = src_roi[0]; } 00097 00098 cv::Mat dstm(dst_roi->height, dst_roi->width, CV_8UC1, 00099 dst + 00100 (dst_roi->start.y * dst_roi->line_step) + 00101 (dst_roi->start.x * dst_roi->pixel_step), 00102 dst_roi->line_step); 00103 00104 cv::GaussianBlur(srcm, dstm, /* ksize */ cv::Size(5, 5), /* sigma */ 1.0); 00105 00106 #endif 00107 00108 } 00109 00110 } // end namespace firevision