Commit 4d17051f authored by Alexander Alekhin's avatar Alexander Alekhin

android: backport Android SDK build script

parent 9285dddb
......@@ -274,6 +274,17 @@ macro(add_android_project target path)
file(GLOB_RECURSE android_proj_jni_files "${path}/jni/*.c" "${path}/jni/*.h" "${path}/jni/*.cpp" "${path}/jni/*.hpp")
ocv_list_filterout(android_proj_jni_files "\\\\.svn")
foreach(lib "opencv_java")
get_property(f TARGET ${lib} PROPERTY LOCATION)
get_filename_component(f_name ${f} NAME)
add_custom_command(
OUTPUT "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f_name}"
COMMAND ${CMAKE_COMMAND} -E copy "${f}" "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f_name}"
DEPENDS "${lib}" VERBATIM
COMMENT "Embedding ${f}")
list(APPEND android_proj_file_deps "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f_name}")
endforeach()
if(android_proj_jni_files AND EXISTS ${path}/jni/Android.mk AND NOT DEFINED JNI_LIB_NAME)
# find local module name in Android.mk file to build native lib
file(STRINGS "${path}/jni/Android.mk" JNI_LIB_NAME REGEX "LOCAL_MODULE[ ]*:=[ ]*.*" )
......@@ -307,6 +318,7 @@ macro(add_android_project target path)
# copy opencv_java, tbb if it is shared and dynamicuda if present if FORCE_EMBED_OPENCV flag is set
if(android_proj_FORCE_EMBED_OPENCV)
set(native_deps ${android_proj_NATIVE_DEPS})
list(REMOVE_ITEM native_deps "opencv_java")
# filter out gpu module as it is always static library on Android
list(REMOVE_ITEM native_deps "opencv_gpu")
if(ENABLE_DYNAMIC_CUDA)
......
......@@ -110,6 +110,10 @@ else
OPENCV_INSTALL_MODULES:=on
endif
ifeq ($(OPENCV_INSTALL_MODULES),)
OPENCV_INSTALL_MODULES:=on
endif
define add_opencv_module
include $(CLEAR_VARS)
LOCAL_MODULE:=opencv_$1
......
package org.opencv.android;
import android.content.Context;
import android.util.Log;
/**
* Helper class provides common initialization methods for OpenCV library.
*/
public class OpenCVLoader
{
private static final String TAG = "OpenCVLoader";
/**
* OpenCV Library version 2.4.2.
*/
......@@ -62,6 +65,11 @@ public class OpenCVLoader
*/
public static final String OPENCV_VERSION_2_4_12 = "2.4.12";
/**
* OpenCV Library version 2.4.13.
*/
public static final String OPENCV_VERSION_2_4_13 = "2.4.13";
/**
* Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
* @return Returns true is initialization of OpenCV was successful.
......@@ -91,6 +99,11 @@ public class OpenCVLoader
public static boolean initAsync(String Version, Context AppContext,
LoaderCallbackInterface Callback)
{
if (initDebug()) {
Callback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
return true;
}
Log.w(TAG, "OpenCV binaries are not packaged with application. Trying to use OpenCV Manager...");
return AsyncServiceHelper.initOpenCV(Version, AppContext, Callback);
}
}
This diff is collapsed.
......@@ -2,5 +2,3 @@ if(BUILD_ANDROID_SERVICE)
add_subdirectory(engine)
#add_subdirectory(engine_test)
endif()
install(FILES "readme.txt" DESTINATION "apk/" COMPONENT libs)
......@@ -79,3 +79,11 @@ OpenCV version constants
.. data:: OPENCV_VERSION_2_4_11
OpenCV Library version 2.4.11
.. data:: OPENCV_VERSION_2_4_12
OpenCV Library version 2.4.12
.. data:: OPENCV_VERSION_2_4_13
OpenCV Library version 2.4.13
How to select the proper version of OpenCV Manager
--------------------------------------------------
DEPRECATED: This information is outdated since OpenCV 2.4.12
Since version 1.7 several packages of OpenCV Manager are built. Every package is targeted for some
specific hardware platform and includes corresponding OpenCV binaries. So, in most cases OpenCV
Manager uses built-in version of OpenCV. Separate package with OpenCV binaries is currently used in
......
......@@ -3,7 +3,6 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
#OPENCV_CAMERA_MODULES:=off
#OPENCV_INSTALL_MODULES:=off
#OPENCV_LIB_TYPE:=SHARED
include ../../sdk/native/jni/OpenCV.mk
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment