Android + OpenCV = ♥ ♥ ♥

Finally getting our feet wet running OpenCV on an Android device…

Good news!!! The OpenCV people have a framework that simplifies writing, compiling and running OpenCV 2.4 apps for Android devices. You no longer have to download OpenCV source and (cross-)compile it like it’s 2010.

Instead, this is what we did:

1. Installed Android SDK, NDK, and Eclipse environments and plug-ins.

There are lots of steps here, but also lots of resources online. The official Android SDK installation guide, the Android NDK installation guide, and the OpenCV intro to Android setup guide.

We wanted to try out the new Android Studio IDE, but as it doesn’t support NDK development yet, decided to stick with Eclipse, and used the Manual environment setup section of the OpenCV guide.

2. Installed OpenCV SDK

Downloaded the OpenCV 2.4 for Android library and examples from sourceforge, and followed the steps in this OpenCV setup guide.

3. Installed OpenCV Manager app from the play store

The OpenCV Manager is an app that will check for OpenCV dynamic libs already installed on a phone, and download new libraries when needed. More info is available on this OpenCV page.

4. RTFM (or in this case, a short guide)

This is a pretty good tutorial for getting a project started: it shows how to initialize OpenCV and get frames from the camera.

After this, we tested the face detection example on some still images and on ourselves:

Money! Even in the dark! On an old phone with Android 2.3.4!