In this tutorial, you will learn about the file structure of OpenCV SDK for Android. The information here is very short and lacks details. My purpose here is to provide just enough information to get going with the rest of the tutorials. I highly recommend reading more about the folders, algorithms, libraries and classes on your own.
So you have downloaded SDK but you may be curious what the SDK files do. Lets see to that now. You can skip this tutorial if you are interested in going directly to the development.
When you extract the “OpenCV-3.0.0-android-sdk-1.zip” from the precious tutorial, you will get a folder /OpenCV-android-sdk/.
Inside the /OpenCV-android-sdk/ folder, you will see:
Lets look at these in detail.
|/apk/||This folder contains OpenCV manager API for different android device architectures. Chose the .apk file which is supported by your android device. Or simply download one from Google Play Store because that way, you will be downloading the apk file that is supported by your device/|
|/samples/||This folder contains sample android apps that you can install into your android device to test features of OpenCV. Also note that the source code of each sample is included in the /samples/ folder. It is a good place to start.|
|/sdk/||THE BRAINS OF OpenCV is here. I will explain about this folder below.|
|LICENSE||Well, it can’t be said more precisely than what is written there as “By downloading, copying, installing or using the software you agree to this license.If you do not agree to this license, do not download, install,
copy or use the software.”
|README.android||Contains a link to online documentation, resources and feedback. Quiet handy!
Now that the root file structure of OpenCV is out of the way, we can now take a look at the SDK folder contents to give you the idea of what exactly what it and its contents do.
The /sdk/ folder contains the OpenCV API and libraries that will be used in your android project. You need these to perform all the functionalities that OpenCV offers in order to help you perform your Computer Vision related job.
Inside the SDK folder, in my case, there are three folders:
Lets look at the contents of SDK folder here:
|1||/sdk/etc/||This folder contains the “memory” of OpenCV. Memory being like the brain-memory :D. See, as the time passed, the geniuses who made OpenCV for us to feast upon collected data and fine-tuned it for algorithms to use. That data is kept here.
For example, face detection requires some data which is compared with the picture snapped by your x-megapixel camera. That data is kept inside this folder.
|2||/sdk/etc/haarcascades||HAAR or HAAR-like-features is a folder where you put post-OpenCV-training data.
In this folder, you can find data files which contain data generated by training OpenCV in order to detect face, eyes, nose etc detection.
You too can create such data files if you wish to detect something such as legs, airplane, cracks on wall (edge detection), pacman, ****, *******, *******888*88* detection 😛
Lets say you wish to train OpenCV to detect face of a “sick” person. So you take pictures of a (e.g.) 1000 sick people (positive images) and then resize those picture to a same small size that is easy to process in bulk :D. Now you will also need pictures of people who are NOT sick. Now, you will train OpenCV on that load of 1000 pictures plus the people who are not sick. This data is put in this folder to be used.
HAAR algorithm is very accurate but is slower as compared to LBP.
|3||/sdk/etc/lbpcascades||LBP stands for local binary pattern. This method is unique in a way that instead of using generated data to detect features (as was the case of HAAR), the LBP takes a pixel and finds the intensity of its neighbor pixels.
So lets say there is a pixel. Practically, each pixel has eight neighbor pixels, so our pixel also has eight surrounding pixels. Now, for each pixel, a binary value is obtained. The value of binary number depends on the comparison between the center pixel and its test-neighbor pixel.
If pixel intensity is greater than center pixel, then value is 1.
If pixel intensity is lesser than center pixel, then value is 0.
LBP algorithm is very fast, but least accurate.
|4||/java/||When creating a new Android project, you can import the OpenCV Java Api from this folder.|
|5||/java/.settings||Contains settings that are implemented when importing the OpenCV for android Java API.|
|6||/java/gen||Contains generated files. For example, R.java, when generated is put here.|
|7||/java/javadoc||This folder contains the documentation of OpenCV for Android. In my case, it is the documentation for the version 3.0.0
All the classes of OpenCV for Android are explained here. So if you ever find yourself in trouble, or wish to learn more, visit this folder.
|8||/java/res||Standard Android project folder that contains resources to be used in an android project. The resource file that came in my case contains camera information.|
|9||/java/src||The /etc/ folder was the memory of OpenCV. But this folder is the actual brain of OpenCV. This folder contains the classes that perform all the functionalities of OpenCV in Android. Classes are written in Java.
Root files are self explainatory. If not, then what on Earth are you doing on this post? You should learn Android and then come here.
|10||/java/src/org/opencv||Exactly this folder contains the classes. Core, mathematical operation algorithm, training and all the shit that OpenCV gets done for you, is actually here. Every improvement in OpenCV is included here. Please respect the contents of this folder if you use OpenCV.|
|11||/native/||This folder contains C++ .h (header) files and native libraries for multiple android architectures.|
This is it for this tutorial. I have explained to you the structure of the OpenCV for Android SDK file structure. In the next tutorial, I will explin to you about the classes available in OpenCV for Android SDK which you can use.