Win10 64-bit vs2017 qt5.12.6 pcl1.9.1 vtk8.1.1 configuration and installation steps

Since I have QT5.12.6 VS2017 in my computer, I won’t introduce how to install it. I will only introduce the configuration steps of cmake, pcl and vtk.

In order to facilitate subsequent calls to QT, Chinese characters and spaces cannot appear in any of the following installation paths.

PCL's own VTK is incomplete, so you need to download the VTK source code and recompile it to support QT.

1: Resource link:

[Free] pcl1.9.1vtk8.1.1cmake3.14.2 is used under win1064, vs2017qt5.12.6 resource-CSDN library https://download.csdn.net/download/u012719076/88146824

Resource content:

 The corresponding VTK version of PCL 1.9.1 version is 8.1.

The VTK 8.1.1 version I chose

First download the above 4 files and unzip all compressed packages

2. Cmake installation

Click cmake-3.14.2-win64-x64.msi and follow the instructions

Note: I did not choose the default path for the installation path. My path is: D:\ProgramFiles\Cmake

3. pcl installation

(1) Installation of PCL-1.9.1-AllInOne-msvc2017-win64.exe

 1. Double-click the exe. The first two steps are default. The third step: select   Add PCL to the system PATH for all users.

2. Installation path D:\ProgramFiles\PCL\PCL1.9.1 - Note that there must be no spaces. 

Subsequent steps Installation path: I chose: D:\ProgramFiles\PCL,

Automatically generate path: D:\ProgramFiles\PCL\PC L 1.9.1 Note: There are spaces in this path. The path in qt cannot recognize the path with spaces, so the spaces must be removed.

The final installation path is D:\ProgramFiles\PCL\PCL1.9.1

3. When selecting components, select all--just follow the default

 4.OpenNI installation

At the end of the PCL installation, a pop-up will pop up to install the third-party library. My installation path is:

D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\OpenNI2 Others can be installed by default.

(2) Unzip and copy 

Unzip pcl-1.9.1-pdb-msvc2017-win64.zip and copy all pdb files to the pcl installation path.

D:\ProgramFiles\PCL\PCL1.9.1\bin

Note: The vtk in pcl does not need to be changed, because the vtk in pcl1.9.1 is 8.1.1, which is consistent with the vtk version configured in Qt

This completes the PCL installation

4. vtk compilation

(1) Compilation steps:

The steps mainly refer to the following two articles.

VS2015 + PCL1.8.0 + QT_5.62 + cmake3.82 compile VTK7.1 and generate QVTKWidgetPlugin.dll_Gongqin Tireless Blog-CSDN Blog https://blog.csdn.net/ktony_90/article/details/77966904 VTK8 .2.0 Compilation, Installation and Test Case Operation (win10 + VS2017 + Qt5, Release + Debug)_How to open the test program during vtk compilation_LiveAn's blog-CSDN blog https://blog.csdn.net/anhec/article/details/86777302

vs+qt+vtk+pcl+cmake download, installation, configuration and solution of a series of problems in the process_vs installation vtk_ych knows nothing blog-CSDN blog https://blog.csdn.net/m0_74195873/article/ details/129910816

0. First create 2 empty folders to store the vtk compiler and installation program--under the desired installation path

 1. Open cmake as an administrator, select the source code path, compilation path, and check Advanced

VS2017+Qt5.12.0+PCL1.9.1 development environment configuration process detailed record_Xiaolong loves learning blog-CSDN blog

You can refer to this setting type 

(1) Click Add Entry, add CMAKE_PREFIX_PATH, type "PATH", and set it to the installation path of QT.
(2) Click Add Entry, add CMAKE_DEBUG_POSTFIX, and set it to "_d". Used to distinguish dll and lib files under debug and release versions. Otherwise, when creating installation files, debug and release versions will overwrite each other with the same names.

I should have chosen string   ; I chose the wrong one, I chose filepath.

(3) Then click config and select vs2017---x64 and other defaults. After configuration, a bunch of red will appear. Don't be afraid, continue. .

 2. Check-Configure-Configure again
 

 Check BUILD_SHARED_LIBS to generate VTK lib and dll.
Check BUILD_EXAMPLES to generate some

​Check VTK_Group_Qt to let VTK support Qt Application

Set the CMAKE_INSTALL_PREFIX directory as the VTK installation directory (D:\ProgramFiles\VTK\VTK811\install)

3. Confirm the path and configure again

Step 2 After clicking config, the red color is much less missing. This step is mainly to confirm whether the path of the red variable (Qt path, Examples path) is correct and whether the Qt version is 5.

 After clicking config in this step, although config done is displayed there is still red. After confirmation, click config again until no red appears.

4. Click Generate

Generate vtk project under compilation path buildid

(2) vs generates lib and dll

1. Open the vtk project

Open VS2017 in administrator mode, and then open the project VTK.sln

The path is in D:\ProgramFiles\VTK\VTK811\build  

2. In debug mode

(1).Compile ALL-BUILD project  

Select debug x64 mode, click the ALL-BUILD project, generate---regenerate ALL-BUILD. The compilation process takes about one hour.

 After about an hour, the compilation results are as follows:

269>------ 已启动全部重新生成: 项目: ALL_BUILD, 配置: Debug x64 ------
269>Building Custom Rule D:/software/pcl/vtk-v8.1.1/vtk-v8.1.1/CMakeLists.txt
269>CMake does not need to re-run because D:/ProgramFiles/VTK/VTK811/build/CMakeFiles/generate.stamp is up-to-date.
========== 全部重新生成: 成功 268 个,失败 1 个,跳过 0 个 ==========

What failed is: I didn’t care and continued to compile and install.

0>CMake Error at D:/ProgramFiles/Cmake/share/cmake-3.14/Modules/ExternalData.cmake:1121 (message):
30>
30>
30>  Object MD5=6424e2a51d932a5c93c361c14c3c4c49 not found at:
30>
30>    http://midas3.kitware.com/midas/api/rest?method=midas.bitstream.download&checksum=6424e2a51d932a5c93c361c14c3c4c49&algorithm=MD5 ("HTTP response code said error")
30>    http://www.vtk.org/files/ExternalData/MD5/6424e2a51d932a5c93c361c14c3c4c49 ("Timeout was reached")
30>
30>
30>C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: “cmd.exe”已退出,代码为 1。
(2).Compile INSTALL project

Click on the INSTALL project, right-click, and select "Only for project -> Generate INSTALL only"

After the compilation is successful, go to D:\ProgramFiles\VTK\VTK811\install in the VTK installation path.

You can see the following information, both dll and lib have _d

(3) Place the above folder under the newly created debug, and then re-create it in release mode

3.release

Select release--x64

(1)ALL-BUILD project  

Click ALL-BUILD, right-click and select Generate     

It took about half an hour to compile, and generated: 268 successful, 1 failed, 0 latest, 0 skipped ==========

Still failed or cmake

(2). INSTALL project

Click on the INSTALL project, right-click, and select " Only for project   ->    Generate INSTALL only"

After the compilation is successful, go to D:\ProgramFiles\VTK\VTK811\install in the VTK installation path.

You can see the following information, neither dll nor lib has _d

(3) Copy all files under the generated release to the new folder

(4) Copy the dll to the QT designer path

Add the release version of QVTKWidgetPlugin.dll (must be the release version) to the path of your QT designer, D:\QT\5.12.6\msvc2017_64\plugins\designer

You can add the QVTKWidget control in the msvc2017_64 version of Qt Designer.

(3) Test vtk

Test whether vtk is compiled successfully. In the VTK project, select the cube project, right-click, and set it as startup project .

Then click Run, and it will appear as shown below

In the same way, you can also test: Cone6 project, the test is a cone

 5. Environment variable settings

(1) PCL system environment variable configuration

The following variable values ​​are newly added to the system environment variable path

//用下面的
D:\ProgramFiles\PCL\PCL1.9.1\bin
D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Boost\lib
D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\FLANN\bin
D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Qhull\bin
D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\OpenNI2\Lib
D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\OpenNI2\Redist
D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\OpenNI2\Tools



Notice:

Note: The vtk in pcl does not need to be changed, because the vtk in pcl1.9.1 is 8.1.1, which is consistent with the vtk version configured in Qt

(2) vtk environment variable settings

Configure vtk into the system's environment variables

D:\ProgramFiles\VTK\VTK811\install\debug\bin
D:\ProgramFiles\VTK\VTK811\install\release\bin

Six: There is no QVTKWidget in the qt createtor designer

When I opened my qt creator, there was no QVTKWidget in the UI interface, but when I opened the designer separately, I found that it was there.

Reference: QT+VTK+PCL environment configuration under Windows 10 (one success)_qt pcl_v Junyi's blog-CSDN blog

There is no problem. Qt creator will not display QVTK, but it is available in Qt Designer. It will not affect the use process. This is a historical problem that Qt has never solved.

Open a separate qt designer and it will appear in the lower left corner 

7. Qt-PCL test

Since there was a problem when testing vtk, let's test pcl first to see if the installation is successful.

(1) View all _d.lib files in the folder

Batch processing steps to get the file name under a certain folder:

获取某一文件夹下文件名的批处理步骤:
新建一个1.txt,输入如下命令:
dir /a-d /b *>scr.txt
再将1.txt后缀名改为.bat即1.bat,运行就会生成一个scr.txt,
里面存放的是文件名,复制所有.lib文件名(即去掉1.bat和scr.txt)到附加依赖项即可完成配置。

(2) pro file configuration in qt

CONFIG += debug_and_release

INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Boost\include\boost-1_68
INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Boost\include\boost-1_68\boost
INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Eigen\eigen3
INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\FLANN\include
INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\FLANN\include\flann
INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Qhull\include
INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\3rdParty\OpenNI2\Include
INCLUDEPATH += D:\ProgramFiles\PCL\PCL1.9.1\include\pcl-1.9

message("peizhi")

CONFIG(debug,debug|release){

message("debug pro")
INCLUDEPATH += D:\ProgramFiles\VTK\VTK811\install\debug\include\vtk-8.1
LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\lib\
        -lpcl_common_debug\
        -lpcl_features_debug\
        -lpcl_filters_debug\
        -lpcl_io_debug\
        -lpcl_io_ply_debug\
        -lpcl_kdtree_debug\
        -lpcl_keypoints_debug\
        -lpcl_ml_debug\
        -lpcl_octree_debug\
        -lpcl_outofcore_debug\
        -lpcl_people_debug\
        -lpcl_recognition_debug\
        -lpcl_registration_debug\
        -lpcl_sample_consensus_debug\
        -lpcl_search_debug\
        -lpcl_segmentation_debug\
        -lpcl_stereo_debug\
        -lpcl_surface_debug\
        -lpcl_tracking_debug\
        -lpcl_visualization_debug

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Boost\lib\
        -llibboost_atomic-vc141-mt-gd-x64-1_68\
        -llibboost_bzip2-vc141-mt-gd-x64-1_68\
        -llibboost_chrono-vc141-mt-gd-x64-1_68\
        -llibboost_container-vc141-mt-gd-x64-1_68\
        -llibboost_context-vc141-mt-gd-x64-1_68\
        -llibboost_coroutine-vc141-mt-gd-x64-1_68\
        -llibboost_date_time-vc141-mt-gd-x64-1_68\
        -llibboost_exception-vc141-mt-gd-x64-1_68\
        -llibboost_fiber-vc141-mt-gd-x64-1_68\
        -llibboost_filesystem-vc141-mt-gd-x64-1_68\
        -llibboost_graph-vc141-mt-gd-x64-1_68\
        -llibboost_graph_parallel-vc141-mt-gd-x64-1_68\
        -llibboost_iostreams-vc141-mt-gd-x64-1_68\
        -llibboost_locale-vc141-mt-gd-x64-1_68\
        -llibboost_log-vc141-mt-gd-x64-1_68\
        -llibboost_log_setup-vc141-mt-gd-x64-1_68\
        -llibboost_math_c99-vc141-mt-gd-x64-1_68\
        -llibboost_math_c99f-vc141-mt-gd-x64-1_68\
        -llibboost_math_c99l-vc141-mt-gd-x64-1_68\
        -llibboost_math_tr1-vc141-mt-gd-x64-1_68\
        -llibboost_math_tr1f-vc141-mt-gd-x64-1_68\
        -llibboost_math_tr1l-vc141-mt-gd-x64-1_68\
        -llibboost_mpi-vc141-mt-gd-x64-1_68\
        -llibboost_numpy27-vc141-mt-gd-x64-1_68\
        -llibboost_numpy37-vc141-mt-gd-x64-1_68\
        -llibboost_prg_exec_monitor-vc141-mt-gd-x64-1_68\
        -llibboost_program_options-vc141-mt-gd-x64-1_68\
        -llibboost_python27-vc141-mt-gd-x64-1_68\
        -llibboost_python37-vc141-mt-gd-x64-1_68\
        -llibboost_random-vc141-mt-gd-x64-1_68\
        -llibboost_regex-vc141-mt-gd-x64-1_68\
        -llibboost_serialization-vc141-mt-gd-x64-1_68\
        -llibboost_signals-vc141-mt-gd-x64-1_68\
        -llibboost_system-vc141-mt-gd-x64-1_68\
        -llibboost_test_exec_monitor-vc141-mt-gd-x64-1_68\
        -llibboost_thread-vc141-mt-gd-x64-1_68\
        -llibboost_timer-vc141-mt-gd-x64-1_68\
        -llibboost_type_erasure-vc141-mt-gd-x64-1_68\
        -llibboost_unit_test_framework-vc141-mt-gd-x64-1_68\
        -llibboost_wave-vc141-mt-gd-x64-1_68\
        -llibboost_wserialization-vc141-mt-gd-x64-1_68\
        -llibboost_zlib-vc141-mt-gd-x64-1_68

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\FLANN\lib\
        -lflann-gd\
        -lflann_cpp-gd\
        -lflann_cpp_s-gd\
        -lflann_s-gd

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\OpenNI2\Lib\ -lOpenNI2

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Qhull\lib\
        -lqhull_d\
        -lqhullcpp_d\
        -lqhullstatic_d\
        -lqhullstatic_r_d\
        -lqhull_p_d\
        -lqhull_r_d

LIBS += -LD:\ProgramFiles\VTK\VTK811\install\debug\lib\
        -lvtkalglib-8.1_d\
        -lvtkChartsCore-8.1_d\
        -lvtkCommonColor-8.1_d\
        -lvtkCommonComputationalGeometry-8.1_d\
        -lvtkCommonCore-8.1_d\
        -lvtkCommonDataModel-8.1_d\
        -lvtkCommonExecutionModel-8.1_d\
        -lvtkCommonMath-8.1_d\
        -lvtkCommonMisc-8.1_d\
        -lvtkCommonSystem-8.1_d\
        -lvtkCommonTransforms-8.1_d\
        -lvtkDICOMParser-8.1_d\
        -lvtkDomainsChemistry-8.1_d\
        -lvtkexoIIc-8.1_d\
        -lvtkexpat-8.1_d\
        -lvtkFiltersAMR-8.1_d\
        -lvtkFiltersCore-8.1_d\
        -lvtkFiltersExtraction-8.1_d\
        -lvtkFiltersFlowPaths-8.1_d\
        -lvtkFiltersGeneral-8.1_d\
        -lvtkFiltersGeneric-8.1_d\
        -lvtkFiltersGeometry-8.1_d\
        -lvtkFiltersHybrid-8.1_d\
        -lvtkFiltersHyperTree-8.1_d\
        -lvtkFiltersImaging-8.1_d\
        -lvtkFiltersModeling-8.1_d\
        -lvtkFiltersParallel-8.1_d\
        -lvtkFiltersParallelImaging-8.1_d\
        -lvtkFiltersPoints-8.1_d\
        -lvtkFiltersProgrammable-8.1_d\
        -lvtkFiltersSelection-8.1_d\
        -lvtkFiltersSMP-8.1_d\
        -lvtkFiltersSources-8.1_d\
        -lvtkFiltersStatistics-8.1_d\
        -lvtkFiltersTexture-8.1_d\
        -lvtkFiltersTopology-8.1_d\
        -lvtkFiltersVerdict-8.1_d\
        -lvtkfreetype-8.1_d\
        -lvtkGeovisCore-8.1_d\
        -lvtkgl2ps-8.1_d\
        -lvtkglew-8.1_d\
        -lvtkGUISupportQt-8.1_d\
#        -lvtkGUISupportQtOpenGL2-8.1_d\
        -lvtkGUISupportQtSQL-8.1_d\
        -lvtkhdf5-8.1_d\
        -lvtkhdf5_hl-8.1_d\
        -lvtkImagingColor-8.1_d\
        -lvtkImagingCore-8.1_d\
        -lvtkImagingFourier-8.1_d\
        -lvtkImagingGeneral-8.1_d\
        -lvtkImagingHybrid-8.1_d\
        -lvtkImagingMath-8.1_d\
        -lvtkImagingMorphological-8.1_d\
        -lvtkImagingSources-8.1_d\
        -lvtkImagingStatistics-8.1_d\
        -lvtkImagingStencil-8.1_d\
        -lvtkInfovisCore-8.1_d\
        -lvtkInfovisLayout-8.1_d\
        -lvtkInteractionImage-8.1_d\
        -lvtkInteractionStyle-8.1_d\
        -lvtkInteractionWidgets-8.1_d\
        -lvtkIOAMR-8.1_d\
        -lvtkIOCore-8.1_d\
        -lvtkIOEnSight-8.1_d\
        -lvtkIOExodus-8.1_d\
        -lvtkIOExport-8.1_d\
        -lvtkIOExportOpenGL2-8.1_d\
        -lvtkIOGeometry-8.1_d\
        -lvtkIOImage-8.1_d\
        -lvtkIOImport-8.1_d\
        -lvtkIOInfovis-8.1_d\
        -lvtkIOLegacy-8.1_d\
        -lvtkIOLSDyna-8.1_d\
        -lvtkIOMINC-8.1_d\
        -lvtkIOMovie-8.1_d\
        -lvtkIONetCDF-8.1_d\
        -lvtkIOParallel-8.1_d\
        -lvtkIOParallelXML-8.1_d\
        -lvtkIOPLY-8.1_d\
        -lvtkIOSQL-8.1_d\
        -lvtkIOTecplotTable-8.1_d\
        -lvtkIOVideo-8.1_d\
        -lvtkIOXML-8.1_d\
        -lvtkIOXMLParser-8.1_d\
        -lvtkjpeg-8.1_d\
        -lvtkjsoncpp-8.1_d\
        -lvtklibharu-8.1_d\
        -lvtklibxml2-8.1_d\
        -lvtklz4-8.1_d\
        -lvtkmetaio-8.1_d\
        -lvtkNetCDF-8.1_d\
        -lvtknetcdfcpp-8.1_d\
        -lvtkoggtheora-8.1_d\
        -lvtkParallelCore-8.1_d\
        -lvtkpng-8.1_d\
        -lvtkproj4-8.1_d\
        -lvtkRenderingAnnotation-8.1_d\
        -lvtkRenderingContext2D-8.1_d\
        -lvtkRenderingContextOpenGL2-8.1_d\
        -lvtkRenderingCore-8.1_d\
        -lvtkRenderingFreeType-8.1_d\
        -lvtkRenderingGL2PSOpenGL2-8.1_d\
        -lvtkRenderingImage-8.1_d\
        -lvtkRenderingLabel-8.1_d\
        -lvtkRenderingLOD-8.1_d\
        -lvtkRenderingOpenGL2-8.1_d\
        -lvtkRenderingQt-8.1_d\
        -lvtkRenderingVolume-8.1_d\
        -lvtkRenderingVolumeOpenGL2-8.1_d\
        -lvtksqlite-8.1_d\
        -lvtksys-8.1_d\
        -lvtktiff-8.1_d\
        -lvtkverdict-8.1_d\
        -lvtkViewsContext2D-8.1_d\
        -lvtkViewsCore-8.1_d\
        -lvtkViewsInfovis-8.1_d\
        -lvtkViewsQt-8.1_d\
        -lvtkzlib-8.1_d

} else {  #也可以按照下面进行设置,没有此句
#CONFIG(release,debug|release){
message("release CameraUi.pro")
INCLUDEPATH += D:\ProgramFiles\VTK\VTK811\install\release\include\vtk-8.1
LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\lib\
        -lpcl_common_release\
        -lpcl_features_release\
        -lpcl_filters_release\
        -lpcl_io_ply_release\
        -lpcl_io_release\
        -lpcl_kdtree_release\
        -lpcl_keypoints_release\
        -lpcl_ml_release\
        -lpcl_octree_release\
        -lpcl_outofcore_release\
        -lpcl_people_release\
        -lpcl_recognition_release\
        -lpcl_registration_release\
        -lpcl_sample_consensus_release\
        -lpcl_search_release\
        -lpcl_segmentation_release\
        -lpcl_stereo_release\
        -lpcl_surface_release\
        -lpcl_tracking_release\
        -lpcl_visualization_release

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Boost\lib\
        -llibboost_atomic-vc141-mt-x64-1_68\
        -llibboost_bzip2-vc141-mt-x64-1_68\
        -llibboost_chrono-vc141-mt-x64-1_68\
        -llibboost_container-vc141-mt-x64-1_68\
        -llibboost_context-vc141-mt-x64-1_68\
        -llibboost_coroutine-vc141-mt-x64-1_68\
        -llibboost_date_time-vc141-mt-x64-1_68\
        -llibboost_exception-vc141-mt-x64-1_68\
        -llibboost_fiber-vc141-mt-x64-1_68\
        -llibboost_filesystem-vc141-mt-x64-1_68\
        -llibboost_graph-vc141-mt-x64-1_68\
        -llibboost_graph_parallel-vc141-mt-x64-1_68\
        -llibboost_iostreams-vc141-mt-x64-1_68\
        -llibboost_locale-vc141-mt-x64-1_68\
        -llibboost_log-vc141-mt-x64-1_68\
        -llibboost_log_setup-vc141-mt-x64-1_68\
        -llibboost_math_c99-vc141-mt-x64-1_68\
        -llibboost_math_c99f-vc141-mt-x64-1_68\
        -llibboost_math_c99l-vc141-mt-x64-1_68\
        -llibboost_math_tr1-vc141-mt-x64-1_68\
        -llibboost_math_tr1f-vc141-mt-x64-1_68\
        -llibboost_math_tr1l-vc141-mt-x64-1_68\
        -llibboost_mpi-vc141-mt-x64-1_68\
        -llibboost_numpy27-vc141-mt-x64-1_68\
        -llibboost_numpy37-vc141-mt-x64-1_68\
        -llibboost_prg_exec_monitor-vc141-mt-x64-1_68\
        -llibboost_program_options-vc141-mt-x64-1_68\
        -llibboost_python27-vc141-mt-x64-1_68\
        -llibboost_python37-vc141-mt-x64-1_68\
        -llibboost_random-vc141-mt-x64-1_68\
        -llibboost_regex-vc141-mt-x64-1_68\
        -llibboost_serialization-vc141-mt-x64-1_68\
        -llibboost_signals-vc141-mt-x64-1_68\
        -llibboost_system-vc141-mt-x64-1_68\
        -llibboost_test_exec_monitor-vc141-mt-x64-1_68\
        -llibboost_thread-vc141-mt-x64-1_68\
        -llibboost_timer-vc141-mt-x64-1_68\
        -llibboost_type_erasure-vc141-mt-x64-1_68\
        -llibboost_unit_test_framework-vc141-mt-x64-1_68\
        -llibboost_wave-vc141-mt-x64-1_68\
        -llibboost_wserialization-vc141-mt-x64-1_68\
        -llibboost_zlib-vc141-mt-x64-1_68

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\FLANN\lib\
        -lflann\
        -lflann_cpp\
        -lflann_cpp_s\
        -lflann_s

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\OpenNI2\Lib\ -lOpenNI2

LIBS += -LD:\ProgramFiles\PCL\PCL1.9.1\3rdParty\Qhull\lib\
        -lqhull\
        -lqhullcpp\
        -lqhullstatic\
        -lqhullstatic_r\
        -lqhull_p\
        -lqhull_r

LIBS += -LD:\ProgramFiles\VTK\VTK811\install\release\lib\
        -lvtkalglib-8.1\
        -lvtkChartsCore-8.1\
        -lvtkCommonColor-8.1\
        -lvtkCommonComputationalGeometry-8.1\
        -lvtkCommonCore-8.1\
        -lvtkCommonDataModel-8.1\
        -lvtkCommonExecutionModel-8.1\
        -lvtkCommonMath-8.1\
        -lvtkCommonMisc-8.1\
        -lvtkCommonSystem-8.1\
        -lvtkCommonTransforms-8.1\
        -lvtkDICOMParser-8.1\
        -lvtkDomainsChemistry-8.1\
        -lvtkexoIIc-8.1\
        -lvtkexpat-8.1\
        -lvtkFiltersAMR-8.1\
        -lvtkFiltersCore-8.1\
        -lvtkFiltersExtraction-8.1\
        -lvtkFiltersFlowPaths-8.1\
        -lvtkFiltersGeneral-8.1\
        -lvtkFiltersGeneric-8.1\
        -lvtkFiltersGeometry-8.1\
        -lvtkFiltersHybrid-8.1\
        -lvtkFiltersHyperTree-8.1\
        -lvtkFiltersImaging-8.1\
        -lvtkFiltersModeling-8.1\
        -lvtkFiltersParallel-8.1\
        -lvtkFiltersParallelImaging-8.1\
        -lvtkFiltersPoints-8.1\
        -lvtkFiltersProgrammable-8.1\
        -lvtkFiltersSelection-8.1\
        -lvtkFiltersSMP-8.1\
        -lvtkFiltersSources-8.1\
        -lvtkFiltersStatistics-8.1\
        -lvtkFiltersTexture-8.1\
        -lvtkFiltersTopology-8.1\
        -lvtkFiltersVerdict-8.1\
        -lvtkfreetype-8.1\
        -lvtkGeovisCore-8.1\
        -lvtkgl2ps-8.1\
        -lvtkglew-8.1\
        -lvtkGUISupportQt-8.1\
        -lvtkGUISupportQtSQL-8.1\
        -lvtkhdf5-8.1\
        -lvtkhdf5_hl-8.1\
        -lvtkImagingColor-8.1\
        -lvtkImagingCore-8.1\
        -lvtkImagingFourier-8.1\
        -lvtkImagingGeneral-8.1\
        -lvtkImagingHybrid-8.1\
        -lvtkImagingMath-8.1\
        -lvtkImagingMorphological-8.1\
        -lvtkImagingSources-8.1\
        -lvtkImagingStatistics-8.1\
        -lvtkImagingStencil-8.1\
        -lvtkInfovisCore-8.1\
        -lvtkInfovisLayout-8.1\
        -lvtkInteractionImage-8.1\
        -lvtkInteractionStyle-8.1\
        -lvtkInteractionWidgets-8.1\
        -lvtkIOAMR-8.1\
        -lvtkIOCore-8.1\
        -lvtkIOEnSight-8.1\
        -lvtkIOExodus-8.1\
        -lvtkIOExport-8.1\
        -lvtkIOExportOpenGL2-8.1\
        -lvtkIOGeometry-8.1\
        -lvtkIOImage-8.1\
        -lvtkIOImport-8.1\
        -lvtkIOInfovis-8.1\
        -lvtkIOLegacy-8.1\
        -lvtkIOLSDyna-8.1\
        -lvtkIOMINC-8.1\
        -lvtkIOMovie-8.1\
        -lvtkIONetCDF-8.1\
        -lvtkIOParallel-8.1\
        -lvtkIOParallelXML-8.1\
        -lvtkIOPLY-8.1\
        -lvtkIOSQL-8.1\
        -lvtkIOTecplotTable-8.1\
        -lvtkIOVideo-8.1\
        -lvtkIOXML-8.1\
        -lvtkIOXMLParser-8.1\
        -lvtkjpeg-8.1\
        -lvtkjsoncpp-8.1\
        -lvtklibharu-8.1\
        -lvtklibxml2-8.1\
        -lvtklz4-8.1\
        -lvtkmetaio-8.1\
        -lvtkNetCDF-8.1\
        -lvtknetcdfcpp-8.1\
        -lvtkoggtheora-8.1\
        -lvtkParallelCore-8.1\
        -lvtkpng-8.1\
        -lvtkproj4-8.1\
        -lvtkRenderingAnnotation-8.1\
        -lvtkRenderingContext2D-8.1\
        -lvtkRenderingContextOpenGL2-8.1\
        -lvtkRenderingCore-8.1\
        -lvtkRenderingFreeType-8.1\
        -lvtkRenderingGL2PSOpenGL2-8.1\
        -lvtkRenderingImage-8.1\
        -lvtkRenderingLabel-8.1\
        -lvtkRenderingLOD-8.1\
        -lvtkRenderingOpenGL2-8.1\
        -lvtkRenderingQt-8.1\
        -lvtkRenderingVolume-8.1\
        -lvtkRenderingVolumeOpenGL2-8.1\
        -lvtksqlite-8.1\
        -lvtksys-8.1\
        -lvtktiff-8.1\
        -lvtkverdict-8.1\
        -lvtkViewsContext2D-8.1\
        -lvtkViewsCore-8.1\
        -lvtkViewsInfovis-8.1\
        -lvtkViewsQt-8.1\
        -lvtkzlib-8.1\

}

(3) Test code

#include "widget.h"
#include "ui_widget.h"

#include <QDebug>

#include <pcl/io/io.h>
#include <pcl/io/pcd_io.h>
#include <pcl/io/obj_io.h>
#include <pcl/PolygonMesh.h>
#include <pcl/point_cloud.h>
#include <pcl/io/vtk_lib_io.h>//loadPolygonFileOBJ所属头文件;
#include <pcl/visualization/pcl_visualizer.h>



Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    std::string fileName = "E:/wokspace/PROJECT/3D_visualization_platform/pcl_data/20210507111715441.pcd";
    //std::string fileName = "chahu.obj";
        pcl::PolygonMesh meshData;//读取原始数据

        pcl::io::loadPolygonFile(fileName,meshData);

        pcl::PointCloud<pcl::PointXYZ>::Ptr cloud;

        cloud.reset(new pcl::PointCloud<pcl::PointXYZ>);
        pcl::fromPCLPointCloud2(meshData.cloud, *cloud);//将obj数据转换为点云数据

        // 显示结果图
        boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer (new pcl::visualization::PCLVisualizer ("3D Viewer"));
        viewer->setBackgroundColor (0, 0, 0); //设置背景
        viewer->addCoordinateSystem (15.0); //设置坐标系
        viewer->initCameraParameters ();

        viewer->addPointCloud(cloud, "show");
        while (!viewer->wasStopped())
        {
            viewer->spinOnce (100);
            boost::this_thread::sleep (boost::posix_time::microseconds (100000));
        }

        qDebug()<<"shuchu jieshu";

}

Widget::~Widget()
{
    delete ui;
}

The debug program starts slowly. Please wait patiently. The point cloud image will eventually pop up.

8. Qt-VTK test

(1) pro configuration

The configuration is as shown in Seven (2)


(2) Code

head File

#ifndef WIDGET_H
#define WIDGET_H

#include <QWidget>



#include <QFileDialog>


//#include <vtkAutoInit.h>
//VTK_MODULE_INIT(vtkRenderingOpenGL2)
//VTK_MODULE_INIT(vtkInteractionStyle)

#include <pcl/point_cloud.h>
#include <pcl/point_types.h>
#include <pcl/visualization/pcl_visualizer.h>
#include <pcl/io/pcd_io.h>
#include <QVTKWidget.h>
#include <vtkRenderWindow.h>


QT_BEGIN_NAMESPACE
namespace Ui { class Widget; }
QT_END_NAMESPACE

class Widget : public QWidget
{
    Q_OBJECT

public:
    Widget(QWidget *parent = nullptr);
    ~Widget();

    void initialOPVtkWidget();

        QVTKWidget *mVTKWidget;
            boost::shared_ptr<pcl::visualization::PCLVisualizer> viewer;
        public slots:
            void showpoint();




private slots:
    void on_pushButton_clicked();

private:
    Ui::Widget *ui;

};
#endif // WIDGET_H

cpp

#include "widget.h"
#include "ui_widget.h"

#include <QDebug>


#include <vtkAutoInit.h>
#include <pcl/filters/radius_outlier_removal.h>
#include <pcl/filters/conditional_removal.h>
#include <pcl/io/pcd_io.h>
#include <QTimer>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QTimer>
#include <vtkOutputWindow.h>  //消除vtk警告窗口的

VTK_MODULE_INIT(vtkRenderingOpenGL2); //必须位opengl2
VTK_MODULE_INIT(vtkInteractionStyle);
pcl::PointCloud<pcl::PointXYZ>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZ>());

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    initialOPVtkWidget();



        mVTKWidget = new QVTKWidget(this);
        QVBoxLayout *layout = new QVBoxLayout(this);
        layout->addWidget(mVTKWidget);

        QSizePolicy sizePolicy1(QSizePolicy::Preferred, QSizePolicy::Preferred);
        sizePolicy1.setHorizontalStretch(0);
        sizePolicy1.setVerticalStretch(0);
        sizePolicy1.setHeightForWidth(mVTKWidget->sizePolicy().hasHeightForWidth());
        mVTKWidget->setSizePolicy(sizePolicy1);//设置vtk视图大小
        mVTKWidget->setMinimumSize(QSize(1200, 800));
        mVTKWidget->showFullScreen();

        viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));//初始化viewer
        mVTKWidget->SetRenderWindow(viewer->getRenderWindow());//关联鼠标事件
        viewer->setupInteractor(mVTKWidget->GetInteractor(), mVTKWidget->GetRenderWindow());//设置显示部件
        viewer->addPointCloud(cloud, "cloud");
        viewer->addCoordinateSystem(383);
        viewer->setPointCloudRenderingProperties(pcl::visualization::PCL_VISUALIZER_POINT_SIZE, 1.3, "cloud");
        pcl::PointXYZ p;
        for (int i = 0; i < 100; i++) {
            p.x = rand() % 100;
            p.y = rand() % 100;
            p.z = rand() % 100;
            cloud->push_back(p);
        }
        viewer->updatePointCloud<pcl::PointXYZ>(cloud, "cloud");
        mVTKWidget->update();

        QTimer *time = new QTimer(this);
        connect(time, SIGNAL(timeout()), this, SLOT(showpoint()));
        time->start(50);
}

Widget::~Widget()
{
    delete ui;
}


void Widget::initialOPVtkWidget()
{
    cloud.reset(new pcl::PointCloud<pcl::PointXYZ>);
    viewer.reset(new pcl::visualization::PCLVisualizer("viewer", false));
    viewer->addPointCloud(cloud, "cloud");
    //消除vtk警告输出窗口
    vtkOutputWindow::SetGlobalWarningDisplay(0);//对应头文件#include <vtkOutputWindow.h>
   

}


void Widget::on_pushButton_clicked()
{
    onOpen();
}

//原文链接:https://blog.csdn.net/qq_34512507/article/details/100991932
void Widget::showpoint()
{
    cloud->clear();
    pcl::PointXYZ p;
    for (int i = 0; i < 100; i++) {
        p.x = rand() % 100;
        p.y = rand() % 100;
        p.z = rand() % 100;
        cloud->push_back(p);
    }
    viewer->updatePointCloud<pcl::PointXYZ>(cloud, "cloud");
    mVTKWidget->update();
}

reference:

Configure vs2017+pcl1.9.1+vtk8.1+qt5.9+Dianyun environment configuration in 10 minutes_Dian sleep's blog-CSDN blog icon-default.png?t=N6B9https://blog.csdn.net/qq_34512507/article/details/100991932

(3) Eliminate vtk warning window

When running the program, in addition to the main window popping up, a warning window about VTK will also pop up. Add the following code to close the window.

#include <vtkOutputWindow.h>


//消除vtk警告输出窗口
vtkOutputWindow::SetGlobalWarningDisplay(0);//必须得添加头文件才行

 

(4) Problems that arise

1.widget.obj:-1: error: LNK2001: Unresolved external symbol "void __cdecl vtkRenderingOpenGL_AutoInit_Construct(void)" (?vtkRenderingOpenGL_AutoInit_Construct@@YAXXZ)

vtkRenderingOpenGL I checked the code and found that VTK_MODULE_INIT(vtkRenderingOpenGL) was added to the header file.

But my library is vtkRenderingOpenGL2,

Later changed to: VTK_MODULE_INIT(vtkRenderingOpenGL2)

2. Errors prompted in the summary information:

2023-08-03T16:24:32 Clang Code Model: Error: The clangbackend process has finished unexpectedly and was restarted.

reference:

Qt displays the VTK interactive window through QVTKWidget_FRED618's blog-CSDN blog https://blog.csdn.net/qq_37441588/article/details/118677431

Guess you like

Origin blog.csdn.net/u012719076/article/details/132061087