/** exit and close manager */ public void exit() { CAPTURE_MANAGER.CloseStreams(); SENSE_MANAGER.Close(); SENSE_MANAGER = null; SESSION.close(); SESSION = null; }
/** * Create a "Socket" for realsense camera * * @throws Exception when fails */ public Socket() throws Input3DException { if (SESSION == null) { createSession(); } if (SESSION == null) { throw new Input3DException(Input3DExceptionType.INSTALL, "RealSense: no session created"); } if (SENSE_MANAGER != null) { throw new Input3DException(Input3DExceptionType.ALREADY_USED, "RealSense: already in use"); } SENSE_MANAGER = SESSION.CreateSenseManager(); if (SENSE_MANAGER == null) { throw new Input3DException( Input3DExceptionType.RUN, "RealSense: Failed to create a SenseManager instance"); } CAPTURE_MANAGER = SENSE_MANAGER.QueryCaptureManager(); CAPTURE_MANAGER.FilterByDeviceInfo("RealSense", null, 0); sts = SENSE_MANAGER.EnableHand(null); if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR) < 0) { throw new Input3DException( Input3DExceptionType.RUN, "RealSense: Failed to enable HandAnalysis"); } dataSampler = new DataAverage(SAMPLES); sts = SENSE_MANAGER.Init(); if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR) >= 0) { PXCMHandModule handModule = SENSE_MANAGER.QueryHand(); PXCMHandConfiguration handConfig = handModule.CreateActiveConfiguration(); handConfig.EnableAllAlerts(); AlertHandler alertHandler = new AlertHandler() { @Override public void OnFiredAlert(intel.rssdk.PXCMHandData.AlertData data) { setAlert(data.handId, data.label); } }; handConfig.SubscribeAlert(alertHandler); handConfig.ApplyChanges(); handConfig.Update(); handData = handModule.CreateOutput(); hand = new PXCMHandData.IHand(); handOut = OutOfField.YES; connected = true; } if (!connected) { throw new Input3DException(Input3DExceptionType.RUN, "RealSense: not connected"); } Log.debug("RealSense: connected"); }