void clickSlider_PrimaryPointUpdate(object sender, HandEventArgs e) { // we want the slider to "drift" and follow the hand position, so that it always feels responsive Point3D clickSliderCenter = clickSlider.Center; float halfSliderSize = clickSlider.SliderSize * 0.5f; // hand is in front of slider if (e.Hand.Position.Z < (clickSliderCenter.Z - halfSliderSize)) { // move slider towards sensor clickSliderCenter.Z = e.Hand.Position.Z + halfSliderSize; } // hand is behind the slider else if (e.Hand.Position.Z > (clickSliderCenter.Z + halfSliderSize)) { // move slider away from sensor clickSliderCenter.Z = e.Hand.Position.Z - halfSliderSize; } // hand is within slider range, but we aren't clicked yet else if (!IsClicked) { // "drift" the slider to the comfortable 0.7 position, that way selection is never too far away // (move the center of the slider to 0.2 closer to the sensor than current hand position) float deltaZ = (e.Hand.Position.Z - (clickSlider.SliderSize * 0.2f)) - clickSliderCenter.Z; clickSliderCenter.Z += (deltaZ * 0.02f); } clickSlider.Center = clickSliderCenter; }
void pointCtrl_PointCreate(object sender, HandEventArgs e) { // Console.WriteLine("Created..\n"); handPoint = depthGen.ConvertRealWorldToProjective(e.Hand.Position); handPoint = e.Hand.Position; handPoint.Y = -handPoint.Y; // handPoint = depthGen.ConvertProjectiveToRealWorld(e.Hand.Position); HandPointContact hdc = new HandPointContact(e.Hand.ID, (int)((handPoint.X * scrWidth) / xRes), (int)(((handPoint.Y) * scrHeight) / yRes), Multitouch.Contracts.ContactState.Removed); hdc.RowPoint = handPoint; hdc.prev_RowPoint = handPoint; hdc.OriginPoint = new System.Windows.Point(hdc.RowPoint.X, hdc.RowPoint.Y); hdc.timestamp = e.Hand.Time; // HandPointContact hdc = new HandPointContact(e.Hand.ID, (int)(handPoint.X ), (int)((handPoint.Y) ), Multitouch.Contracts.ContactState.New); HandPointBuffer.Add(hdc); for (int i = 0; i < 5; i++) { pbuffer[i] = new Point((int)hdc.Position.X, (int)hdc.Position.Y); point_counter = 1; } inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Removed); pointCollections.Add(new PointStatus(hdc)); PointStatus pt = pointCollections[hdc.Id]; Console.WriteLine("Created" + e.Hand.ID.ToString() + " Hello Time:\n" + e.Hand.Time.ToString()); }
void myControl_PrimaryPointUpdate(object sender, HandEventArgs e) { Vector3 pos = new Vector3(e.Hand.Position.X, e.Hand.Position.Y, -e.Hand.Position.Z); Vector3 focusPoint = new Vector3(SessionManager.FocusPoint.X, SessionManager.FocusPoint.Y, -SessionManager.FocusPoint.Z); transform.position = (pos - focusPoint) * Scale; }
void mainSlider_PrimaryPointUpdate(object sender, HandEventArgs e) { // drift the slider when scrolling, so its always responsive to stop scrolling /*if (scrolling) * { * Vector3 currentCenter = new Vector3(mainSlider.Center.X, mainSlider.Center.Y, mainSlider.Center.Z); * Vector3 currentHandPosition = new Vector3(e.Hand.Position.X, e.Hand.Position.Y, e.Hand.Position.Z); * * Vector3 distance = currentCenter - currentHandPosition; * if (distance.magnitude > */ }
void pointCtrl_PointUpdate(object sender, HandEventArgs e) { lock (this) { Point3D updatedhandPoint = depthGen.ConvertRealWorldToProjective(e.Hand.Position); updatedhandPoint = e.Hand.Position; updatedhandPoint.Y = -updatedhandPoint.Y; // Console.WriteLine("x:"+ updatedhandPoint.X +" y:"+updatedhandPoint.Y ); handPoint = updatedhandPoint; for (int i = 0; i < HandPointBuffer.Count; i++) { HandPointContact hdc = HandPointBuffer[i] as HandPointContact; if (hdc.Id == e.Hand.ID) { relativemotion(updatedhandPoint, hdc); break; } } } }
void pointCtrl_PointCreate(object sender, HandEventArgs e) { // Console.WriteLine("Created..\n"); handPoint = depthGen.ConvertRealWorldToProjective(e.Hand.Position); handPoint = e.Hand.Position; handPoint.Y = -handPoint.Y; // handPoint = depthGen.ConvertProjectiveToRealWorld(e.Hand.Position); HandPointContact hdc = new HandPointContact(e.Hand.ID, (int)((handPoint.X * scrWidth) / xRes), (int)(((handPoint.Y) * scrHeight) / yRes), Multitouch.Contracts.ContactState.Removed); hdc.RowPoint = handPoint; hdc.prev_RowPoint = handPoint; hdc.OriginPoint =new System.Windows.Point(hdc.RowPoint.X,hdc.RowPoint.Y); hdc.timestamp = e.Hand.Time; // HandPointContact hdc = new HandPointContact(e.Hand.ID, (int)(handPoint.X ), (int)((handPoint.Y) ), Multitouch.Contracts.ContactState.New); HandPointBuffer.Add(hdc); for (int i = 0; i < 5; i++) { pbuffer[i] = new Point((int)hdc.Position.X,(int)hdc.Position.Y); point_counter = 1; } inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Removed); pointCollections.Add(new PointStatus(hdc)); PointStatus pt = pointCollections[hdc.Id]; Console.WriteLine("Created" + e.Hand.ID.ToString() + " Hello Time:\n" + e.Hand.Time.ToString()); }
void pointControl_PointUpdate(object sender, HandEventArgs e) { Console.WriteLine("Point Updated"); handPoint = DepthGenerator.ConvertRealWorldToProjective(e.Hand.Position); }
/// callback when the point is updated /// @param sender the object that sent the event /// @param e the event arguments void myControl_PrimaryPointUpdateSmooth(object sender, HandEventArgs e) { m_lastFrameCurPoint.UpdatePoint(e.Hand.Position, e.Hand.Confidence); m_curPoint = e.Hand; }
void HandleSteadyDetectorPrimaryPointUpdate(object sender, HandEventArgs e) { currentHandY = e.Hand.Position.Y; }
void MyCanvas_PrimaryPointUpdate(object sender, HandEventArgs e) { Console.WriteLine("Point updated"); Console.WriteLine(e.Hand.Position.X); }
void handTracker_HandCaptured(object sender, HandEventArgs e) { Dispatcher.BeginInvoke((Action)delegate() { if (!IsEnabled || isActive /*|| spaceProvider.FingerTracker.OnSurfaceFingers.Count() > 0*/) { return; } if (e.Position.Y > BOTTOM_CROP) { return; } handUpdateRecords.Add(e.ID, new HandUpdateRecord(0, e.Position, 0, HandStage.Free)); //Trace.WriteLine("Hand " + e.ID.ToString() + " captured"); }, null); }
void handTracker_HandLost(object sender, HandEventArgs e) { Dispatcher.BeginInvoke((Action)delegate() { if (!IsEnabled) { return; } if (isActive && e.ID == capturedHandId) { deactivate(); } else { handUpdateRecords.Remove(e.ID); } }, null); }
void handTracker_HandMove(object sender, HandEventArgs e) { Dispatcher.BeginInvoke((Action)delegate() { if (!IsEnabled) { return; } if (!isActive) { if (!handUpdateRecords.ContainsKey(e.ID)) { return; } var rec = handUpdateRecords[e.ID]; switch (rec.Stage) { case HandStage.Free: if ((e.Position - rec.Position).LengthSquared <= MOVING_THRESHOLD * MOVING_THRESHOLD) { //Trace.WriteLine("Hand " + e.ID + ": " + rec.Item1.ToString()); rec.Position = e.Position; rec.FingerCount = getHoveringFingerCount(e.Position); //Trace.WriteLine("Free: " + rec.FingerCount.ToString() + " fingers. "); if (rec.FingerCount > GRAB_FINGER_COUNT) { rec.FrameCount++; } if (rec.FrameCount >= HAND_UPDATE_COUNT) { rec.Stage = HandStage.Stopping; } } else { rec.FrameCount = 0; rec.Position = e.Position; //Trace.WriteLine("Hand " + e.ID + " reset. "); } break; case HandStage.Stopping: rec.FrameCount++; rec.Position = e.Position; rec.FingerCount = getHoveringFingerCount(rec.Position); //Trace.WriteLine("Stopping: " + rec.FingerCount.ToString() + " fingers."); if (rec.FingerCount <= GRAB_FINGER_COUNT) { rec.Stage = HandStage.Grabbing; } break; case HandStage.Grabbing: rec.FrameCount++; rec.Position = e.Position; rec.FingerCount = getHoveringFingerCount(rec.Position); //Trace.WriteLine("Grabbing: " + rec.FingerCount.ToString() + " fingers."); if (rec.FingerCount >= STRETCH_FINGER_COUNT) { rec.Stage = HandStage.Stretch; activate(e.ID, e.Position); } break; } } /*else if (spaceProvider.FingerTracker.OnSurfaceFingers.Count() > 0) { deactivate(e); }*/ else if (e.ID == capturedHandId) { int fingerCount = getHoveringFingerCount(e.Position); //Trace.WriteLine("Working: " + fingerCount.ToString() + " fingers."); if (fingerCount < STRETCH_FINGER_COUNT) { deactivate(e); } else { double halfSec = 180.0 / buttons.Count; double angle = Math.Atan2(wheelCenter.Y - e.Position.Y, e.Position.X - wheelCenter.X) * 180.0 / Math.PI; if (angle < 0) { angle += 360; } //Trace.WriteLine("Angle = " + angle); int index = (int)((angle + halfSec) / (2 * halfSec)) % buttons.Count; if (index != currentIndex) { double selectedAngle = -index * 2 * halfSec - halfSec; selectionSector.RenderTransform = new RotateTransform(selectedAngle); currentIndex = index; //Trace.WriteLine("Index = " + index); } double ratio = (e.Position - wheelCenter).Length / CIRCLE_RADIUS; selectionSector.Opacity = ratio; if (ratio > 1.0) { //Trace.WriteLine("Index " + index + " activated!"); deactivate(e); if (ButtonSelected != null) { ButtonSelected(this, new HandWheelButtonEventArgs(index)); } } } } }, null); }
private void RaiseHandRemovedEvent(HandEventArgs e) { if (HandRemoved != null) HandRemoved(this, e); }
private void RaiseHandPresentEvent(HandEventArgs e) { if (HandPresent != null) HandPresent(this, e); }
private void OnHandRemoved(object sender, HandEventArgs e) { RaiseHandRemovedEvent(e); }
private void OnHandPresent(object sender, HandEventArgs e) { RaiseHandPresentEvent(e); }
private void deactivate(HandEventArgs e) { deactivate(); handUpdateRecords.Add(e.ID, new HandUpdateRecord(0, e.Position, 0, HandStage.Free)); }
void MyBox_PrimaryPointUpdate(object sender, HandEventArgs e) { //Console.WriteLine("Point Updated" + e.Hand.Position.ToString()); this.currentPoint = e.Hand.Position; Update(e.Hand.Position, "locationupdate"); }
private void pointControl_PrimaryPointUpdate(object sender, HandEventArgs e) { this.point = this.depthGenerator.ConvertRealWorldToProjective(e.Hand.Position); }
void MyBox_PrimaryPointUpdate(object sender, HandEventArgs e) { //Console.WriteLine("Point Updated" + e.Hand.Position.ToString()); Update(e.Hand.Position); }
void waveDetector_PointUpdate(object sender, HandEventArgs e) { Console.WriteLine("{0} - {1}: ({2}, {3}, {4}) [{5}]", DateTimeToUnixTimestamp(DateTime.Now), e.Hand.ID, e.Hand.Position.X, e.Hand.Position.Y, e.Hand.Position.Z, e.Hand.Time); Dictionary<String, Object> d = new Dictionary<String, Object>(); d.Add("event", "move"); d.Add("ts", DateTimeToUnixTimestamp(DateTime.Now)); Dictionary<String, Object> dataDict = new Dictionary<String, Object>(); dataDict.Add("hand_id", e.Hand.ID); dataDict.Add("x", e.Hand.Position.X); dataDict.Add("y", e.Hand.Position.Y); dataDict.Add("z", e.Hand.Position.Z); dataDict.Add("time", e.Hand.Time); d.Add("args", dataDict); String dataString = JsonConvert.SerializeObject(d); this.zmq_publisher.Send(dataString, Encoding.UTF8); }