PDAL / PDAL

PDAL is Point Data Abstraction Library. GDAL for point cloud data.
https://pdal.io
Other
1.14k stars 446 forks source link

Support parsing "rgb" from PCD files #4456

Open abellgithub opened 4 months ago

abellgithub commented 4 months ago

PCD contains special handling for Red, Green and Blue stored as a single entity. These may be stored as 4 byte floating or integral values. PDAL should parse the "rgb" field into Red, Green and Blue dimensions.

See: #2880

claumeh commented 4 months ago

Yes, I agree. There is a non standard pcd being created with the writers.pcd containing no rgb values. Even I try to tell the writers.pcd what type and order of output I need.

{ "type": "writers.pcd", "filename": "data/output.pcd", "compression": "ascii", "order": "X,Y,Z,Red,Green,Blue" },

Am I doing something wrong? But even opening it in Cloud Compare shows there is no RGB values.

claumeh commented 4 months ago

Also open3d confirms that the colors are not contained as this test shows:

`import open3d as o3d import numpy as np

Load the PCD file

pcd = o3d.io.read_point_cloud(input_pcd) # Replace with the correct path to your PCD file

Check if the PCD file has color information

if not pcd.has_colors(): print("PCD file does not contain color information")

Output

PCD file does not contain color information `

bloom256 commented 4 months ago

I usually do this:

{
  "pipeline": [
    {
      "type": "readers.las",
      "filename": "/workdir/${input_file}"
    },
    {
      "type": "filters.assign",
      "value": ["Red = Red / 256", "Green = Green / 256", "Blue = Blue / 256"]
    },
    {
      "type": "filters.ferry",
      "dimensions": "=> RGB"
    },
    {
      "type": "filters.assign",
      "value": "RGB = (Red * 65536 + Green * 256 + Blue)"
    },
    {
      "type": "writers.pcd",
      "filename": "/workdir/${output_file}",
      "compression": "binary",
      "order": "X=Double,Y=Double,Z=Double,RGB=Unsigned32,intensity=Unsigned16",
      "keep_unspecified": "false"
    }
  ]
}

You can also do the reverse transformation while reading the .pcd with ferry and assign. PDAL is quite powerful.