Transform Point Cloud from Millimeters to Meters

This tutorial demonstrates how to transform point cloud data from millimeters to meters using a 4x4 homogeneous transformation matrix.

First, we load a point cloud.

Go to source

source

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();

We then create a 4x4 transformation matrix with 0.001 scaling.

Go to source

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 } };

Then, we transform the point cloud using this transformation matrix.

Go to source

source

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

Finally, save the transformed point cloud.

Go to source

source

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