4 #include "../include/librealsense2/hpp/rs_sensor.hpp"
5 #include "../include/librealsense2/hpp/rs_processing.hpp"
143 _min(0.
f), _max(6.
f), _equalize(true),
144 _target_stream_profile(), _histogram()
153 auto min_opt = std::make_shared< ptr_option< float > >( 0.f, 16.f, 0.1f, 0.f, &
_min,
"Min range in meters" );
155 auto max_opt = std::make_shared< ptr_option< float > >( 0.f, 16.f, 0.1f, 6.f, &
_max,
"Max range in meters" );
157 auto max_dist_opt = std::make_shared< max_distance_option >( max_opt, min_opt );
159 auto min_dist_opt = std::make_shared< min_distance_option >( min_opt, max_opt );
165 auto hist_opt = std::make_shared< ptr_option< bool > >(
false,
170 "Perform histogram equalization" );
172 auto weak_hist_opt = std::weak_ptr< ptr_option< bool > >( hist_opt );
174 max_dist_opt->add_observer( [weak_hist_opt](
float val ) {
175 auto strong_hist_opt = weak_hist_opt.lock();
176 if( strong_hist_opt )
177 strong_hist_opt->set(
false );
180 min_dist_opt->add_observer( [weak_hist_opt](
float val ) {
181 auto strong_hist_opt = weak_hist_opt.lock();
182 if( strong_hist_opt )
183 strong_hist_opt->set(
false );
189 color_map->set_description(2.
f,
"White to Black");
190 color_map->set_description(3.
f,
"Black to White");
199 auto preset_opt = std::make_shared<ptr_option<int>>(0, 3, 1, 0, &
_preset,
"Preset depth colorization");
200 preset_opt->set_description(0.
f,
"Dynamic");
201 preset_opt->set_description(1.
f,
"Fixed");
202 preset_opt->set_description(2.
f,
"Near");
203 preset_opt->set_description(3.
f,
"Far");
205 preset_opt->on_set([
this](
float val)
207 if (fabs(
val - 0.
f) < 1
e-6)
213 if (fabs(
val - 1.
f) < 1
e-6)
221 if (fabs(
val - 2.
f) < 1
e-6)
229 if (fabs(
val - 3.
f) < 1
e-6)
272 const auto w =
depth.get_width(),
h =
depth.get_height();
273 auto rgb_data =
reinterpret_cast<uint8_t*
>(
const_cast<void *
>(rgb.get_data()));
274 auto coloring_function = [&,
this](
float data) {
277 return (hist_data /
pixels);
282 auto depth_data =
reinterpret_cast<const float*
>(
depth.get_data());
284 make_rgb_data<float>(depth_data, rgb_data,
w,
h, coloring_function);
288 auto depth_data =
reinterpret_cast<const uint16_t*
>(
depth.get_data());
290 make_rgb_data<uint16_t>(depth_data, rgb_data,
w,
h, coloring_function);
297 const auto w =
depth.get_width(),
h =
depth.get_height();
298 auto rgb_data =
reinterpret_cast<uint8_t*
>(
const_cast<void *
>(rgb.get_data()));
302 auto depth_data =
reinterpret_cast<const float*
>(
depth.get_data());
306 if (__min < 1
e-6
f) { __min = 1
e-6
f; }
309 auto coloring_function = [&,
this](
float data) {
312 make_rgb_data<float>(depth_data, rgb_data,
w,
h, coloring_function);
316 auto depth_data =
reinterpret_cast<const uint16_t*
>(
depth.get_data());
319 auto coloring_function = [&,
this](
float data) {
320 if (
min >= max)
return 0.f;
323 make_rgb_data<uint16_t>(depth_data, rgb_data,
w,
h, coloring_function);