13 #include "../include/librealsense2/hpp/rs_frame.hpp" 14 #include "../include/librealsense2/hpp/rs_processing.hpp" 29 void dxf_smooth(
void *frame_data,
float alpha,
float delta,
int iterations)
33 for (
int i = 0; i < iterations; i++)
35 recursive_filter_horizontal<T>(frame_data, alpha, delta);
36 recursive_filter_vertical<T>(frame_data, alpha, delta);
49 const float round = fp ? 0.f : 0.5f;
51 const T valid_threshold = fp ?
static_cast<T
>(std::numeric_limits<T>::epsilon()) : static_cast<T>(1);
52 const T delta_z =
static_cast<T
>(deltaZ);
54 auto image =
reinterpret_cast<T*
>(image_data);
57 for (v = 0; v < _height; v++)
60 T *im = image + v * _width;
64 for (u = 1; u < _width-1; u++)
68 if (val0 >= valid_threshold)
70 if (val1 >= valid_threshold)
73 T diff =
static_cast<T
>(fabs(val1 - val0));
75 if (diff >= valid_threshold && diff <= delta_z)
77 float filtered = val1 * alpha + val0 * (1.0f - alpha);
78 val1 =
static_cast<T
>(filtered + round);
84 if (_holes_filling_radius)
86 if (++cur_fill <_holes_filling_radius)
97 im = image + (v + 1) * _width - 2;
101 for (u = _width - 1; u > 0; u--)
105 if (val1 >= valid_threshold)
107 if (val0 > valid_threshold)
110 T diff =
static_cast<T
>(fabs(val1 - val0));
114 float filtered = val0 * alpha + val1 * (1.0f - alpha);
115 val0 =
static_cast<T
>(filtered + round);
121 if (_holes_filling_radius)
123 if (++cur_fill <_holes_filling_radius)
135 template <
typename T>
144 const float round = fp ? 0.f : 0.5f;
146 const T valid_threshold = fp ?
static_cast<T
>(std::numeric_limits<T>::epsilon()) : static_cast<T>(1);
147 const T delta_z =
static_cast<T
>(deltaZ);
149 auto image =
reinterpret_cast<T*
>(image_data);
158 for (v = 1; v < _height; v++)
160 for (u = 0; u < _width; u++)
165 if ((im0 >= valid_threshold) && (imw >= valid_threshold))
167 T diff =
static_cast<T
>(fabs(im0 - imw));
170 float filtered = imw * alpha + im0 * (1.f - alpha);
171 im[_width] =
static_cast<T
>(filtered + round);
179 im = image + (_height - 2) * _width;
180 for (v = 1; v < _height; v++, im -= (_width * 2))
182 for (u = 0; u < _width; u++)
187 if ((im0 >=valid_threshold) && (imw >= valid_threshold))
189 T diff =
static_cast<T
>(fabs(im0 - imw));
192 float filtered = im0 * alpha + imw * (1.f - alpha);
193 im[0] =
static_cast<T
>(filtered + round);
203 float _spatial_alpha_param;
204 uint8_t _spatial_delta_param;
205 uint8_t _spatial_iterations;
206 float _spatial_radius;
207 size_t _width, _height, _stride;
210 size_t _current_frm_size_pixels;
213 bool _stereoscopic_depth;
214 float _focal_lenght_mm;
215 float _stereo_baseline_mm;
216 uint8_t _holes_filling_mode;
217 uint8_t _holes_filling_radius;
Definition: rs_frame.hpp:21
Definition: rs_frame.hpp:202
void recursive_filter_horizontal(void *image_data, float alpha, float deltaZ)
Definition: spatial-filter.h:41
rs2::frame prepare_target_frame(const rs2::frame &f, const rs2::frame_source &source)
Definition: synthetic-stream.h:41
Definition: rs_processing.hpp:13
void dxf_smooth(void *frame_data, float alpha, float delta, int iterations)
Definition: spatial-filter.h:29
void update_configuration(const rs2::frame &f)
Definition: spatial-filter.h:18
rs2_extension
Specifies advanced interfaces (capabilities) objects may implement.
Definition: rs_types.h:93
void recursive_filter_vertical(void *image_data, float alpha, float deltaZ)
Definition: spatial-filter.h:136