pcd-loader- PCD file loader.

Safe HaskellNone




Parser for PCD (point cloud data) files.


Accessing fields

unsafeUnwrap :: PCDType a => FieldType -> aSource

Extract a raw Haskell value from the FieldType variant. If you know what you've got, this frees from having to pattern match on the FieldType constructor. If you're wrong, you'll get an exception.

Loading PCD data

loadFieldsByName :: FilePath -> IO (Text -> Vector FieldType)Source

Parse every field of every point in a PCD file. Returns a function that may be used to project out a named field.

loadFlexiblePoints :: Header -> Handle -> IO (Vector (Vector FieldType))Source

Load a Vector of points, each represented as a Vector of FieldType fields. If you wish to use field names to access to the data, consider using loadFieldsByName.

loadXyzw :: (Fractional a, Storable a) => FilePath -> IO (Vector (V4 a))Source

Read a PCD file consisting of floating point XYZW coordinates for each point (where the final "W" field may be an RGB triple encoded as a float).

loadXyz :: (Fractional a, Storable a) => FilePath -> IO (Vector (V3 a))Source

Read a PCD file consisting of floating point XYZ coordinates for each point.

Saving PCD data

saveBinaryPcd :: forall a. Storable a => FilePath -> Header -> Vector a -> IO ()Source

Use an existing PCD header to save binary point data to a file. The supplied header is used as-is, except that its format is set to Binary.

projectBinaryFields :: [Text] -> FilePath -> FilePath -> IO ()Source

Save a binary PCD file including only the named fields. This is useful when you have a PCD file that has more fields for each point than you care about. For instance, you may wish to extract just the "x", "y", and "z" fields for each point. This can be accomplished using, projectBinaryFields ["x", "y", "z"] inputFile outputFile.

PCD header creation

mkSimpleHeader :: [Text] -> (DimType, Int) -> Int -> HeaderSource

Make a PCD header for a monotyped vector point type. mkSimpleHeader fields (type,sz) n prepares a Header for n points with field names fields, field type given by type, and field size given by sz. Example to save 1000 3D points using a single-precision floating point number (4 bytes) for each field:

 mkSimpleHeader ["x","y","z"] (F,4) 1000

mkHeaderXYZ :: PCDType a => a -> Int -> HeaderSource

mkHeaderXYZ sample n builds a Header for n points with fields "x", "y", and "z" of DimType and size (in bytes) derived from the PCDType instance of sample. Example:

 mkHeaderXYZ (undefined::Float) 1000