Kinect for windows(sdk 1.5)を使用するプロジェクトでKinectColorViewerを使用しようとしています。kinectエクスプローラーの例では、KinectColorViewerコンポーネントにバインドされたKinectSensorManagerコンポーネントがありました。xamlファイルには次のものがあります。
<kt:KinectColorViewer x:Name="ColorViewer" KinectSensorManager="{Binding KinectSensorManager}" CollectFrameRate="True" RetainImageOnSensorChange="True" />
他のプロジェクトで同じコンセプトを再現するのに苦労しています。Microsoft.Kinect.ToolkitのKinectSensorChooser、KinectSensorChooserUI、およびMirosoft.Sampels.Kinect.wpfviewersKinectColorViewerを使用しました。colorViewerのKinectSensorManagerをUI要素にバインドしようとしました。
<my:KinectColorViewer Width="200" Height="200" HorizontalAlignment="Left" Margin="198,12,0,0" Name="kinectColorViewer1" VerticalAlignment="Top" KinectSensorManager="{Binding ElementName=kinectSensorChooserUI1, Path=KinectSensorChooser.Kinect}" />
両方の試みは失敗しました。新しいSDKを使用してColorViwer、DepthViwer、SkeletonViewerを使用した人はいますか?私たちが素晴らしいだろうと考えて...
KinectSensorManagerをバインドするために、バックエンドに次のコードを追加しました。
public partial class MainWindow : Window
{
public KinectSensorManager KinectSensorManager { get; set;}
private void WindowLoaded(object sender, RoutedEventArgs e)
{
KinectSensorManager = new KinectSensorManager();
KinectSensorManager.KinectSensorChanged += new EventHandler<KinectSensorManagerEventArgs<KinectSensor>>(KinectSensorManager_KinectSensorChanged);
// Look through all sensors and start the first connected one.
// This requires that a Kinect is connected at the time of app startup.
foreach (var potentialSensor in KinectSensor.KinectSensors)
{
if (potentialSensor.Status == KinectStatus.Connected)
{
this.sensor = potentialSensor;
break;
}
}
if (null != this.sensor)
{
// Turn on the skeleton stream to receive skeleton frames
this.sensor.SkeletonStream.Enable();
this.sensor.DepthStream.Enable();
this.sensor.ColorStream.Enable(ColorImageFormat.RgbResolution640x480Fps30);
this.sensor.AllFramesReady += new System.EventHandler<AllFramesReadyEventArgs>(sensor_AllFramesReady);
this.sensor.SkeletonFrameReady += this.SensorSkeletonFrameReady;
// Start the sensor!
try
{
this.sensor.Start();
}
catch (IOException)
{
this.sensor = null;
}
var kinectSensorBinding = new Binding("KinectSensor") { Source = this.sensor };
BindingOperations.SetBinding(this.KinectSensorManager, KinectSensorManager.KinectSensorProperty, kinectSensorBinding);
}
if (null == this.sensor)
{
this.statusBarText.Text = Properties.Resources.NoKinectReady;
}
}
およびXamlファイル:
<kt:KinectColorViewer Width="191" Height="83" Grid.Column="3" KinectSensorManager="{Binding KinectSensorManager}" HorizontalAlignment="Left" Margin="17,236,0,0" Name="kinectColorViewer1" VerticalAlignment="Top" />
しかし、私はまだカラーストリームを取得していません。