OpenCV provides a set of samples for Android developers. These samples show how OpenCV can be used from both Java and native C++ levels of Android. There are 2 groups of samples: samples for Java and C++ OpenCV API, and a group of sample applications. The first group is named as “Tutorial #” and considers important aspects for a beginner: using OpenCV in regular apps, working with a standard camera, mixing both Java and C++ calls to OpenCV in a single application. The sample application works with both Mavel Central AAR package and OpenCV for Android SDK.
Java and C++ API usage
The first group of samples illustrates how to use OpenCV Java API in your project. Follow the tutorial “Introduction into Android Development” to install all needed prerequisites, build the applications and understand their behavior.
- Tutorial 1 – Camera Preview – shows the simplest way Android application can use OpenCV, i.e. via OpenCV application helper classes. It displays full screen preview and shows OpenCV API to get camera frames for processing and rendering.
- Tutorial 2 – Mixed Processing – shows ways of pre-processing camera preview frames with filters implemented in Java and C++ calls to OpenCV.
Tutorial 3 – Camera Control – shows a way of basic manipulations with camera in an OpenCV based Android application. In particular it changes camera preview resolution, activates camera built-in effects, takes and saves a still picture.
Sample applications
There are also several sample applications written mostly in Java. They get a frame from camera, do some processing with OpenCV and visualize the frame on a device screen.
- Sample – image-manipulations – this example demonstrates how OpenCV can be used as an image processing and manipulation library. It supports several filters, demonstrates color space conversions and working with histograms. It doesn’t have special relation to computer vision, but OpenCV has powerful core and imgproc modules, which may be useful in a wide range of applications, especially in the field of Computational Photography.
- Sample – 15-puzzle – shows how a simple game can be implemented with just a few calls to OpenCV. It is available on Google Play.
- Sample – face-detection – is the simplest implementation of the face detection functionality on Android. The Sample uses FaceDetection API and DNN module.
- Sample – color-blob-detection – this sample shows a trivial implementation of color blob tracker. User points to some region, and algorithms tries to select the whole blob of a similar color. Work with touch interface and contours is demonstrated.
- Sample – mobilenet-objdetect – shows MobileNet SSD network usage on Android. The network may be replaced by your own with minor modifications.
- Sample – qr-detection – demonstrates two QR code detection and decoding pipelines implemented in OpenCV. The pipelines use classic computer vision.
Sample – video-recorder – is a simple video recording and playback application on top of OpenCV video i/o API. The sample features may vary on Android version and OpenCV build options.
This page was last updated February 28th, 2024.