android: allow to build & run examples without Android OpenCV Manager
This commit is contained in:
parent
3f485d58bb
commit
15b6fd2ec4
@ -216,6 +216,7 @@ OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too no
|
|||||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||||
OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 )
|
OCV_OPTION(ENABLE_WINRT_MODE "Build with Windows Runtime support" OFF IF WIN32 )
|
||||||
OCV_OPTION(ENABLE_WINRT_MODE_NATIVE "Build with Windows Runtime native C++ support" OFF IF WIN32 )
|
OCV_OPTION(ENABLE_WINRT_MODE_NATIVE "Build with Windows Runtime native C++ support" OFF IF WIN32 )
|
||||||
|
OCV_OPTION(ANDROID_EXAMPLES_WITH_LIBS "Build binaries of Android examples with native libraries" OFF IF ANDROID )
|
||||||
|
|
||||||
|
|
||||||
# ----------------------------------------------------------------------------
|
# ----------------------------------------------------------------------------
|
||||||
|
@ -335,6 +335,16 @@ macro(add_android_project target path)
|
|||||||
add_dependencies(${target} ${android_proj_native_deps})
|
add_dependencies(${target} ${android_proj_native_deps})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ANDROID_EXAMPLES_WITH_LIBS)
|
||||||
|
add_custom_target(
|
||||||
|
${target}_copy_libs
|
||||||
|
COMMAND ${CMAKE_COMMAND} -DSRC_DIR=${OpenCV_BINARY_DIR}/lib -DDST_DIR=${android_proj_bin_dir}/libs -P ${OpenCV_SOURCE_DIR}/cmake/copyAndroidLibs.cmake
|
||||||
|
WORKING_DIRECTORY ${OpenCV_BINARY_DIR}/lib
|
||||||
|
DEPENDS "${OpenCV_BINARY_DIR}/bin/classes.jar.dephelper" opencv_java
|
||||||
|
)
|
||||||
|
add_dependencies(${target} ${target}_copy_libs)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(__android_project_chain)
|
if(__android_project_chain)
|
||||||
add_dependencies(${target} ${__android_project_chain})
|
add_dependencies(${target} ${__android_project_chain})
|
||||||
endif()
|
endif()
|
||||||
|
8
cmake/copyAndroidLibs.cmake
Normal file
8
cmake/copyAndroidLibs.cmake
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# helper file for Android samples build
|
||||||
|
|
||||||
|
file(GLOB_RECURSE LIBS RELATIVE ${SRC_DIR} "*.so")
|
||||||
|
|
||||||
|
foreach(l ${LIBS})
|
||||||
|
message(STATUS " Copying: ${l} ...")
|
||||||
|
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SRC_DIR}/${l} ${DST_DIR}/${l})
|
||||||
|
endforeach()
|
@ -76,7 +76,13 @@ public class Puzzle15Activity extends Activity implements CvCameraViewListener,
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
@ -92,7 +92,13 @@ public class CameraCalibrationActivity extends Activity implements CvCameraViewL
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
@ -88,7 +88,13 @@ public class ColorBlobDetectionActivity extends Activity implements OnTouchListe
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
@ -139,7 +139,13 @@ public class FdActivity extends Activity implements CvCameraViewListener2 {
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
@ -111,7 +111,13 @@ public class ImageManipulationsActivity extends Activity implements CvCameraView
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
@ -39,6 +39,12 @@ public class CvNativeActivity extends Activity {
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -76,7 +76,13 @@ public class Tutorial1Activity extends Activity implements CvCameraViewListener2
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
@ -97,7 +97,13 @@ public class Tutorial2Activity extends Activity implements CvCameraViewListener2
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
@ -88,7 +88,13 @@ public class Tutorial3Activity extends Activity implements CvCameraViewListener2
|
|||||||
public void onResume()
|
public void onResume()
|
||||||
{
|
{
|
||||||
super.onResume();
|
super.onResume();
|
||||||
|
if (!OpenCVLoader.initDebug()) {
|
||||||
|
Log.d(TAG, "Internal OpenCV library not found. Using OpenCV Manager for initialization");
|
||||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||||
|
} else {
|
||||||
|
Log.d(TAG, "OpenCV library found inside package. Using it!");
|
||||||
|
mLoaderCallback.onManagerConnected(LoaderCallbackInterface.SUCCESS);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user