我有兩個不同的窗口,一個將顯示圖像上的流並計算用戶的骨架頭位置(窗口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