我正在使用 Kinect 传感器开发 3D 模型重建应用程序。我使用 Microsoft SDK 获取深度数据,我想计算现实世界中每个点的位置。我已经阅读了几篇关于它的文章,并且我已经实现了几种深度校准方法,但它们都不适用于我的应用程序。最接近的校准是http://openkinect.org/wiki/Imaging_Information 但我在 Meshlab 中的结果是不可接受的。我通过这种方法计算深度值:
private double GetDistance(byte firstByte, byte secondByte)
{
double distance = (double)(firstByte >> 3 | secondByte << 5);
return distance;
}
然后我用下面的方法来计算现实世界的距离
public static float RawDepthToMeters(int depthValue)
{
if (depthValue < 2047)
{
return (float)(0.1 / ((double)depthValue * -0.0030711016 + 3.3309495161));
}
return 0.0f;
}
public static Point3D DepthToWorld(int x, int y, int depthValue)
{
const double fx_d = 5.9421434211923247e+02;
const double fy_d = 5.9104053696870778e+02;
const double cx_d = 3.3930780975300314e+02;
const double cy_d = 2.4273913761751615e+02;
double depth = RawDepthToMeters(depthValue);
Point3D result = new Point3D((float)((x - cx_d) * depth / fx_d),
(float)((y - cy_d) * depth / fy_d), (float)(depth));
return result;
}
这些方法效果不佳,生成的场景不正确。然后我使用了下面的方法,结果比以前的方法好,但还不能接受。
public static Point3D DepthToWorld(int x, int y, int depthValue)
{
const int w = 640;
const int h = 480;
int minDistance = -10;
double scaleFactor = 0.0021;
Point3D result = new Point3D((x - w / 2) * (depthValue + minDistance) * scaleFactor * (w/h),
(y - h / 2) * (depthValue + minDistance) * scaleFactor,depthValue);
return result;
}
我想知道您是否让我知道如何根据我的方法计算的深度像素值来计算真实世界的位置。