[Part 4] 在Windows 10上源码编译PCL 1.8.1支持VTK和QT,可视化三维点云

本文首发于个人博客https://kezunlin.me/post/2d809f92/,欢迎阅读!

Part-4: Compile pcl with vtk qt5 support from source on windows.

Series

Guide

Tips

we'd better to use SSD to compile source code instead HDD. So put source code in C folder on windows.

use multiple processor to compile with /MP options.

prerequisit

software

  • vs: vs2015 installer
  • qt: http://mirrors.tuna.tsinghua.edu.cn/qt/archive/qt/5.7/5.7.1/qt-opensource-windows-x86-msvc2015_64-5.7.1.exe
  • qt vs tools: https://mirrors.tuna.tsinghua.edu.cn/qt/archive/vsaddin/qt-vs-tools-msvc2015-2.1.1.vsix
  • pcl installer: https://github.com/PointCloudLibrary/pcl/releases/download/pcl-1.8.1/PCL-1.8.1-AllInOne-msvc2015-win64.exe
  • vtk source: https://www.vtk.org/files/release/8.1/VTK-8.1.0.zip
  • vtk data: https://www.vtk.org/files/release/8.1/VTKData-8.1.0.zip
  • pcl source: https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.zip

download

    wget https://www.vtk.org/files/release/8.1/VTK-8.1.0.zip
    wget https://www.vtk.org/files/release/8.1/VTKData-8.1.0.zip
    wget https://github.com/PointCloudLibrary/pcl/archive/pcl-1.8.1.zip

version

    window: 10
    qt: 5.7.1
    qmake: 3.0 based on Qt 5.7.1
    qtcreator: 4.2.0 based on Qt 5.7.1
    qt-vs-tools: 2.2.1 
    cmake/gui: 3.10.0
    vtk: 8.1.0 (source)
    vtk data: 8.1.0
    pcl: 1.8.1 (source)
    $ qmake -v
    QMake version 3.0
    Using Qt version 5.7.1 in C:/Qt/Qt5.7.1/5.7/msvc2015_64/lib
    $ qtcreator -version
    Qt Creator 4.2.0 based on Qt 5.7.1
    $ cmake -version
    cmake version 3.10.0

install vs2015

skip.

configure vs2015 with admin

when we compile pcl by vs2015 and install to folder C:/Program Files/PCL , we need administrative priviledges.follow steps:

    cmd r 
    regeidt
    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
    # new string entry
    key: C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE\devenv.exe
    value: ~ RUNASADMIN

vs2015 regedit for runasadmin

install qt

install qt to path C:QtQt5.7.1

add the following to system path.

    C:\Qt\Qt5.7.1\5.7\msvc2015_64\bin
    C:\Qt\Qt5.7.1\Tools\QtCreator\bin

install qt-vs-tools

online install by vs2015

start vs2015, install Qt Visual Sutido Tools by:

    Tools---> Extensions and Update... ---> online search qt ---> install Qt Visual Sutido Tools ---> OK

restart vs2015 and new menu Qt VS Tools will be added to VS Main menu.

offline install by vsix

    wget https://mirrors.tuna.tsinghua.edu.cn/qt/archive/vsaddin/qt-vs-tools-msvc2015-2.1.1.vsix

double click qt-vs-tools-msvc2015-2.1.1.vsix and install.

configure qt for vs

follow steps

    Qt VS Tools ---> Qt Options ---> Add name and path

Add qt path for vs2015 so that we can find %PATH%binqmake.exe

    Name: Qt 5.7.1
    Path: C:\Qt\Qt5.7.1\5.7\msvc2015_64\

qt options

new qt project from vs

start vs2015, and new Qt Gui Application.

new qt gui application

Compile and run first qt program.Success.

install pcl third parties

install pcl by installer

install pcl to `C:Program FilesPCL 1.8.1`

choose to install OpenNI2 to `C:Program FilesPCL 1.8.13rdPartyOpenNI2`

this process will add 4 system env.

    PCL_ROOT          C:\Program Files\PCL 1.8.1
    OPENNI2_INCLUDE64 C:\Program Files\PCL 1.8.1\3rdParty\OpenNI2\Include\
    OPENNI2_LIB64     C:\Program Files\PCL 1.8.1\3rdParty\OpenNI2\Lib\ 
    OPENNI2_REDIST64  C:\Program Files\PCL 1.8.1\3rdParty\OpenNI2\Redist\

configure env

add env to Path.

    %PCL_ROOT\bin
    %PCL_ROOT%\3rdParty\FLANN\bin
    %PCL_ROOT%\3rdParty\OpenNI2\Redist
    %PCL_ROOT%\3rdParty\OpenNI2\Tools
    %PCL_ROOT%\3rdParty\Qhull\bin
    %PCL_ROOT%\3rdParty\VTK\bin

copy winpap package

copy winpap to `C:Program FilesPCL 1.8.13rdParty`, and 3rdParty folder looks like this:

    $ ls -al
    total 16
    drwxr-xr-x 1 zunli 197609 0 1月  11 12:47 ./
    drwxr-xr-x 1 zunli 197609 0 1月  11 08:03 ../
    drwxr-xr-x 1 zunli 197609 0 1月  11 08:02 Boost/
    drwxr-xr-x 1 zunli 197609 0 1月  11 08:01 Eigen/
    drwxr-xr-x 1 zunli 197609 0 1月  11 08:02 FLANN/
    drwxr-xr-x 1 zunli 197609 0 1月  11 08:04 OpenNI2/
    drwxr-xr-x 1 zunli 197609 0 1月  11 08:02 Qhull/
    drwxr-xr-x 1 zunli 197609 0 1月  11 08:03 VTK/
    drwxr-xr-x 1 zunli 197609 0 1月  11 12:47 winpcap/

compile vtk

download vtk and data

    wget https://www.vtk.org/files/release/8.1/VTK-8.1.0.zip
    wget https://www.vtk.org/files/release/8.1/VTKData-8.1.0.zip

configure source

we need to compile vtk to replace `C:Program FilesPCL 1.8.13rdPartyVTK`

    cd c:/compile/VTK-8.1.0
    mkdir build && cd build 
    cmake-gui ..

configure generator to Visual Studio 14 2015 Win64 with options

    VTK_Group_Qt  ON
    VTK_QT_VERSION     5  # by default 4
    VTK_RENDERING_BACKEND OpenGL2 # by default OpenGL
    Qt5_DIR  C:/Qt/Qt5.7.1/5.7/msvc2015_64/lib/cmake/Qt5
    CMAKE_INSTALL_PREFIX  C:/Program Files/VTK  # by default
    BUILD_SHARED_LIBS  ON
    CMAKE_CONFIGURATION_TYPES Release # Release
    CMAKE_CXX_FLAGS_RELEASE /MD /O2 /Ob2 /DNDEBUG /MP # for multiple processor

unzip VTKData-8.1.0.zip and copy MD5 to VTK-8.1.0/build/ExternalData/Objects/MD5

(1) With VTK = 8.1.0:

    VTK_Group_Qt  ON

configure again, and then QT_QMAKE_EXECUTABLE and VTK_QT_VERSION will appear.

(2) we need to change VTK_QT_VERSION from 4 to 5.

    VTK_QT_VERSION     5  # by default 4

(3) change VTK_RENDERING_BACKEND from OpenGL to OpenGL2.

    VTK_RENDERING_BACKEND OpenGL2 # by default OpenGL

(4) set install path `C:Program FilesVTK`

    CMAKE_INSTALL_PREFIX  C:/Program Files/VTK  

we need write privileges to install to `C:Program FilesVTK`

otherwise, when we install, error will occur:</

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值