Skip to content

Commit

Permalink
fixed the int field accuracy for json loader
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomer Ashuach committed Aug 31, 2021
1 parent ecb31ec commit 326467a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
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_v<S>) //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
2 changes: 1 addition & 1 deletion src/ds5/advanced_mode/presets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@ namespace librealsense
p.color_sharpness.sharpness = 50;
p.color_auto_white_balance.auto_white_balance = 1;
p.color_white_balance.white_balance = 4600;
p.depth_exposure.exposure = 33000.f;
p.depth_exposure.exposure = 32000.f;
p.depth_auto_exposure.auto_exposure = 1;
p.depth_gain.gain = 16.f;
}
Expand Down

0 comments on commit 326467a

Please sign in to comment.