Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Pol_P_
Beginner
35 Views

C# using handler.onConnect to detect sensor disconnection

I am trying to use PXCMSenseManager.Handler to detect when the RealSense camera is being connected or disconnected.

I do it like so:

// create sense manager
senseManager = PXCMSenseManager.CreateInstance();

// specify streams
senseManager.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_DEPTH, 320, 240, 60);

// create handler
PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler();
handler.onConnect += connectionChanged;

// init sensor
pxcmStatus = senseManager.Init(handler);

if (status != pxcmStatus.PXCM_STATUS_NO_ERROR) {
    // some error
}

and then the connectionChanged function looks like this:

private pxcmStatus connectionChanged(PXCMCapture.Device device, bool connected) {
    if (connected) {
        // do stuff
    } else {
        // stop doing stuff
    }

    return pxcmStatus.PXCM_STATUS_NO_ERROR;
}

this code lets me know correctly when the sensor is being connected but it does not call connectionChanged when the sensor is disconnected mid streaming.

What should I change to make it work?

Thanks,

0 Kudos
0 Replies
Reply