merged the trunk r8704:8716
[profile/ivi/opencv.git] / modules / java / src / cpp / jni_part.cpp
1 #include <jni.h>
2
3 #include "opencv2/opencv_modules.hpp"
4
5 #ifdef HAVE_OPENCV_NONFREE
6 #  include "opencv2/nonfree/nonfree.hpp"
7 #endif
8
9 #ifdef HAVE_OPENCV_FEATURES2D
10 #  include "opencv2/features2d/features2d.hpp"
11 #endif
12
13 #ifdef HAVE_OPENCV_VIDEO
14 #  include "opencv2/video/video.hpp"
15 #endif
16
17 #ifdef HAVE_OPENCV_ML
18 #  include "opencv2/ml/ml.hpp"
19 #endif
20
21 extern "C" {
22
23 JNIEXPORT jint JNICALL
24 JNI_OnLoad(JavaVM* vm, void* )
25 {
26     JNIEnv* env;
27     if (vm->GetEnv((void**) &env, JNI_VERSION_1_6) != JNI_OK)
28         return -1;
29
30     bool init = true;
31 #ifdef HAVE_OPENCV_NONFREE
32     init &= cv::initModule_nonfree();
33 #endif
34 #ifdef HAVE_OPENCV_FEATURES2D
35     init &= cv::initModule_features2d();
36 #endif
37 #ifdef HAVE_OPENCV_VIDEO
38     init &= cv::initModule_video();
39 #endif
40 #ifdef HAVE_OPENCV_ML
41     init &= cv::initModule_ml();
42 #endif
43
44     if(!init)
45         return -1;
46
47     /* get class with (*env)->FindClass */
48     /* register methods with (*env)->RegisterNatives */
49
50     return JNI_VERSION_1_6;
51 }
52
53 JNIEXPORT void JNICALL
54 JNI_OnUnload(JavaVM*, void*)
55 {
56   //do nothing
57 }
58
59 } // extern "C"