void UpdateTexture(ZigLabelMap labelmap, ZigImage image) { Color32[] rawImageMap = image.data; Debug.Log(rawImageMap.Length); short[] rawLabelMap = labelmap.data; int labelMapIndex = 0; int imageMapIndex = 0; int factorX = labelmap.xres / textureSize.Width; int factorY = ((labelmap.yres / textureSize.Height) - 1) * labelmap.xres; int factorXImage = image.xres / textureSize.Width; int factorYImage = ((image.yres / textureSize.Height) - 1) * image.xres; // invert Y axis while doing the update for (int y = textureSize.Height - 1; y >= 0; --y, imageMapIndex += factorYImage) { int outputIndex = (y + offsetY) % (textureSize.Height - 1) * textureSize.Width; for (int x = 0; x < textureSize.Width; ++x, imageMapIndex += factorXImage, ++outputIndex) { outputPixels[outputIndex] = rawImageMap[Mathf.Max(0, imageMapIndex + (offsetX % (textureSize.Width * factorXImage)))];//((((textureSize.Height - 1) * factorYImage - (offsetY % (textureSize.Height * factorYImage))))))]; } } for (int y = textureSize.Height - 1; y >= 0; --y, labelMapIndex += factorY) { int outputIndex = y * textureSize.Width; for (int x = 0; x < textureSize.Width; ++x, labelMapIndex += factorX, outputIndex++) { short label = rawLabelMap[labelMapIndex]; outputPixels[outputIndex].a = (label>0) ? defaultColor.a : bgColor.a; } } texture.SetPixels32(outputPixels); texture.Apply(); }
private void UpdateTexture(ZigImage image, ZigInputJoint[] userSkeleton) { if (image.data == null) { return; } Color32[] rawImageMap = image.data; int srcIndex = 0; int factorX = image.xres / textureSize.Width; int factorY = ((image.yres / textureSize.Height) - 1) * image.xres; // invert Y axis while doing the update for (int y = textureSize.Height - 1; y >= 0; --y, srcIndex += factorY) { int outputIndex = y * textureSize.Width; for (int x = 0; x < textureSize.Width; ++x, srcIndex += factorX, ++outputIndex) { outputPixels[outputIndex] = rawImageMap[srcIndex]; } } 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); }
void UpdateTexture(ZigImage image) { Color32[] rawImageMap = image.data; int srcIndex = 0; int factorX = image.xres / textureSize.Width; int factorY = ((image.yres / textureSize.Height) - 1) * image.xres; // invert Y axis while doing the update for (int y = textureSize.Height - 1; y >= 0; --y, srcIndex += factorY) { int outputIndex = y * textureSize.Width; for (int x = 0; x < textureSize.Width; ++x, srcIndex += factorX, ++outputIndex) { outputPixels[outputIndex] = rawImageMap[srcIndex]; } } texture.SetPixels32(outputPixels); texture.Apply(); }