我有两个不同的窗口,一个将显示图像上的流并计算用户的骨架头位置(窗口A),另一个显示将使用骨架的3D视觉模型数据放大和翻译(动画)(窗口B)。将kinect骨架位置数据传递到另一个窗口
但是,我的问题是我怎么能通过并不断更新从窗口A到窗口B的这些骨架头位置数据?我正在使用WPF和M'soft Kinect SDK。我的另一个问题是,如何在视觉模型上显示像按钮或菜单这样的控件,以便在整个屏幕上填充模型。
foreach (Skeleton skeleton in skeletons)
{
if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
{
ht.GetHeadPosition(skeleton, out message, out headPosition);
this.headPoint.X = headPosition.X;
this.headPoint.Y = headPosition.Y;
this.headPoint.Z = headPosition.Z;
this.StatusTextBlock.Text = message;
}
编辑
public void newSensor_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
{
using (SkeletonFrame skeletonFrame = e.OpenSkeletonFrame())
{
if (skeletonFrame == null)
return;
GetSkeletons(skeletonFrame, ref skeletons);
if (skeletons.All(s => s.TrackingState == SkeletonTrackingState.NotTracked))
return;
//skeletonManager.Draw(skeletons);
}
foreach (Skeleton skeleton in skeletons)
{
if (skeleton.TrackingState == SkeletonTrackingState.Tracked)
{
Joint headJoint = skeleton.Joints[JointType.Head];
Joint hipCenter = skeleton.Joints[JointType.HipCenter];
headPosition = headJoint.Position;
this.headPoint.X = headPosition.X;
this.headPoint.Y = headPosition.Y;
this.headPoint.Z = headPosition.Z;
message = string.Format("Head: X:{0:0.0} Y:{1:0.0} Z:{2:0.0}",
headPoint.X,
headPoint.Y, headPoint.Z);
//MessageBox.Show(message);
this.HeadPosition.Text = message;
}
}
}
我不能获得与data.What的HeadPosition.Text更新实际上发生了什么?
的Kinect在窗口中更改事件处理程序
private void sensorChooser_KinectChanged(object sender, KinectChangedEventArgs e)
{
KinectSensor oldSensor = (KinectSensor)e.OldSensor;
StopKinect(oldSensor);
KinectSensor newSensor = (KinectSensor)e.NewSensor;
if (newSensor == null)
{
return;
}
//Register for event and enable Kinect Sensor features you want
newSensor.DepthFrameReady += newSensor_DepthFrameReady;
newSensor.SkeletonFrameReady += mw.newSensor_SkeletonFrameReady;
//newSensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
newSensor.DepthStream.Enable(DepthImageFormat.Resolution640x480Fps30);
....
newSensor.SkeletonStream.Enable(parameter);
StartKinect(newSensor);
}
XAML_ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ __ _ _
<Grid x:Name="firstGrid">
<Viewport3D x:Name="viewPort" Grid.Column="0" Grid.Row="0" ClipToBounds="False" Width="2048"
....
.....
</Viewport3D>
<TextBox x:Name="IndexPosition" HorizontalAlignment="Left" Height="23" Margin="485,2,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="69"/>
<TextBox x:Name="CameraPosition" HorizontalAlignment="Left" Height="23" Margin="570,2,0,0" TextWrapping="Wrap" Text="TextBox" VerticalAlignment="Top" Width="142"/>
<TextBlock Name="HeadPosition" HorizontalAlignment="Left" Margin="492,23,0,0" Text="Text" VerticalAlignment="Top" Width="182" Height="29"
Foreground="Tomato" FontSize="20"/>
什么'ht.GetHeadPoistion'在做什么?直接访问'skeleton.Joints [JointType.Head] .Position'对象会得到相同的东西 - 没有使用'out'参数的奇怪。 –
是的..我改回来直接访问它。起初我认为我可以从GetHeadPosition传递值。 – user1884304