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 Jul 2, 2019
2 parents 2bf8793 + 2370079 commit 097d813
Show file tree
Hide file tree
Showing 35 changed files with 463 additions and 536 deletions.
40 changes: 17 additions & 23 deletions 3rdparty/tbb/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,14 @@ if (WIN32 AND NOT ARM)
message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!")
endif()

set(tbb_filename "2018_U1.tar.gz")
set(tbb_subdir "tbb-2018_U1")
set(tbb_md5 "b2f2fa09adf44a22f4024049907f774b")

ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702
-Wshadow
-Wunused-parameter
-Wmissing-prototypes # MacOSX
)
ocv_update(OPENCV_TBB_RELEASE "2019_U8")
ocv_update(OPENCV_TBB_RELEASE_MD5 "7c371d0f62726154d2c568a85697a0ad")
ocv_update(OPENCV_TBB_FILENAME "${OPENCV_TBB_RELEASE}.tar.gz")
ocv_update(OPENCV_TBB_SUBDIR "tbb-${OPENCV_TBB_RELEASE}")

set(tbb_src_dir "${OpenCV_BINARY_DIR}/3rdparty/tbb")
ocv_download(FILENAME ${tbb_filename}
HASH ${tbb_md5}
ocv_download(FILENAME ${OPENCV_TBB_FILENAME}
HASH ${OPENCV_TBB_RELEASE_MD5}
URL
"${OPENCV_TBB_URL}"
"$ENV{OPENCV_TBB_URL}"
Expand All @@ -29,7 +24,7 @@ ocv_download(FILENAME ${tbb_filename}
if(NOT res)
return()
endif()
set(tbb_src_dir "${tbb_src_dir}/${tbb_subdir}")
set(tbb_src_dir "${tbb_src_dir}/${OPENCV_TBB_SUBDIR}")

ocv_include_directories("${tbb_src_dir}/include"
"${tbb_src_dir}/src/"
Expand Down Expand Up @@ -82,18 +77,19 @@ endif()

if(ANDROID_COMPILER_IS_CLANG)
add_definitions(-D__TBB_GCC_BUILTIN_ATOMICS_PRESENT=1)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wmissing-prototypes)
endif()

set(TBB_SOURCE_FILES ${lib_srcs} ${lib_hdrs})
ocv_warnings_disable(CMAKE_CXX_FLAGS
/wd4702
-Wshadow
-Wunused-parameter
-Wclass-memaccess # TBB 2018 under GCC 8+
-Wimplicit-fallthrough # TBB 2018 under GCC 7+
-Wmissing-prototypes # MacOSX, Android/Clang
-Wundef -Wmissing-declarations # TBB 2019
)

if (ARM AND NOT WIN32)
if (NOT ANDROID)
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/arm_linux_stub.cpp")
endif()
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h\"")
endif()
set(TBB_SOURCE_FILES ${lib_srcs} ${lib_hdrs})

set(tbb_version_file "version_string.ver")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}.cmakein" "${CMAKE_CURRENT_BINARY_DIR}/${tbb_version_file}" @ONLY)
Expand Down Expand Up @@ -122,8 +118,6 @@ else()
target_link_libraries(tbb c m dl)
endif()

ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)

# filter out flags that are not handled well by the TBB code
foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
string(REPLACE "-Werror=non-virtual-dtor" "" ${var} "${${var}}")
Expand Down
41 changes: 0 additions & 41 deletions 3rdparty/tbb/android_additional.h

This file was deleted.

11 changes: 0 additions & 11 deletions 3rdparty/tbb/arm_linux_stub.cpp

This file was deleted.

5 changes: 1 addition & 4 deletions cmake/OpenCVCompilerOptimizations.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ elseif(ARM OR AARCH64)
ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16 -mfp16-format=ieee")
ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
endif()
ocv_update(CPU_FP16_IMPLIES "NEON")
Expand Down Expand Up @@ -617,9 +617,6 @@ macro(ocv_compiler_optimization_options)
if(ENABLE_POWERPC)
add_extra_compiler_option("-mcpu=G3 -mtune=G5")
endif()
if(ARM)
add_extra_compiler_option("-mfp16-format=ieee")
endif(ARM)
endmacro()

macro(ocv_compiler_optimization_options_finalize)
Expand Down
20 changes: 20 additions & 0 deletions cmake/OpenCVCompilerOptions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,23 @@ macro(ocv_add_modules_compiler_options)
add_definitions(-DOPENCV_ENABLE_MEMORY_SANITIZER=1)
endif()
endmacro()

# adjust -Wl,-rpath-link
if(CMAKE_SKIP_RPATH)
if((NOT CMAKE_CROSSCOMPILING OR OPENCV_ENABLE_LINKER_RPATH_LINK_ORIGIN) AND NOT OPENCV_SKIP_LINKER_RPATH_LINK_ORIGIN)
if(DEFINED CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN)
list(APPEND CMAKE_PLATFORM_RUNTIME_PATH "${CMAKE_SHARED_LIBRARY_RPATH_ORIGIN_TOKEN}")
else()
list(APPEND CMAKE_PLATFORM_RUNTIME_PATH "\$ORIGIN")
endif()
elseif(NOT OPENCV_SKIP_LINKER_RPATH_LINK_BINARY_LIB)
list(APPEND CMAKE_PLATFORM_RUNTIME_PATH "${LIBRARY_OUTPUT_PATH}")
endif()
endif()
if(OPENCV_EXTRA_RPATH_LINK_PATH)
string(REPLACE ":" ";" OPENCV_EXTRA_RPATH_LINK_PATH_ "${OPENCV_EXTRA_RPATH_LINK_PATH}")
list(APPEND CMAKE_PLATFORM_RUNTIME_PATH ${OPENCV_EXTRA_RPATH_LINK_PATH_})
if(NOT CMAKE_EXECUTABLE_RPATH_LINK_CXX_FLAG)
message(WARNING "OPENCV_EXTRA_RPATH_LINK_PATH may not work properly because CMAKE_EXECUTABLE_RPATH_LINK_CXX_FLAG is not defined (not supported)")
endif()
endif()
6 changes: 5 additions & 1 deletion cmake/OpenCVGenConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
# -------------------------------------------------------------------------------------------
file(RELATIVE_PATH OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}/${OPENCV_CONFIG_INSTALL_PATH}/" ${CMAKE_INSTALL_PREFIX})
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\"")
if (IS_ABSOLUTE ${OPENCV_INCLUDE_INSTALL_PATH})
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_INCLUDE_INSTALL_PATH}\"")
else()
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\"")
endif()

if(USE_IPPICV)
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPICV_INSTALL_PATH}")
Expand Down
16 changes: 15 additions & 1 deletion cmake/templates/OpenCVConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,21 @@ set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
set(OpenCV_USE_MANGLED_PATHS @OpenCV_USE_MANGLED_PATHS_CONFIGCMAKE@)

set(OpenCV_LIB_COMPONENTS @OPENCV_MODULES_CONFIGCMAKE@)
set(OpenCV_INCLUDE_DIRS @OpenCV_INCLUDE_DIRS_CONFIGCMAKE@)
set(__OpenCV_INCLUDE_DIRS @OpenCV_INCLUDE_DIRS_CONFIGCMAKE@)

set(OpenCV_INCLUDE_DIRS "")
foreach(d ${__OpenCV_INCLUDE_DIRS})
get_filename_component(__d "${d}" REALPATH)
if(NOT EXISTS "${__d}")
if(NOT OpenCV_FIND_QUIETLY)
message(WARNING "OpenCV: Include directory doesn't exist: '${d}'. OpenCV installation may be broken. Skip...")
endif()
else()
list(APPEND OpenCV_INCLUDE_DIRS "${__d}")
endif()
endforeach()
unset(__d)


if(NOT TARGET opencv_core)
include(${CMAKE_CURRENT_LIST_DIR}/OpenCVModules${OpenCV_MODULES_SUFFIX}.cmake)
Expand Down
73 changes: 39 additions & 34 deletions modules/calib3d/src/ptsetreg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,55 +99,60 @@ class RANSACPointSetRegistrator : public PointSetRegistrator
return nz;
}

bool getSubset( const Mat& m1, const Mat& m2,
Mat& ms1, Mat& ms2, RNG& rng,
int maxAttempts=1000 ) const
bool getSubset( const Mat& m1, const Mat& m2, Mat& ms1, Mat& ms2, RNG& rng, int maxAttempts=1000 ) const
{
cv::AutoBuffer<int> _idx(modelPoints);
int* idx = _idx.data();
int i = 0, j, k, iters = 0;
int d1 = m1.channels() > 1 ? m1.channels() : m1.cols;
int d2 = m2.channels() > 1 ? m2.channels() : m2.cols;
int esz1 = (int)m1.elemSize1()*d1, esz2 = (int)m2.elemSize1()*d2;
int count = m1.checkVector(d1), count2 = m2.checkVector(d2);
const int *m1ptr = m1.ptr<int>(), *m2ptr = m2.ptr<int>();

ms1.create(modelPoints, 1, CV_MAKETYPE(m1.depth(), d1));
ms2.create(modelPoints, 1, CV_MAKETYPE(m2.depth(), d2));

int *ms1ptr = ms1.ptr<int>(), *ms2ptr = ms2.ptr<int>();
const int d1 = m1.channels() > 1 ? m1.channels() : m1.cols;
const int d2 = m2.channels() > 1 ? m2.channels() : m2.cols;

CV_Assert( count >= modelPoints && count == count2 );
CV_Assert( (esz1 % sizeof(int)) == 0 && (esz2 % sizeof(int)) == 0 );
int esz1 = (int)m1.elemSize1() * d1;
int esz2 = (int)m2.elemSize1() * d2;
CV_Assert((esz1 % sizeof(int)) == 0 && (esz2 % sizeof(int)) == 0);
esz1 /= sizeof(int);
esz2 /= sizeof(int);

for(; iters < maxAttempts; iters++)
const int count = m1.checkVector(d1);
const int count2 = m2.checkVector(d2);
CV_Assert(count >= modelPoints && count == count2);

const int *m1ptr = m1.ptr<int>();
const int *m2ptr = m2.ptr<int>();

ms1.create(modelPoints, 1, CV_MAKETYPE(m1.depth(), d1));
ms2.create(modelPoints, 1, CV_MAKETYPE(m2.depth(), d2));

int *ms1ptr = ms1.ptr<int>();
int *ms2ptr = ms2.ptr<int>();

for( int iters = 0; iters < maxAttempts; ++iters )
{
for( i = 0; i < modelPoints && iters < maxAttempts; )
int i;

for( i = 0; i < modelPoints; ++i )
{
int idx_i = 0;
for(;;)
{
idx_i = idx[i] = rng.uniform(0, count);
for( j = 0; j < i; j++ )
if( idx_i == idx[j] )
break;
if( j == i )
break;
}
for( k = 0; k < esz1; k++ )
int idx_i;

for ( idx_i = rng.uniform(0, count);
std::find(idx, idx + i, idx_i) != idx + i;
idx_i = rng.uniform(0, count) )
{}

idx[i] = idx_i;

for( int k = 0; k < esz1; ++k )
ms1ptr[i*esz1 + k] = m1ptr[idx_i*esz1 + k];
for( k = 0; k < esz2; k++ )

for( int k = 0; k < esz2; ++k )
ms2ptr[i*esz2 + k] = m2ptr[idx_i*esz2 + k];
i++;
}
if( i == modelPoints && !cb->checkSubset(ms1, ms2, i) )
continue;
break;

if( cb->checkSubset(ms1, ms2, i) )
return true;
}

return i == modelPoints && iters < maxAttempts;
return false;
}

bool run(InputArray _m1, InputArray _m2, OutputArray _model, OutputArray _mask) const CV_OVERRIDE
Expand Down
4 changes: 2 additions & 2 deletions modules/calib3d/src/stereobm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,12 +534,12 @@ static void findStereoCorrespondenceBM_SIMD( const Mat& left, const Mat& right,
v_expand(sad8, sad4_l, sad4_h);
mask4 = thresh4 > sad4_l;
mask4 = mask4 & ((d1 > d4) | (d4 > d2));
if( v_signmask(mask4) )
if( v_check_any(mask4) )
break;
d4 += dd_4;
mask4 = thresh4 > sad4_h;
mask4 = mask4 & ((d1 > d4) | (d4 > d2));
if( v_signmask(mask4) )
if( v_check_any(mask4) )
break;
d4 += dd_4;
}
Expand Down
4 changes: 2 additions & 2 deletions modules/calib3d/src/stereosgbm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2013,14 +2013,14 @@ void SGBM3WayMainLoop::operator () (const Range& range) const

mask = cost1 < thresh_reg;
mask = mask & ( (cur_d<d1) | (cur_d>d2) );
if( v_signmask(mask) )
if( v_check_any(mask) )
break;

cur_d = cur_d+eight_reg;

mask = cost2 < thresh_reg;
mask = mask & ( (cur_d<d1) | (cur_d>d2) );
if( v_signmask(mask) )
if( v_check_any(mask) )
break;

cur_d = cur_d+eight_reg;
Expand Down
4 changes: 2 additions & 2 deletions modules/core/include/opencv2/core/base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ CV_EXPORTS CV_NORETURN void error(int _code, const String& _err, const char* _fu

// In practice, some macro are not processed correctly (noreturn is not detected).
// We need to use simplified definition for them.
#define CV_Error(...) do { abort(); } while (0)
#define CV_Error_( code, args ) do { cv::format args; abort(); } while (0)
#define CV_Error(code, msg) do { (void)(code); (void)(msg); abort(); } while (0)
#define CV_Error_(code, args) do { (void)(code); (void)(cv::format args); abort(); } while (0)
#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0)

#else // CV_STATIC_ANALYSIS
Expand Down
Loading

0 comments on commit 097d813

Please sign in to comment.