public bool Equals(Vector3DF other) { if (X != other.X) { return(false); } if (Y != other.Y) { return(false); } return(Z == other.Z); }
/// <summary> /// Helper API to retrieve head points structure from a given skeleton instance /// </summary> /// <param name="skeletonOfInterest"> /// skeleton from which head points are to be extracted /// </param> /// <returns> /// HeadPoints that can be passed to Start/Continue tracking APIs /// </returns> private static Vector3DF[] GetHeadPointsFromSkeleton(Skeleton skeletonOfInterest) { Vector3DF[] headPoints = null; if (skeletonOfInterest != null && skeletonOfInterest.TrackingState == SkeletonTrackingState.Tracked) { headPoints = new Vector3DF[2]; SkeletonPoint sp0 = skeletonOfInterest.Joints[JointType.ShoulderCenter].Position; headPoints[0] = new Vector3DF(sp0.X, sp0.Y, sp0.Z); SkeletonPoint sp1 = skeletonOfInterest.Joints[JointType.Head].Position; headPoints[1] = new Vector3DF(sp1.X, sp1.Y, sp1.Z); } return(headPoints); }
private PointF[] GetProjected3DShape( CameraConfig videoCameraConfig, float zoomFactor, Point viewOffset, IntPtr shapeUnitCoeffPtr, uint shapeUnitCoeffCount, IntPtr animUnitCoeffPtr, uint animUnitCoeffCount, float scale, Vector3DF rotation, Vector3DF translation) { this.CheckPtrAndThrow(); PointF[] faceModelProjected3DShape = null; uint vertexCount = this.VertexCount; IntPtr faceModel3DVerticesPtr = IntPtr.Zero; if (shapeUnitCoeffPtr == IntPtr.Zero || shapeUnitCoeffCount == 0) { throw new ArgumentException("Invalid shape unit co-efficients", "shapeUnitCoeffPtr"); } if (animUnitCoeffPtr == IntPtr.Zero || animUnitCoeffCount == 0) { throw new ArgumentException("Invalid animation unit co-efficients", "animUnitCoeffPtr"); } if (vertexCount > 0) { try { faceModel3DVerticesPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Vector3DF)) * (int)vertexCount); this.faceTrackingModelPtr.GetProjectedShape( videoCameraConfig, zoomFactor, viewOffset, shapeUnitCoeffPtr, shapeUnitCoeffCount, animUnitCoeffPtr, animUnitCoeffCount, scale, ref rotation, ref translation, faceModel3DVerticesPtr, vertexCount); faceModelProjected3DShape = new PointF[vertexCount]; for (int i = 0; i < (int)vertexCount; i++) { IntPtr faceModel3DVerticesIthPtr; if (IntPtr.Size == 8) { // 64bit faceModel3DVerticesIthPtr = new IntPtr(faceModel3DVerticesPtr.ToInt64() + (i * Marshal.SizeOf(typeof(PointF)))); } else { // 32bit faceModel3DVerticesIthPtr = new IntPtr(faceModel3DVerticesPtr.ToInt32() + (i * Marshal.SizeOf(typeof(PointF)))); } faceModelProjected3DShape[i] = (PointF)Marshal.PtrToStructure(faceModel3DVerticesIthPtr, typeof(PointF)); } } finally { if (faceModel3DVerticesPtr != IntPtr.Zero) { Marshal.FreeHGlobal(faceModel3DVerticesPtr); } } } return faceModelProjected3DShape; }
public bool Equals(Vector3DF other) { if (X != other.X) { return false; } if (Y != other.Y) { return false; } return Z == other.Z; }
/// <summary> /// Helper API to retrieve head points structure from a given skeleton instance /// </summary> /// <param name="skeletonOfInterest"> /// skeleton from which head points are to be extracted /// </param> /// <returns> /// HeadPoints that can be passed to Start/Continue tracking APIs /// </returns> private static Vector3DF[] GetHeadPointsFromSkeleton(Skeleton skeletonOfInterest) { Vector3DF[] headPoints = null; if (skeletonOfInterest != null && skeletonOfInterest.TrackingState == SkeletonTrackingState.Tracked) { headPoints = new Vector3DF[2]; SkeletonPoint sp0 = skeletonOfInterest.Joints[JointType.ShoulderCenter].Position; headPoints[0] = new Vector3DF(sp0.X, sp0.Y, sp0.Z); SkeletonPoint sp1 = skeletonOfInterest.Joints[JointType.Head].Position; headPoints[1] = new Vector3DF(sp1.X, sp1.Y, sp1.Z); } return headPoints; }
private PointF[] GetProjected3DShape( CameraConfig videoCameraConfig, float zoomFactor, Point viewOffset, IntPtr shapeUnitCoeffPtr, uint shapeUnitCoeffCount, IntPtr animUnitCoeffPtr, uint animUnitCoeffCount, float scale, Vector3DF rotation, Vector3DF translation) { this.CheckPtrAndThrow(); PointF[] faceModelProjected3DShape = null; uint vertexCount = this.VertexCount; IntPtr faceModel3DVerticesPtr = IntPtr.Zero; if (shapeUnitCoeffPtr == IntPtr.Zero || shapeUnitCoeffCount == 0) { throw new ArgumentException("Invalid shape unit co-efficients", "shapeUnitCoeffPtr"); } if (animUnitCoeffPtr == IntPtr.Zero || animUnitCoeffCount == 0) { throw new ArgumentException("Invalid animation unit co-efficients", "animUnitCoeffPtr"); } if (vertexCount > 0) { try { faceModel3DVerticesPtr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Vector3DF)) * (int)vertexCount); this.faceTrackingModelPtr.GetProjectedShape( videoCameraConfig, zoomFactor, viewOffset, shapeUnitCoeffPtr, shapeUnitCoeffCount, animUnitCoeffPtr, animUnitCoeffCount, scale, ref rotation, ref translation, faceModel3DVerticesPtr, vertexCount); faceModelProjected3DShape = new PointF[vertexCount]; for (int i = 0; i < (int)vertexCount; i++) { IntPtr faceModel3DVerticesIthPtr; if (IntPtr.Size == 8) { // 64bit faceModel3DVerticesIthPtr = new IntPtr(faceModel3DVerticesPtr.ToInt64() + (i * Marshal.SizeOf(typeof(PointF)))); } else { // 32bit faceModel3DVerticesIthPtr = new IntPtr(faceModel3DVerticesPtr.ToInt32() + (i * Marshal.SizeOf(typeof(PointF)))); } faceModelProjected3DShape[i] = (PointF)Marshal.PtrToStructure(faceModel3DVerticesIthPtr, typeof(PointF)); } } finally { if (faceModel3DVerticesPtr != IntPtr.Zero) { Marshal.FreeHGlobal(faceModel3DVerticesPtr); } } } return(faceModelProjected3DShape); }