将点云从毫米转换为米

本教程展示了如何使用4x4齐次变换矩阵将点云数据从毫米转换为米。

首先,我们加载一个点云。

跳转到源

源码

const auto dataFile = std::string(ZIVID_SAMPLE_DATA_DIR) + "/CalibrationBoardInCameraOrigin.zdf";
std::cout << "Reading " << dataFile << " point cloud" << std::endl;
auto frame = Zivid::Frame(dataFile);
auto pointCloud = frame.pointCloud();
跳转到源

源码

var dataFile = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData)
               + "/Zivid/CalibrationBoardInCameraOrigin.zdf";
Console.WriteLine("Reading " + dataFile + " point cloud");
var frame = new Zivid.NET.Frame(dataFile);
var pointCloud = frame.PointCloud;

然后我们创建一个0.001缩放比例的4x4变换矩阵。

跳转到源

source

const auto transformMillimetersToMeters =
    Zivid::Matrix4x4{ { 0.001F, 0, 0, 0 }, { 0, 0.001F, 0, 0 }, { 0, 0, 0.001F, 0 }, { 0, 0, 0, 1 } };
跳转到源

source

var transformMillimetersToMeters =
    new float[,] { { 0.001F, 0, 0, 0 }, { 0, 0.001F, 0, 0 }, { 0, 0, 0.001F, 0 }, { 0, 0, 0, 1 } };

我们使用这个变换矩阵进行点云转换。

跳转到源

source

std::cout << "Transforming point cloud from mm to m" << std::endl;
pointCloud.transform(transformMillimetersToMeters);
跳转到源

source

Console.WriteLine("Transforming point cloud from mm to m");
pointCloud.Transform(transformMillimetersToMeters);

最后,保存转换后的点云。

跳转到源

source

const auto transformedFile = "FrameInMeters.zdf";
std::cout << "Saving transformed point cloud to file: " << transformedFile << std::endl;
frame.save(transformedFile);
跳转到源

source

var transformedFile = "FrameInMeters.zdf";
Console.WriteLine("Saving frame to file: " + transformedFile);
frame.Save(transformedFile);