Superres module enabled for Android. GPU samples build fixed for Android.
authorAlexander Smorkalov <alexander.smorkalov@itseez.com>
Wed, 5 Mar 2014 08:31:04 +0000 (12:31 +0400)
committerAlexander Smorkalov <alexander.smorkalov@itseez.com>
Tue, 18 Mar 2014 13:07:19 +0000 (17:07 +0400)
12 files changed:
cmake/OpenCVModule.cmake
modules/superres/CMakeLists.txt
modules/superres/src/btv_l1_gpu.cpp
modules/superres/src/frame_source.cpp
modules/superres/src/input_array_utility.cpp
modules/superres/src/optical_flow.cpp
modules/superres/src/precomp.hpp
modules/ts/CMakeLists.txt
samples/gpu/CMakeLists.txt
samples/gpu/brox_optical_flow.cpp
samples/gpu/opticalflow_nvidia_api.cpp
samples/gpu/super_resolution.cpp

index c9c3511..e11f5e6 100644 (file)
@@ -27,7 +27,8 @@
 # The verbose template for OpenCV module:
 #
 #   ocv_add_module(modname <dependencies>)
-#   ocv_glob_module_sources() or glob them manually and ocv_set_module_sources(...)
+#   ocv_glob_module_sources(([EXCLUDE_CUDA] <extra sources&headers>)
+#                          or glob them manually and ocv_set_module_sources(...)
 #   ocv_module_include_directories(<extra include directories>)
 #   ocv_create_module()
 #   <add extra link dependencies, compiler options, etc>
@@ -478,14 +479,20 @@ endmacro()
 
 # finds and sets headers and sources for the standard OpenCV module
 # Usage:
-# ocv_glob_module_sources(<extra sources&headers in the same format as used in ocv_set_module_sources>)
-macro(ocv_glob_module_sources EXCLUDE_CUDA EXCLUDE_OPENCL)
+# ocv_glob_module_sources([EXCLUDE_CUDA] <extra sources&headers in the same format as used in ocv_set_module_sources>)
+macro(ocv_glob_module_sources)
+  set(_argn ${ARGN})
+  list(FIND _argn "EXCLUDE_CUDA" exclude_cuda)
+  if(NOT exclude_cuda EQUAL -1)
+    list(REMOVE_AT _argn ${exclude_cuda})
+  endif()
+
   file(GLOB_RECURSE lib_srcs "src/*.cpp")
   file(GLOB_RECURSE lib_int_hdrs "src/*.hpp" "src/*.h")
   file(GLOB lib_hdrs "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h")
   file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h")
 
-  if (NOT ${EXCLUDE_CUDA})
+  if (exclude_cuda EQUAL -1)
     file(GLOB lib_cuda_srcs "src/cuda/*.cu")
     set(cuda_objs "")
     set(lib_cuda_hdrs "")
@@ -504,26 +511,22 @@ macro(ocv_glob_module_sources EXCLUDE_CUDA EXCLUDE_OPENCL)
 
   source_group("Src" FILES ${lib_srcs} ${lib_int_hdrs})
 
-  if (NOT ${EXCLUDE_OPENCL})
-    file(GLOB cl_kernels "src/opencl/*.cl")
-    if(HAVE_opencv_ocl AND cl_kernels)
-      ocv_include_directories(${OPENCL_INCLUDE_DIRS})
-      add_custom_command(
-        OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp"
-        COMMAND ${CMAKE_COMMAND} -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
-        DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake")
-      source_group("OpenCL" FILES ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
-      list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
-    endif()
+  file(GLOB cl_kernels "src/opencl/*.cl")
+  if(HAVE_opencv_ocl AND cl_kernels)
+    ocv_include_directories(${OPENCL_INCLUDE_DIRS})
+    add_custom_command(
+      OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp"
+      COMMAND ${CMAKE_COMMAND} -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake"
+      DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake")
+    source_group("OpenCL" FILES ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
+    list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp")
   endif()
 
   source_group("Include" FILES ${lib_hdrs})
   source_group("Include\\detail" FILES ${lib_hdrs_detail})
 
-  message(":${EXCLUDE_CUDA}: ${lib_cuda_srcs}")
-
-  ocv_set_module_sources(${ARGN} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
-                                 SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
+  ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail}
+                         SOURCES ${lib_srcs} ${lib_int_hdrs} ${cuda_objs} ${lib_cuda_srcs} ${lib_cuda_hdrs})
 endmacro()
 
 # creates OpenCV module in current folder
@@ -622,27 +625,20 @@ endmacro()
 # short command for adding simple OpenCV module
 # see ocv_add_module for argument details
 # Usage:
-# ocv_define_module(module_name  [INTERNAL] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>])
+# ocv_define_module(module_name  [INTERNAL] [EXCLUDE_CUDA] [REQUIRED] [<list of dependencies>] [OPTIONAL <list of optional dependencies>])
 macro(ocv_define_module module_name)
-  set(_tmp_argn ${ARGN})
-  set(exclude_cuda 0)
-  set(exclude_opencl 0)
-  set(argv0 ${ARGV1})
-  set(argv1 ${ARGV2})
-  set(argv2 ${ARGV3})
-  foreach(i RANGE 0 2)
-    if("${argv${i}}" STREQUAL "EXCLUDE_CUDA")
-      set(exclude_cuda 1)
-      list(REMOVE_AT _tmp_argn ${i})
-    elseif ("${argv${i}}" STREQUAL "EXCLUDE_OPENCL")
-      set(exclude_opencl 1)
-      list(REMOVE_AT _tmp_argn ${i})
+  set(_argn ${ARGN})
+  set(exclude_cuda "")
+  foreach(arg ${_argn})
+    if("${arg}" STREQUAL "EXCLUDE_CUDA")
+      set(exclude_cuda "${arg}")
+      list(REMOVE_ITEM _argn ${arg})
     endif()
   endforeach()
 
-  ocv_add_module(${module_name} ${_tmp_argn})
+  ocv_add_module(${module_name} ${_argn})
   ocv_module_include_directories()
-  ocv_glob_module_sources(${exclude_cuda} ${exclude_opencl})
+  ocv_glob_module_sources(${exclude_cuda})
   ocv_create_module()
   ocv_add_precompiled_headers(${the_module})
 
index 82c61cc..8e3d7b2 100644 (file)
@@ -1,7 +1,12 @@
-if(ANDROID OR IOS)
+if(IOS)
   ocv_module_disable(superres)
 endif()
 
 set(the_description "Super Resolution")
 ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127 -Wundef -Wshadow)
-ocv_define_module(superres opencv_imgproc opencv_video OPTIONAL opencv_gpu opencv_highgui opencv_ocl ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
+if(ENABLE_DYNAMIC_CUDA)
+  add_definitions(-DDYNAMIC_CUDA_SUPPORT)
+  ocv_define_module(superres EXCLUDE_CUDA opencv_imgproc opencv_video OPTIONAL opencv_highgui opencv_ocl)
+else()
+  ocv_define_module(superres opencv_imgproc opencv_video OPTIONAL opencv_gpu opencv_highgui opencv_ocl ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
+endif()
index b93bcfd..2f40fa3 100644 (file)
@@ -51,7 +51,7 @@ using namespace cv::gpu;
 using namespace cv::superres;
 using namespace cv::superres::detail;
 
-#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_GPU)
+#if !defined(HAVE_CUDA) || !defined(HAVE_OPENCV_GPU) || defined(DYNAMIC_CUDA_SUPPORT)
 
 Ptr<SuperResolution> cv::superres::createSuperResolution_BTVL1_GPU()
 {
index 20e45d9..5f59a98 100644 (file)
@@ -200,7 +200,7 @@ Ptr<FrameSource> cv::superres::createFrameSource_Camera(int deviceId)
 //////////////////////////////////////////////////////
 // VideoFrameSource_GPU
 
-#ifndef HAVE_OPENCV_GPU
+#if !defined(HAVE_OPENCV_GPU) || defined(DYNAMIC_CUDA_SUPPORT)
 
 Ptr<FrameSource> cv::superres::createFrameSource_Video_GPU(const string& fileName)
 {
index 075cf95..10fc1c9 100644 (file)
@@ -207,7 +207,7 @@ namespace
         switch (src.kind())
         {
         case _InputArray::GPU_MAT:
-            #ifdef HAVE_OPENCV_GPU
+            #if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
                 gpu::cvtColor(src.getGpuMat(), dst.getGpuMatRef(), code, cn);
             #else
                 CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform");
index e1e8a10..617f83a 100644 (file)
@@ -344,7 +344,7 @@ Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_DualTVL1()
 ///////////////////////////////////////////////////////////////////
 // GpuOpticalFlow
 
-#ifndef HAVE_OPENCV_GPU
+#if !defined(HAVE_OPENCV_GPU) || defined(DYNAMIC_CUDA_SUPPORT)
 
 Ptr<DenseOpticalFlowExt> cv::superres::createOptFlow_Farneback_GPU()
 {
index 4cf4941..65fc7c8 100644 (file)
@@ -56,7 +56,7 @@
 #include "opencv2/imgproc/imgproc.hpp"
 #include "opencv2/video/tracking.hpp"
 
-#ifdef HAVE_OPENCV_GPU
+#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
     #include "opencv2/gpu/gpu.hpp"
     #ifdef HAVE_CUDA
         #include "opencv2/gpu/stream_accessor.hpp"
index dcd3e15..bb56da2 100644 (file)
@@ -11,7 +11,7 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
 
 ocv_add_module(ts opencv_core opencv_features2d)
 
-ocv_glob_module_sources(0 0)
+ocv_glob_module_sources()
 ocv_module_include_directories()
 ocv_create_module()
 
index 8fa5394..d25c3a6 100644 (file)
@@ -41,7 +41,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND)
 
     target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_GPU_SAMPLES_REQUIRED_DEPS})
 
-    if(HAVE_CUDA)
+    if(HAVE_CUDA AND NOT ANDROID)
       target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY})
     endif()
 
index 722e19f..7cd5089 100644 (file)
@@ -1,6 +1,7 @@
 #include <iostream>
 #include <iomanip>
 #include <string>
+#include <ctype.h>
 
 #include "cvconfig.h"
 #include "opencv2/core/core.hpp"
index 05a37ef..31ee569 100644 (file)
@@ -7,6 +7,7 @@
 #include <memory>
 #include <exception>
 #include <ctime>
+#include <ctype.h>
 
 #include "cvconfig.h"
 #include <iostream>
index 6efd241..85cb6cf 100644 (file)
@@ -1,6 +1,8 @@
 #include <iostream>
 #include <iomanip>
 #include <string>
+#include <ctype.h>
+
 #include "opencv2/core/core.hpp"
 #include "opencv2/highgui/highgui.hpp"
 #include "opencv2/imgproc/imgproc.hpp"