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

SKU B5B #8365

Merged
merged 20 commits into from
Mar 7, 2021
Merged

SKU B5B #8365

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
2 changes: 2 additions & 0 deletions common/metadata-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,8 @@ namespace rs2
{
// L500 has 3 media-pins
if (equal(pid, "0b0d") || equal(pid, "0b3d") || equal(pid, "0b64")) return 3;
// D405 has 3 media-pins
else if (equal(pid, "0b5b")) return 3;
else return 2; // D400 has two
}
return 1; // RGB has one
Expand Down
77 changes: 68 additions & 9 deletions common/model-views.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1091,6 +1091,22 @@ 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<hdr_merge>())
{
// processing block will be skipped if the requested option is not supported
Expand Down Expand Up @@ -1123,7 +1139,21 @@ 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);
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, SHORT_RANGE_MIN_DISTANCE);
depth_colorizer->set_option(RS2_OPTION_MAX_DISTANCE, SHORT_RANGE_MAX_DISTANCE);
}
}

ss.str("");
ss << "##" << dev.get_info(RS2_CAMERA_INFO_NAME)
Expand Down Expand Up @@ -1151,7 +1181,7 @@ namespace rs2
{
auto sensor_profiles = s->get_stream_profiles();
reverse(begin(sensor_profiles), end(sensor_profiles));
rs2_format def_format{ RS2_FORMAT_ANY };
std::map<int, rs2_format> def_format{ {0, RS2_FORMAT_ANY} };
auto default_resolution = std::make_pair(1280, 720);
auto default_fps = 30;
for (auto&& profile : sensor_profiles)
Expand Down Expand Up @@ -1185,7 +1215,7 @@ namespace rs2
if (profile.is_default())
{
stream_enabled[profile.unique_id()] = true;
def_format = profile.format();
def_format[profile.unique_id()] = profile.format();
}

profiles.push_back(profile);
Expand Down Expand Up @@ -1227,10 +1257,9 @@ namespace rs2

for (auto format_array : format_values)
{
if (get_default_selection_index(format_array.second, def_format, &selection_index))
if (get_default_selection_index(format_array.second, def_format[format_array.first], &selection_index))
{
ui.selected_format_id[format_array.first] = selection_index;
break;
}
}

Expand Down Expand Up @@ -3786,10 +3815,10 @@ namespace rs2
for (auto&& sub : dev.query_sensors())
{
auto s = std::make_shared<sensor>(sub);
std::string friendly_name = s->get_info(RS2_CAMERA_INFO_NAME);
auto objects = std::make_shared< atomic_objects_in_frame >();
if (friendly_name.find("RGB") != std::string::npos) objects = _detected_objects;

// checking if the sensor is color_sensor or is D405 (with integrated RGB in depth sensor)
if (s->is<color_sensor>() || !strcmp(dev.get_info(RS2_CAMERA_INFO_PRODUCT_ID), "0B5B"))
objects = _detected_objects;
auto model = std::make_shared<subdevice_model>(dev, std::make_shared<sensor>(sub), objects, error_message, viewer, new_device_connected);
subdevices.push_back(model);
}
Expand Down Expand Up @@ -6472,7 +6501,37 @@ namespace rs2
label = to_string() << "Controls ##" << sub->s->get_info(RS2_CAMERA_INFO_NAME) << "," << id;
if (ImGui::TreeNode(label.c_str()))
{
for (auto&& i : sub->s->get_supported_options())
std::vector<rs2_option> supported_options = sub->s->get_supported_options();

// moving the color dedicated options to the end of the vector
std::vector<rs2_option> color_options = {
RS2_OPTION_BACKLIGHT_COMPENSATION,
RS2_OPTION_BRIGHTNESS,
RS2_OPTION_CONTRAST,
RS2_OPTION_GAMMA,
RS2_OPTION_HUE,
RS2_OPTION_SATURATION,
RS2_OPTION_SHARPNESS,
RS2_OPTION_ENABLE_AUTO_WHITE_BALANCE,
RS2_OPTION_WHITE_BALANCE
};

std::vector<rs2_option> so_ordered;

for (auto&& i : supported_options)
{
auto it = find(color_options.begin(), color_options.end(), i);
if (it == color_options.end())
so_ordered.push_back(i);
}

std::for_each(color_options.begin(), color_options.end(), [&](rs2_option opt) {
auto it = std::find(supported_options.begin(), supported_options.end(), opt);
if (it != supported_options.end())
so_ordered.push_back(opt);
});

for (auto&& i : so_ordered)
{
auto opt = static_cast<rs2_option>(i);
if (viewer.is_option_skipped(opt)) continue;
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 = 0.05f; // 5 cm
const float SHORT_RANGE_MAX_DISTANCE = 4.0f; // 4 meters
};

class viewer_model;
Expand Down
4 changes: 2 additions & 2 deletions common/viewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3194,11 +3194,11 @@ namespace rs2
ppf.frames_queue.emplace(p.unique_id(), rs2::frame_queue(5));
}

bool viewer_model::is_3d_texture_source(frame f)
bool viewer_model::is_3d_texture_source(frame f) const
{
auto profile = f.get_profile().as<video_stream_profile>();
auto index = profile.unique_id();
auto mapped_index = streams_origin[index];
auto mapped_index = streams_origin.at(index);

if (!is_rasterizeable(profile.format()))
return false;
Expand Down
2 changes: 1 addition & 1 deletion common/viewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ namespace rs2
frame get_3d_texture_source(frame f);

bool is_3d_depth_source(frame f);
bool is_3d_texture_source(frame f);
bool is_3d_texture_source(frame f) const;

std::shared_ptr<texture_buffer> upload_frame(frame&& f);

Expand Down
40 changes: 33 additions & 7 deletions src/archive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,32 @@ namespace librealsense
throw invalid_value_exception(to_string() << "metadata not available for "
<< get_string(get_stream()->get_stream_type()) << " stream");

auto it = metadata_parsers.get()->find(frame_metadata);
if (it == metadata_parsers.get()->end()) // Possible user error - md attribute is not supported by this frame type
auto parsers = metadata_parsers->equal_range(frame_metadata);
if (parsers.first == metadata_parsers->end()) // Possible user error - md attribute is not supported by this frame type
throw invalid_value_exception(to_string() << get_string(frame_metadata)
<< " attribute is not applicable for "
<< get_string(get_stream()->get_stream_type()) << " stream ");

// Proceed to parse and extract the required data attribute
return it->second->get(*this);
rs2_metadata_type result = -1;
bool value_retrieved = false;
std::string exc_str;
for (auto it = parsers.first; it != parsers.second; ++it)
{
try
{
result = it->second->get(*this);
value_retrieved = true;
break;
}
catch (invalid_value_exception& e)
{
exc_str = e.what();
}
}
if (!value_retrieved)
throw invalid_value_exception(exc_str);

return result;
}

bool frame::supports_frame_metadata(const rs2_frame_metadata_value& frame_metadata) const
Expand All @@ -235,11 +253,19 @@ namespace librealsense
if (!metadata_parsers)
return false; // No parsers are available or no metadata was attached

auto it = metadata_parsers.get()->find(frame_metadata);
if (it == metadata_parsers.get()->end()) // Possible user error - md attribute is not supported by this frame type
bool ret = false;
auto found = metadata_parsers->equal_range(frame_metadata);
if (found.first == metadata_parsers->end())
return false;

return it->second->supports(*this);
for (auto it = found.first; it != found.second; ++it)
if (it->second->supports(*this))
{
ret = true;
break;
}

return ret;
}

int frame::get_frame_data_size() const
Expand Down
4 changes: 3 additions & 1 deletion src/archive.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ namespace librealsense
class md_attribute_parser_base;
class frame;

typedef std::map<rs2_frame_metadata_value, std::shared_ptr<md_attribute_parser_base>> metadata_parser_map;
// multimap is necessary here in order to permit registration to some metadata value in multiple places in metadata
// as it is required for D405, in which exposure should be available from the same sensor both for depth and color frames
typedef std::multimap<rs2_frame_metadata_value, std::shared_ptr<md_attribute_parser_base>> metadata_parser_map;
remibettan marked this conversation as resolved.
Show resolved Hide resolved

/*
Each frame is attached with a static header
Expand Down
3 changes: 2 additions & 1 deletion src/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,8 @@ namespace librealsense
list.push_back(dev);
}

LOG_INFO( "Found " << list.size() << " RealSense devices (mask " << mask << ")" );
if (list.size())
LOG_INFO( "Found " << list.size() << " RealSense devices (mask 0x" << std::hex << mask << ")" );
return list;
}

Expand Down
Loading