Astra::initialize() Returns success when the depth sensor is already in use by another application or process

I have two applications that use the orbbec sensor In a sprout G2 and I will describe the steps using the samples to check if this is by design.
The questions is: If I have already one app streaming from orbbec is there a way to find out by another application if the sensor is in use before trying to initialize and grab frames?
Here is the scenario I am trying:
1-Launch APP1 that streams both the depth and RGB. (The application is working just fine showing the RGB frames on the screen)
2-Launch APP2 (astra::init() Runs and returns success but I get only black frames from both sensors)
3-APP1 stream freezes

I am able to reproduce the same behavior using the samples from the astra sdk running SimpleStreamViewer-SFML.exe twice.
After digging a bit more I was able to check in the second proccess that the frames were invalid so the second app I can handle just fine telling the user that the camera is in use by another proccess.
But the first process running just got stuck and can’t get any new frame.

Thanks,
walter

Some APIs for other sensors, namely libfreenect2 and the legacy version of librealsense suffer from similar issues. To me it seems like most of these depth sensor projects don’t test their libraries with the concurrent use of multiple cameras. I never tried using the Astra SDK with more than 1 sensor, but I’m going to guess the problem is similar: Enumerating the USB devices in some initialization function in the Astra SDK opens all USB devices matching specific VID / PID, which causes other processes accessing those devices to have issues with the open handle to the USB device.

For the other projects we wrote a hack for both libfreenect2 and librealsense that used an environment variable listing currently open USB devices, and the enumeration / initialization functions in the SDK didn’t touch those devices which were listed in the environment variable. Annoying, but it works. I’m sure the Astras can be operated this way too, but it will take some code reading to get this implemented.

Here’s some discussion about a similar problem with the libfreenect2 project: OpenNI2 driver does not free devices before process exits · Issue #749 · OpenKinect/libfreenect2 · GitHub. Considering Astra SDK uses OpenNI2 under the hood, you’ll find that link more than useful, I believe.