将Cmake与PCL和OpenCV一起使用 [英] Use Cmake with PCL and OpenCV

查看:237
本文介绍了将Cmake与PCL和OpenCV一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Computer Vision的新手.在Cmake上,我试图将PCL和OpenCV与2D激光雷达传感器配合使用.

I am new to Computer Vision. On Cmake, i am trying to use PCL and OpenCV with a 2D Lidar sensor.

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

要在CmakeLists.txt上配置PCL,请使用以下代码:

And to configure PCL on CmakeLists.txt the following code is used:

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()

为OpenCV配置CmakeLists.txt ,以下代码:

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.

How do i make a CmakeLists.txt to use with both? PCL and OpenCV.

推荐答案

在网站上找到答案,要求我得到这些文件: http://unanancyowen.com/en/pcl18/#comment-1221

Found the answer asking on the website that i got those files: http://unanancyowen.com/en/pcl18/#comment-1221

这是提取OpenCV和PCL的代码:

This is the code to pull OpenCV and 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()

在此链接上,有一个古老的解释这是我对OpenCV的问题,此处.

And on this link there is an old explanation and here my question on the OpenCV here.

这篇关于将Cmake与PCL和OpenCV一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆