static private OpenNI.Point3D Change(DepthMetaData depthMD, int[,] backgroundDepthMD) { OpenNI.Point3D newF = new OpenNI.Point3D(0, 0, 0); bool skip = false; int checkUp = 0; for (int j = depthMD.FullYRes - 10; 10 < j; j--) { for (int i = 0; depthMD.FullXRes - 40 > i; i++) { if (Math.Abs(depthMD[i, j] - backgroundDepthMD[i, j]) > 50) { checkUp = j - 50; if (checkUp >= depthMD.FullYRes || checkUp <= 0) { skip = true; } if (skip == false && (Math.Abs(depthMD[i, checkUp] - backgroundDepthMD[i, checkUp]) > 50)) { //Console.WriteLine("change at {0},{1} size {2}", i, j, Math.Abs(depthMD[i, checkUp] - backgroundDepthMD[i, checkUp])); newF = new OpenNI.Point3D(i, j, depthMD[i, j]); j = 9; i = depthMD.FullXRes; } skip = false; } } } return(newF); }
public HandTouchingFOVEdgeEventArgs(UserID id, Point3D position, float time, Direction dir) { this.id = id; this.position = position; this.time = time; this.dir = dir; }
/// <summary> /// Substract point1 from point2 and creates a new point. /// </summary> /// <param name="point1"></param> /// <param name="point2"></param> /// <returns>Point2 - point1</returns> public static Point3D CreateDirectionVector(Point3D point1, Point3D point2) { Point3D res = new Point3D(); res.X = point2.X - point1.X; res.Y = point2.Y - point1.Y; res.Z = point2.Z - point1.Z; return res; }
static public float Distance(Plane3D wall, OpenNI.Point3D newF) { float d, d_u, d_d; float a = wall.Normal.X; float b = wall.Normal.Y; float c = wall.Normal.Z; float x_p = wall.Point.X; float y_p = wall.Point.Y; float z_p = wall.Point.Z; float x_0 = (float)newF.X; float y_0 = (float)newF.Y; float z_0 = (float)newF.Z; d_u = (float)Math.Abs(a * (x_0 - x_p) + b * (y_0 - y_p) + c * (z_0 - z_p)); d_d = (float)Math.Sqrt(a * a + b * b + c * c); return(d = d_u / d_d); }
// こちらのページを参考にしました // http://net2.cocolog-nifty.com/blog/2009/11/post-8792.html bool CrossHitCheck(Point3D a1, Point3D a2, Point3D b1, Point3D b2) { // 外積:axb = ax*by - ay*bx // 外積と使用して交差判定を行なう double v1 = (a2.X - a1.X) * (b1.Y - a1.Y) - (a2.Y - a1.Y) * (b1.X - a1.X); double v2 = (a2.X - a1.X) * (b2.Y - a1.Y) - (a2.Y - a1.Y) * (b2.X - a1.X); double m1 = (b2.X - b1.X) * (a1.Y - b1.Y) - (b2.Y - b1.Y) * (a1.X - b1.X); double m2 = (b2.X - b1.X) * (a2.Y - b1.Y) - (b2.Y - b1.Y) * (a2.X - b1.X); // +-,-+だったら-値になるのでそれぞれを掛けて確認する if ((v1 * v2 <= 0) && (m1 * m2 <= 0)) { return true; // 2つとも左右にあった } else { return false; } }
// 骨格の線を引く void DrawLine(int player, SkeletonJoint eJoint1, SkeletonJoint eJoint2) { // 各箇所の座標を取得する SkeletonJointPosition joint1 = skelton.GetSkeletonJointPosition(player, eJoint1); SkeletonJointPosition joint2 = skelton.GetSkeletonJointPosition(player, eJoint2); if (joint1.Confidence < 0.5 || joint2.Confidence < 0.5) { return; } // 現実の座標から画面の座標に変換する Point3D[] pt = new Point3D[] { joint1.Position, joint2.Position }; pt = depth.ConvertRealWorldToProjective(pt); Graphics g = Graphics.FromImage(bitmap); g.DrawLine(pen, pt[0].X, pt[0].Y, pt[1].X, pt[1].Y); }
/// <summary> /// Parameterized class constructor /// </summary> /// <param name="key">the string that will be used to identify this class object</param> /// <summary> /// set method for flag 'isDone' /// </summary> /// <summary> /// getter for the fingerTips array list /// </summary> /// <returns>returns a list containing the number of finger tips detected</returns> /// <summary> /// invoked by GestureManager to check detection /// </summary> /// <param name="clipping">clipping of the depth map containing hand point</param> /// <returns>true / false if gesture is detected</returns> public int isDetected(ref byte[,] clipping, Point3D handPoint) { isDone = false; int size = (int)Math.Sqrt(clipping.Length); //get the size of the clip int center = size / 2; //get the center Contour<Point> hand = extract_hand(clipping); //extract the hand contour from this clip MemStorage st = new MemStorage(); MemStorage cmst=new MemStorage();//general purpose storage if (hand != null) //if hand contour extracted was not null, do this { /*Step 1 - Distance calculation of all contour points from center*/ Double[] dis = new Double[hand.Total]; //this array will store the distance from the center of all the contour points for (int i = 0; i < hand.Total; i++) //this loop will calculate those distances { Point pt = new Point(); pt.X = hand[i].X - center; pt.Y = hand[i].Y - center; double d = Math.Sqrt(pt.X * pt.X + pt.Y * pt.Y); //calculating distance of a contour point from center dis[i] = d; //store this value in the array } /*Step 2 - determining local maxima and minima points*/ int[] max = new int[20]; //this array will store the local maxima points int[] min = new int[20]; //this array will store the local minima points int mincount = 0; //total number of local minima points int maxcount = 0; //total number of local maxima points find_peak(dis, 5, ref min, ref max, ref mincount, ref maxcount);//find the local maxima and minima in the clip and store them in the vars declared above if (mincount <=3 && maxcount <=3) { return 2; //close hand } else { return 1; //open hand } } return 0; //unknown }
// 腕の交差点を描画する private void DrawCrossPoint(int player) { Point3D[] parts = new Point3D[4] { GetJointPosition(player, SkeletonJoint.LeftElbow).Position, GetJointPosition(player, SkeletonJoint.LeftHand).Position, GetJointPosition(player, SkeletonJoint.RightElbow).Position, GetJointPosition(player, SkeletonJoint.RightHand).Position, }; // 腕が交差している場合に、交差している座標を表示する bool isCross = CrossHitCheck(parts[0], parts[1], parts[2], parts[3]); if (isCross) { parts = depth.ConvertRealWorldToProjective(parts); Point3D point = GetCrossPoint(parts[0], parts[1], parts[2], parts[3]); Graphics g = Graphics.FromImage(bitmap); g.DrawEllipse(new Pen(Color.Red, 10), new Rectangle(new Point((int)point.X, (int)point.Y), new Size(10, 10))); } }
public void DrawOrientation(ref WriteableBitmap image, int id, UserGenerator userGenerator, SkeletonJoint joint, Point3D corner) { SkeletonJointOrientation orientation = new SkeletonJointOrientation(); SkeletonJointPosition position = new SkeletonJointPosition(); position = userGenerator.SkeletonCapability.GetSkeletonJointPosition(id, joint); orientation = userGenerator.SkeletonCapability.GetSkeletonJointOrientation(id, joint); if (position.Confidence != 1 && orientation.Confidence != 1) { return; } SkeletonJointPosition v1 = new SkeletonJointPosition(); SkeletonJointPosition v2 = new SkeletonJointPosition(); v1.Confidence = v2.Confidence = 1; v1.Position = position.Position; v2.Position = new Point3D(v1.Position.X + 100 * orientation.X1, v1.Position.Y + 100 * orientation.Y1, v1.Position.Z + 100 * orientation.Z1); DrawTheLine(ref image, ref v1, ref v2); v1.Position = position.Position; v2.Position = new Point3D(v1.Position.X + 100 * orientation.X2, v1.Position.Y + 100 * orientation.Y2, v1.Position.Z + 100 * orientation.Z2); DrawTheLine(ref image, ref v1, ref v2); v1.Position = position.Position; v2.Position = new Point3D(v1.Position.X + 100 * orientation.X3, v1.Position.Y + 100 * orientation.Y3, v1.Position.Z + 100 * orientation.Z3); DrawTheLine(ref image, ref v1, ref v2); }
public Point3D[] ConvertRealWorldToProjective(Point3D[] realWorldPoints) { Point3D[] projective = new Point3D[realWorldPoints.Length]; ConvertRealWorldToProjective(realWorldPoints, projective); return projective; }
public Point3D ConvertProjectiveToRealWorld(Point3D projectivePoint) { Point3D[] projectivePoints = new Point3D[1]; projectivePoints[0] = projectivePoint; return ConvertProjectiveToRealWorld(projectivePoints)[0]; }
private bool FirstAboveSecond(OpenNI.Point3D p0, OpenNI.Point3D p1) { return(p0.Y - p1.Y > 0); }
private void checkUserGestures(int id) { SkeletonJointPosition head = new SkeletonJointPosition(); SkeletonJointPosition leftHand = new SkeletonJointPosition(); SkeletonJointPosition rightHand = new SkeletonJointPosition(); SkeletonJointPosition leftShoulder = new SkeletonJointPosition(); SkeletonJointPosition rightShoulder = new SkeletonJointPosition(); head = userGenerator.SkeletonCapability.GetSkeletonJointPosition(id, SkeletonJoint.Head); leftHand = userGenerator.SkeletonCapability.GetSkeletonJointPosition(id, SkeletonJoint.LeftHand); rightHand = userGenerator.SkeletonCapability.GetSkeletonJointPosition(id, SkeletonJoint.RightHand); leftShoulder = userGenerator.SkeletonCapability.GetSkeletonJointPosition(id, SkeletonJoint.LeftShoulder); rightShoulder = userGenerator.SkeletonCapability.GetSkeletonJointPosition(id, SkeletonJoint.RightShoulder); OpenNI.Point3D headPoint = head.Position; OpenNI.Point3D leftPoint = leftHand.Position; OpenNI.Point3D rightPoint = rightHand.Position; Ray3D leftPointer = new Ray3D(headPoint.X, headPoint.Y, headPoint.Z, leftPoint.X, leftPoint.Y, leftPoint.Z); Ray3D rightPointer = new Ray3D(headPoint.X, headPoint.Y, headPoint.Z, rightPoint.X, rightPoint.Y, rightPoint.Z); lock (animationLock) { raysToBeAnimated[0] = leftPointer; raysToBeAnimated[1] = rightPointer; } Console.Write("Left vector: " + leftPointer); Console.Write("Right vector: " + rightPointer); if (VerticallyClose(leftPoint, rightPoint)) { // Handle dimming. if (FirstAboveSecond(leftPoint, headPoint) && FirstAboveSecond(rightPoint, headPoint)) { Console.Write("Beginning dim down!"); dimmingDown = true; dimmingStartY = leftPoint.Y; } else if (dimmingDown) { int dimPercent = (int)((dimmingStartY - leftPoint.Y) / TOTAL_DIMMING_DISTANCE); if (dimPercent < 0) { dimPercent = 0; } else if (dimPercent > 100) { dimPercent = 100; } Device.dimAllToPercent(dimPercent); } else if (VerticallyClose(leftPoint, leftShoulder.Position) && VerticallyClose(leftShoulder.Position, rightShoulder.Position) && VerticallyClose(rightShoulder.Position, rightPoint)) { Console.Write("Beginning dim up!"); dimmingUp = true; dimmingStartY = leftPoint.Y; } else if (dimmingUp) { int dimPercent = (int)((leftPoint.Y - dimmingStartY) / TOTAL_DIMMING_DISTANCE); if (dimPercent < 0) { dimPercent = 0; } else if (dimPercent > 100) { dimPercent = 100; } Device.dimAllToPercent(dimPercent); } } else { // Allow pointing. dimmingDown = false; dimmingUp = false; } if (!dimmingUp && !dimmingDown) { foreach (Device d in devices) { if (leftPointer.closeTo(d.position) || rightPointer.closeTo(d.position)) { d.isInFocus(); } } } Console.Write("============================="); }
/*void gestureGenerator_GestureRecognized(object sender, GestureRecognizedEventArgs e) { Trace.WriteLine("Gesture recognized"); //gestureGenerator.RemoveGesture(e.Gesture); handsGenerator.StartTracking(e.EndPosition); }*/ public void StartTrackingAt(Point3D position) { handsGenerator.StopTrackingAll(); handsGenerator.StartTracking(position); }
//Unused .. void smoothenCursorMovement(Point3D updatedhandPoint,HandPointContact hdc) { /* if (is_steady == 1) { if (steady_counter > 10) { } is_push_allow_counter = 0; is_push_allow = 1; is_steady = 0; steady_counter++; }*/ System.Windows.Point center = hdc.OriginPoint; int deskHeight = scrHeight; int deskWidth = scrWidth; int h_x = 0; int h_y = 0; double power = 1.7; PointStatus pt = pointCollections[hdc.Id]; h_x = (int)(updatedhandPoint.X - (center.X - 100)); h_y = (int)(updatedhandPoint.Y - (center.Y - 100)); if (h_x < 0) h_x = 0; if (h_y < 0) h_y = 0; int x = 0; int y = 0; x = h_x * deskWidth / 200; y = h_y * deskHeight / 200; if (is_steady == 1) { // Console.WriteLine("Steady..."); } /* if (pt.is_non_steady == true) { double diffx = updatedhandPoint.X - hdc.Position.X; double diffy = updatedhandPoint.Y - hdc.Position.Y; if (Math.Abs(diffx) < 5 && Math.Abs(diffy) < 5) { return; } else { pt.is_non_steady = false; } }*/ hdc.RowPoint = updatedhandPoint; /* if (pt.is_non_steady == true ) { pt.nonsteady_counter++; // System.Console.WriteLine(pt.nonsteady_counter); // pt.SetColor(Brushes.BlueViolet); if (pt.nonsteady_counter > 10) //stop looking for gesture { pt.nonsteady_counter = 0; // pt.gesture_start = false; pt.is_non_steady = false; //System.Console.WriteLine("Grab Session Ended"); if (pt.is_clicked == true) { pt.SetColor(Brushes.Red); } else { pt.SetColor(Brushes.Green); } } if(pt.nonsteady_counter<5) { return; } if (pt.nonsteady_counter > 7 && pt.nonsteady_counter < 10) { x = (x + pt.Location.X )/ 2; y = (y + pt.Location.Y )/ 2; } }*/ /* clipHandFromDepthMap(updatedhandPoint); if (is_steady == 1) { } int status = openpalm.isDetected(clipping, updatedhandPoint); if (status == 1) { //System.Console.WriteLine("open Palm"); } else if (status == 2) { // System.Console.WriteLine("Close Plam"); } else { System.Console.WriteLine("unknown"); }*/ double avgx = x; double avgy = y; pt.Location = new System.Drawing.Point((int)avgx, (int)avgy); if (hdc.State == Multitouch.Contracts.ContactState.New || hdc.State == Multitouch.Contracts.ContactState.Moved) { hdc.Update((int)avgx, (int)avgy, Multitouch.Contracts.ContactState.Moved); inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Moved); //System.Console.WriteLine("Moving.."); //pt.SetColor(Brushes.Red); } // x = ((int)((Math.Pow(h_x, power) * (deskWidth )) / Math.Pow(200, power))); // y = ((int)((Math.Pow(h_y, power) * (deskHeight)) / Math.Pow(200, power))); /* if (h_x < change_point) { x = ((int)((Math.Pow(h_x, power) * (deskWidth*2)) / Math.Pow(200, power))); } else { x = ((int)((Math.Pow(h_x, (1/power)) * (deskWidth)) / Math.Pow(200, (1/power)))); } if (h_y < change_point) { y = ((int)((Math.Pow(h_y, power) * (deskHeight)*2) / Math.Pow(200, power))); } else { y = ((int)((Math.Pow(h_y,(1/ power)) * (deskHeight)) / Math.Pow(200, (1/power)))); }*/ // Do not delete /* double avgx = x; double avgy = y; if (is_push_allow == 1 & is_push==0) { if (is_push_allow_counter > 3) { is_push_allow = 0; //flrouter.ActiveListener = null; if (hdc.State == Multitouch.Contracts.ContactState.Removed) { pt.SetColor(Brushes.Green); } else { pt.SetColor(Brushes.Red); } } is_push_allow_counter++; return; } if (is_push == 1 && is_push_stable==0) { return; } hdc.RowPoint = updatedhandPoint; pt.Location = new System.Drawing.Point((int)avgx, (int)avgy); //bool status = openpalm.isDetected(clipping, updatedhandPoint); if (hdc.State == Multitouch.Contracts.ContactState.New || hdc.State == Multitouch.Contracts.ContactState.Moved) { hdc.Update((int)avgx, (int)avgy, Multitouch.Contracts.ContactState.Moved); inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Moved); //System.Console.WriteLine("Moving.."); //pt.SetColor(Brushes.Red); } */ }
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; } } } }
private void clipHandFromDepthMap(Point3D HandPoint) { clipping = new byte[clipSize, clipSize]; //initialize the clipping matrix int xStart = (int)HandPoint.X - clipSize / 2; //starting x coordinate of the clip region int yStart = (int)HandPoint.Y - clipSize / 2; //starting y coordinate of the clip region int xEnd = (int)HandPoint.X + clipSize / 2; //ending x coordinate of the clip region int yEnd = (int)HandPoint.Y + clipSize / 2; //ending y coordinate of the clip region int depthAtPoint = (int)HandPoint.Z; //save the depth of the hand point int deviationDepth = 50; //permissible distance in mm ahead/behind the hand point int left = 0, right = xRes; //boundary along x int top = 0, bottom = yRes; //boundary along y /* *the loop below scans the depth map from the starting (x,y) coords to the ending (x,y) coords and thresholds each *point within this window based on its depth. If the depth of this point is within a permissible distance of the hand *point, then it is saved, else it is discarded. *the boundary conditions are observed and only points within the boundary of the 640 x 480 are considered. Sometimes, if the hand * point is near the edges, the clipping region will extend outside the boundaries. In this case only the points which lie in the clipping * area and are within the boundary are taken for thresholding. */ for (int j = yStart; j < yEnd; j++) { for (int i = xStart; i < xEnd; i++) { byte valueToSet = 0; //boundary condition check made here. The point being considered must be within the 640x480 boundary if ((i >= left && i < right) && (j >= top && j < bottom)) { int depth = depthMeta[i, j]; //read the depth at this point /* * this point (i,j) is within the boundary, so lets check if its within the permissible depth. * if yes, save it as a bright spot (MAX_COLOR) */ if ((depth < depthAtPoint + deviationDepth) && (depth > depthAtPoint - deviationDepth)) valueToSet = (byte)255; } //the if clause above will help us decide the value of the point (either 0 or 255), now just fill the //clip matrix with this value clipping[i - xStart, j - yStart] = valueToSet; } } }
public void Initialize() { string SAMPLE_XML_FILE = @"C:\Users\blub\Desktop\MusicWall2\KinectLibrary\KinectLibrary\bin\Release\SamplesConfig.xml"; context = Context.CreateFromXmlFile(SAMPLE_XML_FILE, out scriptNode); scene = new SceneAnalyzer(context); // DepthGenerator depth = context.FindExistingNode(NodeType.Depth) as DepthGenerator; if (depth == null) { //Console.WriteLine("Sample must have a depth generator!"); return; } mapMode = depth.MapOutputMode; xRes = (int)mapMode.XRes; yRes = (int)mapMode.YRes; backgroundDepthMD = new int[xRes, yRes]; while (true) { context.WaitOneUpdateAll(depth); depth.GetMetaData(depthMD); // SceneAnalyzer if (depthMD.FrameID <= loadRuns) { Background(depthMD, backgroundDepthMD, depthMD.FullXRes, depthMD.FullYRes, loadRuns); //if (depthMD.FrameID == 1) // Console.WriteLine("loading background data... ", depthMD.FrameID * 10); //Console.Write(" . ", (double)depthMD.FrameID / loadRuns * 100); centerpointDepth = centerpointDepth + depthMD[(int)mapMode.XRes / 2, (int)mapMode.YRes / 2]; if (depthMD.FrameID == loadRuns) { centerpointDepth = centerpointDepth / loadRuns; } } if (depthMD.FrameID == loadRuns) { scene = new SceneAnalyzer(context); if (scene == null) { //Console.WriteLine("Retry!"); } else { wallNorm = scene.Floor.Normal; wallPoint = scene.Floor.Point; //Console.WriteLine("\n Wall Normal : {0}, {1}, {2}", wallNorm.X, wallNorm.Y, wallNorm.Z); //Console.WriteLine(" Wall Point: {0}, {1}, {2}", wallPoint.X, wallPoint.Y, wallPoint.Z); Vector n1 = new Vector(0, 1); Vector n2 = new Vector(wallNorm.Y, wallNorm.Z); Vector n3 = new Vector(wallNorm.X, wallNorm.Z); angleBetween = (double)Vector.AngleBetween(n1, n2); // need to get the angle for the last axis in degrees angleBetweenY = (double)Vector.AngleBetween(n1, n3); //Console.WriteLine(" Angle: {0}", angleBetween); } break; } } }
public HandCreateEventArgs(UserID id, Point3D position, float time) { this.id = id; this.position = position; this.time = time; }
public Plane3D(Point3D normal, Point3D point) { this.vNormal = normal; this.ptPoint = point; }
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()); }
public static extern XnStatus xnConvertRealWorldToProjective(XnNodeHandle hInstance, XnUInt32 nCount, Point3D[] aRealWorld, [In][Out] Point3D[] aProjective);
//needs improvement void relativemotion(Point3D updatedhandPoint, HandPointContact hdc) { double diffx = ( updatedhandPoint.X-hdc.RowPoint.X) *(scrWidth/((scrWidth*1)/2)) ; double diffy = (updatedhandPoint.Y - hdc.RowPoint.Y) * (scrHeight / ((scrHeight*1 )/ 2)); hdc.accelerationx = diffx - hdc.velocityx; hdc.velocityx += hdc.accelerationx; hdc.accelerationy = diffy - hdc.velocityy; hdc.velocityy += hdc.accelerationy; //double scrdiffx = (((scrWidth/) * Math.Pow(diffx,1.5)) / Math.Pow(50,1.5)); // double scrdiffy = (((scrHeight/4) * Math.Pow(diffy,1.5)) / Math.Pow(50,1.5)); PointStatus pt = pointCollections[hdc.Id]; hdc.RowPoint = updatedhandPoint; /* if (pt.is_non_steady == true) { pt.nonsteady_counter++; if (pt.nonsteady_counter < 11) { pt.Location = new Point((int)(pt.Location.X + hdc.velocityx * (1 - (1 / pt.nonsteady_counter))), (int)(pt.Location.Y + hdc.velocityy * (1 - (1 / pt.nonsteady_counter)))); } else { pt.is_non_steady = false; pt.nonsteady_counter = 0; } } else { pt.Location = new Point((int)(pt.Location.X + hdc.velocityx ), (int)(pt.Location.Y + hdc.velocityy )); }*/ double xval = pt.Location.X + hdc.velocityx; double yval = pt.Location.Y + hdc.velocityy; if (xval < 0) { xval = 0; } if (yval < 0) { yval = 0; } pt.Location = new Point((int)(xval), (int)(yval)); if (hdc.State == Multitouch.Contracts.ContactState.New || hdc.State == Multitouch.Contracts.ContactState.Moved) { hdc.Update((int)pt.Location.X, (int)pt.Location.Y, Multitouch.Contracts.ContactState.Moved); inputProvider.EnqueueContact(hdc, Multitouch.Contracts.ContactState.Moved); //System.Console.WriteLine("Moving.."); //pt.SetColor(Brushes.Red); } /*if (pt.is_non_steady == false) { grab_gesture(hdc, pt); }*/ }
void boxes_Update(Point3D p) { updated(this, p); }
void handsGenerator_HandUpdate(object sender, HandUpdateEventArgs e) { Trace.WriteLine("Hand updated at " + e.Position.X + ", " + e.Position.Y + ", " + e.Position.Z); handPosition = new Point3D(e.Position.X + 320, 240 - e.Position.Y, e.Position.Z); }
public Point3D GetCoM(UserID id) { Point3D com = new Point3D(); int status = SafeNativeMethods.xnGetUserCoM(this.InternalObject, id, out com); WrapperUtils.ThrowOnError(status); return com; }
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"); }
void pointControl_PointUpdate(object sender, HandEventArgs e) { Console.WriteLine("Point Updated"); handPoint = DepthGenerator.ConvertRealWorldToProjective(e.Hand.Position); }
private bool VerticallyClose(OpenNI.Point3D p0, OpenNI.Point3D p1) { return(Math.Abs(p0.Y - p1.Y) < MAX_DIMMING_HAND_OFFSET_Y); }
void handsGenerator_HandUpdate(object sender, HandUpdateEventArgs e) { // this.shouldDrawHands = true; //MessageBox.Show("Hand being updated"); List<Point3D> historyList = history[e.UserID]; historyList.Add(e.Position); while (historyList.Count > historySize) { //String text = historyList.ElementAt(0).ToString(); //MessageBox.Show(text); historyList.RemoveAt(0); } history.Remove(e.UserID); history.Add(e.UserID, historyList); this.lastPoint = e.Position; this.lastPalmPoint = convertPoint3D(e.Position); }
public Point3D[] ConvertProjectiveToRealWorld(Point3D[] projectivePoints) { Point3D[] realWorld = new Point3D[projectivePoints.Length]; ConvertProjectiveToRealWorld(projectivePoints, realWorld); return realWorld; }
private Point convertPoint3D(Point3D point3D) { point3D = depth.ConvertRealWorldToProjective(point3D); int x = (int)point3D.X; int y = (int)point3D.Y; Point point2D = new Point(x, y); return point2D; }
public void ConvertRealWorldToProjective(Point3D[] realWorldPoints, Point3D[] projectivePoints) { if (projectivePoints.Length < realWorldPoints.Length) { throw new ArgumentException("Destination array is too small", "projectivePoints"); } int status = SafeNativeMethods.xnConvertRealWorldToProjective(this.InternalObject, (uint)realWorldPoints.Length, realWorldPoints, projectivePoints); WrapperUtils.ThrowOnError(status); }
public void StartTracking(Point3D position) { int status = SafeNativeMethods.xnStartTracking(this.InternalObject, ref position); WrapperUtils.ThrowOnError(status); }
public Point3D ConvertRealWorldToProjective(Point3D realWorldPoint) { Point3D[] realWorldPoints = new Point3D[1]; realWorldPoints[0] = realWorldPoint; return ConvertRealWorldToProjective(realWorldPoints)[0]; }
private void InternalHandUpdate(IntPtr hNode, UserID id, ref Point3D position, float fTime, IntPtr pCookie) { EventHandler<HandUpdateEventArgs> handlers = this.handUpdateEvent; if (handlers != null) handlers(this, new HandUpdateEventArgs(id, position, fTime)); }