-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | PCD file loader. -- -- Parser for PCD (point cloud data) formats. See -- http://pointclouds.org/documentation/tutorials/pcd_file_format.php -- for more information. @package pcd-loader @version 0.3.0.0 -- | Common types for dealing with PCD files. module PCD.Internal.Types -- | A 2-dimensional vector data V2 a :: * -> * V2 :: a -> a -> V2 a -- | A 3-dimensional vector data V3 a :: * -> * V3 :: a -> a -> a -> V3 a -- | A 4-dimensional vector. data V4 a :: * -> * V4 :: a -> a -> a -> a -> V4 a type M44 a = V4 (V4 a) data Quaternion a :: * -> * Quaternion :: a -> {-# UNPACK #-} !(V3 a) -> Quaternion a -- | Storable-based vectors data Vector a :: * -> * -- | 8-bit unsigned integer type data Word8 :: * -- | Define a data structure for a PCD file header and an associated -- parser. module PCD.Header -- | Fields attached to a point may be signed integers (I), unsigned -- integers (U), or floating point (F). data DimType I :: DimType U :: DimType F :: DimType -- | The PCD format has both ASCII and binary variants. data DataFormat ASCII :: DataFormat Binary :: DataFormat data FieldType TUchar :: {-# UNPACK #-} !Word8 -> FieldType TChar :: {-# UNPACK #-} !Int8 -> FieldType TUshort :: {-# UNPACK #-} !Word16 -> FieldType TShort :: {-# UNPACK #-} !Int16 -> FieldType TUint :: {-# UNPACK #-} !Word32 -> FieldType TInt :: {-# UNPACK #-} !Int32 -> FieldType TFloat :: {-# UNPACK #-} !Float -> FieldType TDouble :: {-# UNPACK #-} !Double -> FieldType class PCDType a unsafeUnwrap :: PCDType a => FieldType -> a fromHaskell :: PCDType a => a -> (DimType, Int) -- | Construct a parser for a field based on its type and size. fieldParser :: DimType -> Int -> Parser FieldType sequence' :: Monad m => [m a] -> m [a] data Header Header :: Text -> [Text] -> [Int] -> [DimType] -> [Int] -> Integer -> Int -> (V3 Double, Quaternion Double) -> Integer -> DataFormat -> Header _version :: Header -> Text _fields :: Header -> [Text] _sizes :: Header -> [Int] _dimTypes :: Header -> [DimType] _counts :: Header -> [Int] _width :: Header -> Integer _height :: Header -> Int _viewpoint :: Header -> (V3 Double, Quaternion Double) _points :: Header -> Integer _format :: Header -> DataFormat width :: Lens Header Header Integer Integer viewpoint :: Lens Header Header (V3 Double, Quaternion Double) (V3 Double, Quaternion Double) version :: Lens Header Header Text Text sizes :: Lens Header Header [Int] [Int] points :: Lens Header Header Integer Integer height :: Lens Header Header Int Int format :: Lens Header Header DataFormat DataFormat fields :: Lens Header Header [Text] [Text] dimTypes :: Lens Header Header [DimType] [DimType] counts :: Lens Header Header [Int] [Int] -- | The default PCD version of 0.7. defaultVersion :: Text -- | 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
--   
mkSimpleHeader :: [Text] -> (DimType, Int) -> Int -> Header -- | 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
--   
mkHeaderXYZ :: PCDType a => a -> Int -> Header -- | Assemble a parser for points by sequencing together all necessary -- field parsers. pointParser :: Header -> Parser [FieldType] -- | Create a Header based on an existing one that keeps only the -- fields whose names pass the supplied predicate. filterFields :: (Text -> Bool) -> Header -> Header defaultHeader :: Header readVersion :: Parser Text readFields :: Parser [Text] readTypes :: Parser [DimType] namedIntegral :: Integral a => Text -> Parser a namedIntegrals :: Integral a => Text -> Parser [a] readViewpoint :: Parser (V3 Double, Quaternion Double) readFormat :: Parser DataFormat -- | Get the next non-comment line. nextLine :: Handle -> IO Text -- | Parse a PCD header. Returns the Header and the rest of the file -- contents. readHeader :: Handle -> IO (Header, Maybe Text) -- | Format a Header to be compatible with the PCD specification. writeHeader :: Header -> Text -- | Compute the number of bytes this point cloud would occupy if -- serialized with the Binary encoding. totalBinarySize :: Header -> Int instance NFData Header instance Eq DimType instance Show DimType instance Ord DimType instance Eq DataFormat instance Show DataFormat instance Ord DataFormat instance Show FieldType instance Show Header instance PCDType Double instance PCDType Float instance PCDType Int32 instance PCDType Word32 instance PCDType Int16 instance PCDType Word16 instance PCDType Int8 instance PCDType Word8 module PCD.Internal.AsciiParsers -- | Read point data using a user-supplied ASCII point parser. readPoints :: Vector v a => Header -> Handle -> Parser a -> IO (v a) -- | Load points of arbitrary dimension into a boxed vector with a -- Vector of FieldType as the point representation. readPointsDefault :: Header -> Handle -> IO (Vector (Vector FieldType)) -- | Parse 3D points serialized in ASCII. readXYZ :: Fractional a => Parser (V3 a) -- | Parse 4D points serialized to ASCII. This is useful for points with -- X,Y,Z, and RGB fields each represented by a single float. readXYZW :: Fractional a => Parser (V4 a) module PCD.Internal.StorableFieldType parseBinaryPoints :: Header -> Handle -> IO (Vector (Vector FieldType)) pokeBinaryPoints :: Ptr a -> Vector (Vector FieldType) -> IO () -- | Facility to convert an ASCII PCD file to a Binary one. module PCD.Conversion -- | asciiToBinary inputFile outputFile converts a PCD file from -- ASCII to Binary. asciiToBinary :: FilePath -> FilePath -> IO () -- | Parser for PCD (point cloud data) files. module PCD.Data data FieldType TUchar :: {-# UNPACK #-} !Word8 -> FieldType TChar :: {-# UNPACK #-} !Int8 -> FieldType TUshort :: {-# UNPACK #-} !Word16 -> FieldType TShort :: {-# UNPACK #-} !Int16 -> FieldType TUint :: {-# UNPACK #-} !Word32 -> FieldType TInt :: {-# UNPACK #-} !Int32 -> FieldType TFloat :: {-# UNPACK #-} !Float -> FieldType TDouble :: {-# UNPACK #-} !Double -> FieldType -- | 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. unsafeUnwrap :: PCDType a => FieldType -> a -- | Parse every field of every point in a PCD file. Returns a function -- that may be used to project out a named field. loadFieldsByName :: FilePath -> IO (Text -> Vector FieldType) -- | 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. loadFlexiblePoints :: Header -> Handle -> IO (Vector (Vector FieldType)) -- | 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). loadXyzw :: (Fractional a, Storable a) => FilePath -> IO (Vector (V4 a)) -- | Read a PCD file consisting of floating point XYZ coordinates for each -- point. loadXyz :: (Fractional a, Storable a) => FilePath -> IO (Vector (V3 a)) -- | 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. saveBinaryPcd :: Storable a => FilePath -> Header -> Vector a -> IO () -- | 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. projectBinaryFields :: [Text] -> FilePath -> FilePath -> IO () -- | 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
--   
mkSimpleHeader :: [Text] -> (DimType, Int) -> Int -> Header -- | 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
--   
mkHeaderXYZ :: PCDType a => a -> Int -> Header