Application:界面程序。内容比较简单,主要定义了界面的主框架,然后使用ParaView相关的功能进行初始化。
LVCore:核心功能及插件。包含LidarView的数据源,滤波器等插件代码。
整个程序是使用ParaView开发模式。显示界面只是个框架,主要功能结构是使用插件的形式实现的。
源代码目录树如下:
├─Application
│ ├─Icons
│ ├─SoftwareInformation
│ └─Ui
│ ├─python
│ │ └─lidarview
│ └─Widgets
│ └─images
├─CMake
├─LVCore
│ ├─CI
│ ├─CMake
│ │ └─scripts
│ ├─Documentation
│ ├─LidarCore
│ │ ├─Common
│ │ │ ├─Ceres
│ │ │ ├─Core
│ │ │ │ └─Testing
│ │ │ │ └─Cxx
│ │ │ ├─OpenCV
│ │ │ └─PCL
│ │ ├─Filters
│ │ │ ├─Calibration
│ │ │ │ └─Testing
│ │ │ │ └─Cxx
│ │ │ ├─Camera
│ │ │ ├─CameraOpenCV
│ │ │ │ └─Testing
│ │ │ │ └─Cxx
│ │ │ ├─Processing
│ │ │ │ └─Testing
│ │ │ │ └─Cxx
│ │ │ ├─ProcessingPCL
│ │ │ ├─Segmentation
│ │ │ ├─Selection
│ │ │ ├─Temporal
│ │ │ │ └─Testing
│ │ │ │ └─Cxx
│ │ │ └─Visualization
│ │ ├─IO
│ │ │ ├─CameraOpenCV
│ │ │ ├─Core
│ │ │ │ └─Testing
│ │ │ │ └─Cxx
│ │ │ ├─General
│ │ │ ├─Geolocation
│ │ │ │ └─Testing
│ │ │ │ └─Cxx
│ │ │ ├─Lidar
│ │ │ └─Network
│ │ ├─Sources
│ │ ├─Testing
│ │ │ └─Core
│ │ └─Utilities
│ │ ├─PCAPTools
│ │ └─UsedModules
│ ├─Plugins
│ │ ├─DatasetIOPlugin
│ │ │ └─KittiIO
│ │ └─LidarCorePlugin
│ │ ├─Filters
│ │ ├─IO
│ │ └─Sources
│ ├─Python
│ │ ├─lidarviewcore
│ │ │ └─DTMFilter
│ │ └─lidarviewpythonplugin
│ │ └─filters
│ ├─Qt
│ │ ├─ApplicationComponents
│ │ │ └─Resources
│ │ │ ├─Icons
│ │ │ └─UI
│ │ ├─Components
│ │ │ └─Resources
│ │ │ └─UI
│ │ └─Core
│ ├─Testing
│ │ ├─Data
│ │ │ ├─Baseline
│ │ │ ├─Camera
│ │ │ │ ├─BrownConrady
│ │ │ │ └─MatchedPoints_3D_2D
│ │ │ ├─Slam
│ │ │ └─trajectories
│ │ │ ├─la_doua_dataset
│ │ │ ├─mm03
│ │ │ ├─mm04
│ │ │ └─mm05_reoptimization
│ │ └─XML
│ └─Utilities
│ ├─Animation
│ │ ├─doc
│ │ ├─examples
│ │ └─lib
│ ├─Examples
│ │ ├─pipeline_setup_helpers
│ │ └─ProcessingSample
│ └─Scripts
├─LVSuperbuild
│ ├─cmake
│ ├─Documentation
│ ├─projects
│ │ ├─apple
│ │ │ └─files
│ │ ├─scripts
│ │ ├─unix
│ │ └─win32
│ ├─pvsb
│ │ ├─.gitlab
│ │ │ └─ci
│ │ │ └─docker
│ │ │ ├─centos7
│ │ │ └─fedora36
│ │ ├─cmake
│ │ │ └─sites
│ │ ├─Documentation
│ │ │ ├─dev
│ │ │ │ └─git
│ │ │ └─img
│ │ ├─launchers
│ │ ├─projects
│ │ │ ├─apple
│ │ │ │ ├─files
│ │ │ │ └─scripts
│ │ │ ├─apple-unix
│ │ │ │ └─patches
│ │ │ ├─files
│ │ │ ├─patches
│ │ │ ├─scripts
│ │ │ │ └─apple
│ │ │ ├─unix
│ │ │ │ └─patches
│ │ │ └─win32
│ │ │ ├─patches
│ │ │ └─scripts
│ │ ├─Scripts
│ │ │ ├─docker
│ │ │ │ ├─el6
│ │ │ │ └─ubuntu
│ │ │ │ ├─development
│ │ │ │ └─runtime
│ │ │ ├─index
│ │ │ ├─singularity
│ │ │ └─sites
│ │ │ └─modulefiles
│ │ │ └─dod_hpc
│ │ │ └─catalyst
│ │ ├─superbuild
│ │ │ ├─.gitlab
│ │ │ │ └─ci
│ │ │ │ └─docker
│ │ │ │ └─fedora36
│ │ │ ├─cmake
│ │ │ │ ├─patches
│ │ │ │ │ └─ExternalProject
│ │ │ │ └─scripts
│ │ │ ├─projects
│ │ │ │ ├─apple
│ │ │ │ ├─apple-unix
│ │ │ │ │ ├─patches
│ │ │ │ │ └─scripts
│ │ │ │ ├─patches
│ │ │ │ ├─scripts
│ │ │ │ ├─unix
│ │ │ │ │ └─patches
│ │ │ │ └─win32
│ │ │ │ ├─patches
│ │ │ │ └─scripts
│ │ │ ├─selftest
│ │ │ │ └─tests
│ │ │ │ ├─mpi-check
│ │ │ │ ├─sqlite-check
│ │ │ │ └─tbb-check
│ │ │ ├─standalone-boost
│ │ │ └─standalone-qt
│ │ ├─tests
│ │ │ ├─baselines
│ │ │ ├─data
│ │ │ ├─python
│ │ │ └─xml
│ │ └─Utilities
│ │ ├─build-mesa
│ │ ├─GitSetup
│ │ └─Scripts
│ └─tests
│ ├─baselines
│ ├─data
│ ├─python
│ └─xml
└─Plugins
├─HesaiPlugin
│ ├─CalibrationFiles
│ ├─HesaiPacketInterpreters
│ ├─HesaiSDK
│ │ └─sources
│ └─Utilities
└─VelodynePlugin
├─CalibrationFiles
├─Filters
├─Testing
│ └─Data
│ ├─HDL-128
│ │ └─GroundTruth
│ ├─HDL-64_Dual
│ │ └─GroundTruth
│ ├─HDL-64_Dual-autocalib
│ │ └─GroundTruth
│ ├─HDL-64_Single
│ │ └─GroundTruth
│ ├─HDL-64_Single-autocalib
│ │ └─GroundTruth
│ ├─VLP-16_Dual
│ │ └─GroundTruth
│ ├─VLP-16_Single
│ │ └─GroundTruth
│ ├─VLP-32c_Dual
│ │ └─GroundTruth
│ └─VLP-32c_Single
│ └─GroundTruth
├─Utilities
├─VelodynePacketInterpreters
└─VelodynePositionPacketInterpreters
顶层的CMakeLists.txt文件比较简单,调用了一些写好的模块,然后添加子文件Application以及LVCore。
cmake_minimum_required(VERSION 3.20.3 FATAL_ERROR)
project(LidarView)
# Add path to get all the needed modules used to config Lidarview
# lidarview_cmake_dir=E:/repo_lv/lidarview/src/CMake
set(lidarview_cmake_dir "${CMAKE_CURRENT_SOURCE_DIR}/CMake")
set(lvcore_cmake_dir "${CMAKE_CURRENT_SOURCE_DIR}/LVCore/CMake")
if (NOT IS_DIRECTORY "${lvcore_cmake_dir}")
message(FATAL_ERROR
"Failed to find the LVCore CMake directory. Did you forget to initialize the "
"submodule? (git submodule update --init --recursive)")
endif ()
list(APPEND CMAKE_MODULE_PATH
"${lidarview_cmake_dir}"
"${lvcore_cmake_dir}")
include(SetBranding) # 设置软件名称,供应商以及图标等信息
include(LidarViewSupportMacros) # 定义了两个函数,用于处理已经废弃不用的旧变量
include(LidarViewOptions) # 调用了LidarViewSupportMacros中的函数,对velodyne和hesai相关的变量进行了说明
# 检查SOFTWARE_NAME是否定义
# CMAKE_CURRENT_SOURCE_DIR和CMAKE_CURRENT_BINARY_DIR,两个变量不能相等
# 构建目录和源码目录不能相等
# CMAKE_BUILD_TYPE 如果没有定义,则赋值为RelWithDebInfo
# include(ParaViewDeterminVersion)
# include(FindLidarViewDependencies)
# include(SetupOutputDirs)
include(SetupLidarviewProject)
# Add plugins to be searched by default in LVCore CMakeLists.txt
set(lidarview_default_plugins
VelodynePlugin
HesaiPlugin)
set(lidarview_plugin_directories
"${CMAKE_CURRENT_SOURCE_DIR}/Plugins")
add_subdirectory(LVCore)
add_subdirectory(Application)
LVCore对LidarView的功能模块进行了构建,包括输入输出,滤波器,界面相关的功能模块等等。
其CMakeLists.txt中首先使用paraview_plugin_find_plugins查找插件的paraview.plugin文件,然后使用paraview_plugin_scan进行扫描,生成可用插件列表(保存在变量lidarview_plugins中),接着使用vtk_module_find_modules查找vtk模块,其结果保存在变量lidarplugin_module_files中,然后使用vtk_module_scan对vtk模块的相关源码进行查找,使用vtk_module_build进行插件构建。最后使用paraview_plugin_build构建LidarView插件。
其CMakeLists.txt文件如下:
#--------------------------------------
# Set-up lvcore test & cmake variables
#--------------------------------------
set(lidarview_cmake_destination "${CMAKE_INSTALL_LIBDIR}/cmake/lidarview")
set(lidarview_test_data_directory_input "${CMAKE_CURRENT_SOURCE_DIR}/Testing/Data")
set(lidarview_test_data_directory_output "${lidarview_test_data_directory_input}")
set(lidarview_test_output_directory "${CMAKE_BINARY_DIR}/Testing/Temporary")
#--------------------------------------
# Scan LidarView plugins
#--------------------------------------
# Retrieve default plugin and plugin directories
# from LidarView based app if existing
list(APPEND lidarview_default_plugins
DatasetIOPlugin
LidarCorePlugin)
list(APPEND lidarview_plugin_directories
"${CMAKE_CURRENT_SOURCE_DIR}/Plugins/")
foreach (lidarview_default_plugin IN LISTS lidarview_default_plugins)
set("_paraview_plugin_default_${lidarview_default_plugin}" "ON")
endforeach ()
# 查找插件文件的paraview.plugin文件
paraview_plugin_find_plugins(lidarview_plugin_files ${lidarview_plugin_directories})
# 扫描上插件,将可用插件保存在lidarview_plugins中
paraview_plugin_scan(
PLUGIN_FILES
${lidarview_plugin_files}
PROVIDES_PLUGINS lidarview_plugins # 可用插件列表
REQUIRES_MODULES lidarview_plugin_required_modules)
#--------------------------------------
# Scan and find vtk modules
#--------------------------------------
list(APPEND lidarview_source_directories
"${CMAKE_CURRENT_SOURCE_DIR}/LidarCore"
"${CMAKE_CURRENT_SOURCE_DIR}/Qt"
)
vtk_module_find_modules(lidarplugin_module_files ${lidarview_source_directories})
vtk_module_scan(
MODULE_FILES ${lidarplugin_module_files}
REQUEST_MODULES ${lidarview_plugin_required_modules}
${lidarview_client_required_modules}
PROVIDES_MODULES lidarview_modules
REQUIRES_MODULES lidarview_required_modules
UNRECOGNIZED_MODULES lidarview_unrecognized_modules
WANT_BY_DEFAULT "${LIDARVIEW_BUILD_ALL_MODULES}"
ENABLE_TESTS "${BUILD_TESTING}")
set(lidarview_unrecognized_lidarview_modules)
foreach (lidarview_module IN LISTS lidarview_unrecognized_modules)
if (lidarview_module MATCHES "LidarView::")
list(APPEND lidarview_unrecognized_lidarview_modules
"${lidarview_module}")
endif ()
endforeach ()
if (lidarview_unrecognized_lidarview_modules)
list(REMOVE_ITEM lidarview_unrecognized_lidarview_modules ${lidarview_rejected_modules})
endif ()
if (lidarview_unrecognized_lidarview_modules)
message(FATAL_ERROR
"The following modules were requested or required, but not found: "
"${lidarview_unrecognized_lidarview_modules}.")
endif ()
#--------------------------------------
# Build LidarView vtk modules
#--------------------------------------
vtk_module_build(
MODULES ${lidarview_modules}
INSTALL_EXPORT LidarView
INSTALL_HEADERS "${LIDARVIEW_INSTALL_DEVELOPMENT_FILES}"
HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/lidarview"
CMAKE_DESTINATION "${lidarview_cmake_destination}"
LICENSE_DESTINATION "${CMAKE_INSTALL_LICENSEDIR}"
VERSION "${LV_VERSION}"
SOVERSION "1"
ENABLE_WRAPPING ON
TEST_INPUT_DATA_DIRECTORY "${lidarview_test_data_directory_input}"
TEST_OUTPUT_DATA_DIRECTORY "${lidarview_test_data_directory_output}"
TEST_OUTPUT_DIRECTORY "${lidarview_test_output_directory}")
#--------------------------------------
# Build LidarView plugins
#--------------------------------------
foreach (module IN LISTS lidarview_plugin_required_modules)
if (NOT TARGET "${module}")
message(FATAL_ERROR "Missing required module: ${module}")
endif ()
endforeach ()
set(autoload_plugins)
foreach (lidarview_plugin IN LISTS lidarview_plugins)
option("PARAVIEW_PLUGIN_AUTOLOAD_${lidarview_plugin}" "Autoload the ${lidarview_plugin} plugin" ON)
mark_as_advanced("PARAVIEW_PLUGIN_AUTOLOAD_${lidarview_plugin}")
if (PARAVIEW_PLUGIN_AUTOLOAD_${lidarview_plugin})
list(APPEND autoload_plugins
"${lidarview_plugin}")
endif ()
endforeach ()
paraview_plugin_build(
HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/lidarview"
RUNTIME_DESTINATION "${CMAKE_INSTALL_BINDIR}"
LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY_SUBDIRECTORY "lidarview/plugins"
CMAKE_DESTINATION "${lidarview_cmake_destination}"
PLUGINS_FILE_NAME "lidarview.plugins.xml"
TARGET LidarView::lidarview_plugins
INSTALL_EXPORT LidarViewPlugins
INSTALL_HEADERS "${LIDARVIEW_INSTALL_DEVELOPMENT_FILES}"
TARGET_COMPONENT "development"
PLUGINS_COMPONENT "plugins"
PLUGINS ${lidarview_plugins}
AUTOLOAD ${autoload_plugins})
#-----------------------------------------------------------------------------
# Python wrapping
# Simply use "import lidarview.modules" and you have acces to the wrapped c++ code
# DO NOT FOR ANY REASON USE the method GetClientSideObject() to have acces to the vtkObject directly.
#-----------------------------------------------------------------------------
vtk_module_wrap_python(
MODULES ${lidarview_modules}
INSTALL_EXPORT LidarViewPython
INSTALL_HEADERS "${LIDARVIEW_INSTALL_DEVELOPMENT_FILES}"
CMAKE_DESTINATION "${lidarview_cmake_destination}"
LIBRARY_DESTINATION "${CMAKE_INSTALL_LIBDIR}"
HEADERS_DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/lidarview/lvpythonmodules"
PYTHON_PACKAGE "lidarview.modules"
MODULE_DESTINATION "${LIDARVIEW_PYTHON_SITE_PACKAGES_SUFFIX}"
TARGET LidarView::lvpythonmodules
DEPENDS VTK::vtkpythonmodules
)
add_subdirectory(Python)
#--------------------------------------
# Build non-plugin/modules LidarView source code
# (This should be progressively removed)
#--------------------------------------
# Add subdirectory containing python script for animation
add_subdirectory(Utilities/Animation)
# Add sudbirectory containing python helper functions for pipeline scripting
add_subdirectory(Utilities/Examples)
#--------------------------------------
# Build Python & UI XML Testing
#--------------------------------------
if (BUILD_TESTING)
add_subdirectory(Testing)
endif ()
applicatoin中是LidarView主界面的框架。其中的Ui文件夹中定义了一些其他的界面元素。主界面程序中会使用一些LVCore中的代码,因此先编译的是LVCore。其CMakeLists.txt如下:
# Sanitize checks
if(NOT SOFTWARE_NAME OR NOT SOFTWARE_VENDOR)
message(FATAL_ERROR "SOFTWARE_NAME or SOFTWARE_VENDOR branding not set")
endif()
if(NOT LV_VERSION_FULL)
message(FATAL_ERROR "LV_VERSION_ variables not set")
endif()
add_subdirectory(Ui)
# Qt编译选项
set(CMAKE_AUTOMOC ON) # 将Qt功能转换成标准C++代码,如信号槽的转换
set(CMAKE_AUTORCC ON) # Qt资源文件处理
set(CMAKE_AUTOUIC ON) # Qt界面文件处理
# 添加源代码,其中Qt相关的会自动处理,因此统一作为源代码
set(source_files
vvMainWindow.h
vvMainWindow.ui
vvResources.qrc
vvMainWindow.cxx
vvMainWindow.h
)
# Please make sure to adapt the AboutDialog text in the followin file
# Lidar\python\lidarview\aboutDialog.py
# You also need to change:
# - bottom_logo.png (bottom logo)
set(plugins_targets
ParaView::paraview_plugins
LidarView::lidarview_plugins
)
if (PARAVIEW_PLUGIN_ENABLE_LidarSlam)
list(APPEND plugins_targets LidarSlam::paraview_wrapping)
endif ()
# paraview客户端
paraview_client_add(
NAME LidarView # 应用程序的名称,同时也是cmake目标变量
NAMESPACE "LidarView" # 为该程序提供了LidarView::LidarView的别名目标变量
EXPORT "LidarViewClient" # 导出目标
VERSION ${LV_VERSION_FULL} # 版本号
APPLICATION_NAME "LidarView" # 应用程序显示的名称,
ORGANIZATION "${SOFTWARE_VENDOR}"
TITLE "${SOFTWARE_NAME} ${LV_VERSION_FULL} ${LV_BUILD_PLATFORM}" # 窗口上显示的标题
SPLASH_IMAGE "${CMAKE_CURRENT_SOURCE_DIR}/SoftwareInformation/Splash.jpg" # 打开程序时先会显示该图片
BUNDLE_ICON "${CMAKE_CURRENT_SOURCE_DIR}/logo.icns" # 图标,MaxOS
APPLICATION_ICON "${CMAKE_CURRENT_SOURCE_DIR}/SoftwareInformation/logo.ico" # 图标
PLUGINS_TARGETS ${plugins_targets} # 插件的目标变量,启动时会调用这些插件的关联函数
REQUIRED_PLUGINS PythonQtPlugin LidarCorePlugin # 启动时加载的插件
MAIN_WINDOW_CLASS vvMainWindow # 主窗口类的名称
MAIN_WINDOW_INCLUDE vvMainWindow.h # 主窗口类的头文件
SOURCES ${source_files} # 源文件
APPLICATION_XMLS # 服务管理器配置文件
${CMAKE_CURRENT_SOURCE_DIR}/lqSources.xml
${CMAKE_CURRENT_SOURCE_DIR}/lqFilters.xml
RUNTIME_DESTINATION ${CMAKE_INSTALL_BINDIR} # 二进制文件存放目录
LIBRARY_DESTINATION ${CMAKE_INSTALL_LIBDIR} # 库文件存放目录
)
target_include_directories(${SOFTWARE_NAME} # SOFTWARE_NAME = LidarView
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
target_link_libraries(${SOFTWARE_NAME}
PRIVATE
LidarView::lqApplicationComponents # Common LVCore code base
ApplicationUi
)
# Bundle Icon on Apple
if(APPLE)
get_target_property(MACOSX_BUNDLE_ICON_FILE ${SOFTWARE_NAME} MACOSX_BUNDLE_ICON_FILE)
install(FILES ${MACOSX_BUNDLE_ICON_FILE} DESTINATION "${LV_INSTALL_RESOURCE_DIR}") # to install tree
endif()
其中paraview_clinet_add是关键代码,确定了paraview应用程序构建的相关信息,其参数如下:
paraview_client_add(
NAME
VERSION
SOURCES