- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi everyone,
I've been learning the SDK while building a project around the multicam SDK sample. I would now like to change the resolution and framerate that is given to a configuration in the rs-multicam.cpp sample. I'm not sure if I can set the framerate and resolution of a device before enabling it:
// Initial population of the device list
for (auto&& dev : ctx.query_devices()) // Query the list of connected RealSense devices
{
// Can I modify dev here?
connected_devices.enable_device(dev);
}
or if I would need to modify the enable_device() function:
void enable_device(rs2::device dev)
{
std::string serial_number(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
std::lock_guard lock(_mutex);
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_device(serial_number);
// Start the pipeline with the configuration
rs2::pipeline_profile profile = p.start(c);
// Hold it internally
_devices.emplace(serial_number, view_port{ {},{},{}, p, profile });
}
If I could set the resolution and framerate options to be the same across all cameras in a configuration, that would be helpful in my case. I'm hoping to be able to optimize these settings, while mostly retaining the device_container functions, but let me know if there's a better way to approach this.
Thank you,
jmagen
- Tags:
- Solutions
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can configure the stream at a script's start-up with the cfg_emable-stream instruction. An example script is linked to below.
https://github.com/IntelRealSense/librealsense/blob/master/doc/stepbystep/getting_started_with_openCV.md librealsense/getting_started_with_openCV.md at master · IntelRealSense/librealsense · GitHub
Taking a line from that script and breaking it down to explain it:
cfg.enable_stream(RS2_STREAM_COLOR, 640, 480, RS2_FORMAT_BGR8, 30);
*******
RS2_STREAM_COLOR
This refers to the type of stream that you want to set up. If you want to use a depth stream, change this command to RS"_STREAM_DEPTH. If you want an infrared stream, change it to RS"_STREAM_INFRARED
640, 480
The two numbers after the RS2_STREAM instruction refer to the resolution. So if you wanted to set it to 1080x720 for example, you would change 640,480 in the script to 1080,720
RS2_FORMAT_BGR8
In this section, you are setting the pixel format that you want to use in your stream. The link below has a script with a list of image formats on lines 54 to 74.
https://github.com/IntelRealSense/librealsense/blob/5e73f7bb906a3cbec8ae43e888f182cc56c18692/include/librealsense2/h/rs_sensor.h# L55 librealsense/rs_sensor.h at 5e73f7bb906a3cbec8ae43e888f182cc56c18692 · IntelRealSense/librealsense · GitHub
30
Finally, the number at the end of the line defines the frame rate that you want the stream to use. Change it to the value appropriate for the resolution and stream type that you are using.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, MartyG.
I have attempted to use this function in conjunction with the multicam sample. However, since my project relies on the multicam sample's device container functions, I'm wondering if/how an enabled stream could be treated like an rs2::device and added to the '_devices' map using _devices.emplace(). I would like to continue using sample functions such as render_textures(), poll_frames(), etc. But I would first need to add the enabled stream to '_devices' or drastically change the structure of the sample.
Is it possible to change the default stream given to a device before or after the _devices.emplace() function is called? I would like to know where the c.enable_device() function associates a device with a default stream, so that I could optimize that stream.
Thanks again,
jmagen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
That knowledge is outside of my programming experience, unfortunately. An Intel support team member should be able to follow up with you on it to try to find a solution. Good luck!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I've done this. You're going to want to look at the rs2::config class.
Generally speaking, I find the C++ RS2 API to be rather obfuscated, and too much of their 'realsense-viewer' app's functionality has trickled down into the API. I recommend looking at the C API first, then working your way back through the mess that is the C++ API.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks, @SMM77. Could you specify what your approach was? Were you enabling a stream (using the first overload of config::enable_stream) and somehow adding it to the _devices map? Or were you modifying the existing streams of already-enabled devices from within the sample's device_container::enable_device() function?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hello @jmagen,
Our engineering team says that inserting
c.enable_stream(….)
After
https://github.com/IntelRealSense/librealsense/blob/master/examples/multicam/rs-multicam.cpp# L48 https://github.com/IntelRealSense/librealsense/blob/master/examples/multicam/rs-multicam.cpp# L48.
should do the trick.
Regards,
Jesus
Intel Customer Support
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page