将 Cmake 与 PCL 和 OpenCV 结合使用
Use Cmake with PCL and OpenCV
我是计算机视觉的新手。在 Cmake 上,我正在尝试将 PCL 和 OpenCV 与 2D 激光雷达传感器结合使用。
我看到了这个教程:[http://unanancyowen.com/en/pcl18/#Download1
并在 CmakeLists.txt 上配置 PCL 使用以下代码:
cmake_minimum_required( VERSION 2.8 )
# Create Project
project( solution )
add_executable( project main.cpp )
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "project" )
# Find Packages
find_package( PCL 1.8 REQUIRED )
if( PCL_FOUND )
# Additional Include Directories
# [C/C++]>[General]>[Additional Include Directories]
include_directories( ${PCL_INCLUDE_DIRS} )
# Preprocessor Definitions
# [C/C++]>[Preprocessor]>[Preprocessor Definitions]
add_definitions( ${PCL_DEFINITIONS} )
#add_definitions( -DPCL_NO_PRECOMPILE )
# Additional Library Directories
# [Linker]>[General]>[Additional Library Directories]
link_directories( ${PCL_LIBRARY_DIRS} )
# Additional Dependencies
# [Linker]>[Input]>[Additional Dependencies]
target_link_libraries( project ${PCL_LIBRARIES} )
endif()
和configure CmakeLists.txt for OpenCV,下面的代码:
cmake_minimum_required( VERSION 3.6 )
# Create Project
project( solution )
add_executable( project main.cpp )
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "project" )
# Find OpenCV
set( OpenCV_DIR "C:/Program Files/opencv/build" )
find_package( OpenCV REQUIRED )
# Project Settings for OpenCV
if( OpenCV_FOUND )
# Additional Include Directories
# [C/C++]>[General]>[Additional Include Directories]
include_directories( ${OpenCV_INCLUDE_DIRS} )
# Additional Library Directories
# [Linker]>[General]>[Additional Library Directories]
link_directories( ${OpenCV_LIB_DIR} )
# Additional Dependencies
# [Linker]>[Input]>[Additional Dependencies]
target_link_libraries( project ${OpenCV_LIBS} )
endif()
如何使 CmakeLists.txt 与两者一起使用? PCL 和 OpenCV。
在网站上找到了我得到这些文件的答案:
http://unanancyowen.com/en/pcl18/#comment-1221
这是提取 OpenCV 和 PCL:
的代码
cmake_minimum_required( VERSION 2.8 )
# Create Project
project( solution )
add_executable( project main.cpp )
# Set StartUp Project (Option)
# (This setting is able to enable by using CMake 3.6.0 RC1 or later.)
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "project" )
# Find Packages
# Find PCL
find_package( PCL 1.8 REQUIRED )
# Find OpenCV
set( OpenCV_DIR "C:/Program Files/opencv/build" )
find_package( OpenCV REQUIRED )
if( PCL_FOUND AND OpenCV_FOUND )
# [C/C++]>[General]>[Additional Include Directories]
include_directories( ${PCL_INCLUDE_DIRS} )
include_directories( ${OpenCV_INCLUDE_DIRS} )
# [C/C++]>[Preprocessor]>[Preprocessor Definitions]
add_definitions( ${PCL_DEFINITIONS} )
# For Use Not PreCompiled Features
#add_definitions( -DPCL_NO_PRECOMPILE )
# [Linker]>[General]>[Additional Library Directories]
link_directories( ${PCL_LIBRARY_DIRS} )
link_directories( ${OpenCV_LIB_DIR} )
# [Linker]>[Input]>[Additional Dependencies]
target_link_libraries( project ${PCL_LIBRARIES} )
target_link_libraries( project ${OpenCV_LIBS} )
endif()
然后在这个 link there is an old explanation and here my question on the OpenCV here.
要在同一个项目中同时使用PCL和OpenCV,可以将CMakeLists.txt文件写成最小行如下:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(project_name)
find_package(PCL 1.4 REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${PCL_INCLUDE_DIRS} )
link_directories(${PCL_LIBRARY_DIRS} )
add_definitions(${PCL_DEFINITIONS} )
add_executable (project_executable main.cpp)
target_link_libraries (project_executable ${PCL_LIBRARIES} ${OpenCV_LIBS})
我是计算机视觉的新手。在 Cmake 上,我正在尝试将 PCL 和 OpenCV 与 2D 激光雷达传感器结合使用。
我看到了这个教程:[http://unanancyowen.com/en/pcl18/#Download1
并在 CmakeLists.txt 上配置 PCL 使用以下代码:
cmake_minimum_required( VERSION 2.8 )
# Create Project
project( solution )
add_executable( project main.cpp )
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "project" )
# Find Packages
find_package( PCL 1.8 REQUIRED )
if( PCL_FOUND )
# Additional Include Directories
# [C/C++]>[General]>[Additional Include Directories]
include_directories( ${PCL_INCLUDE_DIRS} )
# Preprocessor Definitions
# [C/C++]>[Preprocessor]>[Preprocessor Definitions]
add_definitions( ${PCL_DEFINITIONS} )
#add_definitions( -DPCL_NO_PRECOMPILE )
# Additional Library Directories
# [Linker]>[General]>[Additional Library Directories]
link_directories( ${PCL_LIBRARY_DIRS} )
# Additional Dependencies
# [Linker]>[Input]>[Additional Dependencies]
target_link_libraries( project ${PCL_LIBRARIES} )
endif()
和configure CmakeLists.txt for OpenCV,下面的代码:
cmake_minimum_required( VERSION 3.6 )
# Create Project
project( solution )
add_executable( project main.cpp )
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "project" )
# Find OpenCV
set( OpenCV_DIR "C:/Program Files/opencv/build" )
find_package( OpenCV REQUIRED )
# Project Settings for OpenCV
if( OpenCV_FOUND )
# Additional Include Directories
# [C/C++]>[General]>[Additional Include Directories]
include_directories( ${OpenCV_INCLUDE_DIRS} )
# Additional Library Directories
# [Linker]>[General]>[Additional Library Directories]
link_directories( ${OpenCV_LIB_DIR} )
# Additional Dependencies
# [Linker]>[Input]>[Additional Dependencies]
target_link_libraries( project ${OpenCV_LIBS} )
endif()
如何使 CmakeLists.txt 与两者一起使用? PCL 和 OpenCV。
在网站上找到了我得到这些文件的答案: http://unanancyowen.com/en/pcl18/#comment-1221
这是提取 OpenCV 和 PCL:
的代码cmake_minimum_required( VERSION 2.8 )
# Create Project
project( solution )
add_executable( project main.cpp )
# Set StartUp Project (Option)
# (This setting is able to enable by using CMake 3.6.0 RC1 or later.)
set_property( DIRECTORY PROPERTY VS_STARTUP_PROJECT "project" )
# Find Packages
# Find PCL
find_package( PCL 1.8 REQUIRED )
# Find OpenCV
set( OpenCV_DIR "C:/Program Files/opencv/build" )
find_package( OpenCV REQUIRED )
if( PCL_FOUND AND OpenCV_FOUND )
# [C/C++]>[General]>[Additional Include Directories]
include_directories( ${PCL_INCLUDE_DIRS} )
include_directories( ${OpenCV_INCLUDE_DIRS} )
# [C/C++]>[Preprocessor]>[Preprocessor Definitions]
add_definitions( ${PCL_DEFINITIONS} )
# For Use Not PreCompiled Features
#add_definitions( -DPCL_NO_PRECOMPILE )
# [Linker]>[General]>[Additional Library Directories]
link_directories( ${PCL_LIBRARY_DIRS} )
link_directories( ${OpenCV_LIB_DIR} )
# [Linker]>[Input]>[Additional Dependencies]
target_link_libraries( project ${PCL_LIBRARIES} )
target_link_libraries( project ${OpenCV_LIBS} )
endif()
然后在这个 link there is an old explanation and here my question on the OpenCV here.
要在同一个项目中同时使用PCL和OpenCV,可以将CMakeLists.txt文件写成最小行如下:
cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
project(project_name)
find_package(PCL 1.4 REQUIRED)
find_package(OpenCV REQUIRED)
include_directories(${PCL_INCLUDE_DIRS} )
link_directories(${PCL_LIBRARY_DIRS} )
add_definitions(${PCL_DEFINITIONS} )
add_executable (project_executable main.cpp)
target_link_libraries (project_executable ${PCL_LIBRARIES} ${OpenCV_LIBS})