本文整理汇总了C#中CoordinateMapper.MapCameraPointToDepthSpace方法的典型用法代码示例。如果您正苦于以下问题:C# CoordinateMapper.MapCameraPointToDepthSpace方法的具体用法?C# CoordinateMapper.MapCameraPointToDepthSpace怎么用?C# CoordinateMapper.MapCameraPointToDepthSpace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CoordinateMapper
的用法示例。
在下文中一共展示了CoordinateMapper.MapCameraPointToDepthSpace方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateBody
private static BodyFrameData.Body CreateBody(Body input, CoordinateMapper coordinateMapper)
{
var output = new BodyFrameData.Body()
{
TrackingId = input.TrackingId,
IsTracked = input.IsTracked,
IsRestricted = input.IsRestricted,
ClippedEdges = (Schemas.RecorderMessages.FrameEdges)(int)input.ClippedEdges,
HandLeft = new BodyFrameData.Hand()
{
Confidence = (Schemas.RecorderMessages.TrackingConfidence)(int)input.HandLeftConfidence,
State = (Schemas.RecorderMessages.HandState)(int)input.HandLeftState,
},
HandRight = new BodyFrameData.Hand()
{
Confidence = (Schemas.RecorderMessages.TrackingConfidence)(int)input.HandRightConfidence,
State = (Schemas.RecorderMessages.HandState)(int)input.HandRightState,
},
Joints = new Dictionary<Schemas.RecorderMessages.JointType, BodyFrameData.Joint>(),
};
var jointTypes = Enum.GetValues(typeof(JointType));
foreach (JointType type in jointTypes)
{
var joint = input.Joints[type];
var position2d = coordinateMapper.MapCameraPointToDepthSpace(joint.Position);
var position3d = joint.Position;
var orientation = input.JointOrientations[type].Orientation;
output.Joints.Add((Schemas.RecorderMessages.JointType)(int)type, new BodyFrameData.Joint()
{
Type = (Schemas.RecorderMessages.JointType)(int)type,
State = (Schemas.RecorderMessages.TrackingState)(int)joint.TrackingState,
Position2D = new Point(position2d.X, position2d.Y),
Position3D = new Vector3D(position3d.X, position3d.Y, position3d.Z),
Rotation = new Quaternion(orientation.X, orientation.Y, orientation.Z, orientation.W),
});
}
return output;
}
示例2: ShowJoint
private void ShowJoint( CoordinateMapper mapper, Joint joint )
{
var point = mapper.MapCameraPointToDepthSpace( joint.Position );
var ellipse = new Ellipse()
{
Fill = Brushes.Red,
Width = 5,
Height = 5,
};
Canvas.SetLeft( ellipse, point.X );
Canvas.SetTop( ellipse, point.Y );
CanvasBody.Children.Add( ellipse );
}
示例3: DrawBodies
public void DrawBodies(Body[] bodies, CoordinateMapper coordinateMapper, DisplayMode displayMode, int? targetIndex)
{
// Draw a transparent background to set the render size
this.imageSource.DrawRectangle(0, 0, this.displayWidth, this.displayHeight, Color.FromArgb(255, 128, 128, 128));
int count = 0;
bool trackedBody = false;
foreach (Body body in bodies)
{
if (body.IsTracked)
{
this.DrawClippedEdges(body);
IReadOnlyDictionary<JointType, Joint> joints = body.Joints;
// convert the joint points to depth (display) space
Dictionary<JointType, Point> jointPoints = new Dictionary<JointType, Point>();
foreach (JointType jointType in joints.Keys)
{
// sometimes the depth(Z) of an inferred joint may show as negative
// clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity)
CameraSpacePoint position = joints[jointType].Position;
if (position.Z < 0)
{
position.Z = InferredZPositionClamp;
}
DepthSpacePoint depthSpacePoint = coordinateMapper.MapCameraPointToDepthSpace(position);
//convert joint space to color space so that we can draw skeletons on top of color feed
if (displayMode == DisplayMode.COLOR) {
jointPoints[jointType] = new Point((depthSpacePoint.X / this.jointDisplayWidth) * this.displayWidth, (depthSpacePoint.Y / this.jointDisplayHeight) * this.displayHeight);
}
else
{
jointPoints[jointType] = new Point(depthSpacePoint.X / this.jointDisplayWidth,depthSpacePoint.Y / this.jointDisplayHeight);
}
//check if this is the skeleton that has been targeted by system
//if it is we'll draw a big red circle on the skelton chest
if (targetIndex != null && targetIndex == count)
{
if (jointType == JointType.Head)
{
var joint = jointPoints[jointType];
if (!hasValidTracking)
{
voiceSynth.SpeakAsync("Target Aquired!");
hasValidTracking = true;
}
trackedBody = true;
if (displayMode == DisplayMode.COLOR)
{
this.imageSource.FillEllipse((int)joint.X, (int)joint.Y, (int)joint.X + 50, (int)joint.Y + 50, Color.FromArgb(128, 255, 0, 0));
}
else if(displayMode == DisplayMode.INFRARED)
{
//we can't draw on a grayscale 16bit bitmap. So TODO on implementing the drawing here
//var pgra32Version = BitmapFactory.ConvertToPbgra32Format(this.infraredSource);
//pgra32Version.FillEllipse((int)joint.X, (int)joint.Y, (int)joint.X + 50, (int)joint.Y + 50, Colors.Black);
}
}
}
}
this.DrawBody(joints, jointPoints, this.trackedJointColor);
this.DrawHand(body.HandLeftState, jointPoints[JointType.HandLeft]);
this.DrawHand(body.HandRightState, jointPoints[JointType.HandRight]);
count++;
}
}
if (!trackedBody)
{
hasValidTracking = false;
}
// prevent drawing outside of our render area
//this.drawingGroup.ClipGeometry = new RectangleGeometry(new Rect(0.0, 0.0, this.displayWidth, this.displayHeight));
}
示例4: ToPoint
/// <summary>
/// Converts the specified CameraSpacePoint into a 2-D point.
/// </summary>
/// <param name="position">The CameraSpacePoint to convert.</param>
/// <param name="visualization">The type of the conversion (color, depth, or infrared).</param>
/// <param name="coordinateMapper">The CoordinateMapper to make the conversion.</param>
/// <returns>The corresponding 2-D point.</returns>
public static Point ToPoint(this CameraSpacePoint position, Visualization visualization, CoordinateMapper coordinateMapper)
{
Point point = new Point();
switch (visualization)
{
case Visualization.Color:
{
ColorSpacePoint colorPoint = coordinateMapper.MapCameraPointToColorSpace(position);
point.X = float.IsInfinity(colorPoint.X) ? 0.0 : colorPoint.X;
point.Y = float.IsInfinity(colorPoint.Y) ? 0.0 : colorPoint.Y;
}
break;
case Visualization.Depth:
case Visualization.Infrared:
{
DepthSpacePoint depthPoint = coordinateMapper.MapCameraPointToDepthSpace(position);
point.X = float.IsInfinity(depthPoint.X) ? 0.0 : depthPoint.X;
point.Y = float.IsInfinity(depthPoint.Y) ? 0.0 : depthPoint.Y;
}
break;
default:
break;
}
return point;
}
示例5: DrawBone
internal static void DrawBone(DrawingContext drawingContext, System.Windows.Media.Brush brush, JointType startJoint, JointType endJoint, IReadOnlyDictionary<JointType, Joint> joints, System.Windows.Rect rect, CoordinateMapper coordinateMapper, bool useDepthSpace = true, double line = 0.8F)
{
if (joints[startJoint].TrackingState != TrackingState.Tracked
&& joints[endJoint].TrackingState != TrackingState.Tracked)
{
return;
}
System.Windows.Point startPoint;
System.Windows.Point endPoint;
if (useDepthSpace)
{
startPoint = coordinateMapper.MapCameraPointToDepthSpace(joints[startJoint].Position).GetPoint();
endPoint = coordinateMapper.MapCameraPointToDepthSpace(joints[endJoint].Position).GetPoint();
}
else
{
startPoint = coordinateMapper.MapCameraPointToColorSpace(joints[startJoint].Position).GetPoint();
endPoint = coordinateMapper.MapCameraPointToColorSpace(joints[endJoint].Position).GetPoint();
}
if (rect.Contains(startPoint) && rect.Contains(endPoint))
drawingContext.DrawLine(new System.Windows.Media.Pen(brush, line), startPoint, endPoint);
}
开发者ID:andreasassetti,项目名称:Kinect-v2-Visual-Studio-Visualizer,代码行数:25,代码来源:ExtensionMethodsBodyFrame.cs
示例6: ProjectCameraPoint
/// <summary>
/// Project the camera space point using the given sensor coordinate mapper.
/// </summary>
/// <param name="inPoint"></param>
/// <param name="coordinateMapper"></param>
/// <returns></returns>
public Point ProjectCameraPoint(CameraSpacePoint inPoint, CoordinateMapper coordinateMapper)
{
if (_useDepthMapper)
{
DepthSpacePoint depthPoint = coordinateMapper.MapCameraPointToDepthSpace(inPoint);
return new Point(depthPoint.X, depthPoint.Y);
}
else
{
ColorSpacePoint colorPoint = coordinateMapper.MapCameraPointToColorSpace(inPoint);
return new Point(colorPoint.X, colorPoint.Y);
}
}
示例7: getJointPoints
/// <summary>
/// For the body frame of the first tracked skeleton, get a dictionary of all jointTypes and their corresponding currentPoint
/// </summary>
/// <param name="skeletons"></param>
/// <param name="mapper"></param>
/// <returns></returns>
static Dictionary<JointType, Point> getJointPoints(List<Body> skeletons, CoordinateMapper mapper)
{
Body skeleton = skeletons[0]; //only consider the first tracked skeleton.
IReadOnlyDictionary<JointType, Joint> joints = skeleton.Joints;
Dictionary<JointType, Point> jointPoints = new Dictionary<JointType, Point>();
foreach (JointType jointType in joints.Keys)
{
// sometimes the depth(Z) of an inferred joint may show as negative
// clamp down to 0.1f to prevent coordinatemapper from returning (-Infinity, -Infinity)
CameraSpacePoint position = joints[jointType].Position;
if (position.Z < 0)
{
position.Z = Constants.InferredZPositionClamp;
}
DepthSpacePoint depthSpacePoint = mapper.MapCameraPointToDepthSpace(position);
jointPoints[jointType] = new Point((int)depthSpacePoint.X, (int)depthSpacePoint.Y);
}
return jointPoints;
}