【发布时间】:2015-04-08 16:30:15
【问题描述】:
我正在使用官方 Kinect SDK 2.0 和 Emgu CV 来识别魔方的颜色。
一开始我在红外相机上使用 Canny Edge Extraction,因为它比 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 图像的左边缘
-
不,它们不一样。一个来自 RGB 相机 (1920 x 1080),另一个来自旁边的红外传感器 (512 x 424)。对于 Kinect v2,它们具有不同的分辨率和视角。这就是为什么我必须使用 Kinect v2 SDK 中的
CoordinateMapper。 -
我对 Kinect 不熟悉,但你可能缺少一些偏移量!
标签: c# opencv image-processing kinect emgucv