opencv - 将Cmake与PCL和OpenCV一起使用

标签 opencv cmake point-cloud-library

我是计算机视觉的新手。在Cmake上,我试图将PCL和OpenCV与2D激光雷达传感器一起使用。

我看到了本教程:[http://unanancyowen.com/en/pcl18/#Download 1

并使用以下代码在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上有一个古老的解释,这是我对OpenCV here的问题。

关于opencv - 将Cmake与PCL和OpenCV一起使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43902133/

相关文章:

opencv - 在虹膜的opencv中使用霍夫圆函数查找分钟圆

python - OpenCV Python中的内存不足错误-(-215)u!= 0在函数cv::Mat::create中

python - 自动检测人脸并使用opencv拍摄快照

c++ - 使用 ncurses 和 cmake 链接期间 undefined reference

c++ - 如何在 CMake 中使用 VC++ 模块

c++ - Boost 编译点云库时出现的问题

python - 在图像中应用智能阈值的方法

c++ - 命名空间被视为类型

c++ - 链接和编译 pcl

c++ - 在 3D 坐标系中查找矩形中的角度点