Items with no label
3335 Discussions

how to set advanced settings for rs400 in cpp

JSchl4
Beginner
2,201 Views

I want to set advanced settings on my D415 in c++.

How do I do that exactly?

I tried to do something like, but of course it doesn't work:

void enable_device(rs2::device dev, rs2::context ctx)

{

std::lock_guard lock(_mutex);

std::string serial_number(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));

if (_devices.find(serial_number) != _devices.end())

{

return; //already in

}

// Ignoring platform cameras (webcams, etc..)

if (platform_camera_name == dev.get_info(RS2_CAMERA_INFO_NAME))

{

return;

}

// Create a pipeline from the given device

rs2::pipeline p;

rs2::config c;

c.enable_stream(RS2_STREAM_DEPTH, depthWidth, depthHeight, RS2_FORMAT_Z16, depthFps);

c.enable_stream(RS2_STREAM_COLOR, -1, colorWidth, colorHeight, RS2_FORMAT_RGB8, colorFps);

c.enable_device(serial_number);

// Start the pipeline with the configuration

rs2::pipeline_profile profile = p.start(c);

auto depth_sensor = profile.get_device().first();

// general settings

depth_sensor.set_option(RS2_OPTION_EXPOSURE, 62520);

depth_sensor.set_option(RS2_OPTION_LASER_POWER, 360);

// advanced

auto advanced = rs400::advanced_mode(dev);

while (!advanced.is_enabled()) {

advanced.toggle_advanced_mode(true);

std::cout << "toggled advanced mode for " << serial_number << ", have to sleep" << std::endl;

usleep(5000); // the device will reconnect, so we have to wait a bit and then init the device again

auto devices = ctx.query_devices();

for (auto device : devices) {

if (device.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER) == serial_number) {

dev = device;

advanced = rs400::advanced_mode(dev);

}

}

}

advanced.load_json(advancedOptions); // advanced options are exported from realsense-viewer

}

what am I missing?

0 Kudos
2 Replies
idata
Employee
714 Views

Hello jrkb,

 

 

To enable the Advance mode on your D415 camera please follow the instructions on the following link:

 

 

https://github.com/IntelRealSense/librealsense/releases

 

 

Best Regards,

 

Juan N.
0 Kudos
JSchl4
Beginner
714 Views

Hello Juan,

thanks for your answer.

I tried to find more information on the github wiki, but I couldn't find any, so my hope was to get more detailed support here.

In the meantime I figured out a way to do it. Apparently I was only missing to enable the camera again after reconnecting it.

After running that once, the whole `while (...) {..}` is never called again, and advanced mode directly accessible from start.

I guess this is intended behavior.

Somehow I can't set any settings individually with e.g. `STDepthControlGroup` ..

Loading a complete json does work though.

I still doubt that this is the best way to do it, and indeed I found an interesting link here:

https://github.com/IntelRealSense/librealsense/blob/02aeec770d23b3f8a364f1800e3c5faaaa7d0482/doc/rs400_advanced_mode.md librealsense/rs400_advanced_mode.md at 02aeec770d23b3f8a364f1800e3c5faaaa7d0482 · IntelRealSense/librealsense · GitHub

I'll get more into it, and hope that I don't brick the cameras on the way...

0 Kudos
Reply