You're viewing an old version of the documentation. Click here to see the latest release.

将点云从毫米转换为米

本教程展示了如何使用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();

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

const auto transformMillimetersToMeters =
    Zivid::Matrix4x4{ { 0.001F, 0, 0, 0 }, { 0, 0.001F, 0, 0 }, { 0, 0, 0.001F, 0 }, { 0, 0, 0, 1 } };

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

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

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

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