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.
89 lines
2.1 KiB
89 lines
2.1 KiB
12 years ago
|
#include "OpenCVLibraryInfo.h"
|
||
12 years ago
|
#include "EngineCommon.h"
|
||
|
#include <utils/Log.h>
|
||
|
#include <dlfcn.h>
|
||
12 years ago
|
|
||
|
JNIEXPORT jlong JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_open
|
||
12 years ago
|
(JNIEnv * env, jobject, jstring str)
|
||
12 years ago
|
{
|
||
12 years ago
|
const char* infoLibPath = env->GetStringUTFChars(str, NULL);
|
||
|
if (infoLibPath == NULL)
|
||
|
return 0;
|
||
|
|
||
|
LOGD("Trying to load info library \"%s\"", infoLibPath);
|
||
|
|
||
|
void* handle;
|
||
|
|
||
|
handle = dlopen(infoLibPath, RTLD_LAZY);
|
||
|
if (handle == NULL)
|
||
|
LOGI("Info library not found by path \"%s\"", infoLibPath);
|
||
|
|
||
|
return (jlong)handle;
|
||
12 years ago
|
}
|
||
|
|
||
|
JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getPackageName
|
||
12 years ago
|
(JNIEnv* env, jobject, jlong handle)
|
||
12 years ago
|
{
|
||
12 years ago
|
InfoFunctionType info_func;
|
||
12 years ago
|
const char* result;
|
||
|
const char* error;
|
||
|
|
||
|
dlerror();
|
||
12 years ago
|
info_func = (InfoFunctionType)dlsym((void*)handle, "GetPackageName");
|
||
12 years ago
|
if ((error = dlerror()) == NULL)
|
||
|
result = (*info_func)();
|
||
|
else
|
||
|
{
|
||
|
LOGE("dlsym error: \"%s\"", error);
|
||
|
result = "unknown";
|
||
|
}
|
||
|
|
||
|
return env->NewStringUTF(result);
|
||
12 years ago
|
}
|
||
|
|
||
|
JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getLibraryList
|
||
12 years ago
|
(JNIEnv* env, jobject, jlong handle)
|
||
12 years ago
|
{
|
||
12 years ago
|
InfoFunctionType info_func;
|
||
12 years ago
|
const char* result;
|
||
|
const char* error;
|
||
|
|
||
|
dlerror();
|
||
12 years ago
|
info_func = (InfoFunctionType)dlsym((void*)handle, "GetLibraryList");
|
||
12 years ago
|
if ((error = dlerror()) == NULL)
|
||
|
result = (*info_func)();
|
||
|
else
|
||
|
{
|
||
|
LOGE("dlsym error: \"%s\"", error);
|
||
|
result = "unknown";
|
||
|
}
|
||
|
|
||
|
return env->NewStringUTF(result);
|
||
12 years ago
|
}
|
||
|
|
||
|
JNIEXPORT jstring JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_getVersionName
|
||
12 years ago
|
(JNIEnv* env, jobject, jlong handle)
|
||
12 years ago
|
{
|
||
12 years ago
|
InfoFunctionType info_func;
|
||
12 years ago
|
const char* result;
|
||
|
const char* error;
|
||
|
|
||
|
dlerror();
|
||
12 years ago
|
info_func = (InfoFunctionType)dlsym((void*)handle, "GetRevision");
|
||
12 years ago
|
if ((error = dlerror()) == NULL)
|
||
|
result = (*info_func)();
|
||
|
else
|
||
|
{
|
||
|
LOGE("dlsym error: \"%s\"", error);
|
||
|
result = "unknown";
|
||
|
}
|
||
|
|
||
|
return env->NewStringUTF(result);
|
||
12 years ago
|
}
|
||
|
|
||
|
JNIEXPORT void JNICALL Java_org_opencv_engine_OpenCVLibraryInfo_close
|
||
12 years ago
|
(JNIEnv*, jobject, jlong handle)
|
||
12 years ago
|
{
|
||
12 years ago
|
dlclose((void*)handle);
|
||
12 years ago
|
}
|