private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { processingThread.Abort(); if (handData != null) { handData.Dispose(); } handConfig.Dispose(); senseManager.Dispose(); }
private void Uninitialize() { if (senseManager != null) { senseManager.Dispose(); senseManager = null; } if (projection != null) { projection.Dispose(); projection = null; } if (handData != null) { handData.Dispose(); handData = null; } if (handAnalyzer != null) { handAnalyzer.Dispose(); handAnalyzer = null; } }
/// <summary> 終了処理 </summary> private void Uninitialize() { if (senseManager != null) { senseManager.Dispose(); senseManager = null; } if (projection != null) { projection.Dispose(); projection = null; } if (handData != null) { handData.Dispose(); handData = null; } if (handAnalyzer != null) { handAnalyzer.Dispose(); handAnalyzer = null; } if (config != null) { config.UnsubscribeGesture(OnFiredGesture); config.Dispose(); } }
private void Uninitialize() { if (senseManager != null) { senseManager.Dispose(); senseManager = null; } if (handConfig != null) { handConfig.Dispose(); handConfig = null; } if (handData != null) { handData.Dispose(); handData = null; } if (handAnalyzer != null) { handAnalyzer.Dispose(); handAnalyzer = null; } }
public void Dispose() { _smootherFactory.SilentlyDispose(); foreach (var item in _smoothers.Values) { item.SilentlyDispose(); } _handData.Dispose(); }
void OnDisable() { //Disposses all modules Initialized = false; if (SenseManager == null) { return; } if (FaceModuleOutput != null) { FaceModuleOutput.Dispose(); FaceModuleOutput = null; } if (HandDataOutput != null) { SenseManager.PauseHand(true); HandDataOutput.Dispose(); HandDataOutput = null; } if (ImageRgbOutput != null) { ImageRgbOutput.Dispose(); ImageRgbOutput = null; } if (ImageDepthOutput != null) { ImageDepthOutput.Dispose(); ImageDepthOutput = null; } if (ImageIROutput != null) { ImageIROutput.Dispose(); ImageIROutput = null; } if (_projection != null) { _projection.Dispose(); _projection = null; } UvMap = null; PointCloud = null; SenseManager.Dispose(); SenseManager = null; }
void OnDisable() { if (handConfig != null) { handConfig.Dispose(); } if (handData != null) { handData.Dispose(); } if (psm != null) { psm.Dispose(); } }
private void Uninitialize() { // リソースを解放する if (senseManager != null) { senseManager.Dispose(); senseManager = null; } if (handData != null) { handData.Dispose(); handData = null; } if (handAnalyzer != null) { handAnalyzer.Dispose(); handAnalyzer = null; } }
void OnDisable() { /* Dispose hand data instance*/ if (hand_data != null) { hand_data.Dispose(); hand_data = null; } /* Dispose hand module instance*/ if (hand != null) { hand.Dispose(); hand = null; } /* Dispose sense manager instance*/ if (sm != null) { sm.Dispose(); sm = null; } }
pxcmStatus newHandFrame(PXCMHandModule hand) { if (hand != null) { PXCMHandData handData = hand.CreateOutput(); handData.Update(); PXCMHandData.IHand iHandDataLeft = null, iHandDataRight = null; PXCMHandData.JointData jointData = null; PXCMImage image = null; handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_LEFT_HANDS, 0, out iHandDataLeft); handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_RIGHT_HANDS, 0, out iHandDataRight); if (handForm != null && !handForm.IsDisposed) { this.handForm.HandCount = handData.QueryNumberOfHands(); if (iHandDataLeft != null) { iHandDataLeft.QuerySegmentationImage(out image); if (image != null) { PXCMImage.ImageData data = new PXCMImage.ImageData(); image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out data); handForm.LeftHand = data.ToBitmap(0, image.info.width, image.info.height); image.ReleaseAccess(data); } } if (iHandDataRight != null) { iHandDataRight.QuerySegmentationImage(out image); if (image != null) { PXCMImage.ImageData data = new PXCMImage.ImageData(); image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.PixelFormat.PIXEL_FORMAT_RGB32, out data); handForm.RightHand = data.ToBitmap(0, image.info.width, image.info.height); image.ReleaseAccess(data); } } } if (iHandDataLeft != null) { if (jointData == null) { iHandDataLeft.QueryTrackedJoint(PXCMHandData.JointType.JOINT_INDEX_TIP, out jointData); } } if (iHandDataRight != null) { if (jointData == null) { iHandDataRight.QueryTrackedJoint(PXCMHandData.JointType.JOINT_INDEX_TIP, out jointData); } } if (jointData != null && canTrack.Checked) { Cursor.Position = new System.Drawing.Point( (int)((640.0f - jointData.positionImage.x) * Screen.PrimaryScreen.Bounds.Width / 640.0f), (int)(jointData.positionImage.y * Screen.PrimaryScreen.Bounds.Height / 480.0f)); PXCMHandData.GestureData gestureData = null; if (handData.IsGestureFired("two_fingers_pinch_open", out gestureData)) { Program.DoMouseClick(); } Console.WriteLine("Z Position: " + jointData.positionWorld.z); } handData.Dispose(); } return(pxcmStatus.PXCM_STATUS_NO_ERROR); }
void OnDisable() { //Disposses all modules Initialized = false; if (SenseManager == null) { return; } DisposeFunctions.ForEach(i => i.DynamicInvoke()); if (FaceModuleOutput != null) { FaceModuleOutput.Dispose(); FaceModuleOutput = null; } if (HandDataOutput != null) { SenseManager.PauseHand(true); HandDataOutput.Dispose(); HandDataOutput = null; } if (BlobDataOutput != null) { SenseManager.PauseBlob(true); BlobDataOutput.Dispose(); BlobDataOutput = null; } if (ImageRgbOutput != null) { ImageRgbOutput.Dispose(); ImageRgbOutput = null; } if (ImageDepthOutput != null) { ImageDepthOutput.Dispose(); ImageDepthOutput = null; } if (ImageIROutput != null) { ImageIROutput.Dispose(); ImageIROutput = null; } if (Image3DSegmentationOutput != null) { Image3DSegmentationOutput.Dispose(); Image3DSegmentationOutput = null; } if (Projection != null) { Projection.Dispose(); Projection = null; } /* GZ * if (BlobExtractor != null) * { * BlobExtractor.Dispose(); * BlobExtractor = null; * } */ UvMap = null; PointCloud = null; SenseManager.Dispose(); SenseManager = null; }
public void HandPipeLine() { PXCMSenseManager pp = m_form.Session.CreateSenseManager(); if (pp == null) { throw new Exception("PXCMSenseManager null"); } pp.EnableStream(PXCMCapture.StreamType.STREAM_TYPE_COLOR, 640, 360); //手 初始化 PXCMHandModule handAnalysis; PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler(); handler.onModuleProcessedFrame = new PXCMSenseManager.Handler.OnModuleProcessedFrameDelegate(OnNewFrame); PXCMHandConfiguration handConfiguration = null; PXCMHandData handData = null; pxcmStatus status = pp.EnableHand(); handAnalysis = pp.QueryHand(); if (status != pxcmStatus.PXCM_STATUS_NO_ERROR || handAnalysis == null) { Console.WriteLine("hand module load failed"); return; } handConfiguration = handAnalysis.CreateActiveConfiguration(); if (handConfiguration == null) { Console.WriteLine("Failed Create Configuration"); return; } handData = handAnalysis.CreateOutput(); if (handData == null) { Console.WriteLine("Failed Create Output"); return; } if (pp.Init(handler) != pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("init failed"); return; } if (handConfiguration != null) { PXCMHandData.TrackingModeType trackingMode = PXCMHandData.TrackingModeType.TRACKING_MODE_FULL_HAND; // 配置收的Tracking Mode trackingMode = PXCMHandData.TrackingModeType.TRACKING_MODE_FULL_HAND; handConfiguration.SetTrackingMode(trackingMode); handConfiguration.EnableAllAlerts(); handConfiguration.EnableSegmentationImage(true); bool isEnabled = handConfiguration.IsSegmentationImageEnabled(); handConfiguration.ApplyChanges(); int totalNumOfGestures = handConfiguration.QueryGesturesTotalNumber(); if (totalNumOfGestures > 0) { for (int i = 0; i < totalNumOfGestures; i++) { string gestureName = string.Empty; if (handConfiguration.QueryGestureNameByIndex(i, out gestureName) == pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine(gestureName); } } } } int frameCounter = 0; int frameNumber = 0; while (!m_form.Stopped) { string gestureName = "fist"; if (handConfiguration != null) { if (string.IsNullOrEmpty(gestureName) == false) { if (handConfiguration.IsGestureEnabled(gestureName) == false) { handConfiguration.DisableAllGestures(); handConfiguration.EnableGesture(gestureName, true); handConfiguration.ApplyChanges(); } } else { handConfiguration.DisableAllGestures(); handConfiguration.ApplyChanges(); } } if (pp.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } frameCounter++; if (pp.IsConnected()) { PXCMCapture.Sample sample; sample = pp.QueryHandSample(); if (sample != null && sample.depth != null) { // frameNumber = liveCamera ? frameCounter : instance.captureManager.QueryFrameIndex(); frameNumber = frameCounter; } //bool b=(sample.ir==null); //b = (sample.color== null); //b = (sample.left == null); //b = (sample.right == null); DisplayPicture(sample.depth); if (handData != null) { handData.Update(); SaveHandData(handData); } m_form.UpdatePic(); } pp.ReleaseFrame(); } if (handData != null) { handData.Dispose(); } if (handConfiguration != null) { handConfiguration.Dispose(); } pp.Close(); pp.Dispose(); }
public void ProcessingThread() { // Start AcquireFrame/ReleaseFrame loop while (senseManager.AcquireFrame(true) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { hand = senseManager.QueryHand(); if (hand != null) { // Retrieve the most recent processed data handData = hand.CreateOutput(); handData.Update(); // Get number of tracked hands nhands = handData.QueryNumberOfHands(); if (nhands > 0) { // Retrieve hand identifier handData.QueryHandId(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, 0, out handId); // Retrieve hand data handData.QueryHandDataById(handId, out ihand); PXCMHandData.BodySideType bodySideType = ihand.QueryBodySide(); if (bodySideType == PXCMHandData.BodySideType.BODY_SIDE_LEFT) { leftHand = true; } else if (bodySideType == PXCMHandData.BodySideType.BODY_SIDE_RIGHT) { leftHand = false; } // Retrieve all hand joint data for (int i = 0; i < nhands; i++) { for (int j = 0; j < 0x20; j++) { PXCMHandData.JointData jointData; ihand.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData); nodes[i][j] = jointData; } } // Get world coordinates for tip of middle finger on the first hand in camera range handTipX = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.x; handTipY = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.y; handTipZ = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.z; swipehandTipX = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.x; swipehandTipY = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.y; swipehandTipZ = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionImage.z; //Console.Out.WriteLine("Before x={0}", swipehandTipX); //Console.Out.WriteLine("Before speed={0}", nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].speed.x); // Retrieve gesture data if (handData.IsGestureFired("spreadfingers", out gestureData)) { gesture = Gesture.FingerSpread; } else if (handData.IsGestureFired("two_fingers_pinch_open", out gestureData)) { gesture = Gesture.Pinch; } else if (handData.IsGestureFired("wave", out gestureData)) { gesture = Gesture.Wave; } else if (handData.IsGestureFired("swipe_left", out gestureData)) { gesture = Gesture.SwipeLeft; } else if (handData.IsGestureFired("swipe_right", out gestureData)) { gesture = Gesture.SwipeRight; } else if (handData.IsGestureFired("fist", out gestureData)) { gesture = Gesture.Fist; } else if (handData.IsGestureFired("thumb_up", out gestureData)) { gesture = Gesture.Thumb; } } else { gesture = Gesture.Undefined; } UpdateUI(); if (handData != null) { handData.Dispose(); } } senseManager.ReleaseFrame(); } }
private void ProcessingHandThread() { // Start AcquireFrame/ReleaseFrame loop while (senseManager.AcquireFrame(true) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { hand = senseManager.QueryHand(); if (hand != null) { // Retrieve the most recent processed data handData = hand.CreateOutput(); handData.Update(); // Get number of tracked hands nhands = handData.QueryNumberOfHands(); if (nhands > 0) { // Retrieve hand identifier handData.QueryHandId(PXCMHandData.AccessOrderType.ACCESS_ORDER_BY_TIME, 0, out handId); // Retrieve hand data handData.QueryHandDataById(handId, out ihand); // Retrieve all hand joint data for (int i = 0; i < nhands; i++) { for (int j = 0; j < 0x20; j++) { PXCMHandData.JointData jointData; ihand.QueryTrackedJoint((PXCMHandData.JointType)j, out jointData); nodes[i][j] = jointData; } } // Get world coordinates for tip of middle finger on the first hand in camera range handTipX = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.x; handTipY = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.y; handTipZ = nodes[0][Convert.ToInt32(PXCMHandData.JointType.JOINT_MIDDLE_TIP)].positionWorld.z; // Retrieve gesture data if (handData.IsGestureFired("spreadfingers", out gestureData)) { gesture = Gesture.FingerSpread; } else if (handData.IsGestureFired("two_fingers_pinch_open", out gestureData)) { gesture = Gesture.Pinch; } else if (handData.IsGestureFired("wave", out gestureData)) { gesture = Gesture.Wave; } } else { gesture = Gesture.Undefined; } // Get alert status for (int i = 0; i < handData.QueryFiredAlertsNumber(); i++) { PXCMHandData.AlertData alertData; if (handData.QueryFiredAlertData(i, out alertData) != pxcmStatus.PXCM_STATUS_NO_ERROR) { continue; } //Displaying last alert switch (alertData.label) { case PXCMHandData.AlertType.ALERT_HAND_DETECTED: detectionAlert = "Hand Detected"; detectionStatusOk = true; break; case PXCMHandData.AlertType.ALERT_HAND_NOT_DETECTED: detectionAlert = "Hand Not Detected"; detectionStatusOk = false; break; case PXCMHandData.AlertType.ALERT_HAND_CALIBRATED: calibrationAlert = "Hand Calibrated"; calibrationStatusOk = true; break; case PXCMHandData.AlertType.ALERT_HAND_NOT_CALIBRATED: calibrationAlert = "Hand Not Calibrated"; calibrationStatusOk = false; break; case PXCMHandData.AlertType.ALERT_HAND_INSIDE_BORDERS: bordersAlert = "Hand Inside Borders"; borderStatusOk = true; break; case PXCMHandData.AlertType.ALERT_HAND_OUT_OF_BORDERS: bordersAlert = "Hand Out Of Borders"; borderStatusOk = false; break; } } UpdateUI(); if (handData != null) handData.Dispose(); } senseManager.ReleaseFrame(); } }
/* Using PXCMSenseManager to handle data */ public void SimplePipeline() { form.UpdateInfo(String.Empty, Color.Black); bool liveCamera = false; bool flag = true; PXCMSenseManager instance = null; _disconnected = false; instance = form.g_session.CreateSenseManager(); if (instance == null) { form.UpdateStatus("Failed creating SenseManager"); return; } if (form.GetRecordState()) { instance.captureManager.SetFileName(form.GetFileName(), true); PXCMCapture.DeviceInfo info; if (form.Devices.TryGetValue(form.GetCheckedDevice(), out info)) { instance.captureManager.FilterByDeviceInfo(info); } } else if (form.GetPlaybackState()) { instance.captureManager.SetFileName(form.GetFileName(), false); instance.captureManager.SetRealtime(false); } else { PXCMCapture.DeviceInfo info; if (String.IsNullOrEmpty(form.GetCheckedDevice())) { form.UpdateStatus("Device Failure"); return; } if (form.Devices.TryGetValue(form.GetCheckedDevice(), out info)) { instance.captureManager.FilterByDeviceInfo(info); } liveCamera = true; } /* Set Module */ pxcmStatus status = instance.EnableHand(form.GetCheckedModule()); PXCMHandModule handAnalysis = instance.QueryHand(); if (status != pxcmStatus.PXCM_STATUS_NO_ERROR || handAnalysis == null) { form.UpdateStatus("Failed Loading Module"); return; } PXCMSenseManager.Handler handler = new PXCMSenseManager.Handler(); handler.onModuleProcessedFrame = new PXCMSenseManager.Handler.OnModuleProcessedFrameDelegate(OnNewFrame); PXCMHandConfiguration handConfiguration = handAnalysis.CreateActiveConfiguration(); PXCMHandData handData = handAnalysis.CreateOutput(); if (handConfiguration == null) { form.UpdateStatus("Failed Create Configuration"); return; } if (handData == null) { form.UpdateStatus("Failed Create Output"); return; } if (form.getInitGesturesFirstTime() == false) { int totalNumOfGestures = handConfiguration.QueryGesturesTotalNumber(); if (totalNumOfGestures > 0) { this.form.UpdateGesturesToList("", 0); for (int i = 0; i < totalNumOfGestures; i++) { string gestureName = string.Empty; if (handConfiguration.QueryGestureNameByIndex(i, out gestureName) == pxcmStatus.PXCM_STATUS_NO_ERROR) { this.form.UpdateGesturesToList(gestureName, i + 1); } } form.setInitGesturesFirstTime(true); form.UpdateGesturesListSize(); } } FPSTimer timer = new FPSTimer(form); form.UpdateStatus("Init Started"); if (handAnalysis != null && instance.Init(handler) == pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMCapture.DeviceInfo dinfo; PXCMCapture.Device device = instance.captureManager.device; if (device != null) { pxcmStatus result = device.QueryDeviceInfo(out dinfo); if (result == pxcmStatus.PXCM_STATUS_NO_ERROR && dinfo != null && dinfo.model == PXCMCapture.DeviceModel.DEVICE_MODEL_IVCAM) { device.SetDepthConfidenceThreshold(1); device.SetMirrorMode(PXCMCapture.Device.MirrorMode.MIRROR_MODE_DISABLED); device.SetIVCAMFilterOption(6); } _maxRange = device.QueryDepthSensorRange().max; } if (handConfiguration != null) { handConfiguration.EnableAllAlerts(); handConfiguration.EnableSegmentationImage(true); handConfiguration.ApplyChanges(); handConfiguration.Update(); } form.UpdateStatus("Streaming"); int frameCounter = 0; int frameNumber = 0; string nextPageGesture, previousPageGesture, firstPageGesture, endPageGesture; HandsRecognition.Hand nextHand, previousHand, firstHand, endHand; while (!form.stop) { form.GetHandType(out nextHand, out previousHand, out firstHand, out endHand); form.GetGestureName(out nextPageGesture, out previousPageGesture, out firstPageGesture, out endPageGesture); handConfiguration.DisableAllGestures(); if (string.IsNullOrEmpty(nextPageGesture) == false && handConfiguration.IsGestureEnabled(nextPageGesture) == false) { handConfiguration.EnableGesture(nextPageGesture, true); NextPageGesture.Gesture = nextPageGesture; NextPageGesture.handler = form.NextPage; NextPageGesture.HandType = nextHand; } if (string.IsNullOrEmpty(previousPageGesture) == false && handConfiguration.IsGestureEnabled(previousPageGesture) == false) { handConfiguration.EnableGesture(previousPageGesture, true); PreviousPageGesture.Gesture = previousPageGesture; PreviousPageGesture.handler = form.PreviousPage; PreviousPageGesture.HandType = previousHand; } if (string.IsNullOrEmpty(firstPageGesture) == false && handConfiguration.IsGestureEnabled(firstPageGesture) == false) { handConfiguration.EnableGesture(firstPageGesture, true); FirstPageGesture.Gesture = firstPageGesture; FirstPageGesture.handler = form.FirstPage; FirstPageGesture.HandType = firstHand; } if (string.IsNullOrEmpty(endPageGesture) == false && handConfiguration.IsGestureEnabled(endPageGesture) == false) { handConfiguration.EnableGesture(endPageGesture, true); EndPageGesture.Gesture = endPageGesture; EndPageGesture.handler = form.EndPage; EndPageGesture.HandType = endHand; } handConfiguration.ApplyChanges(); if (instance.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } frameCounter++; if (!DisplayDeviceConnection(!instance.IsConnected())) { if (handData != null) { handData.Update(); } PXCMCapture.Sample sample = instance.QueryHandSample(); if (sample != null && sample.depth != null) { DisplayPicture(sample.depth, handData); if (handData != null) { frameNumber = liveCamera ? frameCounter : instance.captureManager.QueryFrameIndex(); DisplayJoints(handData); DisplayGesture(handData, frameNumber); DisplayAlerts(handData, frameNumber); } form.UpdatePanel(); } timer.Tick(); } instance.ReleaseFrame(); } // Clean Up if (handData != null) { handData.Dispose(); } if (handConfiguration != null) { handConfiguration.Dispose(); } } else { form.UpdateStatus("Init Failed"); flag = false; } foreach (PXCMImage pxcmImage in m_images) { pxcmImage.Dispose(); } instance.Close(); instance.Dispose(); if (flag) { form.UpdateStatus("Stopped"); } }
public static void start(IoT_RealSense_Surfing frm) { keepLooping = true; iot_form = frm; InitializeMqqtClient(); PXCMSession session = PXCMSession.CreateInstance(); // Querying the SDK version Console.WriteLine(frm.comboTarget.SelectedText); if (session != null) { // Optional steps to send feedback to Intel Corporation to understand how often each SDK sample is used. PXCMMetadata md = session.QueryInstance <PXCMMetadata>(); if (md != null) { string sample_name = "Emotion Viewer CS"; md.AttachBuffer(1297303632, System.Text.Encoding.Unicode.GetBytes(sample_name)); } //Application.Run(new MainForm(session)); //session.Dispose(); } //PXCMSession.ImplVersion version = session.QueryVersion(); //Console.WriteLine("RealSense SDK Version {0}.{1}", version.major, version.minor); session.CreateImpl <PXCMRotation>(out rotationHelper); // Creating the SenseManager PXCMSenseManager senseManager = session.CreateSenseManager(); if (senseManager == null) { Console.WriteLine("Failed to create the SenseManager object."); return; } // Enabling Emotion Module pxcmStatus enablingModuleStatus = senseManager.EnableEmotion(); if (enablingModuleStatus != pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("Failed to enable the Emotion Module"); return; } // Getting the instance of the Emotion Module PXCMEmotion emotionModule = senseManager.QueryEmotion(); if (emotionModule == null) { Console.WriteLine("Failed to query the emotion module"); return; } // Initializing the camera if (senseManager.Init() < pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("Failed to initialize the SenseManager"); return; } // Enabling the Hand module pxcmStatus enablingModuleStatus1 = senseManager.EnableHand("Hand Module"); if (enablingModuleStatus1 != pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("Failed to enable the Hand Module"); return; } // Getting the instance of the Hand Module PXCMHandModule handModule = senseManager.QueryHand(); if (handModule == null) { Console.WriteLine("Failed to get the HandModule object."); return; } // Creating an active configuration PXCMHandConfiguration handConfiguration = handModule.CreateActiveConfiguration(); if (handConfiguration == null) { Console.WriteLine("Failed to create the HandConfiguration object."); return; } // Listing the available gestures int supportedGesturesCount = handConfiguration.QueryGesturesTotalNumber(); if (supportedGesturesCount > 0) { Console.WriteLine("Supported gestures:"); for (int i = 0; i < supportedGesturesCount; i++) { string gestureName = string.Empty; if (handConfiguration.QueryGestureNameByIndex(i, out gestureName) == pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("\t" + gestureName); } } } // Enabling some gestures String[] enabledGestures = { GESTURE_CLICK, GESTURE_VSIGN, GESTURE_FIST, GESTURE_SPREADFINGERS }; foreach (String gesture in enabledGestures) { if (!handConfiguration.IsGestureEnabled(gesture)) { handConfiguration.EnableGesture(gesture); } } handConfiguration.ApplyChanges(); // Creating a data output object PXCMHandData handData = handModule.CreateOutput(); if (handData == null) { Console.WriteLine("Failed to create the HandData object."); return; } // Initializing the SenseManager if (senseManager.Init() != pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine(senseManager.Init()); return; } // Looping to query the hands information while (keepLooping) { // Acquiring a frame if (senseManager.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR) { break; } // Updating the hand data if (handData != null) { handData.Update(); } //ProcessHands(handData); ProcessGestures(handData); ProcessEmotions(emotionModule); // Releasing the acquired frame senseManager.ReleaseFrame(); /* using another frame to process different stuff? may be... * // Acquiring a frame * if (senseManager.AcquireFrame(true) < pxcmStatus.PXCM_STATUS_NO_ERROR) * { * break; * } * * // Processing Emotions * ProcessEmotions(emotionModule); * * // Releasing the acquired frame * senseManager.ReleaseFrame();*/ } // Releasing resources if (handData != null) { handData.Dispose(); } if (handConfiguration != null) { handConfiguration.Dispose(); } rotationHelper.Dispose(); senseManager.Close(); senseManager.Dispose(); session.Dispose(); client.Disconnect(); }