/// <summary> /// Start to retrieve the frame /// </summary> public override void Open() { // Open the reader for the color frames this.colorFrameReader = this.sensor.ColorFrameSource.OpenReader(); // Wire handler for frame arrival this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; // Create the colorFrameDescription from the ColorFrameSource using Bgra format this.frameDescription = this.sensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra); // Create the bitmap to display this.imageBitmap = new WriteableBitmap(frameDescription.Width, frameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); }
/// <summary> /// Start to retrieve the frame /// </summary> public override void Open() { // Get the coordinate mapper this.coordinateMapper = this.sensor.CoordinateMapper; /* Preparing the bodycolor image to display bodies */ // Get the color (display) extents FrameDescription frameDescription = this.sensor.ColorFrameSource.FrameDescription; // Get size of joint space this.displayWidth = frameDescription.Width; this.displayHeight = frameDescription.Height; // Initialize all bitmaps this.bodyColorBitmap = new WriteableBitmap(frameDescription.Width, frameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); this.bodyBitmap = new WriteableBitmap(frameDescription.Width, frameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null); //this.bodyColorBitmapResized = new WriteableBitmap(frameDescription.Width / 4, frameDescription.Height / 4, 96.0, 96.0, PixelFormats.Bgr32, null); //this.bodyBitmapResized = new WriteableBitmap(frameDescription.Width / 4, frameDescription.Height / 4, 96.0, 96.0, PixelFormats.Bgr32, null); // Initialize body image // Create the drawing group we'll use for drawing this.drawingGroup = new DrawingGroup(); // Create an image source that we can use in our image control this.imageSource = new DrawingImage(this.drawingGroup); bitmapRender = new RenderTargetBitmap(displayWidth, displayHeight, 96.0, 96.0, PixelFormats.Pbgra32); // Allocate space to put the pixels being received this.bodyBytespixels = new byte[frameDescription.Width * frameDescription.Height * this.bytesPerPixel]; // Access the parameters of body structure bodyStructure = BodyStructure.Instance; // Open the reader for the body frames this.bodyFrameReader = this.sensor.BodyFrameSource.OpenReader(); this.bodyFrameReader.FrameArrived += this.Reader_BodyFrameArrived; // Open the reader for the color frames this.colorFrameReader = this.sensor.ColorFrameSource.OpenReader(); this.colorFrameReader.FrameArrived += this.Reader_ColorFrameArrived; }