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();
Go to source

source

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;

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 } };
Go to source

source

var transformMillimetersToMeters =
    new float[,] { { 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);
Go to source

source

Console.WriteLine("Transforming point cloud from mm to m");
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);
Go to source

source

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