diff --git a/samples/android/CMakeLists.txt b/samples/android/CMakeLists.txt index dbb539fc5..3913fd35b 100644 --- a/samples/android/CMakeLists.txt +++ b/samples/android/CMakeLists.txt @@ -14,6 +14,7 @@ add_subdirectory(color-blob-detection) add_subdirectory(tutorial-1-camerapreview) add_subdirectory(tutorial-2-mixedprocessing) add_subdirectory(tutorial-3-cameracontrol) +add_subdirectory(tutorial-4-opencl) # hello-android sample if(HAVE_opencv_highgui) diff --git a/samples/android/tutorial-4-opencl/CMakeLists.txt b/samples/android/tutorial-4-opencl/CMakeLists.txt index 2d529ffb7..96bacdeb4 100644 --- a/samples/android/tutorial-4-opencl/CMakeLists.txt +++ b/samples/android/tutorial-4-opencl/CMakeLists.txt @@ -1,4 +1,12 @@ set(sample example-tutorial-4-opencl) +if(NOT DEFINED ANDROID_OPENCL_SDK) + message(STATUS "Sample ${sample} is disabled, because ANDROID_OPENCL_SDK is not specified") + return() +endif() +if(ANDROID_NATIVE_API_LEVEL LESS 14) + message(STATUS "Sample ${sample} is disabled, because ANDROID_NATIVE_API_LEVEL < 14") + return() +endif() if(BUILD_FAT_JAVA_LIB) set(native_deps opencv_java) @@ -6,7 +14,13 @@ else() set(native_deps opencv_imgproc) endif() -add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 21 ${ANDROID_SDK_TARGET} NATIVE_DEPS ${native_deps}) +include_directories(${ANDROID_OPENCL_SDK}/include) +link_directories(${ANDROID_OPENCL_SDK}/lib/${ANDROID_ABI}) +add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" + LIBRARY_DEPS ${OpenCV_BINARY_DIR} + SDK_TARGET 21 ${ANDROID_SDK_TARGET} + NATIVE_DEPS ${native_deps} -lGLESv2 -lEGL -lOpenCL +) if(TARGET ${sample}) add_dependencies(opencv_android_examples ${sample}) endif() diff --git a/samples/android/tutorial-4-opencl/jni/Android.mk b/samples/android/tutorial-4-opencl/jni/Android.mk index 63b79935e..fa44bf8c5 100644 --- a/samples/android/tutorial-4-opencl/jni/Android.mk +++ b/samples/android/tutorial-4-opencl/jni/Android.mk @@ -13,6 +13,10 @@ else include ../../sdk/native/jni/OpenCV.mk endif +ifndef OPENCL_SDK + $(error Specify OPENCL_SDK to Android OpenCL SDK location) +endif + # add OpenCL LOCAL_C_INCLUDES += $(OPENCL_SDK)/include LOCAL_LDLIBS += -L$(OPENCL_SDK)/lib/$(TARGET_ARCH_ABI) -lOpenCL diff --git a/samples/android/tutorial-4-opencl/jni/CLprocessor.cpp b/samples/android/tutorial-4-opencl/jni/CLprocessor.cpp index 6d843acdd..dcad18e26 100644 --- a/samples/android/tutorial-4-opencl/jni/CLprocessor.cpp +++ b/samples/android/tutorial-4-opencl/jni/CLprocessor.cpp @@ -3,7 +3,8 @@ #include -#include +#include +#include #include #include "common.hpp" diff --git a/samples/android/tutorial-4-opencl/jni/GLrender.cpp b/samples/android/tutorial-4-opencl/jni/GLrender.cpp index 194fc4f91..05b796ff3 100644 --- a/samples/android/tutorial-4-opencl/jni/GLrender.cpp +++ b/samples/android/tutorial-4-opencl/jni/GLrender.cpp @@ -1,7 +1,8 @@ #include #include -#include +#include +#include #include "common.hpp"