Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Viewer] Switch off histogram equalization when min/max distance is changed #9746

Merged
merged 4 commits into from
Sep 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions src/option.h
Original file line number Diff line number Diff line change
Expand Up @@ -672,29 +672,31 @@ namespace librealsense

/** \brief class provided a control
* that changes min distance value when changing max distance value */
class max_distance_option : public proxy_option
class max_distance_option : public proxy_option, public observable_option
{
public:
explicit max_distance_option(std::shared_ptr<option> max_option,
std::shared_ptr<option> min_option)
: proxy_option(max_option), _min_option(min_option)
{}

void set(float value) override
void set( float value ) override
{
auto strong = _min_option.lock();
if (!strong)
if( ! strong )
return;

auto min_value = strong->query();

if (min_value > value)
if( min_value > value )
{
auto min = strong->get_range().min;
strong->set(min);
strong->set( min );
}
_proxy->set(value);
_recording_function(*this);
_proxy->set( value );
_recording_function( *this );

notify( value );
}

private:
Expand All @@ -703,29 +705,31 @@ namespace librealsense

/** \brief class provided a control
* that changes max distance value when changing min distance value */
class min_distance_option : public proxy_option
class min_distance_option : public proxy_option, public observable_option
{
public:
explicit min_distance_option(std::shared_ptr<option> min_option,
std::shared_ptr<option> max_option)
: proxy_option(min_option), _max_option(max_option)
{}

void set(float value) override
void set( float value ) override
{
auto strong = _max_option.lock();
if (!strong)
if( ! strong )
return;

auto max_value = strong->query();

if (max_value < value)
if( max_value < value )
{
auto max = strong->get_range().max;
strong->set(max);
strong->set( max );
}
_proxy->set(value);
_recording_function(*this);
_proxy->set( value );
_recording_function( *this );

notify( value );
}

private:
Expand Down
40 changes: 29 additions & 11 deletions src/proc/colorizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,19 +150,38 @@ namespace librealsense

_maps = { &jet, &classic, &grayscale, &inv_grayscale, &biomes, &cold, &warm, &quantized, &pattern, &hue };

auto min_opt = std::make_shared<ptr_option<float>>(0.f, 16.f, 0.1f, 0.f, &_min, "Min range in meters");
auto min_opt = std::make_shared< ptr_option< float > >( 0.f, 16.f, 0.1f, 0.f, &_min, "Min range in meters" );

auto max_opt = std::make_shared<ptr_option<float>>(0.f, 16.f, 0.1f, 6.f, &_max, "Max range in meters");
auto max_opt = std::make_shared< ptr_option< float > >( 0.f, 16.f, 0.1f, 6.f, &_max, "Max range in meters" );

register_option(RS2_OPTION_MAX_DISTANCE,
std::make_shared<max_distance_option>(
max_opt,
min_opt));
auto max_dist_opt = std::make_shared< max_distance_option >( max_opt, min_opt );

register_option(RS2_OPTION_MIN_DISTANCE,
std::make_shared<min_distance_option>(
min_opt,
max_opt));
auto min_dist_opt = std::make_shared< min_distance_option >( min_opt, max_opt );

register_option( RS2_OPTION_MAX_DISTANCE, max_dist_opt );

register_option( RS2_OPTION_MIN_DISTANCE, min_dist_opt );

auto hist_opt = std::make_shared< ptr_option< bool > >( false,
true,
true,
true,
&_equalize,
"Perform histogram equalization" );

auto weak_hist_opt = std::weak_ptr< ptr_option< bool > >( hist_opt );

max_dist_opt->add_observer( [weak_hist_opt]( float val ) {
auto strong_hist_opt = weak_hist_opt.lock();
if( strong_hist_opt )
strong_hist_opt->set( false );
} );

min_dist_opt->add_observer( [weak_hist_opt]( float val ) {
auto strong_hist_opt = weak_hist_opt.lock();
if( strong_hist_opt )
strong_hist_opt->set( false );
} );

auto color_map = std::make_shared<ptr_option<int>>(0, (int)_maps.size() - 1, 1, 0, &_map_index, "Color map");
color_map->set_description(0.f, "Jet");
Expand Down Expand Up @@ -218,7 +237,6 @@ namespace librealsense
});
register_option(RS2_OPTION_VISUAL_PRESET, preset_opt);

auto hist_opt = std::make_shared<ptr_option<bool>>(false, true, true, true, &_equalize, "Perform histogram equalization");
register_option(RS2_OPTION_HISTOGRAM_EQUALIZATION_ENABLED, hist_opt);
}

Expand Down