Ask Your Question

Creating a Visual Studio 2012 project including openCV and CUDA 7.0

asked 2015-05-15 08:47:29 -0500

LFDC89 gravatar image

Hi, I want to create a visual studio project with CUDA framework and openCV library (I need openCV to read an image and then I'd like to calculate an histograme image using parallel threads). Thre's a tutorial that can explain me how I can do this?

thanks to everybody!

edit retag flag offensive close merge delete


Build opencv with cuda and after use CMAKE to create your visual studio project. this CMakeLists.txt could be used

cmake_minimum_required(VERSION 2.8)

PROJECT (testvideo)
find_package(OpenCV  REQUIRED)
file(GLOB testvideo_SRCS
ADD_EXECUTABLE (testvideo ${testvideo_SRCS})
if (OpenCV_FOUND)
    include_directories( ${OpenCV_INCLUDE_DIRS} )
    target_link_libraries( testvideo ${OpenCV_LIBS} )
else (OpenCV_FOUND)
message("PB->OPENCV = ${OpenCV_INCLUDE_DIRS}")
endif (OpenCV_FOUND)
LBerger gravatar imageLBerger ( 2015-05-15 12:55:16 -0500 )edit

How can I build openCV with CUDA??

sorry for my incompetence.

LFDC89 gravatar imageLFDC89 ( 2015-05-20 04:50:42 -0500 )edit

If you use Cmake GUI check option WITH_CUDA and may be WITH_CUBLAS too

Command line something like that -D WITH_CUDA=ON -D WITH_CUBLAS=ON

LBerger gravatar imageLBerger ( 2015-05-20 06:22:04 -0500 )edit

We have a problem: we build OpenCV.sln but this isn't a CUDA project, so it doesn't find CUDA libraries. It's possible to create a Visual Studio 2012 CUDA project first, and then add OpenCV libraries?

LFDC89 gravatar imageLFDC89 ( 2015-05-20 09:42:42 -0500 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2015-05-20 09:53:58 -0500

I made CMakeLists.txt with CUDA.
Please use it as a reference.

edit flag offensive delete link more


I'm sorry but is the first time that I use Cmake, CUDA with openCV and so I haven't understand the utilization of Cmake. What's the first step I've to do???

LFDC89 gravatar imageLFDC89 ( 2015-05-20 10:11:45 -0500 )edit

I explain the procedure using cmake-gui.

  1. launch cmake-gui
  2. input the path of your souce code
  3. input the path for build(solution file is generated in this place)
  4. push Configure button
  5. select your compiler and architecture(win32 or x64)
  6. push Finish button
  7. edit the path of OpenCV_DIR
  8. push Configure button
  9. push Generate button

As a result, solution file is generated in the path for build.

dandelion1124 gravatar imagedandelion1124 ( 2015-05-20 10:30:48 -0500 )edit

Sorry, I misunderstood.
I made a batch file to build OpenCV(WITH_CUDA).
Please run this batch file in Visual Studio command prompt(VS2012).

dandelion1124 gravatar imagedandelion1124 ( 2015-05-20 10:37:43 -0500 )edit

Hi dandelion1124, I have the same problem so I used your procedure but after launch the .bat file my error output is: Access is denied. The system cannot find the path specified. "cmake.exe" is not recognized as an internal or external command....and...impossible to find the files: openCV.sln... Do you have any idea to solve this problem?

Thank you very much for your help :)

Marco1990 gravatar imageMarco1990 ( 2015-05-21 02:57:09 -0500 )edit

Do you set the location of the cmake.exe to the environment variable (PATH)?
Because, this setting is required to run the cmake on command prompt.

"cmake.exe" is not recognized as an internal or external command....and...impossible to find the files: openCV.sln...

Maybe, I think that cmake.exe was not found.
As a result, OpenCV.sln was not generated.

dandelion1124 gravatar imagedandelion1124 ( 2015-05-21 05:23:00 -0500 )edit

Your information is so interesting and useful. Thanks for posting.

addseo1118 gravatar imageaddseo1118 ( 2015-05-22 01:18:43 -0500 )edit

Why not use the VS13? I think there is more bugs in VS12.

Sheng Liu gravatar imageSheng Liu ( 2015-05-22 04:25:05 -0500 )edit

Previous version CUDA does not support VS2013.
From this background, my batch file specify VS2012.

But, the latest CUDA support VS2013. So, we can specify VS2013 now.
Does that answer your question?

dandelion1124 gravatar imagedandelion1124 ( 2015-05-22 05:56:23 -0500 )edit

Question Tools

1 follower


Asked: 2015-05-15 08:47:29 -0500

Seen: 513 times

Last updated: May 22 '15