Skip to content

Commit

Permalink
Merge branch 'master' into gsoc_2021_webnn
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkGHX authored Aug 22, 2021
2 parents c8da522 + 6fbfc58 commit 651275b
Show file tree
Hide file tree
Showing 320 changed files with 24,753 additions and 8,494 deletions.
4 changes: 3 additions & 1 deletion 3rdparty/libwebp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ endif()
# Define the library target:
# ----------------------------------------------------------------------------------

add_definitions(-DWEBP_USE_THREAD)
if(NOT OPENCV_DISABLE_THREAD_SUPPORT)
add_definitions(-DWEBP_USE_THREAD)
endif()

add_library(${WEBP_LIBRARY} STATIC ${OPENCV_3RDPARTY_EXCLUDE_FROM_ALL} ${lib_srcs} ${lib_hdrs})
if(ANDROID)
Expand Down
6 changes: 4 additions & 2 deletions 3rdparty/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ libpng Portable Network Graphics library.
libtiff Tag Image File Format (TIFF) Software
Copyright (c) 1988-1997 Sam Leffler
Copyright (c) 1991-1997 Silicon Graphics, Inc.
See libtiff home page http://www.remotesensing.org/libtiff/
See libtiff home page http://www.libtiff.org/
for details and links to the source code

WITH_TIFF CMake option must be ON to add libtiff & zlib support to imgcodecs.
Expand All @@ -51,7 +51,9 @@ jasper JasPer is a collection of software
Copyright (c) 1999-2000 The University of British Columbia
Copyright (c) 2001-2003 Michael David Adams

The JasPer license can be found in libjasper.
See JasPer official GitHub repository
https://github.com/jasper-software/jasper.git
for details and links to source code
------------------------------------------------------------------------------------
openexr OpenEXR is a high dynamic-range (HDR) image file format developed
by Industrial Light & Magic for use in computer imaging applications.
Expand Down
22 changes: 19 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -515,6 +515,8 @@ OCV_OPTION(OPENCV_GENERATE_SETUPVARS "Generate setup_vars* scripts" ON IF (NOT
OCV_OPTION(ENABLE_CONFIG_VERIFICATION "Fail build if actual configuration doesn't match requested (WITH_XXX != HAVE_XXX)" OFF)
OCV_OPTION(OPENCV_ENABLE_MEMALIGN "Enable posix_memalign or memalign usage" ON)
OCV_OPTION(OPENCV_DISABLE_FILESYSTEM_SUPPORT "Disable filesystem support" OFF)
OCV_OPTION(OPENCV_DISABLE_THREAD_SUPPORT "Build the library without multi-threaded code." OFF)
OCV_OPTION(OPENCV_SEMIHOSTING "Build the library for semihosting target (Arm). See https://developer.arm.com/documentation/100863/latest." OFF)

OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
OCV_OPTION(ENABLE_FLAKE8 "Add target with Python flake8 checker" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
Expand Down Expand Up @@ -661,14 +663,19 @@ if(UNIX)
elseif(EMSCRIPTEN)
# no need to link to system libs with emscripten
elseif(QNXNTO)
# no need to link to system libs with QNX
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m)
else()
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt)
endif()
else()
set(HAVE_PTHREAD 1)
endif()

# Ensure that libpthread is not listed as one of the libraries to pass to the linker.
if (OPENCV_DISABLE_THREAD_SUPPORT)
list(REMOVE_ITEM OPENCV_LINKER_LIBS pthread)
endif()

if(OPENCV_ENABLE_MEMALIGN)
CHECK_SYMBOL_EXISTS(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
CHECK_INCLUDE_FILE(malloc.h HAVE_MALLOC_H)
Expand Down Expand Up @@ -915,7 +922,7 @@ add_subdirectory(include)
ocv_add_modules_compiler_options()

# OpenCV modules
add_subdirectory(modules)
ocv_register_modules()

# Generate targets for documentation
add_subdirectory(doc)
Expand Down Expand Up @@ -1245,7 +1252,7 @@ endif(WIN32)

# ========================== GUI ==========================
status("")
status(" GUI: ")
status(" GUI: " "${OPENCV_HIGHGUI_BUILTIN_BACKEND}")

if(WITH_QT OR HAVE_QT)
if(HAVE_QT5)
Expand Down Expand Up @@ -1467,6 +1474,15 @@ ocv_build_features_string(parallel_status EXCLUSIVE
ELSE "none")
status("")
status(" Parallel framework:" "${parallel_status}")
if (OPENCV_DISABLE_THREAD_SUPPORT)
status("" "Multi thread code explicitly disabled with OPENCV_DISABLE_THREAD_SUPPORT.")
if(HAVE_PTHREADS_PF OR HAVE_HPX OR HAVE_OPENMP OR HAVE_GCD OR HAVE_CONCURRENCY)
message(FATAL_ERROR "Not all parallel frameworks have been disabled (using ${parallel_status}).")
endif()
if(HAVE_PTHREAD)
message(FATAL_ERROR "Thread execution might be in use in some component.")
endif()
endif()

if(CV_TRACE OR OPENCV_TRACE)
ocv_build_features_string(trace_status EXCLUSIVE
Expand Down
8 changes: 5 additions & 3 deletions apps/model-diagnostics/model_diagnostics.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/*************************************************
USAGE:
./model_diagnostics -m <onnx file location>
./model_diagnostics -m <model file location>
**************************************************/
#include <opencv2/dnn.hpp>
#include <opencv2/core/utils/filesystem.hpp>
#include <opencv2/dnn/utils/debug_utils.hpp>

#include <iostream>

Expand Down Expand Up @@ -32,7 +33,7 @@ static std::string checkFileExists(const std::string& fileName)
}

std::string diagnosticKeys =
"{ model m | | Path to the model .onnx file. }"
"{ model m | | Path to the model file. }"
"{ config c | | Path to the model configuration file. }"
"{ framework f | | [Optional] Name of the model framework. }";

Expand All @@ -41,7 +42,7 @@ std::string diagnosticKeys =
int main( int argc, const char** argv )
{
CommandLineParser argParser(argc, argv, diagnosticKeys);
argParser.about("Use this tool to run the diagnostics of provided ONNX model"
argParser.about("Use this tool to run the diagnostics of provided ONNX/TF model"
"to obtain the information about its support (supported layers).");

if (argc == 1)
Expand All @@ -57,6 +58,7 @@ int main( int argc, const char** argv )
CV_Assert(!model.empty());

enableModelDiagnostics(true);
skipModelImport(true);
redirectError(diagnosticsErrorCallback, NULL);

Net ocvNet = readNet(model, config, frameworkId);
Expand Down
13 changes: 11 additions & 2 deletions cmake/OpenCVCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,17 @@ if(CV_GCC OR CV_CLANG)
add_extra_compiler_option(-Wno-long-long)
endif()

# We need pthread's
if(UNIX AND NOT ANDROID AND NOT (APPLE AND CV_CLANG)) # TODO
# We need pthread's, unless we have explicitly disabled multi-thread execution.
if(NOT OPENCV_DISABLE_THREAD_SUPPORT
AND (
(UNIX
AND NOT ANDROID
AND NOT (APPLE AND CV_CLANG)
AND NOT EMSCRIPTEN
)
OR (EMSCRIPTEN AND WITH_PTHREADS_PF) # https://github.com/opencv/opencv/issues/20285
)
) # TODO
add_extra_compiler_option(-pthread)
endif()

Expand Down
2 changes: 1 addition & 1 deletion cmake/OpenCVDetectCUDA.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ if(CUDA_FOUND)
if(CUDA_GENERATION)
if(NOT ";${_generations};" MATCHES ";${CUDA_GENERATION};")
string(REPLACE ";" ", " _generations "${_generations}")
message(FATAL_ERROR "ERROR: ${_generations} Generations are suppered.")
message(FATAL_ERROR "ERROR: ${_generations} Generations are supported.")
endif()
unset(CUDA_ARCH_BIN CACHE)
unset(CUDA_ARCH_PTX CACHE)
Expand Down
24 changes: 13 additions & 11 deletions cmake/OpenCVDetectHalide.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,14 @@ set(HALIDE_ROOT_DIR "${HALIDE_ROOT_DIR}" CACHE PATH "Halide root directory")
if(NOT HAVE_HALIDE)
find_package(Halide QUIET) # Try CMake-based config files
if(Halide_FOUND)
set(HALIDE_INCLUDE_DIRS "${Halide_INCLUDE_DIRS}" CACHE PATH "Halide include directories" FORCE)
set(HALIDE_LIBRARIES "${Halide_LIBRARIES}" CACHE PATH "Halide libraries" FORCE)
set(HAVE_HALIDE TRUE)
if(TARGET Halide::Halide) # modern Halide scripts defines imported target
set(HALIDE_INCLUDE_DIRS "")
set(HALIDE_LIBRARIES "Halide::Halide")
set(HAVE_HALIDE TRUE)
else()
# using HALIDE_INCLUDE_DIRS / Halide_LIBRARIES
set(HAVE_HALIDE TRUE)
endif()
endif()
endif()

Expand All @@ -28,18 +33,15 @@ if(NOT HAVE_HALIDE AND HALIDE_ROOT_DIR)
)
if(HALIDE_LIBRARY AND HALIDE_INCLUDE_DIR)
# TODO try_compile
set(HALIDE_INCLUDE_DIRS "${HALIDE_INCLUDE_DIR}" CACHE PATH "Halide include directories" FORCE)
set(HALIDE_LIBRARIES "${HALIDE_LIBRARY}" CACHE PATH "Halide libraries" FORCE)
set(HALIDE_INCLUDE_DIRS "${HALIDE_INCLUDE_DIR}")
set(HALIDE_LIBRARIES "${HALIDE_LIBRARY}")
set(HAVE_HALIDE TRUE)
endif()
if(NOT HAVE_HALIDE)
ocv_clear_vars(HALIDE_LIBRARIES HALIDE_INCLUDE_DIRS CACHE)
endif()
endif()

if(HAVE_HALIDE)
include_directories(${HALIDE_INCLUDE_DIRS})
if(HALIDE_INCLUDE_DIRS)
include_directories(${HALIDE_INCLUDE_DIRS})
endif()
list(APPEND OPENCV_LINKER_LIBS ${HALIDE_LIBRARIES})
else()
ocv_clear_vars(HALIDE_INCLUDE_DIRS HALIDE_LIBRARIES)
endif()
19 changes: 12 additions & 7 deletions cmake/OpenCVDetectInferenceEngine.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,16 +134,21 @@ endif()
# Add more features to the target

if(INF_ENGINE_TARGET)
if(InferenceEngine_VERSION VERSION_GREATER_EQUAL "2021.4")
math(EXPR INF_ENGINE_RELEASE "${InferenceEngine_VERSION_MAJOR} * 1000000 + ${InferenceEngine_VERSION_MINOR} * 10000 + ${InferenceEngine_VERSION_PATCH} * 100")
if(DEFINED InferenceEngine_VERSION)
message(STATUS "InferenceEngine: ${InferenceEngine_VERSION}")
if(NOT INF_ENGINE_RELEASE AND NOT (InferenceEngine_VERSION VERSION_LESS "2021.4"))
math(EXPR INF_ENGINE_RELEASE_INIT "${InferenceEngine_VERSION_MAJOR} * 1000000 + ${InferenceEngine_VERSION_MINOR} * 10000 + ${InferenceEngine_VERSION_PATCH} * 100")
endif()
endif()
if(NOT INF_ENGINE_RELEASE)
message(WARNING "InferenceEngine version has not been set, 2021.3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
set(INF_ENGINE_RELEASE "2021030000")
if(NOT INF_ENGINE_RELEASE AND NOT INF_ENGINE_RELEASE_INIT)
message(WARNING "InferenceEngine version has not been set, 2021.4 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
set(INF_ENGINE_RELEASE_INIT "2021040000")
elseif(DEFINED INF_ENGINE_RELEASE)
set(INF_ENGINE_RELEASE_INIT "${INF_ENGINE_RELEASE}")
endif()
set(INF_ENGINE_RELEASE "${INF_ENGINE_RELEASE}" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
set(INF_ENGINE_RELEASE "${INF_ENGINE_RELEASE_INIT}" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
)
endif()

Expand Down
60 changes: 30 additions & 30 deletions cmake/OpenCVDetectVTK.cmake
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
# VTK 9.0
if(NOT VTK_FOUND)
find_package(VTK 9 QUIET NAMES vtk COMPONENTS
FiltersExtraction
FiltersSources
FiltersTexture
IOExport
IOGeometry
IOPLY
InteractionStyle
RenderingCore
RenderingLOD
RenderingOpenGL2
NO_MODULE)
endif()

# VTK 6.x components
if(NOT VTK_FOUND)
find_package(VTK QUIET COMPONENTS vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
IF(VTK_FOUND)
IF(VTK_RENDERING_BACKEND) #in vtk 7, the rendering backend is exported as a var.
find_package(VTK QUIET COMPONENTS vtkRendering${VTK_RENDERING_BACKEND} vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport vtkIOGeometry NO_MODULE)
ELSE(VTK_RENDERING_BACKEND)
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
ENDIF(VTK_RENDERING_BACKEND)
ENDIF(VTK_FOUND)
endif()

# VTK 5.x components
if(NOT VTK_FOUND)
find_package(VTK QUIET COMPONENTS vtkCommon NO_MODULE)
find_package(VTK QUIET NAMES vtk VTK)
if(VTK_FOUND)
if(VTK_VERSION VERSION_EQUAL "9") # VTK 9.0
find_package(VTK 9 QUIET NAMES vtk COMPONENTS
FiltersExtraction
FiltersSources
FiltersTexture
IOExport
IOGeometry
IOPLY
InteractionStyle
RenderingCore
RenderingLOD
RenderingOpenGL2
NO_MODULE)
elseif(VTK_VERSION VERSION_GREATER "5") # VTK 6.x components
find_package(VTK QUIET COMPONENTS vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
IF(VTK_FOUND)
IF(VTK_RENDERING_BACKEND) #in vtk 7, the rendering backend is exported as a var.
find_package(VTK QUIET COMPONENTS vtkRendering${VTK_RENDERING_BACKEND} vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport vtkIOGeometry NO_MODULE)
ELSE(VTK_RENDERING_BACKEND)
find_package(VTK QUIET COMPONENTS vtkRenderingOpenGL vtkInteractionStyle vtkRenderingLOD vtkIOPLY vtkFiltersTexture vtkRenderingFreeType vtkIOExport NO_MODULE)
ENDIF(VTK_RENDERING_BACKEND)
ENDIF(VTK_FOUND)
elseif(VTK_VERSION VERSION_EQUAL "5") # VTK 5.x components
find_package(VTK QUIET COMPONENTS vtkCommon NO_MODULE)
else()
set(VTK_FOUND FALSE)
endif()
endif()
endif()

if(NOT VTK_FOUND)
Expand Down
9 changes: 0 additions & 9 deletions cmake/OpenCVFindLibsGUI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
# Detect 3rd-party GUI libraries
# ----------------------------------------------------------------------------

#--- Win32 UI ---
ocv_clear_vars(HAVE_WIN32UI)
if(WITH_WIN32UI)
try_compile(HAVE_WIN32UI
"${OpenCV_BINARY_DIR}"
"${OpenCV_SOURCE_DIR}/cmake/checks/win32uitest.cpp"
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=user32;gdi32")
endif()

# --- QT4/5 ---
ocv_clear_vars(HAVE_QT HAVE_QT5)
if(WITH_QT)
Expand Down
39 changes: 35 additions & 4 deletions cmake/OpenCVModule.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ function(_glob_locations out_paths out_names)
list(LENGTH paths before)
get_filename_component(path "${path}" ABSOLUTE)
# Either module itself
if(NOT path STREQUAL CMAKE_CURRENT_SOURCE_DIR AND EXISTS "${path}/CMakeLists.txt")
if(NOT path STREQUAL "${OpenCV_SOURCE_DIR}/modules" AND EXISTS "${path}/CMakeLists.txt")
get_filename_component(name "${path}" NAME)
list(APPEND paths "${path}")
list(APPEND names "${name}")
Expand Down Expand Up @@ -296,7 +296,7 @@ macro(_add_modules_1 paths names)
list(GET ${names} ${i} __name)
#message(STATUS "First pass: ${__name} => ${__path}")
include("${__path}/cmake/init.cmake" OPTIONAL)
add_subdirectory("${__path}" "${CMAKE_CURRENT_BINARY_DIR}/.firstpass/${__name}")
add_subdirectory("${__path}" "${OpenCV_BINARY_DIR}/modules/.firstpass/${__name}")
endforeach()
endif()
endmacro()
Expand All @@ -316,7 +316,7 @@ macro(_add_modules_2)
endif()
string(REGEX REPLACE "^opencv_" "" name "${m}")
#message(STATUS "Second pass: ${name} => ${OPENCV_MODULE_${m}_LOCATION}")
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${name}")
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${OpenCV_BINARY_DIR}/modules/${name}")
endif()
ocv_cmake_hook(POST_MODULES_CREATE_${the_module})
endforeach()
Expand Down Expand Up @@ -369,14 +369,44 @@ macro(ocv_glob_modules main_root)
__ocv_resolve_dependencies()

# create modules
set(OPENCV_INITIAL_PASS OFF PARENT_SCOPE)
set(OPENCV_INITIAL_PASS OFF)
ocv_cmake_hook(PRE_MODULES_CREATE)
_add_modules_2(${OPENCV_MODULES_BUILD})
ocv_cmake_hook(POST_MODULES_CREATE)
endmacro()


# called by root CMakeLists.txt
macro(ocv_register_modules)
if(NOT OPENCV_MODULES_PATH)
set(OPENCV_MODULES_PATH "${OpenCV_SOURCE_DIR}/modules")
endif()

ocv_glob_modules(${OPENCV_MODULES_PATH} ${OPENCV_EXTRA_MODULES_PATH})

# build lists of modules to be documented
set(OPENCV_MODULES_MAIN "")
set(OPENCV_MODULES_EXTRA "")

foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MODULES_DISABLED_AUTO} ${OPENCV_MODULES_DISABLED_FORCE})
string(REGEX REPLACE "^opencv_" "" mod "${mod}")
if("${OPENCV_MODULE_opencv_${mod}_LOCATION}" STREQUAL "${OpenCV_SOURCE_DIR}/modules/${mod}")
list(APPEND OPENCV_MODULES_MAIN ${mod})
else()
list(APPEND OPENCV_MODULES_EXTRA ${mod})
endif()
endforeach()
ocv_list_sort(OPENCV_MODULES_MAIN)
ocv_list_sort(OPENCV_MODULES_EXTRA)
set(FIXED_ORDER_MODULES core imgproc imgcodecs videoio highgui video calib3d features2d objdetect dnn ml flann photo stitching)
list(REMOVE_ITEM OPENCV_MODULES_MAIN ${FIXED_ORDER_MODULES})
set(OPENCV_MODULES_MAIN ${FIXED_ORDER_MODULES} ${OPENCV_MODULES_MAIN})

set(OPENCV_MODULES_MAIN ${OPENCV_MODULES_MAIN} CACHE INTERNAL "List of main modules" FORCE)
set(OPENCV_MODULES_EXTRA ${OPENCV_MODULES_EXTRA} CACHE INTERNAL "List of extra modules" FORCE)
endmacro()


# disables OpenCV module with missing dependencies
function(__ocv_module_turn_off the_module)
list(REMOVE_ITEM OPENCV_MODULES_DISABLED_AUTO "${the_module}")
Expand Down Expand Up @@ -877,6 +907,7 @@ macro(ocv_create_module)
endmacro()

macro(_ocv_create_module)
add_definitions(-D__OPENCV_BUILD=1)

ocv_compiler_optimization_process_sources(OPENCV_MODULE_${the_module}_SOURCES OPENCV_MODULE_${the_module}_DEPS_EXT ${the_module})
set(__module_headers ${OPENCV_MODULE_${the_module}_HEADERS})
Expand Down
Loading

0 comments on commit 651275b

Please sign in to comment.