View my account

Check if device is already used

Comments

3 comments

  • MartyG

    Hi Faviersebastien01  Using a try-catch is the usual way to check the busy status of a stream.  If you require an alternative, you could explore using the SDK's can_resolve instruction to see whether the requested pipeline profile can be provided.

    https://intelrealsense.github.io/librealsense/doxygen/classrs2_1_1config.html#a4ff9ae18bf1b3aaaaaf9bba524b04d2c

    A C++ example of the instruction's use in the SDK's code is highlighted in the link below.

    https://github.com/IntelRealSense/librealsense/blob/master/src/rs.cpp#L2049

    0
    Comment actions Permalink
  • Faviersebastien01

    Hi MartyG!

    Thank a lot for your reply and for your interesting lead 

    Using a try-catch is the usual way to check the busy status of a stream

    Indeed, try {} catch () {} takes too long before returning an error, sometimes, the program crashes instead of catch and my project can't wait more 8 sec for check my 4 d455 cameras.

    I've testing can_resolve(), but there a maybe a problem, i've launched Intel.RS.Viewer or another program for using/lock depth pipe, and when i execute my code, this function return always true.

    Do you have an idea ?

    Thank a lot!
    Regards

    ---

    NB
    Parcial source code:

    rs2::pipeline instance_pipeline;
    rs2::device selected_device;


    selected_device = dev;
    auto depth_sensor = selected_device.first<rs2::depth_sensor>();

    //Create a configuration for configuring the pipeline with a non default profile
    rs2::config cfg;

    //Add desired streams to configuration
    //cfg.enable_stream(RS2_STREAM_COLOR, Size_X, Size_Y, RS2_FORMAT_BGR8, 30);
    cfg.enable_stream(RS2_STREAM_DEPTH, Size_X, Size_Y, RS2_FORMAT_Z16, 30);

    if (cfg.can_resolve(instance_pipeline))
    MessageBox(NULL, "Avaiable", "", 0);
    else
    MessageBox(NULL, "Not avaiable ", "", 0);

    instance_pipeline.start(cfg);
    0
    Comment actions Permalink
  • MartyX Grover

    The link below highlights a more advanced use of can_resolve in the SDK code.  If can_resolve is detected to be true then a pipe start instruction is issued.  If the pipe start generates an error because it is already started then a catch handles the error, stops the pipeline and informs the user that the camera is not functional or busy. 

    https://github.com/IntelRealSense/librealsense/blob/master/tools/depth-quality/depth-quality-model.cpp#L81-L101

     

    Alternatively, if all of the D455 are attached to the same computer and you are using multicam ctx code then your original catch code may run faster if you adapt a C++ script in the link below for accessing all attached cameras simultaneously.

    https://github.com/IntelRealSense/librealsense/issues/2219#issuecomment-412899468

    This script checks the camera name to see whether it is a D415 model, so to make the script work you should change the name check to D455 or remove the checking mechanism.

    0
    Comment actions Permalink

Please sign in to leave a comment.