mirror of https://github.com/opencv/opencv.git
Open Source Computer Vision Library
https://opencv.org/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
1.6 KiB
69 lines
1.6 KiB
#include "OpenCVEngine_jni.h" |
|
#include "EngineCommon.h" |
|
#include "IOpenCVEngine.h" |
|
#include "OpenCVEngine.h" |
|
#include "IPackageManager.h" |
|
#include "JavaBasedPackageManager.h" |
|
#include <utils/Log.h> |
|
#include <android_util_Binder.h> |
|
|
|
#undef LOG_TAG |
|
#define LOG_TAG "OpenCVEngine/JNI" |
|
|
|
using namespace android; |
|
|
|
sp<IBinder> OpenCVEngineBinder = NULL; |
|
IPackageManager* PackageManager = NULL; |
|
|
|
JNIEXPORT jobject JNICALL Java_org_opencv_engine_BinderConnector_Connect(JNIEnv* env, jobject) |
|
{ |
|
LOGI("Creating new component"); |
|
if (NULL != OpenCVEngineBinder.get()) |
|
{ |
|
LOGI("New component created successfully"); |
|
} |
|
else |
|
{ |
|
LOGE("OpenCV Engine component was not created!"); |
|
} |
|
|
|
return javaObjectForIBinder(env, OpenCVEngineBinder); |
|
} |
|
|
|
JNIEXPORT jboolean JNICALL Java_org_opencv_engine_BinderConnector_Init(JNIEnv* env, jobject , jobject market) |
|
{ |
|
LOGD("Java_org_opencv_engine_BinderConnector_Init"); |
|
|
|
if (NULL == PackageManager) |
|
{ |
|
JavaVM* jvm; |
|
env->GetJavaVM(&jvm); |
|
PackageManager = new JavaBasedPackageManager(jvm, env->NewGlobalRef(market)); |
|
} |
|
if (PackageManager) |
|
{ |
|
if (!OpenCVEngineBinder.get()) |
|
{ |
|
OpenCVEngineBinder = new OpenCVEngine(PackageManager); |
|
return (NULL != OpenCVEngineBinder.get()); |
|
} |
|
else |
|
{ |
|
return true; |
|
} |
|
} |
|
else |
|
{ |
|
return false; |
|
} |
|
} |
|
|
|
JNIEXPORT void JNICALL Java_org_opencv_engine_BinderConnector_Final(JNIEnv *, jobject) |
|
{ |
|
LOGD("Java_org_opencv_engine_BinderConnector_Final"); |
|
|
|
OpenCVEngineBinder = NULL; |
|
|
|
delete PackageManager; |
|
PackageManager = NULL; |
|
}
|
|
|