示例#1
0
 // Event Handler for ColorFrameReady events
 // (A new frame of ColorStream data is available)
 private void KinectColorFrameReady(object sender, ColorImageFrameReadyEventArgs e)
 {
     // Get the current ColorImageFrame
     using (ColorImageFrame colorFrame = e.OpenColorImageFrame())
     {
         if (colorFrame != null)
         {
             try
             {
                 // Get the pixel data from the ColorImageFrame
                 colorFrame.CopyPixelDataTo(this.colorStreamData);
                 // Write the pixel data to the colorBitmap image
                 colorBitmap.WritePixels(new Int32Rect(0, 0, colorFrame.Width, colorFrame.Height), colorStreamData, colorFrame.Width * colorFrame.BytesPerPixel, 0);
                 // Dispatch the ColorDataChange event
                 ColorDataChangeEventArgs c = new ColorDataChangeEventArgs(colorStreamData);
                 ColorDataChange(c);
             }
             catch (NullReferenceException ex)
             {
                 Console.WriteLine(ex.TargetSite + " - " + ex.Message);
             }
         }
     }
 }
示例#2
0
 protected virtual void ColorDataChange(ColorDataChangeEventArgs e)
 {
     if (ColorDataChanged != null)
     {
         ColorDataChanged(this, e);
     }
 }