public override void OnImage(PXCMImage image) { #region 攝影機影像顯示 //Debug.WriteLine("收到影像,格式 : " + image.imageInfo.format); PXCMSession session = QuerySession(); Bitmap bitmapimage; image.QueryBitmap(session, out bitmapimage); BitmapSource source = ToWpfBitmap(bitmapimage); if (image.imageInfo.format == PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH) { MainWindow.mainwin.ProcessDepthImage(source); } else if (image.imageInfo.format == PXCMImage.ColorFormat.COLOR_FORMAT_RGB24) { MainWindow.mainwin.ProcessColorImage(source); } image.Dispose(); #endregion PXCMGesture gesture = QueryGesture(); if (gesture != null) { PXCMGesture.GeoNode node; //PXCMGesture.GeoNode[] nodes = new PXCMGesture.GeoNode[11]; gesture.QueryNodeData(0, NeedNode(), out node); //gesture.QueryNodeData(0, NeedNodes(), nodes); ProcessNode(node); //ProcessNodes(nodes); } }
public override void OnGesture(ref PXCMGesture.Gesture data) { m_UI.Notify(string.Format("GESTURE: {0}", data.label)); switch (data.label) { case PXCMGesture.Gesture.Label.LABEL_POSE_BIG5: if (m_Mode != Mode.Rotate) { m_UI.Notify("Rotate Mode"); } m_Mode = Mode.Rotate; break; case PXCMGesture.Gesture.Label.LABEL_POSE_THUMB_UP: if (m_Mode != Mode.Follow) { m_UI.Notify("Follow Mode"); } m_Mode = Mode.Follow; break; case PXCMGesture.Gesture.Label.LABEL_POSE_PEACE: if (m_Mode != Mode.Animate) { m_UI.Notify("Animate Mode"); } m_Mode = Mode.Animate; break; } }
public void DisplayGeoNodes(PXCMGesture.GeoNode[][] nodes) { if (this.Visible == true) { lock (this) { if (bitmap == null) return; if (nodes == null) return; Graphics g = Graphics.FromImage(bitmap); using (Pen red = new Pen(Color.Red, 3.0f), green = new Pen(Color.Green, 3.0f), cyan = new Pen(Color.Cyan, 3.0f)) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 10; j++) { if (nodes[i][j].body <= 0) continue; float sz = (j == 0) ? 10 : ((nodes[i][j].radiusImage > 5) ? nodes[i][j].radiusImage : 5); g.DrawEllipse(j > 5 ? red : green, nodes[i][j].positionImage.x - sz / 2, nodes[i][j].positionImage.y - sz / 2, sz, sz); } } if (Params.Checked) { if (nodes[0][0].body > 0) g.DrawLine(cyan, 0, bitmap.Height - 1, 0, (100 - nodes[0][0].openness) * (bitmap.Height - 1) / 100); if (nodes[1][0].body > 0) g.DrawLine(cyan, bitmap.Width - 1, bitmap.Height - 1, bitmap.Width - 1, (100 - nodes[1][0].openness) * (bitmap.Height - 1) / 100); } } g.Dispose(); } } }
public override bool OnNewFrame() { PXCMGesture gesture = QueryGesture(); PXCMGesture.GeoNode ndata; pxcmStatus sts = gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, out ndata); uint sx; uint sy; QueryImageSize(PXCMImage.ImageType.IMAGE_TYPE_DEPTH, out sx, out sy); xx = sx; yy = sy; if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("HAND_MIDDLE:" + ndata.positionImage.x.ToString() + "," + ndata.positionImage.y.ToString() + " Openess:" + ndata.openness.ToString()); } float x = ndata.positionImage.x; float y = ndata.positionImage.y; z = ndata.positionWorld.z; position = new Vector2(MyGraphics.screenRect.Width / 2 - (x / xx - 0.5f) * MyGraphics.screenRect.Width * 1.5f, MyGraphics.screenRect.Height / 2 + (y / yy - 0.5f) * MyGraphics.screenRect.Height * 1.5f); opennes = ndata.openness; openState = ndata.opennessState; //return (++nframes < 50000); return(start); }
private void DisplayPicture(PXCMImage depth, PXCMGesture gesture) { PXCMImage image = depth; bool dispose = false; if (form.GetLabelmapState()) { if (gesture.QueryBlobImage(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out image) < pxcmStatus.PXCM_STATUS_NO_ERROR) { return; } dispose = true; } PXCMImage.ImageData data; if (image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.ColorFormat.COLOR_FORMAT_RGB32, out data) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMImage.ImageInfo imageInfo = image.imageInfo; form.DisplayBitmap(data.ToBitmap(imageInfo.width, imageInfo.height)); image.ReleaseAccess(ref data); } if (dispose) { image.Dispose(); } }
public override void OnGesture(ref PXCMGesture.Gesture data) { if (data.label == PXCMGesture.Gesture.Label.LABEL_POSE_THUMB_DOWN) { if (Game.gd.Gamestate == 0) Game.gd.Gamestate = 1; } if (data.active) Console.WriteLine("OnGesture("+data.label+")"); }
public override void OnAlert(ref PXCMGesture.Alert data) { m_UI.Notify(string.Format("ALERT: {0}", data.label)); switch (data.label) { case PXCMGesture.Alert.Label.LABEL_GEONODE_INACTIVE: m_UI.Notify("Idle Mode"); m_Mode = Mode.Idle; break; } }
private void DisplayGeoNodes(PXCMGesture gesture) { if (form.GetGeoNodeState()) { gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, nodes[0]); gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY, nodes[1]); //gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_ELBOW_PRIMARY, out nodes[0][nodes.Length-1]); //gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_ELBOW_SECONDARY, out nodes[1][nodes.Length-1]); form.DisplayGeoNodes(nodes); } else { form.DisplayGeoNodes(null); } }
public CaptureHand(CaptureForm form) : base() { pp = new UtilMPipeline(); pp.EnableGesture(); pp.EnableImage(PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH); if (pp.Init()) { pp.QueryCapture().SetFilter(PXCMCapture.Device.Property.PROPERTY_DEPTH_SMOOTHING, 100); do { if (!pp.AcquireFrame(true)) { MessageBox.Show("Failed to aquire a frame.", "Kwi-S", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); break; } gesture = pp.QueryGesture(); gesture.QueryBlobData(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bdata); gesture.QueryBlobImage(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bimage); bimage.AcquireAccess(PXCMImage.Access.ACCESS_READ, out data); info = bimage.imageInfo; color = (int)bdata.labelLeftHand; form.setTextBox(color.ToString()); pp.ReleaseFrame(); } while (color == -1); Coord[] locations = handLocation(data, (int)(info.width * info.height), (int)info.width); bitmap = createBitmap(locations, (int)info.width, (int)info.height); form.setImage(bitmap); form.bitmap = bitmap; } }
//public override void OnGestureSetup(ref PXCMGesture.ProfileInfo profile) {} // sdk can recognize some predefine gesture: swipe left/top/right/down, action: wave circle, hand pose: thumb up/down victory, big5 public override void OnGesture(ref PXCMGesture.Gesture data) { for (uint i = 0; ; i++) { // queryGestureData(user,label for body, zero based index for gesture, gesture to be return pxcmStatus sts = QueryGesture().QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_ANY, i, out data); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break; if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN) Console.WriteLine("Just swipe down", data.label); if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_LEFT) Console.WriteLine("Just swipe left", data.label); if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_RIGHT) Console.WriteLine("Just swipe right", data.label); if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP) Console.WriteLine("Just swipe up", data.label); } }
public CaptureHand(CaptureForm form) : base() { pp = new UtilMPipeline(); pp.EnableGesture(); pp.EnableImage(PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH); if (pp.Init()) { pp.QueryCapture().SetFilter(PXCMCapture.Device.Property.PROPERTY_DEPTH_SMOOTHING, 100); do { if (!pp.AcquireFrame(true)) { MessageBox.Show("Failed to aquire a frame.", "Kwi-S", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); break; } gesture = pp.QueryGesture(); gesture.QueryBlobData(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bdata); gesture.QueryBlobImage(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bimage); bimage.AcquireAccess(PXCMImage.Access.ACCESS_READ,out data); info = bimage.imageInfo; color =(int) bdata.labelLeftHand; form.setTextBox(color.ToString()); pp.ReleaseFrame(); } while (color == -1); Coord[] locations = handLocation(data, (int)(info.width * info.height),(int) info.width); bitmap = createBitmap(locations, (int)info.width, (int)info.height); form.setImage(bitmap); form.bitmap = bitmap; } }
public override bool OnNewFrame() { PXCMGesture gesture = QueryGesture(); PXCMGesture.GeoNode ndata; pxcmStatus sts = gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, out ndata); if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) { _lastDirection = _DetectGesture(ndata.positionImage.x, ndata.positionImage.y); if (_lastDirection != MovingDirection.Undefined) { _sender.UpdateGesture(_lastDirection); } //Console.WriteLine("node HAND_MIDDLE ({0},{1})", ndata.positionImage.x, ndata.positionImage.y); } return(++_nframes < 50000); }
public override bool AcquireFrame(bool wait) { PXCMGesture gesture = QueryGesture(); PXCMGesture.GeoNode ndata; pxcmStatus sts = gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, out ndata); if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) { if ((ndata.positionImage.x >= 0) && (ndata.positionImage.x <= 320)) { geoNodeParams.nodeX = ndata.positionImage.x; } if ((ndata.positionImage.y >= 0) && (ndata.positionImage.y <= 240)) { geoNodeParams.nodeY = ndata.positionImage.y; } geoNodeParams.opennes = ndata.openness; } return(base.AcquireFrame(wait)); }
public bool QueryGeoNode(PXCMGesture.GeoNode.Label label, PXCMGesture.GeoNode[,] ndata) { throw new NotImplementedException(); }
public override void OnGesture(ref PXCMGesture.Gesture gesture) { base.OnGesture(ref gesture); Debug.WriteLine(gesture.body + " Gesture: {0} Visible: {1} Confidence: {2}", gesture.label, gesture.active, gesture.confidence); switch (gesture.label) { case PXCMGesture.Gesture.Label.LABEL_POSE_BIG5: IfThisElseThat(gesture.active, _poses.OnBigFiveBegin, _poses.OnBigFiveEnd); break; case PXCMGesture.Gesture.Label.LABEL_POSE_PEACE: IfThisElseThat(gesture.active, _poses.OnPosePeaceBegin, _poses.OnPosePeaceEnd); break; case PXCMGesture.Gesture.Label.LABEL_POSE_THUMB_DOWN: IfThisElseThat(gesture.active, _poses.OnPoseThumbsDownBegin, _poses.OnPoseThumbsDownEnd); break; case PXCMGesture.Gesture.Label.LABEL_POSE_THUMB_UP: IfThisElseThat(gesture.active, _poses.OnPoseThumbsUpBegin, _poses.OnPoseThumbsUpEnd); break; case PXCMGesture.Gesture.Label.LABEL_HAND_CIRCLE: _gestures.OnGestureHandCircle(); break; case PXCMGesture.Gesture.Label.LABEL_HAND_WAVE: _gestures.OnGestureHandWave(); break; case PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN: _gestures.OnGestureSwipeDown(); break; case PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP: _gestures.OnGestureSwipeUp(); break; case PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_RIGHT: _gestures.OnGestureSwipeRight(); break; case PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_LEFT: _gestures.OnGestureSwipeLeft(); break; case PXCMGesture.Gesture.Label.LABEL_SET_CUSTOMIZED: break; case PXCMGesture.Gesture.Label.LABEL_SET_POSE: break; case PXCMGesture.Gesture.Label.LABEL_SET_NAVIGATION: break; case PXCMGesture.Gesture.Label.LABEL_SET_HAND: break; case PXCMGesture.Gesture.Label.LABEL_MASK_DETAILS: break; case PXCMGesture.Gesture.Label.LABEL_MASK_SET: break; case PXCMGesture.Gesture.Label.LABEL_ANY: break; default: throw new ArgumentOutOfRangeException(); } }
private void TrackFingers(Item finger, PXCMGesture.GeoNode.Label fingerLabel) { var geoNode = QueryGeoNode(fingerLabel); TrackPosition(finger, geoNode); }
private void TrackPosition(Item item, PXCMGesture.GeoNode geoNode) { item.IsVisible = geoNode.body != PXCMGesture.GeoNode.Label.LABEL_ANY; if (!item.IsVisible) { return; } Func<double, double> meterToCentimeters = p => p * 100; item.Position = new Point3D { X = geoNode.positionImage.x, Y = geoNode.positionImage.y, Z = meterToCentimeters(geoNode.positionWorld.y) }; }
public void SimplePipeline() { //UtilMPipeline pp = null; MyUtilMPipeline pp = null; disconnected = false; bool sts = true; /* gesture */ /* Set Source */ //if (form.GetRecordState()) //{ //pp = new UtilMPipeline(form.GetRecordFile(), true); //pp.QueryCapture().SetFilter(form.GetCheckedDevice()); //} //else if (form.GetPlaybackState()) //{ //pp = new UtilMPipeline(form.GetPlaybackFile(), false); //} //else //{ //pp = new UtilMPipeline(); pp = new MyUtilMPipeline(); pp.SetForm(this); // pp.QueryCapture().SetFilter(form.GetCheckedDevice()); //} /* Set Module */ pp.EnableGesture(/*form.GetCheckedModule()*/); /* end egesture*/ /* speech recognition*/ /* Set Audio Source */ // pp.QueryCapture().SetFilter("Microphone Array (Creative GestureCam)"/*form.GetCheckedSource()*/); /* Set Module */ pp.EnableVoiceRecognition(/*"Voice Recognition (Nuance*)"*//*form.GetCheckedModule()*/); /* Set Language */ //pp.SetProfileIndex(form.GetCheckedLanguage()); // pp.SetProfileIndex(0); /* Set Command/Control or Dictation */ /* * if (form.IsCommandControl()) * { * string[] cmds = form.GetCommands(); * if (cmds == null) * { * form.PrintStatus("No Command List. Dictation instead."); * pp.SetVoiceDictation(); * } * else * {*/ pp.SetVoiceCommands(cmds); //pp.SetVoiceDictation(); /* * } * } * else * { * pp.SetVoiceDictation(); * }*/ /* end speech recognition*/ /* Initialization */ //form.UpdateStatus("Init Started"); bool initok = false; try { pp.Init(); initok = true; } catch (Exception e) { pp = null; System.Diagnostics.Debug.Print("Exception - Init Failed"); } if (initok) { // form.UpdateStatus("Streaming"); pp.QueryCapture().device.SetProperty(PXCMCapture.Device.Property.PROPERTY_AUDIO_MIX_LEVEL, 0.2f); while (!this.stop) { if (this.pause) { System.Threading.Thread.Sleep(50); } else { if (!pp.AcquireFrame(true)) { break; } if (!DisplayDeviceConnection(pp.IsDisconnected())) { /* Display Results */ PXCMGesture gesture = pp.QueryGesture(); PXCMImage depth = pp.QueryImage(PXCMImage.ImageType.IMAGE_TYPE_DEPTH); //DisplayPicture(depth, gesture); //DisplayGeoNodes(gesture); DisplayGesture(gesture); //form.UpdatePanel(); } pp.ReleaseFrame(); } } pp.Close(); // pp.Dispose(); } else { //form.UpdateStatus("Init Failed"); sts = false; } if (!sts) { System.Diagnostics.Debug.Print("Init Failed"); } //if (sts) form.UpdateStatus("Stopped"); }
public static void gestureHandler(PXCMGesture.Gesture[] x) { for (int i = 0; i < 2; i++) { /* if (x[0].label == x[1].label) { if(x[1].label==PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN) ExtProgramHandle.set_show_state(ShowState.SW_MINIMIZE); if (x[1].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP) ExtProgramHandle.set_show_state(ShowState.SW_RESTORE); return; } */ if (x[i].label == PXCMGesture.Gesture.Label.LABEL_POSE_THUMB_DOWN) { //ExtProgramHandle.restore_prev_win(ShowState.SW_MAXIMIZE); ExtProgramHandle.pass_string("{PGDN}"); } if (x[i].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN) { //ExtProgramHandle.pass_string("{PGDN}"); ExtProgramHandle.set_show_state(ShowState.SW_MINIMIZE); } // if (x[i].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP) { ExtProgramHandle.restore_prev_win(ShowState.SW_RESTORE); //ExtProgramHandle.pass_string("{PGUP}"); } //go back if (x[i].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_LEFT) ExtProgramHandle.pass_string("{BACKSPACE}"); //SingleClick if (x[i].label == PXCMGesture.Gesture.Label.LABEL_POSE_BIG5 & prevGesture[i].label!=PXCMGesture.Gesture.Label.LABEL_POSE_BIG5) JarvisMouse.leftClick(); //DoubleClick if (x[i].label == PXCMGesture.Gesture.Label.LABEL_POSE_PEACE & prevGesture[i].label != PXCMGesture.Gesture.Label.LABEL_POSE_PEACE) JarvisMouse.mousDoubleClick(); /* //Drag&Drop Check if (x[i].label == PXCMGesture.Gesture.Label.LABEL_POSE_BIG5) counter++; else counter = 0; //DragfDropExecute if (counter > 500) { drag = true; JarvisMouse.Mouse_Event(Mouse_Evnt.Left_button_Down); } else if (counter == 0) JarvisMouse.Mouse_Event(Mouse_Evnt.Left_button_Up); */ } prevGesture[0] = x[0]; prevGesture[1] = x[1]; }
public bool QueryGesture(PXCMGesture.GeoNode.Label body, out PXCMGesture.Gesture data) { if (instance!=IntPtr.Zero) return QueryGestureC(instance,body,out data); data=new PXCMGesture.Gesture(); return false; }
//public override void OnGestureSetup(ref PXCMGesture.ProfileInfo profile) {} // sdk can recognize some predefine gesture: swipe left/top/right/down, action: wave circle, hand pose: thumb up/down victory, big5 public override void OnGesture(ref PXCMGesture.Gesture data) { for (uint i = 0; ; i++) { // queryGestureData(user,label for body, zero based index for gesture, gesture to be return pxcmStatus sts = QueryGesture().QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_ANY, i, out data); if (sts < pxcmStatus.PXCM_STATUS_NO_ERROR) break; try { if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN) { Console.WriteLine("Just swipe down", data.label); formed.config(false, false, false, true); //down = true; //up = false; //left = false; //right = false; //Environment.Exit(0); //break; } //Console.WriteLine("Just swipe down", data.label); if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_LEFT) { Console.WriteLine("Just swipe left", data.label); formed.config(true, false, false, false); //down = false; //up = false; //left = true; //right = false; //break; } // Console.WriteLine("Just swipe left", data.label); if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_RIGHT) { Console.WriteLine("Just swipe right", data.label); formed.config(false, true, false, false); //down = false; //up = false; //left = false; //right = true; //break; } // Console.WriteLine("Just swipe right", data.label); if (data.label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP) { Console.WriteLine("Just swipe up", data.label); formed.config(false, false, true, false); //down = false; //up = true; //left = false; //right = false; //break; } //Console.WriteLine("Just swipe up", data.label); } catch (NullReferenceException e) { } } }
public void DisplayGestures(PXCMGesture.Gesture[] gestures) { if (!Gesture.Checked) return; if (this.Visible == true) { Gesture1.Invoke(new DisplayGesturesDelegate(delegate(PXCMGesture.Gesture[] data) { if (data != null) if (data[0].label > 0) { Gesture1.Image = (Bitmap)pictures[data[0].label]; Gesture1.Invalidate(); timer.Start(); } }), new object[] { gestures }); Gesture2.Invoke(new DisplayGesturesDelegate(delegate(PXCMGesture.Gesture[] data) { if (data != null) if (data[1].label > 0) { Gesture2.Image = (Bitmap)pictures[data[1].label]; Gesture2.Invalidate(); timer.Start(); } }), new object[] { gestures }); } }
private void DisplayGesture(PXCMGesture gesture) { gesture.QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, 0, out gestures[0]); gesture.QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY, 0, out gestures[1]); /* //int fingr = 0; for (int i = 0; i < 2; i++) { if ((finger_gesture()[i] > 3) & (gestures[i].label == PXCMGesture.Gesture.Label.LABEL_ANY)) gestures[i].label = PXCMGesture.Gesture.Label.LABEL_SET_CUSTOMIZED; if (finger_gesture()[i] > 1) gestures[i].label = PXCMGesture.Gesture.Label.LABEL_HAND_CIRCLE; mscreen.Invoke(new Action(delegate { mscreen.label5.Text = "1: " + finger_gesture()[0]; mscreen.label6.Text = "2: " + finger_gesture()[1]; })); } */ CommandHandler.gestureHandler(gestures); form.DisplayGestures(gestures); }
public override void OnAlert(ref PXCMGesture.Alert data) { }
public void DisplayGestures(PXCMGesture.Gesture[] gestures) { if (!Gesture.Checked) return; Gesture1.Invoke(new DisplayGesturesDelegate(delegate(PXCMGesture.Gesture[] data) { if (data != null) if (data[0].label > 0) { Gesture1.Image = (Bitmap)pictures[data[0].label]; Gesture1.Invalidate(); timer.Start(); if (data[0].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_LEFT || data[0].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_RIGHT || data[0].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP || data[0].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN) { Console.WriteLine("Toggling projection"); Projected.Instance.Projecting = !Projected.Instance.Projecting; } } }), new object[] { gestures }); Gesture2.Invoke(new DisplayGesturesDelegate(delegate(PXCMGesture.Gesture[] data) { if (data != null) if (data[1].label > 0) { Gesture2.Image = (Bitmap)pictures[data[1].label]; Gesture2.Invalidate(); timer.Start(); if (data[1].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_LEFT || data[1].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_RIGHT || data[1].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_UP || data[1].label == PXCMGesture.Gesture.Label.LABEL_NAV_SWIPE_DOWN) { Console.WriteLine("Toggling projection"); Projected.Instance.Projecting = !Projected.Instance.Projecting; } } }), new object[] { gestures }); }
public bool QueryGesture(PXCMGesture.GeoNode.Label body, out PXCMGesture.Gesture data) { if (initialized) return QueryGestureC(instance,body,out data); data=new PXCMGesture.Gesture(); return false; }
private void DisplayPicture(PXCMImage depth, PXCMGesture gesture) { PXCMImage image = depth; bool dispose = false; if (form.GetLabelmapState()) { if (gesture.QueryBlobImage(PXCMGesture.Blob.Label.LABEL_SCENE,0,out image)<pxcmStatus.PXCM_STATUS_NO_ERROR) return; dispose = true; } PXCMImage.ImageData data; if (image.AcquireAccess(PXCMImage.Access.ACCESS_READ, PXCMImage.ColorFormat.COLOR_FORMAT_RGB32, out data) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { form.DisplayBitmap(data.ToBitmap(image.info.width,image.info.height)); image.ReleaseAccess(ref data); } if (dispose) image.Dispose(); }
public bool QueryGeoNode(PXCMGesture.GeoNode.Label body, PXCMGesture.GeoNode[] data) { bool found=false; for (int i=0;i<data.Length;i++,body++) { if (!QueryGeoNode(body,out data[i])) data[i].body=PXCMGesture.GeoNode.Label.LABEL_ANY; else found=true; } return found; }
private void Disable(FlexiblePart flexiblePart, PXCMGesture.Alert alert) { if (alert.label == PXCMGesture.Alert.Label.LABEL_GEONODE_INACTIVE) { flexiblePart.IsVisible = false; } }
private static extern bool QueryGestureC(IntPtr pp, PXCMGesture.GeoNode.Label body, out PXCMGesture.Gesture data);
public GesturePipeline(Form1 form) : base() { //------------------------------ // Creates datastructures for // the PCSDK //------------------------------ UtilMPipeline pp; //The pipeline PXCMGesture.Blob bdata; //The intrepred blobs PXCMImage bimage; //The frame from the camera PXCMImage.ImageData data; //The data contained in the frame. PXCMImage.ImageInfo info; //Metadata about the frame. int color; //The "color" for the hand in question. //------------------------------ //------------------------------ // Initilize the datastructures // defined above. //------------------------------ Coord[] locations; pp = new UtilMPipeline(); pp.EnableGesture(); pp.EnableImage(PXCMImage.ColorFormat.COLOR_FORMAT_DEPTH); //----------------------------- //initilize the pointer for the WMC window. IntPtr handle = GetDesktopWindow(); //---------------------------------- // Create and initilize the bitmaps // that the frames will be comapred // against. //--------------------------------- Bitmap pause = convertBitmap(KwisStandalone.Properties.Resources.STOP); Bitmap fastForward = convertBitmap(KwisStandalone.Properties.Resources.FAST_FORWARD); Bitmap rewind = convertBitmap(KwisStandalone.Properties.Resources.REWIND); Bitmap play = convertBitmap(KwisStandalone.Properties.Resources.PLAY); Bitmap menu = convertBitmap(KwisStandalone.Properties.Resources.MENU); Bitmap volUp = convertBitmap(KwisStandalone.Properties.Resources.VOL_UP); Bitmap volDown = convertBitmap(KwisStandalone.Properties.Resources.VOL_DOWN); //-------------------------------- // initial the template matching algorithm. templateMatching = new ExhaustiveTemplateMatching(0.75f); /* If we were able to aquire a frame from the camera, * start the main application logic. * */ if (pp.Init()) { //Loop forever as long as the form is still open. while (!form.closing) { if (!pp.AcquireFrame(true)) { MessageBox.Show("Failed to aquire a frame.", "Kwi-S", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); break; } //Aquire the gesture data for the frame. using (PXCMGesture gesture = pp.QueryGesture()) { //Load gesture data into respective data structures. gesture.QueryBlobData(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bdata); gesture.QueryBlobImage(PXCMGesture.Blob.Label.LABEL_SCENE, 0, out bimage); bimage.AcquireAccess(PXCMImage.Access.ACCESS_READ, out data); info = bimage.imageInfo; /* Although this says left hand, * this actually aquires the right hand. * This is from trial and error and contradicts * both the documentation and common sense. A bug * in the SDK? * */ color = (int)bdata.labelLeftHand; //Store the pixels that include the hand specified above. locations = new Coord[info.width * info.height]; handLocation(ref locations, data, (int)info.width); //create a new bitmap from this data. Bitmap bitmap = createBitmap(ref locations, (int)info.width, (int)info.height); /* Zero is the left hand (actuall right). So, if we detected this, * then lets see if it matches any of the stored reference images. * */ if (color == 0) { try { if (compare(ref bitmap, ref pause)) { clickAndSendKey(RemoteKey.PLAY_PAUSE); } else if (compare(ref bitmap, ref play)) { clickAndSendKey(RemoteKey.PLAY); } else if (compare(ref bitmap, ref fastForward)) { clickAndSendKey(RemoteKey.FAST_FORWARD); } else if (compare(ref bitmap, ref rewind)) { clickAndSendKey(APPCOMMAND_MEDIA_REWIND, handle); } else if (compare(ref bitmap, ref menu)) { clickAndSendKey(RemoteKey.STOP); } else if (compare(ref bitmap, ref volUp)) { clickAndSendKey(RemoteKey.VOL_UP); } else if (compare(ref bitmap, ref volDown)) { clickAndSendKey(RemoteKey.VOL_DOWN); } } catch (InvalidImagePropertiesException iipe) { } } //Clean up the datastructures in prep for a new frame. bitmap.Dispose(); bimage.ReleaseAccess(ref data); bimage.Dispose(); gesture.Dispose(); } pp.ReleaseFrame(); } } }
private void DisplayGesture(PXCMGesture gesture) { gesture.QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, 0, out gestures[0]); gesture.QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY, 0, out gestures[1]); DisplayGestures(gestures); }
public override bool OnNewFrame() { float x, y; PXCMGesture gesture = QueryGesture(); PXCMGesture.GeoNode ndata; pxcmStatus sts = gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, out ndata); if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) { Console.WriteLine("node HAND_MIDDLE ({0},{1},{2},{3},{4})", ndata.positionImage.x, ndata.positionImage.y, ndata.confidence, ndata.openness, ndata.opennessState); x = ndata.positionImage.x; if (x > 260) { x = 260; } if (x < 40) { x = 40; } x = x - 40; ////////////////////////////////////////////////// x = 220 - x; if (ndata.opennessState == PXCMGesture.GeoNode.Openness.LABEL_CLOSE) { Game.Update1((float)(x - 110) / 110, 1, 1); } // /* * } * sts = gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, out ndata); * if (sts >= pxcmStatus.PXCM_STATUS_NO_ERROR) * { * Console.WriteLine("node HAND_MIDDLE ({0},{1},{2},{3},{4})", ndata.positionImage.x, ndata.positionImage.y, ndata.confidence, ndata.openness, ndata.opennessState); * //*/ int state; if (ndata.opennessState == PXCMGesture.GeoNode.Openness.LABEL_OPEN) { state = 0; } else { state = 1; } // Game.Update((float)Program.game.Width * (160 - ndata.positionImage.x) / 160, (float)Program.game.Height * (ndata.positionImage.y - 100) / 100, state, 0); x = ndata.positionImage.x; y = ndata.positionImage.y; //////////////////////////////////////////////// ///////////////Smoothing of coordinate nad removing data outside less presice rang////////////// if (x > 260) { x = 260; } if (x < 40) { x = 40; } if (y > 200) { y = 200; } if (y < 20) { y = 20; } x = x - 40; y = y - 20; ////////////////////////////////////////////////// x = 220 - x; if (Game.gd.Gamestate != 0) { Game.Update(Program.game.Width * x / 220, Program.game.Height * y / 180, state, 0); } } PXCMImage img = QueryImage(PXCMImage.ImageType.IMAGE_TYPE_COLOR); if (img != null) { img.QueryBitmap(QuerySession(), out bmp); } if (bmp != null) { Main.camerapre = GetTexture(Main.GrDev, bmp); } bmp = null; img = QueryImage(PXCMImage.ImageType.IMAGE_TYPE_DEPTH); if (img != null) { img.QueryBitmap(QuerySession(), out bmp); } if (bmp != null) { Main.camerapre1 = GetTexture(Main.GrDev, bmp); } bmp = null; img = QueryImage(PXCMImage.ImageType.IMAGE_TYPE_MASK); if (img != null) { img.QueryBitmap(QuerySession(), out bmp); } if (bmp != null) { Main.camerapre2 = GetTexture(Main.GrDev, bmp); } return(loop); }
public void SimplePipeline() { bool sts = true; UtilMPipeline pp = null; disconnected = false; /* Set Source */ if (form.GetRecordState()) { pp = new UtilMPipeline(form.GetRecordFile(), true); pp.QueryCapture().SetFilter(form.GetCheckedDevice()); } else if (form.GetPlaybackState()) { pp = new UtilMPipeline(form.GetPlaybackFile(), false); } else { pp = new UtilMPipeline(); pp.QueryCapture().SetFilter(form.GetCheckedDevice()); } /* Set Module */ pp.EnableGesture(form.GetCheckedModule()); /* Initialization */ form.UpdateStatus("Init Started"); if (pp.Init()) { form.UpdateStatus("Streaming"); while (!form.stop) { if (!pp.AcquireFrame(true)) { break; } if (!DisplayDeviceConnection(pp.IsDisconnected())) { /* Display Results */ PXCMGesture gesture = pp.QueryGesture(); PXCMImage depth = pp.QueryImage(PXCMImage.ImageType.IMAGE_TYPE_DEPTH); DisplayPicture(depth, gesture); DisplayGeoNodes(gesture); DisplayGesture(gesture); form.UpdatePanel(); } pp.ReleaseFrame(); } } else { form.UpdateStatus("Init Failed"); sts = false; } pp.Close(); pp.Dispose(); if (sts) { form.UpdateStatus("Stopped"); } }
public void Start() { //create session PXCMSession session; pxcmStatus status = PXCMSession.CreateInstance(out session); if (IsError(status)) { OnError(CamEvent.FAILED_TO_CREATE_SDK_SESSION); return; } //create gesture-module PXCMBase gestureBase; status = session.CreateImpl(PXCMGesture.CUID, out gestureBase); if (IsError(status)) { OnError(CamEvent.FAILED_TO_LOAD_GESTURE_RECOGNITION); session.Dispose(); return; } //create gesture-profile PXCMGesture gesture = (PXCMGesture)gestureBase; PXCMGesture.ProfileInfo profileInfo; status = gesture.QueryProfile(0, out profileInfo); profileInfo.activationDistance = 70; //setup gesture-capture UtilMCapture capture = new UtilMCapture(session); status = capture.LocateStreams(ref profileInfo.inputs); if (IsError(status)) { OnError(CamEvent.FAILED_TO_LOCATE_CAPTURE_MODULE); gesture.Dispose(); capture.Dispose(); session.Dispose(); return; } status = gesture.SetProfile(ref profileInfo); status = gesture.SubscribeAlert(this.OnAlertHandler); status = gesture.SubscribeGesture(100, this.OnGesureHandler); //start capture of frames bool device_lost = false; PXCMImage[] images = new PXCMImage[PXCMCapture.VideoStream.STREAM_LIMIT]; PXCMScheduler.SyncPoint[] syncPoints = new PXCMScheduler.SyncPoint[2]; while (_tracking) { status = capture.ReadStreamAsync(images, out syncPoints[0]); if (IsError(status)) { if (status == pxcmStatus.PXCM_STATUS_DEVICE_LOST) { if (!device_lost) { OnError(CamEvent.DEVICE_DISCONNECTED); } device_lost = true; continue; } OnError(CamEvent.DEVICE_FAILED); break; } if (device_lost) { OnNotify(CamEvent.DEVICE_RECONNECTED); device_lost = false; } status = gesture.ProcessImageAsync(images, out syncPoints[1]); if (IsError(status)) { break; } PXCMScheduler.SyncPoint.SynchronizeEx(syncPoints); if (syncPoints[0].Synchronize(0) >= pxcmStatus.PXCM_STATUS_NO_ERROR) { PXCMGesture.GeoNode data; status = gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, out data); if (!IsError(status)) { if (ShapeHelper.IsPointInsideRect(data.positionImage.x, data.positionImage.y, Constants.FoVWindow)) { //adjust the point to field-of-view window Point cameraPoint = new Point(data.positionImage.x - Constants.FoVWindow.X, data.positionImage.y - Constants.FoVWindow.Y); //cameraPoint = ShapeHelper.RotatePoint(cameraPoint, Constants.FoVCenter, Constants.RotationAngle); OnMovement(cameraPoint); if (data.opennessState != _previousOpenness) { OnOpenClose(data.opennessState, data.openness); _previousOpenness = data.opennessState; } } else { OnNotify(CamEvent.HOVERING_OUTSIDE); } } } foreach (PXCMScheduler.SyncPoint p in syncPoints) { if (p != null) { p.Dispose(); } } foreach (PXCMImage img in images) { if (img != null) { img.Dispose(); } } } if (gesture != null) { gesture.Dispose(); } if (capture != null) { capture.Dispose(); } if (session != null) { session.Dispose(); } }
private void TrackOpeness(FlexiblePart part, PXCMGesture.GeoNode geoNode) { if (!part.IsVisible) { return; } if (geoNode.openness > 75) { part.IsOpen = true; } else if (geoNode.openness < 10) { part.IsOpen = false; } }
private void DisplayGeoNodes(PXCMGesture gesture) { if (form.GetGeoNodeState()) { gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, nodes[0]); gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY, nodes[1]); gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_ELBOW_PRIMARY, out nodes[0][nodes.Length-1]); gesture.QueryNodeData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_ELBOW_SECONDARY, out nodes[1][nodes.Length-1]); form.DisplayGeoNodes(nodes); } else { form.DisplayGeoNodes(null); } }
private PXCMGesture.GeoNode QueryGeoNode(PXCMGesture.GeoNode.Label bodyLabel) { var values = new PXCMGesture.GeoNode(); QueryGesture().QueryNodeData(0, bodyLabel, out values); return values; }
private void DisplayGesture(PXCMGesture gesture) { gesture.QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY, 0, out gestures[0]); gesture.QueryGestureData(0, PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY, 0, out gestures[1]); form.DisplayGestures(gestures); }
public override void OnAlert(ref PXCMGesture.Alert alert) { base.OnAlert(ref alert); if (alert.body == PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_LEFT) { Disable(LeftHand, alert); } else if (alert.body == PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_RIGHT) { Disable(RightHand, alert); } Debug.WriteLine("Alert: " + alert.label + " Body: " + alert.body); }
public override void OnGesture(ref PXCMGesture.Gesture gesture) { _camera.OnGesture(gesture); }
private void TrackHandAndFingers(Hand hand, PXCMGesture.GeoNode.Label bodyLabel) { var geoNode = QueryGeoNode(bodyLabel); TrackPosition(hand, geoNode); TrackOpeness(hand, geoNode); TrackFingers(hand.Thumb, bodyLabel | PXCMGesture.GeoNode.Label.LABEL_FINGER_THUMB); TrackFingers(hand.Index, bodyLabel | PXCMGesture.GeoNode.Label.LABEL_FINGER_INDEX); TrackFingers(hand.Middle, bodyLabel | PXCMGesture.GeoNode.Label.LABEL_FINGER_MIDDLE); TrackFingers(hand.Ring, bodyLabel | PXCMGesture.GeoNode.Label.LABEL_FINGER_RING); TrackFingers(hand.Pinky, bodyLabel | PXCMGesture.GeoNode.Label.LABEL_FINGER_PINKY); }
public void DisplayGeoNodes(PXCMGesture.GeoNode[][] nodes) { lock(this) { if (bitmap == null) return; if (nodes == null) return; bool primaryOpen = false, secondaryOpen = false; Graphics g = Graphics.FromImage(bitmap); using (Pen red = new Pen(Color.Red, 3.0f), green = new Pen(Color.Green, 3.0f), cyan = new Pen(Color.Cyan, 3.0f)) { PXCMGesture.GeoNode node; PXCMGesture.GeoNode.Label body; int[] fingers = new int[] {0,0}; //int fing = 0; PXCMGesture.GeoNode.Label hand = PXCMGesture.GeoNode.Label.LABEL_ANY; for (int i = 0; i < 2; i++) { for (int j = 0; j < 10; j++) { node = nodes[i][j]; if (node.body <= 0) continue; float sz = (j == 0) ? 10 : ((node.radiusImage>5)?node.radiusImage:5); body = node.body; /*foreach (PXCMGesture.GeoNode.Label l in new PXCMGesture.GeoNode.Label[] { PXCMGesture.GeoNode.Label.LABEL_FINGER_THUMB, PXCMGesture.GeoNode.Label.LABEL_FINGER_INDEX, PXCMGesture.GeoNode.Label.LABEL_FINGER_MIDDLE, PXCMGesture.GeoNode.Label.LABEL_FINGER_RING, PXCMGesture.GeoNode.Label.LABEL_FINGER_PINKY }) { PXCMGesture.GeoNode.Label flippedMask = ~l; PXCMGesture.GeoNode.Label body2 = body & }*/ if ((body & PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY) != 0) { body &= ~PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY; hand = PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY; } if ((body & PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY) != 0) { body &= ~PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY; hand = PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY; } if ((node.body & PXCMGesture.GeoNode.Label.LABEL_FINGER_THUMB) != 0 || (node.body & PXCMGesture.GeoNode.Label.LABEL_FINGER_INDEX) != 0 || (node.body & PXCMGesture.GeoNode.Label.LABEL_FINGER_MIDDLE) != 0 || (node.body & PXCMGesture.GeoNode.Label.LABEL_FINGER_RING) != 0 || (node.body & PXCMGesture.GeoNode.Label.LABEL_FINGER_PINKY) != 0) { if (hand == PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_PRIMARY) fingers[0]++; else if (hand == PXCMGesture.GeoNode.Label.LABEL_BODY_HAND_SECONDARY) fingers[1]++; else Log("Unknown hand above!\n"); } //Log("Node (" + i + ", " + j + "): " + node.body + "\n"); g.DrawEllipse(j > 5 ? red : green, nodes[i][j].positionImage.x - sz / 2, nodes[i][j].positionImage.y - sz / 2, sz, sz); } // all nodes //Log(fingers[0] + " primary fingers up\n"); //Log(fingers[1] + " secondary fingers up\n"); } // both hands if (Params.Checked) { Pen pen; if (nodes[0][0].body > 0) { pen = red; if (nodes[0][0].opennessState == PXCMGesture.GeoNode.Openness.LABEL_OPEN) pen = cyan; g.DrawLine(pen, 0, bitmap.Height - 1, 0, (100 - nodes[0][0].openness) * (bitmap.Height - 1) / 100); //Log("Hand 1 is " + nodes[0][0].opennessState + "\n"); if (nodes[0][0].opennessState == PXCMGesture.GeoNode.Openness.LABEL_OPEN) primaryOpen = true; } if (nodes[1][0].body > 0) { pen = red; if (nodes[1][0].opennessState == PXCMGesture.GeoNode.Openness.LABEL_OPEN) pen = cyan; g.DrawLine(pen, bitmap.Width - 1, bitmap.Height - 1, bitmap.Width - 1, (100 - nodes[1][0].openness) * (bitmap.Height - 1) / 100); //Log("Hand 2 is " + nodes[1][0].opennessState + "\n"); if (nodes[1][0].opennessState == PXCMGesture.GeoNode.Openness.LABEL_OPEN) secondaryOpen = true; } } } // using Pens int right = -1; // which node has the right hand (0 = primary, 1 = secondary) int left = -1; // same, for left hand. If both are in the same region, this is NOT set. bool openRight = false, openLeft = false; if (nodes[0][8].body > 0 && nodes[0][8].positionWorld.x < 0 && nodes[1][8].body > 0 && nodes[1][8].positionWorld.x < 0) UpdatelblRight("Both"); else if (nodes[0][8].body > 0 && nodes[0][8].positionWorld.x < 0) { UpdatelblRight(primaryOpen ? "Primary (open)" : "Primary (closed)"); right = 0; openRight = primaryOpen; } else if (nodes[1][8].body > 0 && nodes[1][8].positionWorld.x < 0) { UpdatelblRight(secondaryOpen ? "Secondary (open)" : "Secondary (closed)"); right = 1; openRight = secondaryOpen; } else UpdatelblRight("(none)"); if (nodes[0][8].body > 0 && nodes[0][8].positionWorld.x >= 0 && nodes[1][8].body > 0 && nodes[1][8].positionWorld.x >= 0) UpdatelblLeft("Both"); else if (nodes[0][8].body > 0 && nodes[0][8].positionWorld.x >= 0) { UpdatelblLeft(primaryOpen ? "Primary (open)" : "Primary (closed)"); left = 0; openLeft = primaryOpen; } else if (nodes[1][8].body > 0 && nodes[1][8].positionWorld.x >= 0) { UpdatelblLeft(secondaryOpen ? "Secondary (open)" : "Secondary (closed)"); left = 1; openLeft = secondaryOpen; } else UpdatelblLeft("(none)"); //Log(nodes[0][8].body + " and " + nodes[1][8].body + "\n"); // Actual motion logic float x, y, z; if (right >= 0) // Is there a (single) handle on the right half of the view? { // get x, y, z of right hand's center of hand node x = nodes[right][8].positionWorld.x; y = nodes[right][8].positionWorld.y; z = nodes[right][8].positionWorld.z; if (openRight) { float filterDistance = 0.03f; int moveDist = 100; float xDelta = Math.Abs(x - rightLastX); float yDelta = Math.Abs(y - rightLastY); float zDelta = Math.Abs(z - rightLastZ); if (x < rightLastX && xDelta > filterDistance) { Log("Right moved right\n"); myAppMan.MoveXY((int)((float)moveDist * xDelta), 0); rightLastX = x; } else if (x > rightLastX && xDelta > filterDistance) { Log("Right moved left\n"); myAppMan.MoveXY(-(int)((float)moveDist * xDelta), 0); rightLastX = x; } //else // Log("Right didn't move\n"); if (y < rightLastY && yDelta > filterDistance) { myAppMan.ZoomIn(); Log("Right zoom in\n"); rightLastY = y; } else if (y > rightLastY && yDelta > filterDistance) { myAppMan.ZoomOut(); Log("Right zoom out\n"); rightLastY = y; } //else // Log("Right no zoom\n"); if (z < rightLastZ && zDelta > filterDistance) { myAppMan.MoveXY(0, (int)((float)moveDist * zDelta)); Log("Right move up\n"); rightLastZ = z; } else if (z > rightLastZ && zDelta > filterDistance) { myAppMan.MoveXY(0, -(int)((float)moveDist * zDelta)); Log("Right move down\n"); rightLastZ = z; } //else // Log("Right no Z\n"); } } g.Dispose(); } // lock }