Main Content

pcwrite

Write 3-D point cloud to PLY or PCD file

Description

pcwrite(ptCloud,filename) writes the point cloud object, ptCloud, to the PLY or PCD file specified by the input filename.

example

pcwrite(ptCloud,filename,Encoding=encodingType) writes a pointCloud object, ptCloud, to a PLY file that is in the specified format.

Examples

collapse all

ptCloud = pcread("teapot.ply");
pcshow(ptCloud); 

Figure contains an axes object. The axes object contains an object of type scatter.

pcwrite(ptCloud,"teapotOut",PLYFormat="binary");
load('object3d.mat');
pcwrite(ptCloud,'object3d.pcd','Encoding','ascii');
pc = pcread('object3d.pcd');
pcshow(pc);

Figure contains an axes object. The axes object contains an object of type scatter.

Input Arguments

collapse all

File name, specified as a character vector or string scalar. The input file type must be a PLY or PCD format file.

For a PLY-file, the pcwrite function converts an organized M-by-N-by-3 point cloud to an unorganized M-by-3 format. It converts the format because PLY files do not support organized point clouds. To preserve the organized format, you can save the point cloud as a PCD-file.

If you do not specify the file name with an extension, the function writes the file in a PLY-format. All NaN or Inf values will be skipped when writing to a PLY file.

Object for storing point cloud, specified as a pointCloud object.

PLY or PCD formatted file, specified as "ascii", "binary", or "compressed" for the file format.

File FormatValid Encodings
PLY

"ascii", "binary"

PCD

"ascii", "binary", or "compressed"

Note

The PCD file format does not support storing colors of datatype uint16. You can downsize the color to uint8 to save the file in a PCD format or save it in the PLY format.

To improve performance when writing large point clouds, use the "compressed" or "binary" file type.

Version History

Introduced in R2015a