Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open3D saved ply cannot be ready by pcl? #1633

Closed
Guptajakala opened this issue Mar 17, 2020 · 3 comments
Closed

Open3D saved ply cannot be ready by pcl? #1633

Guptajakala opened this issue Mar 17, 2020 · 3 comments
Assignees

Comments

@Guptajakala
Copy link

IMPORTANT: Please use the following template to report the bug.


Describe the bug
Open3D saved ply cannot be ready by pcl:

o3d.io.write_point_cloud(...)
pcl::io::readPLYFile(...)

Then pcl will get empty cloud

Environment (please complete the following information):

  • OS: Ubuntu 16.04
  • Python version: 3.6
  • Open3D version: 0.9.0.0
  • Is this remote workstation?: no
  • How did you install Open3D?: conda
@Guptajakala
Copy link
Author

this problem still exists.

@heethesh
Copy link
Contributor

heethesh commented Aug 11, 2021

Same issue here, when converted back from ply (generated by Open3D) to pcd using the pcl_ply2pcd tool, I just see 3x3 cube of 27 points in the PCL viewer. I also don't see the ply header in the file when compared to what PCL tools generate.

@reyanshsolis
Copy link
Collaborator

Hi @heethesh @Guptajakala,
Thanks for finding out about this issue.

Here is what I found:

  • Open3D IO (Legacy/Eigen based) only supports double. Therefore while reading the data is converted to double, and while saving x,y, z, nx, ny, nz are saved as double, while color r, g, b are converted to uchar.
  • PCL PLY format does not seem to support double.
    Therefore, PLY files saved by Open3D Legacy/Eigen IO is incompatible with PCL PLY, as it lacks support for double value attributes.

However,

  • The NEW Open3D Tensor IO, supports saving files in the original attribute (float -> float, double -> double). So, one may use that to save point clouds in Float, which is compatible with PCL.

Conclusion:

  • PCL does not support Double attribute in PLY format (to my understanding, there might be some other way too).
  • Please use the NEW Open3D Tensor IO, as is it supports various data types and custom attributes.

PCL C++ Test Code for PLY IO:

#include <pcl/io/ply_io.h>
#include <pcl/point_types.h>

#include <iostream>

int
main(int argc, char* argv[])

{
  if (argc < 2) {
    std::cout << "Please pass the path to PLY file, as argument.";
    return 1;
  }

  const std::string path = argv[1];

  pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);

  if (pcl::io::loadPLYFile<pcl::PointXYZ>(path, *cloud) == -1) //* load the file
  {
    PCL_ERROR("Couldn't read file o3d_io_ply_ascii.ply \n");
    return (-1);
  }

  std::cout << "Loaded " << cloud->width * cloud->height
            << " data points from test_ply.ply with the following fields: "
            << std::endl;
  for (const auto& point : *cloud)
    std::cout << "    " << point.x << " " << point.y << " " << point.z << std::endl;

  return (0);
}

original.ply is a ply generated by PCL, with Float Points, Normals, Curvature, and UChar Colors.

Case 1: Open3D Legacy/Eigen based IO : File Generated by the following code are NOT supported by PCL.

import open3d as o3d
pcd = o3d.io.read_point_cloud("/home/rey/original.ply")
o3d.io.write_point_cloud("/home/rey/o3d_io_ply_ascii.ply", pcd, write_ascii=True, compressed=False)
o3d.io.write_point_cloud("/home/rey/o3d_io_ply_ascii_compressed.ply", pcd, write_ascii=True, compressed=False)
o3d.io.write_point_cloud("/home/rey/o3d_io_ply_bin.ply", pcd, write_ascii=False, compressed=False)
o3d.io.write_point_cloud("/home/rey/o3d_io_ply_bin_compressed.ply", pcd, write_ascii=False, compressed=True)

Case 2: Open3D New Tensor IO : File Generated by the following code are supported by PCL.

tpcd = o3d.t.io.read_point_cloud("/home/rey/original.ply")
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_ascii.ply", tpcd, write_ascii=True, compressed=False)
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_ascii_compressed.ply", tpcd, write_ascii=True, compressed=False)
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_bin.ply", tpcd, write_ascii=False, compressed=False)
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_bin_compressed.ply", tpcd, write_ascii=False, compressed=True)

Case 3: Converted to Float64/Double by Open3D and then saved by Tensor IO: File Generated by the following code are NOT supported by PCL.

tpcd_f64 = o3d.t.io.read_point_cloud("/home/rey/original.ply")

for attr in tpcd_f64.point:
    tpcd_f64.point[attr] = tpcd_f64.point[attr].to(o3d.core.float64)
    
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_ascii64.ply", tpcd_f64, write_ascii=True, compressed=False)
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_ascii_compressed64.ply", tpcd_f64, write_ascii=True, compressed=False)
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_bin64.ply", tpcd_f64, write_ascii=False, compressed=False)
o3d.t.io.write_point_cloud("/home/rey/o3d_tio_ply_bin_compressed64.ply", tpcd_f64, write_ascii=False, compressed=True)

f-dy added a commit to f-dy/nerfstudio that referenced this issue Mar 9, 2023
Use the newer Open3D Tensor API to write pointclouds as float32, which
are compatible with PCL (see isl-org/Open3D#1633).

fixes nerfstudio-project#1571
f-dy added a commit to f-dy/nerfstudio that referenced this issue Mar 9, 2023
Use the newer Open3D Tensor API to write pointclouds as float32, which
are compatible with PCL (see isl-org/Open3D#1633).

fixes nerfstudio-project#1571
f-dy added a commit to f-dy/nerfstudio that referenced this issue Mar 9, 2023
Use the newer Open3D Tensor API to write pointclouds as float32, which
are compatible with PCL (see isl-org/Open3D#1633).

fixes nerfstudio-project#1571
f-dy added a commit to f-dy/nerfstudio that referenced this issue Mar 10, 2023
Use the newer Open3D Tensor API to write pointclouds as float32, which
are compatible with PCL (see isl-org/Open3D#1633).

fixes nerfstudio-project#1571
tancik pushed a commit to nerfstudio-project/nerfstudio that referenced this issue Mar 10, 2023
* scripts/exporter.py: export PLY compatible with PCL

Use the newer Open3D Tensor API to write pointclouds as float32, which
are compatible with PCL (see isl-org/Open3D#1633).

fixes #1571

* exporter.py: pylint: disable=no-member

fixes https://github.com/nerfstudio-project/nerfstudio/actions/runs/4377569585/jobs/7661246358#step:10:13

open3d.core.Dtype has been around since open3d 0.11.0 http://www.open3d.org/docs/0.11.0/python_api/open3d.core.Dtype.html

---------

Co-authored-by: Frédéric Devernay <f-dy@users.noreply.github.com>
chris838 pushed a commit to chris838/nerfstudio that referenced this issue Apr 22, 2023
…ct#1572)

* scripts/exporter.py: export PLY compatible with PCL

Use the newer Open3D Tensor API to write pointclouds as float32, which
are compatible with PCL (see isl-org/Open3D#1633).

fixes nerfstudio-project#1571

* exporter.py: pylint: disable=no-member

fixes https://github.com/nerfstudio-project/nerfstudio/actions/runs/4377569585/jobs/7661246358#step:10:13

open3d.core.Dtype has been around since open3d 0.11.0 http://www.open3d.org/docs/0.11.0/python_api/open3d.core.Dtype.html

---------

Co-authored-by: Frédéric Devernay <f-dy@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants