亲测 有效 Ubuntu16.04安装PCL库

亲测 Ubuntu16.04安装PCL库

1.安装各种依赖包

     sudo apt-get update
     sudo apt-get install git build-essential linux-libc-dev
     sudo apt-get install cmake cmake-gui 
     sudo apt-get install libusb-1.0-0-dev libusb-dev libudev-dev
     sudo apt-get install mpi-default-dev openmpi-bin openmpi-common  
     sudo apt-get install libflann1.8 libflann-dev
     sudo apt-get install libeigen3-dev
     sudo apt-get install libboost-all-dev
     sudo apt-get install libvtk5.10-qt4 libvtk5.10 libvtk5-dev
     sudo apt-get install libqhull* libgtest-dev
     sudo apt-get install freeglut3-dev pkg-config
     sudo apt-get install libxmu-dev libxi-dev 
     sudo apt-get install mono-complete
     sudo apt-get install qt-sdk openjdk-8-jdk openjdk-8-jre

2.下载源码

git clone https://github.com/PointCloudLibrary/pcl.git

3.编译源码

     cd pcl
     mkdir release
     cd release
     cmake -DCMAKE_BUILD_TYPE=None -DCMAKE_INSTALL_PREFIX=/usr \
           -DBUILD_GPU=ON -DBUILD_apps=ON -DBUILD_examples=ON \
           -DCMAKE_INSTALL_PREFIX=/usr ..
     make

     sudo make install

4.PCL可视化相关依赖包安装

sudo apt-get install libopenni-dev 
sudo apt-get install libopenni2-dev

完成!

PS 测试demo

//pcl_test.cpp
#include 
#include 
#include 
#include 
#include 
#include 
 
 
int main(int argc, char **argv) {
    std::cout << "Test PCL !!!" << std::endl;
    
    pcl::PointCloud::Ptr point_cloud_ptr (new pcl::PointCloud);
    uint8_t r(255), g(15), b(15);
    for (float z(-1.0); z <= 1.0; z += 0.05)
    {
      for (float angle(0.0); angle <= 360.0; angle += 5.0)
      {
	pcl::PointXYZRGB point;
	point.x = 0.5 * cosf (pcl::deg2rad(angle));
	point.y = sinf (pcl::deg2rad(angle));
	point.z = z;
	uint32_t rgb = (static_cast(r) << 16 |
		static_cast(g) << 8 | static_cast(b));
	point.rgb = *reinterpret_cast(&rgb);
	point_cloud_ptr->points.push_back (point);
      }
      if (z < 0.0)
      {
	r -= 12;
	g += 12;
      }
      else
      {
	g -= 12;
	b += 12;
      }
    }
    point_cloud_ptr->width = (int) point_cloud_ptr->points.size ();
    point_cloud_ptr->height = 1;
    
    pcl::visualization::CloudViewer viewer ("test");
    viewer.showCloud(point_cloud_ptr);
    while (!viewer.wasStopped()){ };
    return 0;
}

//CMakeLists.txt
cmake_minimum_required(VERSION 2.6)
project(pcl_test)
 
find_package(PCL 1.2 REQUIRED)
 
include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})
 
add_executable(pcl_test pcl_test.cpp)
 
target_link_libraries (pcl_test ${PCL_LIBRARIES})
 
install(TARGETS pcl_test RUNTIME DESTINATION bin)

以上两个文件放在同一文件夹后,执行命令
cmake .
make
./pcl_test

结果显示
亲测 有效 Ubuntu16.04安装PCL库_第1张图片

问题补充:
1.sudo apt-get update 显示仓库“***”没有release文件 解决办法 在etc/apt/spurces.list.d目录删除对应ppa,在执行一遍即可
2.安装相关依赖包时有问题,可进入root用户重新安装即可

你可能感兴趣的:(亲测 有效 Ubuntu16.04安装PCL库)