Intro Android Mobile Development: Open Source Computer Vision Library
The following information, and code example was obtained from the following from http://opencv.org/. If you are not familiar with OpenCV and want to learn more, please visit the link. All steps were made using MAC OS 10.7.4
OpenCV (Open Source Computer Vision Library) is an open source computer vision, and machine learning software library. OpenCV was built to provide a common infrastructure for computer vision applications and to accelerate the use of machine perception in the commercial products.
The library has more than 2500 optimized algorithms, which includes a comprehensive set of both classic and state-of-the-art computer vision, and machine learning algorithms. These algorithms can be used to detect and recognize faces, identify objects, classify human actions in videos, track camera movements, track moving objects, extract 3D models of objects, produce 3D point clouds from stereo cameras, stitch images together to produce a high resolution image of an entire scene, find similar images from an image database, remove red eyes from images taken using flash, follow eye movements, recognize scenery and establish markers to overlay it with augmented reality, etc. The library is used extensively in companies, research groups, and by governmental research projects.
Well-established companies like Google, Yahoo, Microsoft, Intel, IBM, Sony, Honda, Toyota use the library. There are many startups such as Applied Minds, VideoSurf, and Zeitera, that make extensive use of OpenCV. OpenCV’s deployed uses span the range from stitching streetview images together, detecting intrusions in surveillance video in Israel, monitoring mine equipment in China, helping robots navigate and pick up objects at Willow Garage, detection of swimming pool drowning accidents in Europe, running interactive art in Spain and New York, checking runways for debris in Turkey, inspecting labels on products in factories around the world on to rapid face detection in Japan.
It has C++, C, Python and Java interfaces and supports Windows, Linux, Android, and Mac OS. OpenCV leans mostly towards real-time vision. OpenCV is written natively in C++ . OpenCV runs on both desktop (Windows, Linux, Android, MacOS) ,and mobile (Android, Maemo, iOS).
Let's Start With a Example for Android Mobile Apps
To start working with one example about face detection using OpenCV in Android you must already have installed, and configured Android Developer Tools, and the Android NDK.
1) Download OpenCV for Android 2.4.6
2) Unzip, and import the OpenCV Library, and the OpenCV Sample – face-detection
3) Go to the OpenCV Sample –face-detection properties project, and go to the android section, and check if you have the OpenCV Library added.
4) Go to C/C++ Build section, and check the ndk-build path
5) Go to the Java Build Path section, and then Libraries tab. If you open the Android Dependencies, and you did not find the opencv library – 2.4.6.jar you will need to add the library manually on the add external jars button.
6) Go to the ADT menu, and then select Preferences, Android, NDK to select the path of the NDK location.
7) Open the terminal, and type the following line of code to open the bash profile, and verify you have the following paths in your bash profile.
9) Download to your device OpenCV Manager from Google play
8) Run OpenCV Sample – face-detection from the ADT and enjoy.
I have learned how to use the OpenCV Library with Android. It’s a good library to implement other functionalities like detect colors, shapes, to do manipulations of images, etc. What I noticed running the OpenCV Sample – face-detection is that the application is not working a 100%, but the majority of cases the application does detect faces.
The picture above is the OpenCV Sample – face-detection application running. On the right is our CEO, Anurag Kumar!
About the Author
Francisco Antonio Duran is a computer science engineer. He is currently studying a master degree about Internet Technologies, and an Informatics Security specialization in the Universidad Autónoma de Guadalajara. He works as mobile developer, and mobile instructor in iTexico.