I'm trying to capture an image using Microsoft Kinect around the head without the using of face detection. I manage to capture the whole camera image but not just around the head only. I have found some sample code on the internet but it doesn't seem to work on my program. Using Microsoft SDK v1.6 and Microsoft Visual Studio for my program. Can anyone help me on this? Thanks a lot XD
I tried the CroppedBitmap
CroppedBitmap croppedImage = new CroppedBitmap();
croppedImage.BeginInit();
croppedImage.Source = colorImageBitmap;
croppedImage.SourceRect = new Int32Rect((int)headPos.X, (int)headPos.Y, (int)imageHeight, (int)imageWidth);
croppedImage.EndInit();
headImage.Source = croppedImage;
and also the Kinect Crop Image coding but i heard that planar image is no longer exist in SDKv.16 Kinect crop image
I have also tried https://stackguides.com/questions/11435544/how-do-i-save-a-croppedbitmap-to-an-image-file, but i'm having NullReferenceException was unhandled error.
double imageHeight = heightDiff * 1.2;
double imageWidth = ((heightDiff * 1.2) / 2);
Int32Rect cropRect = new Int32Rect((int)headPos.X, (int)headPos.Y, (int)imageWidth, (int)imageHeight);
this.headImageBitmap = new WriteableBitmap(this.headImageBitmap.PixelWidth, this.headImageBitmap.PixelHeight, 96, 96, PixelFormats.Bgr32, null);
this.headImageBitmap.WritePixels(new Int32Rect((int)headPos.X, (int)headPos.Y, (int)imageWidth, (int)imageHeight), colorData, (int)imageWidth * colorFrame.BytesPerPixel, 0);
CroppedBitmap croppedImage = new CroppedBitmap(colorImageBitmap, cropRect);
headImage.Source = croppedImage;