public MainWindow() { this.Sensor = new KinectV2(); this.RgbStreamAdapter = new WpfRgbStreamAdapter(this); this.RgbStreamAdapter.Init(); this.DataContext = this; InitializeComponent(); }
public MainWindow() { this.Sensor = new KinectV2(); #region Initializing Stream Adapters this.RgbStreamAdapter = new WpfRgbStreamAdapter(this); this.RgbStreamAdapter.Init(); this.MultiFrameStreamAdapter = new WpfMultiFrameStreamAdapter(this); this.MultiFrameStreamAdapter.FrameArrived += MultiFrameStreamAdapter_FrameArrived; this.MultiFrameStreamAdapter.Init(); this.depthFrameReader = this.Kinect.DepthFrameSource.OpenReader(); this.depthFrameReader.FrameArrived += depthFrameReader_FrameArrived; this.depthFrameDescription = this.Kinect.DepthFrameSource.FrameDescription; this.depthPixels = new byte[this.depthFrameDescription.Width * this.depthFrameDescription.Height]; this.depthBitmap = new WriteableBitmap(this.depthFrameDescription.Width, this.depthFrameDescription.Height, 96.0, 96.0, PixelFormats.Gray8, null); #endregion #region Coordinate Mapper Configuration this.coordinateMapper = this.Kinect.CoordinateMapper; FrameDescription depthFrameDescription = this.Kinect.DepthFrameSource.FrameDescription; int depthWidth = depthFrameDescription.Width; int depthHeight = depthFrameDescription.Height; // allocate space to put the pixels being received and converted this.depthFrameData = new ushort[depthWidth * depthHeight]; this.colorPoints = new ColorSpacePoint[depthWidth * depthHeight]; this.cameraPoints = new CameraSpacePoint[depthWidth * depthHeight]; // get FrameDescription from ColorFrameSource FrameDescription colorFrameDescription = this.Kinect.ColorFrameSource.FrameDescription; int colorWidth = colorFrameDescription.Width; int colorHeight = colorFrameDescription.Height; // allocate space to put the pixels being received this.colorFrameData = new byte[colorWidth * colorHeight * this.bytesPerPixel]; #endregion #region Recorder this.Recorder = new PointCloudRecorder(ConfigurationManager.AppSettings["RecordFolder"], new PCL()); this.Recorder.RecordRGB = false; this.Recorder.StateChanged += Recorder_StateChanged; this.Recorder.Stopped += Recorder_Stopped; this.Recorder.CloudProcessed += Recorder_CloudProcessed; #endregion this.DataContext = this; InitializeComponent(); }