Kinect/Demo6/Demo6/MainWindow.xaml.cs
2015-11-15 17:33:38 +00:00

51 lines
1.6 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Microsoft.Research.Kinect.Nui;
namespace Demo6
{
/// <summary>
/// Interaktionslogik für MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Window_Loaded(object sender, RoutedEventArgs e)
{
if (Runtime.Kinects.Count == 0)
{
MessageBox.Show("Keine Kinect");
return;
}
Runtime r = Runtime.Kinects[0];
r.Initialize(RuntimeOptions.UseDepth);
r.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.Depth);
r.DepthFrameReady += new EventHandler<ImageFrameReadyEventArgs>(r_DepthFrameReady);
}
void r_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
{
PlanarImage img = e.ImageFrame.Image;
//byte[] b = cv.ConvertDepthFrame(img.Bits);
imgDepth.Source = BitmapSource.Create(img.Width, img.Height,
96, 96, PixelFormats.Bgr32, null,
b, img.Width * img.BytesPerPixel);
}
}
}