diff --git a/CMakeLists.txt b/CMakeLists.txt index 09a530d41..066d0563d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,6 +337,9 @@ if(DEFINED CMAKE_DEBUG_POSTFIX) set(OPENCV_DEBUG_POSTFIX "${CMAKE_DEBUG_POSTFIX}") endif() +if(INSTALL_CREATE_DISTRIB AND BUILD_SHARED_LIBS AND NOT DEFINED BUILD_opencv_world) + set(BUILD_opencv_world ON CACHE INTERNAL "") +endif() # ---------------------------------------------------------------------------- # Path for build/platform -specific headers @@ -554,7 +557,6 @@ endif() # ---------------------------------------------------------------------------- # Finalization: generate configuration-based files # ---------------------------------------------------------------------------- -ocv_track_build_dependencies() # Generate platform-dependent and configuration-dependent headers include(cmake/OpenCVGenHeaders.cmake) diff --git a/apps/traincascade/CMakeLists.txt b/apps/traincascade/CMakeLists.txt index ab32b4cfb..59d48172d 100644 --- a/apps/traincascade/CMakeLists.txt +++ b/apps/traincascade/CMakeLists.txt @@ -6,18 +6,18 @@ if(NOT OCV_DEPENDENCIES_FOUND) endif() project(traincascade) +set(the_target opencv_traincascade) -ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") -ocv_include_modules(${OPENCV_TRAINCASCADE_DEPS}) +ocv_target_include_directories(${the_target} PRIVATE "${CMAKE_CURRENT_SOURCE_DIR}" "${OpenCV_SOURCE_DIR}/include/opencv") +ocv_target_include_modules(${the_target} ${OPENCV_TRAINCASCADE_DEPS}) file(GLOB SRCS *.cpp) file(GLOB HDRS *.h*) set(traincascade_files ${SRCS} ${HDRS}) -set(the_target opencv_traincascade) -add_executable(${the_target} ${traincascade_files}) -target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS}) +ocv_add_executable(${the_target} ${traincascade_files}) +ocv_target_link_libraries(${the_target} ${OPENCV_TRAINCASCADE_DEPS}) set_target_properties(${the_target} PROPERTIES DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}" diff --git a/cmake/OpenCVDetectAndroidSDK.cmake b/cmake/OpenCVDetectAndroidSDK.cmake index 90e11761e..d97e9ec74 100644 --- a/cmake/OpenCVDetectAndroidSDK.cmake +++ b/cmake/OpenCVDetectAndroidSDK.cmake @@ -280,9 +280,6 @@ macro(add_android_project target path) string(REGEX REPLACE "LOCAL_MODULE[ ]*:=[ ]*([a-zA-Z_][a-zA-Z_0-9]*)[ ]*" "\\1" JNI_LIB_NAME "${JNI_LIB_NAME}") if(JNI_LIB_NAME) - ocv_include_modules_recurse(${android_proj_NATIVE_DEPS}) - ocv_include_directories("${path}/jni") - if(NATIVE_APP_GLUE) include_directories(${ANDROID_NDK}/sources/android/native_app_glue) list(APPEND android_proj_jni_files ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) @@ -291,7 +288,9 @@ macro(add_android_project target path) endif() add_library(${JNI_LIB_NAME} MODULE ${android_proj_jni_files}) - target_link_libraries(${JNI_LIB_NAME} ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS}) + ocv_target_include_modules_recurse(${JNI_LIB_NAME} ${android_proj_NATIVE_DEPS}) + ocv_target_include_directories(${JNI_LIB_NAME} "${path}/jni") + ocv_target_link_libraries(${JNI_LIB_NAME} ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS}) set_target_properties(${JNI_LIB_NAME} PROPERTIES OUTPUT_NAME "${JNI_LIB_NAME}" diff --git a/cmake/OpenCVModule.cmake b/cmake/OpenCVModule.cmake index 3f4da5f10..d53f0666e 100644 --- a/cmake/OpenCVModule.cmake +++ b/cmake/OpenCVModule.cmake @@ -6,16 +6,19 @@ # Global variables: # # OPENCV_MODULE_${the_module}_LOCATION +# OPENCV_MODULE_${the_module}_BINARY_DIR # OPENCV_MODULE_${the_module}_DESCRIPTION # OPENCV_MODULE_${the_module}_CLASS - PUBLIC|INTERNAL|BINDINGS # OPENCV_MODULE_${the_module}_HEADERS # OPENCV_MODULE_${the_module}_SOURCES # OPENCV_MODULE_${the_module}_DEPS - final flattened set of module dependencies +# OPENCV_MODULE_${the_module}_DEPS_TO_LINK - differs from above for world build only # OPENCV_MODULE_${the_module}_DEPS_EXT - non-module dependencies # OPENCV_MODULE_${the_module}_REQ_DEPS # OPENCV_MODULE_${the_module}_OPT_DEPS # OPENCV_MODULE_${the_module}_PRIVATE_REQ_DEPS # OPENCV_MODULE_${the_module}_PRIVATE_OPT_DEPS +# OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD # HAVE_${the_module} - for fast check of module availability # To control the setup of the module you could also set: @@ -53,6 +56,7 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD unset(OPENCV_MODULE_${mod}_OPT_DEPS CACHE) unset(OPENCV_MODULE_${mod}_PRIVATE_REQ_DEPS CACHE) unset(OPENCV_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE) + unset(OPENCV_MODULE_${mod}_LINK_DEPS CACHE) endforeach() # clean modules info which needs to be recalculated @@ -61,6 +65,7 @@ set(OPENCV_MODULES_BUILD "" CACHE INTERNAL "List of OpenCV modules incl set(OPENCV_MODULES_DISABLED_USER "" CACHE INTERNAL "List of OpenCV modules explicitly disabled by user") set(OPENCV_MODULES_DISABLED_AUTO "" CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies") set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration") +unset(OPENCV_WORLD_MODULES CACHE) # adds dependencies to OpenCV module # Usage: @@ -68,6 +73,7 @@ set(OPENCV_MODULES_DISABLED_FORCE "" CACHE INTERNAL "List of OpenCV modules whic # Notes: # * - can include full names of modules or full pathes to shared/static libraries or cmake targets macro(ocv_add_dependencies full_modname) + ocv_debug_message("ocv_add_dependencies(" ${full_modname} ${ARGN} ")") #we don't clean the dependencies here to allow this macro several times for every module foreach(d "REQUIRED" ${ARGN}) if(d STREQUAL "REQUIRED") @@ -105,6 +111,7 @@ endmacro() # Example: # ocv_add_module(yaom INTERNAL opencv_core opencv_highgui opencv_flann OPTIONAL opencv_cuda) macro(ocv_add_module _name) + ocv_debug_message("ocv_add_module(" ${_name} ${ARGN} ")") string(TOLOWER "${_name}" name) string(REGEX REPLACE "^opencv_" "" ${name} "${name}") set(the_module opencv_${name}) @@ -134,6 +141,8 @@ macro(ocv_add_module _name) set(OPENCV_MODULE_${the_module}_DESCRIPTION "${the_description}" CACHE INTERNAL "Brief description of ${the_module} module") set(OPENCV_MODULE_${the_module}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${the_module} module sources") + set(OPENCV_MODULE_${the_module}_LINK_DEPS "" CACHE INTERNAL "") + # parse list of dependencies if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS") set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The category of the module") @@ -150,8 +159,14 @@ macro(ocv_add_module _name) endif() # add self to the world dependencies - if(NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS" OR OPENCV_MODULE_IS_PART_OF_WORLD) + if((NOT DEFINED OPENCV_MODULE_IS_PART_OF_WORLD AND NOT OPENCV_MODULE_${the_module}_CLASS STREQUAL "BINDINGS" + AND NOT OPENCV_PROCESSING_EXTRA_MODULES) + OR OPENCV_MODULE_IS_PART_OF_WORLD + ) + set(OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD ON CACHE INTERNAL "") ocv_add_dependencies(opencv_world OPTIONAL ${the_module}) + else() + set(OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD OFF CACHE INTERNAL "") endif() if(BUILD_${the_module}) @@ -164,12 +179,15 @@ macro(ocv_add_module _name) # stop processing of current file return() - else(OPENCV_INITIAL_PASS) + else() + set(OPENCV_MODULE_${the_module}_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE INTERNAL "") if(NOT BUILD_${the_module}) return() # extra protection from redefinition endif() - project(${the_module}) - endif(OPENCV_INITIAL_PASS) + if((NOT OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD AND NOT ${the_module} STREQUAL opencv_world) OR NOT ${BUILD_opencv_world}) + project(${the_module}) + endif() + endif() endmacro() # excludes module from current configuration @@ -200,7 +218,11 @@ macro(ocv_glob_modules) # collect modules set(OPENCV_INITIAL_PASS ON) + set(OPENCV_PROCESSING_EXTRA_MODULES 0) foreach(__path ${ARGN}) + if("${__path}" STREQUAL "EXTRA") + set(OPENCV_PROCESSING_EXTRA_MODULES 1) + endif() get_filename_component(__path "${__path}" ABSOLUTE) list(FIND __directories_observed "${__path}" __pathIdx) @@ -222,16 +244,7 @@ macro(ocv_glob_modules) endif() list(APPEND __directories_observed "${__modpath}") - if(OCV_MODULE_RELOCATE_ON_INITIAL_PASS) - file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}") - file(COPY "${__modpath}/CMakeLists.txt" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}") - add_subdirectory("${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}") - if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}") - set(OPENCV_MODULE_opencv_${mod}_LOCATION "${__modpath}" CACHE PATH "" FORCE) - endif() - else() - add_subdirectory("${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}") - endif() + add_subdirectory("${__modpath}" "${CMAKE_CURRENT_BINARY_DIR}/${mod}/.${mod}") endif() endforeach() endif() @@ -244,15 +257,31 @@ macro(ocv_glob_modules) # create modules set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE) set(OPENCV_INITIAL_PASS OFF) - foreach(m ${OPENCV_MODULES_BUILD}) - if(m MATCHES "^opencv_") - string(REGEX REPLACE "^opencv_" "" __shortname "${m}") - add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}") - else() - message(WARNING "Check module name: ${m}") - add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${m}") - endif() - endforeach() + if(${BUILD_opencv_world}) + add_subdirectory("${OPENCV_MODULE_opencv_world_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/world") + foreach(m ${OPENCV_MODULES_BUILD}) + if(NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD AND NOT ${m} STREQUAL opencv_world) + message(STATUS "Processing module ${m}...") + if(m MATCHES "^opencv_") + string(REGEX REPLACE "^opencv_" "" __shortname "${m}") + add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}") + else() + message(WARNING "Check module name: ${m}") + add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${m}") + endif() + endif() + endforeach() + else() + foreach(m ${OPENCV_MODULES_BUILD}) + if(m MATCHES "^opencv_") + string(REGEX REPLACE "^opencv_" "" __shortname "${m}") + add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}") + else() + message(WARNING "Check module name: ${m}") + add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${m}") + endif() + endforeach() + endif() unset(__shortname) endmacro() @@ -394,11 +423,36 @@ function(__ocv_resolve_dependencies) __ocv_sort_modules_by_deps(OPENCV_MODULE_${m}_DEPS) ocv_list_sort(OPENCV_MODULE_${m}_DEPS_EXT) + set(LINK_DEPS ${OPENCV_MODULE_${m}_DEPS}) + + # process world + if(BUILD_opencv_world) + if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD) + list(APPEND OPENCV_WORLD_MODULES ${m}) + endif() + foreach(m2 ${OPENCV_MODULES_BUILD}) + if(OPENCV_MODULE_${m2}_IS_PART_OF_WORLD) + if(";${LINK_DEPS};" MATCHES ";${m2};") + list(REMOVE_ITEM LINK_DEPS ${m2}) + if(NOT (";${LINK_DEPS};" MATCHES ";opencv_world;") AND NOT (${m} STREQUAL opencv_world)) + list(APPEND LINK_DEPS opencv_world) + endif() + endif() + if(${m} STREQUAL opencv_world) + list(APPEND OPENCV_MODULE_opencv_world_DEPS_EXT ${OPENCV_MODULE_${m2}_DEPS_EXT}) + endif() + endif() + endforeach() + endif() + set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module") set(OPENCV_MODULE_${m}_DEPS_EXT ${OPENCV_MODULE_${m}_DEPS_EXT} CACHE INTERNAL "Extra dependencies of ${m} module") + set(OPENCV_MODULE_${m}_DEPS_TO_LINK ${LINK_DEPS} CACHE INTERNAL "Flattened dependencies of ${m} module (for linker)") -# message(STATUS " module deps: ${OPENCV_MODULE_${m}_DEPS}") -# message(STATUS " extra deps: ${OPENCV_MODULE_${m}_DEPS_EXT}") +# message(STATUS " module deps of ${m}: ${OPENCV_MODULE_${m}_DEPS}") +# message(STATUS " module link deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_TO_LINK}") +# message(STATUS " extra deps of ${m}: ${OPENCV_MODULE_${m}_DEPS_EXT}") +# message(STATUS "") endforeach() __ocv_sort_modules_by_deps(OPENCV_MODULES_BUILD) @@ -406,6 +460,7 @@ function(__ocv_resolve_dependencies) set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} CACHE INTERNAL "List of OpenCV modules marked for export") set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD} CACHE INTERNAL "List of OpenCV modules included into the build") set(OPENCV_MODULES_DISABLED_AUTO ${OPENCV_MODULES_DISABLED_AUTO} CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies") + set(OPENCV_WORLD_MODULES ${OPENCV_WORLD_MODULES} CACHE INTERNAL "List of OpenCV modules included into the world") endfunction() @@ -422,18 +477,31 @@ macro(ocv_include_modules) endforeach() endmacro() -# setup include paths for the list of passed modules and recursively add dependent modules -macro(ocv_include_modules_recurse) +# setup include paths for the list of passed modules +macro(ocv_target_include_modules target) foreach(d ${ARGN}) if(d MATCHES "^opencv_" AND HAVE_${d}) if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include") - ocv_include_directories("${OPENCV_MODULE_${d}_LOCATION}/include") - endif() - if(OPENCV_MODULE_${d}_DEPS) - ocv_include_modules(${OPENCV_MODULE_${d}_DEPS}) + ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include") endif() elseif(EXISTS "${d}") - ocv_include_directories("${d}") + ocv_target_include_directories(${target} "${d}") + endif() + endforeach() +endmacro() + +# setup include paths for the list of passed modules and recursively add dependent modules +macro(ocv_target_include_modules_recurse target) + foreach(d ${ARGN}) + if(d MATCHES "^opencv_" AND HAVE_${d}) + if (EXISTS "${OPENCV_MODULE_${d}_LOCATION}/include") + ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include") + endif() + if(OPENCV_MODULE_${d}_DEPS) + ocv_target_include_modules(${target} ${OPENCV_MODULE_${d}_DEPS}) + endif() + elseif(EXISTS "${d}") + ocv_target_include_directories(${target} "${d}") endif() endforeach() endmacro() @@ -441,11 +509,12 @@ endmacro() # setup include path for OpenCV headers for specified module # ocv_module_include_directories() macro(ocv_module_include_directories) - ocv_include_directories("${OPENCV_MODULE_${the_module}_LOCATION}/include" - "${OPENCV_MODULE_${the_module}_LOCATION}/src" - "${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers - ) - ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS} ${ARGN}) + ocv_target_include_directories(${the_module} + "${OPENCV_MODULE_${the_module}_LOCATION}/include" + "${OPENCV_MODULE_${the_module}_LOCATION}/src" + "${CMAKE_CURRENT_BINARY_DIR}" # for precompiled headers + ) + ocv_target_include_modules(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${ARGN}) endmacro() @@ -454,6 +523,8 @@ endmacro() # Usage: # ocv_set_module_sources([HEADERS] [SOURCES] ) macro(ocv_set_module_sources) + ocv_debug_message("ocv_set_module_sources(" ${ARGN} ")") + set(OPENCV_MODULE_${the_module}_HEADERS "") set(OPENCV_MODULE_${the_module}_SOURCES "") @@ -481,31 +552,50 @@ endmacro() # Usage: # ocv_glob_module_sources([EXCLUDE_CUDA] ) macro(ocv_glob_module_sources) + ocv_debug_message("ocv_glob_module_sources(" ${ARGN} ")") 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/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") - file(GLOB lib_hdrs_detail "include/opencv2/${name}/detail/*.hpp" "include/opencv2/${name}/detail/*.h") - file(GLOB_RECURSE lib_srcs_apple "src/*.mm") + file(GLOB_RECURSE lib_srcs + "${CMAKE_CURRENT_LIST_DIR}/src/*.cpp" + ) + file(GLOB_RECURSE lib_int_hdrs + "${CMAKE_CURRENT_LIST_DIR}/src/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/src/*.h" + ) + file(GLOB lib_hdrs + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h" + ) + file(GLOB lib_hdrs_detail + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.h" + ) if (APPLE) + file(GLOB_RECURSE lib_srcs_apple + "${CMAKE_CURRENT_LIST_DIR}/src/*.mm" + ) list(APPEND lib_srcs ${lib_srcs_apple}) endif() - ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs}) - ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_SOURCE_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail}) + ocv_source_group("Src" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/src" FILES ${lib_srcs} ${lib_int_hdrs}) + ocv_source_group("Include" DIRBASE "${CMAKE_CURRENT_LIST_DIR}/include" FILES ${lib_hdrs} ${lib_hdrs_detail}) if (exclude_cuda EQUAL -1) - file(GLOB lib_cuda_srcs "src/cuda/*.cu") + file(GLOB lib_cuda_srcs + "${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.cu" + ) set(cuda_objs "") set(lib_cuda_hdrs "") if(HAVE_CUDA) ocv_include_directories(${CUDA_INCLUDE_DIRS}) - file(GLOB lib_cuda_hdrs "src/cuda/*.hpp") + file(GLOB lib_cuda_hdrs + "${CMAKE_CURRENT_LIST_DIR}/src/cuda/*.hpp" + ) ocv_cuda_compile(cuda_objs ${lib_cuda_srcs} ${lib_cuda_hdrs}) source_group("Src\\Cuda" FILES ${lib_cuda_srcs} ${lib_cuda_hdrs}) @@ -516,17 +606,19 @@ macro(ocv_glob_module_sources) set(lib_cuda_hdrs "") endif() - file(GLOB cl_kernels "src/opencl/*.cl") + file(GLOB cl_kernels + "${CMAKE_CURRENT_LIST_DIR}/src/opencl/*.cl" + ) if(cl_kernels) + set(OCL_NAME opencl_kernels_${name}) ocv_include_directories(${OPENCL_INCLUDE_DIRS}) - string(REGEX REPLACE "opencv_" "" the_module_barename "${the_module}") add_custom_command( - OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" "${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.hpp" - COMMAND ${CMAKE_COMMAND} -DMODULE_NAME="${the_module_barename}" -DCL_DIR="${CMAKE_CURRENT_SOURCE_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/opencl_kernels.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake" + OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp" + COMMAND ${CMAKE_COMMAND} -DMODULE_NAME="${name}" -DCL_DIR="${CMAKE_CURRENT_LIST_DIR}/src/opencl" -DOUTPUT="${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" -P "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake" DEPENDS ${cl_kernels} "${OpenCV_SOURCE_DIR}/cmake/cl2cpp.cmake") ocv_source_group("Src\\opencl\\kernels" FILES ${cl_kernels}) - ocv_source_group("Src\\opencl\\kernels\\autogenerated" FILES "${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") + ocv_source_group("Src\\opencl\\kernels\\autogenerated" FILES "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp") + list(APPEND lib_srcs ${cl_kernels} "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.cpp" "${CMAKE_CURRENT_BINARY_DIR}/${OCL_NAME}.hpp") endif() ocv_set_module_sources(${_argn} HEADERS ${lib_hdrs} ${lib_hdrs_detail} @@ -537,29 +629,39 @@ endmacro() # creates new target, configures standard dependencies, compilers flags, install rules # Usage: # ocv_create_module() -# ocv_create_module(SKIP_LINK) +# ocv_create_module() macro(ocv_create_module) + ocv_debug_message("ocv_create_module(" ${ARGN} ")") + set(OPENCV_MODULE_${the_module}_LINK_DEPS "${OPENCV_MODULE_${the_module}_LINK_DEPS};${ARGN}" CACHE INTERNAL "") + if(${BUILD_opencv_world} AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD) + # nothing + set(the_module_target opencv_world) + else() + _ocv_create_module(${ARGN}) + set(the_module_target ${the_module}) + endif() +endmacro() + +macro(_ocv_create_module) # The condition we ought to be testing here is whether ocv_add_precompiled_headers will # be called at some point in the future. We can't look into the future, though, # so this will have to do. - if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp" AND NOT ${the_module} STREQUAL opencv_world) get_native_precompiled_header(${the_module} precomp.hpp) endif() - add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} + ocv_add_library(${the_module} ${OPENCV_MODULE_TYPE} ${OPENCV_MODULE_${the_module}_HEADERS} ${OPENCV_MODULE_${the_module}_SOURCES} "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/opencv_modules.hpp" ${${the_module}_pch}) if(NOT the_module STREQUAL opencv_ts) set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL) endif() - if(NOT "${ARGN}" STREQUAL "SKIP_LINK") - target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS}) - target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS}) - target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN}) - if (HAVE_CUDA) - target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) - endif() + ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK}) + ocv_target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS_TO_LINK}) + ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN}) + if (HAVE_CUDA) + ocv_target_link_libraries(${the_module} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY}) endif() add_dependencies(opencv_modules ${the_module}) @@ -614,13 +716,16 @@ macro(ocv_create_module) endif() endforeach() endif() + _ocv_add_precompiled_headers(${the_module}) endmacro() # opencv precompiled headers macro (can add pch to modules and tests) # this macro must be called after any "add_definitions" commands, otherwise precompiled headers will not work # Usage: # ocv_add_precompiled_headers(${the_module}) -macro(ocv_add_precompiled_headers the_target) +macro(_ocv_add_precompiled_headers the_target) + ocv_debug_message("ocv_add_precompiled_headers(" ${the_target} ${ARGN} ")") + if("${the_target}" MATCHES "^opencv_test_.*$") SET(pch_path "test/test_") elseif("${the_target}" MATCHES "^opencv_perf_.*$") @@ -637,6 +742,7 @@ endmacro() # Usage: # ocv_define_module(module_name [INTERNAL] [EXCLUDE_CUDA] [REQUIRED] [] [OPTIONAL ]) macro(ocv_define_module module_name) + ocv_debug_message("ocv_define_module(" ${module_name} ${ARGN} ")") set(_argn ${ARGN}) set(exclude_cuda "") foreach(arg ${_argn}) @@ -647,10 +753,9 @@ macro(ocv_define_module module_name) endforeach() ocv_add_module(${module_name} ${_argn}) - ocv_module_include_directories() ocv_glob_module_sources(${exclude_cuda}) + ocv_module_include_directories() ocv_create_module() - ocv_add_precompiled_headers(${the_module}) ocv_add_accuracy_tests() ocv_add_perf_tests() @@ -685,7 +790,7 @@ macro(__ocv_parse_test_sources tests_type) set(__file_group_name "") set(__file_group_sources "") elseif(arg STREQUAL "DEPENDS_ON") - set(__currentvar "OPENCV_TEST_${the_module}_DEPS") + set(__currentvar "OPENCV_${tests_type}_${the_module}_DEPS") elseif("${__currentvar}" STREQUAL "__file_group_sources" AND NOT __file_group_name) set(__file_group_name "${arg}") else() @@ -700,20 +805,20 @@ endmacro() # this is a command for adding OpenCV performance tests to the module # ocv_add_perf_tests() function(ocv_add_perf_tests) - set(perf_path "${CMAKE_CURRENT_SOURCE_DIR}/perf") + ocv_debug_message("ocv_add_perf_tests(" ${ARGN} ")") + + set(perf_path "${CMAKE_CURRENT_LIST_DIR}/perf") if(BUILD_PERF_TESTS AND EXISTS "${perf_path}") __ocv_parse_test_sources(PERF ${ARGN}) # opencv_imgcodecs is required for imread/imwrite - set(perf_deps ${the_module} opencv_ts opencv_imgcodecs ${OPENCV_PERF_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS}) + set(perf_deps ${the_module} opencv_ts opencv_imgcodecs ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS}) ocv_check_dependencies(${perf_deps}) if(OCV_DEPENDENCIES_FOUND) set(the_target "opencv_perf_${name}") # project(${the_target}) - ocv_module_include_directories(${perf_deps} "${perf_path}") - if(NOT OPENCV_PERF_${the_module}_SOURCES) file(GLOB_RECURSE perf_srcs "${perf_path}/*.cpp") file(GLOB_RECURSE perf_hdrs "${perf_path}/*.hpp" "${perf_path}/*.h") @@ -722,10 +827,13 @@ function(ocv_add_perf_tests) set(OPENCV_PERF_${the_module}_SOURCES ${perf_srcs} ${perf_hdrs}) endif() - get_native_precompiled_header(${the_target} perf_precomp.hpp) + if(NOT BUILD_opencv_world) + get_native_precompiled_header(${the_target} perf_precomp.hpp) + endif() - add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch}) - target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS}) + ocv_add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch}) + ocv_target_include_modules(${the_target} ${perf_deps} "${perf_path}") + ocv_target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS}) add_dependencies(opencv_perf_tests ${the_target}) # Additional target properties @@ -738,8 +846,9 @@ function(ocv_add_perf_tests) set_target_properties(${the_target} PROPERTIES FOLDER "tests performance") endif() - ocv_add_precompiled_headers(${the_target}) - + if(NOT BUILD_opencv_world) + _ocv_add_precompiled_headers(${the_target}) + endif() else(OCV_DEPENDENCIES_FOUND) # TODO: warn about unsatisfied dependencies endif(OCV_DEPENDENCIES_FOUND) @@ -752,21 +861,19 @@ endfunction() # this is a command for adding OpenCV accuracy/regression tests to the module # ocv_add_accuracy_tests([FILES ] [DEPENDS_ON] ) function(ocv_add_accuracy_tests) - set(test_path "${CMAKE_CURRENT_SOURCE_DIR}/test") - ocv_check_dependencies(${test_deps}) + ocv_debug_message("ocv_add_accuracy_tests(" ${ARGN} ")") + + set(test_path "${CMAKE_CURRENT_LIST_DIR}/test") if(BUILD_TESTS AND EXISTS "${test_path}") __ocv_parse_test_sources(TEST ${ARGN}) # opencv_imgcodecs is required for imread/imwrite - set(test_deps ${the_module} opencv_ts opencv_imgcodecs opencv_videoio ${OPENCV_TEST_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS}) + set(test_deps ${the_module} opencv_ts opencv_imgcodecs opencv_videoio ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_MODULE_opencv_ts_DEPS}) ocv_check_dependencies(${test_deps}) - if(OCV_DEPENDENCIES_FOUND) set(the_target "opencv_test_${name}") # project(${the_target}) - ocv_module_include_directories(${test_deps} "${test_path}") - if(NOT OPENCV_TEST_${the_module}_SOURCES) file(GLOB_RECURSE test_srcs "${test_path}/*.cpp") file(GLOB_RECURSE test_hdrs "${test_path}/*.hpp" "${test_path}/*.h") @@ -775,10 +882,13 @@ function(ocv_add_accuracy_tests) set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs}) endif() - get_native_precompiled_header(${the_target} test_precomp.hpp) - add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch}) + if(NOT BUILD_opencv_world) + get_native_precompiled_header(${the_target} test_precomp.hpp) + endif() - target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${test_deps} ${OPENCV_LINKER_LIBS}) + ocv_add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch}) + ocv_target_include_modules(${the_target} ${test_deps} "${test_path}") + ocv_target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${test_deps} ${OPENCV_LINKER_LIBS}) add_dependencies(opencv_tests ${the_target}) # Additional target properties @@ -795,7 +905,9 @@ function(ocv_add_accuracy_tests) get_target_property(LOC ${the_target} LOCATION) add_test(${the_target} "${LOC}") - ocv_add_precompiled_headers(${the_target}) + if(NOT BUILD_opencv_world) + _ocv_add_precompiled_headers(${the_target}) + endif() else(OCV_DEPENDENCIES_FOUND) # TODO: warn about unsatisfied dependencies endif(OCV_DEPENDENCIES_FOUND) @@ -807,6 +919,8 @@ function(ocv_add_accuracy_tests) endfunction() function(ocv_add_samples) + ocv_debug_message("ocv_add_samples(" ${ARGN} ")") + set(samples_path "${CMAKE_CURRENT_SOURCE_DIR}/samples") string(REGEX REPLACE "^opencv_" "" module_id ${the_module}) @@ -816,15 +930,14 @@ function(ocv_add_samples) if(OCV_DEPENDENCIES_FOUND) file(GLOB sample_sources "${samples_path}/*.cpp") - ocv_include_modules(${OPENCV_MODULE_${the_module}_DEPS}) foreach(source ${sample_sources}) get_filename_component(name "${source}" NAME_WE) set(the_target "example_${module_id}_${name}") - add_executable(${the_target} "${source}") - target_link_libraries(${the_target} ${samples_deps}) - + ocv_add_executable(${the_target} "${source}") + ocv_target_include_modules(${the_target} ${samples_deps}) + ocv_target_link_libraries(${the_target} ${samples_deps}) set_target_properties(${the_target} PROPERTIES PROJECT_LABEL "(sample) ${name}") if(ENABLE_SOLUTION_FOLDERS) @@ -847,82 +960,3 @@ function(ocv_add_samples) PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples) endif() endfunction() - -# internal macro; finds all link dependencies of the module -# should be used at the end of CMake processing -macro(__ocv_track_module_link_dependencies the_module optkind) - set(${the_module}_MODULE_DEPS_${optkind} "") - set(${the_module}_EXTRA_DEPS_${optkind} "") - - get_target_property(__module_type ${the_module} TYPE) - if(__module_type STREQUAL "STATIC_LIBRARY") - #in case of static library we have to inherit its dependencies (in right order!!!) - if(NOT DEFINED ${the_module}_LIB_DEPENDS_${optkind}) - ocv_split_libs_list(${the_module}_LIB_DEPENDS ${the_module}_LIB_DEPENDS_DBG ${the_module}_LIB_DEPENDS_OPT) - endif() - - set(__resolved_deps "") - set(__mod_depends ${${the_module}_LIB_DEPENDS_${optkind}}) - set(__has_cycle FALSE) - - while(__mod_depends) - list(GET __mod_depends 0 __dep) - list(REMOVE_AT __mod_depends 0) - if(__dep STREQUAL the_module) - set(__has_cycle TRUE) - else()#if("${OPENCV_MODULES_BUILD}" MATCHES "(^|;)${__dep}(;|$)") - ocv_regex_escape(__rdep "${__dep}") - if(__resolved_deps MATCHES "(^|;)${__rdep}(;|$)") - #all dependencies of this module are already resolved - list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${__dep}") - else() - get_target_property(__module_type ${__dep} TYPE) - if(__module_type STREQUAL "STATIC_LIBRARY") - if(NOT DEFINED ${__dep}_LIB_DEPENDS_${optkind}) - ocv_split_libs_list(${__dep}_LIB_DEPENDS ${__dep}_LIB_DEPENDS_DBG ${__dep}_LIB_DEPENDS_OPT) - endif() - list(INSERT __mod_depends 0 ${${__dep}_LIB_DEPENDS_${optkind}} ${__dep}) - list(APPEND __resolved_deps "${__dep}") - elseif(NOT __module_type) - list(APPEND ${the_module}_EXTRA_DEPS_${optkind} "${__dep}") - endif() - endif() - #else() - # get_target_property(__dep_location "${__dep}" LOCATION) - endif() - endwhile() - - ocv_list_unique(${the_module}_MODULE_DEPS_${optkind}) - #ocv_list_reverse(${the_module}_MODULE_DEPS_${optkind}) - ocv_list_unique(${the_module}_EXTRA_DEPS_${optkind}) - #ocv_list_reverse(${the_module}_EXTRA_DEPS_${optkind}) - - if(__has_cycle) - # not sure if it can work - list(APPEND ${the_module}_MODULE_DEPS_${optkind} "${the_module}") - endif() - - unset(__dep_location) - unset(__mod_depends) - unset(__resolved_deps) - unset(__has_cycle) - unset(__rdep) - endif()#STATIC_LIBRARY - unset(__module_type) - - #message("${the_module}_MODULE_DEPS_${optkind}") - #message(" ${${the_module}_MODULE_DEPS_${optkind}}") - #message(" ${OPENCV_MODULE_${the_module}_DEPS}") - #message("") - #message("${the_module}_EXTRA_DEPS_${optkind}") - #message(" ${${the_module}_EXTRA_DEPS_${optkind}}") - #message("") -endmacro() - -# creates lists of build dependencies needed for external projects -macro(ocv_track_build_dependencies) - foreach(m ${OPENCV_MODULES_BUILD}) - __ocv_track_module_link_dependencies("${m}" OPT) - __ocv_track_module_link_dependencies("${m}" DBG) - endforeach() -endmacro() diff --git a/cmake/OpenCVPCHSupport.cmake b/cmake/OpenCVPCHSupport.cmake index 8af30f115..e5fb90e6f 100644 --- a/cmake/OpenCVPCHSupport.cmake +++ b/cmake/OpenCVPCHSupport.cmake @@ -68,6 +68,15 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags) endif() ENDFOREACH(item) + get_target_property(DIRINC ${_PCH_current_target} INCLUDE_DIRECTORIES ) + FOREACH(item ${DIRINC}) + if(item MATCHES "^${OpenCV_SOURCE_DIR}/modules/") + LIST(APPEND ${_out_compile_flags} "${_PCH_include_prefix}\"${item}\"") + else() + LIST(APPEND ${_out_compile_flags} "${_PCH_isystem_prefix}\"${item}\"") + endif() + ENDFOREACH(item) + GET_DIRECTORY_PROPERTY(_directory_flags DEFINITIONS) GET_DIRECTORY_PROPERTY(_global_definitions DIRECTORY ${OpenCV_SOURCE_DIR} DEFINITIONS) #MESSAGE("_directory_flags ${_directory_flags} ${_global_definitions}" ) @@ -254,6 +263,9 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input) endif() endif() + get_target_property(DIRINC ${_targetName} INCLUDE_DIRECTORIES) + set_target_properties(${_targetName}_pch_dephelp PROPERTIES INCLUDE_DIRECTORIES "${DIRINC}") + #MESSAGE("_compile_FLAGS: ${_compile_FLAGS}") #message("COMMAND ${CMAKE_CXX_COMPILER} ${_compile_FLAGS} -x c++-header -o ${_output} ${_input}") diff --git a/cmake/OpenCVUtils.cmake b/cmake/OpenCVUtils.cmake index d8171770d..a7d449f1b 100644 --- a/cmake/OpenCVUtils.cmake +++ b/cmake/OpenCVUtils.cmake @@ -42,6 +42,11 @@ macro(ocv_assert) endif() endmacro() +macro(ocv_debug_message) +# string(REPLACE ";" " " __msg "${ARGN}") +# message(STATUS "${__msg}") +endmacro() + macro(ocv_check_environment_variables) foreach(_var ${ARGN}) if(NOT DEFINED ${_var} AND DEFINED ENV{${_var}}) @@ -53,8 +58,18 @@ macro(ocv_check_environment_variables) endforeach() endmacro() +# rename modules target to world if needed +macro(_ocv_fix_target target_var) + if(BUILD_opencv_world) + if(OPENCV_MODULE_${${target_var}}_IS_PART_OF_WORLD) + set(${target_var} opencv_world) + endif() + endif() +endmacro() + # adds include directories in such way that directories from the OpenCV source tree go first function(ocv_include_directories) + ocv_debug_message("ocv_include_directories( ${ARGN} )") set(__add_before "") foreach(dir ${ARGN}) get_filename_component(__abs_dir "${dir}" ABSOLUTE) @@ -67,6 +82,30 @@ function(ocv_include_directories) include_directories(BEFORE ${__add_before}) endfunction() +# adds include directories in such way that directories from the OpenCV source tree go first +function(ocv_target_include_directories target) + _ocv_fix_target(target) + set(__params "") + foreach(dir ${ARGN}) + get_filename_component(__abs_dir "${dir}" ABSOLUTE) + if("${__abs_dir}" MATCHES "^${OpenCV_SOURCE_DIR}" OR "${__abs_dir}" MATCHES "^${OpenCV_BINARY_DIR}") + list(APPEND __params "${__abs_dir}") + else() + list(APPEND __params "${dir}") + endif() + endforeach() + if(CMAKE_VERSION VERSION_LESS 2.8.11) + include_directories(${__params}) + else() + if(TARGET ${target}) + target_include_directories(${target} PRIVATE ${__params}) + else() + set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}") + set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "") + endif() + endif() +endfunction() + # clears all passed variables macro(ocv_clear_vars) foreach(_var ${ARGN}) @@ -295,8 +334,8 @@ endfunction() macro(ocv_finalize_status) if(NOT OPENCV_SKIP_STATUS_FINALIZATION) - if(TARGET opencv_core) - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET) + if(DEFINED OPENCV_MODULE_opencv_core_BINARY_DIR) + execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OPENCV_BUILD_INFO_FILE}" "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc" OUTPUT_QUIET) endif() endif() endmacro() @@ -533,16 +572,20 @@ function(ocv_install_target) # message(STATUS "Process ${__target} dst=${__dst}...") if(DEFINED __dst) - get_target_property(fname ${__target} LOCATION_DEBUG) - if(fname MATCHES "\\.lib$") - string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}") - install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Debug) - endif() + if(CMAKE_VERSION VERSION_LESS 2.8.12) + get_target_property(fname ${__target} LOCATION_DEBUG) + if(fname MATCHES "\\.lib$") + string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}") + install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Debug) + endif() - get_target_property(fname ${__target} LOCATION_RELEASE) - if(fname MATCHES "\\.lib$") - string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}") - install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Release) + get_target_property(fname ${__target} LOCATION_RELEASE) + if(fname MATCHES "\\.lib$") + string(REGEX REPLACE "\\.lib$" ".pdb" fname "${fname}") + install(FILES ${fname} DESTINATION ${__dst} CONFIGURATIONS Release) + endif() + else() + # CMake 2.8.12 brokes PDB support in STATIC libraries for MSVS endif() endif() endif() @@ -637,6 +680,9 @@ endmacro() ################################################################################################ # short command to setup source group function(ocv_source_group group) + if(BUILD_opencv_world AND OPENCV_MODULE_${the_module}_IS_PART_OF_WORLD) + set(group "${the_module}\\${group}") + endif() cmake_parse_arguments(SG "" "DIRBASE" "GLOB;GLOB_RECURSE;FILES" ${ARGN}) set(files "") if(SG_FILES) @@ -669,3 +715,39 @@ function(ocv_source_group group) source_group(${group} FILES ${files}) endif() endfunction() + +function(ocv_target_link_libraries target) + _ocv_fix_target(target) + set(LINK_DEPS ${ARGN}) + # process world + if(BUILD_opencv_world) + foreach(m ${OPENCV_MODULES_BUILD}) + if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD) + if(";${LINK_DEPS};" MATCHES ";${m};") + list(REMOVE_ITEM LINK_DEPS ${m}) + if(NOT (";${LINK_DEPS};" MATCHES ";opencv_world;")) + list(APPEND LINK_DEPS opencv_world) + endif() + endif() + endif() + endforeach() + endif() + target_link_libraries(${target} ${LINK_DEPS}) +endfunction() + +function(_ocv_append_target_includes target) + if(DEFINED OCV_TARGET_INCLUDE_DIRS_${target}) + target_include_directories(${target} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}}) + unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE) + endif() +endfunction() + +function(ocv_add_executable target) + add_executable(${target} ${ARGN}) + _ocv_append_target_includes(${target}) +endfunction() + +function(ocv_add_library target) + add_library(${target} ${ARGN}) + _ocv_append_target_includes(${target}) +endfunction() \ No newline at end of file diff --git a/cmake/templates/OpenCVConfig.cmake.in b/cmake/templates/OpenCVConfig.cmake.in index e3bde4bbe..5d97474f3 100644 --- a/cmake/templates/OpenCVConfig.cmake.in +++ b/cmake/templates/OpenCVConfig.cmake.in @@ -141,6 +141,7 @@ SET(OpenCV_VERSION_STATUS "@OPENCV_VERSION_STATUS@") # ==================================================================== SET(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@) +SET(OpenCV_WORLD_COMPONENTS @OPENCV_WORLD_MODULES@) # ============================================================== # Extra include directories, needed by OpenCV 2 new structure @@ -200,8 +201,8 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) message(WARNING "${__cvcomponent} is required but was not found") endif() #indicate that module is NOT found - string(TOUPPER "${__cvcomponent}" __cvcomponent) - set(${__cvcomponent}_FOUND "${__cvcomponent}_FOUND-NOTFOUND") + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND "${__cvcomponentUP}_FOUND-NOTFOUND") else() list(APPEND OpenCV_FIND_COMPONENTS_ ${__cvcomponent}) # Not using list(APPEND) here, because OpenCV_LIBS may not exist yet. @@ -209,8 +210,31 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS}) # to find_package(OpenCV) with different component lists add up. set(OpenCV_LIBS ${OpenCV_LIBS} "${__cvcomponent}") #indicate that module is found - string(TOUPPER "${__cvcomponent}" __cvcomponent) - set(${__cvcomponent}_FOUND 1) + string(TOUPPER "${__cvcomponent}" __cvcomponentUP) + set(${__cvcomponentUP}_FOUND 1) + endif() + if(OpenCV_SHARED AND ";${OpenCV_WORLD_COMPONENTS};" MATCHES ";${__cvcomponent};" AND NOT TARGET ${__cvcomponent}) + get_target_property(__implib_dbg opencv_world IMPORTED_IMPLIB_DEBUG) + get_target_property(__implib_release opencv_world IMPORTED_IMPLIB_RELEASE) + get_target_property(__location_dbg opencv_world IMPORTED_LOCATION_DEBUG) + get_target_property(__location_release opencv_world IMPORTED_LOCATION_RELEASE) + add_library(${__cvcomponent} SHARED IMPORTED) + if(__location_dbg) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS DEBUG) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_DEBUG "${__implib_dbg}" + IMPORTED_LINK_INTERFACE_LIBRARIES_DEBUG "" + IMPORTED_LOCATION_DEBUG "${__location_dbg}" + ) + endif() + if(__location_release) + set_property(TARGET ${__cvcomponent} APPEND PROPERTY IMPORTED_CONFIGURATIONS RELEASE) + set_target_properties(${__cvcomponent} PROPERTIES + IMPORTED_IMPLIB_RELEASE "${__implib_release}" + IMPORTED_LINK_INTERFACE_LIBRARIES_RELEASE "" + IMPORTED_LOCATION_RELEASE "${__location_release}" + ) + endif() endif() endforeach() set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_}) @@ -321,6 +345,7 @@ macro(ocv_check_dependencies) set(OCV_DEPENDENCIES_FOUND TRUE) foreach(d ${ARGN}) if(NOT TARGET ${d}) + message(WARNING "OpenCV: Can't resolve dependency: ${d}") set(OCV_DEPENDENCIES_FOUND FALSE) break() endif() @@ -346,6 +371,10 @@ macro(ocv_include_modules) include_directories(BEFORE "${OpenCV_INCLUDE_DIRS}") endmacro() +macro(ocv_target_link_libraries) + target_link_libraries(${ARGN}) +endmacro() + # remove all matching elements from the list macro(ocv_list_filterout lst regex) foreach(item ${${lst}}) diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 400b2a838..2c6c34304 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -4,4 +4,4 @@ if(NOT OPENCV_MODULES_PATH) set(OPENCV_MODULES_PATH "${CMAKE_CURRENT_SOURCE_DIR}") endif() -ocv_glob_modules(${OPENCV_MODULES_PATH} ${OPENCV_EXTRA_MODULES_PATH}) +ocv_glob_modules(${OPENCV_MODULES_PATH} EXTRA ${OPENCV_EXTRA_MODULES_PATH}) diff --git a/modules/androidcamera/camera_wrapper/CMakeLists.txt b/modules/androidcamera/camera_wrapper/CMakeLists.txt index d08e2c469..c306db1de 100644 --- a/modules/androidcamera/camera_wrapper/CMakeLists.txt +++ b/modules/androidcamera/camera_wrapper/CMakeLists.txt @@ -46,7 +46,7 @@ ADD_LIBRARY(${the_target} SHARED camera_wrapper.h camera_wrapper.cpp) string(REGEX REPLACE "[.]" "_" LIBRARY_DEF ${ANDROID_VERSION}) add_definitions(-DANDROID_r${LIBRARY_DEF}) -target_link_libraries(${the_target} c m dl utils camera_client binder log) +ocv_target_link_libraries(${the_target} c m dl utils camera_client binder log) if(NOT ANDROID_VERSION VERSION_LESS "3.0.0") target_link_libraries(${the_target} gui ) diff --git a/modules/calib3d/perf/opencl/perf_stereobm.cpp b/modules/calib3d/perf/opencl/perf_stereobm.cpp index 8fca1b894..1436eb9d9 100644 --- a/modules/calib3d/perf/opencl/perf_stereobm.cpp +++ b/modules/calib3d/perf/opencl/perf_stereobm.cpp @@ -40,7 +40,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/calib3d/src/circlesgrid.cpp b/modules/calib3d/src/circlesgrid.cpp index 0b89e181c..ea169bdd7 100644 --- a/modules/calib3d/src/circlesgrid.cpp +++ b/modules/calib3d/src/circlesgrid.cpp @@ -40,6 +40,7 @@ // //M*/ +#include "precomp.hpp" #include "circlesgrid.hpp" #include //#define DEBUG_CIRCLES diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index 2b2d1bdf3..20e289973 100644 --- a/modules/calib3d/src/solvepnp.cpp +++ b/modules/calib3d/src/solvepnp.cpp @@ -139,11 +139,13 @@ namespace cv CameraParameters camera; }; + template static void pnpTask(const std::vector& pointsMask, const Mat& objectPoints, const Mat& imagePoints, const Parameters& params, std::vector& inliers, Mat& rvec, Mat& tvec, const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex) { - Mat modelObjectPoints(1, MIN_POINTS_COUNT, CV_32FC3), modelImagePoints(1, MIN_POINTS_COUNT, CV_32FC2); + Mat modelObjectPoints(1, MIN_POINTS_COUNT, CV_MAKETYPE(DataDepth::value, 3)); + Mat modelImagePoints(1, MIN_POINTS_COUNT, CV_MAKETYPE(DataDepth::value, 2)); for (int i = 0, colIndex = 0; i < (int)pointsMask.size(); i++) { if (pointsMask[i]) @@ -162,7 +164,7 @@ namespace cv for (int i = 0; i < MIN_POINTS_COUNT; i++) for (int j = i + 1; j < MIN_POINTS_COUNT; j++) { - if (norm(modelObjectPoints.at(0, i) - modelObjectPoints.at(0, j)) < eps) + if (norm(modelObjectPoints.at >(0, i) - modelObjectPoints.at >(0, j)) < eps) num_same_points++; } if (num_same_points > 0) @@ -176,7 +178,7 @@ namespace cv params.useExtrinsicGuess, params.flags); - std::vector projected_points; + std::vector > projected_points; projected_points.resize(objectPoints.cols); projectPoints(objectPoints, localRvec, localTvec, params.camera.intrinsics, params.camera.distortion, projected_points); @@ -186,9 +188,11 @@ namespace cv std::vector localInliers; for (int i = 0; i < objectPoints.cols; i++) { - Point2f p(imagePoints.at(0, i)[0], imagePoints.at(0, i)[1]); + //Although p is a 2D point it needs the same type as the object points to enable the norm calculation + Point_ p((OpointType)imagePoints.at >(0, i)[0], + (OpointType)imagePoints.at >(0, i)[1]); if ((norm(p - projected_points[i]) < params.reprojectionError) - && (rotatedPoints.at(0, i)[2] > 0)) //hack + && (rotatedPoints.at >(0, i)[2] > 0)) //hack { localInliers.push_back(i); } @@ -208,6 +212,30 @@ namespace cv } } + static void pnpTask(const std::vector& pointsMask, const Mat& objectPoints, const Mat& imagePoints, + const Parameters& params, std::vector& inliers, Mat& rvec, Mat& tvec, + const Mat& rvecInit, const Mat& tvecInit, Mutex& resultsMutex) + { + CV_Assert(objectPoints.depth() == CV_64F || objectPoints.depth() == CV_32F); + CV_Assert(imagePoints.depth() == CV_64F || imagePoints.depth() == CV_32F); + const bool objectDoublePrecision = objectPoints.depth() == CV_64F; + const bool imageDoublePrecision = imagePoints.depth() == CV_64F; + if(objectDoublePrecision) + { + if(imageDoublePrecision) + pnpTask(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex); + else + pnpTask(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex); + } + else + { + if(imageDoublePrecision) + pnpTask(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex); + else + pnpTask(pointsMask, objectPoints, imagePoints, params, inliers, rvec, tvec, rvecInit, tvecInit, resultsMutex); + } + } + class PnPSolver { public: @@ -283,10 +311,10 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints, Mat cameraMatrix = _cameraMatrix.getMat(), distCoeffs = _distCoeffs.getMat(); CV_Assert(opoints.isContinuous()); - CV_Assert(opoints.depth() == CV_32F); + CV_Assert(opoints.depth() == CV_32F || opoints.depth() == CV_64F); CV_Assert((opoints.rows == 1 && opoints.channels() == 3) || opoints.cols*opoints.channels() == 3); CV_Assert(ipoints.isContinuous()); - CV_Assert(ipoints.depth() == CV_32F); + CV_Assert(ipoints.depth() == CV_32F || ipoints.depth() == CV_64F); CV_Assert((ipoints.rows == 1 && ipoints.channels() == 2) || ipoints.cols*ipoints.channels() == 2); _rvec.create(3, 1, CV_64FC1); @@ -322,7 +350,7 @@ void cv::solvePnPRansac(InputArray _opoints, InputArray _ipoints, if (flags != P3P) { int i, pointsCount = (int)localInliers.size(); - Mat inlierObjectPoints(1, pointsCount, CV_32FC3), inlierImagePoints(1, pointsCount, CV_32FC2); + Mat inlierObjectPoints(1, pointsCount, CV_MAKE_TYPE(opoints.depth(), 3)), inlierImagePoints(1, pointsCount, CV_MAKE_TYPE(ipoints.depth(), 2)); for (i = 0; i < pointsCount; i++) { int index = localInliers[i]; diff --git a/modules/calib3d/src/stereobm.cpp b/modules/calib3d/src/stereobm.cpp index 7c06debcb..676202d12 100644 --- a/modules/calib3d/src/stereobm.cpp +++ b/modules/calib3d/src/stereobm.cpp @@ -48,7 +48,7 @@ #include "precomp.hpp" #include #include -#include "opencl_kernels.hpp" +#include "opencl_kernels_calib3d.hpp" namespace cv { diff --git a/modules/calib3d/test/opencl/test_stereobm.cpp b/modules/calib3d/test/opencl/test_stereobm.cpp index 636d76cb2..e64fe415e 100644 --- a/modules/calib3d/test/opencl/test_stereobm.cpp +++ b/modules/calib3d/test/opencl/test_stereobm.cpp @@ -40,7 +40,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "cvconfig.h" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/core/CMakeLists.txt b/modules/core/CMakeLists.txt index e5898023f..5158dec5f 100644 --- a/modules/core/CMakeLists.txt +++ b/modules/core/CMakeLists.txt @@ -1,6 +1,5 @@ set(the_description "The Core Functionality") ocv_add_module(core PRIVATE_REQUIRED ${ZLIB_LIBRARIES} "${OPENCL_LIBRARIES}" OPTIONAL opencv_cudev) -ocv_module_include_directories(${ZLIB_INCLUDE_DIRS}) if(HAVE_WINRT_CX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /ZW") @@ -19,11 +18,11 @@ file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "incl source_group("Cuda Headers" FILES ${lib_cuda_hdrs}) source_group("Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail}) -ocv_glob_module_sources(SOURCES "${opencv_core_BINARY_DIR}/version_string.inc" +ocv_glob_module_sources(SOURCES "${OPENCV_MODULE_opencv_core_BINARY_DIR}/version_string.inc" HEADERS ${lib_cuda_hdrs} ${lib_cuda_hdrs_detail}) +ocv_module_include_directories(${the_module} ${ZLIB_INCLUDE_DIRS}) ocv_create_module() -ocv_add_precompiled_headers(${the_module}) ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/core/perf/opencl/perf_arithm.cpp b/modules/core/perf/opencl/perf_arithm.cpp index 17badca76..9cb5ac982 100644 --- a/modules/core/perf/opencl/perf_arithm.cpp +++ b/modules/core/perf/opencl/perf_arithm.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/perf/opencl/perf_bufferpool.cpp b/modules/core/perf/opencl/perf_bufferpool.cpp index 2e01db404..3d241a6a5 100644 --- a/modules/core/perf/opencl/perf_bufferpool.cpp +++ b/modules/core/perf/opencl/perf_bufferpool.cpp @@ -4,7 +4,7 @@ // // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/perf/opencl/perf_channels.cpp b/modules/core/perf/opencl/perf_channels.cpp index 1dbad51a0..62d6b822b 100644 --- a/modules/core/perf/opencl/perf_channels.cpp +++ b/modules/core/perf/opencl/perf_channels.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/perf/opencl/perf_dxt.cpp b/modules/core/perf/opencl/perf_dxt.cpp index c0e41485e..8a45a8c1a 100644 --- a/modules/core/perf/opencl/perf_dxt.cpp +++ b/modules/core/perf/opencl/perf_dxt.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/perf/opencl/perf_gemm.cpp b/modules/core/perf/opencl/perf_gemm.cpp index 700f38049..205062dac 100644 --- a/modules/core/perf/opencl/perf_gemm.cpp +++ b/modules/core/perf/opencl/perf_gemm.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/perf/opencl/perf_matop.cpp b/modules/core/perf/opencl/perf_matop.cpp index 67d382239..0fd5d437c 100644 --- a/modules/core/perf/opencl/perf_matop.cpp +++ b/modules/core/perf/opencl/perf_matop.cpp @@ -5,7 +5,7 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/perf/opencl/perf_usage_flags.cpp b/modules/core/perf/opencl/perf_usage_flags.cpp index 3f59fec8b..b140e3a04 100644 --- a/modules/core/perf/opencl/perf_usage_flags.cpp +++ b/modules/core/perf/opencl/perf_usage_flags.cpp @@ -4,7 +4,7 @@ // // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/src/arithm.cpp b/modules/core/src/arithm.cpp index 2211fcd36..b8ecfdd68 100644 --- a/modules/core/src/arithm.cpp +++ b/modules/core/src/arithm.cpp @@ -47,7 +47,7 @@ // */ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" namespace cv { diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index d6abaa4ad..fc29b2e1f 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" namespace cv { @@ -50,6 +50,71 @@ namespace cv * split & merge * \****************************************************************************************/ +#if CV_NEON +template struct VSplit2; +template struct VSplit3; +template struct VSplit4; + +#define SPLIT2_KERNEL_TEMPLATE(name, data_type, reg_type, load_func, store_func) \ + template<> \ + struct name{ \ + void operator()(const data_type* src, data_type* dst0, data_type* dst1){ \ + reg_type r = load_func(src); \ + store_func(dst0, r.val[0]); \ + store_func(dst1, r.val[1]); \ + } \ + } + +#define SPLIT3_KERNEL_TEMPLATE(name, data_type, reg_type, load_func, store_func) \ + template<> \ + struct name{ \ + void operator()(const data_type* src, data_type* dst0, data_type* dst1, \ + data_type* dst2){ \ + reg_type r = load_func(src); \ + store_func(dst0, r.val[0]); \ + store_func(dst1, r.val[1]); \ + store_func(dst2, r.val[2]); \ + } \ + } + +#define SPLIT4_KERNEL_TEMPLATE(name, data_type, reg_type, load_func, store_func) \ + template<> \ + struct name{ \ + void operator()(const data_type* src, data_type* dst0, data_type* dst1, \ + data_type* dst2, data_type* dst3){ \ + reg_type r = load_func(src); \ + store_func(dst0, r.val[0]); \ + store_func(dst1, r.val[1]); \ + store_func(dst2, r.val[2]); \ + store_func(dst3, r.val[3]); \ + } \ + } + +SPLIT2_KERNEL_TEMPLATE(VSplit2, uchar , uint8x16x2_t, vld2q_u8 , vst1q_u8 ); +SPLIT2_KERNEL_TEMPLATE(VSplit2, schar , int8x16x2_t, vld2q_s8 , vst1q_s8 ); +SPLIT2_KERNEL_TEMPLATE(VSplit2, ushort, uint16x8x2_t, vld2q_u16, vst1q_u16); +SPLIT2_KERNEL_TEMPLATE(VSplit2, short , int16x8x2_t, vld2q_s16, vst1q_s16); +SPLIT2_KERNEL_TEMPLATE(VSplit2, int , int32x4x2_t, vld2q_s32, vst1q_s32); +SPLIT2_KERNEL_TEMPLATE(VSplit2, float , float32x4x2_t, vld2q_f32, vst1q_f32); +SPLIT2_KERNEL_TEMPLATE(VSplit2, int64 , int64x1x2_t, vld2_s64 , vst1_s64 ); + +SPLIT3_KERNEL_TEMPLATE(VSplit3, uchar , uint8x16x3_t, vld3q_u8 , vst1q_u8 ); +SPLIT3_KERNEL_TEMPLATE(VSplit3, schar , int8x16x3_t, vld3q_s8 , vst1q_s8 ); +SPLIT3_KERNEL_TEMPLATE(VSplit3, ushort, uint16x8x3_t, vld3q_u16, vst1q_u16); +SPLIT3_KERNEL_TEMPLATE(VSplit3, short , int16x8x3_t, vld3q_s16, vst1q_s16); +SPLIT3_KERNEL_TEMPLATE(VSplit3, int , int32x4x3_t, vld3q_s32, vst1q_s32); +SPLIT3_KERNEL_TEMPLATE(VSplit3, float , float32x4x3_t, vld3q_f32, vst1q_f32); +SPLIT3_KERNEL_TEMPLATE(VSplit3, int64 , int64x1x3_t, vld3_s64 , vst1_s64 ); + +SPLIT4_KERNEL_TEMPLATE(VSplit4, uchar , uint8x16x4_t, vld4q_u8 , vst1q_u8 ); +SPLIT4_KERNEL_TEMPLATE(VSplit4, schar , int8x16x4_t, vld4q_s8 , vst1q_s8 ); +SPLIT4_KERNEL_TEMPLATE(VSplit4, ushort, uint16x8x4_t, vld4q_u16, vst1q_u16); +SPLIT4_KERNEL_TEMPLATE(VSplit4, short , int16x8x4_t, vld4q_s16, vst1q_s16); +SPLIT4_KERNEL_TEMPLATE(VSplit4, int , int32x4x4_t, vld4q_s32, vst1q_s32); +SPLIT4_KERNEL_TEMPLATE(VSplit4, float , float32x4x4_t, vld4q_f32, vst1q_f32); +SPLIT4_KERNEL_TEMPLATE(VSplit4, int64 , int64x1x4_t, vld4_s64 , vst1_s64 ); +#endif + template static void split_( const T* src, T** dst, int len, int cn ) { @@ -58,13 +123,34 @@ split_( const T* src, T** dst, int len, int cn ) if( k == 1 ) { T* dst0 = dst[0]; - for( i = j = 0; i < len; i++, j += cn ) - dst0[i] = src[j]; + + if(cn == 1) + { + memcpy(dst0, src, len * sizeof(T)); + } + else + { + for( i = 0, j = 0 ; i < len; i++, j += cn ) + dst0[i] = src[j]; + } } else if( k == 2 ) { T *dst0 = dst[0], *dst1 = dst[1]; - for( i = j = 0; i < len; i++, j += cn ) + i = j = 0; + +#if CV_NEON + if(cn == 2) + { + int inc_i = (sizeof(T) == 8)? 1: 16/sizeof(T); + int inc_j = 2 * inc_i; + + VSplit2 vsplit; + for( ; i < len - inc_i; i += inc_i, j += inc_j) + vsplit(src + j, dst0 + i, dst1 + i); + } +#endif + for( ; i < len; i++, j += cn ) { dst0[i] = src[j]; dst1[i] = src[j+1]; @@ -73,7 +159,20 @@ split_( const T* src, T** dst, int len, int cn ) else if( k == 3 ) { T *dst0 = dst[0], *dst1 = dst[1], *dst2 = dst[2]; - for( i = j = 0; i < len; i++, j += cn ) + i = j = 0; + +#if CV_NEON + if(cn == 3) + { + int inc_i = (sizeof(T) == 8)? 1: 16/sizeof(T); + int inc_j = 3 * inc_i; + + VSplit3 vsplit; + for( ; i < len - inc_i; i += inc_i, j += inc_j) + vsplit(src + j, dst0 + i, dst1 + i, dst2 + i); + } +#endif + for( ; i < len; i++, j += cn ) { dst0[i] = src[j]; dst1[i] = src[j+1]; @@ -83,7 +182,20 @@ split_( const T* src, T** dst, int len, int cn ) else { T *dst0 = dst[0], *dst1 = dst[1], *dst2 = dst[2], *dst3 = dst[3]; - for( i = j = 0; i < len; i++, j += cn ) + i = j = 0; + +#if CV_NEON + if(cn == 4) + { + int inc_i = (sizeof(T) == 8)? 1: 16/sizeof(T); + int inc_j = 4 * inc_i; + + VSplit4 vsplit; + for( ; i < len - inc_i; i += inc_i, j += inc_j) + vsplit(src + j, dst0 + i, dst1 + i, dst2 + i, dst3 + i); + } +#endif + for( ; i < len; i++, j += cn ) { dst0[i] = src[j]; dst1[i] = src[j+1]; dst2[i] = src[j+2]; dst3[i] = src[j+3]; @@ -101,6 +213,77 @@ split_( const T* src, T** dst, int len, int cn ) } } + +#if CV_NEON +template struct VMerge2; +template struct VMerge3; +template struct VMerge4; + +#define MERGE2_KERNEL_TEMPLATE(name, data_type, reg_type, load_func, store_func) \ + template<> \ + struct name{ \ + void operator()(const data_type* src0, const data_type* src1, \ + data_type* dst){ \ + reg_type r; \ + r.val[0] = load_func(src0); \ + r.val[1] = load_func(src1); \ + store_func(dst, r); \ + } \ + } + +#define MERGE3_KERNEL_TEMPLATE(name, data_type, reg_type, load_func, store_func) \ + template<> \ + struct name{ \ + void operator()(const data_type* src0, const data_type* src1, \ + const data_type* src2, data_type* dst){ \ + reg_type r; \ + r.val[0] = load_func(src0); \ + r.val[1] = load_func(src1); \ + r.val[2] = load_func(src2); \ + store_func(dst, r); \ + } \ + } + +#define MERGE4_KERNEL_TEMPLATE(name, data_type, reg_type, load_func, store_func) \ + template<> \ + struct name{ \ + void operator()(const data_type* src0, const data_type* src1, \ + const data_type* src2, const data_type* src3, \ + data_type* dst){ \ + reg_type r; \ + r.val[0] = load_func(src0); \ + r.val[1] = load_func(src1); \ + r.val[2] = load_func(src2); \ + r.val[3] = load_func(src3); \ + store_func(dst, r); \ + } \ + } + +MERGE2_KERNEL_TEMPLATE(VMerge2, uchar , uint8x16x2_t, vld1q_u8 , vst2q_u8 ); +MERGE2_KERNEL_TEMPLATE(VMerge2, schar , int8x16x2_t, vld1q_s8 , vst2q_s8 ); +MERGE2_KERNEL_TEMPLATE(VMerge2, ushort, uint16x8x2_t, vld1q_u16, vst2q_u16); +MERGE2_KERNEL_TEMPLATE(VMerge2, short , int16x8x2_t, vld1q_s16, vst2q_s16); +MERGE2_KERNEL_TEMPLATE(VMerge2, int , int32x4x2_t, vld1q_s32, vst2q_s32); +MERGE2_KERNEL_TEMPLATE(VMerge2, float , float32x4x2_t, vld1q_f32, vst2q_f32); +MERGE2_KERNEL_TEMPLATE(VMerge2, int64 , int64x1x2_t, vld1_s64 , vst2_s64 ); + +MERGE3_KERNEL_TEMPLATE(VMerge3, uchar , uint8x16x3_t, vld1q_u8 , vst3q_u8 ); +MERGE3_KERNEL_TEMPLATE(VMerge3, schar , int8x16x3_t, vld1q_s8 , vst3q_s8 ); +MERGE3_KERNEL_TEMPLATE(VMerge3, ushort, uint16x8x3_t, vld1q_u16, vst3q_u16); +MERGE3_KERNEL_TEMPLATE(VMerge3, short , int16x8x3_t, vld1q_s16, vst3q_s16); +MERGE3_KERNEL_TEMPLATE(VMerge3, int , int32x4x3_t, vld1q_s32, vst3q_s32); +MERGE3_KERNEL_TEMPLATE(VMerge3, float , float32x4x3_t, vld1q_f32, vst3q_f32); +MERGE3_KERNEL_TEMPLATE(VMerge3, int64 , int64x1x3_t, vld1_s64 , vst3_s64 ); + +MERGE4_KERNEL_TEMPLATE(VMerge4, uchar , uint8x16x4_t, vld1q_u8 , vst4q_u8 ); +MERGE4_KERNEL_TEMPLATE(VMerge4, schar , int8x16x4_t, vld1q_s8 , vst4q_s8 ); +MERGE4_KERNEL_TEMPLATE(VMerge4, ushort, uint16x8x4_t, vld1q_u16, vst4q_u16); +MERGE4_KERNEL_TEMPLATE(VMerge4, short , int16x8x4_t, vld1q_s16, vst4q_s16); +MERGE4_KERNEL_TEMPLATE(VMerge4, int , int32x4x4_t, vld1q_s32, vst4q_s32); +MERGE4_KERNEL_TEMPLATE(VMerge4, float , float32x4x4_t, vld1q_f32, vst4q_f32); +MERGE4_KERNEL_TEMPLATE(VMerge4, int64 , int64x1x4_t, vld1_s64 , vst4_s64 ); +#endif + template static void merge_( const T** src, T* dst, int len, int cn ) { @@ -115,7 +298,19 @@ merge_( const T** src, T* dst, int len, int cn ) else if( k == 2 ) { const T *src0 = src[0], *src1 = src[1]; - for( i = j = 0; i < len; i++, j += cn ) + i = j = 0; +#if CV_NEON + if(cn == 2) + { + int inc_i = (sizeof(T) == 8)? 1: 16/sizeof(T); + int inc_j = 2 * inc_i; + + VMerge2 vmerge; + for( ; i < len - inc_i; i += inc_i, j += inc_j) + vmerge(src0 + i, src1 + i, dst + j); + } +#endif + for( ; i < len; i++, j += cn ) { dst[j] = src0[i]; dst[j+1] = src1[i]; @@ -124,7 +319,19 @@ merge_( const T** src, T* dst, int len, int cn ) else if( k == 3 ) { const T *src0 = src[0], *src1 = src[1], *src2 = src[2]; - for( i = j = 0; i < len; i++, j += cn ) + i = j = 0; +#if CV_NEON + if(cn == 3) + { + int inc_i = (sizeof(T) == 8)? 1: 16/sizeof(T); + int inc_j = 3 * inc_i; + + VMerge3 vmerge; + for( ; i < len - inc_i; i += inc_i, j += inc_j) + vmerge(src0 + i, src1 + i, src2 + i, dst + j); + } +#endif + for( ; i < len; i++, j += cn ) { dst[j] = src0[i]; dst[j+1] = src1[i]; @@ -134,7 +341,19 @@ merge_( const T** src, T* dst, int len, int cn ) else { const T *src0 = src[0], *src1 = src[1], *src2 = src[2], *src3 = src[3]; - for( i = j = 0; i < len; i++, j += cn ) + i = j = 0; +#if CV_NEON + if(cn == 4) + { + int inc_i = (sizeof(T) == 8)? 1: 16/sizeof(T); + int inc_j = 4 * inc_i; + + VMerge4 vmerge; + for( ; i < len - inc_i; i += inc_i, j += inc_j) + vmerge(src0 + i, src1 + i, src2 + i, src3 + i, dst + j); + } +#endif + for( ; i < len; i++, j += cn ) { dst[j] = src0[i]; dst[j+1] = src1[i]; dst[j+2] = src2[i]; dst[j+3] = src3[i]; diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 8bd2f457d..2bd6ebb9d 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -46,7 +46,7 @@ // */ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" namespace cv { diff --git a/modules/core/src/dxt.cpp b/modules/core/src/dxt.cpp index bbe0f7400..c1551acb4 100644 --- a/modules/core/src/dxt.cpp +++ b/modules/core/src/dxt.cpp @@ -42,7 +42,7 @@ #include "precomp.hpp" #include "opencv2/core/opencl/runtime/opencl_clamdfft.hpp" #include "opencv2/core/opencl/runtime/opencl_core.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" #include namespace cv diff --git a/modules/core/src/mathfuncs.cpp b/modules/core/src/mathfuncs.cpp index f36e268d0..6c6ed6b1c 100644 --- a/modules/core/src/mathfuncs.cpp +++ b/modules/core/src/mathfuncs.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" namespace cv { diff --git a/modules/core/src/matmul.cpp b/modules/core/src/matmul.cpp index 2ef44179d..b3c04a6bf 100644 --- a/modules/core/src/matmul.cpp +++ b/modules/core/src/matmul.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" #include "opencv2/core/opencl/runtime/opencl_clamdblas.hpp" namespace cv diff --git a/modules/core/src/matrix.cpp b/modules/core/src/matrix.cpp index 398abcaaa..46c8eeac8 100644 --- a/modules/core/src/matrix.cpp +++ b/modules/core/src/matrix.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" #include "bufferpool.impl.hpp" diff --git a/modules/core/src/opencl/runtime/opencl_clamdblas.cpp b/modules/core/src/opencl/runtime/opencl_clamdblas.cpp index 420fdb97d..379929993 100644 --- a/modules/core/src/opencl/runtime/opencl_clamdblas.cpp +++ b/modules/core/src/opencl/runtime/opencl_clamdblas.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "../../precomp.hpp" #ifdef HAVE_CLAMDBLAS diff --git a/modules/core/src/opencl/runtime/opencl_clamdfft.cpp b/modules/core/src/opencl/runtime/opencl_clamdfft.cpp index 36a9ed2a7..255bcd826 100644 --- a/modules/core/src/opencl/runtime/opencl_clamdfft.cpp +++ b/modules/core/src/opencl/runtime/opencl_clamdfft.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "../../precomp.hpp" #ifdef HAVE_CLAMDFFT diff --git a/modules/core/src/opencl/runtime/opencl_core.cpp b/modules/core/src/opencl/runtime/opencl_core.cpp index 5dbc85ec1..93f6aae5d 100644 --- a/modules/core/src/opencl/runtime/opencl_core.cpp +++ b/modules/core/src/opencl/runtime/opencl_core.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "precomp.hpp" +#include "../../precomp.hpp" #if defined(HAVE_OPENCL) && !defined(HAVE_OPENCL_STATIC) diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index 26bae7a44..7abbde543 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -44,7 +44,7 @@ #include #include -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" namespace cv { diff --git a/modules/core/src/umatrix.cpp b/modules/core/src/umatrix.cpp index 60f547794..494f3e3c0 100644 --- a/modules/core/src/umatrix.cpp +++ b/modules/core/src/umatrix.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_core.hpp" ///////////////////////////////// UMat implementation /////////////////////////////// diff --git a/modules/core/test/ocl/test_arithm.cpp b/modules/core/test/ocl/test_arithm.cpp index b0905b19f..3af01f3d5 100644 --- a/modules/core/test/ocl/test_arithm.cpp +++ b/modules/core/test/ocl/test_arithm.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #include diff --git a/modules/core/test/ocl/test_channels.cpp b/modules/core/test/ocl/test_channels.cpp index 53d7de5d5..2a07bc108 100644 --- a/modules/core/test/ocl/test_channels.cpp +++ b/modules/core/test/ocl/test_channels.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/test/ocl/test_dft.cpp b/modules/core/test/ocl/test_dft.cpp index cd0c1f07d..db280f19c 100644 --- a/modules/core/test/ocl/test_dft.cpp +++ b/modules/core/test/ocl/test_dft.cpp @@ -43,7 +43,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/test/ocl/test_gemm.cpp b/modules/core/test/ocl/test_gemm.cpp index e92fc2a1c..e98135a3d 100644 --- a/modules/core/test/ocl/test_gemm.cpp +++ b/modules/core/test/ocl/test_gemm.cpp @@ -42,7 +42,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/test/ocl/test_matrix_expr.cpp b/modules/core/test/ocl/test_matrix_expr.cpp index 167026d8c..b8448fb50 100644 --- a/modules/core/test/ocl/test_matrix_expr.cpp +++ b/modules/core/test/ocl/test_matrix_expr.cpp @@ -5,7 +5,7 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/core/test/ocl/test_matrix_operation.cpp b/modules/core/test/ocl/test_matrix_operation.cpp index 252db01d1..b19b74f54 100644 --- a/modules/core/test/ocl/test_matrix_operation.cpp +++ b/modules/core/test/ocl/test_matrix_operation.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/cudaarithm/CMakeLists.txt b/modules/cudaarithm/CMakeLists.txt index c819ec928..b4708e723 100644 --- a/modules/cudaarithm/CMakeLists.txt +++ b/modules/cudaarithm/CMakeLists.txt @@ -23,7 +23,5 @@ endif() ocv_create_module(${extra_libs}) -ocv_add_precompiled_headers(${the_module}) - ocv_add_accuracy_tests(DEPENDS_ON opencv_imgproc) ocv_add_perf_tests(DEPENDS_ON opencv_imgproc) diff --git a/modules/cudacodec/CMakeLists.txt b/modules/cudacodec/CMakeLists.txt index 5d8f7327c..90599766a 100644 --- a/modules/cudacodec/CMakeLists.txt +++ b/modules/cudacodec/CMakeLists.txt @@ -23,7 +23,5 @@ endif() ocv_create_module(${extra_libs}) -ocv_add_precompiled_headers(${the_module}) - ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/cudev/test/CMakeLists.txt b/modules/cudev/test/CMakeLists.txt index 363970e4b..89213e236 100644 --- a/modules/cudev/test/CMakeLists.txt +++ b/modules/cudev/test/CMakeLists.txt @@ -29,7 +29,7 @@ if(OCV_DEPENDENCIES_FOUND) endforeach() CUDA_ADD_EXECUTABLE(${the_target} ${OPENCV_TEST_${the_module}_SOURCES}) - target_link_libraries(${the_target} ${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES}) + ocv_target_link_libraries(${the_target} ${test_deps} ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES}) add_dependencies(opencv_tests ${the_target}) # Additional target properties diff --git a/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp b/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp index 2e6e57416..2cb8daabf 100644 --- a/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp +++ b/modules/features2d/perf/opencl/perf_brute_force_matcher.cpp @@ -43,7 +43,7 @@ // the use of this software, even if advised of the possibility of such damage. // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/features2d/perf/opencl/perf_fast.cpp b/modules/features2d/perf/opencl/perf_fast.cpp index 7816da7b1..c4a8e078c 100644 --- a/modules/features2d/perf/opencl/perf_fast.cpp +++ b/modules/features2d/perf/opencl/perf_fast.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/features2d/perf/opencl/perf_orb.cpp b/modules/features2d/perf/opencl/perf_orb.cpp index f40b5f4b9..c551dee88 100644 --- a/modules/features2d/perf/opencl/perf_orb.cpp +++ b/modules/features2d/perf/opencl/perf_orb.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/features2d/src/fast.cpp b/modules/features2d/src/fast.cpp index c01cbba69..79b6d6cef 100644 --- a/modules/features2d/src/fast.cpp +++ b/modules/features2d/src/fast.cpp @@ -43,7 +43,7 @@ The references are: #include "precomp.hpp" #include "fast_score.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_features2d.hpp" #if defined _MSC_VER # pragma warning( disable : 4127) diff --git a/modules/features2d/src/kaze/AKAZEConfig.h b/modules/features2d/src/kaze/AKAZEConfig.h index c7ac1cfc0..e2ba51c53 100644 --- a/modules/features2d/src/kaze/AKAZEConfig.h +++ b/modules/features2d/src/kaze/AKAZEConfig.h @@ -10,7 +10,7 @@ /* ************************************************************************* */ // OpenCV -#include "precomp.hpp" +#include "../precomp.hpp" #include /* ************************************************************************* */ diff --git a/modules/features2d/src/kaze/AKAZEFeatures.h b/modules/features2d/src/kaze/AKAZEFeatures.h index f8ce7a488..9119c97f2 100644 --- a/modules/features2d/src/kaze/AKAZEFeatures.h +++ b/modules/features2d/src/kaze/AKAZEFeatures.h @@ -11,7 +11,7 @@ /* ************************************************************************* */ // Includes -#include "precomp.hpp" +#include "../precomp.hpp" #include "AKAZEConfig.h" #include "TEvolution.h" diff --git a/modules/features2d/src/kaze/KAZEConfig.h b/modules/features2d/src/kaze/KAZEConfig.h index 21489a07a..546ee3657 100644 --- a/modules/features2d/src/kaze/KAZEConfig.h +++ b/modules/features2d/src/kaze/KAZEConfig.h @@ -9,7 +9,7 @@ #define __OPENCV_FEATURES_2D_AKAZE_CONFIG_H__ // OpenCV Includes -#include "precomp.hpp" +#include "../precomp.hpp" #include //************************************************************************************* diff --git a/modules/features2d/src/kaze/fed.cpp b/modules/features2d/src/kaze/fed.cpp index 7c2588559..cb47628e0 100644 --- a/modules/features2d/src/kaze/fed.cpp +++ b/modules/features2d/src/kaze/fed.cpp @@ -28,7 +28,7 @@ * DAGM, 2010 * */ -#include "precomp.hpp" +#include "../precomp.hpp" #include "fed.h" using namespace std; diff --git a/modules/features2d/src/kaze/nldiffusion_functions.h b/modules/features2d/src/kaze/nldiffusion_functions.h index 5c161a6e7..6665e5427 100644 --- a/modules/features2d/src/kaze/nldiffusion_functions.h +++ b/modules/features2d/src/kaze/nldiffusion_functions.h @@ -13,7 +13,7 @@ /* ************************************************************************* */ // Includes -#include "precomp.hpp" +#include "../precomp.hpp" /* ************************************************************************* */ // Declaration of functions diff --git a/modules/features2d/src/matchers.cpp b/modules/features2d/src/matchers.cpp index 2b5605031..1ae1340d1 100644 --- a/modules/features2d/src/matchers.cpp +++ b/modules/features2d/src/matchers.cpp @@ -41,7 +41,7 @@ #include "precomp.hpp" #include -#include "opencl_kernels.hpp" +#include "opencl_kernels_features2d.hpp" #if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 2 #include diff --git a/modules/features2d/src/orb.cpp b/modules/features2d/src/orb.cpp index 4fe9cbc23..57bce1ce4 100644 --- a/modules/features2d/src/orb.cpp +++ b/modules/features2d/src/orb.cpp @@ -35,7 +35,7 @@ /** Authors: Ethan Rublee, Vincent Rabaud, Gary Bradski */ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_features2d.hpp" #include //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// diff --git a/modules/features2d/test/ocl/test_brute_force_matcher.cpp b/modules/features2d/test/ocl/test_brute_force_matcher.cpp index 0e1df784f..635953307 100644 --- a/modules/features2d/test/ocl/test_brute_force_matcher.cpp +++ b/modules/features2d/test/ocl/test_brute_force_matcher.cpp @@ -48,7 +48,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "cvconfig.h" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/highgui/CMakeLists.txt b/modules/highgui/CMakeLists.txt index 78d6bfb09..de8c27ba3 100644 --- a/modules/highgui/CMakeLists.txt +++ b/modules/highgui/CMakeLists.txt @@ -17,21 +17,27 @@ if(APPLE) endif() set(highgui_hdrs - src/precomp.hpp + ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp ) set(highgui_srcs - src/window.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/window.cpp ) -file(GLOB highgui_ext_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") +file(GLOB highgui_ext_hdrs + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h") if(HAVE_QT5) set(CMAKE_AUTOMOC ON) set(CMAKE_INCLUDE_CURRENT_DIR ON) - QT5_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc) - list(APPEND highgui_srcs src/window_QT.cpp src/window_QT.h ${_RCC_OUTFILES}) + QT5_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc) + list(APPEND highgui_srcs + ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h + ${_RCC_OUTFILES}) foreach(dt5_dep Core Gui Widgets Test Concurrent) add_definitions(${Qt5${dt5_dep}_DEFINITIONS}) @@ -51,24 +57,24 @@ elseif(HAVE_QT) endif() include(${QT_USE_FILE}) - QT4_ADD_RESOURCES(_RCC_OUTFILES src/window_QT.qrc) - QT4_WRAP_CPP(_MOC_OUTFILES src/window_QT.h) + QT4_ADD_RESOURCES(_RCC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.qrc) + QT4_WRAP_CPP(_MOC_OUTFILES ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.h) list(APPEND HIGHGUI_LIBRARIES ${QT_LIBRARIES}) - list(APPEND highgui_srcs src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES}) + list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_QT.cpp ${_MOC_OUTFILES} ${_RCC_OUTFILES}) ocv_check_flag_support(CXX -Wno-missing-declarations _have_flag) if(${_have_flag}) set_source_files_properties(${_RCC_OUTFILES} PROPERTIES COMPILE_FLAGS -Wno-missing-declarations) endif() elseif(HAVE_WIN32UI) - list(APPEND highgui_srcs src/window_w32.cpp) + list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_w32.cpp) elseif(HAVE_GTK OR HAVE_GTK3) - list(APPEND highgui_srcs src/window_gtk.cpp) + list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_gtk.cpp) elseif(HAVE_CARBON) - list(APPEND highgui_srcs src/window_carbon.cpp) + list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_carbon.cpp) list(APPEND HIGHGUI_LIBRARIES "-framework Carbon" "-framework QuickTime") elseif(HAVE_COCOA) - list(APPEND highgui_srcs src/window_cocoa.mm) + list(APPEND highgui_srcs ${CMAKE_CURRENT_LIST_DIR}/src/window_cocoa.mm) list(APPEND HIGHGUI_LIBRARIES "-framework Cocoa") endif() @@ -90,6 +96,7 @@ ocv_module_include_directories() ocv_create_module(${HIGHGUI_LIBRARIES}) +macro(ocv_highgui_configure_target) if(APPLE) ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS) if(HAVE_OBJC_EXCEPTIONS) @@ -116,11 +123,17 @@ if(MSVC) set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG") endif() -#stop automatic dependencies propagation for this module -set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "") +if(NOT BUILD_opencv_world) + #stop automatic dependencies propagation for this module + set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "") +endif() -ocv_add_precompiled_headers(${the_module}) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations) +endmacro() + +if(NOT BUILD_opencv_world) + ocv_highgui_configure_target() +endif() ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/imgcodecs/CMakeLists.txt b/modules/imgcodecs/CMakeLists.txt index 8cf60e546..5ef34da53 100644 --- a/modules/imgcodecs/CMakeLists.txt +++ b/modules/imgcodecs/CMakeLists.txt @@ -50,30 +50,34 @@ if(HAVE_OPENEXR) list(APPEND GRFMT_LIBS ${OPENEXR_LIBRARIES}) endif() -file(GLOB grfmt_hdrs src/grfmt*.hpp) -file(GLOB grfmt_srcs src/grfmt*.cpp) -list(APPEND grfmt_hdrs src/bitstrm.hpp) -list(APPEND grfmt_srcs src/bitstrm.cpp) -list(APPEND grfmt_hdrs src/rgbe.hpp) -list(APPEND grfmt_srcs src/rgbe.cpp) +file(GLOB grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.hpp) +file(GLOB grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/grfmt*.cpp) +list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.hpp) +list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/bitstrm.cpp) +list(APPEND grfmt_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.hpp) +list(APPEND grfmt_srcs ${CMAKE_CURRENT_LIST_DIR}/src/rgbe.cpp) source_group("Src\\grfmts" FILES ${grfmt_hdrs} ${grfmt_srcs}) set(imgcodecs_hdrs - src/precomp.hpp - src/utils.hpp + ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp + ${CMAKE_CURRENT_LIST_DIR}/src/utils.hpp ) set(imgcodecs_srcs - src/loadsave.cpp - src/utils.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/loadsave.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/utils.cpp ) -file(GLOB imgcodecs_ext_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") +file(GLOB imgcodecs_ext_hdrs + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.hpp" + "${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/*.h" + ) if(IOS) add_definitions(-DHAVE_IOS=1) - list(APPEND imgcodecs_srcs src/ios_conversions.mm) + list(APPEND imgcodecs_srcs ${CMAKE_CURRENT_LIST_DIR}/src/ios_conversions.mm) list(APPEND IMGCODECS_LIBRARIES "-framework Accelerate" "-framework CoreGraphics" "-framework CoreImage" "-framework QuartzCore" "-framework AssetsLibrary") endif() @@ -95,6 +99,7 @@ ocv_module_include_directories() ocv_create_module(${GRFMT_LIBS} ${IMGCODECS_LIBRARIES}) +macro(ocv_imgcodecs_configure_target) if(APPLE) ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS) if(HAVE_OBJC_EXCEPTIONS) @@ -124,8 +129,12 @@ endif() #stop automatic dependencies propagation for this module set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "") -ocv_add_precompiled_headers(${the_module}) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations) +endmacro() + +if(NOT BUILD_opencv_world) + ocv_imgcodecs_configure_target() +endif() ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/imgproc/perf/opencl/perf_3vs4.cpp b/modules/imgproc/perf/opencl/perf_3vs4.cpp index f6601e123..940a5ff63 100644 --- a/modules/imgproc/perf/opencl/perf_3vs4.cpp +++ b/modules/imgproc/perf/opencl/perf_3vs4.cpp @@ -5,7 +5,7 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_accumulate.cpp b/modules/imgproc/perf/opencl/perf_accumulate.cpp index 5b7ac4c75..e0ba471b9 100644 --- a/modules/imgproc/perf/opencl/perf_accumulate.cpp +++ b/modules/imgproc/perf/opencl/perf_accumulate.cpp @@ -43,7 +43,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_blend.cpp b/modules/imgproc/perf/opencl/perf_blend.cpp index f595069bd..6396fef7e 100644 --- a/modules/imgproc/perf/opencl/perf_blend.cpp +++ b/modules/imgproc/perf/opencl/perf_blend.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_color.cpp b/modules/imgproc/perf/opencl/perf_color.cpp index 4a30f3a1f..14dd61490 100644 --- a/modules/imgproc/perf/opencl/perf_color.cpp +++ b/modules/imgproc/perf/opencl/perf_color.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_filters.cpp b/modules/imgproc/perf/opencl/perf_filters.cpp index 9667b8f90..ede98c308 100644 --- a/modules/imgproc/perf/opencl/perf_filters.cpp +++ b/modules/imgproc/perf/opencl/perf_filters.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_gftt.cpp b/modules/imgproc/perf/opencl/perf_gftt.cpp index 29626c62e..b6c3b2c36 100644 --- a/modules/imgproc/perf/opencl/perf_gftt.cpp +++ b/modules/imgproc/perf/opencl/perf_gftt.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #include diff --git a/modules/imgproc/perf/opencl/perf_imgproc.cpp b/modules/imgproc/perf/opencl/perf_imgproc.cpp index 7f0770853..f441bd9b3 100644 --- a/modules/imgproc/perf/opencl/perf_imgproc.cpp +++ b/modules/imgproc/perf/opencl/perf_imgproc.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_imgwarp.cpp b/modules/imgproc/perf/opencl/perf_imgwarp.cpp index b5a5138e2..d6832aec5 100644 --- a/modules/imgproc/perf/opencl/perf_imgwarp.cpp +++ b/modules/imgproc/perf/opencl/perf_imgwarp.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_matchTemplate.cpp b/modules/imgproc/perf/opencl/perf_matchTemplate.cpp index db9199b87..d230f9046 100644 --- a/modules/imgproc/perf/opencl/perf_matchTemplate.cpp +++ b/modules/imgproc/perf/opencl/perf_matchTemplate.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_moments.cpp b/modules/imgproc/perf/opencl/perf_moments.cpp index e77b76850..69a3e6835 100644 --- a/modules/imgproc/perf/opencl/perf_moments.cpp +++ b/modules/imgproc/perf/opencl/perf_moments.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/perf/opencl/perf_pyramid.cpp b/modules/imgproc/perf/opencl/perf_pyramid.cpp index 8bbc3184f..f26fd1940 100644 --- a/modules/imgproc/perf/opencl/perf_pyramid.cpp +++ b/modules/imgproc/perf/opencl/perf_pyramid.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/src/accum.cpp b/modules/imgproc/src/accum.cpp index 04a70128b..1a4b4080e 100644 --- a/modules/imgproc/src/accum.cpp +++ b/modules/imgproc/src/accum.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" namespace cv { diff --git a/modules/imgproc/src/blend.cpp b/modules/imgproc/src/blend.cpp index 4fbdff9c3..7a2e57d52 100644 --- a/modules/imgproc/src/blend.cpp +++ b/modules/imgproc/src/blend.cpp @@ -44,7 +44,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" namespace cv { diff --git a/modules/imgproc/src/canny.cpp b/modules/imgproc/src/canny.cpp index 2a87ae05b..09898a539 100644 --- a/modules/imgproc/src/canny.cpp +++ b/modules/imgproc/src/canny.cpp @@ -40,7 +40,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) diff --git a/modules/imgproc/src/clahe.cpp b/modules/imgproc/src/clahe.cpp index f19f19243..1a2674425 100644 --- a/modules/imgproc/src/clahe.cpp +++ b/modules/imgproc/src/clahe.cpp @@ -40,7 +40,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" // ---------------------------------------------------------------------- // CLAHE diff --git a/modules/imgproc/src/color.cpp b/modules/imgproc/src/color.cpp index 351ee74e4..db5bcd35f 100644 --- a/modules/imgproc/src/color.cpp +++ b/modules/imgproc/src/color.cpp @@ -90,7 +90,7 @@ \**********************************************************************************/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" #include #define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n)) diff --git a/modules/imgproc/src/corner.cpp b/modules/imgproc/src/corner.cpp index 923d78b30..1fdd047cd 100644 --- a/modules/imgproc/src/corner.cpp +++ b/modules/imgproc/src/corner.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" namespace cv { diff --git a/modules/imgproc/src/deriv.cpp b/modules/imgproc/src/deriv.cpp index 1a29c38ab..80b1e9b33 100644 --- a/modules/imgproc/src/deriv.cpp +++ b/modules/imgproc/src/deriv.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) static IppStatus sts = ippInit(); diff --git a/modules/imgproc/src/featureselect.cpp b/modules/imgproc/src/featureselect.cpp index 54bb65fff..a50b704e8 100644 --- a/modules/imgproc/src/featureselect.cpp +++ b/modules/imgproc/src/featureselect.cpp @@ -40,7 +40,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" #include #include diff --git a/modules/imgproc/src/filter.cpp b/modules/imgproc/src/filter.cpp index 6c0da79cc..4928a16d2 100644 --- a/modules/imgproc/src/filter.cpp +++ b/modules/imgproc/src/filter.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" /****************************************************************************************\ Base Image Filter diff --git a/modules/imgproc/src/histogram.cpp b/modules/imgproc/src/histogram.cpp index b38ddcad0..1006897e4 100644 --- a/modules/imgproc/src/histogram.cpp +++ b/modules/imgproc/src/histogram.cpp @@ -40,7 +40,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" namespace cv { diff --git a/modules/imgproc/src/imgwarp.cpp b/modules/imgproc/src/imgwarp.cpp index 1d16bcc3f..907fa445d 100644 --- a/modules/imgproc/src/imgwarp.cpp +++ b/modules/imgproc/src/imgwarp.cpp @@ -47,7 +47,7 @@ // */ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) static IppStatus sts = ippInit(); diff --git a/modules/imgproc/src/moments.cpp b/modules/imgproc/src/moments.cpp index a61002a79..b114264e3 100644 --- a/modules/imgproc/src/moments.cpp +++ b/modules/imgproc/src/moments.cpp @@ -39,7 +39,7 @@ // //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" namespace cv { diff --git a/modules/imgproc/src/morph.cpp b/modules/imgproc/src/morph.cpp index 520d26d6c..8985a7f06 100644 --- a/modules/imgproc/src/morph.cpp +++ b/modules/imgproc/src/morph.cpp @@ -42,7 +42,7 @@ #include "precomp.hpp" #include -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" /****************************************************************************************\ Basic Morphological Operations: Erosion & Dilation diff --git a/modules/imgproc/src/opencl/match_template.cl b/modules/imgproc/src/opencl/match_template.cl index 1919e8edd..c6c9468e8 100644 --- a/modules/imgproc/src/opencl/match_template.cl +++ b/modules/imgproc/src/opencl/match_template.cl @@ -90,11 +90,8 @@ __kernel void calcSum(__global const uchar * srcptr, int src_step, int src_offse T src = loadpix(srcptr + src_index); tmp = convertToWT(src); -#if wdepth == 4 - accumulator = mad24(tmp, tmp, accumulator); -#else + accumulator = mad(tmp, tmp, accumulator); -#endif } if (lid < WGS2_ALIGNED) @@ -165,11 +162,9 @@ __kernel void matchTemplate_Naive_CCORR(__global const uchar * srcptr, int src_s { T temp = (T)(template[j]); T src = *(__global const T*)(srcptr + ind + j*(int)sizeof(T1)); -#if wdepth == 4 - sum = mad24(convertToWT(src), convertToWT(temp), sum); -#else - sum = mad(convertToWT(src), convertToWT(temp), sum); -#endif + + sum = mad(convertToWT(src), convertToWT(temp), sum); + } ind += src_step; template = (__global const T1 *)((__global const uchar *)template + template_step); @@ -195,12 +190,7 @@ __kernel void matchTemplate_Naive_CCORR(__global const uchar * srcptr, int src_s #pragma unroll for (int cx=0, x = x0; cx < PIX_PER_WI_X && x < dst_cols; ++cx, ++x) { - -#if wdepth == 4 - sum[cx] = mad24(convertToWT1(src[j+cx]), convertToWT1(template[j]), sum[cx]); -#else sum[cx] = mad(convertToWT1(src[j+cx]), convertToWT1(template[j]), sum[cx]); -#endif } } @@ -237,11 +227,8 @@ __kernel void matchTemplate_Naive_CCORR(__global const uchar * srcptr, int src_s { T src = loadpix(srcptr + mad24(y+i, src_step, mad24(x+j, TSIZE, src_offset))); T template = loadpix(templateptr + mad24(i, template_step, mad24(j, TSIZE, template_offset))); -#if wdepth == 4 - sum = mad24(convertToWT(src), convertToWT(template), sum); -#else + sum = mad(convertToWT(src), convertToWT(template), sum); -#endif } } @@ -296,11 +283,8 @@ __kernel void matchTemplate_Naive_SQDIFF(__global const uchar * srcptr, int src_ T template = loadpix(templateptr + mad24(i, template_step, mad24(j, TSIZE, template_offset))); value = convertToWT(src) - convertToWT(template); -#if wdepth == 4 - sum = mad24(value, value, sum); -#else + sum = mad(value, value, sum); -#endif } } diff --git a/modules/imgproc/src/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index 2714e08f3..658eb4215 100644 --- a/modules/imgproc/src/pyramids.cpp +++ b/modules/imgproc/src/pyramids.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" namespace cv { diff --git a/modules/imgproc/src/smooth.cpp b/modules/imgproc/src/smooth.cpp index 907a6591b..7f2e31bdc 100644 --- a/modules/imgproc/src/smooth.cpp +++ b/modules/imgproc/src/smooth.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" /* * This file includes the code, contributed by Simon Perreault diff --git a/modules/imgproc/src/sumpixels.cpp b/modules/imgproc/src/sumpixels.cpp index e7694b01a..1c6f1513f 100755 --- a/modules/imgproc/src/sumpixels.cpp +++ b/modules/imgproc/src/sumpixels.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" #if defined (HAVE_IPP) && (IPP_VERSION_MAJOR >= 7) static IppStatus sts = ippInit(); diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 164af425e..df2e19cc4 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -40,7 +40,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" ////////////////////////////////////////////////// matchTemplate ////////////////////////////////////////////////////////// @@ -79,7 +79,7 @@ static bool extractFirstChannel_32F(InputArray _image, OutputArray _result, int static bool sumTemplate(InputArray _src, UMat & result) { int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); - int wdepth = std::max(CV_32S, depth), wtype = CV_MAKE_TYPE(wdepth, cn); + int wdepth = CV_32F, wtype = CV_MAKE_TYPE(wdepth, cn); size_t wgs = ocl::Device::getDefault().maxWorkGroupSize(); int wgs2_aligned = 1; @@ -89,10 +89,10 @@ static bool sumTemplate(InputArray _src, UMat & result) char cvt[40]; ocl::Kernel k("calcSum", ocl::imgproc::match_template_oclsrc, - format("-D CALC_SUM -D T=%s -D T1=%s -D WT=%s -D cn=%d -D convertToWT=%s -D WGS=%d -D WGS2_ALIGNED=%d -D wdepth=%d", + format("-D CALC_SUM -D T=%s -D T1=%s -D WT=%s -D cn=%d -D convertToWT=%s -D WGS=%d -D WGS2_ALIGNED=%d", ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype), cn, ocl::convertTypeStr(depth, wdepth, cn, cvt), - (int)wgs, wgs2_aligned, wdepth)); + (int)wgs, wgs2_aligned)); if (k.empty()) return false; @@ -110,12 +110,8 @@ static bool sumTemplate(InputArray _src, UMat & result) static bool useNaive(Size size) { - if (!ocl::Device::getDefault().isIntel()) - return true; - int dft_size = 18; return size.height < dft_size && size.width < dft_size; - } struct ConvolveBuf @@ -129,7 +125,6 @@ struct ConvolveBuf UMat image_block, templ_block, result_data; void create(Size image_size, Size templ_size); - static Size estimateBlockSize(Size result_size); }; void ConvolveBuf::create(Size image_size, Size templ_size) @@ -137,19 +132,26 @@ void ConvolveBuf::create(Size image_size, Size templ_size) result_size = Size(image_size.width - templ_size.width + 1, image_size.height - templ_size.height + 1); - block_size = user_block_size; - if (user_block_size.width == 0 || user_block_size.height == 0) - block_size = estimateBlockSize(result_size); + const double blockScale = 4.5; + const int minBlockSize = 256; - dft_size.width = 1 << int(ceil(std::log(block_size.width + templ_size.width - 1.) / std::log(2.))); - dft_size.height = 1 << int(ceil(std::log(block_size.height + templ_size.height - 1.) / std::log(2.))); + block_size.width = cvRound(result_size.width*blockScale); + block_size.width = std::max( block_size.width, minBlockSize - templ_size.width + 1 ); + block_size.width = std::min( block_size.width, result_size.width ); + block_size.height = cvRound(templ_size.height*blockScale); + block_size.height = std::max( block_size.height, minBlockSize - templ_size.height + 1 ); + block_size.height = std::min( block_size.height, result_size.height ); - dft_size.width = getOptimalDFTSize(block_size.width + templ_size.width - 1); + dft_size.width = std::max(getOptimalDFTSize(block_size.width + templ_size.width - 1), 2); dft_size.height = getOptimalDFTSize(block_size.height + templ_size.height - 1); + if( dft_size.width <= 0 || dft_size.height <= 0 ) + CV_Error( CV_StsOutOfRange, "the input arrays are too big" ); - // To avoid wasting time doing small DFTs - dft_size.width = std::max(dft_size.width, 512); - dft_size.height = std::max(dft_size.height, 512); + // recompute block size + block_size.width = dft_size.width - templ_size.width + 1; + block_size.width = std::min( block_size.width, result_size.width); + block_size.height = dft_size.height - templ_size.height + 1; + block_size.height = std::min( block_size.height, result_size.height ); image_block.create(dft_size, CV_32F); templ_block.create(dft_size, CV_32F); @@ -164,15 +166,6 @@ void ConvolveBuf::create(Size image_size, Size templ_size) block_size.height = std::min(dft_size.height - templ_size.height + 1, result_size.height); } -Size ConvolveBuf::estimateBlockSize(Size result_size) -{ - int width = (result_size.width + 2) / 3; - int height = (result_size.height + 2) / 3; - width = std::min(width, result_size.width); - height = std::min(height, result_size.height); - return Size(width, height); -} - static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _result) { ConvolveBuf buf; @@ -202,7 +195,7 @@ static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _resu copyMakeBorder(templ_roi, templ_block, 0, templ_block.rows - templ_roi.rows, 0, templ_block.cols - templ_roi.cols, BORDER_ISOLATED); - dft(templ_block, templ_spect, 0); + dft(templ_block, templ_spect, 0, templ.rows); // Process all blocks of the result matrix for (int y = 0; y < result.rows; y += block_size.height) @@ -281,8 +274,8 @@ static bool matchTemplateNaive_CCORR(InputArray _image, InputArray _templ, Outpu const char* convertToWT = ocl::convertTypeStr(depth, wdepth, rated_cn, cvt1); ocl::Kernel k("matchTemplate_Naive_CCORR", ocl::imgproc::match_template_oclsrc, - format("-D CCORR -D T=%s -D T1=%s -D WT=%s -D WT1=%s -D convertToWT=%s -D convertToWT1=%s -D cn=%d -D wdepth=%d -D PIX_PER_WI_X=%d", ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype1), ocl::typeToStr(wtype), - convertToWT, convertToWT1, cn, wdepth, pxPerWIx)); + format("-D CCORR -D T=%s -D T1=%s -D WT=%s -D WT1=%s -D convertToWT=%s -D convertToWT1=%s -D cn=%d -D PIX_PER_WI_X=%d", ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(wtype1), ocl::typeToStr(wtype), + convertToWT, convertToWT1, cn, pxPerWIx)); if (k.empty()) return false; @@ -358,8 +351,8 @@ static bool matchTemplateNaive_SQDIFF(InputArray _image, InputArray _templ, Outp char cvt[40]; ocl::Kernel k("matchTemplate_Naive_SQDIFF", ocl::imgproc::match_template_oclsrc, - format("-D SQDIFF -D T=%s -D T1=%s -D WT=%s -D convertToWT=%s -D cn=%d -D wdepth=%d", ocl::typeToStr(type), ocl::typeToStr(depth), - ocl::typeToStr(wtype), ocl::convertTypeStr(depth, wdepth, cn, cvt), cn, wdepth)); + format("-D SQDIFF -D T=%s -D T1=%s -D WT=%s -D convertToWT=%s -D cn=%d", ocl::typeToStr(type), ocl::typeToStr(depth), + ocl::typeToStr(wtype), ocl::convertTypeStr(depth, wdepth, cn, cvt), cn)); if (k.empty()) return false; diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 988fc9e9f..9376d62a5 100644 --- a/modules/imgproc/src/thresh.cpp +++ b/modules/imgproc/src/thresh.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_imgproc.hpp" namespace cv { diff --git a/modules/imgproc/test/ocl/test_accumulate.cpp b/modules/imgproc/test/ocl/test_accumulate.cpp index 50c9085cb..cebf173d5 100644 --- a/modules/imgproc/test/ocl/test_accumulate.cpp +++ b/modules/imgproc/test/ocl/test_accumulate.cpp @@ -43,7 +43,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "cvconfig.h" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/imgproc/test/ocl/test_blend.cpp b/modules/imgproc/test/ocl/test_blend.cpp index 6d8a15fb2..d64b0bae8 100644 --- a/modules/imgproc/test/ocl/test_blend.cpp +++ b/modules/imgproc/test/ocl/test_blend.cpp @@ -43,7 +43,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "cvconfig.h" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/imgproc/test/ocl/test_boxfilter.cpp b/modules/imgproc/test/ocl/test_boxfilter.cpp index 4940dff79..19a6ace75 100644 --- a/modules/imgproc/test/ocl/test_boxfilter.cpp +++ b/modules/imgproc/test/ocl/test_boxfilter.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_canny.cpp b/modules/imgproc/test/ocl/test_canny.cpp index 631fe5bd1..fadf77798 100644 --- a/modules/imgproc/test/ocl/test_canny.cpp +++ b/modules/imgproc/test/ocl/test_canny.cpp @@ -43,7 +43,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_color.cpp b/modules/imgproc/test/ocl/test_color.cpp index 5f3a2f73f..818d6a85a 100644 --- a/modules/imgproc/test/ocl/test_color.cpp +++ b/modules/imgproc/test/ocl/test_color.cpp @@ -43,7 +43,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_filter2d.cpp b/modules/imgproc/test/ocl/test_filter2d.cpp index 18ba4cc52..03a6bcff7 100644 --- a/modules/imgproc/test/ocl/test_filter2d.cpp +++ b/modules/imgproc/test/ocl/test_filter2d.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_filters.cpp b/modules/imgproc/test/ocl/test_filters.cpp index 61f38a6b8..35e4aa8f8 100644 --- a/modules/imgproc/test/ocl/test_filters.cpp +++ b/modules/imgproc/test/ocl/test_filters.cpp @@ -48,7 +48,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "cvconfig.h" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/imgproc/test/ocl/test_gftt.cpp b/modules/imgproc/test/ocl/test_gftt.cpp index 6e65f90dd..15618cc30 100644 --- a/modules/imgproc/test/ocl/test_gftt.cpp +++ b/modules/imgproc/test/ocl/test_gftt.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_histogram.cpp b/modules/imgproc/test/ocl/test_histogram.cpp index 68a2a60fd..e8813c85a 100644 --- a/modules/imgproc/test/ocl/test_histogram.cpp +++ b/modules/imgproc/test/ocl/test_histogram.cpp @@ -52,7 +52,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "cvconfig.h" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/imgproc/test/ocl/test_imgproc.cpp b/modules/imgproc/test/ocl/test_imgproc.cpp index ad8e26cbc..d89101799 100644 --- a/modules/imgproc/test/ocl/test_imgproc.cpp +++ b/modules/imgproc/test/ocl/test_imgproc.cpp @@ -51,7 +51,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "cvconfig.h" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/imgproc/test/ocl/test_match_template.cpp b/modules/imgproc/test/ocl/test_match_template.cpp index 8c8a1238c..a525039ac 100644 --- a/modules/imgproc/test/ocl/test_match_template.cpp +++ b/modules/imgproc/test/ocl/test_match_template.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #include "iostream" #include "fstream" diff --git a/modules/imgproc/test/ocl/test_medianfilter.cpp b/modules/imgproc/test/ocl/test_medianfilter.cpp index 6015ed1d7..74077f6db 100644 --- a/modules/imgproc/test/ocl/test_medianfilter.cpp +++ b/modules/imgproc/test/ocl/test_medianfilter.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_pyramids.cpp b/modules/imgproc/test/ocl/test_pyramids.cpp index a129c7f77..5ac88411d 100644 --- a/modules/imgproc/test/ocl/test_pyramids.cpp +++ b/modules/imgproc/test/ocl/test_pyramids.cpp @@ -44,7 +44,7 @@ //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_sepfilter2D.cpp b/modules/imgproc/test/ocl/test_sepfilter2D.cpp index f7a18aae1..ed42e8b4a 100644 --- a/modules/imgproc/test/ocl/test_sepfilter2D.cpp +++ b/modules/imgproc/test/ocl/test_sepfilter2D.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/imgproc/test/ocl/test_warp.cpp b/modules/imgproc/test/ocl/test_warp.cpp index 53d82187f..0bcc330c7 100644 --- a/modules/imgproc/test/ocl/test_warp.cpp +++ b/modules/imgproc/test/ocl/test_warp.cpp @@ -51,7 +51,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index 7d1acb93b..6eba20537 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -1,7 +1,9 @@ # ---------------------------------------------------------------------------- # CMake file for java support # ---------------------------------------------------------------------------- -if(IOS OR NOT PYTHON_DEFAULT_AVAILABLE OR NOT ANT_EXECUTABLE OR NOT (JNI_FOUND OR (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7))) +if(IOS OR NOT PYTHON_DEFAULT_AVAILABLE OR NOT ANT_EXECUTABLE OR NOT (JNI_FOUND OR (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7)) + OR BUILD_opencv_world + ) ocv_module_disable(java) endif() @@ -274,7 +276,7 @@ endif(ANDROID) # workarounding lack of `__attribute__ ((visibility("default")))` in jni_md.h/JNIEXPORT string(REPLACE "-fvisibility=hidden" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -add_library(${the_module} SHARED ${handwrittren_h_sources} ${handwrittren_cpp_sources} ${generated_cpp_sources} +ocv_add_library(${the_module} SHARED ${handwrittren_h_sources} ${handwrittren_cpp_sources} ${generated_cpp_sources} ${copied_files} "${JAR_FILE}" "${JAR_FILE}.dephelper") set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL) @@ -295,18 +297,18 @@ if(BUILD_FAT_JAVA_LIB) endif() if(APPLE) foreach(_dep ${__deps}) - target_link_libraries(${the_module} -Wl,-force_load "${_dep}") + ocv_target_link_libraries(${the_module} -Wl,-force_load "${_dep}") endforeach() else() - target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive) + ocv_target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive) endif() - target_link_libraries(${the_module} ${__extradeps} ${OPENCV_LINKER_LIBS}) + ocv_target_link_libraries(${the_module} ${__extradeps} ${OPENCV_LINKER_LIBS}) else() - target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS}) + ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS}) endif() if(ANDROID) - target_link_libraries(${the_module} jnigraphics) # for Mat <=> Bitmap converters + ocv_target_link_libraries(${the_module} jnigraphics) # for Mat <=> Bitmap converters # force strip library after the build command # because samples and tests will make a copy of the library before install diff --git a/modules/nonfree/src/surf.ocl.cpp b/modules/nonfree/src/surf.ocl.cpp index eaf50fbc7..f46fc500f 100644 --- a/modules/nonfree/src/surf.ocl.cpp +++ b/modules/nonfree/src/surf.ocl.cpp @@ -47,7 +47,7 @@ #include #include -#include "opencl_kernels.hpp" +#include "opencl_kernels_nonfree.hpp" namespace cv { diff --git a/modules/objdetect/perf/opencl/perf_cascades.cpp b/modules/objdetect/perf/opencl/perf_cascades.cpp index dd61cdb66..7cd1112a5 100644 --- a/modules/objdetect/perf/opencl/perf_cascades.cpp +++ b/modules/objdetect/perf/opencl/perf_cascades.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include #include "opencv2/ts/ocl_perf.hpp" diff --git a/modules/objdetect/perf/opencl/perf_hogdetect.cpp b/modules/objdetect/perf/opencl/perf_hogdetect.cpp index 36ab857c8..7c107a962 100644 --- a/modules/objdetect/perf/opencl/perf_hogdetect.cpp +++ b/modules/objdetect/perf/opencl/perf_hogdetect.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/objdetect/src/cascadedetect.cpp b/modules/objdetect/src/cascadedetect.cpp index 2d5c0795d..70311d91f 100644 --- a/modules/objdetect/src/cascadedetect.cpp +++ b/modules/objdetect/src/cascadedetect.cpp @@ -44,7 +44,7 @@ #include "cascadedetect.hpp" #include "opencv2/objdetect/objdetect_c.h" -#include "opencl_kernels.hpp" +#include "opencl_kernels_objdetect.hpp" namespace cv { diff --git a/modules/objdetect/src/hog.cpp b/modules/objdetect/src/hog.cpp index a84c00d05..7230954dc 100644 --- a/modules/objdetect/src/hog.cpp +++ b/modules/objdetect/src/hog.cpp @@ -42,7 +42,7 @@ #include "precomp.hpp" #include "opencv2/core/core_c.h" -#include "opencl_kernels.hpp" +#include "opencl_kernels_objdetect.hpp" #include #include diff --git a/modules/objdetect/test/opencl/test_hogdetector.cpp b/modules/objdetect/test/opencl/test_hogdetector.cpp index b3ef6b48f..eb666cb1c 100644 --- a/modules/objdetect/test/opencl/test_hogdetector.cpp +++ b/modules/objdetect/test/opencl/test_hogdetector.cpp @@ -50,7 +50,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/photo/perf/opencl/perf_denoising.cpp b/modules/photo/perf/opencl/perf_denoising.cpp index a2ee9178a..14ffa3a15 100644 --- a/modules/photo/perf/opencl/perf_denoising.cpp +++ b/modules/photo/perf/opencl/perf_denoising.cpp @@ -5,7 +5,7 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp index 2ec9b9487..ae173905d 100644 --- a/modules/photo/src/fast_nlmeans_denoising_opencl.hpp +++ b/modules/photo/src/fast_nlmeans_denoising_opencl.hpp @@ -5,11 +5,11 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. +#include "precomp.hpp" #ifndef __OPENCV_FAST_NLMEANS_DENOISING_OPENCL_HPP__ #define __OPENCV_FAST_NLMEANS_DENOISING_OPENCL_HPP__ -#include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_photo.hpp" #ifdef HAVE_OPENCL diff --git a/modules/photo/test/ocl/test_denoising.cpp b/modules/photo/test/ocl/test_denoising.cpp index b533399cc..cb2d74f85 100644 --- a/modules/photo/test/ocl/test_denoising.cpp +++ b/modules/photo/test/ocl/test_denoising.cpp @@ -5,7 +5,7 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index 205562dad..5339efecf 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -2,7 +2,9 @@ # CMake file for python support # ---------------------------------------------------------------------------- -if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") +if((WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") + OR BUILD_opencv_world + ) ocv_module_disable(python2) ocv_module_disable(python3) endif() diff --git a/modules/python/common.cmake b/modules/python/common.cmake index 30f6d2813..2343c64e8 100644 --- a/modules/python/common.cmake +++ b/modules/python/common.cmake @@ -56,15 +56,15 @@ add_custom_command( DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt DEPENDS ${opencv_hdrs}) -add_library(${the_module} SHARED ${PYTHON_SOURCE_DIR}/src2/cv2.cpp ${cv2_generated_hdrs}) +ocv_add_library(${the_module} SHARED ${PYTHON_SOURCE_DIR}/src2/cv2.cpp ${cv2_generated_hdrs}) set_target_properties(${the_module} PROPERTIES COMPILE_DEFINITIONS OPENCV_NOSTL) if(PYTHON_DEBUG_LIBRARIES AND NOT PYTHON_LIBRARIES MATCHES "optimized.*debug") - target_link_libraries(${the_module} debug ${PYTHON_DEBUG_LIBRARIES} optimized ${PYTHON_LIBRARIES}) + ocv_target_link_libraries(${the_module} debug ${PYTHON_DEBUG_LIBRARIES} optimized ${PYTHON_LIBRARIES}) else() - target_link_libraries(${the_module} ${PYTHON_LIBRARIES}) + ocv_target_link_libraries(${the_module} ${PYTHON_LIBRARIES}) endif() -target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS}) +ocv_target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS}) execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; print(distutils.sysconfig.get_config_var('SO'))" RESULT_VARIABLE PYTHON_CVPY_PROCESS @@ -82,7 +82,7 @@ if(ENABLE_SOLUTION_FOLDERS) endif() if(MSVC) - add_definitions(-DCVAPI_EXPORTS) + add_definitions(-DCVAPI_EXPORTS) endif() if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) diff --git a/modules/stitching/perf/opencl/perf_stitch.cpp b/modules/stitching/perf/opencl/perf_stitch.cpp index 343472699..ce7c3a9f1 100644 --- a/modules/stitching/perf/opencl/perf_stitch.cpp +++ b/modules/stitching/perf/opencl/perf_stitch.cpp @@ -4,7 +4,7 @@ // // Copyright (C) 2014, Itseez, Inc, all rights reserved. -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" using namespace cv; diff --git a/modules/stitching/perf/opencl/perf_warpers.cpp b/modules/stitching/perf/opencl/perf_warpers.cpp index 6a8be4ebe..57ca9a602 100644 --- a/modules/stitching/perf/opencl/perf_warpers.cpp +++ b/modules/stitching/perf/opencl/perf_warpers.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/stitching/warpers.hpp" #include "opencv2/ts/ocl_perf.hpp" diff --git a/modules/stitching/src/blenders.cpp b/modules/stitching/src/blenders.cpp index 03aad752f..2fb04d29e 100644 --- a/modules/stitching/src/blenders.cpp +++ b/modules/stitching/src/blenders.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_stitching.hpp" namespace cv { namespace detail { diff --git a/modules/stitching/src/timelapsers.cpp b/modules/stitching/src/timelapsers.cpp index d78ad86a5..bc1d62e1a 100644 --- a/modules/stitching/src/timelapsers.cpp +++ b/modules/stitching/src/timelapsers.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_stitching.hpp" namespace cv { namespace detail { diff --git a/modules/stitching/src/warpers.cpp b/modules/stitching/src/warpers.cpp index 8b2c77e75..c01b7d0d3 100644 --- a/modules/stitching/src/warpers.cpp +++ b/modules/stitching/src/warpers.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_stitching.hpp" namespace cv { namespace detail { diff --git a/modules/stitching/test/ocl/test_warpers.cpp b/modules/stitching/test/ocl/test_warpers.cpp index 43f0e9741..4a95fff00 100644 --- a/modules/stitching/test/ocl/test_warpers.cpp +++ b/modules/stitching/test/ocl/test_warpers.cpp @@ -39,7 +39,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #include "opencv2/stitching/warpers.hpp" diff --git a/modules/superres/src/btv_l1.cpp b/modules/superres/src/btv_l1.cpp index d54b4b398..3b3513e8d 100644 --- a/modules/superres/src/btv_l1.cpp +++ b/modules/superres/src/btv_l1.cpp @@ -44,7 +44,7 @@ // Dennis Mitzel, Thomas Pock, Thomas Schoenemann, Daniel Cremers. Video Super Resolution using Duality Based TV-L1 Optical Flow. #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_superres.hpp" using namespace cv; using namespace cv::superres; diff --git a/modules/superres/test/test_precomp.hpp b/modules/superres/test/test_precomp.hpp index 553481818..9e89b428e 100644 --- a/modules/superres/test/test_precomp.hpp +++ b/modules/superres/test/test_precomp.hpp @@ -57,6 +57,6 @@ #include "opencv2/imgproc.hpp" #include "opencv2/superres.hpp" #include "cvconfig.h" -#include "input_array_utility.hpp" +#include "../src/input_array_utility.hpp" #endif diff --git a/modules/ts/CMakeLists.txt b/modules/ts/CMakeLists.txt index c923a29d8..9727c9a8c 100644 --- a/modules/ts/CMakeLists.txt +++ b/modules/ts/CMakeLists.txt @@ -14,5 +14,3 @@ ocv_add_module(ts opencv_core opencv_imgproc opencv_imgcodecs opencv_videoio ope ocv_glob_module_sources() ocv_module_include_directories() ocv_create_module() - -ocv_add_precompiled_headers(${the_module}) diff --git a/modules/video/perf/opencl/perf_bgfg_mog2.cpp b/modules/video/perf/opencl/perf_bgfg_mog2.cpp index 50814bf81..12223d663 100644 --- a/modules/video/perf/opencl/perf_bgfg_mog2.cpp +++ b/modules/video/perf/opencl/perf_bgfg_mog2.cpp @@ -1,4 +1,4 @@ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/perf/opencl/perf_motempl.cpp b/modules/video/perf/opencl/perf_motempl.cpp index 795685721..d60356902 100644 --- a/modules/video/perf/opencl/perf_motempl.cpp +++ b/modules/video/perf/opencl/perf_motempl.cpp @@ -5,7 +5,7 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/perf/opencl/perf_optflow_dualTVL1.cpp b/modules/video/perf/opencl/perf_optflow_dualTVL1.cpp index 72b1b0cbb..90e656d81 100644 --- a/modules/video/perf/opencl/perf_optflow_dualTVL1.cpp +++ b/modules/video/perf/opencl/perf_optflow_dualTVL1.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" using std::tr1::make_tuple; diff --git a/modules/video/perf/opencl/perf_optflow_farneback.cpp b/modules/video/perf/opencl/perf_optflow_farneback.cpp index a17ed4dd9..03eac1a07 100644 --- a/modules/video/perf/opencl/perf_optflow_farneback.cpp +++ b/modules/video/perf/opencl/perf_optflow_farneback.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" using std::tr1::make_tuple; diff --git a/modules/video/perf/opencl/perf_optflow_pyrlk.cpp b/modules/video/perf/opencl/perf_optflow_pyrlk.cpp index 1d7e643d5..6041a4b51 100644 --- a/modules/video/perf/opencl/perf_optflow_pyrlk.cpp +++ b/modules/video/perf/opencl/perf_optflow_pyrlk.cpp @@ -44,7 +44,7 @@ // //M*/ -#include "perf_precomp.hpp" +#include "../perf_precomp.hpp" #include "opencv2/ts/ocl_perf.hpp" using std::tr1::make_tuple; diff --git a/modules/video/src/bgfg_gaussmix2.cpp b/modules/video/src/bgfg_gaussmix2.cpp index a5c48cb1f..08c3d12d6 100644 --- a/modules/video/src/bgfg_gaussmix2.cpp +++ b/modules/video/src/bgfg_gaussmix2.cpp @@ -83,7 +83,7 @@ ///////////*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_video.hpp" namespace cv { diff --git a/modules/video/src/lkpyramid.cpp b/modules/video/src/lkpyramid.cpp index 3e939391c..60e990f42 100644 --- a/modules/video/src/lkpyramid.cpp +++ b/modules/video/src/lkpyramid.cpp @@ -43,7 +43,7 @@ #include #include #include "lkpyramid.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_video.hpp" #define CV_DESCALE(x,n) (((x) + (1 << ((n)-1))) >> (n)) diff --git a/modules/video/src/motempl.cpp b/modules/video/src/motempl.cpp index bb48206ec..af1942925 100644 --- a/modules/video/src/motempl.cpp +++ b/modules/video/src/motempl.cpp @@ -40,7 +40,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_video.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/src/optflowgf.cpp b/modules/video/src/optflowgf.cpp index c0b1d88f1..4225e3d7f 100644 --- a/modules/video/src/optflowgf.cpp +++ b/modules/video/src/optflowgf.cpp @@ -41,7 +41,7 @@ //M*/ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_video.hpp" // // 2D dense optical flow algorithm from the following paper: diff --git a/modules/video/src/tvl1flow.cpp b/modules/video/src/tvl1flow.cpp index 914f09c73..fec000dc4 100644 --- a/modules/video/src/tvl1flow.cpp +++ b/modules/video/src/tvl1flow.cpp @@ -73,7 +73,7 @@ */ #include "precomp.hpp" -#include "opencl_kernels.hpp" +#include "opencl_kernels_video.hpp" #include #include diff --git a/modules/video/test/ocl/test_bgfg_mog2.cpp b/modules/video/test/ocl/test_bgfg_mog2.cpp index 0a52227ec..49539ac04 100644 --- a/modules/video/test/ocl/test_bgfg_mog2.cpp +++ b/modules/video/test/ocl/test_bgfg_mog2.cpp @@ -1,4 +1,4 @@ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/test/ocl/test_motempl.cpp b/modules/video/test/ocl/test_motempl.cpp index 91053d9ad..f8c6abc63 100644 --- a/modules/video/test/ocl/test_motempl.cpp +++ b/modules/video/test/ocl/test_motempl.cpp @@ -5,7 +5,7 @@ // Copyright (C) 2014, Advanced Micro Devices, Inc., all rights reserved. // Third party copyrights are property of their respective owners. -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/test/ocl/test_optflow_farneback.cpp b/modules/video/test/ocl/test_optflow_farneback.cpp index cc40f749b..ec718d4f6 100644 --- a/modules/video/test/ocl/test_optflow_farneback.cpp +++ b/modules/video/test/ocl/test_optflow_farneback.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/test/ocl/test_optflow_tvl1flow.cpp b/modules/video/test/ocl/test_optflow_tvl1flow.cpp index 6e7150718..bd32252b2 100644 --- a/modules/video/test/ocl/test_optflow_tvl1flow.cpp +++ b/modules/video/test/ocl/test_optflow_tvl1flow.cpp @@ -41,7 +41,7 @@ // //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" #ifdef HAVE_OPENCL diff --git a/modules/video/test/ocl/test_optflowpyrlk.cpp b/modules/video/test/ocl/test_optflowpyrlk.cpp index 94195eabe..3c264a5e4 100644 --- a/modules/video/test/ocl/test_optflowpyrlk.cpp +++ b/modules/video/test/ocl/test_optflowpyrlk.cpp @@ -42,7 +42,7 @@ //M*/ -#include "test_precomp.hpp" +#include "../test_precomp.hpp" #include "opencv2/ts/ocl_test.hpp" diff --git a/modules/videoio/CMakeLists.txt b/modules/videoio/CMakeLists.txt index 96ac5045f..f92f5ea68 100644 --- a/modules/videoio/CMakeLists.txt +++ b/modules/videoio/CMakeLists.txt @@ -17,80 +17,80 @@ if(APPLE) endif() set(videoio_hdrs - src/precomp.hpp - src/cap_ffmpeg_impl.hpp + ${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp + ${CMAKE_CURRENT_LIST_DIR}/src/cap_ffmpeg_impl.hpp ) set(videoio_srcs - src/cap.cpp - src/cap_images.cpp - src/cap_ffmpeg.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/cap.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/cap_images.cpp + ${CMAKE_CURRENT_LIST_DIR}/src/cap_ffmpeg.cpp ) file(GLOB videoio_ext_hdrs "include/opencv2/*.hpp" "include/opencv2/${name}/*.hpp" "include/opencv2/${name}/*.h") if(WIN32 AND NOT ARM) - list(APPEND videoio_srcs src/cap_cmu.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_cmu.cpp) endif() if (WIN32 AND HAVE_DSHOW) - list(APPEND videoio_srcs src/cap_dshow.cpp) - list(APPEND videoio_hdrs src/cap_dshow.hpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.cpp) + list(APPEND videoio_hdrs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dshow.hpp) endif() if (WIN32 AND HAVE_MSMF) - list(APPEND videoio_srcs src/cap_msmf.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_msmf.cpp) endif() if (WIN32 AND HAVE_VFW) - list(APPEND videoio_srcs src/cap_vfw.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_vfw.cpp) endif() if(HAVE_XINE) - list(APPEND videoio_srcs src/cap_xine.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_xine.cpp) endif(HAVE_XINE) if(HAVE_DC1394_2) - list(APPEND videoio_srcs src/cap_dc1394_v2.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394_v2.cpp) endif(HAVE_DC1394_2) if(HAVE_DC1394) - list(APPEND videoio_srcs src/cap_dc1394.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_dc1394.cpp) endif(HAVE_DC1394) if(HAVE_GSTREAMER) - list(APPEND videoio_srcs src/cap_gstreamer.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_gstreamer.cpp) endif(HAVE_GSTREAMER) if(HAVE_UNICAP) - list(APPEND videoio_srcs src/cap_unicap.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_unicap.cpp) endif(HAVE_UNICAP) if(HAVE_LIBV4L) - list(APPEND videoio_srcs src/cap_libv4l.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_libv4l.cpp) elseif(HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO) - list(APPEND videoio_srcs src/cap_v4l.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_v4l.cpp) endif() if(HAVE_OPENNI) - list(APPEND videoio_srcs src/cap_openni.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_openni.cpp) ocv_include_directories(${OPENNI_INCLUDE_DIR}) list(APPEND VIDEOIO_LIBRARIES ${OPENNI_LIBRARY}) endif(HAVE_OPENNI) if(HAVE_OPENNI2) - list(APPEND videoio_srcs src/cap_openni2.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_openni2.cpp) ocv_include_directories(${OPENNI2_INCLUDE_DIR}) list(APPEND VIDEOIO_LIBRARIES ${OPENNI2_LIBRARY}) endif(HAVE_OPENNI2) if(HAVE_opencv_androidcamera) - list(APPEND videoio_srcs src/cap_android.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_android.cpp) add_definitions(-DHAVE_ANDROID_NATIVE_CAMERA)#TODO: remove this line endif(HAVE_opencv_androidcamera) if(HAVE_XIMEA) - list(APPEND videoio_srcs src/cap_ximea.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_ximea.cpp) ocv_include_directories(${XIMEA_PATH}) if(XIMEA_LIBRARY_DIR) link_directories("${XIMEA_LIBRARY_DIR}") @@ -115,40 +115,43 @@ if(HAVE_PVAPI) add_definitions(-DHAVE_PVAPI) add_definitions(${PVAPI_DEFINITIONS}) ocv_include_directories(${PVAPI_INCLUDE_PATH}) - set(videoio_srcs src/cap_pvapi.cpp ${videoio_srcs}) + set(videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_pvapi.cpp ${videoio_srcs}) list(APPEND VIDEOIO_LIBRARIES ${PVAPI_LIBRARY}) endif() if(HAVE_GIGE_API) add_definitions(-DHAVE_GIGE_API) ocv_include_directories(${GIGEAPI_INCLUDE_PATH}) - set(videoio_srcs src/cap_giganetix.cpp ${videoio_srcs}) + set(videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_giganetix.cpp ${videoio_srcs}) list(APPEND VIDEOIO_LIBRARIES ${GIGEAPI_LIBRARIES}) - list(APPEND videoio_srcs src/cap_giganetix.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_giganetix.cpp) endif(HAVE_GIGE_API) if(HAVE_AVFOUNDATION) - list(APPEND videoio_srcs src/cap_avfoundation.mm) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_avfoundation.mm) list(APPEND VIDEOIO_LIBRARIES "-framework AVFoundation" "-framework QuartzCore") endif() if(HAVE_QUICKTIME) - list(APPEND videoio_srcs src/cap_qt.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_qt.cpp) list(APPEND VIDEOIO_LIBRARIES "-framework Carbon" "-framework QuickTime" "-framework CoreFoundation" "-framework QuartzCore") elseif(HAVE_QTKIT) - list(APPEND videoio_srcs src/cap_qtkit.mm) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_qtkit.mm) list(APPEND VIDEOIO_LIBRARIES "-framework QTKit" "-framework QuartzCore" "-framework AppKit") endif() if(HAVE_INTELPERC) - list(APPEND videoio_srcs src/cap_intelperc.cpp) + list(APPEND videoio_srcs ${CMAKE_CURRENT_LIST_DIR}/src/cap_intelperc.cpp) ocv_include_directories(${INTELPERC_INCLUDE_DIR}) list(APPEND VIDEOIO_LIBRARIES ${INTELPERC_LIBRARIES}) endif(HAVE_INTELPERC) if(IOS) add_definitions(-DHAVE_IOS=1) - list(APPEND videoio_srcs src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm) + list(APPEND videoio_srcs + ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_abstract_camera.mm + ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_photo_camera.mm + ${CMAKE_CURRENT_LIST_DIR}/src/cap_ios_video_camera.mm) list(APPEND VIDEOIO_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreImage" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary") endif() @@ -176,6 +179,7 @@ ocv_module_include_directories() ocv_create_module(${VIDEOIO_LIBRARIES}) +macro(ocv_videoio_configure_target) if(APPLE) ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS) if(HAVE_OBJC_EXCEPTIONS) @@ -203,9 +207,10 @@ if(MSVC) endif() #stop automatic dependencies propagation for this module -set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "") +if(NOT BUILD_opencv_world) + set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "") +endif() -ocv_add_precompiled_headers(${the_module}) ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations) if(WIN32 AND WITH_FFMPEG) @@ -235,6 +240,11 @@ if(WIN32 AND WITH_FFMPEG) install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}") endif() +endmacro() + +if(NOT BUILD_opencv_world) + ocv_videoio_configure_target() +endif() ocv_add_accuracy_tests() ocv_add_perf_tests() diff --git a/modules/viz/CMakeLists.txt b/modules/viz/CMakeLists.txt index d839491c1..7fddb5388 100644 --- a/modules/viz/CMakeLists.txt +++ b/modules/viz/CMakeLists.txt @@ -7,7 +7,7 @@ set(the_description "Viz") ocv_define_module(viz opencv_core ${VTK_LIBRARIES}) if(APPLE AND BUILD_opencv_viz) - target_link_libraries(opencv_viz "-framework Cocoa") + ocv_target_link_libraries(opencv_viz "-framework Cocoa") endif() if(TARGET opencv_test_viz) diff --git a/modules/world/CMakeLists.txt b/modules/world/CMakeLists.txt index 33a9304c8..4e05188e0 100644 --- a/modules/world/CMakeLists.txt +++ b/modules/world/CMakeLists.txt @@ -9,124 +9,47 @@ else() set(OPENCV_WORLD_FLAGS_PROPERTY LINK_FLAGS) endif() -ocv_add_module(world opencv_core) +if(NOT OPENCV_INITIAL_PASS) + project(opencv_world) -if(MSVC) - foreach(_var CMAKE_EXE_LINKER_FLAGS_RELEASE CMAKE_MODULE_LINKER_FLAGS_RELEASE CMAKE_SHARED_LINKER_FLAGS_RELEASE - CMAKE_EXE_LINKER_FLAGS_DEBUG CMAKE_MODULE_LINKER_FLAGS_DEBUG CMAKE_SHARED_LINKER_FLAGS_DEBUG) - string(REPLACE "/INCREMENTAL:NO" "/INCREMENTAL:YES" ${_var} "${${_var}}") - endforeach() -endif() - -ocv_glob_module_sources() -ocv_module_include_directories() -ocv_create_module(SKIP_LINK) - -#TODO: try to use try_compile to find real object file extension/location -if(CMAKE_GENERATOR MATCHES "^Visual.*$") - set(have_cfg 1) - set(objpath0 ".dir//.obj") -elseif (CMAKE_GENERATOR MATCHES Xcode) - set(have_cfg 1) - set(objpath0 "OpenCV.build/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/.build/Objects-normal/$(CURRENT_ARCH)/.o") -else() - set(have_cfg 0) - set(objpath0 "CMakeFiles/.dir/.o") - if(MINGW OR MSVC) - set(objpath0 "${objpath0}bj") - endif() -endif() - -set(objlist "") -foreach(m ${OPENCV_MODULE_${the_module}_DEPS}) - # build order dependencies - add_dependencies(${the_module} ${m}) - # link dependencies - string(REGEX REPLACE "(general|debug|optimized);opencv_[^;]*(;|$)" "" _link_deps "${${m}_LIB_DEPENDS}") - if(_link_deps) - target_link_libraries(${the_module} ${_link_deps}) - endif() - - string(REGEX REPLACE "" "${m}" objpath1 "${${m}_BINARY_DIR}/${objpath0}") - foreach(srcname ${OPENCV_MODULE_${m}_SOURCES}) - if(srcname MATCHES "\\.(cpp|mm|c|cxx|cc|o|obj)$") - if(srcname MATCHES "\\.(o|obj)$") - if(IS_ABSOLUTE "${srcname}") - set(objpath3 "${srcname}") - else() - set(objpath3 "${${m}_SOURCE_DIR}/${srcname}") - endif() - else() - if(IS_ABSOLUTE "${srcname}") - if(srcname MATCHES "/(qrc|moc)_[^/]*\\.cxx$") - # QT generated sources - file(RELATIVE_PATH srcname "${${m}_BINARY_DIR}" "${srcname}") - else() - file(RELATIVE_PATH srcname "${OPENCV_MODULE_${m}_LOCATION}" "${srcname}") - endif() - endif() - string(REPLACE ".." "__" srcname "${srcname}") - #NAME_WE intentionally not used since it interprets first period as start of extension (http://cmake.org/Bug/view.php?id=12282) - get_filename_component(srcname_we "${srcname}" NAME) - string(REGEX REPLACE "\\.[^.]+$" "" srcname_we "${srcname_we}") - string(REGEX REPLACE "${srcname_we}" objpath2 "${objpath1}") - string(REGEX REPLACE "${srcname}" objpath3 "${objpath2}") - endif() - if(CMAKE_GENERATOR MATCHES Makefiles) - file(RELATIVE_PATH objpath4 "${CMAKE_CURRENT_BINARY_DIR}" "${objpath3}") - else() - set(objpath4 ${objpath3}) - endif() - list(APPEND objlist "\"${objpath4}\"") + message(STATUS "Processing WORLD modules...") + foreach(m ${OPENCV_MODULES_BUILD}) + if(OPENCV_MODULE_${m}_IS_PART_OF_WORLD) + message(STATUS " module ${m}...") + set(CMAKE_CURRENT_SOURCE_DIR ${OPENCV_MODULE_${m}_LOCATION}) + #add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" ${CMAKE_CURRENT_BINARY_DIR}/${m}) + include("${OPENCV_MODULE_${m}_LOCATION}/CMakeLists.txt") endif() endforeach() + message(STATUS "Processing WORLD modules... DONE") + set(CMAKE_CURRENT_SOURCE_DIR OPENCV_MODULE_${opencv_world}_LOCATION) +endif() + +ocv_add_module(world opencv_core) + +set(headers_list "HEADERS") +set(sources_list "SOURCES") +set(link_deps "") +foreach(m ${OPENCV_MODULE_${the_module}_DEPS}) + set(headers_list "${headers_list};${OPENCV_MODULE_${m}_HEADERS}") + set(sources_list "${sources_list};${OPENCV_MODULE_${m}_SOURCES}") + set(link_deps "${link_deps};${OPENCV_MODULE_${m}_LINK_DEPS}") endforeach() +ocv_glob_module_sources(${headers_list} ${sources_list}) -macro(ios_include_3party_libs) - foreach(l ${ARGN}) - add_dependencies(${the_module} ${l}) - string(REGEX REPLACE "" "${l}" objpath1 "${CMAKE_BINARY_DIR}/3rdparty/${l}/${objpath0}") - file(GLOB sources ${CMAKE_SOURCE_DIR}/3rdparty/${l}/*.c) - foreach(srcname ${sources}) - if(IS_ABSOLUTE "${srcname}") - file(RELATIVE_PATH srcname "${CMAKE_SOURCE_DIR}/3rdparty/${l}" "${srcname}") - endif() +ocv_module_include_directories() - string(REPLACE ".." "__" srcname "${srcname}") - #NAME_WE intentionally not used since it interprets first period as start of extension (http://cmake.org/Bug/view.php?id=12282) - get_filename_component(srcname_we "${srcname}" NAME) - string(REGEX REPLACE "\\.[^.]+$" "" srcname_we "${srcname_we}") - string(REGEX REPLACE "${srcname_we}" objpath2 "${objpath1}") - string(REGEX REPLACE "${srcname}" objpath3 "${objpath2}") +#message(STATUS "${OPENCV_MODULE_${the_module}_HEADERS}") +#message(STATUS "${OPENCV_MODULE_${the_module}_SOURCES}") +ocv_create_module(${link_deps}) - list(APPEND objlist "\"${objpath3}\"") - endforeach() # (srcname ${sources}) - endforeach() - ocv_list_filterout(objlist jmemansi) # <<= dirty fix -endmacro() - -if( (IOS OR APPLE) AND WITH_PNG) - ios_include_3party_libs(zlib libpng) +if(BUILD_opencv_imgcodecs) + ocv_imgcodecs_configure_target() endif() - -if( (IOS OR APPLE) AND WITH_JPEG) - ios_include_3party_libs(libjpeg) +if(BUILD_opencv_videoio) + ocv_videoio_configure_target() endif() - -string(REPLACE ";" " " objlist "${objlist}") - -if(have_cfg) - string(REGEX REPLACE "" "Debug" objlist_dbg "${objlist}") - string(REGEX REPLACE "" "Release" objlist_rls "${objlist}") - set_target_properties(${the_module} PROPERTIES - ${OPENCV_WORLD_FLAGS_PROPERTY}_DEBUG ${objlist_dbg} - ${OPENCV_WORLD_FLAGS_PROPERTY}_RELEASE ${objlist_rls}) -else() - file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/world_objects.list" "${objlist}") - execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/world_objects.list" "${CMAKE_CURRENT_BINARY_DIR}/world_objects.rsp" OUTPUT_QUIET) - set_target_properties(${the_module} PROPERTIES - ${OPENCV_WORLD_FLAGS_PROPERTY} "@${CMAKE_CURRENT_BINARY_DIR}/world_objects.rsp") +if(BUILD_opencv_highgui) + ocv_highgui_configure_target() endif() - -ocv_add_precompiled_headers(${the_module}) diff --git a/modules/world/src/precomp.hpp b/modules/world/src/precomp.hpp index 1aa056848..a46e470b4 100644 --- a/modules/world/src/precomp.hpp +++ b/modules/world/src/precomp.hpp @@ -44,6 +44,9 @@ #define __OPENCV_PRECOMP_H__ #include "opencv2/opencv_modules.hpp" + +#include "opencv2/core/ocl.hpp" + #ifdef HAVE_OPENCV_VIDEO #include "opencv2/video.hpp" #endif @@ -53,9 +56,6 @@ #ifdef HAVE_OPENCV_NONFREE #include "opencv2/nonfree.hpp" #endif -#ifdef HAVE_OPENCV_ML -#include "opencv2/ml.hpp" -#endif #include "opencv2/world.hpp" diff --git a/modules/world/src/world_init.cpp b/modules/world/src/world_init.cpp index 3fd13f392..685e44bdf 100644 --- a/modules/world/src/world_init.cpp +++ b/modules/world/src/world_init.cpp @@ -53,9 +53,6 @@ bool cv::initAll() #endif #ifdef HAVE_OPENCV_NONFREE && initModule_nonfree() -#endif -#ifdef HAVE_OPENCV_ML - && initModule_ml() #endif ; } diff --git a/samples/android/CMakeLists.txt b/samples/android/CMakeLists.txt index 1ca60fbb9..8cad0e9fe 100644 --- a/samples/android/CMakeLists.txt +++ b/samples/android/CMakeLists.txt @@ -19,9 +19,9 @@ add_subdirectory(native-activity) # hello-android sample if(HAVE_opencv_highgui) - ocv_include_modules_recurse(opencv_imgcodecs opencv_videoio opencv_highgui opencv_core) add_executable(hello-android hello-android/main.cpp) - target_link_libraries(hello-android ${OPENCV_LINKER_LIBS} opencv_imgcodecs opencv_videoio opencv_highgui opencv_core) + ocv_target_include_modules_recurse(hello-android opencv_imgcodecs opencv_videoio opencv_highgui opencv_core) + ocv_target_link_libraries(hello-android ${OPENCV_LINKER_LIBS} opencv_imgcodecs opencv_videoio opencv_highgui opencv_core) set_target_properties(hello-android PROPERTIES OUTPUT_NAME hello-android RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}") add_dependencies(opencv_android_examples hello-android) endif() diff --git a/samples/cpp/CMakeLists.txt b/samples/cpp/CMakeLists.txt index f22483cf6..26acad145 100644 --- a/samples/cpp/CMakeLists.txt +++ b/samples/cpp/CMakeLists.txt @@ -55,14 +55,14 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) set(the_target "${sample_kind}_${name}") add_executable(${the_target} ${srcs}) - target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) + ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CPP_SAMPLES_REQUIRED_DEPS}) if("${srcs}" MATCHES "gpu/") - target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters) + ocv_target_link_libraries(${the_target} opencv_cudaarithm opencv_cudafilters) endif() if(HAVE_opencv_ocl) - target_link_libraries(${the_target} opencv_ocl) + ocv_target_link_libraries(${the_target} opencv_ocl) endif() set_target_properties(${the_target} PROPERTIES diff --git a/samples/directx/CMakeLists.txt b/samples/directx/CMakeLists.txt index 108389410..15a657537 100644 --- a/samples/directx/CMakeLists.txt +++ b/samples/directx/CMakeLists.txt @@ -17,7 +17,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) set(the_target "example_${project}_${name}") add_executable(${the_target} ${srcs}) - target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS}) + ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_DIRECTX_SAMPLES_REQUIRED_DEPS}) set_target_properties(${the_target} PROPERTIES OUTPUT_NAME "${project}-example-${name}" diff --git a/samples/gpu/CMakeLists.txt b/samples/gpu/CMakeLists.txt index 849e3109d..01bd694bb 100644 --- a/samples/gpu/CMakeLists.txt +++ b/samples/gpu/CMakeLists.txt @@ -47,21 +47,21 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) set(the_target "example_${project}_${name}") add_executable(${the_target} ${srcs}) - target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS}) + ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS}) if(HAVE_CUDA AND NOT ANDROID) - target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY}) + ocv_target_link_libraries(${the_target} ${CUDA_CUDA_LIBRARY}) endif() if(HAVE_opencv_nonfree) - target_link_libraries(${the_target} opencv_nonfree) + ocv_target_link_libraries(${the_target} opencv_nonfree) endif() if(HAVE_opencv_cudacodec) - target_link_libraries(${the_target} opencv_cudacodec) + ocv_target_link_libraries(${the_target} opencv_cudacodec) endif() if(HAVE_opencv_ocl) - target_link_libraries(${the_target} opencv_ocl) + ocv_target_link_libraries(${the_target} opencv_ocl) endif() set_target_properties(${the_target} PROPERTIES diff --git a/samples/gpu/performance/CMakeLists.txt b/samples/gpu/performance/CMakeLists.txt index 9289180af..07125c2eb 100644 --- a/samples/gpu/performance/CMakeLists.txt +++ b/samples/gpu/performance/CMakeLists.txt @@ -8,10 +8,10 @@ if(HAVE_opencv_nonfree) endif() add_executable(${the_target} ${sources} ${headers}) -target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS}) +ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_CUDA_SAMPLES_REQUIRED_DEPS}) if(HAVE_opencv_nonfree) - target_link_libraries(${the_target} opencv_nonfree) + ocv_target_link_libraries(${the_target} opencv_nonfree) endif() set_target_properties(${the_target} PROPERTIES diff --git a/samples/tapi/CMakeLists.txt b/samples/tapi/CMakeLists.txt index cf88f3a98..83fd7260a 100644 --- a/samples/tapi/CMakeLists.txt +++ b/samples/tapi/CMakeLists.txt @@ -17,7 +17,7 @@ if(BUILD_EXAMPLES AND OCV_DEPENDENCIES_FOUND) set(the_target "example_${project}_${name}") add_executable(${the_target} ${srcs}) - target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS}) + ocv_target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${OPENCV_TAPI_SAMPLES_REQUIRED_DEPS}) set_target_properties(${the_target} PROPERTIES OUTPUT_NAME "${project}-example-${name}"