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

Updating presets #9642

Merged
merged 13 commits into from
Sep 22, 2021
59 changes: 20 additions & 39 deletions src/ds5/advanced_mode/advanced_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ namespace librealsense
{
auto p = get_all();
res_type res;

// configuration is empty before first streaming - so set default res
if (configuration.empty())
res = low_resolution;
Expand All @@ -87,11 +86,26 @@ namespace librealsense
case ds::RS430_PID:
case ds::RS430I_PID:
case ds::RS435_RGB_PID:
case ds::RS435I_PID:
case ds::RS465_PID:
case ds::RS455_PID:
case ds::RS435I_PID:
default_430(p);
break;
case ds::RS455_PID:
default_450_mid_low_res(p);
switch (res)
{
case low_resolution:
case medium_resolution:
//applied defaultly
break;
case high_resolution:
default_450_high_res(p);
break;
default:
throw invalid_value_exception(to_string() << "apply_preset(...) failed! Given device doesn't support Default Preset (pid=0x" <<
std::hex << device_pid << ")");
break;
}
case ds::RS405U_PID:
default_405u(p);
break;
Expand All @@ -117,46 +131,13 @@ namespace librealsense
p.depth_table.depthUnits = 100; // 0.1mm
break;
case RS2_RS400_VISUAL_PRESET_HIGH_ACCURACY:
switch (res)
{
case low_resolution:
low_res_high_accuracy(p);
break;
case medium_resolution:
mid_res_high_accuracy(p);
break;
case high_resolution:
high_res_high_accuracy(p);
break;
}
high_accuracy(p);
break;
case RS2_RS400_VISUAL_PRESET_HIGH_DENSITY:
switch (res)
{
case low_resolution:
low_res_high_density(p);
break;
case medium_resolution:
mid_res_high_density(p);
break;
case high_resolution:
high_res_high_density(p);
break;
}
high_density(p);
break;
case RS2_RS400_VISUAL_PRESET_MEDIUM_DENSITY:
switch (res)
{
case low_resolution:
low_res_mid_density(p);
break;
case medium_resolution:
mid_res_mid_density(p);
break;
case high_resolution:
high_res_mid_density(p);
break;
}
mid_density(p);
break;
case RS2_RS400_VISUAL_PRESET_REMOVE_IR_PATTERN:
{
Expand Down
6 changes: 5 additions & 1 deletion src/ds5/advanced_mode/json_loader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@ namespace librealsense
void load(const std::string& str) override
{
float value = static_cast<float>(::atof(str.c_str()));
strct->vals[0].*field = static_cast<S>(scale * value);
if (std::is_integral<S>::value) //in order to convert float to int correctly we add 0.5 and then use the floor function
value = std::floor(scale * value + 0.5f);
else
value = scale * value;
strct->vals[0].*field = static_cast<S>(value);
strct->update = true;
}

Expand Down
Loading