public void DrawStickFigure(ref WriteableBitmap image, DepthGenerator depthGenerator, DepthMetaData data, UserGenerator userGenerator, Ray3D[] rays) { Point3D corner = new Point3D(data.XRes, data.YRes, data.ZRes); corner = depthGenerator.ConvertProjectiveToRealWorld(corner); this.depthGenerator = depthGenerator; int nXRes = data.XRes; int nYRes = data.YRes; // TODO: Fix these. /*foreach (Ray3D ray in rays) * { * if (ray != null) * { * int[] p0 = ray.point0(); * int[] p1 = ray.point1(); * DrawTheLine(ref image, p0, p1); * } * }*/ int[] users = userGenerator.GetUsers(); foreach (int user in users) { if (userGenerator.SkeletonCapability.IsTracking(user)) { DrawSingleUser(ref image, user, userGenerator, corner); } } }
public void getData() { context.WaitOneUpdateAll(depth); depth.GetMetaData(depthMD); System.Windows.Media.Media3D.Point3D u_new, u_real, f, c; c = new System.Windows.Media.Media3D.Point3D(0, 0, centerpointDepth); OpenNI.Point3D newF; newF = Change(depthMD, backgroundDepthMD); //returns the pixal pos if (newF.X != 0 && newF.Z != 0 && newF.Z != 0) { newF = depth.ConvertProjectiveToRealWorld(newF); f = new System.Windows.Media.Media3D.Point3D(newF.X, newF.Y, newF.Z); // the point of intress u_new = Translation(f, c); //A translation that brings point 1 to the origin float d = Distance(scene.Floor, newF); double angleInRadians = (Math.PI / 180) * angleBetween;; double angleInRadiansY = (Math.PI / 180) * angleBetweenY;; var matrix = NewRotateAroundX(angleInRadians); // Rotation around the origin by the required angle matrix = NewRotateAroundY(angleInRadiansY); u_real = Multiplication(matrix, u_new); //Console.WriteLine("new U {0}, {1}, {2} ", (int)u_new.X, (int)u_new.Y, (int)u_new.Z); //Console.WriteLine("u_real , {1}, {2} and {3} distance {4}", depthMD.FrameID, (int)u_real.X, (int)u_real.Y, (int)u_real.Z, d); xYDepth = new System.Windows.Media.Media3D.Point3D(u_real.X, u_real.Y, d); } }
public void DrawStickFigure(ref WriteableBitmap image, DepthGenerator depthGenerator, DepthMetaData data, UserGenerator userGenerator) { Point3D corner = new Point3D(data.XRes, data.YRes, data.ZRes); corner = depthGenerator.ConvertProjectiveToRealWorld(corner); this.depthGenerator = depthGenerator; int nXRes = data.XRes; int nYRes = data.YRes; int[] users = userGenerator.GetUsers(); foreach (int user in users) { if (userGenerator.SkeletonCapability.IsTracking(user)) { DrawSingleUser(ref image, user, userGenerator, corner); } } }
private void UpdateVertices(int YScaled, int XScaled) { int depthIndex = 0; UnityEngine.Profiling.Profiler.BeginSample("UpdateVertices"); UnityEngine.Profiling.Profiler.BeginSample("FillPoint3Ds"); DepthGenerator dg = OpenNIContext.Instance.Depth; short maxDepth = (short)OpenNIContext.Instance.Depth.DeviceMaxDepth; Vector3 vec = new Vector3(); Point3D pt = new Point3D(); for (int y = 0; y < YScaled; y++) { for (int x = 0; x < XScaled; x++, depthIndex += factorX) { short pixel = rawDepthMap[depthIndex]; if (pixel == 0) { pixel = maxDepth; // if there's no depth, default to max depth } // RW coordinates pt.X = x * factorX; pt.Y = y * factorY; pt.Z = pixel; pts[x + y * XScaled] = pt; // in structs, assignment is a copy, so modifying the same variable // every iteration is okay } // Skip lines depthIndex += (factorY - 1) * XRes; } UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.BeginSample("ProjectiveToRW"); if (RealWorldPoints) { pts = dg.ConvertProjectiveToRealWorld(pts); } else { for (int i = 0; i < pts.Length; i++) { pts[i].X -= XRes / 2; pts[i].Y = (YRes / 2) - pts[i].Y; // flip Y axis in projective } } UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.BeginSample("PointsToVertices"); for (int y = 0; y < YScaled; y++) { for (int x = 0; x < XScaled; x++) { pt = pts[x + y * XScaled]; vec.x = pt.X * gridScale.x; vec.y = pt.Y * gridScale.y; vec.z = -pt.Z * gridScale.z; verts[y * XScaled + x] = vec; } } UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.BeginSample("AssignVerticesToMesh"); mesh.vertices = verts; UnityEngine.Profiling.Profiler.EndSample(); UnityEngine.Profiling.Profiler.EndSample(); }