0

我正在使用 windows SDK 在 kinect 上做一个项目。我正在尝试使用以下代码在骨架肩上显示图像。**

Xaml 代码

<Canvas Margin="250,0,0,0" Visibility="{Binding Path=Showcamera, Converter={StaticResource BVC}}" Background="Green" HorizontalAlignment="Stretch" VerticalAlignment="Top" Grid.Column="1" Grid.Row="1">

        <Image MaxHeight="600" MaxWidth="950" x:Name="PART_KinectVideo"  Visibility="{Binding Path=Showcamera, Converter={StaticResource BVC}}"  />
        <Canvas>
        <Image  RenderOptions.BitmapScalingMode="HighQuality" Visibility="{Binding Path=Showcamera, Converter={StaticResource BVC}}"
            RenderOptions.EdgeMode="Aliased"  Canvas.Top="60" Canvas.Left="350"  Stretch="Uniform" x:Name="Jewel"/>
        </Canvas>

代码背后

var j1p = nui.MapSkeletonPointToDepth(closestSkeleton.Joints[JointType.ShoulderLeft].Position,DepthImageFormat.Resolution640x480Fps30);

 Canvas.SetLeft(Jewel, j1p.X+90);
 Canvas.SetTop(Jewel, j1p.Y-280);

通过获取 j1p 值,我试图为 Jewel 图像对象设置画布的左侧和顶部位置。

代码的问题是:

这没有正确放置图像。当用户在屏幕中移动时,图像也会随着用户的移动而以左右方向移出身体。

即使用户向右或向左移动,我也需要将图像设置为该位置。
我应该如何更改代码或者是否有任何示例可用于将图像设置在 kinect 关节的特定位置?

4

1 回答 1

0

也许试试这个:

var left = (double)image.GetValue(Canvas.LeftProperty)
left += 90;
image.SetValue(Canvas.LeftProperty, left);

我使用该代码编写了一个应用程序,一切对我来说都很好:)

于 2012-09-05T07:28:12.187 回答