PCL函数库摘要——IO模块

15 篇文章 7 订阅

1.Class pcl::FileReader

类FileReader定义了PCD文件的读取接口,主要用做其他读取类的父类。

#include <pcl/io/file_io.h>
virtual int pcl::FileReader::read  ( const std::string &  file_name,  
  pcl::PCLPointCloud2 &  cloud,  
  Eigen::Vector4f &  origin,  
  Eigen::Quaternionf &  orientation,  
  int &  file_version,  
  const int  offset = 0  
 ) 
int pcl::FileReader::read  ( const std::string &  file_name,  
  pcl::PCLPointCloud2 &  cloud,  
  const int  offset = 0  
 )  //从文件文件中读取点云数据(仅限FILE_V6!)。并将其存储到PCL/PCLPointCloud2中
int pcl::FileReader::read  ( const std::string &  file_name,  
  pcl::PointCloud< PointT > &  cloud,  
  const int  offset = 0  
 ) //从任何文件文件中读取点云数据,并将其转换为给定的样板格式。
virtual int pcl::FileReader::readHeader  ( const std::string &  file_name,  
  pcl::PCLPointCloud2 &  cloud,  
  Eigen::Vector4f &  origin,  
  Eigen::Quaternionf &  orientation,  
  int &  file_version,  
  int &  data_type,  
  unsigned int &  data_idx,  
  const int  offset = 0  
 ) 

 /*
 file_name:读取文件的文件名。
 cloud:存储读取后的点云数据,但只填充文件头。
 origin:点云获取原点,该参数只有在文件版本大于FILE_V7才存在v否则为NULL。
 orientation:点云获取方向,该参数只有在文件版本大于FILE_V7才存在,否则为NULL。
 file_version:文件版本(FILE_V7或者FILE_V6)。
 data_type:数据类型(二进制置为1,ASCII 码置为0)。
 data_idx:数据偏移文件头末尾的偏移量。
 offset:文件头偏移文件开始的偏移量。
 */

2.Class pcl::FileWriter

类FileWriter 与 FileReader对应,是写人PCD文件的类接口定义,可以作为其它写入类的父类。

#include <pcl/io/file_io.h>
virtual int pcl::FileWriter::write  ( const std::string &  file_name,  
  const pcl::PCLPointCloud2 &  cloud,  
  const Eigen::Vector4f &  origin = Eigen::Vector4f::Zero(),  
  const Eigen::Quaternionf &  orientation = Eigen::Quaternionf::Identity(),  
  const bool  binary = false  
 ) 
int pcl::FileWriter::write  ( const std::string &  file_name,  
  const pcl::PCLPointCloud2::ConstPtr &  cloud,  
  const Eigen::Vector4f &  origin = Eigen::Vector4f::Zero (),  
  const Eigen::Quaternionf &  orientation = Eigen::Quaternionf::Identity (),  
  const bool  binary = false  
 ) 
int pcl::FileWriter::write  ( const std::string &  file_name,  
  const pcl::PointCloud< PointT > &  cloud,  
  const bool  binary = false  
 ) 

  /*
 file_name:写入文件的文件名。
 cloud:需要写入的点云对象。
 origin:写入文件头的点云获取原点﹐默认为(0,0,0,0)。
 orientation:写入文件头的点云获取方向。
 binary:设置写人时的类型(true为二进制,false 为 ASCII 码,默认为ASCII码)。
 */

3.Class pcl::Grabber

类Grabber为PCL1.X对应的设备驱动接口的基类定义。

#include <pcl/io/grabber.h>
//关键成员函数
Grabber () //  构造函数。 
virtual  ~Grabber () throw () //虚拟构造函数
template<typename T >  
boost::signals2::connection  registerCallback (const boost::function< T > &callback) 
//提供回调函数指针,当获取每帧图像或点云数据时都会启动回调函数。
template<typename T >  
bool  providesCallback () const 
//判断是否提供回调函数。
virtual void  start ()=0 
//启动设备,开始传输数据流。
virtual void  stop ()=0     
//停止设备上的数据流传输。
virtual std::string  getName () const =0     
//返回明确的子类名字。
virtual bool  isRunning () const =0 
//判断是否在传输数据流。
virtual float  getFramesPerSecond () const =0     
//获取FPS帧率,即每秒多少帧数据。    

4.Class openni_wrapper::OpenNIDevice

类OpenNIDevice定义OpenNI设备的基类,继承该基类可以实现不同的OpenNI设备子类,用于获取包括红外数据、RGB数据、深度图像数据等。

#include <pcl/io/openni_camera/openni_device.h>
virtual  ~OpenNIDevice () throw () 
//  虚拟析构函数。  
bool  findCompatibleImageMode (const XnMapOutputMode &output_mode, XnMapOutputMode &mode) const throw () 
//  查询是否有与output_mode对应的图像模式匹配的输出模式,如果有则返回true并且存储兼容模式在mode中,否返回值为false。
bool  findCompatibleDepthMode (const XnMapOutputMode &output_mode, XnMapOutputMode &mode) const throw () 
//  功能和参数同上,只是针对深度图像的模式,并非上述彩色图像的模式。
bool  isImageModeSupported (const XnMapOutputMode &output_mode) const throw () 
//  只判断是否支持该output_mode所给定的图像模式,支持返回true,否则返回false。
bool  isDepthModeSupported (const XnMapOutputMode &output_mode) const throw () 
//  只判断是否支持该output_mode所给定的深度图像模式,支持返回true,否则返回false。 
const XnMapOutputMode &  getDefaultImageMode () const throw () 
const XnMapOutputMode &  getDefaultDepthMode () const throw () 
const XnMapOutputMode &  getDefaultIRMode () const throw () 
//  以上三个函数分别是获取默认的RGB、深度、红外图像的输出模式。
void  setImageOutputMode (const XnMapOutputMode &output_mode) 
void  setDepthOutputMode (const XnMapOutputMode &output_mode) 
void  setIROutputMode (const XnMapOutputMode &output_mode) 
//  以上三个函数分别是设置当前的RGB、深度、红外图像的输出模式。
XnMapOutputMode  getImageOutputMode () const 
XnMapOutputMode  getDepthOutputMode () const 
XnMapOutputMode  getIROutputMode () const 
//  以上三个函数分别是获取当前的RGB、深度、红外图像的输出模式。
void  setDepthRegistration (bool on_off) 
//  设置深度图像是否与RGB图像对齐。
bool  isDepthRegistered () const throw () 
//  判断深度图像是否注册到RGB摄影机帧。
bool  isDepthRegistrationSupported () const throw () 
//  判断深度图像是否与RGB图像对齐。
void  setSynchronization (bool on_off) 
//  设置设备是否同步输出RGB和深度图像。
bool  isSynchronized () const throw () 
//  判断设备是否同步输出RGB和深度图像,如果是返回true,否则返回false。
virtual bool  isSynchronizationSupported () const throw () 
//  判断设备是否支持同步输出RGB和深度图像。
bool  isDepthCropped () const 
//  返回深度图像是否被裁剪过,是为true,否则为false。
void  setDepthCropping (unsigned x, unsigned y, unsigned width, unsigned height) 
//  打开深度图像的裁剪,x、y分别为两个方向上的起始裁剪位置, width 和 height分别为保留的x与y方向上的尺寸。
bool  isDepthCroppingSupported () const throw () 
//  判断深度图像是否支持裁剪。
float  getImageFocalLength (int output_x_resolution=0) const throw () 
//  获取RGB图像的焦距长度(像素)。
float  getDepthFocalLength (int output_x_resolution=0) const throw () 
//  获取深度图像的焦距长度(像素)。 
float  getBaseline () const throw () 
//  获取基线长度
virtual void  startImageStream () 
virtual void  stopImageStream () 
//  上面一对函数为启动和停止 RGB数据流的采集。
virtual void  startDepthStream () 
virtual void  stopDepthStream () 
//  上面一对函数为启动和停止深度数据流的采集。
virtual void  startIRStream () 
virtual void  stopIRStream () 
//  上面一对函数为启动和停止红外数据流的采集。
bool  hasImageStream () const throw () 
bool  hasDepthStream () const throw ()  
bool  hasIRStream () const throw () 
//  以上三个函数分别判断设备是否支持RGB、深度、红外图像数据采集,如果是返回true,否则返回false。
virtual bool  isImageStreamRunning () const throw () 
virtual bool  isDepthStreamRunning () const throw () 
virtual bool  isIRStreamRunning () const throw () 
//  以上三个函数分别判断设备是否正在进行RGB,深度、红外图像数据采集。
CallbackHandle  registerImageCallback (const ImageCallbackFunction &callback, void *cookie=NULL) throw () 
//  使用可选的用户定义参数注册RGB图像流的boost::function类型的回调函数。 
template<typename T >  
CallbackHandle  registerImageCallback (void(T::*callback)(boost::shared_ptr< Image >, void *cookie), T &instance, void *cookie=NULL) throw () 
bool  unregisterImageCallback (const CallbackHandle &callbackHandle) throw () 
//  上面一对函数分别为RGB图像数据流的回调函数注册与注销。
CallbackHandle  registerDepthCallback (const DepthImageCallbackFunction &callback, void *cookie=NULL) throw () 
//  使用可选的用户定义参数注册深度图像流的boost::function类型的回调函数。 
template<typename T >  
CallbackHandle  registerDepthCallback (void(T::*callback)(boost::shared_ptr< DepthImage >, void *cookie), T &instance, void *cookie=NULL) throw () 
bool  unregisterDepthCallback (const CallbackHandle &callbackHandle) throw () 
//  上面一对函数分别为深度图像数据流的回调函数注册与注销。
CallbackHandle  registerIRCallback (const IRImageCallbackFunction &callback, void *cookie=NULL) throw () 
//  使用可选的用户定义参数注册红外图像流的boost::function类型的回调函数。
template<typename T >  
CallbackHandle  registerIRCallback (void(T::*callback)(boost::shared_ptr< IRImage >, void *cookie), T &instance, void *cookie=NULL) throw () 
bool  unregisterIRCallback (const CallbackHandle &callbackHandle) throw () 
//  上面一对函数分别为红外图像数据流的回调函数注册与注销。
const char *  getSerialNumber () const throw () 
//  获取设备对应的序列号,注意该返回值有可能为空字符串。  
const char *  getConnectionString () const throw () 
//  获取设备连接字符串,一般格式为vendorID/productID@BusID/DeviceID。  
const char *  getVendorName () const throw ()
const char *  getProductName () const throw () 
unsigned short  getVendorID () const throw () 
unsigned short  getProductID () const throw () 
//  以上4个函数分别获取厂商和产品的名字字符串及ID编号。
unsigned char  getBus () const throw () 
//  获取设备所在的USB总线。
unsigned char  getAddress () const throw () 
//  获取设备所在USB地址。
void  setRGBFocalLength (float focal_length) 
void  setDepthFocalLength (float focal_length) 
//  以上两个函数分别设定RGB与深度图像获取时的焦距大小。
void  setDepthOutputFormat (const DepthMode &depth_mode=OpenNI_12_bit_depth) 
//  设置深度图像的输出格式。  
XnUInt64  getDepthOutputFormat () const 
//  获取用户设置的深度输出格式。  
pcl::uint16_t  shiftToDepth (pcl::uint16_t shift_value) const 
//  将Shift值转换为深度值。

5.Class openni_wrapper::DeviceKinect

6.Class openni_wrapper::DevicePrimesense

7.Class openni_wrapper::DeviceXtionPro

以上3个类分别封装了Kinect,Primesense,XtionPro相关设备操作和数据获取操作实现,其详细接口参考其父类OpenNIDevice的关键函数说明。

8.Class openni_wrapper::DeviceONI

封装了利用ONI文件回放虚拟类kinect设备的操作和数据获取操作实现,其详细接口参考其父类OpenNIDevice的关键函数说明。

9.Class openni_wrapper::OpenNIDriver

类OpenNIDriver采用单例模式实现对底层驱动的封装,里面包含一xn::Context对象,提供给所有设备使用。该类提供了枚举和访问所有设备的方法实现。

~OpenNIDriver () throw () 
//  从不抛出异常的虚拟析构函数。  
unsigned  updateDeviceList () 
//  枚举所有系统可以获取的设备列表,返回获取设备的数目。
unsigned  getNumberDevices () const throw () 
//  获取系统可用设备的数目。
boost::shared_ptr< OpenNIDevice >  createVirtualDevice (const std::string &path, bool repeat, bool stream) const 
//从ONI文件创建一虚拟设备,其中 path为ONI文件的路径, repeat设置是否虚拟设备支持无限循环从ONI文件获取数据, stream设置虚拟设备是支持数据流形式的数据获取还是引发式的数据获取。
 
  
boost::shared_ptr< OpenNIDevice >  getDeviceByIndex (unsigned index) const 
//  返回一设备, index为给定的设备索引。  
boost::shared_ptr< OpenNIDevice >  getDeviceBySerialNumber (const std::string &serial_number) const 
//  返回一设备,serial_number为给定的设备的序列号。
boost::shared_ptr< OpenNIDevice >  getDeviceByAddress (unsigned char bus, unsigned char address) const 
//  返回一设备, bus为USB设备总线号,address为USB设备地址。
const char *  getSerialNumber (unsigned index) const throw () 
//  获取索引为index的设备序列号,但该设备未被创建。
const char *  getConnectionString (unsigned index) const throw () 
//  获取索引为index的设备连接字符串,但该设备未被创建。
 
  
const char *  getVendorName (unsigned index) const throw () 
//  获取索引为index的USB设备供应商名称,但该设备未被创建。  
const char *  getProductName (unsigned index) const throw () 
//  获取索引为index的USB设备产品名称,但该设备未被创建。
unsigned short  getVendorID (unsigned index) const throw () 
//  获取索引为index的USB设备供应商ID,但该设备未被创建。
unsigned short  getProductID (unsigned index) const throw () 
//  获取索引为index的USB设备产品ID,但该设备未被创建。
unsigned char  getBus (unsigned index) const throw () 
//  获取索引为index的USB设备产品ID,但该设备未被创建。
unsigned char  getAddress (unsigned index) const throw () 
//  获取索引为index的USB设备vaddress,但该设备未被创建。
void  stopAll () 
//  停止所有设备。
static OpenNIDriver &  getInstance () 
//  为静态成员函数,获取唯一的设备实例。
static void  getDeviceType (const std::string &connection_string, unsigned short &vendorId, unsigned short &productId) 
//  为静态成员函数,获取设备连接字符串存储在connection_string,设备厂商及产品ID存储在vendorId,productId 中。


10.Class openni_wrapper::OpenNIException

类OpenNIException封装一般的异常处理实现。

OpenNIException (const std::string &function_name, const std::string &file_name, unsigned line_number, const std::string &message) throw () 
//  构造函数
virtual  ~OpenNIException () throw () 
//  永远不会抛出异常的虚拟析构函数。  
OpenNIException &  operator= (const OpenNIException &exception) throw () 
//  赋值运算符允许复制另一个异常变量的消息。  
virtual const char *  what () const throw () 
//  返回异常消息字符串。  
const std::string &  getFunctionName () const throw () 
//  返回发生异常的函数名。
const std::string &  getFileName () const throw () 
//  const std: : string &getFileName ( ) const throw ( )返回发生异常的文件名。
unsigned  getLineNumber () const throw () 
//  返回发生异常的行号。

11.Class openni_wrapper::Image

类Image是简单的图像数据封装基类。

#include <pcl/io/openni_camera/openni_image.h>
Image (boost::shared_ptr< xn::ImageMetaData > image_meta_data) throw () 
//  构造函数
virtual  ~Image () throw () 
//  永远不会抛出异常的虚拟析构函数。    
virtual bool  isResizingSupported (unsigned input_width, unsigned input_height, unsigned output_width, unsigned output_height) const =0 
//  纯虚函数﹐具体实现见子类,判断图像是否支持尺寸变换, input_width, input_height为设定的宽度和高度,output_width , output_height变换后的宽度和高度。
virtual void  fillRGB (unsigned width, unsigned height, unsigned char *rgb_buffer, unsigned rgb_line_step=0) const =0 
//  用RGB数据填充用户给定的rgb_ buffer,返回图像的宽度和高度为width、height,隔rgb_line_step行输出到输出缓存中。  
virtual Encoding  getEncoding () const =0 
//  返回原始编码的方式。
void  fillRaw (unsigned char *rgb_buffer) const throw () 
//  用原始数据填充用户给定的rgb_buffer。
virtual void  fillGrayscale (unsigned width, unsigned height, unsigned char *gray_buffer, unsigned gray_line_step=0) const =0 
//  用灰度数据填充给定的 gray_buffer,其他参数参考函数fillRGB。  
unsigned  getWidth () const throw () 
unsigned  getHeight () const throw () 
//  以上两个函数分别获取图像宽度和高度。
unsigned  getFrameID () const throw () 
//  获取帧的ID号。
unsigned long  getTimeStamp () const throw () 
//  获取图像原始OpenNI格式数据.
const xn::ImageMetaData &  getMetaData () const throw () 
//  获取图像原始OpenNI格式数据.

12.Class openni_wrapper::ImageBayerGRBG

13.Class openni_wrapper::ImageRGB24

14.Class openni_wrapper::ImageYUV422 Class Reference

以上3个类分别实现了对原始数据 BayerGRBG ,RGB24、YUV422到图像转化接口,详细参考其父类关键函数说明。

15.Class pcl::OpenNIGrabber

类OpenNIGrabber 实现对OpenNI设备(例如Primesense PSDK,MicrosoftKinect,Asus XTion Pro/Live)数据的采集接口,详细参考其父类Grabber 关键函数说明。

16.Class pcl::PCDReader

17.Class pcl::PLYReader

以上两个类分别是PCD、PLY文件格式读入接口的实现,详细参考其父类pcl: :FileReader。

18.Class pcl::PLYWriter

19.Class pcl::PCDWriter

以上两个类分别是PCD、PLY文件格式写出接口的实现,详细参考其父类pcl: :FileWriter。

20.Class pcl::io::IOException

类pcl::io::IOException 是I/O相关的异常处理接口实现,详细参考其父类PCLEx-ception。

21.I/O模块其他关键成员说明

#include <obj_io.h>
PCL_EXPORTS int pcl::io::saveOBJFile  ( const std::string &  file_name,  
  const pcl::TextureMesh &  tex_mesh,  
  unsigned  precision = 5  
 ) 
//  该函数实现对TextureMesh 保存到OBJ文件,file_name为OBJ文件名,tex_mesh 为网格模型数据, precision为保存时的精度(默认为5)。
PCL_EXPORTS int pcl::io::saveOBJFile  ( const std::string &  file_name,  
  const pcl::PolygonMesh &  mesh,  
  unsigned  precision = 5  
 ) 
//  功能同上,存储对象为PolygonMesh。
#include <pcd_io.h>
int pcl::io::loadPCDFile  ( const std::string &  file_name,  
  pcl::PCLPointCloud2 &  cloud  
 ) 
//  打开一版本V6.0的 PCD文件, file_name为文件名, cloud存储读入的点云数据。
template<typename PointT > 
int pcl::io::loadPCDFile  ( const std::string &  file_name,  
  pcl::PointCloud< PointT > &  cloud  
 ) 
//  打开任何类型的PCD点云文件,file_name为文件名, cloud存储读入的点云数据。
int pcl::io::savePCDFile  ( const std::string &  file_name,  
  const pcl::PCLPointCloud2 &  cloud,  
  const Eigen::Vector4f &  origin = Eigen::Vector4f::Zero (),  
  const Eigen::Quaternionf &  orientation = Eigen::Quaternionf::Identity (),  
  const bool  binary_mode = false  
 )   
//  保存点云到PCD文件, file_name文件名,cloud需要保存的点云数据, origin为获取点云的原点,orientation为获取点云的方向, binary_mode设置是否保存为二进制格式,默认为false。
template<typename PointT > 
int pcl::io::savePCDFile  ( const std::string &  file_name,  
  const pcl::PointCloud< PointT > &  cloud,  
  bool  binary_mode = false  
 ) 
//  保存点云到PCD文件,file_name文件名, cloud需要保存的点云数据, binary.mode设置是否保存为二进制格式,默认为false。
template<typename PointT > 
int pcl::io::savePCDFileASCII  ( const std::string &  file_name,  
  const pcl::PointCloud< PointT > &  cloud  
 ) 
 //  以ASCII方式保存点云到PCD文件,file_name文件名,cloud需要保存的点云数据。
template<typename PointT > 
int pcl::io::savePCDFileBinary  ( const std::string &  file_name,  
  const pcl::PointCloud< PointT > &  cloud  
 ) 
//  以二进制方式保存点云到PCD文件,file_name文件名,cloud需要保存的点云数据。
#include <ply_io.h>
template<typename PointT > 
int pcl::io::loadPLYFile  ( const std::string &  file_name,  
  pcl::PointCloud< PointT > &  cloud  
 ) 
//  打开ply文件, file_name文件名,cloud保存打开的点云数据。
template<typename PointT > 
int pcl::io::savePLYFile  ( const std::string &  file_name,  
  const pcl::PointCloud< PointT > &  cloud,  
  bool  binary_mode = false  
 ) 
//  保存点云到PLY文件,file_name 文件名, cloud需要保存的点云数据, binary_mode设置是否保存为二进制格式,默认为false。
template<typename PointT > 
int pcl::io::savePLYFileASCII  ( const std::string &  file_name,  
  const pcl::PointCloud< PointT > &  cloud  
 )   
template<typename PointT > 
int pcl::io::savePLYFileBinary  ( const std::string &  file_name,  
  const pcl::PointCloud< PointT > &  cloud  
 )   
//  以上两个函数分别以为ASCII和二进制方式保存点云到ply文件, file_name文件名,cloud需要保存的点云数据。
PCL_EXPORTS int pcl::io::savePLYFile  ( const std::string &  file_name,  
  const pcl::PolygonMesh &  mesh,  
  unsigned  precision = 5  
 ) 
//  保存PolygonMesh对象到PLY文件,file_name为 PLY文件名, mesh为需要保存的对象数据, precision为保存精度(默认为5)。  
#include <png_io.h>
PCL_EXPORTS void pcl::io::saveRgbPNGFile  ( const std::string &  file_name,  
  const unsigned char *  rgb_image,  
  int  width,  
  int  height  
 )  
//  保存RGB数据为PNG文件,file_name为PNG文件名,rgb_image为 RGB数据, width,height为图像数据的宽度和高度。
PCL_EXPORTS void pcl::io::saveShortPNGFile  ( const std::string &  file_name,  
  const unsigned short *  short_image,  
  int  width,  
  int  height,  
  int  channels  
 ) 
//  功能同上,只是保存的数据为16 位灰度图像格式。
template<typename T > 
void pcl::io::savePNGFile  ( const std::string &  file_name,  
  const pcl::PointCloud< T > &  cloud  
 ) 
//  保存点云中 RGB域为png 文件,cloud为包含RGB域的点云对象,file_name为png 文件名。
#include <vtk_lib_io.h>
PCL_EXPORTS int pcl::io::saveVTKFile  ( const std::string &  file_name,  
  const pcl::PolygonMesh &  triangles,  
  unsigned  precision = 5  
 ) 
//  保存PolygonMesh对象数据为VTK文件,file_name为VTK文件名, triangles为需要保存的数据,precision为保存精度(默认为5)。
  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值