如何在ubuntu 11.10上使用cuda和opencv

时间:2013-05-17 01:33:49

标签: opencv ubuntu cuda ros orb

我想在ubuntu上运行surfgpu。但是不知道如何编写cmakelists。我已经安装了CUDA 4.2 SDK和Toolkit,程序内部的C可以运行。我的开发环境是Qt.ubuntu 11.10.opencv2。 4.2赞赏任何好的建议。

1 个答案:

答案 0 :(得分:1)

这个怎么样?

# CMakeLists.txt to build OpenCV project
cmake_minimum_required(VERSION 2.8)
project( testOpenCV )

查找OpenCV和CUDA包

find_package(OpenCV REQUIRED )
find_package(CUDA 4.2 REQUIRED)

包括某些目录

# Since surf is a non free package, you also have to add non free include dir
include_directories( ${OpenCV_INCLUDE_DIR} "${OpenCV_SOURCE_DIR}/modules/nonfree/include" ${CUDA_INCLUDE_DIRS})

编译来源

cuda_add_executable( exefile source.cpp source2.cpp )
target_link_libraries( exefile ${OpenCV_LIBS} ${otherlibsyouneed} )

以上所有内容仅在您使用-DHAVE_CUDA

编译OpenCV时才有效