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

source

data_file = get_sample_data_path() / "CalibrationBoardInCameraOrigin.zdf"
print(f"Reading {data_file} point cloud")
frame = zivid.Frame(data_file)
point_cloud = frame.point_cloud()

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

Go to source

source

const auto millimetersToMetersTransform =
    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 millimetersToMetersTransform =
    new float[,] { { 0.001F, 0, 0, 0 }, { 0, 0.001F, 0, 0 }, { 0, 0, 0.001F, 0 }, { 0, 0, 0, 1 } };
Go to source

source

transform_millimeters_to_meters = np.array(
    [[0.001, 0, 0, 0], [0, 0.001, 0, 0], [0, 0, 0.001, 0], [0, 0, 0, 1]], dtype=np.float32
)

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

source

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

source

print("Transforming point cloud from mm to m")
point_cloud.transform(transform_millimeters_to_meters)

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

source

transformed_file = "FrameInMeters.zdf"
print(f"Saving transformed point cloud to file: {transformed_file}")
frame.save(transformed_file)