From fc085d9dbd4b693f149cc14f1f28778f3788ec4b Mon Sep 17 00:00:00 2001 From: Alexander Smorkalov Date: Wed, 31 Oct 2012 20:35:37 +0400 Subject: [PATCH] info library for OpenCV added. --- CMakeLists.txt | 4 ++ android/libinfo/CMakeLists.txt | 39 +++++++++++++++++++ android/libinfo/info.c | 31 +++++++++++++++ .../jni/BinderComponent/OpenCVEngine.cpp | 2 +- 4 files changed, 75 insertions(+), 1 deletion(-) create mode 100644 android/libinfo/CMakeLists.txt create mode 100644 android/libinfo/info.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f42ef30f..b9a798d3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -467,6 +467,10 @@ if(BUILD_ANDROID_PACKAGE) add_subdirectory(android/package) endif() +if (ANDROID AND NOT BUILD_ANDROID_SERVICE AND NOT BUILD_ANDROID_PACKAGE AND NOT BUILD_CAMERA_WRAPER) + add_subdirectory(android/libinfo) +endif() + # ---------------------------------------------------------------------------- # Finalization: generate configuration-based files # ---------------------------------------------------------------------------- diff --git a/android/libinfo/CMakeLists.txt b/android/libinfo/CMakeLists.txt new file mode 100644 index 000000000..f8e8e15af --- /dev/null +++ b/android/libinfo/CMakeLists.txt @@ -0,0 +1,39 @@ +project(libopencv_info) +if(NOT ANDROID_PACKAGE_RELEASE) + set(ANDROID_PACKAGE_RELEASE 1) +endif() + +if(NOT ANDROID_PACKAGE_PLATFORM) + if(ARMEABI_V7A) + if(NEON) + set(ANDROID_PACKAGE_PLATFORM armv7a_neon) + else() + set(ANDROID_PACKAGE_PLATFORM armv7a) + endif() + elseif(ARMEABI_V6) + set(ANDROID_PACKAGE_PLATFORM armv6) + elseif(ARMEABI) + set(ANDROID_PACKAGE_PLATFORM armv5) + elseif(X86) + set(ANDROID_PACKAGE_PLATFORM x86) + elseif(MIPS) + set(ANDROID_PACKAGE_PLATFORM mips) + else() + message(ERROR "Can not automatically determine the value for ANDROID_PACKAGE_PLATFORM") + endif() +endif() + +add_definitions(-DANDROID_PACKAGE_RELEASE=${ANDROID_PACKAGE_RELEASE} -DANDROID_PACKAGE_PLATFORM="${ANDROID_PACKAGE_PLATFORM}") + +include_directories(jni/BinderComponent jni/include "${OpenCV_SOURCE_DIR}/modules/core/include") + +add_library(opencv_info SHARED info.c) + +set_target_properties(${the_module} PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH} + RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH} + INSTALL_NAME_DIR lib + ) + +get_filename_component(lib_name "opencv_info" NAME) +install(FILES "${LIBRARY_OUTPUT_PATH}/${lib_name}" DESTINATION ${OPENCV_LIB_INSTALL_PATH} COMPONENT main) \ No newline at end of file diff --git a/android/libinfo/info.c b/android/libinfo/info.c new file mode 100644 index 000000000..f1e5bf01e --- /dev/null +++ b/android/libinfo/info.c @@ -0,0 +1,31 @@ +#include "opencv2/core/version.hpp" +#include + +const char* GetPackageName(void); +const char* GetRevision(void); +const char* GetLibraryList(void); +JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv *, jclass); + +#define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" ANDROID_PACKAGE_PLATFORM +#define PACKAGE_REVISION CVAUX_STR(CV_SUBMINOR_VERSION) CVAUX_STR(ANDROID_PACKAGE_RELEASE) + +const char* GetPackageName(void) +{ + return PACKAGE_NAME; +} + +const char* GetRevision(void) +{ + return PACKAGE_REVISION; +} + +const char* GetLibraryList(void) +{ + return ""; +} + +JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv * env, jclass clazz) +{ + (void)clazz; + return (*env)->NewStringUTF(env, GetLibraryList()); +} diff --git a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp index 6b9979993..e08082004 100644 --- a/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp +++ b/android/service/engine/jni/BinderComponent/OpenCVEngine.cpp @@ -130,7 +130,7 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version) LOGD("Trying to load info library \"%s\"", tmp.c_str()); void* handle; - char* (*info_func)(); + const char* (*info_func)(); handle = dlopen(tmp.c_str(), RTLD_LAZY); if (handle)