Fawkes API  Fawkes Development Version
gauss.cpp
1 
2 /***************************************************************************
3  * gauss.cpp - Implementation of a Gauss filter
4  *
5  * Created: Thu May 12 09:33:55 2005
6  * Copyright 2005-2012 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version. A runtime exception applies to
13  * this software (see LICENSE.GPL_WRE file mentioned below for details).
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU Library General Public License for more details.
19  *
20  * Read the full text in the LICENSE.GPL_WRE file in the doc directory.
21  */
22 
23 #include <fvfilters/gauss.h>
24 
25 #include <cstddef>
26 
27 #ifdef HAVE_IPP
28 # include <ippi.h>
29 #elif defined(HAVE_OPENCV)
30 # include <cv.h>
31 # include <opencv2/imgproc.hpp>
32 #else
33 # error "Neither IPP nor OpenCV available"
34 #endif
35 
36 namespace firevision {
37 #if 0 /* just to make Emacs auto-indent happy */
38 }
39 #endif
40 
41 /** @class FilterGauss <fvfilters/gauss.h>
42  * Gaussian filter.
43  * Applies Gaussian linear filter to image (blur effect).
44  */
45 
46 /** Constructor. */
48  : Filter("FilterGauss")
49 {
50 }
51 
52 
53 void
55 {
56 #if defined(HAVE_IPP)
57  IppiSize size;
58  size.width = src_roi[0]->width;
59  size.height = src_roi[0]->height;
60 
61  /* 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,
63  size,
64  ippMskSize5x5 );
65 
66  /*
67  cout << "FilterGauss: ippiFilterGauss exit code: " << flush;
68  switch (status) {
69  case ippStsNoErr:
70  cout << "ippStsNoErr";
71  break;
72  case ippStsNullPtrErr:
73  cout << "ippStsNullPtrErr";
74  break;
75  case ippStsSizeErr:
76  cout << "ippStsSizeErr";
77  break;
78  case ippStsStepErr:
79  cout << "ippStsStepErr";
80  break;
81  case ippStsMaskSizeErr:
82  cout << "ippStsMaskSizeErr";
83  break;
84  default:
85  cout << "Unknown status";
86  }
87  cout << endl;
88  */
89 
90 #elif defined(HAVE_OPENCV)
91  cv::Mat srcm(src_roi[0]->height, src_roi[0]->width, CV_8UC1,
92  src[0] +
93  (src_roi[0]->start.y * src_roi[0]->line_step) +
94  (src_roi[0]->start.x * src_roi[0]->pixel_step),
95  src_roi[0]->line_step);
96 
97  if (dst == NULL) { dst = src[0]; dst_roi = src_roi[0]; }
98 
99  cv::Mat dstm(dst_roi->height, dst_roi->width, CV_8UC1,
100  dst +
103  dst_roi->line_step);
104 
105  cv::GaussianBlur(srcm, dstm, /* ksize */ cv::Size(5, 5), /* sigma */ 1.0);
106 
107 #endif
108 
109 }
110 
111 } // end namespace firevision
FilterGauss()
Constructor.
Definition: gauss.cpp:47
fawkes::point_t start
ROI start.
Definition: roi.h:118
unsigned int x
x coordinate
Definition: types.h:35
unsigned int width
ROI width.
Definition: roi.h:120
virtual void apply()
Apply the filter.
Definition: gauss.cpp:54
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
Definition: filter.h:65
Filter interface.
Definition: filter.h:35
unsigned int y
y coordinate
Definition: types.h:36
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
Definition: filter.h:70
unsigned int height
ROI height.
Definition: roi.h:122
unsigned int line_step
line step
Definition: roi.h:128
unsigned char * dst
Destination buffer.
Definition: filter.h:67
unsigned int pixel_step
pixel step
Definition: roi.h:130
ROI * dst_roi
Destination ROI.
Definition: filter.h:72