Skip to content

Commit

Permalink
Threshold filter default distances modified
Browse files Browse the repository at this point in the history
  • Loading branch information
remibettan committed Mar 4, 2021
1 parent beb2af6 commit 125a3bb
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
54 changes: 38 additions & 16 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,10 @@ namespace rs2
yuy2rgb(std::make_shared<rs2::gl::yuy_decoder>()),
depth_decoder(std::make_shared<rs2::depth_huffman_decoder>()),
viewer(viewer),
detected_objects(device_detected_objects)
detected_objects(device_detected_objects),
SHORT_RANGE_MIN_DISTANCE(0.05f),
SHORT_RANGE_MAX_DISTANCE(1.5f)

{
supported_options = s->get_supported_options();
restore_processing_block("colorizer", depth_colorizer);
Expand Down Expand Up @@ -1091,6 +1094,39 @@ namespace rs2
model->enable(false);
}

if (shared_filter->is<threshold_filter>())
{
if (s->supports(RS2_CAMERA_INFO_PRODUCT_ID))
{
// using short range for D405
std::string device_pid = s->get_info(RS2_CAMERA_INFO_PRODUCT_ID);
if (device_pid == "0B5B")
{
std::string error_msg;
auto threshold_pb = shared_filter->as<threshold_filter>();
threshold_pb.set_option(RS2_OPTION_MIN_DISTANCE, SHORT_RANGE_MIN_DISTANCE);
threshold_pb.set_option(RS2_OPTION_MAX_DISTANCE, SHORT_RANGE_MAX_DISTANCE);
}
}
}

if (shared_filter->is<colorizer>())
{
if (s->supports(RS2_CAMERA_INFO_PRODUCT_ID))
{
// using short range for D405
std::string device_pid = s->get_info(RS2_CAMERA_INFO_PRODUCT_ID);
if (device_pid == "0B5B")
{
std::string error_msg;
auto colorizer_pb = shared_filter->as<colorizer>();
colorizer_pb.set_option(RS2_OPTION_MIN_DISTANCE, SHORT_RANGE_MIN_DISTANCE);
colorizer_pb.set_option(RS2_OPTION_MAX_DISTANCE, SHORT_RANGE_MAX_DISTANCE);
}
}
}


if (shared_filter->is<hdr_merge>())
{
// processing block will be skipped if the requested option is not supported
Expand Down Expand Up @@ -1123,21 +1159,7 @@ namespace rs2
auto colorizer = std::make_shared<processing_block_model>(
this, "Depth Visualization", depth_colorizer,
[=](rs2::frame f) { return depth_colorizer->colorize(f); }, error_message);
const_effects.push_back(colorizer);

if (s->supports(RS2_CAMERA_INFO_PRODUCT_ID))
{
std::string device_pid = s->get_info(RS2_CAMERA_INFO_PRODUCT_ID);

// using short range for D405
if (device_pid == "0B5B")
{
std::string error_msg;
depth_colorizer->set_option(RS2_OPTION_MIN_DISTANCE, 0.05f);
depth_colorizer->set_option(RS2_OPTION_MAX_DISTANCE, 1.5f);
}
}

const_effects.push_back(colorizer);

ss.str("");
ss << "##" << dev.get_info(RS2_CAMERA_INFO_NAME)
Expand Down
4 changes: 4 additions & 0 deletions common/model-views.h
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,10 @@ namespace rs2
std::vector<std::shared_ptr<processing_block_model>> post_processing;
bool post_processing_enabled = true;
std::vector<std::shared_ptr<processing_block_model>> const_effects;

private:
const float SHORT_RANGE_MIN_DISTANCE;
const float SHORT_RANGE_MAX_DISTANCE;
};

class viewer_model;
Expand Down

0 comments on commit 125a3bb

Please sign in to comment.