"configure OpenCV using CMake with WITH_CUDA=ON"

Do we know if the pre-compiled binaries of openCV that ship with ofxOpenCV and 007 were compiled.


or not? There are several GPU functions that would be available out of the box if this were the case.


It is in there, but right now the ofxOpenCV is using the 1.x version of OpenCV, so it would be a little bit of work to get the 2.2 stuff going. That said though, it would be awesome to see it working, I’d totally encourage you to check it out if you have a CUDA compatible machine!

@joshuajnoble - are you sure the gpu cuda part is already backed into the lib provided with ofxOpenCV? … I just compiled the actual OpenCV svn head with CUDA support and the libopencv_gpu library alone is already over 30mb!

@NovySan - Are you using OSX or Windows? I think there is a windows version of opencv with baked cuda support available.

I really encourage to use Kyles ofxCv addon and the new OpenCv C++ interface. It’s so much better then this old shitty opencv 1.x C style shit - and you can even mix the new with the old if really needed!

I’m not positive, but I just did a string search through the .a and saw all the method names for the gpu module so I assumed it was in there.

don’t know for sure in osx, (although i think they are) but in windows and linux, the gpu libraries are there.

@m9dfukc did you compiled it for windows vs? the libraries there are way bigger than those compiled with gcc, it could also be that you have the debug symbols activated

I am indeed developing on Windows right now, in VS2010. Have any of you run across a short tutorial on getting it working? Even, say, just using the cv::gpu::GaussianBlur()?


no I compiled it under osx and in various combinations - with debug symbols the libopencv_gpu.a is about 50mb (with tbb enabled). But it could be that I did something wrong, because I had to additionally link the cuda libs in my xcode project - which seems illogical as I expected that these will be already statically linked into to opencv lib?!

@NovySans … just look into the actual (and by the way pretty solid) opencv documentation: http://opencv.itseez.com/modules/gpu/doc/gpu.html

Looking now. OF doesn’t seem to know what


is though.

Hey NovySan,

this method directly forwards to the method in the cuda libs … I first needed to link the cuda libs in my project before this started to work (which is quite strange … see my last post). … That sayed, if you get linker errors you definitely need to separately link the cuda libs.

By the way - this http://experienceopencv.blogspot.com/ is a nice resource for opencv related stuff. The last few blog entries dealing with cuda!

@m9dfukc thanks for the link - good stuff. I wish it were OpenCL instead so it would work with ATI also but that’s another thread/forum :confused:

Well, I can get it to recognize the cv::gpu:: namespace and even compile, but when I make a cv::gpu::GpuMat I get the following error:

“OpenCV Error: No GPU support (The library is compilled without GPU support)” so I’m guessing something WASN’T compiled with the flag on?

I get no errors or crashes with a simple


but it just reports “0”

I’ll keep poking away at it.

@NovySan Obvious question but are you sure your system is setup for CUDA? Up to date drivers, compatible hardware, etc? If that’s not it then there might be a problem with how the libs were compiled, which would be nice to get sorted out.

I’m going to update to the latest cuda drivers and toolkit release, compile oCV and see what I come up with.

Yup. everything is CUDA capable, latest drivers, etc, etc.

Let me know what you find. :slight_smile:

Check through the openCV.a I think it has the same problem that my original oCV build had: gpu files included but not actually working. I see these error message in the .a itself:

/Users/theo/Documents/CODE/__OPENFRAMEWORKS/gitOF/__BuildAllLibs/OpenCV-2.2.0/modules/gpu/src/precomp.hppThe library is compilled without GPU support%s:%d: error: (%d) %s in function %s  
%s:%d: error: (%d) %s  

It’s not included in a functional state. I got OpenCV2.3 compiled with GPU support, which involved getting the SDK (didn’t have that already). I had thought I was compiling it with GPU support, but I apparently wasn’t. Apparently CUDA 3.0 && 3.2 don’t work with oCV so you’ll need set 4.0 in the CMake file and check that the output from CMake says:

With Cuda: YES  

I’m not having much luck getting the static lib built with ar or libtool so I’m not sure what process was used to put it together. Seems like doing a GPU build would need to be very specific to where the CUDA libs are living on someone’s machine, so it might be better just have instructions for doing it than trying to include it in the static lib.

As a quick word of warning: if you do get the GPU support compiled in, running the opencv_test_gpu will probably completely freak out your machine for about 20min, so be patient :slight_smile:


yeah it took me several days to get opencv cuda support up and running - including several compile cycles of opencv. According to the opencv reference all functions throw an error if cv::gpu::getCudaEnabledDeviceCount() counts 0 cuda reday devices OR if cuda isn’t baked in.

As I already stated, I never got cuda linked “into” opencv as a static lib, I always need to link the cuda libraries separately into my “opencv’ed” project - through I’m working on osx and the “ready to install” cuda package doesn’t come with static libraries (just dynlib’s).

Yes, this is what I noticed too. Unless you’re willing to hack the Nvidia installers, you get dylibs. Just curious: did you compile the oCV libs into a single static lib & then linked ofxOpenCv to that? If so, was it 2.3 or 2.2?


I compiled opencv 2.3 into several static libs (libopencv_core.a, libopencv_ml.a …) ans linked them against ofxCv - I’m not using ofxOpenCv. As far as I know opencv 2.3 is fully backwards compatible to opencv 1.1 so its shouldn’t be a problem to use it with ofxOpenCv. Through what I’ve read is that soem of the oldscool c functions run a lot faster in in opencv 1.x then in opencv 2.x.

Looks like I’m going to have to abandon development in VS2010 because I’m on a 64bit machine, with 64bit drivers, so to get cv:gpu:: to work, I need 64 bit everything else (correct me if I’m wrong.) So I’ll be booting into Ubuntu and learning my way around CodeBlocks and the 64 bit version of OF. Does the 64bit Linux version use Gstreamer instead of Quicktime?


you can compile opencv for 32bits, try adding -m32 in the CFLAGS variable in the cmake config

but yes, the linux version uses gstreamer and theres a 64bits version, the problem you’ll have in linux is the default nvidia drivers doesn’t have cuda yet so you’ll have to install custom ones from nvidia which is usually quite messy