Contenuto principale

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

Load a point cloud into the workspace.

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

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

pcwrite(ptCloud,"teapotOut",Encoding="binary");

Load a MAT file containing point cloud data into the workspace.

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.

Encoding type for the output file, specified as "ascii", "binary", or "compressed". This table summarizes the valid and default encoding types for PLY and PCD file formats.

File FormatValid Encodings
PLY

"ascii"

"binary" (default)

PCD

"ascii"

"binary"

"compressed" (default)

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

Version History

Introduced in R2015a

expand all