Computer Science programming University

Building and using OpenCV with Eclipse on Mac OS X

This took me a little while to figure out due to the sometimes subtle differences in Mac OS X and Linux, and the imperfect documentation.  Eventually I got it working though. The goal was to build OpenCV for Mac OS X 10.9 and then get it working in Eclipse. So, here goes:

  1. Ensure you’re using a JDK with version number 1.7 or higher.  If not, see here for instructions.
  2. Download the latest version of OpenCV (I used 2.4.8, so if you have problems, try going back this) from here, for Mac.
  3. Extract it.
  4. cd into the extracted directory of OpenCV in your terminal and execute the following:
mkdir build
cd build
cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ -D CMAKE_C_COMPILER=/usr/bin/gcc -D WITH_CUDA=ON ..
make -j2

(Note in the above, -j2 refers to the number of CPU cores I had – e.g. set to -j4 if you have 4 logical cores).

Then just look in build/bin, and you’ll see a .jar at the bottom – congratulations, you just built OpenCV! Import this as a library into Eclipse, and set the native path also to build/bin, and you’re done.

If you get stuck, let me know in the comments and I’ll do my best to help.

Computer Science

Using Face Detection to Manipulate 3D Objects

New methods of Human Computer Interaction are always interesting.  I’ve had a passing interest in how movement of the Human face can be used to manipulate 3D objects in design applications for a few months now, and decided to dig up a old project.

In 2012 I saw a video of this been done, and wanted to replicate it as a project to work on with my Google Mentor.  Unfortunately, the use of some large libraries was a bit beyond the knowledge of Python I’d picked up my first 6 weeks of University, so the project got put on hold.  Luckily, I’ve had some spare time in the last week to re-start this project and get it working, this time in Java.

The basic idea here is that as you move your head, a 3D cube rotates and zooms to match your head movement, as if you were looking at a real 3D cube.

The code is open source, so take a look and feel free to play with it and adjust it.  I’ve had a few problems with including the relevant libraries and setting the paths for the natives, so you will need OpenCV installed natively (and hence may have to adjust the build path), but after that all should be fine.  I’m aware that the build path needs changing on Linux when you install OpenCV with apt-get, but couldn’t find out what this path should be – let me know if you do!

Update 9/4/14 – updated to include error detection (for outlaying locations where a face was detected) and error correction, if requested.