1
我使用官方的Kinect SDK 2.0和Emgu CV来识别Rubik's Cube的颜色。Kinect v2红外传感器和RGB图像的对齐总是稍微偏离
起初我用Canny边缘提取物对红外摄像机,因为它处理比RGB摄像头更好的不同照明条件和要好得多检测轮廓。
然后,我使用此代码将红外传感器的坐标转换为RGB相机的坐标。 正如你可以看到图片中他们仍然不符合我的要求。由于我已经使用官方KinectSensor.CoordinateMapper.MapDepthFrameToColorSpace
,我不知道如何改善这种情况。
using (var colorFrame = reference.ColorFrameReference.AcquireFrame())
using (var irFrame = reference.InfraredFrameReference.AcquireFrame())
{
if (colorFrame == null || irFrame == null)
return;
// initialize depth frame data
FrameDescription depthDesc = irFrame.FrameDescription;
if (_depthData == null)
{
uint depthSize = depthDesc.LengthInPixels;
_depthData = new ushort[depthSize];
_colorSpacePoints = new ColorSpacePoint[depthSize];
// fill Array with max value so all pixels can be mapped
for (int i = 0; i < _depthData.Length; i++)
{
_depthData[i] = UInt16.MaxValue;
}
// didn't work so well with the actual depth-data
//depthFrame.CopyFrameDataToArray(_depthData);
_sensor.CoordinateMapper.MapDepthFrameToColorSpace(_depthData, _colorSpacePoints);
}
}
这是一个辅助功能我为了点阵列转换红外空格键以色彩空间
public static System.Drawing.Point[] DepthPointsToColorSpace(System.Drawing.Point[] depthPoints, ColorSpacePoint[] colorSpace){
for (int i = 0; i < depthPoints.Length; i++)
{
// 512 is the width of the depth/infrared image
int index = 512 * depthPoints[i].Y + depthPoints[i].X;
depthPoints[i].X = (int)Math.Floor(colorSpace[index].X + 0.5);
depthPoints[i].Y = (int)Math.Floor(colorSpace[index].Y + 0.5);
}
return depthPoints;
}
都是真的一样吗?在红外传感器中,我们可以看到左侧仍然有很多空间,而您是RGB图像中的左侧边缘 – chouaib 2015-02-09 00:55:25
不,它们不一样。一个来自RGB摄像机(1920 x 1080),另一个来自红外传感器(512 x 424)。对于Kinect v2,它们具有不同的分辨率和视角。这就是为什么我必须使用Kinect v2 SDK中的'CoordinateMapper'。 – Hedge 2015-02-09 01:10:15
我对Kinect并不熟悉,但是您可能会错过一些抵消! – chouaib 2015-02-09 01:12:19