Kinect上的颜色和深度传感器产生的图像略微不对齐。我怎样才能改变他们使他们排队?如何将kinect的深度图像与彩色图像对齐
回答
的关键,这是调用“Runtime.NuiCamera.GetColorPixelCoordinatesFromDepthPixel”
下面是Runtime类的扩展方法。它返回一个WriteableBitmap对象。作为新帧进来这WriteableBitmap的自动更新,因此它的用法非常简单:
kinect = new Runtime();
kinect.Initialize(RuntimeOptions.UseColor | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseDepthAndPlayerIndex);
kinect.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
kinect.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
myImageControl.Source = kinect.CreateLivePlayerRenderer();
,这里是代码本身:
public static class RuntimeExtensions
{
public static WriteableBitmap CreateLivePlayerRenderer(this Runtime runtime)
{
if (runtime.DepthStream.Width == 0)
throw new InvalidOperationException("Either open the depth stream before calling this method or use the overload which takes in the resolution that the depth stream will later be opened with.");
return runtime.CreateLivePlayerRenderer(runtime.DepthStream.Width, runtime.DepthStream.Height);
}
public static WriteableBitmap CreateLivePlayerRenderer(this Runtime runtime, int depthWidth, int depthHeight)
{
PlanarImage depthImage = new PlanarImage();
WriteableBitmap target = new WriteableBitmap(depthWidth, depthHeight, 96, 96, PixelFormats.Bgra32, null);
var depthRect = new System.Windows.Int32Rect(0, 0, depthWidth, depthHeight);
runtime.DepthFrameReady += (s, e) =>
{
depthImage = e.ImageFrame.Image;
Debug.Assert(depthImage.Height == depthHeight && depthImage.Width == depthWidth);
};
runtime.VideoFrameReady += (s, e) =>
{
// don't do anything if we don't yet have a depth image
if (depthImage.Bits == null) return;
byte[] color = e.ImageFrame.Image.Bits;
byte[] output = new byte[depthWidth * depthHeight * 4];
// loop over each pixel in the depth image
int outputIndex = 0;
for (int depthY = 0, depthIndex = 0; depthY < depthHeight; depthY++)
{
for (int depthX = 0; depthX < depthWidth; depthX++, depthIndex += 2)
{
// combine the 2 bytes of depth data representing this pixel
short depthValue = (short)(depthImage.Bits[depthIndex] | (depthImage.Bits[depthIndex + 1] << 8));
// extract the id of a tracked player from the first bit of depth data for this pixel
int player = depthImage.Bits[depthIndex] & 7;
// find a pixel in the color image which matches this coordinate from the depth image
int colorX, colorY;
runtime.NuiCamera.GetColorPixelCoordinatesFromDepthPixel(
e.ImageFrame.Resolution,
e.ImageFrame.ViewArea,
depthX, depthY, // depth coordinate
depthValue, // depth value
out colorX, out colorY); // color coordinate
// ensure that the calculated color location is within the bounds of the image
colorX = Math.Max(0, Math.Min(colorX, e.ImageFrame.Image.Width - 1));
colorY = Math.Max(0, Math.Min(colorY, e.ImageFrame.Image.Height - 1));
output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 0];
output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 1];
output[outputIndex++] = color[(4 * (colorX + (colorY * e.ImageFrame.Image.Width))) + 2];
output[outputIndex++] = player > 0 ? (byte)255 : (byte)0;
}
}
target.WritePixels(depthRect, output, depthWidth * PixelFormats.Bgra32.BitsPerPixel/8, 0);
};
return target;
}
}
一种方式做,这是假设颜色和深度图像在它们之间具有相似的变化,并且使两个图像(或它们的较小版本)交叉相关。
- Pre-whiten the image s到获得在底层的变化。
- Cross-correlate预白化图像或它们的较小版本。
- 互相关的峰值位置会告诉你抵消X和ÿ
Peter,那些是有趣的文章。不过,我认为这个解决方案可能会更具经验。我认为这可能只是一个抵消或类似的东西 –
:-)好的。我可能过度思考它。 [我刚读过这类东西......](http://liu.diva-portal.org/smash/record.jsf?pid=diva2:420400) –
在工厂里,每个kinect设备都经过校准并且相机之间的偏移量会被刻录到设备的内存中。诀窍在于找到合适的API来利用这些数据。现在官方的kinect sdk只提供一个这样的API,但其他人正在考虑未来版本 –
- 1. Kinect深度和图像帧对齐
- 2. kinect深度图像处理
- 3. Kinect不显示彩色图像
- 4. Kinect深度图像仅部分可见
- 5. 在Matlab中保存Kinect深度图像?
- 6. 来自Kinect的深度图像:索引图像?
- 7. 将JavaScript图像与HTML图像对齐
- 8. 将彩色图像转换为灰度
- 9. 将灰度图像转换为彩色
- 10. 图像大小取决于图像的色彩位深
- 11. 彩色图像与Raphael.js灰度图像不工作在I.E. 9
- 12. 如何将现有的彩色图像变成黑白图像?
- 13. 如何将图像与中心对齐?
- 14. 如何将文本与图像对齐?
- 15. 如何将字幕与图像对齐?
- 16. 如何将图像与名称对齐?
- 17. 是否有任何好的彩色地图使用python的PIL将灰度图像转换为彩色图像?
- 18. 如何识别图像是灰度图像或彩色图像在c#
- 19. 使用Kinect 1.0 SDK对RGB图像进行深度图像故障修正
- 20. C# - 如何将图像转换为8位彩色图像?
- 21. 如何填写的黑色斑块在Kinect的V1深度图像
- 22. CSS:如何将彩色图像变成灰色或黑色/白色图像
- 23. 如何对齐图像中的图像
- 24. 如何在MATLAB中将彩色图像转换为灰度图像?
- 25. 将图像对齐
- 26. 图像为16bpp时,从位图获取彩色图像灰度
- 27. Kinect和Opencv,深度图像,如何使用它
- 28. 真正灰度的彩色图像的理想图像格式
- 29. 像素深度与颜色深度
- 30. 如何从彩色图像动画到灰色图像?
可悲的是链接的,现在扔死我的方式的黄色画面。但我正在研究你提到的方法 –
@ Mr-Bell - 我用实际的代码而不是链接来更新这篇文章 –
这看起来像是有效的。它看起来好像调用GetColorPixelCoordinatesFromDepthPixel正在杀死我的帧速率。 –