Welcome to stack overflow, please do not ask the same question multiple times. With less popular tags, such as Kinect, it may take some time for people to respond (there are only 79 subscribers in the tag).
For simplicity, I'm going to assume that you want to crop an image with a set size (for example, 60x60 pixels from the original 800x600). In your VideoFrameReady method, you get PlanarImage from the event arguments. This PlanarImage has a bit field that contains all the RGB data for the image. With a little math, you can cut out a small piece of this data and use it as a smaller image.
// update video feeds void nui_VideoFrameReady(object sender, ImageFrameReadyEventArgs e) { PlanarImage image = e.ImageFrame.Image; // Large video feed video.Source = BitmapSource.Create(image.Width, image.Height, 96, 96, PixelFormats.Bgr32, null, image.Bits, image.Width * image.BytesPerPixel); // X and Y coordinates of the smaller image, and the width and height of smaller image int xCoord = 100, yCoord = 150, width = 60, height = 60; // Create an array to copy data into byte[] bytes = new byte[width * height * image.BytesPerPixel]; // Copy over the relevant bytes for (int i = 0; i < height; i++) { for (int j = 0; j < width * image.BytesPerPixel; j++) { bytes[i * (width * image.BytesPerPixel) + j] = image.Bits[(i + yCoord) * (image.Width * image.BytesPerPixel) + (j + xCoord * image.BytesPerPixel)]; } } // Create the smaller image smallVideo.Source = BitmapSource.Create(width, height, 96, 96, PixelFormats.Bgr32, null, bytes, width * image.BytesPerPixel); }
Please make sure that you understand the code, and not just copy / paste it. Two for loops are designed for basic copying of the array taking into account the number of bytes per pixel (4 for BGR32). Then you use this small subset of the source data to create a new BitmapSource. You will need to change the width / height as you see fit and determine the X and Y coordinates from head tracking.
Coeffect
source share