Multiple improvements in OpenCV examples build.
EMBED_CUDA and FORCE_EMBED_OPENCV flags added to cmake macro add_android_project; INSTALL_CUDA_LIBRARIES option added to OpenCV.mk opencv_dynamicuda library installation with enabled OPENCV_INSTALL_MODULES flag fixed; CUDA initialization apportunity added to OpenCVLoader.initDebug(); Tutorial-4-CUDA sample reimplemented with static OpenCV and CUDA initialization.
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
set(sample example-tutorial-4-cuda)
|
||||
|
||||
ocv_check_dependencies(opencv_core opencv_java opencv_gpu)
|
||||
ocv_check_dependencies(opencv_core opencv_features2d opencv_java opencv_gpu)
|
||||
|
||||
if (OCV_DEPENDENCIES_FOUND)
|
||||
if(BUILD_FAT_JAVA_LIB)
|
||||
set(native_deps opencv_java opencv_gpu)
|
||||
else()
|
||||
set(native_deps opencv_gpu)
|
||||
set(native_deps opencv_core opencv_features2d opencv_java opencv_gpu)
|
||||
endif()
|
||||
|
||||
add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11 ${ANDROID_SDK_TARGET} NATIVE_DEPS ${native_deps})
|
||||
add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11 ${ANDROID_SDK_TARGET} NATIVE_DEPS ${native_deps} EMBED_CUDA ON FORCE_EMBED_OPENCV ON)
|
||||
|
||||
if(TARGET ${sample})
|
||||
add_dependencies(opencv_android_examples ${sample})
|
||||
endif()
|
||||
|
@@ -2,6 +2,8 @@ LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
INSTALL_CUDA_LIBRARIES:=on
|
||||
OPENCV_INSTALL_MODULES:=on
|
||||
CUDA_TOOLKIT_DIR=$(CUDA_TOOLKIT_ROOT)
|
||||
include ../../sdk/native/jni/OpenCV.mk
|
||||
|
||||
|
@@ -49,29 +49,6 @@ public class Tutorial4Activity extends Activity implements CvCameraViewListener2
|
||||
{
|
||||
Log.i(TAG, "OpenCV loaded successfully");
|
||||
|
||||
// Check CUDA support
|
||||
if (Gpu.getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
Log.e(TAG, "No CUDA capable device found!");
|
||||
AlertDialog InitFailedDialog = new AlertDialog.Builder(Tutorial4Activity.this).create();
|
||||
InitFailedDialog.setTitle("OpenCV CUDA error");
|
||||
InitFailedDialog.setMessage("CUDA compatible device was not found!");
|
||||
InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button
|
||||
InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Tutorial4Activity.this.finish();
|
||||
}
|
||||
});
|
||||
InitFailedDialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load native library after(!) OpenCV initialization
|
||||
Log.i(TAG, "Found CUDA capable device!");
|
||||
System.loadLibrary("cuda_sample");
|
||||
mOpenCvCameraView.enableView();
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
@@ -120,7 +97,32 @@ public class Tutorial4Activity extends Activity implements CvCameraViewListener2
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8, this, mLoaderCallback);
|
||||
if (OpenCVLoader.initDebug(true))
|
||||
{
|
||||
// Check CUDA support
|
||||
if (Gpu.getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
Log.e(TAG, "No CUDA capable device found!");
|
||||
AlertDialog InitFailedDialog = new AlertDialog.Builder(Tutorial4Activity.this).create();
|
||||
InitFailedDialog.setTitle("OpenCV CUDA error");
|
||||
InitFailedDialog.setMessage("CUDA compatible device was not found!");
|
||||
InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button
|
||||
InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Tutorial4Activity.this.finish();
|
||||
}
|
||||
});
|
||||
InitFailedDialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load native library after(!) OpenCV initialization
|
||||
Log.i(TAG, "Found CUDA capable device!");
|
||||
System.loadLibrary("cuda_sample");
|
||||
mOpenCvCameraView.enableView();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
|
Reference in New Issue
Block a user