文档介绍:Android Development with OpenCV
This tutorial has been created to help you use OpenCV library within your Android pable, . emulator, developer board, etc, you can install it manually using adb tool. See How to select the proper version of OpenCV Managefror details.
There is a very base code snippet implementing the async initialization. It shows basic principles. See the “15-puzzle” OpenCV sample for details.
1 public class Sample1Java extends Activity implements 2 CvCameraViewListener {
3
4 private BaseLoaderCallback mLoaderCallback = new 5 BaseLoaderCallback(this) {
***@Override
public void onManagerConnected(int status) {
switch (status) {
9
case :
10
{
11
(TAG, “OpenCV loaded successfully“);
12
();
13
} break;
14
default:
15
{
16
(status);
17
} break;
18
}
19
}
20
};
21
***@Override
public void onResume() 24 {
();
(, 27 this, mLoaderCallback);
28 }
...
}
It this case application works with OpenCV Manager in asynchronous fashion. OnManagerConnected callback will be called in UI thread, when initialization finishes. Please note, that it is not allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback. Load your own native libraries that depend on OpenCV after the successful OpenCV initialization. Default BaseLoaderCallback implementation treat application context as Activity and calls () method to exit in case of initialization failure. To override this behavior you need to override finish() method of BaseLoaderCallback class and implement your own finalization method.
Application Development with Static Initialization
According to this approach all OpenCV binaries are included into your application package. It is designed