手把手开始第一个PCL工程(VS2017)
两年前毕设的时候写的,忘记发布了,尴尬。。。。
Hardware&Software Environment to this tutorial
Operating System and version: Windows 10 64-bit based on x64 processors
Compiler: IDE VS2017 Community
solution configuration: Debug platform: x86
PCL Version:PCL 1.8.1 All-in-one Installer MSVC2017 Win32
Step 1 Download the All-in-one Installer
You may have multiple alternatives to do this at the moment. Some of them are listed below.
1 http://unanancyowen.com/en/pcl181#DownloadVC141
Tips: This tutorial is aimed at PCL-1.8.1 for win32 platform. In order to avoid unpredictable situations, you have better choose the correct version aligned to this tutorial.
Step 2 Install
Give it with a double-click and you just act as the wizard suggests.
As it goes, I prefer [Add PCL to the system PATH for all users].
And my desired target folder location is N:\PCL 1.8.1 as you see:
Both components have been selected by me.
On the process of All-in-one installation, you will see a window popping up. That is OpenNI 2.2 SDK installer. You should choose your desired location for it.
When the setup of OpenNI 2.2 SDK is completed, you are closer to the full completion of installation.
And then I can see two relative folders have been written in my hard disk N.
Step 3 Create a new VS2017 project
An empty project is what we exactly want and you can add a new item to your Source Files folder. This tutorial is going to use the example in:
http://www.pointclouds.org/documentation/tutorials/cluster_extraction.php
After copy the code from that page, I save and name it as Euclidean_Cluster_Extraction.cpp
Step 4 Configure your project
You can perform these procedures in your VS2017 by:
[A] Debug->Project Property->VC++ Directories->
1 In the Include Directories, make sure you have:
2 In the Library Directories, make sure you have:
[B] C++->General->
Disable SDL checks.
Tips: don’t forget to replace the PATH/TO/FOLDER in the location strings specific to your unique workplace.
Step 5 Have a try to build your solution at the first time
You may fail to do that, and don’t worry about it. It is under control.
If you find an error like this:
1>n:\pcl 1.8.1\3rdparty\flann\include\flann\algorithms\dist.h(522): error C3861: ‘pop_t’: identifier not found
Solution: move the line(maybe at line 503 in dist.h) before [#if __GNUC__], after that save and rebuild it.
This time, you are more likely to meet with [23 unresolved externals]. Just copy the lines below to your Euclidean_Cluster_Extraction.cpp.
Tips: don’t forget to replace the PATH/TO/FOLDER in the location strings specific to your unique workplace.
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_search_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_kdtree_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_common_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_segmentation_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_sample_consensus_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_filters_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_io_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_octree_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_surface_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_visualization_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_search_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_features_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_keypoints_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_outofcore_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_people_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_recognition_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_registration_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_stereo_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_tracking_debug.lib”)
#pragma comment(lib , “N://PCL 1.8.1//lib//pcl_io_ply_debug.lib”)
Save and rebuild it.
This time, you may have gotten an exe file successfully. However, this is not the end.
Step 6 Complete it
Before you can successfully run the exe file you have just generated, you should search for certain dll file and exe file from your PCL 1.8.1 folder and OpenNI 2.2 SDK folder. And remember to download the corresponding data file from
https://raw.github.com/PointCloudLibrary/data/master/tutorials/table_scene_lms400.pcd
Once you’ve finished, in the directory where your project executable file exists you should see something similar to this:
Step 7 Run your executable file and visualize the results using pcl_viewer
1 after double clicking your project exe file you will see several pcd file will have been created in a few seconds.
2 start your cmd at current workplace and type this line:
$pcl_viewer_debug.exe cloud_cluster_0.pcd cloud_cluster_1.pcd cloud_cluster_2.pcd cloud_cluster_3.pcd cloud_cluster_4.pcd