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 <opencv2/opencv.hpp>
31 #else
32 # error "Neither IPP nor OpenCV available"
33 #endif
34 
35 namespace firevision {
36 
37 /** @class FilterGauss <fvfilters/gauss.h>
38  * Gaussian filter.
39  * Applies Gaussian linear filter to image (blur effect).
40  */
41 
42 /** Constructor. */
43 FilterGauss::FilterGauss() : Filter("FilterGauss")
44 {
45 }
46 
47 void
49 {
50 #if defined(HAVE_IPP)
51  IppiSize size;
52  size.width = src_roi[0]->width;
53  size.height = src_roi[0]->height;
54 
55  /* IppStatus status = */ ippiFilterGauss_8u_C1R(
56  src[0] + (src_roi[0]->start.y * src_roi[0]->line_step)
57  + (src_roi[0]->start.x * src_roi[0]->pixel_step),
58  src_roi[0]->line_step,
61  size,
62  ippMskSize5x5);
63 
64  /*
65  cout << "FilterGauss: ippiFilterGauss exit code: " << flush;
66  switch (status) {
67  case ippStsNoErr:
68  cout << "ippStsNoErr";
69  break;
70  case ippStsNullPtrErr:
71  cout << "ippStsNullPtrErr";
72  break;
73  case ippStsSizeErr:
74  cout << "ippStsSizeErr";
75  break;
76  case ippStsStepErr:
77  cout << "ippStsStepErr";
78  break;
79  case ippStsMaskSizeErr:
80  cout << "ippStsMaskSizeErr";
81  break;
82  default:
83  cout << "Unknown status";
84  }
85  cout << endl;
86  */
87 
88 #elif defined(HAVE_OPENCV)
89  cv::Mat srcm(src_roi[0]->height,
90  src_roi[0]->width,
91  CV_8UC1,
92  src[0] + (src_roi[0]->start.y * src_roi[0]->line_step)
93  + (src_roi[0]->start.x * src_roi[0]->pixel_step),
94  src_roi[0]->line_step);
95 
96  if (dst == NULL) {
97  dst = src[0];
98  dst_roi = src_roi[0];
99  }
100 
101  cv::Mat dstm(dst_roi->height,
102  dst_roi->width,
103  CV_8UC1,
105  + (dst_roi->start.x * dst_roi->pixel_step),
106  dst_roi->line_step);
107 
108  cv::GaussianBlur(srcm, dstm, /* ksize */ cv::Size(5, 5), /* sigma */ 1.0);
109 
110 #endif
111 }
112 
113 } // end namespace firevision
virtual void apply()
Apply the filter.
Definition: gauss.cpp:48
FilterGauss()
Constructor.
Definition: gauss.cpp:43
Filter interface.
Definition: filter.h:33
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
Definition: filter.h:66
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
Definition: filter.h:61
unsigned char * dst
Destination buffer.
Definition: filter.h:63
ROI * dst_roi
Destination ROI.
Definition: filter.h:68
unsigned int height
ROI height.
Definition: roi.h:119
fawkes::upoint_t start
ROI start.
Definition: roi.h:115
unsigned int line_step
line step
Definition: roi.h:125
unsigned int width
ROI width.
Definition: roi.h:117
unsigned int pixel_step
pixel step
Definition: roi.h:127
unsigned int x
x coordinate
Definition: types.h:36
unsigned int y
y coordinate
Definition: types.h:37