void GetRemoveBackground(KinectOneLabelMap labelmap, KinectOneImage image, Kinect.ColorSpacePoint[] colorSpaces) { byte[] data = labelmap.GetData(); Color32[] _image = image.GetColorTexture().GetPixels32(); int imageWidth = image.Sensor.ColorFrameSource.FrameDescription.Width; for (int i = 0; i < outputPixels.Length; i++) { byte indexValue = data[i]; if (IsValidFloatValue(colorSpaces[i].X) || IsValidFloatValue(colorSpaces[i].Y) || indexValue == 255) { outputPixels[i] = new Color32(0, 0, 0, 0); } else { float x = colorSpaces[i].X, y = colorSpaces[i].Y; int colorIndex = (int)y * imageWidth + (int)x; outputPixels[i] = (indexValue > 0) ? ((indexValue <= labelToColor.Length) ? labelToColor[indexValue - 1] : defaultColor) : bgColor; if (indexValue == m_engageuser.engagedTrackedUser.Id && colorIndex < _image.Length && colorIndex > 0) { outputPixels[i] = _image[colorIndex]; } } } }
void UpdateTexture(KinectOneDepth depth, KinectOneLabelMap labelmap, KinectOneImage image) { int trackedUserId = -1; if (m_engageuser != null && m_engageuser.engagedTrackedUser != null) { trackedUserId = m_engageuser.engagedTrackedUser.Id; } if (trackedUserId == -1) { GetNoTrackingTexture(depth); } else { Kinect.ColorSpacePoint[] colorSpacePoints = new Kinect.ColorSpacePoint[depth.xres * depth.yres]; _mapper.MapDepthFrameToColorSpace(depth.GetData(), colorSpacePoints); GetRemoveBackground(labelmap, image, colorSpacePoints); } texture.SetPixels32(outputPixels); texture.Apply(); }
void GetRemoveBackground(KinectOneLabelMap labelmap, KinectOneImage image, Kinect.ColorSpacePoint[] colorSpaces) { byte[] data = labelmap.GetData(); Color32[] _image = image.GetColorTexture().GetPixels32(); int imageWidth = image.Sensor.ColorFrameSource.FrameDescription.Width; for (int i = 0; i < outputPixels.Length; i++) { byte indexValue = data[i]; if (IsValidFloatValue(colorSpaces[i].X) || IsValidFloatValue(colorSpaces[i].Y) || indexValue == 255) { outputPixels[i] = new Color32(0, 0, 0, 0); } else { float x=colorSpaces[i].X, y=colorSpaces[i].Y; int colorIndex = (int)y * imageWidth + (int)x; outputPixels[i] = (indexValue > 0) ? ((indexValue <= labelToColor.Length) ? labelToColor[indexValue - 1] : defaultColor) : bgColor; if (indexValue == m_engageuser.engagedTrackedUser.Id && colorIndex < _image.Length && colorIndex > 0) { outputPixels[i] = _image[colorIndex]; } } } }
void UpdateTexture(KinectOneDepth depth, KinectOneLabelMap labelmap, KinectOneImage image) { int trackedUserId = -1; if (m_engageuser != null && m_engageuser.engagedTrackedUser != null) trackedUserId = m_engageuser.engagedTrackedUser.Id; if (trackedUserId == -1) { GetNoTrackingTexture(depth); } else { Kinect.ColorSpacePoint[] colorSpacePoints = new Kinect.ColorSpacePoint[depth.xres * depth.yres]; _mapper.MapDepthFrameToColorSpace(depth.GetData(), colorSpacePoints); GetRemoveBackground(labelmap, image, colorSpacePoints); } texture.SetPixels32(outputPixels); texture.Apply(); }