pcl 1.9.1+VS2019显示法线

测试代码:

#include 
VTK_MODULE_INIT(vtkRenderingOpenGL);
//VTK_MODULE_INIT(vtkRenderingFreeType);
//VTK_MODULE_INIT(vtkInteractionStyle);
#include 
#include 
#include 
#include 
#include 
#include 



int main()
{
    //加载点云
    pcl::PointCloud::Ptr cloud(new pcl::PointCloud);
    pcl::io::loadPCDFile("../public/bunny.pcd", *cloud);
    //估计法线
    pcl::NormalEstimation ne;
    ne.setInputCloud(cloud);
    //创建一个空的kdtree对象,并把它传递给法线估计对象
    //基于给出的输入数据集,kdtree将被建立
    pcl::search::KdTree::Ptr tree(new pcl::search::KdTree());
    ne.setSearchMethod(tree);
    //输出数据集
    pcl::PointCloud::Ptr cloud_normals(new pcl::PointCloud);
    //使用半径在查询点周围3厘米范围内的所有邻元素
    ne.setRadiusSearch(0.03);
    //计算特征值
    ne.compute(*cloud_normals);
    // cloud_normals->points.size ()应该与input cloud_downsampled->points.size ()有相同尺寸
    //法线可视化
    pcl::visualization::PCLVisualizer viewer("PCL");
    viewer.setBackgroundColor(0.0, 0.0, 0.0);
    viewer.addPointCloud(cloud);
    viewer.addPointCloudNormals(cloud, cloud_normals, 10, 0.02, "nor");

    while (!viewer.wasStopped())
    {
        viewer.spinOnce(100);
        //boost::this_thread::sleep(boost::posix_time::microseconds(100000));
    }

    return 0;
}

VS2019在使用pcl的时候需要在预处理器里添加以下代码:

_CRT_SECURE_NO_WARNINGS
_SCL_SECURE_NO_WARNINGS
_SILENCE_FPOS_SEEKPOS_DEPRECATION_WARNING
NOMINMAX
BOOST_USE_WINDOWS_H

属性配置(release版,debug慢):

包含目录:

C:\Program Files\OpenNI2\Include;
C:\Program Files\PCL 1.9.1\include\pcl-1.9;
C:\Program Files\PCL 1.9.1\3rdParty\VTK\include\vtk-8.1;
C:\Program Files\PCL 1.9.1\3rdParty\Qhull\include;
C:\Program Files\PCL 1.9.1\3rdParty\FLANN\include;
C:\Program Files\PCL 1.9.1\3rdParty\Eigen\eigen3;
C:\Program Files\PCL 1.9.1\3rdParty\Boost\include\boost-1_68;

库目录:

C:\Program Files\OpenNI2\Lib;
C:\Program Files\PCL 1.9.1\lib;
C:\Program Files\PCL 1.9.1\3rdParty\VTK\lib;
C:\Program Files\PCL 1.9.1\3rdParty\Qhull\lib;
C:\Program Files\PCL 1.9.1\3rdParty\FLANN\lib;
C:\Program Files\PCL 1.9.1\3rdParty\Boost\lib;

附加依赖项:

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
vtkalglib-8.1.lib
vtkChartsCore-8.1.lib
vtkCommonColor-8.1.lib
vtkCommonComputationalGeometry-8.1.lib
vtkCommonCore-8.1.lib
vtkCommonDataModel-8.1.lib
vtkCommonExecutionModel-8.1.lib
vtkCommonMath-8.1.lib
vtkCommonMisc-8.1.lib
vtkCommonSystem-8.1.lib
vtkCommonTransforms-8.1.lib
vtkDICOMParser-8.1.lib
vtkDomainsChemistry-8.1.lib
vtkexoIIc-8.1.lib
vtkexpat-8.1.lib
vtkFiltersAMR-8.1.lib
vtkFiltersCore-8.1.lib
vtkFiltersExtraction-8.1.lib
vtkFiltersFlowPaths-8.1.lib
vtkFiltersGeneral-8.1.lib
vtkFiltersGeneric-8.1.lib
vtkFiltersGeometry-8.1.lib
vtkFiltersHybrid-8.1.lib
vtkFiltersHyperTree-8.1.lib
vtkFiltersImaging-8.1.lib
vtkFiltersModeling-8.1.lib
vtkFiltersParallel-8.1.lib
vtkFiltersParallelImaging-8.1.lib
vtkFiltersPoints-8.1.lib
vtkFiltersProgrammable-8.1.lib
vtkFiltersSelection-8.1.lib
vtkFiltersSMP-8.1.lib
vtkFiltersSources-8.1.lib
vtkFiltersStatistics-8.1.lib
vtkFiltersTexture-8.1.lib
vtkFiltersTopology-8.1.lib
vtkFiltersVerdict-8.1.lib
vtkfreetype-8.1.lib
vtkGeovisCore-8.1.lib
vtkgl2ps-8.1.lib
vtkhdf5-8.1.lib
vtkhdf5_hl-8.1.lib
vtkImagingColor-8.1.lib
vtkImagingCore-8.1.lib
vtkImagingFourier-8.1.lib
vtkImagingGeneral-8.1.lib
vtkImagingHybrid-8.1.lib
vtkImagingMath-8.1.lib
vtkImagingMorphological-8.1.lib
vtkImagingSources-8.1.lib
vtkImagingStatistics-8.1.lib
vtkImagingStencil-8.1.lib
vtkInfovisCore-8.1.lib
vtkInfovisLayout-8.1.lib
vtkInteractionImage-8.1.lib
vtkInteractionStyle-8.1.lib
vtkInteractionWidgets-8.1.lib
vtkIOAMR-8.1.lib
vtkIOCore-8.1.lib
vtkIOEnSight-8.1.lib
vtkIOExodus-8.1.lib
vtkIOExport-8.1.lib
vtkIOExportOpenGL-8.1.lib
vtkIOGeometry-8.1.lib
vtkIOImage-8.1.lib
vtkIOImport-8.1.lib
vtkIOInfovis-8.1.lib
vtkIOLegacy-8.1.lib
vtkIOLSDyna-8.1.lib
vtkIOMINC-8.1.lib
vtkIOMovie-8.1.lib
vtkIONetCDF-8.1.lib
vtkIOParallel-8.1.lib
vtkIOParallelXML-8.1.lib
vtkIOPLY-8.1.lib
vtkIOSQL-8.1.lib
vtkIOTecplotTable-8.1.lib
vtkIOVideo-8.1.lib
vtkIOXML-8.1.lib
vtkIOXMLParser-8.1.lib
vtkjpeg-8.1.lib
vtkjsoncpp-8.1.lib
vtklibharu-8.1.lib
vtklibxml2-8.1.lib
vtklz4-8.1.lib
vtkmetaio-8.1.lib
vtkNetCDF-8.1.lib
vtknetcdfcpp-8.1.lib
vtkoggtheora-8.1.lib
vtkParallelCore-8.1.lib
vtkpng-8.1.lib
vtkproj4-8.1.lib
vtkRenderingAnnotation-8.1.lib
vtkRenderingContext2D-8.1.lib
vtkRenderingContextOpenGL-8.1.lib
vtkRenderingCore-8.1.lib
vtkRenderingFreeType-8.1.lib
vtkRenderingGL2PS-8.1.lib
vtkRenderingImage-8.1.lib
vtkRenderingLabel-8.1.lib
vtkRenderingLIC-8.1.lib
vtkRenderingLOD-8.1.lib
vtkRenderingOpenGL-8.1.lib
vtkRenderingVolume-8.1.lib
vtkRenderingVolumeOpenGL-8.1.lib
vtksqlite-8.1.lib
vtksys-8.1.lib
vtktiff-8.1.lib
vtkverdict-8.1.lib
vtkViewsContext2D-8.1.lib
vtkViewsCore-8.1.lib
vtkViewsInfovis-8.1.lib
vtkzlib-8.1.lib
opengl32.lib

模型下载地址:

https://download.csdn.net/download/oMoDao1/12397824

你可能感兴趣的:(PCL)