longzhixi
longzhixi

Reputation: 31

how to use cuda with opencv on ubuntu 11.10

I would like to run surfgpu on ubuntu .But do not know how to write cmakelists.I have installed the CUDA 4.2 SDK and Toolkit, and C inside the program can run.My development environment is Qt.ubuntu 11.10.opencv2.4.2 any good suggestions are appreciated.

Upvotes: 3

Views: 372

Answers (1)

ardiyu07
ardiyu07

Reputation: 1800

How about this?

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

Find OpenCV and CUDA package

find_package(OpenCV REQUIRED )
find_package(CUDA 4.2 REQUIRED)

Include from some directories

# 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})

Compile source

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

All of the above only work if you compiled OpenCV with -DHAVE_CUDA

Upvotes: 1

Related Questions