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