目录
1.VS2015
一键安装,免费社区版即可
2.PCL安装
下载:
我采用的是PCL1.8.0,32位版本的,如下。下载地址为:http://unanancyowen.com/en/pcl18/
安装:
一键安装,推荐安装到C盘,安装过程中出现OpenNI2的安装的时候,注意OpenNI2要安装到3rdParty文件夹下。安装好后的截图如下:
配置:
> 先定义系统路径`PCL_ROOT = C:\Program Files\PCL 1.8.0`
1. 属性->VC++目录->包含目录和源目录
* `$(PCL_ROOT)\include\pcl-1.8;$(PCL_ROOT)\3rdParty\Boost\include\boost-1_61;$(PCL_ROOT)\3rdParty\Eigen\eigen3;$(PCL_ROOT)\3rdParty\FLANN\include;$(PCL_ROOT)\3rdParty\Qhull\include;$(PCL_ROOT)\3rdParty\VTK\include\vtk-7.0;$(PCL_ROOT)\3rdParty\OpenNI2\Include;`
2. 属性->VC++目录->库目录
* `$(PCL_ROOT)\lib;$(PCL_ROOT)\3rdParty\Boost\lib;$(PCL_ROOT)\3rdParty\FLANN\lib;$(PCL_ROOT)\3rdParty\Qhull\lib;$(PCL_ROOT)\3rdParty\VTK\lib;$(PCL_ROOT)\3rdParty\OpenNI2\lib;`
3. 属性->调试->环境
* `PATH=$(PCL_ROOT)\bin%3b$(PCL_ROOT)\3rdParty\FLANN\bin%3b$(PCL_ROOT)\3rdParty\VTK\bin%3b$(PCL_ROOT)\3rdParty\OpenNI2\Tools`
4. 属性->C/C++->预处理器->预处理器定义
* `_SCL_SECURE_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;`
5. 系统变量->path(release用)
* `C:\Program Files\PCL 1.8.0\bin;C:\Program Files\PCL 1.8.0\3rdParty\FLANN\bin;C:\Program Files\PCL 1.8.0\3rdParty\Qhull\bin;C:\Program Files\PCL 1.8.0\3rdParty\OpenNI2\Tools;C:\Program Files\PCL 1.8.0\3rdParty\VTK\bin;`
6. 属性->链接器->输入->附加依赖项(DEBUG)
6. 属性->链接器->输入->附加依赖项(DEBUG)
```
pcl_common_debug.lib
pcl_features_debug.lib
pcl_filters_debug.lib
pcl_io_debug.lib
pcl_io_ply_debug.lib
pcl_kdtree_debug.lib
pcl_keypoints_debug.lib
pcl_ml_debug.lib
pcl_octree_debug.lib
pcl_outofcore_debug.lib
pcl_people_debug.lib
pcl_recognition_debug.lib
pcl_registration_debug.lib
pcl_sample_consensus_debug.lib
pcl_search_debug.lib
pcl_segmentation_debug.lib
pcl_stereo_debug.lib
pcl_surface_debug.lib
pcl_tracking_debug.lib
pcl_visualization_debug.lib
flann_cpp_s-gd.lib
flann_s-gd.lib
flann-gd.lib
libboost_atomic-vc140-mt-gd-1_61.lib
libboost_chrono-vc140-mt-gd-1_61.lib
libboost_container-vc140-mt-gd-1_61.lib
libboost_context-vc140-mt-gd-1_61.lib
libboost_coroutine-vc140-mt-gd-1_61.lib
libboost_date_time-vc140-mt-gd-1_61.lib
libboost_exception-vc140-mt-gd-1_61.lib
libboost_filesystem-vc140-mt-gd-1_61.lib
libboost_graph-vc140-mt-gd-1_61.lib
libboost_iostreams-vc140-mt-gd-1_61.lib
libboost_locale-vc140-mt-gd-1_61.lib
libboost_log-vc140-mt-gd-1_61.lib
libboost_log_setup-vc140-mt-gd-1_61.lib
libboost_math_c99-vc140-mt-gd-1_61.lib
libboost_math_c99f-vc140-mt-gd-1_61.lib
libboost_math_c99l-vc140-mt-gd-1_61.lib
libboost_math_tr1-vc140-mt-gd-1_61.lib
libboost_math_tr1f-vc140-mt-gd-1_61.lib
libboost_math_tr1l-vc140-mt-gd-1_61.lib
libboost_mpi-vc140-mt-gd-1_61.lib
libboost_prg_exec_monitor-vc140-mt-gd-1_61.lib
libboost_program_options-vc140-mt-gd-1_61.lib
libboost_random-vc140-mt-gd-1_61.lib
libboost_regex-vc140-mt-gd-1_61.lib
libboost_serialization-vc140-mt-gd-1_61.lib
libboost_signals-vc140-mt-gd-1_61.lib
libboost_system-vc140-mt-gd-1_61.lib
libboost_test_exec_monitor-vc140-mt-gd-1_61.lib
libboost_thread-vc140-mt-gd-1_61.lib
libboost_timer-vc140-mt-gd-1_61.lib
libboost_unit_test_framework-vc140-mt-gd-1_61.lib
libboost_wave-vc140-mt-gd-1_61.lib
libboost_wserialization-vc140-mt-gd-1_61.lib
qhull_d.lib
qhull_p_d.lib
qhull_r_d.lib
qhullcpp_d.lib
qhullstatic_d.lib
qhullstatic_r_d.lib
vtkalglib-7.0-gd.lib
vtkChartsCore-7.0-gd.lib
vtkCommonColor-7.0-gd.lib
vtkCommonComputationalGeometry-7.0-gd.lib
vtkCommonCore-7.0-gd.lib
vtkCommonDataModel-7.0-gd.lib
vtkCommonExecutionModel-7.0-gd.lib
vtkCommonMath-7.0-gd.lib
vtkCommonMisc-7.0-gd.lib
vtkCommonSystem-7.0-gd.lib
vtkCommonTransforms-7.0-gd.lib
vtkDICOMParser-7.0-gd.lib
vtkDomainsChemistry-7.0-gd.lib
vtkexoIIc-7.0-gd.lib
vtkexpat-7.0-gd.lib
vtkFiltersAMR-7.0-gd.lib
vtkFiltersCore-7.0-gd.lib
vtkFiltersExtraction-7.0-gd.lib
vtkFiltersFlowPaths-7.0-gd.lib
vtkFiltersGeneral-7.0-gd.lib
vtkFiltersGeneric-7.0-gd.lib
vtkFiltersGeometry-7.0-gd.lib
vtkFiltersHybrid-7.0-gd.lib
vtkFiltersHyperTree-7.0-gd.lib
vtkFiltersImaging-7.0-gd.lib
vtkFiltersModeling-7.0-gd.lib
vtkFiltersParallel-7.0-gd.lib
vtkFiltersParallelImaging-7.0-gd.lib
vtkFiltersProgrammable-7.0-gd.lib
vtkFiltersSelection-7.0-gd.lib
vtkFiltersSMP-7.0-gd.lib
vtkFiltersSources-7.0-gd.lib
vtkFiltersStatistics-7.0-gd.lib
vtkFiltersTexture-7.0-gd.lib
vtkFiltersVerdict-7.0-gd.lib
vtkfreetype-7.0-gd.lib
vtkGeovisCore-7.0-gd.lib
vtkhdf5-7.0-gd.lib
vtkhdf5_hl-7.0-gd.lib
vtkImagingColor-7.0-gd.lib
vtkImagingCore-7.0-gd.lib
vtkImagingFourier-7.0-gd.lib
vtkImagingGeneral-7.0-gd.lib
vtkImagingHybrid-7.0-gd.lib
vtkImagingMath-7.0-gd.lib
vtkImagingMorphological-7.0-gd.lib
vtkImagingSources-7.0-gd.lib
vtkImagingStatistics-7.0-gd.lib
vtkImagingStencil-7.0-gd.lib
vtkInfovisCore-7.0-gd.lib
vtkInfovisLayout-7.0-gd.lib
vtkInteractionImage-7.0-gd.lib
vtkInteractionStyle-7.0-gd.lib
vtkInteractionWidgets-7.0-gd.lib
vtkIOAMR-7.0-gd.lib
vtkIOCore-7.0-gd.lib
vtkIOEnSight-7.0-gd.lib
vtkIOExodus-7.0-gd.lib
vtkIOExport-7.0-gd.lib
vtkIOGeometry-7.0-gd.lib
vtkIOImage-7.0-gd.lib
vtkIOImport-7.0-gd.lib
vtkIOInfovis-7.0-gd.lib
vtkIOLegacy-7.0-gd.lib
vtkIOLSDyna-7.0-gd.lib
vtkIOMINC-7.0-gd.lib
vtkIOMovie-7.0-gd.lib
vtkIONetCDF-7.0-gd.lib
vtkIOParallel-7.0-gd.lib
vtkIOPLY-7.0-gd.lib
vtkIOSQL-7.0-gd.lib
vtkIOVideo-7.0-gd.lib
vtkIOXML-7.0-gd.lib
vtkIOXMLParser-7.0-gd.lib
vtkjpeg-7.0-gd.lib
vtkjsoncpp-7.0-gd.lib
vtklibxml2-7.0-gd.lib
vtkmetaio-7.0-gd.lib
vtkNetCDF-7.0-gd.lib
vtkNetCDF_cxx-7.0-gd.lib
vtkoggtheora-7.0-gd.lib
vtkParallelCore-7.0-gd.lib
vtkpng-7.0-gd.lib
vtkproj4-7.0-gd.lib
vtkRenderingAnnotation-7.0-gd.lib
vtkRenderingContext2D-7.0-gd.lib
vtkRenderingCore-7.0-gd.lib
vtkRenderingFreeType-7.0-gd.lib
vtkRenderingImage-7.0-gd.lib
vtkRenderingLabel-7.0-gd.lib
vtkRenderingLOD-7.0-gd.lib
vtkRenderingVolume-7.0-gd.lib
vtksqlite-7.0-gd.lib
vtksys-7.0-gd.lib
vtktiff-7.0-gd.lib
vtkverdict-7.0-gd.lib
vtkViewsContext2D-7.0-gd.lib
vtkViewsCore-7.0-gd.lib
vtkViewsInfovis-7.0-gd.lib
vtkzlib-7.0-gd.lib
OpenNI2.lib
```
7. 属性->链接器->输入->附加依赖项(RELEASE)
```
pcl_common_release.lib
pcl_features_release.lib
pcl_filters_release.lib
pcl_io_release.lib
pcl_io_ply_release.lib
pcl_kdtree_release.lib
pcl_keypoints_release.lib
pcl_ml_release.lib
pcl_octree_release.lib
pcl_outofcore_release.lib
pcl_people_release.lib
pcl_recognition_release.lib
pcl_registration_release.lib
pcl_sample_consensus_release.lib
pcl_search_release.lib
pcl_segmentation_release.lib
pcl_stereo_release.lib
pcl_surface_release.lib
pcl_tracking_release.lib
pcl_visualization_release.lib
flann_cpp_s.lib
flann_s.lib
flann.lib
libboost_atomic-vc140-mt-1_61.lib
libboost_chrono-vc140-mt-1_61.lib
libboost_container-vc140-mt-1_61.lib
libboost_context-vc140-mt-1_61.lib
libboost_coroutine-vc140-mt-1_61.lib
libboost_date_time-vc140-mt-1_61.lib
libboost_exception-vc140-mt-1_61.lib
libboost_filesystem-vc140-mt-1_61.lib
libboost_graph-vc140-mt-1_61.lib
libboost_iostreams-vc140-mt-1_61.lib
libboost_locale-vc140-mt-1_61.lib
libboost_log-vc140-mt-1_61.lib
libboost_log_setup-vc140-mt-1_61.lib
libboost_math_c99-vc140-mt-1_61.lib
libboost_math_c99f-vc140-mt-1_61.lib
libboost_math_c99l-vc140-mt-1_61.lib
libboost_math_tr1-vc140-mt-1_61.lib
libboost_math_tr1f-vc140-mt-1_61.lib
libboost_math_tr1l-vc140-mt-1_61.lib
libboost_mpi-vc140-mt-1_61.lib
libboost_prg_exec_monitor-vc140-mt-1_61.lib
libboost_program_options-vc140-mt-1_61.lib
libboost_random-vc140-mt-1_61.lib
libboost_regex-vc140-mt-1_61.lib
libboost_serialization-vc140-mt-1_61.lib
libboost_signals-vc140-mt-1_61.lib
libboost_system-vc140-mt-1_61.lib
libboost_test_exec_monitor-vc140-mt-1_61.lib
libboost_thread-vc140-mt-1_61.lib
libboost_timer-vc140-mt-1_61.lib
libboost_unit_test_framework-vc140-mt-1_61.lib
libboost_wave-vc140-mt-1_61.lib
libboost_wserialization-vc140-mt-1_61.lib
qhullstatic.lib
qhull.lib
qhull_p.lib
qhull_r.lib
qhullcpp.lib
qhullstatic_r.lib
vtkalglib-7.0.lib
vtkChartsCore-7.0.lib
vtkCommonColor-7.0.lib
vtkCommonComputationalGeometry-7.0.lib
vtkCommonCore-7.0.lib
vtkCommonDataModel-7.0.lib
vtkCommonExecutionModel-7.0.lib
vtkCommonMath-7.0.lib
vtkCommonMisc-7.0.lib
vtkCommonSystem-7.0.lib
vtkCommonTransforms-7.0.lib
vtkDICOMParser-7.0.lib
vtkDomainsChemistry-7.0.lib
vtkexoIIc-7.0.lib
vtkexpat-7.0.lib
vtkFiltersAMR-7.0.lib
vtkFiltersCore-7.0.lib
vtkFiltersExtraction-7.0.lib
vtkFiltersFlowPaths-7.0.lib
vtkFiltersGeneral-7.0.lib
vtkFiltersGeneric-7.0.lib
vtkFiltersGeometry-7.0.lib
vtkFiltersHybrid-7.0.lib
vtkFiltersHyperTree-7.0.lib
vtkFiltersImaging-7.0.lib
vtkFiltersModeling-7.0.lib
vtkFiltersParallel-7.0.lib
vtkFiltersParallelImaging-7.0.lib
vtkFiltersProgrammable-7.0.lib
vtkFiltersSelection-7.0.lib
vtkFiltersSMP-7.0.lib
vtkFiltersSources-7.0.lib
vtkFiltersStatistics-7.0.lib
vtkFiltersTexture-7.0.lib
vtkFiltersVerdict-7.0.lib
vtkfreetype-7.0.lib
vtkGeovisCore-7.0.lib
vtkhdf5-7.0.lib
vtkhdf5_hl-7.0.lib
vtkImagingColor-7.0.lib
vtkImagingCore-7.0.lib
vtkImagingFourier-7.0.lib
vtkImagingGeneral-7.0.lib
vtkImagingHybrid-7.0.lib
vtkImagingMath-7.0.lib
vtkImagingMorphological-7.0.lib
vtkImagingSources-7.0.lib
vtkImagingStatistics-7.0.lib
vtkImagingStencil-7.0.lib
vtkInfovisCore-7.0.lib
vtkInfovisLayout-7.0.lib
vtkInteractionImage-7.0.lib
vtkInteractionStyle-7.0.lib
vtkInteractionWidgets-7.0.lib
vtkIOAMR-7.0.lib
vtkIOCore-7.0.lib
vtkIOEnSight-7.0.lib
vtkIOExodus-7.0.lib
vtkIOExport-7.0.lib
vtkIOGeometry-7.0.lib
vtkIOImage-7.0.lib
vtkIOImport-7.0.lib
vtkIOInfovis-7.0.lib
vtkIOLegacy-7.0.lib
vtkIOLSDyna-7.0.lib
vtkIOMINC-7.0.lib
vtkIOMovie-7.0.lib
vtkIONetCDF-7.0.lib
vtkIOParallel-7.0.lib
vtkIOPLY-7.0.lib
vtkIOSQL-7.0.lib
vtkIOVideo-7.0.lib
vtkIOXML-7.0.lib
vtkIOXMLParser-7.0.lib
vtkjpeg-7.0.lib
vtkjsoncpp-7.0.lib
vtklibxml2-7.0.lib
vtkmetaio-7.0.lib
vtkNetCDF-7.0.lib
vtkNetCDF_cxx-7.0.lib
vtkoggtheora-7.0.lib
vtkParallelCore-7.0.lib
vtkpng-7.0.lib
vtkproj4-7.0.lib
vtkRenderingAnnotation-7.0.lib
vtkRenderingContext2D-7.0.lib
vtkRenderingCore-7.0.lib
vtkRenderingFreeType-7.0.lib
vtkRenderingImage-7.0.lib
vtkRenderingLabel-7.0.lib
vtkRenderingLOD-7.0.lib
vtkRenderingVolume-7.0.lib
vtksqlite-7.0.lib
vtksys-7.0.lib
vtktiff-7.0.lib
vtkverdict-7.0.lib
vtkViewsContext2D-7.0.lib
vtkViewsCore-7.0.lib
vtkViewsInfovis-7.0.lib
vtkzlib-7.0.lib
OpenNI2.lib
```
3.测试
新建WIN32测试程序,测试代码如下:
// test20210107.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <iostream>
#include <pcl/io/pcd_io.h>
#include <pcl/point_types.h>
#include <pcl/ModelCoefficients.h>
#include <pcl/filters/project_inliers.h>
int main(int argc, char** argv)
{
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud_projected(new pcl::PointCloud<pcl::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<pcl::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;
system("pause");
return (0);
}
测试成功截图如下: