简体   繁体   English

带播放器索引和视频流的Kinect深度

[英]Kinect depth with player index + video stream

I'm trying to produce an image from the kinect where all pixel that do not represent a player will be set to black. 我正在尝试从kinect生成图像,其中所有不代表玩家的像素都将设置为黑色。

My idea is to use the data produced by the depthstream with player index along with the videostream to accomplish this task. 我的想法是将深度流产生的数据与播放器索引以及视频流一起使用以完成此任务。

My hope was to do something like this: 我的希望是做这样的事情:

byte[] pixelData = video.imageFrame.Bits;
byte[] depthData = depth.imageFrame.Bits;

var depthIndex = 0;
for (var y = 0; y < height; y++)
{
     var heightOffset = y * width;

     for (var x = 0; x < width; x++)
     {
          var index = (x + heightOffset) * 4;

          var distance = GetDistanceWithPlayerIndex(depthData[depthIndex], depthData[depthIndex + 1]);

          if (GetPlayerIndex(depthData[depthIndex]) == 0)
          {
               pixelData[index + BlueIndex] = 0;
               pixelData[index + GreenIndex] = 0;
               pixelData[index + RedIndex] = 0;
          }
     }
}

The issue that I am currently working on it trying to get the videostream data to have the same resolution as the depthwithplayerindex. 我当前正在处理的问题试图使视频流数据具有与depthwithplayerindex相同的分辨率。

I've tried to piece some stuff together from other posts on here but I can't get it to work: 我尝试将此处的其他帖子中的内容拼凑起来,但无法正常工作:

private byte[] ScaleVideoImage(ImageFrame imageFrame, int newWidth, int newHeight)
        {
            //convert imageFrame to byte array
            Byte[] oPixelData = imageFrame.Image.Bits;

            Image tempImage = BytesToImg(oPixelData);
            //scale image
            Bitmap bmp = new Bitmap(newWidth, newHeight);
            using (Graphics graphics = Graphics.FromImage(bmp))
            {
                graphics.CompositingQuality = System.Drawing.Drawing2D.CompositingQuality.HighQuality;
                graphics.InterpolationMode = System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
                graphics.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;

                graphics.DrawImage(tempImage, 0, 0, bmp.Width, bmp.Height);
            }
            //Convert image to byte array
            MemoryStream ms1 = new MemoryStream();
            bmp.Save(ms1, ImageFormat.Jpeg);
            byte[] result = ms1.GetBuffer();
            bmp.Dispose();
            ms1.Close();
            return result;
        }

Any ideas? 有任何想法吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM