Friday, December 27, 2013

OSX Mavericks 10.9 + OpenCV 2.4.7 + Eclipse Juno WITHOUT CUDA

Note to self, note to self, note to self

Setting up

1) Download OpenCV2.4.7
2) Extract the file
3) mkdir build inside the directory (where you extract openCV2.4.7 to)
4) cd build

cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -D CMAKE_C_COMPILER=/usr/bin/gcc -D CMAKE_CXX_FLAGS:STRING='-stdlib=libc++ -std=gnu++11' -D BUILD_PERF_TESTS=OFF -D BUILD_opencv_legacy=NO -D CMAKE_OSX_ARCHITECTURES=x86_64 -D WITH_CUDA=OFF  ..

6) make -j4
7) in Eclipse Juno, create a user library, Eclipse > Preferences > Java > Build Path > User Libraries > New > [Type OpenCV2.4.7] > Add External JARS
8) a) for jar file, browse to opencv-247.jar (usually in build/bin/opencv-247.jar)
8) b) also for native library location, browse to the lib directory (usually in build/lib)

Testing the linkage (in Eclipse Juno)

1) Create a new project
2) Link to OpenCV2.4.7 library by

Right Click your project > Properties > Add Library > User Library > Select OpenCV2.4.7

3) Create a class file with a main function > and duplicate the following codes
//opencvimport org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
public class Tester {
* @param args
public static void main(String[] args) {
// TODO Auto-generated method stub
Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
System.out.println("mat= "+mat.dump());

4) Look at the *beaut* in the console now.

Unfortunately, i am still figuring out to make this work with CUDA.  Until then .. until then..

No comments:

Post a Comment