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
48
FilterGauss::apply
()
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
,
59
dst
+ (
dst_roi
->
start
.
y
*
dst_roi
->
line_step
) + (
dst_roi
->
start
.
x
*
dst_roi
->
pixel_step
),
60
dst_roi
->
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,
104
dst
+ (
dst_roi
->
start
.
y
*
dst_roi
->
line_step
)
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
firevision::FilterGauss::apply
virtual void apply()
Apply the filter.
Definition:
gauss.cpp:48
firevision::FilterGauss::FilterGauss
FilterGauss()
Constructor.
Definition:
gauss.cpp:43
firevision::Filter
Filter interface.
Definition:
filter.h:33
firevision::Filter::src_roi
ROI ** src_roi
Source ROIs, dynamically allocated by Filter ctor.
Definition:
filter.h:66
firevision::Filter::src
unsigned char ** src
Source buffers, dynamically allocated by Filter ctor.
Definition:
filter.h:61
firevision::Filter::dst
unsigned char * dst
Destination buffer.
Definition:
filter.h:63
firevision::Filter::dst_roi
ROI * dst_roi
Destination ROI.
Definition:
filter.h:68
firevision::ROI::height
unsigned int height
ROI height.
Definition:
roi.h:119
firevision::ROI::start
fawkes::upoint_t start
ROI start.
Definition:
roi.h:115
firevision::ROI::line_step
unsigned int line_step
line step
Definition:
roi.h:125
firevision::ROI::width
unsigned int width
ROI width.
Definition:
roi.h:117
firevision::ROI::pixel_step
unsigned int pixel_step
pixel step
Definition:
roi.h:127
fawkes::upoint_t::x
unsigned int x
x coordinate
Definition:
types.h:36
fawkes::upoint_t::y
unsigned int y
y coordinate
Definition:
types.h:37
src
libs
fvfilters
gauss.cpp
Generated by
1.9.1