PCL安装-win10+vs2017+PCL1.8.1(一)

1. PCL1.8.1安装

1.1 平台介绍

win10系统
vs2017社区版
PCL1.8.1win64版本

1.2 安装准备

PCL安装文件:
集合包:PCL-1.8.1-AllInOne-msvc2017-win64.exe
Debug包:pcl-1.8.1-pdb-msvc2017-win64.zip
CMake:cmake-3.11.1-win64-x64.msi
必须全部下载

1.3 安装

第一步:安装集合包,所有都默认,PATH添加为全部用户即可
第二步:解压pdb包到安装目录下bin文件夹内
第三步:安装CMake,默认安装,PATH添加为全部用户即可

1.4 测试

a. 新建项目目录:test文件夹
b. test文件夹下新建两个文件:source和build
c. 将下面两个文件保存在source目录下

project_inliers.cpp
#include 
#include 
#include 
#include 
#include 

int
 main (int argc, char** argv)
{
  pcl::PointCloud::PointXYZ>::Ptr cloud (new pcl::PointCloud::PointXYZ>);
  pcl::PointCloud::PointXYZ>::Ptr cloud_projected (new pcl::PointCloud::PointXYZ>);

  // Fill in the cloud data
  cloud->width  = 5;
  cloud->height = 1;
  cloud->points.resize (cloud->width * cloud->height);

  for (size_t i = 0; i < cloud->points.size (); ++i)
  {
    cloud->points[i].x = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud->points[i].y = 1024 * rand () / (RAND_MAX + 1.0f);
    cloud->points[i].z = 1024 * rand () / (RAND_MAX + 1.0f);
  }

  std::cerr << "Cloud before projection: " << std::endl;
  for (size_t i = 0; i < cloud->points.size (); ++i)
    std::cerr << "    " << cloud->points[i].x << " " 
                        << cloud->points[i].y << " " 
                        << cloud->points[i].z << std::endl;

  // Create a set of planar coefficients with X=Y=0,Z=1
  pcl::ModelCoefficients::Ptr coefficients (new pcl::ModelCoefficients ());
  coefficients->values.resize (4);
  coefficients->values[0] = coefficients->values[1] = 0;
  coefficients->values[2] = 1.0;
  coefficients->values[3] = 0;

  // Create the filtering object
  pcl::ProjectInliers::PointXYZ> proj;
  proj.setModelType (pcl::SACMODEL_PLANE);
  proj.setInputCloud (cloud);
  proj.setModelCoefficients (coefficients);
  proj.filter (*cloud_projected);

  std::cerr << "Cloud after projection: " << std::endl;
  for (size_t i = 0; i < cloud_projected->points.size (); ++i)
    std::cerr << "    " << cloud_projected->points[i].x << " " 
                        << cloud_projected->points[i].y << " " 
                        << cloud_projected->points[i].z << std::endl;

  return (0);
}
CMakeLists.txt
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)

project(project_inliers)

find_package(PCL 1.2 REQUIRED)

include_directories(${PCL_INCLUDE_DIRS})
link_directories(${PCL_LIBRARY_DIRS})
add_definitions(${PCL_DEFINITIONS})

add_executable (project_inliers project_inliers.cpp)
target_link_libraries (project_inliers ${PCL_LIBRARIES})

d. 打开CMake的图形界面,选择源码文件夹source和目标文件夹build
e. config配置编译器为vs2017 win64
f. config一次,提示红色,输出显示done,再config一次,无红色,输出显示done
g. generate一次,提示done
h. open project即可

1.5 可能碰到的问题

某些情况提示openNI2.dll找不到,可以将openNI2/Redist目录下的文件拷贝到运行目录下,比如debug目录下,即可解决。

你可能感兴趣的:(PCL)