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)
34 for (
int i = 0; i < iterations; i++)
43 recursive_filter_horizontal<T>(frame_data, alpha, delta);
44 recursive_filter_vertical<T>(frame_data, alpha, delta);
50 if (_holes_filling_mode && fp)
51 intertial_holes_fill<T>(
static_cast<T*
>(frame_data));
66 const float round = fp ? 0.f : 0.5f;
68 const T valid_threshold = fp ?
static_cast<T
>(std::numeric_limits<T>::epsilon()) : static_cast<T>(1);
69 const T delta_z =
static_cast<T
>(deltaZ);
71 auto image =
reinterpret_cast<T*
>(image_data);
74 for (v = 0; v < _height; v++)
77 T *im = image + v * _width;
81 for (u = 1; u < _width-1; u++)
85 if (fabs(val0) >= valid_threshold)
87 if (fabs(val1) >= valid_threshold)
90 T diff =
static_cast<T
>(fabs(val1 - val0));
92 if (diff >= valid_threshold && diff <= delta_z)
94 float filtered = val1 * alpha + val0 * (1.0f - alpha);
95 val1 =
static_cast<T
>(filtered + round);
101 if (_holes_filling_radius)
103 if (++cur_fill <_holes_filling_radius)
114 im = image + (v + 1) * _width - 2;
118 for (u = _width - 1; u > 0; u--)
122 if (val1 >= valid_threshold)
124 if (val0 > valid_threshold)
127 T diff =
static_cast<T
>(fabs(val1 - val0));
131 float filtered = val0 * alpha + val1 * (1.0f - alpha);
132 val0 =
static_cast<T
>(filtered + round);
138 if (_holes_filling_radius)
140 if (++cur_fill <_holes_filling_radius)
152 template <
typename T>
161 const float round = fp ? 0.f : 0.5f;
163 const T valid_threshold = fp ?
static_cast<T
>(std::numeric_limits<T>::epsilon()) : static_cast<T>(1);
164 const T delta_z =
static_cast<T
>(deltaZ);
166 auto image =
reinterpret_cast<T*
>(image_data);
175 for (v = 1; v < _height; v++)
177 for (u = 0; u < _width; u++)
184 T diff =
static_cast<T
>(fabs(im0 - imw));
187 float filtered = imw * alpha + im0 * (1.f - alpha);
188 im[_width] =
static_cast<T
>(filtered + round);
196 im = image + (_height - 2) * _width;
197 for (v = 1; v < _height; v++, im -= (_width * 2))
199 for (u = 0; u < _width; u++)
204 if ((fabs(im0) >= valid_threshold) && (fabs(imw) >= valid_threshold))
206 T diff =
static_cast<T
>(fabs(im0 - imw));
209 float filtered = im0 * alpha + imw * (1.f - alpha);
210 im[0] =
static_cast<T
>(filtered + round);
221 std::function<bool(T*)> fp_oper = [](T* ptr) {
return !*((
int *)ptr); };
222 std::function<bool(T*)> uint_oper = [](T* ptr) {
return !(*ptr); };
228 for (
int j = 0; j < _height; ++j)
234 for (
size_t i = 1; i < _width; ++i)
238 if (++cur_fill < _holes_filling_radius)
250 for (
size_t i = 1; i < _width; ++i)
254 if (++cur_fill < _holes_filling_radius)
267 float _spatial_alpha_param;
268 uint8_t _spatial_delta_param;
269 uint8_t _spatial_iterations;
270 float _spatial_edge_threshold;
271 size_t _width, _height, _stride;
274 size_t _current_frm_size_pixels;
277 bool _stereoscopic_depth;
278 float _focal_lenght_mm;
279 float _stereo_baseline_mm;
280 uint8_t _holes_filling_mode;
281 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:58
rs2::frame prepare_target_frame(const rs2::frame &f, const rs2::frame_source &source)
Definition: synthetic-stream.h:41
void intertial_holes_fill(T *image_data)
Definition: spatial-filter.h:219
Definition: rs_processing.hpp:13
void recursive_filter_horizontal_fp(void *image_data, float alpha, float deltaZ)
void dxf_smooth(void *frame_data, float alpha, float delta, int iterations)
Definition: spatial-filter.h:29
void recursive_filter_vertical_fp(void *image_data, float alpha, float deltaZ)
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:94
void recursive_filter_vertical(void *image_data, float alpha, float deltaZ)
Definition: spatial-filter.h:153