From cac1218eef7ebbd07951e961d547234d5c910bd2 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Sun, 29 Jun 2014 16:45:24 -0400 Subject: [PATCH 01/21] Build both Python 2 and Python 3 bindings If both Python 2 and Python 3 are found, then build bindings for both of them during the build process. Currently, one version of Python is detected automatically, and building for the other requires changes the CMake config. The largest chunk of this change generalizes OpenCVDetectPython.cmake to find both a Python 2 and Python 3 version of Python. Secondly, the opencv_python module is split into two modules, opencv_python2 and opencv_python3. Both are built from the same source. but for different versions of Python. --- CMakeLists.txt | 32 ++- cmake/OpenCVDetectPython.cmake | 293 ++++++++++++++++------- cmake/OpenCVMinDepVersions.cmake | 3 +- doc/CMakeLists.txt | 4 +- modules/java/CMakeLists.txt | 8 +- modules/java/android_test/CMakeLists.txt | 4 +- modules/matlab/CMakeLists.txt | 12 +- modules/python/CMakeLists.txt | 132 +--------- modules/python/common.cmake | 128 ++++++++++ modules/python/python2/CMakeLists.txt | 26 ++ modules/python/python3/CMakeLists.txt | 26 ++ 11 files changed, 440 insertions(+), 228 deletions(-) create mode 100644 modules/python/common.cmake create mode 100644 modules/python/python2/CMakeLists.txt create mode 100644 modules/python/python3/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 5abf449804..b9ff7bec16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -991,18 +991,34 @@ endif() # ========================== python ========================== status("") -status(" Python:") -status(" Interpreter:" PYTHONINTERP_FOUND THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_STRING})" ELSE NO) -if(BUILD_opencv_python) - if(PYTHONLIBS_VERSION_STRING) - status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE NO) +status(" Python 2:") +status(" Interpreter:" PYTHON2INTERP_FOUND THEN "${PYTHON2_EXECUTABLE} (ver ${PYTHON2_VERSION_STRING})" ELSE NO) +if(BUILD_opencv_python2) + if(PYTHON2LIBS_VERSION_STRING) + status(" Libraries:" HAVE_opencv_python2 THEN "${PYTHON2_LIBRARIES} (ver ${PYTHON2LIBS_VERSION_STRING})" ELSE NO) else() - status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES}" ELSE NO) + status(" Libraries:" HAVE_opencv_python2 THEN "${PYTHON2_LIBRARIES}" ELSE NO) endif() - status(" numpy:" PYTHON_NUMPY_INCLUDE_DIRS THEN "${PYTHON_NUMPY_INCLUDE_DIRS} (ver ${PYTHON_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)") - status(" packages path:" PYTHON_EXECUTABLE THEN "${PYTHON_PACKAGES_PATH}" ELSE "-") + status(" numpy:" PYTHON2_NUMPY_INCLUDE_DIRS THEN "${PYTHON2_NUMPY_INCLUDE_DIRS} (ver ${PYTHON2_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)") + status(" packages path:" PYTHON2_EXECUTABLE THEN "${PYTHON2_PACKAGES_PATH}" ELSE "-") endif() +status("") +status(" Python 3:") +status(" Interpreter:" PYTHON3INTERP_FOUND THEN "${PYTHON3_EXECUTABLE} (ver ${PYTHON3_VERSION_STRING})" ELSE NO) +if(BUILD_opencv_python3) + if(PYTHON3LIBS_VERSION_STRING) + status(" Libraries:" HAVE_opencv_python3 THEN "${PYTHON3_LIBRARIES} (ver ${PYTHON3LIBS_VERSION_STRING})" ELSE NO) + else() + status(" Libraries:" HAVE_opencv_python3 THEN "${PYTHON3_LIBRARIES}" ELSE NO) + endif() + status(" numpy:" PYTHON3_NUMPY_INCLUDE_DIRS THEN "${PYTHON3_NUMPY_INCLUDE_DIRS} (ver ${PYTHON3_NUMPY_VERSION})" ELSE "NO (Python3 wrappers can not be generated)") + status(" packages path:" PYTHON3_EXECUTABLE THEN "${PYTHON3_PACKAGES_PATH}" ELSE "-") +endif() + +status("") +status(" Python (for build):" PYTHON_DEFAULT_AVAILABLE THEN "${PYTHON_DEFAULT_EXECUTABLE}" ELSE NO) + # ========================== java ========================== status("") status(" Java:") diff --git a/cmake/OpenCVDetectPython.cmake b/cmake/OpenCVDetectPython.cmake index 95a26dbf32..4b71052685 100644 --- a/cmake/OpenCVDetectPython.cmake +++ b/cmake/OpenCVDetectPython.cmake @@ -1,101 +1,234 @@ -if(WIN32 AND NOT PYTHON_EXECUTABLE) - # search for executable with the same bitness as resulting binaries - # standard FindPythonInterp always prefers executable from system path - # this is really important because we are using the interpreter for numpy search and for choosing the install location - foreach(_CURRENT_VERSION ${Python_ADDITIONAL_VERSIONS} 2.7 "${MIN_VER_PYTHON}") - find_host_program(PYTHON_EXECUTABLE - NAMES python${_CURRENT_VERSION} python - PATHS - [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath] - [HKEY_CURRENT_USER\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath] - NO_SYSTEM_ENVIRONMENT_PATH - ) - endforeach() -endif() -find_host_package(PythonInterp 2.7) -if(NOT PYTHONINTERP_FOUND) -find_host_package(PythonInterp "${MIN_VER_PYTHON}") -endif() +# Find specified Python version +# Arguments: +# preferred_version (value): Version to check for first +# min_version (value): Minimum supported version +# library_env (value): Name of Python library ENV variable to check +# include_dir_env (value): Name of Python include directory ENV variable to check +# found (variable): Set if interpreter found +# executable (variable): Output of executable found +# version_string (variable): Output of found version +# version_major (variable): Output of found major version +# version_minor (variable): Output of found minor version +# libs_found (variable): Set if libs found +# libs_version_string (variable): Output of found libs version +# libraries (variable): Output of found Python libraries +# library (variable): Output of found Python library +# debug_libraries (variable): Output of found Python debug libraries +# debug_library (variable): Output of found Python debug library +# include_path (variable): Output of found Python include path +# include_dir (variable): Output of found Python include dir +# include_dir2 (variable): Output of found Python include dir2 +# packages_path (variable): Output of found Python packages path +# numpy_include_dirs (variable): Output of found Python Numpy include dirs +# numpy_version (variable): Output of found Python Numpy version +function(find_python preferred_version min_version library_env include_dir_env + found executable version_string version_major version_minor + libs_found libs_version_string libraries library debug_libraries + debug_library include_path include_dir include_dir2 packages_path + numpy_include_dirs numpy_version) + if(WIN32 AND NOT ${executable}) + # search for executable with the same bitness as resulting binaries + # standard FindPythonInterp always prefers executable from system path + # this is really important because we are using the interpreter for numpy search and for choosing the install location + foreach(_CURRENT_VERSION ${Python_ADDITIONAL_VERSIONS} "${preferred_version}" "${min_version}") + find_host_program(executable + NAMES python${_CURRENT_VERSION} python + PATHS + [HKEY_LOCAL_MACHINE\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath] + [HKEY_CURRENT_USER\\\\SOFTWARE\\\\Python\\\\PythonCore\\\\${_CURRENT_VERSION}\\\\InstallPath] + NO_SYSTEM_ENVIRONMENT_PATH + ) + endforeach() + endif() -unset(HAVE_SPHINX CACHE) + find_host_package(PythonInterp "${preferred_version}") + if(NOT PYTHONINTERP_FOUND) + find_host_package(PythonInterp "${min_version}") + endif() -if(PYTHONINTERP_FOUND) - set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") + if(PYTHONINTERP_FOUND) + # Copy outputs + set(_found ${PYTHONINTERP_FOUND}) + set(_executable ${PYTHON_EXECUTABLE}) + set(_version_string ${PYTHON_VERSION_STRING}) + set(_version_major ${PYTHON_VERSION_MAJOR}) + set(_version_minor ${PYTHON_VERSION_MINOR}) + set(_version_patch ${PYTHON_VERSION_PATCH}) - if(NOT ANDROID AND NOT IOS) - ocv_check_environment_variables(PYTHON_LIBRARY PYTHON_INCLUDE_DIR) - # not using PYTHON_VERSION_STRING here, because it might not conform to the CMake version format - find_host_package(PythonLibs "${PYTHON_VERSION_MAJOR_MINOR}.${PYTHON_VERSION_PATCH}" EXACT) + # Clear find_host_package side effects + unset(PYTHONINTERP_FOUND) + unset(PYTHON_EXECUTABLE CACHE) + unset(PYTHON_VERSION_STRING) + unset(PYTHON_VERSION_MAJOR) + unset(PYTHON_VERSION_MINOR) + unset(PYTHON_VERSION_PATCH) endif() - if(NOT ANDROID AND NOT IOS) - if(CMAKE_HOST_UNIX) - execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "from distutils.sysconfig import *; print(get_python_lib())" - RESULT_VARIABLE PYTHON_CVPY_PROCESS - OUTPUT_VARIABLE PYTHON_STD_PACKAGES_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE) - if("${PYTHON_STD_PACKAGES_PATH}" MATCHES "site-packages") - set(_PYTHON_PACKAGES_PATH "python${PYTHON_VERSION_MAJOR_MINOR}/site-packages") - else() #debian based assumed, install to the dist-packages. - set(_PYTHON_PACKAGES_PATH "python${PYTHON_VERSION_MAJOR_MINOR}/dist-packages") + if(_found) + set(_version_major_minor "${_version_major}.${_version_minor}") + + if(NOT ANDROID AND NOT IOS) + ocv_check_environment_variables(${library_env} ${include_dir_env}) + if(${library}) + set(PYTHON_LIBRARY "${${library_env}}") endif() - if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${PYTHON_PACKAGES_PATH}") - set(_PYTHON_PACKAGES_PATH "lib${LIB_SUFFIX}/${_PYTHON_PACKAGES_PATH}") - else() - set(_PYTHON_PACKAGES_PATH "lib/${_PYTHON_PACKAGES_PATH}") + if(${include_dir}) + set(PYTHON_INCLUDE_DIR "${${include_dir_env}}") endif() - elseif(CMAKE_HOST_WIN32) - get_filename_component(PYTHON_PATH "${PYTHON_EXECUTABLE}" PATH) - file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH) - if(NOT EXISTS "${PYTHON_PATH}/Lib/site-packages") - unset(PYTHON_PATH) - get_filename_component(PYTHON_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE) - if(NOT PYTHON_PATH) - get_filename_component(PYTHON_PATH "[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${PYTHON_VERSION_MAJOR_MINOR}\\InstallPath]" ABSOLUTE) - endif() - file(TO_CMAKE_PATH "${PYTHON_PATH}" PYTHON_PATH) + + # not using _version_string here, because it might not conform to the CMake version format + find_host_package(PythonLibs "${_version_major_minor}.${_version_patch}" EXACT) + + if(PYTHONLIBS_FOUND) + # Copy outputs + set(_libs_found ${PYTHONLIBS_FOUND}) + set(_libraries ${PYTHON_LIBRARIES}) + set(_include_path ${PYTHON_INCLUDE_PATH}) + set(_include_dirs ${PYTHON_INCLUDE_DIRS}) + set(_debug_libraries ${PYTHON_DEBUG_LIBRARIES}) + set(_libs_version_string ${PYTHONLIBS_VERSION_STRING}) + set(_debug_library ${PYTHON_DEBUG_LIBRARY}) + set(_library ${PYTHON_LIBRARY}) + set(_library_debug ${PYTHON_LIBRARY_DEBUG}) + set(_library_release ${PYTHON_LIBRARY_RELEASE}) + set(_include_dir ${PYTHON_INCLUDE_DIR}) + set(_include_dir2 ${PYTHON_INCLUDE_DIR2}) + + # Clear find_host_package side effects + unset(PYTHONLIBS_FOUND) + unset(PYTHON_LIBRARIES) + unset(PYTHON_INCLUDE_PATH) + unset(PYTHON_INCLUDE_DIRS) + unset(PYTHON_DEBUG_LIBRARIES) + unset(PYTHONLIBS_VERSION_STRING) + unset(PYTHON_DEBUG_LIBRARY CACHE) + unset(PYTHON_LIBRARY) + unset(PYTHON_LIBRARY_DEBUG) + unset(PYTHON_LIBRARY_RELEASE) + unset(PYTHON_LIBRARY CACHE) + unset(PYTHON_LIBRARY_DEBUG CACHE) + unset(PYTHON_LIBRARY_RELEASE CACHE) + unset(PYTHON_INCLUDE_DIR CACHE) + unset(PYTHON_INCLUDE_DIR2 CACHE) endif() - set(_PYTHON_PACKAGES_PATH "${PYTHON_PATH}/Lib/site-packages") endif() - SET(PYTHON_PACKAGES_PATH "${_PYTHON_PACKAGES_PATH}" CACHE PATH "Where to install the python packages.") - - if(NOT PYTHON_NUMPY_INCLUDE_DIRS) - if(CMAKE_CROSSCOMPILING) - message(STATUS "Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)") - message(STATUS "If you want to enable Python/Numpy support, set the following variables:") - message(STATUS " PYTHON_INCLUDE_PATH") - message(STATUS " PYTHON_LIBRARIES") - message(STATUS " PYTHON_NUMPY_INCLUDE_DIRS") - else() - # Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))" - RESULT_VARIABLE PYTHON_NUMPY_PROCESS - OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIRS + + if(NOT ANDROID AND NOT IOS) + if(CMAKE_HOST_UNIX) + execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())" + RESULT_VARIABLE _cvpy_process + OUTPUT_VARIABLE _std_packages_path OUTPUT_STRIP_TRAILING_WHITESPACE) + if("${_std_packages_path}" MATCHES "site-packages") + set(_packages_path "python${_version_major_minor}/site-packages") + else() #debian based assumed, install to the dist-packages. + set(_packages_path "python${_version_major_minor}/dist-packages") + endif() + if(EXISTS "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}/${${packages_path}}") + set(_packages_path "lib${LIB_SUFFIX}/${_packages_path}") + else() + set(_packages_path "lib/${_packages_path}") + endif() + elseif(CMAKE_HOST_WIN32) + get_filename_component(_path "${_executable}" PATH) + file(TO_CMAKE_PATH "${_path}" _path) + if(NOT EXISTS "${_path}/Lib/site-packages") + unset(_path) + get_filename_component(_path "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Python\\PythonCore\\${_version_major_minor}\\InstallPath]" ABSOLUTE) + if(NOT _path) + get_filename_component(_path "[HKEY_CURRENT_USER\\SOFTWARE\\Python\\PythonCore\\${_version_major_minor}\\InstallPath]" ABSOLUTE) + endif() + file(TO_CMAKE_PATH "${_path}" _path) + endif() + set(_packages_path "${_path}/Lib/site-packages") + unset(_path) + endif() + + set(_numpy_include_dirs ${${numpy_include_dirs}}) + + if(NOT _numpy_include_dirs) + if(CMAKE_CROSSCOMPILING) + message(STATUS "Cannot probe for Python/Numpy support (because we are cross-compiling OpenCV)") + message(STATUS "If you want to enable Python/Numpy support, set the following variables:") + message(STATUS " PYTHON2_INCLUDE_PATH") + message(STATUS " PYTHON2_LIBRARIES") + message(STATUS " PYTHON2_NUMPY_INCLUDE_DIRS") + message(STATUS " PYTHON3_INCLUDE_PATH") + message(STATUS " PYTHON3_LIBRARIES") + message(STATUS " PYTHON3_NUMPY_INCLUDE_DIRS") + else() + # Attempt to discover the NumPy include directory. If this succeeds, then build python API with NumPy + execute_process(COMMAND "${_executable}" -c "import os; os.environ['DISTUTILS_USE_SDK']='1'; import numpy.distutils; print(os.pathsep.join(numpy.distutils.misc_util.get_numpy_include_dirs()))" + RESULT_VARIABLE _numpy_process + OUTPUT_VARIABLE _numpy_include_dirs + OUTPUT_STRIP_TRAILING_WHITESPACE) - if(NOT PYTHON_NUMPY_PROCESS EQUAL 0) - unset(PYTHON_NUMPY_INCLUDE_DIRS) + if(NOT _numpy_process EQUAL 0) + unset(_numpy_include_dirs) + endif() endif() endif() - endif() - if(PYTHON_NUMPY_INCLUDE_DIRS) - file(TO_CMAKE_PATH "${PYTHON_NUMPY_INCLUDE_DIRS}" _PYTHON_NUMPY_INCLUDE_DIRS) - set(PYTHON_NUMPY_INCLUDE_DIRS ${_PYTHON_NUMPY_INCLUDE_DIRS} CACHE PATH "Path to numpy headers") - if(CMAKE_CROSSCOMPILING) - if(NOT PYTHON_NUMPY_VERSION) - set(PYTHON_NUMPY_VERSION "undefined - cannot be probed because of the cross-compilation") + if(_numpy_include_dirs) + file(TO_CMAKE_PATH "${_numpy_include_dirs}" _numpy_include_dirs) + if(CMAKE_CROSSCOMPILING) + if(NOT _numpy_version) + set(_numpy_version "undefined - cannot be probed because of the cross-compilation") + endif() + else() + execute_process(COMMAND "${_executable}" -c "import numpy; print(numpy.version.version)" + RESULT_VARIABLE _numpy_process + OUTPUT_VARIABLE _numpy_version + OUTPUT_STRIP_TRAILING_WHITESPACE) endif() - else() - execute_process(COMMAND "${PYTHON_EXECUTABLE}" -c "import numpy; print(numpy.version.version)" - RESULT_VARIABLE PYTHON_NUMPY_PROCESS - OUTPUT_VARIABLE PYTHON_NUMPY_VERSION - OUTPUT_STRIP_TRAILING_WHITESPACE) endif() - endif() - endif(NOT ANDROID AND NOT IOS) + endif(NOT ANDROID AND NOT IOS) + endif() + + # Export return values + set(${found} "${_found}" PARENT_SCOPE) + set(${executable} "${_executable}" CACHE FILEPATH "Path to Python interpretor") + set(${version_string} "${_version_string}" PARENT_SCOPE) + set(${version_major} "${_version_major}" PARENT_SCOPE) + set(${version_minor} "${_version_minor}" PARENT_SCOPE) + set(${libs_found} "${_libs_found}" PARENT_SCOPE) + set(${libs_version_string} "${_libs_version_string}" PARENT_SCOPE) + set(${libraries} "${_libraries}" PARENT_SCOPE) + set(${library} "${_library}" CACHE FILEPATH "Path to Python library") + set(${debug_libraries} "${_debug_libraries}" PARENT_SCOPE) + set(${debug_library} "${_debug_library}" CACHE FILEPATH "Path to Python debug") + set(${include_path} "${_include_path}" PARENT_SCOPE) + set(${include_dir} "${_include_dir}" CACHE PATH "Python include dir") + set(${include_dir2} "${_include_dir2}" CACHE PATH "Python include dir 2") + set(${packages_path} "${_packages_path}" CACHE PATH "Where to install the python packages.") + set(${numpy_include_dirs} ${_numpy_include_dirs} CACHE PATH "Path to numpy headers") + set(${numpy_version} "${_numpy_version}" PARENT_SCOPE) +endfunction(find_python) + +find_python(2.7 "${MIN_VER_PYTHON2}" PYTHON2_LIBRARY PYTHON2_INCLUDE_DIR + PYTHON2INTERP_FOUND PYTHON2_EXECUTABLE PYTHON2_VERSION_STRING + PYTHON2_VERSION_MAJOR PYTHON2_VERSION_MINOR PYTHON2LIBS_FOUND + PYTHON2LIBS_VERSION_STRING PYTHON2_LIBRARIES PYTHON2_LIBRARY + PYTHON2_DEBUG_LIBRARIES PYTHON2_LIBRARY_DEBUG PYTHON2_INCLUDE_PATH + PYTHON2_INCLUDE_DIR PYTHON2_INCLUDE_DIR2 PYTHON2_PACKAGES_PATH + PYTHON2_NUMPY_INCLUDE_DIRS PYTHON2_NUMPY_VERSION) + +find_python(3.4 "${MIN_VER_PYTHON3}" PYTHON3_LIBRARY PYTHON3_INCLUDE_DIR + PYTHON3INTERP_FOUND PYTHON3_EXECUTABLE PYTHON3_VERSION_STRING + PYTHON3_VERSION_MAJOR PYTHON3_VERSION_MINOR PYTHON3LIBS_FOUND + PYTHON3LIBS_VERSION_STRING PYTHON3_LIBRARIES PYTHON3_LIBRARY + PYTHON3_DEBUG_LIBRARIES PYTHON3_LIBRARY_DEBUG PYTHON3_INCLUDE_PATH + PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR2 PYTHON3_PACKAGES_PATH + PYTHON3_NUMPY_INCLUDE_DIRS PYTHON3_NUMPY_VERSION) + +# Use Python 2 as default Python interpreter +if(PYTHON2LIBS_FOUND) + set(PYTHON_DEFAULT_AVAILABLE "TRUE") + set(PYTHON_DEFAULT_EXECUTABLE "${PYTHON2_EXECUTABLE}") endif() +unset(HAVE_SPHINX CACHE) + if(BUILD_DOCS) find_host_program(SPHINX_BUILD sphinx-build) find_host_program(PLANTUML plantuml) diff --git a/cmake/OpenCVMinDepVersions.cmake b/cmake/OpenCVMinDepVersions.cmake index 9dae725481..e8591e26e2 100644 --- a/cmake/OpenCVMinDepVersions.cmake +++ b/cmake/OpenCVMinDepVersions.cmake @@ -1,5 +1,6 @@ set(MIN_VER_CMAKE 2.8.7) set(MIN_VER_CUDA 4.2) -set(MIN_VER_PYTHON 2.6) +set(MIN_VER_PYTHON2 2.6) +set(MIN_VER_PYTHON3 3.2) set(MIN_VER_ZLIB 1.2.3) set(MIN_VER_GTK 2.18.0) diff --git a/doc/CMakeLists.txt b/doc/CMakeLists.txt index 1c284539ee..7c641cc260 100644 --- a/doc/CMakeLists.txt +++ b/doc/CMakeLists.txt @@ -105,8 +105,8 @@ if(BUILD_DOCS AND HAVE_SPHINX) COMMAND ${SPHINX_BUILD} ${BUILD_PLANTUML} -b latex -c "${CMAKE_CURRENT_SOURCE_DIR}" "${DOC_FAKE_ROOT}" . COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/pics ${CMAKE_CURRENT_BINARY_DIR}/doc/opencv1/pics COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2refman.tex - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2manager.tex + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2refman.tex + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2manager.tex COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv2refman.pdf" COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2refman.tex COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2refman.tex diff --git a/modules/java/CMakeLists.txt b/modules/java/CMakeLists.txt index 1948e21141..4db3847bd2 100644 --- a/modules/java/CMakeLists.txt +++ b/modules/java/CMakeLists.txt @@ -1,7 +1,7 @@ # ---------------------------------------------------------------------------- # CMake file for java support # ---------------------------------------------------------------------------- -if(IOS OR NOT PYTHON_EXECUTABLE 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))) ocv_module_disable(java) endif() @@ -100,7 +100,7 @@ foreach(module ${OPENCV_JAVA_MODULES}) # first run of gen_java.py (to get list of generated files) file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out/") file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out") - execute_process(COMMAND ${PYTHON_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} + execute_process(COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/gen_java_out" OUTPUT_QUIET ERROR_QUIET) unset(generated_java_sources_${module}) @@ -124,7 +124,7 @@ set(step1_depends "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_ foreach(module ${OPENCV_JAVA_MODULES}) # second run of gen_java.py (at build time) add_custom_command(OUTPUT ${generated_java_sources_${module}} "${CMAKE_CURRENT_BINARY_DIR}/${module}.cpp" - COMMAND ${PYTHON_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} "${scripts_gen_java}" "${scripts_hdr_parser}" ${module} ${opencv_public_headers_${module}} WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS "${scripts_gen_java}" "${scripts_hdr_parser}" ${opencv_public_headers_${module}} ) @@ -134,7 +134,7 @@ endforeach() set(step2_depends ${step1_depends} ${scripts_gen_javadoc} ${scripts_rst_parser} ${javadoc_rst_sources} ${generated_java_sources} ${handwrittren_java_sources}) string(REPLACE ";" "," OPENCV_JAVA_MODULES_STR "${OPENCV_JAVA_MODULES}") add_custom_command(OUTPUT ${documented_java_files} - COMMAND ${PYTHON_EXECUTABLE} "${scripts_gen_javadoc}" --modules ${OPENCV_JAVA_MODULES_STR} "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/java" "${CMAKE_CURRENT_BINARY_DIR}" 2> "${CMAKE_CURRENT_BINARY_DIR}/get_javadoc_errors.log" + COMMAND ${PYTHON_DEFUALT_EXECUTABLE} "${scripts_gen_javadoc}" --modules ${OPENCV_JAVA_MODULES_STR} "${CMAKE_CURRENT_SOURCE_DIR}/generator/src/java" "${CMAKE_CURRENT_BINARY_DIR}" 2> "${CMAKE_CURRENT_BINARY_DIR}/get_javadoc_errors.log" WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} DEPENDS ${step2_depends} VERBATIM diff --git a/modules/java/android_test/CMakeLists.txt b/modules/java/android_test/CMakeLists.txt index 41f69e6ca7..a920508899 100644 --- a/modules/java/android_test/CMakeLists.txt +++ b/modules/java/android_test/CMakeLists.txt @@ -59,9 +59,9 @@ add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} -E add_dependencies(opencv_tests ${PROJECT_NAME}) -if(PYTHON_EXECUTABLE) +if(PYTHON_DEFAULT_AVAILABLE) set(CHECK_TEST_COVERAGE "${OPENCV_MODULE_opencv_java_LOCATION}/check-tests.py") add_custom_command(TARGET ${PROJECT_NAME} POST_BUILD - COMMAND ${PYTHON_EXECUTABLE} ${CHECK_TEST_COVERAGE} "${CMAKE_CURRENT_SOURCE_DIR}/src" "${OpenCV_BINARY_DIR}/src" > "${CMAKE_CURRENT_BINARY_DIR}/tests_coverage.log" + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CHECK_TEST_COVERAGE} "${CMAKE_CURRENT_SOURCE_DIR}/src" "${OpenCV_BINARY_DIR}/src" > "${CMAKE_CURRENT_BINARY_DIR}/tests_coverage.log" ) endif() diff --git a/modules/matlab/CMakeLists.txt b/modules/matlab/CMakeLists.txt index a4c1c3b164..095db36499 100644 --- a/modules/matlab/CMakeLists.txt +++ b/modules/matlab/CMakeLists.txt @@ -51,7 +51,7 @@ endmacro() if (IOS OR ANDROID OR NOT MATLAB_FOUND) ocv_module_disable(matlab) return() -elseif (NOT PYTHONLIBS_FOUND) +elseif (NOT PYTHON_DEFAULT_AVAILABLE) message(WARNING "A required dependency of the matlab module (PythonLibs) was not found. Disabling Matlab bindings...") ocv_module_disable(matlab) return() @@ -152,7 +152,7 @@ if (NOT MEX_WORKS) # attempt to generate a gateway for a function message(STATUS "Trying to generate Matlab code") execute_process( - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_matlab.py --jinja2 ${JINJA2_PATH} --hdrparser ${HDR_PARSER_PATH} @@ -212,7 +212,7 @@ file(REMOVE ${GENERATE_PROXY} ${COMPILE_PROXY}) # call the python executable to generate the Matlab gateways add_custom_command( OUTPUT ${GENERATE_PROXY} - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generator/gen_matlab.py --jinja2 ${JINJA2_PATH} --hdrparser ${HDR_PARSER_PATH} @@ -221,7 +221,7 @@ add_custom_command( --modules ${opencv_modules} --extra ${opencv_extra_hdrs} --outdir ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generator/build_info.py --jinja2 ${JINJA2_PATH} --os ${CMAKE_SYSTEM} @@ -235,7 +235,7 @@ add_custom_command( --modules ${opencv_modules} --configuration $ --outdir ${CMAKE_CURRENT_BINARY_DIR} - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generator/cvmex.py --jinja2 ${JINJA2_PATH} --opts="${MEX_OPTS}" @@ -298,7 +298,7 @@ string(REPLACE " " "\\ " MEX_CXXFLAGS ${MEX_CXXFLAGS}) string(REPLACE ";" "\\ " MEX_INCLUDE_DIRS "${MEX_INCLUDE_DIRS}") install(CODE "execute_process( - COMMAND ${PYTHON_EXECUTABLE} + COMMAND ${PYTHON_DEFAULT_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generator/cvmex.py --jinja2 ${JINJA2_PATH} --opts=${MEX_OPTS} diff --git a/modules/python/CMakeLists.txt b/modules/python/CMakeLists.txt index a50e372cc9..205562dadd 100644 --- a/modules/python/CMakeLists.txt +++ b/modules/python/CMakeLists.txt @@ -3,132 +3,14 @@ # ---------------------------------------------------------------------------- if(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "Debug") - ocv_module_disable(python) + ocv_module_disable(python2) + ocv_module_disable(python3) endif() -if(ANDROID OR IOS OR NOT PYTHONLIBS_FOUND OR NOT PYTHON_NUMPY_INCLUDE_DIRS) - ocv_module_disable(python) +if(ANDROID OR IOS) + ocv_module_disable(python2) + ocv_module_disable(python3) endif() -set(the_description "The python bindings") -ocv_add_module(python BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect OPTIONAL opencv_nonfree) - -ocv_module_include_directories( - "${PYTHON_INCLUDE_PATH}" - ${PYTHON_NUMPY_INCLUDE_DIRS} - "${CMAKE_CURRENT_SOURCE_DIR}/src2" - ) - -set(opencv_hdrs - "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core.hpp" - "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/base.hpp" - "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/types.hpp" - "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/persistence.hpp" - "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/utility.hpp" - "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/ocl.hpp" - "${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp" - "${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/opencv2/imgproc.hpp" - "${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/background_segm.hpp" - "${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/tracking.hpp" - "${OPENCV_MODULE_opencv_photo_LOCATION}/include/opencv2/photo.hpp" - "${OPENCV_MODULE_opencv_highgui_LOCATION}/include/opencv2/highgui.hpp" - "${OPENCV_MODULE_opencv_ml_LOCATION}/include/opencv2/ml.hpp" - "${OPENCV_MODULE_opencv_features2d_LOCATION}/include/opencv2/features2d.hpp" - "${OPENCV_MODULE_opencv_calib3d_LOCATION}/include/opencv2/calib3d.hpp" - "${OPENCV_MODULE_opencv_objdetect_LOCATION}/include/opencv2/objdetect.hpp" - ) - -if(HAVE_opencv_nonfree) - list(APPEND opencv_hdrs "${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree/features2d.hpp" - "${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree.hpp") -endif() - -set(cv2_generated_hdrs - "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h" - "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h" - "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_func_tab.h" - "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_types.h" - "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h" - "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_const_reg.h") - -add_custom_command( - OUTPUT ${cv2_generated_hdrs} - COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} ${opencv_hdrs} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/gen2.py - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/src2/hdr_parser.py - DEPENDS ${opencv_hdrs}) - -add_library(${the_module} SHARED 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}) -else() - target_link_libraries(${the_module} ${PYTHON_LIBRARIES}) -endif() -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 - OUTPUT_VARIABLE CVPY_SUFFIX - OUTPUT_STRIP_TRAILING_WHITESPACE) - -set_target_properties(${the_module} PROPERTIES - PREFIX "" - OUTPUT_NAME cv2 - SUFFIX ${CVPY_SUFFIX}) - -if(ENABLE_SOLUTION_FOLDERS) - set_target_properties(${the_module} PROPERTIES FOLDER "bindings") -endif() - -if(MSVC) - add_definitions(-DCVAPI_EXPORTS) -endif() - -if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") -endif() - -if(MSVC AND NOT ENABLE_NOISY_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100") #unreferenced formal parameter - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4127") #conditional expression is constant - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4505") #unreferenced local function has been removed - string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") -endif() - -if(MSVC AND NOT BUILD_SHARED_LIBS) - set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") -endif() - -if(MSVC AND NOT PYTHON_DEBUG_LIBRARIES) - set(PYTHON_INSTALL_CONFIGURATIONS CONFIGURATIONS Release) -else() - set(PYTHON_INSTALL_CONFIGURATIONS "") -endif() - -if(WIN32) - set(PYTHON_INSTALL_ARCHIVE "") -else() - set(PYTHON_INSTALL_ARCHIVE ARCHIVE DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python) -endif() - -if(NOT INSTALL_CREATE_DISTRIB) - install(TARGETS ${the_module} - ${PYTHON_INSTALL_CONFIGURATIONS} - RUNTIME DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python - LIBRARY DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python - ${PYTHON_INSTALL_ARCHIVE} - ) -else() - if(DEFINED PYTHON_VERSION_MAJOR) - set(__ver "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") - else() - set(__ver "unknown") - endif() - install(TARGETS ${the_module} - CONFIGURATIONS Release - RUNTIME DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT python - LIBRARY DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT python - ) -endif() +add_subdirectory(python2) +add_subdirectory(python3) diff --git a/modules/python/common.cmake b/modules/python/common.cmake new file mode 100644 index 0000000000..edac17f20e --- /dev/null +++ b/modules/python/common.cmake @@ -0,0 +1,128 @@ +# This file is included from a subdirectory +set(PYTHON_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../") + +ocv_module_include_directories( + "${PYTHON_INCLUDE_PATH}" + ${PYTHON_NUMPY_INCLUDE_DIRS} + "${PYTHON_SOURCE_DIR}/src2" + ) + +set(opencv_hdrs + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core.hpp" + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/base.hpp" + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/types.hpp" + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/persistence.hpp" + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/utility.hpp" + "${OPENCV_MODULE_opencv_core_LOCATION}/include/opencv2/core/ocl.hpp" + "${OPENCV_MODULE_opencv_flann_LOCATION}/include/opencv2/flann/miniflann.hpp" + "${OPENCV_MODULE_opencv_imgproc_LOCATION}/include/opencv2/imgproc.hpp" + "${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/background_segm.hpp" + "${OPENCV_MODULE_opencv_video_LOCATION}/include/opencv2/video/tracking.hpp" + "${OPENCV_MODULE_opencv_photo_LOCATION}/include/opencv2/photo.hpp" + "${OPENCV_MODULE_opencv_highgui_LOCATION}/include/opencv2/highgui.hpp" + "${OPENCV_MODULE_opencv_ml_LOCATION}/include/opencv2/ml.hpp" + "${OPENCV_MODULE_opencv_features2d_LOCATION}/include/opencv2/features2d.hpp" + "${OPENCV_MODULE_opencv_calib3d_LOCATION}/include/opencv2/calib3d.hpp" + "${OPENCV_MODULE_opencv_objdetect_LOCATION}/include/opencv2/objdetect.hpp" + ) + +if(HAVE_opencv_nonfree) + list(APPEND opencv_hdrs "${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree/features2d.hpp" + "${OPENCV_MODULE_opencv_nonfree_LOCATION}/include/opencv2/nonfree.hpp") +endif() + +set(cv2_generated_hdrs + "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_include.h" + "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_funcs.h" + "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_func_tab.h" + "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_types.h" + "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_type_reg.h" + "${CMAKE_CURRENT_BINARY_DIR}/pyopencv_generated_const_reg.h") + +add_custom_command( + OUTPUT ${cv2_generated_hdrs} + COMMAND ${PYTHON_EXECUTABLE} "${PYTHON_SOURCE_DIR}/src2/gen2.py" ${CMAKE_CURRENT_BINARY_DIR} ${opencv_hdrs} + DEPENDS ${PYTHON_SOURCE_DIR}/src2/gen2.py + DEPENDS ${PYTHON_SOURCE_DIR}/src2/hdr_parser.py + DEPENDS ${opencv_hdrs}) + +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}) +else() + target_link_libraries(${the_module} ${PYTHON_LIBRARIES}) +endif() +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 + OUTPUT_VARIABLE CVPY_SUFFIX + OUTPUT_STRIP_TRAILING_WHITESPACE) + +set_target_properties(${the_module} PROPERTIES + PREFIX "" + OUTPUT_NAME cv2 + SUFFIX ${CVPY_SUFFIX}) + +if(ENABLE_SOLUTION_FOLDERS) + set_target_properties(${the_module} PROPERTIES FOLDER "bindings") +endif() + +if(MSVC) + add_definitions(-DCVAPI_EXPORTS) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX AND NOT ENABLE_NOISY_WARNINGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-function") +endif() + +if(MSVC AND NOT ENABLE_NOISY_WARNINGS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4100") #unreferenced formal parameter + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4127") #conditional expression is constant + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4505") #unreferenced local function has been removed + string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") +endif() + +if(MSVC AND NOT BUILD_SHARED_LIBS) + set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG") +endif() + +if(MSVC AND NOT PYTHON_DEBUG_LIBRARIES) + set(PYTHON_INSTALL_CONFIGURATIONS CONFIGURATIONS Release) +else() + set(PYTHON_INSTALL_CONFIGURATIONS "") +endif() + +if(WIN32) + set(PYTHON_INSTALL_ARCHIVE "") +else() + set(PYTHON_INSTALL_ARCHIVE ARCHIVE DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python) +endif() + +if(NOT INSTALL_CREATE_DISTRIB) + install(TARGETS ${the_module} + ${PYTHON_INSTALL_CONFIGURATIONS} + RUNTIME DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python + LIBRARY DESTINATION ${PYTHON_PACKAGES_PATH} COMPONENT python + ${PYTHON_INSTALL_ARCHIVE} + ) +else() + if(DEFINED PYTHON_VERSION_MAJOR) + set(__ver "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}") + else() + set(__ver "unknown") + endif() + install(TARGETS ${the_module} + CONFIGURATIONS Release + RUNTIME DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT python + LIBRARY DESTINATION python/${__ver}/${OpenCV_ARCH} COMPONENT python + ) +endif() + +unset(PYTHON_SRC_DIR) +unset(PYTHON_CVPY_PROCESS) +unset(CVPY_SUFFIX) +unset(PYTHON_INSTALL_CONFIGURATIONS) +unset(PYTHON_INSTALL_ARCHIVE) diff --git a/modules/python/python2/CMakeLists.txt b/modules/python/python2/CMakeLists.txt new file mode 100644 index 0000000000..8756316007 --- /dev/null +++ b/modules/python/python2/CMakeLists.txt @@ -0,0 +1,26 @@ +if(NOT PYTHON2LIBS_FOUND OR NOT PYTHON2_NUMPY_INCLUDE_DIRS) + ocv_module_disable(python2) +endif() + +set(the_description "The python2 bindings") +ocv_add_module(python2 BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect OPTIONAL opencv_nonfree) + +set(PYTHON_INCLUDE_PATH ${PYTHON2_INCLUDE_PATH}) +set(PYTHON_NUMPY_INCLUDE_PATH ${PYTHON2_NUMPY_INCLUDE_PATH}) +set(PYTHON_EXECUTABLE ${PYTHON2_EXECUTABLE}) +set(PYTHON_DEBUG_LIBRARIES ${PYTHON2_DEBUG_LIBRARIES}) +set(PYTHON_LIBRARIES ${PYTHON2_LIBRARIES}) +set(PYTHON_PACKAGES_PATH ${PYTHON2_PACKAGES_PATH}) +set(PYTHON_VERSION_MAJOR ${PYTHON2_VERSION_MAJOR}) +set(PYTHON_VERSION_MINOR ${PYTHON2_VERSION_MINOR}) + +include(../common.cmake) + +unset(PYTHON_INCLUDE_PATH) +unset(PYTHON_NUMPY_INCLUDE_PATH) +unset(PYTHON_EXECUTABLE) +unset(PYTHON_DEBUG_LIBRARIES) +unset(PYTHON_LIBRARIES) +unset(PYTHON_PACKAGES_PATH) +unset(PYTHON_VERSION_MAJOR) +unset(PYTHON_VERSION_MINOR) diff --git a/modules/python/python3/CMakeLists.txt b/modules/python/python3/CMakeLists.txt new file mode 100644 index 0000000000..b380bacc11 --- /dev/null +++ b/modules/python/python3/CMakeLists.txt @@ -0,0 +1,26 @@ +if(NOT PYTHON3LIBS_FOUND OR NOT PYTHON3_NUMPY_INCLUDE_DIRS) + ocv_module_disable(python3) +endif() + +set(the_description "The python3 bindings") +ocv_add_module(python3 BINDINGS opencv_core opencv_flann opencv_imgproc opencv_video opencv_ml opencv_features2d opencv_highgui opencv_calib3d opencv_photo opencv_objdetect OPTIONAL opencv_nonfree) + +set(PYTHON_INCLUDE_PATH ${PYTHON3_INCLUDE_PATH}) +set(PYTHON_NUMPY_INCLUDE_PATH ${PYTHON3_NUMPY_INCLUDE_PATH}) +set(PYTHON_EXECUTABLE ${PYTHON3_EXECUTABLE}) +set(PYTHON_DEBUG_LIBRARIES ${PYTHON3_DEBUG_LIBRARIES}) +set(PYTHON_LIBRARIES ${PYTHON3_LIBRARIES}) +set(PYTHON_PACKAGES_PATH ${PYTHON3_PACKAGES_PATH}) +set(PYTHON_VERSION_MAJOR ${PYTHON3_VERSION_MAJOR}) +set(PYTHON_VERSION_MINOR ${PYTHON3_VERSION_MINOR}) + +include(../common.cmake) + +unset(PYTHON_INCLUDE_PATH) +unset(PYTHON_NUMPY_INCLUDE_PATH) +unset(PYTHON_EXECUTABLE) +unset(PYTHON_DEBUG_LIBRARIES) +unset(PYTHON_LIBRARIES) +unset(PYTHON_PACKAGES_PATH) +unset(PYTHON_VERSION_MAJOR) +unset(PYTHON_VERSION_MINOR) From e7216a5987c77e31585ed573c620089715333985 Mon Sep 17 00:00:00 2001 From: Elena Gvozdeva Date: Tue, 29 Jul 2014 11:34:39 +0400 Subject: [PATCH 02/21] Used float instead of int for CV_8U in sumTemplate --- modules/imgproc/src/opencl/match_template.cl | 28 +++++--------------- modules/imgproc/src/templmatch.cpp | 14 +++++----- 2 files changed, 13 insertions(+), 29 deletions(-) diff --git a/modules/imgproc/src/opencl/match_template.cl b/modules/imgproc/src/opencl/match_template.cl index 1919e8edd2..c6c9468e88 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/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 164af425e3..b0b188be67 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -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; @@ -281,8 +281,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 +358,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; From dc3c691c8c784b097f72f2df2b0275f734a8c321 Mon Sep 17 00:00:00 2001 From: Elena Gvozdeva Date: Tue, 29 Jul 2014 12:06:20 +0400 Subject: [PATCH 03/21] new block size for dft --- modules/imgproc/src/templmatch.cpp | 43 ++++++++++++++---------------- 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index b0b188be67..00e61061d4 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -129,7 +129,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 +136,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); - - 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.))); - - dft_size.width = getOptimalDFTSize(block_size.width + templ_size.width - 1); + const double blockScale = 4.5; + const int minBlockSize = 256; + + block_size.width = cvRound(result_size.width*blockScale); + block_size.width = 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 = 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 = MIN( block_size.width, result_size.width); + block_size.height = dft_size.height - templ_size.height + 1; + block_size.height = MIN( block_size.height, result_size.height ); image_block.create(dft_size, CV_32F); templ_block.create(dft_size, CV_32F); @@ -164,21 +170,12 @@ 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; CV_Assert(_image.type() == CV_32F); CV_Assert(_templ.type() == CV_32F); - + buf.create(_image.size(), _templ.size()); _result.create(buf.result_size, CV_32F); @@ -202,7 +199,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) From dbb5993d13e8542e0f6cca3dcf2d2430ff9037e8 Mon Sep 17 00:00:00 2001 From: Elena Gvozdeva Date: Tue, 29 Jul 2014 12:07:21 +0400 Subject: [PATCH 04/21] added dft for all platforms --- modules/imgproc/src/templmatch.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index 00e61061d4..aec83b74cb 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -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 @@ -138,7 +134,7 @@ void ConvolveBuf::create(Size image_size, Size templ_size) const double blockScale = 4.5; const int minBlockSize = 256; - + block_size.width = cvRound(result_size.width*blockScale); block_size.width = MAX( block_size.width, minBlockSize - templ_size.width + 1 ); block_size.width = std::min( block_size.width, result_size.width ); @@ -175,7 +171,7 @@ static bool convolve_dft(InputArray _image, InputArray _templ, OutputArray _resu ConvolveBuf buf; CV_Assert(_image.type() == CV_32F); CV_Assert(_templ.type() == CV_32F); - + buf.create(_image.size(), _templ.size()); _result.create(buf.result_size, CV_32F); From 90ac88cb8e39f7f7fcb64041da0a0fdfbbe31b00 Mon Sep 17 00:00:00 2001 From: Elena Gvozdeva Date: Wed, 30 Jul 2014 14:28:02 +0400 Subject: [PATCH 05/21] use std::min,max --- modules/imgproc/src/templmatch.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/imgproc/src/templmatch.cpp b/modules/imgproc/src/templmatch.cpp index aec83b74cb..45f2529f7a 100644 --- a/modules/imgproc/src/templmatch.cpp +++ b/modules/imgproc/src/templmatch.cpp @@ -136,22 +136,22 @@ void ConvolveBuf::create(Size image_size, Size templ_size) const int minBlockSize = 256; block_size.width = cvRound(result_size.width*blockScale); - block_size.width = MAX( block_size.width, minBlockSize - templ_size.width + 1 ); + 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 = MAX(getOptimalDFTSize(block_size.width + templ_size.width - 1), 2); + 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" ); // recompute block size block_size.width = dft_size.width - templ_size.width + 1; - block_size.width = MIN( block_size.width, result_size.width); + block_size.width = std::min( block_size.width, result_size.width); block_size.height = dft_size.height - templ_size.height + 1; - block_size.height = MIN( block_size.height, result_size.height ); + 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); From 52df3b232d87e5b144c37f4c89af2e8e1f1ff5c7 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 31 Jul 2014 03:27:06 -0400 Subject: [PATCH 06/21] Reference PYTHON_NUMPY_INCLUDE_DIRS not PYTHON_NUMPY_INCLUDE_PATH PYTHON_NUMPY_INCLUDE_PATH was a typo, it should have been PYTHON_NUMPY_INCLUDE_DIRS. --- modules/python/python2/CMakeLists.txt | 2 +- modules/python/python3/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/python/python2/CMakeLists.txt b/modules/python/python2/CMakeLists.txt index f65c75d783..4881cb5edf 100644 --- a/modules/python/python2/CMakeLists.txt +++ b/modules/python/python2/CMakeLists.txt @@ -6,7 +6,7 @@ set(the_description "The python2 bindings") set(MODULE_NAME python2) set(PYTHON_INCLUDE_PATH ${PYTHON2_INCLUDE_PATH}) -set(PYTHON_NUMPY_INCLUDE_PATH ${PYTHON2_NUMPY_INCLUDE_PATH}) +set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON2_NUMPY_INCLUDE_DIRS}) set(PYTHON_EXECUTABLE ${PYTHON2_EXECUTABLE}) set(PYTHON_DEBUG_LIBRARIES ${PYTHON2_DEBUG_LIBRARIES}) set(PYTHON_LIBRARIES ${PYTHON2_LIBRARIES}) diff --git a/modules/python/python3/CMakeLists.txt b/modules/python/python3/CMakeLists.txt index 7c23bd9c72..3f66492050 100644 --- a/modules/python/python3/CMakeLists.txt +++ b/modules/python/python3/CMakeLists.txt @@ -6,7 +6,7 @@ set(the_description "The python3 bindings") set(MODULE_NAME python3) set(PYTHON_INCLUDE_PATH ${PYTHON3_INCLUDE_PATH}) -set(PYTHON_NUMPY_INCLUDE_PATH ${PYTHON3_NUMPY_INCLUDE_PATH}) +set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON3_NUMPY_INCLUDE_DIRS}) set(PYTHON_EXECUTABLE ${PYTHON3_EXECUTABLE}) set(PYTHON_DEBUG_LIBRARIES ${PYTHON3_DEBUG_LIBRARIES}) set(PYTHON_LIBRARIES ${PYTHON3_LIBRARIES}) From 3fe4980ce1c38db20c1ad7e3e536aefdab059bf0 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 4 Aug 2014 14:12:48 +0200 Subject: [PATCH 07/21] Double precision for solvePnPRansac() --- modules/calib3d/src/solvepnp.cpp | 44 ++++++++++++++++++++++++++------ 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/modules/calib3d/src/solvepnp.cpp b/modules/calib3d/src/solvepnp.cpp index 2b2d1bdf34..20e2899737 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]; From b2acd1f75a3d281f901c975c25655c7fe524afda Mon Sep 17 00:00:00 2001 From: Adrian Stratulat Date: Sat, 19 Oct 2013 17:07:08 +0000 Subject: [PATCH 08/21] Vectorize split & merge for NEON --- modules/core/src/convert.cpp | 235 +++++++++++++++++++++++++++++++++-- 1 file changed, 227 insertions(+), 8 deletions(-) diff --git a/modules/core/src/convert.cpp b/modules/core/src/convert.cpp index 21d5bdaca7..d5d1efecbc 100644 --- a/modules/core/src/convert.cpp +++ b/modules/core/src/convert.cpp @@ -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]; From 8c2c3b54d934c308e006d280ca28b1653215999c Mon Sep 17 00:00:00 2001 From: Elena Gvozdeva Date: Mon, 4 Aug 2014 11:28:48 +0400 Subject: [PATCH 09/21] fixed ocl tests for BlendLinear, BoxFilter, Integral --- modules/imgproc/test/ocl/test_blend.cpp | 2 +- modules/imgproc/test/ocl/test_boxfilter.cpp | 2 +- modules/imgproc/test/ocl/test_imgproc.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/test/ocl/test_blend.cpp b/modules/imgproc/test/ocl/test_blend.cpp index 7b62b97172..6d8a15fb2b 100644 --- a/modules/imgproc/test/ocl/test_blend.cpp +++ b/modules/imgproc/test/ocl/test_blend.cpp @@ -117,7 +117,7 @@ OCL_TEST_P(BlendLinear, Accuracy) OCL_OFF(cv::blendLinear(src1_roi, src2_roi, weights1_roi, weights2_roi, dst_roi)); OCL_ON(cv::blendLinear(usrc1_roi, usrc2_roi, uweights1_roi, uweights2_roi, udst_roi)); - Near(depth <= CV_32S ? 1.0 : 0.2); + Near(depth <= CV_32S ? 1.0 : 0.5); } } diff --git a/modules/imgproc/test/ocl/test_boxfilter.cpp b/modules/imgproc/test/ocl/test_boxfilter.cpp index 63f4ebff20..4940dff799 100644 --- a/modules/imgproc/test/ocl/test_boxfilter.cpp +++ b/modules/imgproc/test/ocl/test_boxfilter.cpp @@ -109,7 +109,7 @@ OCL_TEST_P(BoxFilter, Mat) OCL_OFF(cv::boxFilter(src_roi, dst_roi, -1, ksize, anchor, normalize, borderType)); OCL_ON(cv::boxFilter(usrc_roi, udst_roi, -1, ksize, anchor, normalize, borderType)); - Near(depth <= CV_32S ? 1 : 1e-3); + Near(depth <= CV_32S ? 1 : 3e-3); } } diff --git a/modules/imgproc/test/ocl/test_imgproc.cpp b/modules/imgproc/test/ocl/test_imgproc.cpp index ad8e26cbca..69d8f4e786 100644 --- a/modules/imgproc/test/ocl/test_imgproc.cpp +++ b/modules/imgproc/test/ocl/test_imgproc.cpp @@ -347,7 +347,7 @@ OCL_TEST_P(Integral, Mat2) OCL_ON(cv::integral(usrc_roi, udst_roi, udst2_roi, sdepth, sqdepth)); Near(); - sqdepth == CV_32F ? Near2(1e-6, true) : Near2(); + sqdepth == CV_32F ? Near2(2e-4, true) : Near2(); } } From f32b52ea8dcb79a4a8b8e06ce7922fa1fc2bd5f9 Mon Sep 17 00:00:00 2001 From: Elena Gvozdeva Date: Mon, 4 Aug 2014 14:15:21 +0400 Subject: [PATCH 10/21] fixed test for CvtColor RGB -> Luv --- modules/imgproc/test/ocl/test_color.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/modules/imgproc/test/ocl/test_color.cpp b/modules/imgproc/test/ocl/test_color.cpp index 82bf2c06f1..5f3a2f73f9 100644 --- a/modules/imgproc/test/ocl/test_color.cpp +++ b/modules/imgproc/test/ocl/test_color.cpp @@ -302,14 +302,14 @@ OCL_TEST_P(CvtColor8u32f, Lab2LRGBA) { performTest(3, 4, CVTCODE(Lab2LRGB), dept // RGB -> Luv -OCL_TEST_P(CvtColor8u32f, BGR2Luv) { performTest(3, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 1e-2); } -OCL_TEST_P(CvtColor8u32f, RGB2Luv) { performTest(3, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 1e-2); } -OCL_TEST_P(CvtColor8u32f, LBGR2Luv) { performTest(3, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 4e-3); } -OCL_TEST_P(CvtColor8u32f, LRGB2Luv) { performTest(3, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 5e-3); } -OCL_TEST_P(CvtColor8u32f, BGRA2Luv) { performTest(4, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 8e-3); } -OCL_TEST_P(CvtColor8u32f, RGBA2Luv) { performTest(4, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 9e-3); } -OCL_TEST_P(CvtColor8u32f, LBGRA2Luv) { performTest(4, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 5e-3); } -OCL_TEST_P(CvtColor8u32f, LRGBA2Luv) { performTest(4, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 5e-3); } +OCL_TEST_P(CvtColor8u32f, BGR2Luv) { performTest(3, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 1.5e-2); } +OCL_TEST_P(CvtColor8u32f, RGB2Luv) { performTest(3, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 1.5e-2); } +OCL_TEST_P(CvtColor8u32f, LBGR2Luv) { performTest(3, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 6e-3); } +OCL_TEST_P(CvtColor8u32f, LRGB2Luv) { performTest(3, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 6e-3); } +OCL_TEST_P(CvtColor8u32f, BGRA2Luv) { performTest(4, 3, CVTCODE(BGR2Luv), depth == CV_8U ? 1 : 2e-2); } +OCL_TEST_P(CvtColor8u32f, RGBA2Luv) { performTest(4, 3, CVTCODE(RGB2Luv), depth == CV_8U ? 1 : 2e-2); } +OCL_TEST_P(CvtColor8u32f, LBGRA2Luv) { performTest(4, 3, CVTCODE(LBGR2Luv), depth == CV_8U ? 1 : 6e-3); } +OCL_TEST_P(CvtColor8u32f, LRGBA2Luv) { performTest(4, 3, CVTCODE(LRGB2Luv), depth == CV_8U ? 1 : 6e-3); } OCL_TEST_P(CvtColor8u32f, Luv2BGR) { performTest(3, 3, CVTCODE(Luv2BGR), depth == CV_8U ? 1 : 7e-5); } OCL_TEST_P(CvtColor8u32f, Luv2RGB) { performTest(3, 3, CVTCODE(Luv2RGB), depth == CV_8U ? 1 : 7e-5); } From 7999fbf7652a944b975bac1a3122f7288c0bc083 Mon Sep 17 00:00:00 2001 From: Elena Gvozdeva Date: Tue, 5 Aug 2014 11:55:18 +0400 Subject: [PATCH 11/21] fixed ocl_integral --- modules/imgproc/src/opencl/integral_sum.cl | 7 +++++-- modules/imgproc/test/ocl/test_imgproc.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/modules/imgproc/src/opencl/integral_sum.cl b/modules/imgproc/src/opencl/integral_sum.cl index 49a3bde955..3c51c1a28b 100644 --- a/modules/imgproc/src/opencl/integral_sum.cl +++ b/modules/imgproc/src/opencl/integral_sum.cl @@ -132,8 +132,11 @@ kernel void integral_sum_rows(__global const uchar *buf_ptr, int buf_step, int b } dst_sq_offset += dst_sq_step; - dst_sq = (__global sumSQT *)(dst_sq_ptr + mad24(x, dst_sq_step, dst_sq_offset)); - dst_sq[0] = 0; + if (x < rows - 1) + { + dst_sq = (__global sumSQT *)(dst_sq_ptr + mad24(x, dst_sq_step, dst_sq_offset)); + dst_sq[0] = 0; + } int buf_sq_index = mad24((int)sizeof(sumSQT), x, buf_sq_offset); sumSQT accum_sq = 0; diff --git a/modules/imgproc/test/ocl/test_imgproc.cpp b/modules/imgproc/test/ocl/test_imgproc.cpp index 69d8f4e786..ad8e26cbca 100644 --- a/modules/imgproc/test/ocl/test_imgproc.cpp +++ b/modules/imgproc/test/ocl/test_imgproc.cpp @@ -347,7 +347,7 @@ OCL_TEST_P(Integral, Mat2) OCL_ON(cv::integral(usrc_roi, udst_roi, udst2_roi, sdepth, sqdepth)); Near(); - sqdepth == CV_32F ? Near2(2e-4, true) : Near2(); + sqdepth == CV_32F ? Near2(1e-6, true) : Near2(); } } From 2637b18b67a9236fd58f3239e11f25d9f0393c19 Mon Sep 17 00:00:00 2001 From: vbystricky Date: Tue, 5 Aug 2014 16:34:23 +0400 Subject: [PATCH 12/21] Fix epsilon for OpenCL function ConverTo, for convertation from float to integer types --- modules/core/test/ocl/test_matrix_operation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/core/test/ocl/test_matrix_operation.cpp b/modules/core/test/ocl/test_matrix_operation.cpp index 1ff3bec6c2..252db01d16 100644 --- a/modules/core/test/ocl/test_matrix_operation.cpp +++ b/modules/core/test/ocl/test_matrix_operation.cpp @@ -96,7 +96,7 @@ OCL_TEST_P(ConvertTo, Accuracy) OCL_OFF(src_roi.convertTo(dst_roi, dstType, alpha, beta)); OCL_ON(usrc_roi.convertTo(udst_roi, dstType, alpha, beta)); - double eps = src_depth >= CV_32F || CV_MAT_DEPTH(dstType) >= CV_32F ? 2e-4 : 1; + double eps = CV_MAT_DEPTH(dstType) >= CV_32F ? 2e-4 : 1; OCL_EXPECT_MATS_NEAR(dst, eps); } } From 774d277c1f3ac883d489fd2011da788204d63b1b Mon Sep 17 00:00:00 2001 From: vbystricky Date: Tue, 5 Aug 2014 17:30:06 +0400 Subject: [PATCH 13/21] Fix error in OpenCl version of meanstddev for continues src and not continues mask --- modules/core/src/opencl/meanstddev.cl | 2 +- modules/core/src/stat.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/core/src/opencl/meanstddev.cl b/modules/core/src/opencl/meanstddev.cl index 39e917e96d..ed68c64538 100644 --- a/modules/core/src/opencl/meanstddev.cl +++ b/modules/core/src/opencl/meanstddev.cl @@ -59,7 +59,7 @@ __kernel void meanStdDev(__global const uchar * srcptr, int src_step, int src_of for (int grain = groups * WGS; id < total; id += grain) { #ifdef HAVE_MASK -#ifdef HAVE_SRC_CONT +#ifdef HAVE_MASK_CONT int mask_index = id; #else int mask_index = mad24(id / cols, mask_step, id % cols); diff --git a/modules/core/src/stat.cpp b/modules/core/src/stat.cpp index f47a28ad26..26bae7a44d 100644 --- a/modules/core/src/stat.cpp +++ b/modules/core/src/stat.cpp @@ -918,7 +918,8 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv { int type = _src.type(), depth = CV_MAT_DEPTH(type), cn = CV_MAT_CN(type); bool doubleSupport = ocl::Device::getDefault().doubleFPConfig() > 0, - isContinuous = _src.isContinuous(); + isContinuous = _src.isContinuous(), + isMaskContinuous = _mask.isContinuous(); const ocl::Device &defDev = ocl::Device::getDefault(); int groups = defDev.maxComputeUnits(); if (defDev.isIntel()) @@ -943,13 +944,14 @@ static bool ocl_meanStdDev( InputArray _src, OutputArray _mean, OutputArray _sdv char cvt[2][40]; String opts = format("-D srcT=%s -D srcT1=%s -D dstT=%s -D dstT1=%s -D sqddepth=%d" - " -D sqdstT=%s -D sqdstT1=%s -D convertToSDT=%s -D cn=%d%s" + " -D sqdstT=%s -D sqdstT1=%s -D convertToSDT=%s -D cn=%d%s%s" " -D convertToDT=%s -D WGS=%d -D WGS2_ALIGNED=%d%s%s", ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(dtype), ocl::typeToStr(ddepth), sqddepth, ocl::typeToStr(sqdtype), ocl::typeToStr(sqddepth), ocl::convertTypeStr(depth, sqddepth, cn, cvt[0]), cn, isContinuous ? " -D HAVE_SRC_CONT" : "", + isMaskContinuous ? " -D HAVE_MASK_CONT" : "", ocl::convertTypeStr(depth, ddepth, cn, cvt[1]), (int)wgs, wgs2_aligned, haveMask ? " -D HAVE_MASK" : "", doubleSupport ? " -D DOUBLE_SUPPORT" : ""); From 55188fe991a962e6b04fb087e0845b3a0d4b88b4 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Fri, 1 Aug 2014 18:11:20 +0400 Subject: [PATCH 14/21] world fix --- CMakeLists.txt | 1 - apps/traincascade/CMakeLists.txt | 10 +- cmake/OpenCVDetectAndroidSDK.cmake | 7 +- cmake/OpenCVModule.cmake | 364 ++++++++++-------- cmake/OpenCVPCHSupport.cmake | 12 + cmake/OpenCVUtils.cmake | 104 ++++- cmake/templates/OpenCVConfig.cmake.in | 37 +- modules/CMakeLists.txt | 2 +- .../camera_wrapper/CMakeLists.txt | 2 +- modules/calib3d/perf/opencl/perf_stereobm.cpp | 2 +- modules/calib3d/src/circlesgrid.cpp | 1 + modules/calib3d/src/stereobm.cpp | 2 +- modules/calib3d/test/opencl/test_stereobm.cpp | 2 +- modules/core/CMakeLists.txt | 5 +- modules/core/perf/opencl/perf_arithm.cpp | 2 +- modules/core/perf/opencl/perf_bufferpool.cpp | 2 +- modules/core/perf/opencl/perf_channels.cpp | 2 +- modules/core/perf/opencl/perf_dxt.cpp | 2 +- modules/core/perf/opencl/perf_gemm.cpp | 2 +- modules/core/perf/opencl/perf_matop.cpp | 2 +- modules/core/perf/opencl/perf_usage_flags.cpp | 2 +- modules/core/src/arithm.cpp | 2 +- modules/core/src/convert.cpp | 2 +- modules/core/src/copy.cpp | 2 +- modules/core/src/dxt.cpp | 2 +- modules/core/src/mathfuncs.cpp | 2 +- modules/core/src/matmul.cpp | 2 +- modules/core/src/matrix.cpp | 2 +- .../src/opencl/runtime/opencl_clamdblas.cpp | 2 +- .../src/opencl/runtime/opencl_clamdfft.cpp | 2 +- .../core/src/opencl/runtime/opencl_core.cpp | 2 +- modules/core/src/stat.cpp | 2 +- modules/core/src/umatrix.cpp | 2 +- modules/core/test/ocl/test_arithm.cpp | 2 +- modules/core/test/ocl/test_channels.cpp | 2 +- modules/core/test/ocl/test_dft.cpp | 2 +- modules/core/test/ocl/test_gemm.cpp | 2 +- modules/core/test/ocl/test_matrix_expr.cpp | 2 +- .../core/test/ocl/test_matrix_operation.cpp | 2 +- modules/cudaarithm/CMakeLists.txt | 2 - modules/cudacodec/CMakeLists.txt | 2 - modules/cudev/test/CMakeLists.txt | 2 +- .../perf/opencl/perf_brute_force_matcher.cpp | 2 +- modules/features2d/perf/opencl/perf_fast.cpp | 2 +- modules/features2d/perf/opencl/perf_orb.cpp | 2 +- modules/features2d/src/fast.cpp | 2 +- modules/features2d/src/kaze/AKAZEConfig.h | 2 +- modules/features2d/src/kaze/AKAZEFeatures.h | 2 +- modules/features2d/src/kaze/KAZEConfig.h | 2 +- modules/features2d/src/kaze/fed.cpp | 2 +- .../src/kaze/nldiffusion_functions.h | 2 +- modules/features2d/src/matchers.cpp | 2 +- modules/features2d/src/orb.cpp | 2 +- .../test/ocl/test_brute_force_matcher.cpp | 2 +- modules/highgui/CMakeLists.txt | 43 ++- modules/imgcodecs/CMakeLists.txt | 35 +- modules/imgproc/perf/opencl/perf_3vs4.cpp | 2 +- .../imgproc/perf/opencl/perf_accumulate.cpp | 2 +- modules/imgproc/perf/opencl/perf_blend.cpp | 2 +- modules/imgproc/perf/opencl/perf_color.cpp | 2 +- modules/imgproc/perf/opencl/perf_filters.cpp | 2 +- modules/imgproc/perf/opencl/perf_gftt.cpp | 2 +- modules/imgproc/perf/opencl/perf_imgproc.cpp | 2 +- modules/imgproc/perf/opencl/perf_imgwarp.cpp | 2 +- .../perf/opencl/perf_matchTemplate.cpp | 2 +- modules/imgproc/perf/opencl/perf_moments.cpp | 2 +- modules/imgproc/perf/opencl/perf_pyramid.cpp | 2 +- modules/imgproc/src/accum.cpp | 2 +- modules/imgproc/src/blend.cpp | 2 +- modules/imgproc/src/canny.cpp | 2 +- modules/imgproc/src/clahe.cpp | 2 +- modules/imgproc/src/color.cpp | 2 +- modules/imgproc/src/corner.cpp | 2 +- modules/imgproc/src/deriv.cpp | 2 +- modules/imgproc/src/featureselect.cpp | 2 +- modules/imgproc/src/filter.cpp | 2 +- modules/imgproc/src/histogram.cpp | 2 +- modules/imgproc/src/imgwarp.cpp | 2 +- modules/imgproc/src/moments.cpp | 2 +- modules/imgproc/src/morph.cpp | 2 +- modules/imgproc/src/pyramids.cpp | 2 +- modules/imgproc/src/smooth.cpp | 2 +- modules/imgproc/src/sumpixels.cpp | 2 +- modules/imgproc/src/templmatch.cpp | 2 +- modules/imgproc/src/thresh.cpp | 2 +- modules/imgproc/test/ocl/test_accumulate.cpp | 2 +- modules/imgproc/test/ocl/test_blend.cpp | 2 +- modules/imgproc/test/ocl/test_boxfilter.cpp | 2 +- modules/imgproc/test/ocl/test_canny.cpp | 2 +- modules/imgproc/test/ocl/test_color.cpp | 2 +- modules/imgproc/test/ocl/test_filter2d.cpp | 2 +- modules/imgproc/test/ocl/test_filters.cpp | 2 +- modules/imgproc/test/ocl/test_gftt.cpp | 2 +- modules/imgproc/test/ocl/test_histogram.cpp | 2 +- modules/imgproc/test/ocl/test_imgproc.cpp | 2 +- .../imgproc/test/ocl/test_match_template.cpp | 2 +- .../imgproc/test/ocl/test_medianfilter.cpp | 2 +- modules/imgproc/test/ocl/test_pyramids.cpp | 2 +- modules/imgproc/test/ocl/test_sepfilter2D.cpp | 2 +- modules/imgproc/test/ocl/test_warp.cpp | 2 +- modules/java/CMakeLists.txt | 16 +- modules/nonfree/src/surf.ocl.cpp | 2 +- .../objdetect/perf/opencl/perf_cascades.cpp | 2 +- .../objdetect/perf/opencl/perf_hogdetect.cpp | 2 +- modules/objdetect/src/cascadedetect.cpp | 2 +- modules/objdetect/src/hog.cpp | 2 +- .../test/opencl/test_hogdetector.cpp | 2 +- modules/photo/perf/opencl/perf_denoising.cpp | 2 +- .../src/fast_nlmeans_denoising_opencl.hpp | 4 +- modules/photo/test/ocl/test_denoising.cpp | 2 +- modules/python/CMakeLists.txt | 14 +- modules/stitching/perf/opencl/perf_stitch.cpp | 2 +- .../stitching/perf/opencl/perf_warpers.cpp | 2 +- modules/stitching/src/blenders.cpp | 2 +- modules/stitching/src/timelapsers.cpp | 2 +- modules/stitching/src/warpers.cpp | 2 +- modules/stitching/test/ocl/test_warpers.cpp | 2 +- modules/superres/src/btv_l1.cpp | 2 +- modules/superres/test/test_precomp.hpp | 2 +- modules/ts/CMakeLists.txt | 2 - modules/video/perf/opencl/perf_bgfg_mog2.cpp | 2 +- modules/video/perf/opencl/perf_motempl.cpp | 2 +- .../perf/opencl/perf_optflow_dualTVL1.cpp | 2 +- .../perf/opencl/perf_optflow_farneback.cpp | 2 +- .../video/perf/opencl/perf_optflow_pyrlk.cpp | 2 +- modules/video/src/bgfg_gaussmix2.cpp | 2 +- modules/video/src/lkpyramid.cpp | 2 +- modules/video/src/motempl.cpp | 2 +- modules/video/src/optflowgf.cpp | 2 +- modules/video/src/tvl1flow.cpp | 2 +- modules/video/test/ocl/test_bgfg_mog2.cpp | 2 +- modules/video/test/ocl/test_motempl.cpp | 2 +- .../video/test/ocl/test_optflow_farneback.cpp | 2 +- .../video/test/ocl/test_optflow_tvl1flow.cpp | 2 +- modules/video/test/ocl/test_optflowpyrlk.cpp | 2 +- modules/videoio/CMakeLists.txt | 72 ++-- modules/viz/CMakeLists.txt | 2 +- modules/world/CMakeLists.txt | 139 ++----- modules/world/src/precomp.hpp | 6 +- modules/world/src/world_init.cpp | 3 - samples/android/CMakeLists.txt | 4 +- samples/cpp/CMakeLists.txt | 6 +- samples/directx/CMakeLists.txt | 2 +- samples/gpu/CMakeLists.txt | 10 +- samples/gpu/performance/CMakeLists.txt | 4 +- samples/tapi/CMakeLists.txt | 2 +- 146 files changed, 625 insertions(+), 520 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dd2054d977..e397912943 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -554,7 +554,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 ab32b4cfb5..59d48172da 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 90e11761e7..d97e9ec74f 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 3f4da5f106..d53f0666ec 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 +macro(ocv_target_include_modules 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() + elseif(EXISTS "${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_include_modules_recurse) +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_include_directories("${OPENCV_MODULE_${d}_LOCATION}/include") + ocv_target_include_directories(${target} "${OPENCV_MODULE_${d}_LOCATION}/include") endif() if(OPENCV_MODULE_${d}_DEPS) - ocv_include_modules(${OPENCV_MODULE_${d}_DEPS}) + ocv_target_include_modules(${target} ${OPENCV_MODULE_${d}_DEPS}) endif() elseif(EXISTS "${d}") - ocv_include_directories("${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 8af30f1151..e5fb90e6ff 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 d8171770de..a7d449f1b9 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 e3bde4bbe3..5d97474f3a 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 400b2a8381..2c6c34304e 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 d08e2c469d..c306db1de5 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 8fca1b894f..1436eb9d94 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 0b89e181c2..ea169bdd72 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/stereobm.cpp b/modules/calib3d/src/stereobm.cpp index 7c06debcb3..676202d129 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 636d76cb27..e64fe415e7 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 e5898023f2..5158dec5f4 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 17badca765..9cb5ac9821 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 2e01db4045..3d241a6a56 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 1dbad51a06..62d6b822b7 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 c0e41485e4..8a45a8c1ab 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 700f380492..205062dacb 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 67d382239c..0fd5d437c4 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 3f59fec8be..b140e3a046 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 2211fcd367..b8ecfdd68d 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 d6abaa4adb..74f1cf0b97 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 { diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 8bd2f457d9..2bd6ebb9d2 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 bbe0f74001..c1551acb41 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 f36e268d0d..6c6ed6b1c8 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 2ef44179d8..b3c04a6bf3 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 398abcaaa6..46c8eeac86 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 420fdb97d3..379929993f 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 36a9ed2a71..255bcd826a 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 5dbc85ec10..93f6aae5de 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 26bae7a44d..7abbde543e 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 60f547794c..494f3e3c06 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 b0905b19f0..3af01f3d50 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 53d7de5d52..2a07bc1085 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 cd0c1f07d0..db280f19cf 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 e92fc2a1c9..e98135a3dc 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 167026d8cd..b8448fb50c 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 252db01d16..b19b74f543 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 c819ec928d..b4708e723a 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 5d8f7327c0..90599766ad 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 363970e4b7..89213e236d 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 2e6e574160..2cb8daabfb 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 7816da7b10..c4a8e078c0 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 f40b5f4b92..c551dee88a 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 c01cbba698..79b6d6cef3 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 c7ac1cfc0b..e2ba51c531 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 f8ce7a4889..9119c97f2f 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 21489a07a4..546ee36579 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 7c2588559d..cb47628e03 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 5c161a6e7c..6665e54270 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 2b5605031a..1ae1340d1d 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 4fe9cbc237..57bce1ce4e 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 0e1df784f2..635953307c 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 78d6bfb094..de8c27ba33 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 8cf60e5469..5ef34da53e 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 f6601e1233..940a5ff63b 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 5b7ac4c75d..e0ba471b9c 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 f595069bde..6396fef7e2 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 4a30f3a1f9..14dd614904 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 9667b8f907..ede98c308e 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 29626c62e3..b6c3b2c369 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 7f0770853d..f441bd9b32 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 b5a5138e20..d6832aec54 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 db9199b878..d230f90465 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 e77b76850d..69a3e6835c 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 8bbc3184fc..f26fd1940e 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 04a70128bb..1a4b4080e1 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 4fbdff9c3d..7a2e57d520 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 2a87ae05b4..09898a539e 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 f19f192430..1a26744257 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 351ee74e43..db5bcd35f2 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 923d78b30f..1fdd047cd1 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 1a29c38abf..80b1e9b33c 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 54bb65fffa..a50b704e8a 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 6c0da79ccf..4928a16d28 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 b38ddcad0c..1006897e4e 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 1d16bcc3fc..907fa445de 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 a61002a792..b114264e31 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 520d26d6c7..8985a7f06b 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/pyramids.cpp b/modules/imgproc/src/pyramids.cpp index 2714e08f30..658eb42152 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 907a6591ba..7f2e31bdc4 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 e7694b01a9..1c6f1513f1 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 164af425e3..37e4d1113a 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 ////////////////////////////////////////////////////////// diff --git a/modules/imgproc/src/thresh.cpp b/modules/imgproc/src/thresh.cpp index 988fc9e9f6..9376d62a50 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 50c9085cb4..cebf173d5d 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 6d8a15fb2b..d64b0bae8e 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 4940dff799..19a6ace75e 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 631fe5bd19..fadf777985 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 5f3a2f73f9..818d6a85ab 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 18ba4cc529..03a6bcff74 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 61f38a6b8b..35e4aa8f81 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 6e65f90dd0..15618cc308 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 68a2a60fd0..e8813c85ad 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 ad8e26cbca..d89101799a 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 8c8a1238c7..a525039ac2 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 6015ed1d77..74077f6db7 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 a129c7f771..5ac88411df 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 f7a18aae10..ed42e8b4a7 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 53d82187f9..0bcc330c70 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 38b75e8d36..364cb87ea9 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_EXECUTABLE OR NOT ANT_EXECUTABLE OR NOT (JNI_FOUND OR (ANDROID AND ANDROID_NATIVE_API_LEVEL GREATER 7))) +if(IOS OR NOT PYTHON_EXECUTABLE 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 eaf50fbc74..f46fc500f2 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 dd61cdb668..7cd1112a5d 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 36ab857c8b..7c107a962d 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 2d5c0795dc..70311d91fe 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 a84c00d051..7230954dc6 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 b3ef6b48fb..eb666cb1c8 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 a2ee9178a1..14ffa3a15a 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 2ec9b94878..ae173905d8 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 b533399ccd..cb2d74f850 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 128f28558f..f70092ac8a 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(python) endif() @@ -67,15 +69,15 @@ add_custom_command( DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/headers.txt DEPENDS ${opencv_hdrs}) -add_library(${the_module} SHARED src2/cv2.cpp ${cv2_generated_hdrs}) +ocv_add_library(${the_module} SHARED 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 @@ -92,7 +94,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 3434726996..ce7c3a9f11 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 6a8be4ebe8..57ca9a602d 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 03aad752fe..2fb04d29e9 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 d78ad86a57..bc1d62e1a8 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 8b2c77e759..c01b7d0d3b 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 43f0e9741d..4a95fff00f 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 d54b4b398a..3b3513e8de 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 553481818c..9e89b428e6 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 c923a29d8f..9727c9a8c5 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 50814bf817..12223d6631 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 7956857216..d603569024 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 72b1b0cbb2..90e656d81e 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 a17ed4dd9d..03eac1a07e 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 1d7e643d52..6041a4b51f 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 a5c48cb1f3..08c3d12d6e 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 3e939391c2..60e990f42d 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 bb48206ecf..af19429252 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 c0b1d88f12..4225e3d7fc 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 914f09c730..fec000dc4f 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 0a52227ece..49539ac04d 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 91053d9add..f8c6abc633 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 cc40f749ba..ec718d4f67 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 6e7150718b..bd32252b27 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 94195eabe4..3c264a5e41 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 96ac5045f5..f92f5ea689 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 d839491c1b..7fddb53880 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 33a9304c87..4e05188e03 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(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}}") +if(NOT OPENCV_INITIAL_PASS) + project(opencv_world) + + 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_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() +ocv_add_module(world opencv_core) -set(objlist "") +set(headers_list "HEADERS") +set(sources_list "SOURCES") +set(link_deps "") 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}\"") - endif() - endforeach() + 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 1aa056848f..a46e470b43 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 3fd13f392a..685e44bdf7 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 1ca60fbb91..8cad0e9fe1 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 f22483cf6e..26acad1452 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 1083894100..15a6575374 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 849e3109df..01bd694bb8 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 9289180afc..07125c2eb2 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 cf88f3a98f..83fd7260ac 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}" From fc0f254f0042dd94419bdc07358a7fd38577b359 Mon Sep 17 00:00:00 2001 From: Alexander Alekhin Date: Tue, 5 Aug 2014 20:37:18 +0400 Subject: [PATCH 15/21] make distrib with world (shared libs) --- CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index e397912943..58108fa346 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 From 976c727eec7b9bb3f4c12b7ed4ada8b3f664bf69 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 6 Aug 2014 02:30:35 -0400 Subject: [PATCH 16/21] Fix a few more PYTHON_NUMPY_INCLUDE_PATH The previous commit fixing references to PYTHON_NUMPY_INCLUDE_PATH missed a few unset()s. --- modules/python/python2/CMakeLists.txt | 2 +- modules/python/python3/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/python/python2/CMakeLists.txt b/modules/python/python2/CMakeLists.txt index 4881cb5edf..01a3b474d0 100644 --- a/modules/python/python2/CMakeLists.txt +++ b/modules/python/python2/CMakeLists.txt @@ -18,7 +18,7 @@ include(../common.cmake) unset(MODULE_NAME) unset(PYTHON_INCLUDE_PATH) -unset(PYTHON_NUMPY_INCLUDE_PATH) +unset(PYTHON_NUMPY_INCLUDE_DIRS) unset(PYTHON_EXECUTABLE) unset(PYTHON_DEBUG_LIBRARIES) unset(PYTHON_LIBRARIES) diff --git a/modules/python/python3/CMakeLists.txt b/modules/python/python3/CMakeLists.txt index 3f66492050..14672d3c75 100644 --- a/modules/python/python3/CMakeLists.txt +++ b/modules/python/python3/CMakeLists.txt @@ -18,7 +18,7 @@ include(../common.cmake) unset(MODULE_NAME) unset(PYTHON_INCLUDE_PATH) -unset(PYTHON_NUMPY_INCLUDE_PATH) +unset(PYTHON_NUMPY_INCLUDE_DIRS) unset(PYTHON_EXECUTABLE) unset(PYTHON_DEBUG_LIBRARIES) unset(PYTHON_LIBRARIES) From 9d9411555fa87321a1e36a39c8993c224f66e2fd Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Wed, 6 Aug 2014 02:31:30 -0400 Subject: [PATCH 17/21] Place Python library out in dedicated folder Place the built Python module library in a dedicated folder inside of lib/. This ensures that even if the Python 2 and Python 3 module names conflict, they will not overwrite one another. --- modules/python/common.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/python/common.cmake b/modules/python/common.cmake index 7d964067af..c37ae6681b 100644 --- a/modules/python/common.cmake +++ b/modules/python/common.cmake @@ -71,6 +71,7 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; pri OUTPUT_STRIP_TRAILING_WHITESPACE) set_target_properties(${the_module} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_PATH}/${MODULE_NAME}" PREFIX "" OUTPUT_NAME cv2 SUFFIX ${CVPY_SUFFIX}) From f3aa4bdf5941f413282d3400359e946bf812e2e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20W=C3=B6ldecke?= Date: Wed, 6 Aug 2014 19:02:48 +0200 Subject: [PATCH 18/21] fix misinterpretation of empty window name The documentation states, that a NULL or an empty window name can be used to refer to the control panel. But the string parameters of the C++ frontend methods cannot be NULL and converting an empty string to a const char* by c_str() doesn't produce a NULL pointer, but an empty string. Unfortunately, the const char* pointer is just passed on to the standard C functions in the QT backend, which doesn't check for the empty string case. There are two places where the empty string check could have been introduced: inside the frontend or inside the backend. As long as the documentation only mentions this as a special case for the QT backend, the best place seems to be there. --- modules/highgui/src/window_QT.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/highgui/src/window_QT.cpp b/modules/highgui/src/window_QT.cpp index 1433f744de..d4dfc989f5 100644 --- a/modules/highgui/src/window_QT.cpp +++ b/modules/highgui/src/window_QT.cpp @@ -401,7 +401,7 @@ static CvTrackbar* icvFindTrackBarByName(const char* name_trackbar, const char* { QString nameQt(name_trackbar); - if (!name_window && global_control_panel) //window name is null and we have a control panel + if ((!name_window || !name_window[0]) && global_control_panel) //window name is null and we have a control panel layout = global_control_panel->myLayout; if (!layout) From d921cde4d2ee72533896ef971e8e30d2ce33806a Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 7 Aug 2014 00:16:49 -0400 Subject: [PATCH 19/21] Add opencv_matlab to Python ignored modules Requested by @vpisarev in #3047. --- modules/python/common.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/modules/python/common.cmake b/modules/python/common.cmake index c37ae6681b..581822e9d5 100644 --- a/modules/python/common.cmake +++ b/modules/python/common.cmake @@ -15,6 +15,7 @@ endforeach(mp) # module blacklist ocv_list_filterout(candidate_deps "^opencv_cud(a|ev)") ocv_list_filterout(candidate_deps "^opencv_adas$") +ocv_list_filterout(candidate_deps "^opencv_matlab$") ocv_list_filterout(candidate_deps "^opencv_tracking$") From 7d41ce23a757b56d6b4c96d741f9a4b175606a70 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 7 Aug 2014 00:21:42 -0400 Subject: [PATCH 20/21] Build Python 3 bindings in subdirectory Build the Python 3 cv2 module in lib/python3/, to avoid potential naming conflicts with the Python 2 bindings. The Python 2 bindings are placed directly in lib/, where they are required for the Buildbot to successfully execute the Python tests. --- modules/python/common.cmake | 2 +- modules/python/python2/CMakeLists.txt | 3 +++ modules/python/python3/CMakeLists.txt | 2 ++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/modules/python/common.cmake b/modules/python/common.cmake index 581822e9d5..30f6d2813c 100644 --- a/modules/python/common.cmake +++ b/modules/python/common.cmake @@ -72,7 +72,7 @@ execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import distutils.sysconfig; pri OUTPUT_STRIP_TRAILING_WHITESPACE) set_target_properties(${the_module} PROPERTIES - LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_PATH}/${MODULE_NAME}" + LIBRARY_OUTPUT_DIRECTORY "${LIBRARY_OUTPUT_PATH}/${MODULE_INSTALL_SUBDIR}" PREFIX "" OUTPUT_NAME cv2 SUFFIX ${CVPY_SUFFIX}) diff --git a/modules/python/python2/CMakeLists.txt b/modules/python/python2/CMakeLists.txt index 01a3b474d0..158763ec50 100644 --- a/modules/python/python2/CMakeLists.txt +++ b/modules/python/python2/CMakeLists.txt @@ -4,6 +4,8 @@ endif() set(the_description "The python2 bindings") set(MODULE_NAME python2) +# Buildbot requires Python 2 to be in root lib dir +set(MODULE_INSTALL_SUBDIR "") set(PYTHON_INCLUDE_PATH ${PYTHON2_INCLUDE_PATH}) set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON2_NUMPY_INCLUDE_DIRS}) @@ -17,6 +19,7 @@ set(PYTHON_VERSION_MINOR ${PYTHON2_VERSION_MINOR}) include(../common.cmake) unset(MODULE_NAME) +unset(MODULE_INSTALL_SUBDIR) unset(PYTHON_INCLUDE_PATH) unset(PYTHON_NUMPY_INCLUDE_DIRS) unset(PYTHON_EXECUTABLE) diff --git a/modules/python/python3/CMakeLists.txt b/modules/python/python3/CMakeLists.txt index 14672d3c75..4b6fe4f141 100644 --- a/modules/python/python3/CMakeLists.txt +++ b/modules/python/python3/CMakeLists.txt @@ -4,6 +4,7 @@ endif() set(the_description "The python3 bindings") set(MODULE_NAME python3) +set(MODULE_INSTALL_SUBDIR python3) set(PYTHON_INCLUDE_PATH ${PYTHON3_INCLUDE_PATH}) set(PYTHON_NUMPY_INCLUDE_DIRS ${PYTHON3_NUMPY_INCLUDE_DIRS}) @@ -17,6 +18,7 @@ set(PYTHON_VERSION_MINOR ${PYTHON3_VERSION_MINOR}) include(../common.cmake) unset(MODULE_NAME) +unset(MODULE_INSTALL_SUBDIR) unset(PYTHON_INCLUDE_PATH) unset(PYTHON_NUMPY_INCLUDE_DIRS) unset(PYTHON_EXECUTABLE) From e9ccadebed4a07626b2aa8108fde0634d96827d4 Mon Sep 17 00:00:00 2001 From: Michael Pratt Date: Thu, 7 Aug 2014 00:51:48 -0400 Subject: [PATCH 21/21] Support Python 2 and 3 in test script Add Python 3 support to the Python test.py script. The print function is used in place of the print statement. The urlopen function has been moved to urllib.request in Python 3, so attempt to import it from either location. TestCase.assert_() has been deprecated in place of TestCase.assertTrue(). The tests all pass in both Python 2 and 3. --- modules/python/test/test.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/modules/python/test/test.py b/modules/python/test/test.py index 2da740de9b..76f64fc52e 100644 --- a/modules/python/test/test.py +++ b/modules/python/test/test.py @@ -1,12 +1,12 @@ #!/usr/bin/env python +from __future__ import print_function import unittest import random import time import math import sys import array -import urllib import tarfile import hashlib import os @@ -16,11 +16,17 @@ import functools import numpy as np import cv2 +# Python 3 moved urlopen to urllib.requests +try: + from urllib.request import urlopen +except ImportError: + from urllib import urlopen + class NewOpenCVTests(unittest.TestCase): def get_sample(self, filename, iscolor = cv2.IMREAD_COLOR): if not filename in self.image_cache: - filedata = urllib.urlopen("https://raw.github.com/Itseez/opencv/master/" + filename).read() + filedata = urlopen("https://raw.github.com/Itseez/opencv/master/" + filename).read() self.image_cache[filename] = cv2.imdecode(np.fromstring(filedata, dtype=np.uint8), iscolor) return self.image_cache[filename] @@ -51,7 +57,7 @@ class Hackathon244Tests(NewOpenCVTests): def test_int_array(self): a = np.array([-1, 2, -3, 4, -5]) absa0 = np.abs(a) - self.assert_(cv2.norm(a, cv2.NORM_L1) == 15) + self.assertTrue(cv2.norm(a, cv2.NORM_L1) == 15) absa1 = cv2.absdiff(a, 0) self.assertEqual(cv2.norm(absa1, absa0, cv2.NORM_INF), 0) @@ -90,13 +96,13 @@ class Hackathon244Tests(NewOpenCVTests): img = cv2.medianBlur(img, 3) imgc = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR) keypoints = fd.detect(img) - self.assert_(600 <= len(keypoints) <= 700) + self.assertTrue(600 <= len(keypoints) <= 700) for kpt in keypoints: self.assertNotEqual(kpt.response, 0) def check_close_angles(self, a, b, angle_delta): - self.assert_(abs(a - b) <= angle_delta or - abs(360 - abs(a - b)) <= angle_delta) + self.assertTrue(abs(a - b) <= angle_delta or + abs(360 - abs(a - b)) <= angle_delta) def check_close_pairs(self, a, b, delta): self.assertLessEqual(abs(a[0] - b[0]), delta) @@ -127,6 +133,6 @@ class Hackathon244Tests(NewOpenCVTests): self.assertLessEqual(abs(mr - mr0), 5) if __name__ == '__main__': - print "Testing OpenCV", cv2.__version__ + print("Testing OpenCV", cv2.__version__) random.seed(0) unittest.main()