Find out whether a pipe to a device is already started
Dear Intel RealSense Community,
The following code snippet is from the RealSense API example "rs-multicam.cpp".
rs2::context ctx;
std::vector<rs2::pipeline> pipelines;
for (auto&& dev : ctx.query_devices())
{
rs2::pipeline pipe(ctx);
rs2::config cfg;
cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
pipe.start(cfg);
pipelines.emplace_back(pipe);
}
I noticed that when a pipe to a device is already started (e.g. in another application), trying to start a new pipe will result in an exception. So I wonder if there's a way to find out whether a pipe to a device is already started before starting a new one. The code snippet I'm looking for could look like that:
rs2::context ctx;
std::vector<rs2::pipeline> pipelines;
for (auto&& dev : ctx.query_devices())
{
if( !dev.PipeToDeviceIsAlreadyStarted() )
{
rs2::pipeline pipe(ctx);
rs2::config cfg;
cfg.enable_device(dev.get_info(RS2_CAMERA_INFO_SERIAL_NUMBER));
pipe.start(cfg);
pipelines.emplace_back(pipe);
}
}
Best regards,
Sylvain
-
Hi S Roy I hope that the information in the link below will be helpful to you.
-
Hi MartyG,
Thank you for the quick reply. I'm aware that I can use "try catch" to find out whether a pipe to a device is already started. But my problem is that I'm using the Intel RealSense API in an MFC application. It means that the only time I can start a pipe to a device is at initialization time. After that, any attempt to start a pipe will result in an exception even when no pipe to the device is already started. As a consequence, I cannot use "try catch". Therefore, I wondered if there was a flag that informs whether a device is already busy.
Best regards,
Sylvain -
The RealSense SDK Manager advised in August 2019 that there was no function in the API for checking if a camera was busy and that catch should try to be used, or some mechanism placed in your own application. I researched the subject but could not find anything that updates that advice since then.
https://github.com/IntelRealSense/librealsense/issues/4672#issuecomment-522915133
It is possible that a function within the rs2::config class, such as can_resolve(), could provide a means of checking whether a request to the pipeline can be completed successfully.
https://intelrealsense.github.io/librealsense/doxygen/classrs2_1_1config.html
Please sign in to leave a comment.
Comments
4 comments