-
Notifications
You must be signed in to change notification settings - Fork 2
PlyReader
Jianling Zhou edited this page Oct 16, 2018
·
1 revision
PlyReader provide a user-friendly api to read data from a ply file. All you need to do is to specify a entity class and call one function.
Firstly, on *NIX system, use following command to see the header of your ply file:
head -n 20 foo.ply
you will see a structure like this:
ply
format binary_little_endian 1.0
comment VCGLIB generated
element vertex 27788
property float x
property float y
property float z
property uchar red
property uchar green
property uchar blue
property uchar alpha
property float quality
element face 52113
property list uchar int vertex_indices
end_header
Secondly, you need to declare a class to describe your point cloud. Decorate the getter with an annotation @PcuElement. Make sure the name and type of field is corresponding to your ply header.
class YourPointCloud {
private List<float[]> points = new ArrayList<>();
@PcuPlyData(
properties = {"x", "y", "z"},
element = {"vertex"}
)
public List<float[]> getPoints() {
return points;
}
}Thirdly, instantiate a PlyReader, use readPointCloud() to get your point cloud.
File file = new File("path of your ply file"); //ply file
PlyReader plyReader = new PlyReader();
YourPointCloud pc = plyReader.readPointCloud(file, YourPointCloud.class);Note that @PcuPlyData must be used on a getter of a List field. The value in the list must be an java array.