IDS peak ICV v1.1.0
Loading...
Searching...
No Matches
Reading and writing objects to files

Table of Contents

The library includes support for reading from and writing objects to files, when persistent storage is needed. While the specific implementation may differ between programming interfaces, the following general rules apply:

  • File format is determined by the file extension.
    For example, a file named point_cloud.ply is saved in the Polygon File Format.
  • Existing files will be overwritten.
    If a file with the same name already exists, it will be replaced without warning.

Because the read/write mechanisms vary across interfaces, they are documented separately below.

File I/O Python

The Python interface provides a save method for all objects that support writing to a file.

point_cloud.save("point_cloud.ply")

Reading is handled via a class method named create_from_file, which takes the file path as a single string argument and returns a new instance of the class.

point_cloud = PointCloud.create_from_file("point_cloud.ply")

File I/O C++

The C++ interface provides writer classes for objects that can be saved to a file. Each writer class follows the naming convention <ClassName>Writer (e.g., PointCloudWriter).

Writing is performed using one or more write methods, where the first parameter is the file path and the second is the object to write.

peak::icv::PointCloudWriter pointCloudWriter;
pointCloudWriter.Write("point_cloud.ply", pointCloud);

Reading from a file is performed through constructors that accept a file path and return a fully initialized object.

peak::icv::PointCloudXYZ pointCloud{ "point_cloud.ply" };