/// <summary> /// Update the depth viewer texture. /// </summary> /// <param name="depth">The depth map</param> private void UpdateTexture(ZigDepth depth, ZigInputJoint[] userSkeleton) { short[] rawDepthMap = depth.data; int depthIndex = 0; int factorX = depth.xres / textureSize.Width; int factorY = ((depth.yres / textureSize.Height) - 1) * depth.xres; // invert Y axis while doing the update for (int y = textureSize.Height - 1; y >= 0; --y, depthIndex += factorY) { int outputIndex = y * textureSize.Width; for (int x = 0; x < textureSize.Width; ++x, depthIndex += factorX, ++outputIndex) { outputPixels[outputIndex] = depthToColor[rawDepthMap[depthIndex]]; } } if (userSkeleton != null && showBones) { DrawBones(userSkeleton); } if (userSkeleton != null && showNodes) { DrawJoints(userSkeleton); } texture.SetPixels32(outputPixels); texture.Apply(); }
public ZigInputKinectOne() { _sensor = KinectSensor.GetDefault(); _mapper = _sensor.CoordinateMapper; _depth = new KinectOneDepth(_sensor); _image = new KinectOneImage(_sensor); _labelMap = new KinectOneLabelMap(_sensor); }
private void updateTexture(ZigDepth depth) { short[] rawDepthMap = depth.data; int depthIndex = 0; int factorX = depth.xres/WIDTH; int factorY = ((depth.yres/HEIGHT) - 1)*depth.xres; for (int y = HEIGHT - 1; y >= 0; --y, depthIndex += factorY) { int outputIndex = y*WIDTH; for (int x = 0; x < WIDTH; ++x, depthIndex += factorX, ++outputIndex) { outputPixels[outputIndex] = depthToColor[rawDepthMap[depthIndex]]; } } DepthTexture.SetPixels32(outputPixels); DepthTexture.Apply(); }
void UpdateHistogram(ZigDepth depth) { int i, numOfPoints = 0; System.Array.Clear(depthHistogramMap, 0, depthHistogramMap.Length); short[] rawDepthMap = depth.data; int depthIndex = 0; // assume only downscaling // calculate the amount of source pixels to move per column and row in // output pixels int factorX = depth.xres / textureSize.Width; int factorY = ((depth.yres / textureSize.Height) - 1) * depth.xres; for (int y = 0; y < textureSize.Height; ++y, depthIndex += factorY) { for (int x = 0; x < textureSize.Width; ++x, depthIndex += factorX) { short pixel = rawDepthMap[depthIndex]; if (pixel != 0) { depthHistogramMap[pixel]++; numOfPoints++; } } } depthHistogramMap[0] = 0; if (numOfPoints > 0) { for (i = 1; i < depthHistogramMap.Length; i++) { depthHistogramMap[i] += depthHistogramMap[i - 1]; } depthToColor[0] = Color.black; for (i = 1; i < depthHistogramMap.Length; i++) { float intensity = (1.0f - (depthHistogramMap[i] / numOfPoints)); //depthHistogramMap[i] = intensity * 255; depthToColor[i].r = (byte)(BaseColor.r * intensity); depthToColor[i].g = (byte)(BaseColor.g * intensity); depthToColor[i].b = (byte)(BaseColor.b * intensity); depthToColor[i].a = 255;//(byte)(BaseColor.a * intensity); } } }
private void updateTexture(ZigDepth depth) { short[] rawDepthMap = depth.data; int depthIndex = 0; int factorX = depth.xres / WIDTH; int factorY = ((depth.yres / HEIGHT) - 1) * depth.xres; for (int y = HEIGHT - 1; y >= 0; --y, depthIndex += factorY) { int outputIndex = y * WIDTH; for (int x = 0; x < WIDTH; ++x, depthIndex += factorX, ++outputIndex) { outputPixels[outputIndex] = depthToColor[rawDepthMap[depthIndex]]; } } DepthTexture.SetPixels32(outputPixels); DepthTexture.Apply(); }
void UpdateTexture(ZigDepth depth) { short[] rawDepthMap = depth.data; int depthIndex = 0; int factorX = depth.xres / textureSize.Width; int factorY = ((depth.yres / textureSize.Height) - 1) * depth.xres; // invert Y axis while doing the update for (int y = textureSize.Height - 1; y >= 0; --y, depthIndex += factorY) { int outputIndex = y * textureSize.Width; for (int x = 0; x < textureSize.Width; ++x, depthIndex += factorX, ++outputIndex) { outputPixels[outputIndex] = depthToColor[rawDepthMap[depthIndex]]; } } texture.SetPixels32(outputPixels); texture.Apply(); }
/// <summary> /// Update the histogram given the depth map. /// </summary> /// <param name="depth">The depth map</param> private void UpdateHistogram(ZigDepth depth) { int i, numOfPoints = 0; BaseSystem.Array.Clear(depthHistogramMap, 0, depthHistogramMap.Length); short[] rawDepthMap = depth.data; int depthIndex = 0; int factorX = depth.xres / textureSize.Width; int factorY = ((depth.yres / textureSize.Height) - 1) * depth.xres; for (int y = 0; y < textureSize.Height; ++y, depthIndex += factorY) { for (int x = 0; x < textureSize.Width; ++x, depthIndex += factorX) { short pixel = rawDepthMap[depthIndex]; if (pixel != 0) { depthHistogramMap[pixel]++; numOfPoints++; } } } depthHistogramMap[0] = 0; if (numOfPoints > 0) { for (i = 1; i < depthHistogramMap.Length; i++) { depthHistogramMap[i] += depthHistogramMap[i - 1]; } depthToColor[0] = Color.black; for (i = 1; i < depthHistogramMap.Length; i++) { float intensity = (1.0f - (depthHistogramMap[i] / numOfPoints)); depthToColor[i].r = (byte)(BaseColor.r * intensity); depthToColor[i].g = (byte)(BaseColor.g * intensity); depthToColor[i].b = (byte)(BaseColor.b * intensity); depthToColor[i].a = 255; } } }
void UpdateHistogram(ZigDepth depth) { int i, numOfPoints = 0; System.Array.Clear(depthHistogramMap, 0, depthHistogramMap.Length); short[] rawDepthMap = depth.data; int depthIndex = 0; // assume only downscaling // calculate the amount of source pixels to move per column and row in // output pixels int factorX = depth.xres/textureSize.Width; int factorY = ((depth.yres / textureSize.Height) - 1) * depth.xres; for (int y = 0; y < textureSize.Height; ++y, depthIndex += factorY) { for (int x = 0; x < textureSize.Width; ++x, depthIndex += factorX) { short pixel = rawDepthMap[depthIndex]; if (pixel != 0) { depthHistogramMap[pixel]++; numOfPoints++; } } } depthHistogramMap[0] = 0; if (numOfPoints > 0) { for (i = 1; i < depthHistogramMap.Length; i++) { depthHistogramMap[i] += depthHistogramMap[i - 1]; } depthToColor[0] = Color.black; for (i = 1; i < depthHistogramMap.Length; i++) { float intensity = (1.0f - (depthHistogramMap[i] / numOfPoints)); //depthHistogramMap[i] = intensity * 255; depthToColor[i].r = (byte)(BaseColor.r * intensity); depthToColor[i].g = (byte)(BaseColor.g * intensity); depthToColor[i].b = (byte)(BaseColor.b * intensity); depthToColor[i].a = 255;//(byte)(BaseColor.a * intensity); } } }
void UpdateTexture(ZigDepth depth) { short[] rawDepthMap = depth.data; int depthIndex = 0; int factorX = depth.xres / textureSize.Width; int factorY = ((depth.yres / textureSize.Height) - 1) * depth.xres; // invert Y axis while doing the update for (int y = textureSize.Height - 1; y >= 0 ; --y, depthIndex += factorY) { int outputIndex = y * textureSize.Width; for (int x = 0; x < textureSize.Width; ++x, depthIndex += factorX, ++outputIndex) { outputPixels[outputIndex] = depthToColor[rawDepthMap[depthIndex]]; } } texture.SetPixels32(outputPixels); texture.Apply(); }