Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/3.4' into merge-3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
alalek committed Apr 19, 2019
2 parents 1f517b8 + 3abae3c commit c024edb
Show file tree
Hide file tree
Showing 40 changed files with 333 additions and 352 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1301,15 +1301,15 @@ endif()

if(WITH_GTK OR HAVE_GTK)
if(HAVE_GTK3)
status(" GTK+:" "YES (ver ${ALIASOF_gtk+-3.0_VERSION})")
status(" GTK+:" "YES (ver ${GTK3_VERSION})")
elseif(HAVE_GTK)
status(" GTK+:" "YES (ver ${ALIASOF_gtk+-2.0_VERSION})")
status(" GTK+:" "YES (ver ${GTK2_VERSION})")
else()
status(" GTK+:" "NO")
endif()
if(HAVE_GTK)
status( " GThread :" HAVE_GTHREAD THEN "YES (ver ${ALIASOF_gthread-2.0_VERSION})" ELSE NO)
status( " GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${ALIASOF_gtkglext-1.0_VERSION})" ELSE NO)
status( " GThread :" HAVE_GTHREAD THEN "YES (ver ${GTHREAD_VERSION})" ELSE NO)
status( " GtkGlExt:" HAVE_GTKGLEXT THEN "YES (ver ${GTKGLEXT_VERSION})" ELSE NO)
endif()
endif()

Expand Down Expand Up @@ -1449,7 +1449,7 @@ if(WITH_XIMEA OR HAVE_XIMEA)
endif()

if(WITH_XINE OR HAVE_XINE)
status(" Xine:" HAVE_XINE THEN "YES (${XINE_VERSION})" ELSE NO)
status(" Xine:" HAVE_XINE THEN "YES (ver ${XINE_VERSION})" ELSE NO)
endif()

if(WITH_LIBREALSENSE OR HAVE_LIBREALSENSE)
Expand Down
6 changes: 4 additions & 2 deletions cmake/OpenCVDetectTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,10 @@ function(ocv_tbb_cmake_guess _found)
message(STATUS "Found TBB (cmake): ${_lib}")
get_target_property(_inc TBB::tbb INTERFACE_INCLUDE_DIRECTORIES)
ocv_tbb_read_version("${_inc}")
add_library(tbb INTERFACE)
target_link_libraries(tbb INTERFACE TBB::tbb)
add_library(tbb INTERFACE IMPORTED)
set_target_properties(tbb PROPERTIES
INTERFACE_LINK_LIBRARIES TBB::tbb
)
set(${_found} TRUE PARENT_SCOPE)
endif()
endfunction()
Expand Down
24 changes: 17 additions & 7 deletions cmake/OpenCVFindLibsGUI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,24 +42,34 @@ endif()
ocv_clear_vars(HAVE_GTK HAVE_GTK3 HAVE_GTHREAD HAVE_GTKGLEXT)
if(WITH_GTK AND NOT HAVE_QT)
if(NOT WITH_GTK_2_X)
CHECK_MODULE(gtk+-3.0 HAVE_GTK3 HIGHGUI)
ocv_check_modules(GTK3 gtk+-3.0)
if(HAVE_GTK3)
ocv_append_build_options(HIGHGUI GTK3)
set(HAVE_GTK TRUE)
endif()
endif()
if(NOT HAVE_GTK)
CHECK_MODULE(gtk+-2.0 HAVE_GTK HIGHGUI)
if(HAVE_GTK AND (ALIASOF_gtk+-2.0_VERSION VERSION_LESS MIN_VER_GTK))
message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${ALIASOF_gtk+-2.0_VERSION} found)")
set(HAVE_GTK FALSE)
ocv_check_modules(GTK2 gtk+-2.0)
if(HAVE_GTK2)
if (GTK2_VERSION VERSION_LESS MIN_VER_GTK)
message (FATAL_ERROR "GTK support requires a minimum version of ${MIN_VER_GTK} (${GTK2_VERSION} found)")
else()
ocv_append_build_options(HIGHGUI GTK2)
set(HAVE_GTK TRUE)
endif()
endif()
endif()
CHECK_MODULE(gthread-2.0 HAVE_GTHREAD HIGHGUI)
ocv_check_modules(GTHREAD gthread-2.0)
if(HAVE_GTK AND NOT HAVE_GTHREAD)
message(FATAL_ERROR "gthread not found. This library is required when building with GTK support")
else()
ocv_append_build_options(HIGHGUI GTHREAD)
endif()
if(WITH_OPENGL AND NOT HAVE_GTK3)
CHECK_MODULE(gtkglext-1.0 HAVE_GTKGLEXT HIGHGUI)
ocv_check_modules(GTKGLEXT gtkglext-1.0)
if(HAVE_GTKGLEXT)
ocv_append_build_options(GTKGLEXT GTHREAD)
endif()
endif()
endif()

Expand Down
5 changes: 2 additions & 3 deletions cmake/OpenCVFindLibsPerf.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,13 @@ endif(WITH_EIGEN)
ocv_clear_vars(HAVE_CLP)
if(WITH_CLP)
if(UNIX)
PKG_CHECK_MODULES(CLP clp)
ocv_check_modules(CLP clp)
if(CLP_FOUND)
set(HAVE_CLP TRUE)
if(NOT ${CLP_INCLUDE_DIRS} STREQUAL "")
ocv_include_directories(${CLP_INCLUDE_DIRS})
endif()
link_directories(${CLP_LIBRARY_DIRS})
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CLP_LIBRARIES})
list(APPEND OPENCV_LINKER_LIBS ${CLP_LIBRARIES})
endif()
endif()

Expand Down
29 changes: 15 additions & 14 deletions cmake/OpenCVPCHSupport.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,9 @@ MACRO(_PCH_GET_COMPILE_FLAGS _out_compile_flags)
LIST(APPEND ${_out_compile_flags} "-fPIC")
ENDIF()

GET_PROPERTY(_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS)
if(_definitions)
foreach(_def ${_definitions})
LIST(APPEND ${_out_compile_flags} "\"-D${_def}\"")
endforeach()
endif()
GET_TARGET_PROPERTY(_target_definitions ${_PCH_current_target} COMPILE_DEFINITIONS)
if(_target_definitions)
foreach(_def ${_target_definitions})
LIST(APPEND ${_out_compile_flags} "\"-D${_def}\"")
endforeach()
endif()
# Processed via $<TARGET_PROPERTY:target,COMPILE_DEFINITIONS>
#GET_PROPERTY(_definitions DIRECTORY PROPERTY COMPILE_DEFINITIONS)
#GET_TARGET_PROPERTY(_target_definitions ${_PCH_current_target} COMPILE_DEFINITIONS)

GET_TARGET_PROPERTY(_cxx_standard ${_PCH_current_target} CXX_STANDARD)
if (_cxx_standard)
Expand Down Expand Up @@ -304,12 +295,22 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
#message("_command ${_input} ${_output}")
_PCH_GET_COMPILE_COMMAND(_command ${CMAKE_CURRENT_BINARY_DIR}/${_name} ${_output} )

set(_pch_generate_file_cmd "${CMAKE_CURRENT_BINARY_DIR}/${_name}.command.sh")
string(REPLACE " " "\\ " _command "${_command}")
string(REPLACE ";" " " _command "${_command}")
file(GENERATE OUTPUT "${_pch_generate_file_cmd}" CONTENT "#!/bin/sh
if [ -n \"$VERBOSE\" ]; then
tail -n1 \$0
fi
${_command} -D$<JOIN:$<TARGET_PROPERTY:${_targetName},COMPILE_DEFINITIONS>, -D>
")
GET_FILENAME_COMPONENT(_outdir ${_output} PATH)
ADD_CUSTOM_COMMAND(
OUTPUT "${_output}"
COMMAND ${CMAKE_COMMAND} -E make_directory "${_outdir}"
COMMAND ${_command}
DEPENDS "${_input}"
COMMAND chmod +x "${_pch_generate_file_cmd}"
COMMAND "${_pch_generate_file_cmd}"
DEPENDS "${_input}" "${_pch_generate_file_cmd}"
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${_name}"
DEPENDS ${_targetName}_pch_dephelp
)
Expand Down
89 changes: 58 additions & 31 deletions cmake/OpenCVUtils.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
if(COMMAND ocv_cmake_dump_vars) # include guard
return()
endif()

include(CMakeParseArguments)

# Debugging function
Expand Down Expand Up @@ -701,7 +705,7 @@ endfunction()

# Usage: ocv_append_build_options(HIGHGUI FFMPEG)
macro(ocv_append_build_options var_prefix pkg_prefix)
foreach(suffix INCLUDE_DIRS LIBRARIES LIBRARY_DIRS)
foreach(suffix INCLUDE_DIRS LIBRARIES LIBRARY_DIRS LINK_LIBRARIES)
if(${pkg_prefix}_${suffix})
list(APPEND ${var_prefix}_${suffix} ${${pkg_prefix}_${suffix}})
list(REMOVE_DUPLICATES ${var_prefix}_${suffix})
Expand Down Expand Up @@ -739,7 +743,9 @@ macro(ocv_check_modules define)
endif()
unset(${define}_${__modname}_FOUND)
endforeach()
pkg_check_modules(${define} ${ARGN})
if(COMMAND pkg_check_modules)
pkg_check_modules(${define} ${ARGN})
endif()
if(${define}_FOUND)
set(HAVE_${define} 1)
endif()
Expand All @@ -753,29 +759,47 @@ macro(ocv_check_modules define)
set(${define}_${__modname}_FOUND 1)
endif()
endforeach()
endmacro()


# Macro that checks if module has been installed.
# After it adds module to build and define
# constants passed as second arg
macro(CHECK_MODULE module_name define cv_module)
set(${define} 0)
if(PKG_CONFIG_FOUND)
set(ALIAS ALIASOF_${module_name})
set(ALIAS_FOUND ${ALIAS}_FOUND)
set(ALIAS_INCLUDE_DIRS ${ALIAS}_INCLUDE_DIRS)
set(ALIAS_LIBRARY_DIRS ${ALIAS}_LIBRARY_DIRS)
set(ALIAS_LIBRARIES ${ALIAS}_LIBRARIES)

PKG_CHECK_MODULES(${ALIAS} ${module_name})
if(${ALIAS_FOUND})
set(${define} 1)
ocv_append_build_options(${cv_module} ${ALIAS})
if(${define}_FOUND AND ${define}_LIBRARIES)
if(${define}_LINK_LIBRARIES_XXXXX) # CMake 3.12+: https://gitlab.kitware.com/cmake/cmake/merge_requests/2068
set(${define}_LIBRARIES "${${define}_LINK_LIBRARIES}" CACHE INTERNAL "")
else()
unset(_libs) # absolute paths
unset(_libs_paths) # -L args
foreach(flag ${${define}_LDFLAGS})
if(flag MATCHES "^-L(.*)")
list(APPEND _libs_paths ${CMAKE_MATCH_1})
elseif(IS_ABSOLUTE "${flag}")
list(APPEND _libs "${flag}")
elseif(flag MATCHES "^-l(.*)")
set(_lib "${CMAKE_MATCH_1}")
if(_libs_paths)
find_library(pkgcfg_lib_${define}_${_lib} NAMES ${_lib}
HINTS ${_libs_paths} NO_DEFAULT_PATH)
endif()
find_library(pkgcfg_lib_${define}_${_lib} NAMES ${_lib})
mark_as_advanced(pkgcfg_lib_${define}_${_lib})
if(pkgcfg_lib_${define}_${_lib})
list(APPEND _libs "${pkgcfg_lib_${define}_${_lib}}")
else()
message(WARNING "ocv_check_modules(${define}): can't find library '${_lib}'. Specify 'pkgcfg_lib_${define}_${_lib}' manualy")
list(APPEND _libs "${_lib}")
endif()
else()
# -pthread
#message(WARNING "ocv_check_modules(${define}): unknown LDFLAG '${flag}'")
endif()
endforeach()
set(${define}_LINK_LIBRARIES "${_libs}")
set(${define}_LIBRARIES "${_libs}" CACHE INTERNAL "")
unset(_lib)
unset(_libs)
unset(_libs_paths)
endif()
endif()
endmacro()



if(NOT DEFINED CMAKE_ARGC) # Guard CMake standalone invocations

# Use this option carefully, CMake's install() will install symlinks instead of real files
Expand Down Expand Up @@ -1091,15 +1115,6 @@ function(ocv_convert_to_lib_name var)
set(${var} ${tmp} PARENT_SCOPE)
endfunction()

if(MSVC AND BUILD_SHARED_LIBS) # no defaults for static libs (modern CMake is required)
if(NOT CMAKE_VERSION VERSION_LESS 3.6.0)
option(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL "Don't install PDB files by default" ON)
option(INSTALL_PDB "Add install PDB rules" ON)
elseif(NOT CMAKE_VERSION VERSION_LESS 3.1.0)
option(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL "Don't install PDB files by default (not supported)" OFF)
option(INSTALL_PDB "Add install PDB rules" OFF)
endif()
endif()

# add install command
function(ocv_install_target)
Expand Down Expand Up @@ -1132,6 +1147,18 @@ function(ocv_install_target)

if(MSVC)
set(__target "${ARGV0}")

# don't move this into global scope of this file: compiler settings (like MSVC variable) are not available during processing
if(BUILD_SHARED_LIBS) # no defaults for static libs (modern CMake is required)
if(NOT CMAKE_VERSION VERSION_LESS 3.6.0)
option(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL "Don't install PDB files by default" ON)
option(INSTALL_PDB "Add install PDB rules" ON)
elseif(NOT CMAKE_VERSION VERSION_LESS 3.1.0)
option(INSTALL_PDB_COMPONENT_EXCLUDE_FROM_ALL "Don't install PDB files by default (not supported)" OFF)
option(INSTALL_PDB "Add install PDB rules" OFF)
endif()
endif()

if(INSTALL_PDB AND NOT INSTALL_IGNORE_PDB
AND NOT OPENCV_${__target}_PDB_SKIP
)
Expand Down Expand Up @@ -1176,7 +1203,7 @@ function(ocv_install_target)
endif()

# message(STATUS "Adding PDB file installation rule: target=${__target} dst=${__dst} component=${__pdb_install_component}")
if("${__target_type}" STREQUAL "SHARED_LIBRARY")
if("${__target_type}" STREQUAL "SHARED_LIBRARY" OR "${__target_type}" STREQUAL "MODULE_LIBRARY")
install(FILES "$<TARGET_PDB_FILE:${__target}>" DESTINATION "${__dst}"
COMPONENT ${__pdb_install_component} OPTIONAL ${__pdb_exclude_from_all})
else()
Expand Down
2 changes: 1 addition & 1 deletion cmake/templates/OpenCVConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ endif()

# Extract the directory where *this* file has been installed (determined at cmake run-time)
# Get the absolute path with no ../.. relative marks, to eliminate implicit linker warnings
set(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}")
get_filename_component(OpenCV_CONFIG_PATH "${CMAKE_CURRENT_LIST_DIR}" REALPATH)
get_filename_component(OpenCV_INSTALL_PATH "${OpenCV_CONFIG_PATH}/@OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE@" REALPATH)

# Search packages for host system instead of packages for target system.
Expand Down
6 changes: 5 additions & 1 deletion modules/calib3d/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
set(the_description "Camera Calibration and 3D Reconstruction")
ocv_define_module(calib3d opencv_imgproc opencv_features2d opencv_flann WRAP java python)
set(debug_modules "")
if(DEBUG_opencv_calib3d)
list(APPEND debug_modules opencv_highgui)
endif()
ocv_define_module(calib3d opencv_imgproc opencv_features2d opencv_flann ${debug_modules} WRAP java python)
1 change: 1 addition & 0 deletions modules/calib3d/src/calibinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@

//#define ENABLE_TRIM_COL_ROW

// Requires CMake flag: DEBUG_opencv_calib3d=ON
//#define DEBUG_CHESSBOARD
#define DEBUG_CHESSBOARD_TIMEOUT 0 // 0 - wait for 'q'

Expand Down
2 changes: 2 additions & 0 deletions modules/calib3d/src/circlesgrid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
#include "precomp.hpp"
#include "circlesgrid.hpp"
#include <limits>

// Requires CMake flag: DEBUG_opencv_calib3d=ON
//#define DEBUG_CIRCLES

#ifdef DEBUG_CIRCLES
Expand Down
2 changes: 1 addition & 1 deletion modules/dnn/include/opencv2/dnn/version.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// Use with major OpenCV version only.
#define OPENCV_DNN_API_VERSION 20190412

#if !defined CV_DOXYGEN && !defined CV_DNN_DONT_ADD_INLINE_NS
#if !defined CV_DOXYGEN && !defined CV_STATIC_ANALYSIS && !defined CV_DNN_DONT_ADD_INLINE_NS
#define CV__DNN_INLINE_NS __CV_CAT(dnn4_v, OPENCV_DNN_API_VERSION)
#define CV__DNN_INLINE_NS_BEGIN namespace CV__DNN_INLINE_NS {
#define CV__DNN_INLINE_NS_END }
Expand Down
10 changes: 10 additions & 0 deletions modules/dnn/src/layers/flatten_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ class FlattenLayerImpl CV_FINAL : public FlattenLayer
return true;
}

void finalize(InputArrayOfArrays inputs_arr, OutputArrayOfArrays) CV_OVERRIDE
{
std::vector<Mat> inputs;
inputs_arr.getMatVector(inputs);

int numAxes = inputs[0].dims;
_startAxis = clamp(_startAxis, numAxes);
_endAxis = clamp(_endAxis, numAxes);
}

#ifdef HAVE_OPENCL
bool forward_ocl(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr)
{
Expand Down
20 changes: 8 additions & 12 deletions modules/dnn/src/layers/normalize_bbox_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,13 @@ class NormalizeBBoxLayerImpl CV_FINAL : public NormalizeBBoxLayer
InferenceEngine::Blob::Ptr weights;
if (blobs.empty())
{
auto onesBlob = InferenceEngine::make_shared_blob<float>(InferenceEngine::Precision::FP32,
InferenceEngine::Layout::C,
{(size_t)numChannels});
onesBlob->allocate();
std::vector<float> ones(numChannels, 1);
onesBlob->set(ones);
weights = onesBlob;
weights = InferenceEngine::make_shared_blob<float>(InferenceEngine::Precision::FP32,
InferenceEngine::Layout::C,
{(size_t)numChannels});
weights->allocate();

Mat weightsMat = infEngineBlobToMat(weights).reshape(1, numChannels);
Mat(numChannels, 1, CV_32F, Scalar(1)).copyTo(weightsMat);
l.getParameters()["channel_shared"] = false;
}
else
Expand All @@ -290,11 +290,7 @@ class NormalizeBBoxLayerImpl CV_FINAL : public NormalizeBBoxLayer
weights = wrapToInfEngineBlob(blobs[0], {(size_t)numChannels}, InferenceEngine::Layout::C);
l.getParameters()["channel_shared"] = blobs[0].total() == 1;
}
#if INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2019R1)
l.getParameters()["weights"] = weights;
#else
l.addConstantData("weights", weights);
#endif
addConstantData("weights", weights, l);
l.getParameters()["across_spatial"] = acrossSpatial;
return Ptr<BackendNode>(new InfEngineBackendNode(l));
}
Expand Down
Loading

0 comments on commit c024edb

Please sign in to comment.