PCL Chinese Forum: http://www.pclcn.org/bbs/forum.php
1. Installation
The full PCL installation package can be downloaded to: http://pointclouds.org/downloads/windows.html. Then install, my compiler is 32-bit, I downloaded the vs2010 32bit.
Install it automatically, select Add environment variable
2. Environment variable Configuration
Add environment variable Pcl_root
C:\Program Files (x86) \PCL 1.6.0
Then add it under the PATH environment variable:
%pcl_root%\bin;%pcl_root%\3rdparty\flann\bin;%pcl_root%\3rdparty\qhull\bin;
3. Create an empty project
New File Main.cpp
#include <pcl/visualization/cloud_viewer.h> #include <iostream> #include <pcl/io/io.h> #include <pcl/io/pcd_io.h>int user_data;void Vieweroneoff (pcl::visualization::P clvisualizer& Viewer) { Viewer.setbackgroundcolor (1.0, 0.5, 1.0); PCL::P ointxyz o; o.x = 1.0; O.Y = 0; o.z = 0; Viewer.addsphere (O, 0.25, "sphere", 0); Std::cout << "I only run Once" << Std::endl;} void Viewerpsycho (pcl::visualization::P clvisualizer& Viewer) {static unsigned count = 0; Std::stringstream SS; SS << "Once per Viewer loop:" << count++; Viewer.removeshape ("text", 0); Viewer.addtext (Ss.str (), Max, "text", 0); Fixme:possible race condition here:user_data++;} int main () {PCL::P OINTCLOUD<PCL::P ointxyzrgba>::P TR Cloud (New PCL::P OINTCLOUD<PCL::P ointxyzrgba>); Pcl::io::loadpcdfile ("MY_POINT_CLOUD.PCD", *cloud); Pcl::visualization::cloudviewer Viewer ("Cloud viewer"); Blocks untilThe cloud is actually rendered viewer.showcloud (cloud); Use the following functions-get access to the underlying more advanced/powerful//pclvisualizer//this would onl Y get called once viewer.runonvisualizationthreadonce (Vieweroneoff); This would get called once per visualization iteration viewer.runonvisualizationthread (Viewerpsycho); while (!viewer.wasstopped ()) {//you can also does cool processing here//fixme:note the This is running In a separate thread from Viewerpsycho//and you should guard against race conditions yourself ... user_data ++; } return 0;}
4. Configuration Engineering
1. Project---> Properties---> Configuration Properties--->vc++ directory
Contains the configuration of the mesh:
C:\Program Files (x86) \PCL 1.6.0\3rdparty\boost\include;
C:\Program Files (x86) \PCL 1.6.0\3rdparty\eigen\include;
C:\Program Files (x86) \PCL 1.6.0\3rdparty\flann\include;
C:\Program Files (x86) \PCL 1.6.0\3rdparty\qhull\include;
C:\Program Files (x86) \PCL 1.6.0\3rdparty\vtk\include\vtk-5.8;
C:\Program Files (x86) \openni\include;
C:\Program Files (x86) \PCL 1.6.0\include\pcl-1.6;
Project Properties->vc++ catalog, library directory
Library Directory Configuration:
C:\Program Files (x86) \PCL 1.6.0\3rdparty\boost\lib;
C:\Program Files (x86) \PCL 1.6.0\3rdparty\qhull\lib;
C:\Program Files (x86) \PCL 1.6.0\3rdparty\flann\lib;
C:\Program Files (x86) \PCL 1.6.0\3rdparty\vtk\lib\vtk-5.8;
C:\Program Files (x86) \PCL 1.6.0\lib;
C:\Program Files (x86) \openni\lib;
Dubug mode, add-on dependency of linker, input, and more:
Opengl32.libpcl_kdtree_debug.libpcl_io_debug.libpcl_search_debug.libpcl_segmentation_debug.libpcl_apps_ Debug.libpcl_features_debug.libpcl_filters_debug.libpcl_visualization_debug.libpcl_common_debug.libflann_cpp_ S-gd.liblibboost_system-vc100-mt-gd-1_47.liblibboost_filesystem-vc100-mt-gd-1_47.liblibboost_ Thread-vc100-mt-gd-1_47.liblibboost_date_time-vc100-mt-gd-1_47.liblibboost_iostreams-vc100-mt-gd-1_47. Libvtkalglib-gd.libvtkcharts-gd.libvtkcommon-gd.libvtkdicomparser-gd.libvtkexoiic-gd.libvtkexpat-gd.libvtkfiltering-gd.li Bvtkfreetype-gd.libvtkftgl-gd.libvtkgenericfiltering-gd.libvtkgeovis-gd.libvtkgraphics-gd.libvtkhdf5-gd.libvtkhybrid-gd.l Ibvtkimaging-gd.libvtkinfovis-gd.libvtkio-gd.libvtkjpeg-gd.libvtklibxml2-gd.libvtkmetaio-gd.libvtknetcdf-gd.libvtknetcdf _cxx-gd.libvtkpng-gd.libvtkproj4-gd.libvtkrendering-gd.libvtksqlite-gd.libvtksys-gd.libvtktiff-gd.libvtkverdict-gd.libvtk Views-gd.libvtkvolumerendering-gd.libvtkwidgets-gd.libvtkzlib-gd.lib
At this time the environment has been built, the compiler can pass, add a run-time required files my_point_cloud.pcd on it.
The contents of the document are as follows:
# . PCD v.7-point Cloud Data file formatversion. 7FIELDS x y z rgbsize 4 4 4 4TYPE F f F fcount 1 1 1 1WIDTH 213HEIGHT 1VIEW Point 0 0 0 1 0 0 0POINTS 213DATA ascii0.93773 0.33763 0 4.2108e+060.90805 0.35641 0 4.2108e+060.81915 0.32 0 4.2108e+060. 97192 0.278 0 4.2108e+060.944 0.29474 0 4.2108e+060.98111 0.24247 0 4.2108e+060.93655 0.26143 0 4.2108e+060.91631 0.27442 0 4.2108e+060.81921 0.29315 0 4.2108e+060.90701 0.24109 0 4.2108e+060.83239 0.23398 0 4.2108e+060.99185 0.2116 0 4.2108e+0 60.89264 0.21174 0 4.2108e+060.85082 0.21212 0 4.2108e+060.81044 0.32222 0 4.2108e+060.74459 0.32192 0 4.2108e+060.69927 0 .32278 0 4.2108e+060.8102 0.29315 0 4.2108e+060.75504 0.29765 0 4.2108e+060.8102 0.24399 0 4.2108e+060.74995 0.24723 0 4.2 108e+060.68049 0.29768 0 4.2108e+060.66509 0.29002 0 4.2108e+060.69441 0.2526 0 4.2108e+060.62807 0.22187 0 4.2108e+060.58 706 0.32199 0 4.2108e+060.52125 0.31955 0 4.2108e+060.49351 0.32282 0 4.2108e+060.44313 0.32169 0 4.2108e+060.58678 0.2929 0 4.2108e+060.534360.29164 0 4.2108e+060.59308 0.24134 0 4.2108e+060.5357 0.2444 0 4.2108e+060.50043 0.31235 0 4.2108e+060.44107 0.29711 0 4. 2108e+060.50727 0.22193 0 4.2108e+060.43957 0.23976 0 4.2108e+060.8105 0.21112 0 4.2108e+060.73555 0.2114 0 4.2108e+060.69 907 0.21082 0 4.2108e+060.63327 0.21154 0 4.2108e+060.59165 0.21201 0 4.2108e+060.52477 0.21491 0 4.2108e+060.49375 0.2100 6 0 4.2108e+060.4384 0.19632 0 4.2108e+060.43425 0.16052 0 4.2108e+060.3787 0.32173 0 4.2108e+060.33444 0.3216 0 4.2108e+0 60.23815 0.32199 0 4.808e+060.3788 0.29315 0 4.2108e+060.33058 0.31073 0 4.2108e+060.3788 0.24399 0 4.2108e+060.30249 0.29 189 0 4.2108e+060.23492 0.29446 0 4.808e+060.29465 0.24399 0 4.2108e+060.23514 0.24172 0 4.808e+060.18836 0.32277 0 4.808e +060.15992 0.32176 0 4.808e+060.08642 0.32181 0 4.808e+060.039994 0.32283 0 4.808e+060.20039 0.31211 0 4.808e+060.1417 0.2 9506 0 4.808e+060.20921 0.22332 0 4.808e+060.13884 0.24227 0 4.808e+060.085123 0.29441 0 4.808e+060.048446 0.31279 0 4.808 e+060.086957 0.24399 0 4.808e+060.3788 0.21189 0 4.2108e+060.29465 0.19323 0 4.2108e+060.23755 0.19348 0 4.808e+060.29463 0.16054 0 4.2108e+060.23 776 0.16054 0 4.808e+060.19016 0.21038 0 4.808e+060.15704 0.21245 0 4.808e+060.08678 0.21169 0 4.808e+060.012746 0.32168 0 4.808e+06-0.075715 0.32095 0 4.808e+06-0.10622 0.32304 0 4.808e+06-0.16391 0.32118 0 4.808e+060.00088411 0.29487 0 4.808e +06-0.057568 0.29457 0 4.808e+06-0.0034333 0.24399 0 4.808e+06-0.055185 0.24185 0 4.808e+06-0.10983 0.31352 0 4.808e+06-0. 15082 0.29453 0 4.808e+06-0.11534 0.22049 0 4.808e+06-0.15155 0.24381 0 4.808e+06-0.1912 0.32173 0 4.808e+06-0.281 0.3185 0 4.808e+06-0.30791 0.32307 0 4.808e+06-0.33854 0.32148 0 4.808e+06-0.21248 0.29805 0 4.808e+06-0.26372 0.29905 0 4.808e+0 6-0.22562 0.24399 0 4.808e+06-0.25035 0.2371 0 4.808e+06-0.29941 0.31191 0 4.808e+06-0.35845 0.2954 0 4.808e+06-0.29231 0. 22236 0 4.808e+06-0.36101 0.24172 0 4.808e+06-0.0034393 0.21129 0 4.808e+06-0.07306 0.21304 0 4.808e+06-0.10579 0.2099 0 4 .808e+06-0.13642 0.21411 0 4.808e+06-0.22562 0.19323 0 4.808e+06-0.24439 0.19799 0 4.808e+06-0.22591 0.16041 0 4.808e+06-0.23466 0.16082 0 4.808e+ 06-0.3077 0.20998 0 4.808e+06-0.3413 0.21239 0 4.808e+06-0.40551 0.32178 0 4.2108e+06-0.50568 0.3218 0 4.2108e+06-0.41732 0.30844 0 4.2108e+06-0.44237 0.28859 0 4.2108e+06-0.41591 0.22004 0 4.2108e+06-0.44803 0.24236 0 4.2108e+06-0.50623 0.2931 5 0 4.2108e+06-0.50916 0.24296 0 4.2108e+06-0.57019 0.22334 0 4.2108e+06-0.59611 0.32199 0 4.2108e+06-0.65104 0.32199 0 4. 2108e+06-0.72566 0.32129 0 4.2108e+06-0.75538 0.32301 0 4.2108e+06-0.59653 0.29315 0 4.2108e+06-0.65063 0.29315 0 4.2108e+ 06-0.59478 0.24245 0 4.2108e+06-0.65063 0.24399 0 4.2108e+06-0.70618 0.29525 0 4.2108e+06-0.76203 0.31284 0 4.2108e+06-0.7 0302 0.24183 0 4.2108e+06-0.77062 0.22133 0 4.2108e+06-0.41545 0.21099 0 4.2108e+06-0.45004 0.19812 0 4.2108e+06-0.4475 0. 1673 0 4.2108e+06-0.52031 0.21236 0 4.2108e+06-0.55182 0.21045 0 4.2108e+06-0.5965 0.21131 0 4.2108e+06-0.65064 0.2113 0 4 .2108e+06-0.72216 0.21286 0 4.2108e+06-0.7556 0.20987 0 4.2108e+06-0.78343 0.31973 0 4.2108e+06-0.87572 0.32111 0 4.2108e+06-0.90519 0.32263 0 4.2 108e+06-0.95526 0.34127 0 4.2108e+06-0.79774 0.29271 0 4.2108e+06-0.85618 0.29497 0 4.2108e+06-0.79975 0.24326 0 4.2108e+0 6-0.8521 0.24246 0 4.2108e+06-0.91157 0.31224 0 4.2108e+06-0.95031 0.29572 0 4.2108e+06-0.92223 0.2213 0 4.2108e+06-0.9497 9 0.24354 0 4.2108e+06-0.78641 0.21505 0 4.2108e+06-0.87094 0.21237 0 4.2108e+06-0.90637 0.20934 0 4.2108e+06-0.93777 0.21 481 0 4.2108e+060.22244-0.0296 0 4.808e+060.2704-0.078167 0 4.808e+060.24416-0.056883 0 4.808e+060.27311-0.10653 0 4.8 08e+060.26172-0.10653 0 4.808e+060.2704-0.1349 0 4.808e+060.24428-0.15599 0 4.808e+060.19017-0.025297 0 4.808e+060.142 48-0.02428 0 4.808e+060.19815-0.037432 0 4.808e+060.14248-0.03515 0 4.808e+060.093313-0.02428 0 4.808e+060.044144-0.0 2428 0 4.808e+060.093313-0.03515 0 4.808e+060.044144-0.03515 0 4.808e+060.21156-0.17357 0 4.808e+060.029114-0.12594 0 4.2108e+060.036583-0.15619 0 4.2108e+060.22446-0.20514 0 4.808e+060.2208-0.2369 0 4.808e+060.2129-0.208 0 4.808e+060.19316-0.25672 0 4.808e+0 60.14497-0.27484 0 4.808e+060.030167-0.18748 0 4.2108e+060.1021-0.27453 0 4.808e+060.1689-0.2831 0 4.808e+060.13875-0 .28647 0 4.808e+060.086993-0.29568 0 4.808e+060.044924-0.3154 0 4.808e+06-0.0066125-0.02428 0 4.808e+06-0.057362-0.024 0 4.808e+06-0.0066125-0.03515 0 4.808e+06-0.057362-0.03515 0 4.808e+06-0.10653-0.02428 0 4.808e+06-0.15266-0.025282 0 4.808e+06-0.10653-0.03515 0 4.808e+06-0.16036-0.037257 0 4.808e+060.0083286-0.1259 0 4.2108e+060.0007442-0.15603 0 4.2108e+06-0.1741-0.17381 0 4.808e+06-0.18502-0.02954 0 4.808e+06-0.20707-0.056403 0 4.808e+06-0.23348-0.07764 0 4.808 e+06-0.2244-0.10653 0 4.808e+06-0.23604-0.10652 0 4.808e+06-0.20734-0.15641 0 4.808e+06-0.23348-0.13542 0 4.808e+060.0 061083-0.18729 0 4.2108e+06-0.066235-0.27472 0 4.808e+06-0.17577-0.20789 0 4.808e+06-0.10861-0.27494 0 4.808e+06-0.155 84-0.25716 0 4.808e+06-0.0075775-0.31546 0 4.808e+06-0.050817-0.29595 0 4.808e+06-0.10306-0.28653 0 4.808e+06-0.1319-0.2831 0 4.808e+06-0.187 16-0.20571 0 4.808e+06-0.18369-0.23729 0 4.808e+06
5. Implementation results
Problem occurs, the runtime will appear no more than the PCD file, you can create additional code to generate the PCD file, you can also copy other PCD files over the notebook open, modify the contents
Generate the PCD file code:
#include <iostream> #include <pcl/io/pcd_io.h> #include <pcl/ Point_types.h>int Main (int argc, char** argv) {PCL::P OINTCLOUD<PCL::P ointxyz> Cloud; Fill in the cloud data Cloud.width = 5; Cloud.height = 1; Cloud.is_dense = false; Cloud.points.resize (Cloud.width * cloud.height); for (size_t i = 0; i < cloud.points.size (); ++i) {cloud.points[i].x = 1024x768 * RAND ()/(Rand_max + 1.0f); CLOUD.POINTS[I].Y = 1024x768 * RAND ()/(Rand_max + 1.0f); CLOUD.POINTS[I].Z = 1024x768 * RAND ()/(Rand_max + 1.0f); } pcl::io::savepcdfileascii ("TEST_PCD.PCD", Cloud); Std::cerr << "Saved" << cloud.points.size () << "data points to test_pcd.pcd." << 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; return (0);}
Vs2010+pcl+openni Configuration