View my account

D435 librealsense2 separated queues for each stream

Comments

5 comments

  • MartyG

    I have researched your question very carefully and found no clear pre-made solution, which led me to return to the original code sample in the section that you linked to:

    rs2::frame_queue depth_q;

    dev.start(RS2_STREAM_DEPTH, depth_q);

    rs2::frame_queue ir_q;

    dev.start(RS2_STREAM_INFRARED, ir_q);

    It looks as though what it is doing is defining custom frame queues with your own choice of variable name.  If that is the case then I would speculate that it might be possible to define a custom queue for color as well in this way:

     

    rs2::frame_queue depth_q;

    dev.start(RS2_STREAM_DEPTH, depth_q);

    rs2::frame_queue ir_q;

    dev.start(RS2_STREAM_INFRARED, ir_q);

    rs2::frame_queue color_q;

    dev.start(RS2_STREAM_COLOR, color_q);

    0
    Comment actions Permalink
  • Davidllevat

    Hi Marty,

    Thanks for your answers!

    To be a little more concise:

    1. I've managed to define different queues for the different modules, hence, a queue for "RGB Camera" and a different one for "Stereo Module"
    2. In the link I've posted before and in your answer:
    • what is the dev object? I guessed it's a rs2::device, but it does not have an start() method
    • I've tried to search this method: start(rs2_stream, callback) but I can't find it anywhere, any ideas on where can I find it's documentation?

    Summarizing, I can't find in the library this start method and I cannot define separate queues for the Infrared and Depth streams.

    Any help or pointers would be greatly appreciated!

    0
    Comment actions Permalink
  • MartyG

    It is a difficult subject to research.   The frame streaming documentation dates back to the time of the RealSense 400 Series' launch at the start of January 2018, so it is very old in terms of documentation.  

    I believe dev.start is a command for accessing the camera device (hence 'dev' for device, not developer / development).  dev.start is apparently used to configure a direct callback to the camera device for new frames so that it allows users to bypass the buffering and synchronization that was done by wait_for_frames.   Example:

     

     

    In regard to rs2_stream, callback I could not find any useful references on this to provide more information about it, unfortunately.

    0
    Comment actions Permalink
  • Davidllevat

    I've managed to finally do it. The function described in the librealsense documentation does not exist, but a workaround related with your answer is the following:

    ---------

    std::map<std::string, rs2::sensor> _sensors_module;  // map values can be "RGB Camera" and "Stereo Module"

    std::map<rs2_stream, rs2::frame_queue> _queue; // map values can be "RS2_STREAM_COLOR", "RS2_STREAM_INFRARED" and "RS2_STREAM_DEPTH"

    _sensors_module[module_name].start([&](rs2::frame f){
         rs2_stream stream = f.get_profile().stream_type();
         _queue[stream].enqueue(std::move(f));
    });

    ------------

    Thanks for your help!

    0
    Comment actions Permalink
  • MartyG

    Awesome news!   Thanks for sharing your workaround with the RealSense community   :)

    0
    Comment actions Permalink

Please sign in to leave a comment.