public AbstractPlayer() { Hands = new HandCollection(); Hands.Add(new Hand() { Item = null, Position = HandPosition.Left }); Hands.Add(new Hand() { Item = null, Position = HandPosition.Right }); Sex = Life.Sex.Male; }
private void HandsController_HandsDetected(object sender, HandCollection e) { // Display the results! if (e.HandLeft != null) { // Draw contour. foreach (var point in e.HandLeft.ContourDepth) { DrawEllipse(point, Brushes.Green, 2.0); } // Draw fingers. foreach (var finger in e.HandLeft.Fingers) { DrawEllipse(finger.DepthPoint, Brushes.White, 4.0); } } if (e.HandRight != null) { // Draw contour. foreach (var point in e.HandRight.ContourDepth) { DrawEllipse(point, Brushes.Blue, 2.0); } // Draw fingers. foreach (var finger in e.HandRight.Fingers) { DrawEllipse(finger.DepthPoint, Brushes.White, 4.0); } } }
public override void Process(HandCollection handData) { var fingerCount = handData.Hands[0].FingerCount; if (twoFingersDetected == null && fingerCount == 2) { twoFingersDetected = DateTime.Now; } if (fingerCount == 1) { twoFingersDetected = null; } if (twoFingersDetected.HasValue && DateTime.Now > twoFingersDetected.Value.AddMilliseconds(100)) { if (fingerCount == 2 && !this.mouseDown) { UserInput.MouseDown(); this.mouseDown = true; } } if (fingerCount == 1 && this.mouseDown) { UserInput.MouseUp(); this.mouseDown = false; } }
void handSource_NewDataAvailable(HandCollection handData) { if (!this.Enabled || handData.Count == 0) { return; } if (this.cursorMode.HasPoint(handData)) { var pointOnScreen = this.MapToScreen(this.cursorMode.GetPoint(handData)); double newX = pointOnScreen.X; double newY = pointOnScreen.Y; if (lastPointOnScreen.HasValue) { var distance = Point.Distance2D(pointOnScreen, lastPointOnScreen.Value); if (distance < 100) { newX = lastPointOnScreen.Value.X + (newX - lastPointOnScreen.Value.X) * (distance / 100); newY = lastPointOnScreen.Value.Y + (newY - lastPointOnScreen.Value.Y) * (distance / 100); } if (distance < 10) { newX = lastPointOnScreen.Value.X; newY = lastPointOnScreen.Value.Y; } } UserInput.SetCursorPositionAbsolute((int)newX, (int)newY); lastPointOnScreen = new Point((float)newX, (float)newY, 0); this.clickMode.Process(handData); } }
private void HandsController_HandsDetected(object sender, HandCollection e) { // Display the results! foreach (Body body in bodies) { if (body.TrackingId == e.TrackingId) { if (e.HandLeft != null) { // Draw fingers. foreach (var finger in e.HandLeft.Fingers) { ColorSpacePoint center = coordinateMapper.MapCameraPointToColorSpace(body.Joints[JointType.WristLeft].Position); Point CenterPosition = new Point(center.X, center.Y); Point point = new Point(finger.ColorPoint.X, finger.ColorPoint.Y); DrawEllipse(point, Brushes.Yellow, 20.0); } } if (e.HandRight != null) { // Draw fingers. foreach (var finger in e.HandRight.Fingers) { ColorSpacePoint center = coordinateMapper.MapCameraPointToColorSpace(body.Joints[JointType.WristRight].Position); Point CenterPosition = new Point(center.X, center.Y); Point point = new Point(finger.ColorPoint.X, finger.ColorPoint.Y); DrawEllipse(point, Brushes.Yellow, 20.0); } } } } }
public void DoubleDummy() { var board = new Board() { Dealer = Seat.West, Vulnerability = Vulnerability.All, Hands = HandCollection.ParsePbn("W:KJ95.T.AT873.T98 76.AQJ9642.KJ.QJ QT8.K87.962.A654 A432.53.Q54.K732") }; var dds = Solver.MakeableContracts(board); Assert.AreEqual(0, dds[Seat.North, Denomination.Clubs].Level); Assert.AreEqual(0, dds[Seat.North, Denomination.Diamonds].Level); Assert.AreEqual(3, dds[Seat.North, Denomination.Hearts].Level); Assert.AreEqual(0, dds[Seat.North, Denomination.Spades].Level); Assert.AreEqual(1, dds[Seat.North, Denomination.NoTrumps].Level); Assert.AreEqual(0, dds[Seat.South, Denomination.Clubs].Level); Assert.AreEqual(0, dds[Seat.South, Denomination.Diamonds].Level); Assert.AreEqual(3, dds[Seat.South, Denomination.Hearts].Level); Assert.AreEqual(0, dds[Seat.South, Denomination.Spades].Level); Assert.AreEqual(1, dds[Seat.South, Denomination.NoTrumps].Level); Assert.AreEqual(1, dds[Seat.East, Denomination.Clubs].Level); Assert.AreEqual(2, dds[Seat.East, Denomination.Diamonds].Level); Assert.AreEqual(0, dds[Seat.East, Denomination.Hearts].Level); Assert.AreEqual(1, dds[Seat.East, Denomination.Spades].Level); Assert.AreEqual(0, dds[Seat.East, Denomination.NoTrumps].Level); Assert.AreEqual(1, dds[Seat.West, Denomination.Clubs].Level); Assert.AreEqual(2, dds[Seat.West, Denomination.Diamonds].Level); Assert.AreEqual(0, dds[Seat.West, Denomination.Hearts].Level); Assert.AreEqual(1, dds[Seat.West, Denomination.Spades].Level); Assert.AreEqual(0, dds[Seat.West, Denomination.NoTrumps].Level); }
public HandCollectionEnumerator(HandCollection collection) { collectionRef = collection; currentIndex = -1; currentObject = null; currentSize = collectionRef.Count; }
public HandCollection(HandCollection other) : this(EfficioRuntimePINVOKE.new_HandCollection__SWIG_1(HandCollection.getCPtr(other)), true) { if (EfficioRuntimePINVOKE.SWIGPendingException.Pending) { throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve(); } }
public HandData(HandCollection hands) : this(EfficioRuntimePINVOKE.new_HandData__SWIG_1(HandCollection.getCPtr(hands)), true) { if (EfficioRuntimePINVOKE.SWIGPendingException.Pending) { throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve(); } }
internal void Update(HandCollection handCollection) { if (stopped) { return; } this.Dispatcher.Invoke(new Action(() => { this.currentData = handCollection; if (!handCollection.IsEmpty) { var hand = handCollection.Hands.First(); if (hand.HasPalmPoint) { this.UpdateFingerCount(hand); if (this.fingerPointCount >= 1) { UpdateHandValues(hand); } } } if ((handCollection.IsEmpty || this.fingerPointCount == 0) && this.InterfaceOpacity == 100) { this.FadeOut(500); } InvalidateVisual(); })); }
private void UpdateHandTrackData(HandCollection handData) { foreach (var newHand in handData.Hands.Where(h => !this.handTracks.Any(t => t.Id == h.Id))) { this.handTracks.Add(new HandTracker(newHand)); } foreach (var handTrack in this.handTracks.ToList()) { var newHand = handData.Hands.Where(h => h.Id == handTrack.Id).FirstOrDefault(); if (newHand == null) { this.handTracks.Remove(handTrack); } else { if (!newHand.HasPalmPoint) { continue; } handTrack.SetHandData(newHand); var hoveredImage = this.images.Where(i => this.ImageContains(i, newHand.PalmPoint.Value)).LastOrDefault(); if (hoveredImage != null) { MoveImageToFront(hoveredImage); handTrack.HandleTranslation(hoveredImage, this.handLayer.ZoomFactor); } } } }
public void SetRange(int index, HandCollection values) { EfficioRuntimePINVOKE.HandCollection_SetRange(swigCPtr, index, HandCollection.getCPtr(values)); if (EfficioRuntimePINVOKE.SWIGPendingException.Pending) { throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve(); } }
//This is the active function that consistently looks for hands and dynamic gestures to execute functions. void handDataSource_NewDataAvailable(HandCollection data) { //bool variable to check if the gesture listener is active if (listen == true) { //when a hand(s) found, enter the loop for (int index = 0; index < data.Count; index++) { var hand = data.Hands[index]; //if there are two hands if (data.Count == 2) { //assign the first hand as left var leftHand = data.Hands.OrderBy(h => h.Location.X).First(); //assign the last hand as right var rightHand = data.Hands.OrderBy(h => h.Location.X).Last(); //Exit Application Gesture //if there a 5 fingers on both hands and they move away from each other then the exit function is executed. if (leftHand.FingerCount == 5 && rightHand.FingerCount == 5) { if (isSet == false) { lHndX = leftHand.PalmX; rHndX = rightHand.PalmX; isSet = true; } else if (isSet == true) { if (leftHand.PalmX < lHndX - 50 && rightHand.PalmX > rHndX + 50) { ExitGesture(); } } } //Code Mode Gesture //If there are no fingers on the left hand and there is 1 finger on the right hand, and the right hand moves from the right hand side towards the left then execute Code Mode. if (leftHand.FingerCount == 0 && rightHand.FingerCount == 1) { if (isSet == false) { rHndX = rightHand.PalmX; isSet = true; } else if (isSet == true) { if (rightHand.PalmX < rHndX - 50) { listen = false; CodeModeGesture(); } } } } } } }
//private void invalidSign() //{ // if invalid sign.... // initialState = true; // cache.Clear(); // inActiveState = false; // steadyFrameCount = 0 //} // every frame that hands are detected private void HandsController_HandsDetected(object sender, HandCollection e) { if (e.HandLeft != null) { // Draw contour. foreach (var point in e.HandLeft.ContourDepth) { DrawEllipse(point, Brushes.Green, 2.0); } // Draw fingers. foreach (var finger in e.HandLeft.Fingers) { DrawEllipse(finger.DepthPoint, Brushes.White, 4.0); } } if (e.HandRight != null) { // Draw contour. foreach (var point in e.HandRight.ContourDepth) { DrawEllipse(point, Brushes.Blue, 2.0); } // Draw fingers. foreach (var finger in e.HandRight.Fingers) { DrawEllipse(finger.DepthPoint, Brushes.White, 4.0); } } if (e.HandLeft != null && e.HandRight != null) { // both hands must exist CameraSpacePoint leftHandPosition = getContourAverage(e.HandLeft.ContourCamera); CameraSpacePoint rightHandPosition = getContourAverage(e.HandRight.ContourCamera); if (initialState) { prevPositionLeftHand = leftHandPosition; prevPositionRightHand = rightHandPosition; initialState = false; } if (isActiveState(leftHandPosition, rightHandPosition)) { doActiveState(e.HandLeft.ContourCamera, e.HandRight.ContourCamera); } else { doSteadyState(leftHandPosition, prevPositionRightHand); } } }
static Info SuitLength(HandCollection hand, Suit suit) { var info = new Info(); info.North = hand[Seat.North].SuitLength(suit); info.South = hand[Seat.South].SuitLength(suit); info.East = hand[Seat.East].SuitLength(suit); info.West = hand[Seat.West].SuitLength(suit); return(info); }
public HandCollection GetRange(int index, int count) { global::System.IntPtr cPtr = EfficioRuntimePINVOKE.HandCollection_GetRange(swigCPtr, index, count); HandCollection ret = (cPtr == global::System.IntPtr.Zero) ? null : new HandCollection(cPtr, true); if (EfficioRuntimePINVOKE.SWIGPendingException.Pending) { throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public static HandCollection Repeat(Hand value, int count) { global::System.IntPtr cPtr = EfficioRuntimePINVOKE.HandCollection_Repeat(Hand.getCPtr(value), count); HandCollection ret = (cPtr == global::System.IntPtr.Zero) ? null : new HandCollection(cPtr, true); if (EfficioRuntimePINVOKE.SWIGPendingException.Pending) { throw EfficioRuntimePINVOKE.SWIGPendingException.Retrieve(); } return(ret); }
public bool MakeGood(Hand hand, HandCollection otherHands) { var rng = RandomThreaded.Generator; if (this.Minimum > Card.CardsInSuit || this.Maximum > Card.CardsInSuit) { return(false); } int cardsNeeded = Minimum == Maximum ? Minimum : rng.Next(Minimum, Maximum + 1); int extras = cardsNeeded - hand.SuitLength(Suit); var thisSuit = Suit; while (extras != 0) { int ci; int oi; var other = otherHands[rng.Next(0, otherHands.Count)]; if (extras > 0) { ci = hand.Cards.FindIndexRandom(card => thisSuit != card.Suit); if (ci < 0) { return(false); } oi = other.Cards.FindIndexRandom(card => thisSuit == card.Suit); if (oi < 0) { continue; } --extras; } else { ci = hand.Cards.FindIndexRandom(card => thisSuit == card.Suit); if (ci < 0) { return(false); } oi = other.Cards.FindIndexRandom(card => thisSuit != card.Suit); if (oi < 0) { continue; } ++extras; } Card t = hand.Cards[ci]; hand.Cards[ci] = other.Cards[oi]; other.Cards[oi] = t; } return(true); }
private void handDataSource_NewDataAvailable(HandCollection data) { if (data.IsEmpty) { ReportNoTouch(this.touchDevices.Values); return; } var touchedDevices = this.ReportTouches(data); this.ReportNoTouch(this.touchDevices.Values.Except(touchedDevices)); }
public override void Process(HandCollection handData) { if (!mouseDown && handData.Count >= 2) { this.MouseDown(); this.mouseDown = true; } if (mouseDown && handData.Count < 2) { this.MouseUp(); this.mouseDown = false; } }
private void handDataSource_NewDataAvailable(HandCollection data) { if (data.IsEmpty || !data.Hands.First().HasFingers) { this.Dispatcher.Invoke(new Action(() => { foreach (var line in mainCanvas.Children.OfType <Line>().ToList()) { mainCanvas.Children.Remove(line); } })); } }
public bool MakeGood(Hand hand, HandCollection otherHands) { var rng = RandomThreaded.Generator; if (this.Minimum > 10 || this.Maximum > 10) { return(false); } Suit thisSuit = Suit; while (!IsTrue(hand)) { int pointsNeeded = Minimum == Maximum ? Minimum : rng.Next(Minimum, Maximum + 1); int delta = pointsNeeded - HcpEvaluator.GetHcp(hand, thisSuit); int ci; int oi; var other = otherHands[rng.Next(0, otherHands.Count)]; if (delta > 0) { ci = hand.Cards.FindIndexRandom(card => !(card.Suit == thisSuit && card.IsBiddingHonour)); if (ci < 0) { return(false); } oi = other.Cards.FindIndexRandom(card => card.Suit == thisSuit && card.IsBiddingHonour); if (oi < 0) { continue; } } else { ci = hand.Cards.FindIndexRandom(card => card.Suit == thisSuit && card.IsBiddingHonour); if (ci < 0) { return(false); } oi = other.Cards.FindIndexRandom(card => !(card.Suit == thisSuit && card.IsBiddingHonour)); if (oi < 0) { continue; } } Card t = hand.Cards[ci]; hand.Cards[ci] = other.Cards[oi]; other.Cards[oi] = t; } return(true); }
void handDataSource_NewDataAvailable(HandCollection data) { if (data.Count == 1) { var hand = data.Hands.First(); if (hand.FingerCount >= 4) { this.StopMode(); } if (hand.FingerCount == 1) { this.Select(hand.FingerPoints.First()); } } if (data.Count == 2) { var leftHand = data.Hands.OrderBy(h => h.Location.X).First(); var rightHand = data.Hands.OrderBy(h => h.Location.X).Last(); if (leftHand.FingerCount == 2 && rightHand.FingerCount == 2) { SurfaceMode(data); } else if (leftHand.FingerCount >= 4 && rightHand.FingerCount == 0) { StopMode(); } else if (leftHand.FingerCount >= 4 && rightHand.FingerCount >= 1) { TimeShiftMode(rightHand); } else if (rightHand.FingerCount == 0 && leftHand.FingerCount == 0) { isNew = true; DisabeMoveMode(); } else if (leftHand.FingerCount == 0) { DisabeMoveMode(); } else if (rightHand.FingerCount >= 4 && leftHand.FingerCount == 1) { CancelMode(leftHand); } } else { isNew = true; } }
public bool MakeGood(Hand hand, HandCollection otherHands) { restart: foreach (var rule in BalancedEvaluator.Rules) { if (rule.IsTrue(hand)) { continue; } rule.MakeGood(hand, otherHands); goto restart; } return(true); }
private void SurfaceMode(HandCollection data) { this.Dispatcher.Invoke(new Action(() => { if (isNew) { if (this.selectedVideo != null) { this.selectedVideo.IsSelected = false; } this.selectedVideo = new VideoSurface(this.videoPaths[this.videoPointer++]); this.videos.Add(this.selectedVideo); this.selectedVideo.RequestRemove += new EventHandler(videoSurface_RequestRemove); if (videoPointer >= this.videoPaths.Length) { videoPointer = 0; } this.viewPort.Children.Add(selectedVideo.ModelVisual3D); this.selectedVideo.Play(); this.selectedVideo.Opacity = 0.8; isNew = false; } if (selectedVideo.IsPaused) { selectedVideo.Play(); } var points = new List <CCT.NUI.Core.Point>(); var hand1 = data.Hands[0]; var hand2 = data.Hands[1]; points.Add(hand1.FingerPoints[0].Fingertip); points.Add(hand1.FingerPoints[1].Fingertip); points.Add(hand2.FingerPoints[0].Fingertip); points.Add(hand2.FingerPoints[1].Fingertip); points = points.OrderBy((p) => p.X).ToList(); var leftPoints = points.Take(2).ToList(); var rightPoints = points.Skip(2).Take(2).ToList(); leftPoints = leftPoints.OrderByDescending(p => p.Y).ToList(); rightPoints = rightPoints.OrderByDescending(p => p.Y).ToList(); this.selectedVideo.SetPoints(Map(leftPoints[0]), Map(rightPoints[0]), Map(rightPoints[1]), Map(leftPoints[1])); })); moveMode = false; }
void handDataSource_NewDataAvailable(HandCollection data) { if (data.IsEmpty) { return; } var handData = data.Hands.First(); if (!handData.HasContour) { this.View.Dispatcher.Invoke(new Action(this.View.Hide)); return; } this.View.Dispatcher.BeginInvoke(new Action(() => this.UpdateView(handData))); }
private IList <KinectTouchDevice> ReportTouches(HandCollection data) { var touchedDevices = new List <KinectTouchDevice>(); foreach (var hand in data.Hands) { foreach (var fingerPoint in hand.FingerPoints) { var device = this.GetDevice(hand.Id * handMultiplier + fingerPoint.Id); var pointOnPresentationArea = this.MapToPresentationArea(fingerPoint, new Size(this.handDataSource.Size.Width, this.handDataSource.Height)); device.Touch(pointOnPresentationArea); touchedDevices.Add(device); } } return(touchedDevices); }
void handDataSource_NewDataAvailable(HandCollection data) { for (int index = 0; index < data.Count; index++) { var hand = data.Hands[index]; // Console.WriteLine(string.Format("Fingers on hand {0}: {1}", index, hand.FingerCount)); //HINT : the current contet when running is on a separate thread, need to use begininvoke or a backgroundworker to change the UItext //uncomment the following 1 line, and get it working if you can. //updateHandLabels(data.Count, hand.FingerCount); //offloaded to a separate method. //handLabel.Text = "Hands: " + data.Count; //fingerLabel.Text = "Fingers: " + hand.FingerCount; } }
public override void Process(HandCollection handData) { var fingerCount = handData.Hands[0].FingerCount; if (fingerCount <= 1 && !this.mouseDown) { UserInput.MouseDown(); this.mouseDown = true; } if (fingerCount >= 2 && this.mouseDown) { UserInput.MouseUp(); this.mouseDown = false; } }
private void HandsController_HandsDetected(object sender, HandCollection e) { //// Display the results! //if (e.HandLeft != null) //{ // // Draw contour. // foreach (var point in e.HandLeft.ContourDepth) // { // DrawEllipse(point, Brushes.Green, 2.0); // } // // Draw fingers. // foreach (var finger in e.HandLeft.Fingers) // { // DrawEllipse(finger.DepthPoint, Brushes.White, 4.0); // } //} if (e.HandRight != null) { HandsDetected = true; // Draw contour. foreach (var point in e.HandRight.ContourDepth) { if (recording) { DrawEllipse(point, Brushes.Red, 2.0); } else { DrawEllipse(point, Brushes.Blue, 2.0); } } // Draw fingers. //foreach (var finger in e.HandRight.Fingers) //{ // DrawEllipse(finger.DepthPoint, Brushes.Red, 4.0); //} } else { HandsDetected = false; } }
void handDataSource_NewDataAvailable(HandCollection data) { // for each frame, count number of fingers (resultfinger), if no hand found is 0 for (int index = 0; index < data.Count; index++) { var hand = data.Hands[index]; resultfinger = hand.FingerCount; if (hand.HasPalmPoint == true) { palm = 1; } else { palm = 0; } this.element.Update(data); } }
public Point GetPoint(HandCollection handData) { return handData.Hands.First().Location; }
public bool HasPoint(HandCollection handData) { return handData.Count > 0; }
void handSource_NewDataAvailable(HandCollection handData) { if (!this.Enabled || handData.Count == 0) { return; } if(this.cursorMode.HasPoint(handData)) { var pointOnScreen = this.MapToScreen(this.cursorMode.GetPoint(handData)); double newX = pointOnScreen.X; double newY = pointOnScreen.Y; if (lastPointOnScreen.HasValue) { var distance = Point.Distance2D(pointOnScreen, lastPointOnScreen.Value); if (distance < 100) { newX = lastPointOnScreen.Value.X + (newX - lastPointOnScreen.Value.X) * (distance / 100); newY = lastPointOnScreen.Value.Y + (newY - lastPointOnScreen.Value.Y) * (distance / 100); } if (distance < 10) { newX = lastPointOnScreen.Value.X; newY = lastPointOnScreen.Value.Y; } } UserInput.SetCursorPositionAbsolute((int)newX, (int)newY); lastPointOnScreen = new Point((float)newX, (float)newY, 0); this.clickMode.Process(handData); } }
public Point GetPoint(HandCollection handData) { return this.trackingClusterDataSource.TrackingPoint.GetValueOrDefault(); }
public Player(string name,int number) { this.Number = number; this.name = name; this.hand = new HandCollection(); }
public abstract void Process(HandCollection handData);
public Point GetPoint(HandCollection handData) { return handData.Hands.First().PalmPoint.Value; }
public bool HasPoint(HandCollection handData) { return handData.Count > 0 && handData.Hands.First().HasPalmPoint; }
public bool HasPoint(HandCollection handData) { return this.trackingClusterDataSource.TrackingPoint.HasValue; }
public bool HasPoint(HandCollection handData) { var fingerCount = handData.Hands.First().FingerCount; return handData.Count > 0 && fingerCount > 0 && fingerCount <= 2; }