Showing posts with label Visual Studio 2010. Show all posts
Showing posts with label Visual Studio 2010. Show all posts

Wednesday, January 8, 2014

Building OpenCV 2.4.8 with CUDA and running GPU methods in Java using JNI

Though OpenCV comes with Java bindings since version 2.4.4, there are still some modules that don't have Java bindings - the most obvious one being the gpu module.

The OpenCV distribution for Windows is not built with CUDA so the gpu module doesn't work out of the box. So the first step is to build the OpenCV binaries with CUDA. As there are no Java bindings for the gpu module, a Java application wanting to use gpu methods will need to use JNI (Java Native Interface) to talk to the OpenCV gpu DLL. This is described in a complete example at the end of this post.

Building and Running OpenCV 2.4.8 with Java on Windows 7

OpenCV comes with Java bindings since version 2.4.4.

The OpenCV 2.4.8 distribution for Windows contains pre-compiled jar and dll files for the Java module so there is actually no need to build this module from source. These files are located in opencv/build/java/. All you need to do is import opencv-248.jar into your Java application and point to appropriate (32 or 64 bit) dll using System.load(). If you just want to know how to run an OpenCV application in Java then you can skip the build sections of this post.

But if you are interested in building the Java module then read on from the next section below.