-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
what is the correct way of changing depth_scale? #2385
Comments
[Realsense Customer Engineering Team Comment] Check below code. It should be no problem to modify the depth scale. auto sensor = profile.get_device().firstrs2::depth_sensor(); |
Hi @RealSense-Customer-Engineering, I copy&paste and run your code above, but depth_scale was not changed, as output below: [Before]Depth Scale: 0.001000 Of course, the first line was changed to Also, what is the difference between "sensor.get_option(RS2_OPTION_DEPTH_UNITS)" and " get_depth_scale(profile.get_device())"? Thanks. |
[Realsense Customer Engineering Team Comment] "RS2_OPTION_DEPTH_UNITS" and "get_depth_scale" can be used to get the value. But, you can use "RS2_OPTION_DEPTH_UNITS" before stream starts. rs2::context ctx; // Create librealsense context for managing devices |
thanks. I understood it now. the key is to apply set_option() before starting the pipeline. issue closed. |
Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
Issue Description
What is the correct way of setting depth_scale? I have the following code running, but the output puzzles me. See below. I would expect depth_scale_2 be the updated value 0.0001, not the original one (0.001).
int main()
{
rs2::context ctx;
auto list = ctx.query_devices();
if (list.size() == 0) throw std::runtime_error("No device detected. Is it plugged in?");
rs2::pipeline pipe;
rs2::config cfg;
cfg.enable_stream(RS2_STREAM_COLOR, 1920, 1080, RS2_FORMAT_BGR8, 15);
cfg.enable_stream(RS2_STREAM_DEPTH, 1280, 720, RS2_FORMAT_Z16, 15);
rs2::pipeline_profile profile = pipe.start(cfg);
rs2::depth_sensor depth_sensor = profile.get_device().firstrs2::depth_sensor();
auto original_scale = depth_sensor.get_option(RS2_OPTION_DEPTH_UNITS);
std::cout << "original scale: " << original_scale << std::endl;
float depth_scale_1 = get_depth_scale(profile.get_device());
std::cout << "depth_scale_1 = " << depth_scale_1 << std::endl;
depth_sensor.set_option(RS2_OPTION_DEPTH_UNITS, 0.0001);
auto updated_scale = depth_sensor.get_option(RS2_OPTION_DEPTH_UNITS);
std::cout << "updated scale: " << updated_scale << std::endl;
float depth_scale_2 = get_depth_scale(profile.get_device());
std::cout << "depth_scale_2 = " << depth_scale << std::endl;
return EXIT_SUCCESS;
}
output:
original scale: 0.001
depth_scale_1 = 0.001
updated scale: 0.0001
depth_scale_2 = 0.001
The text was updated successfully, but these errors were encountered: