mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merging master to filter_avx2, and resolving conflicts
This commit is contained in:
Vendored
+33
-21
@@ -1,25 +1,37 @@
|
||||
# Binary branch name: ffmpeg/master_20161202
|
||||
# Binaries were created for OpenCV: 594c136d1fcbb5816c57516e50f9cbeffbd90835
|
||||
set(FFMPEG_BINARIES_COMMIT "2a19d0006415955c79431116e4634f04d5eb5a74")
|
||||
set(FFMPEG_FILE_HASH_BIN32 "f081abd9d6ca7e425d340ce586f9c090")
|
||||
set(FFMPEG_FILE_HASH_BIN64 "a423363a6eb76d362ca6c406c96c8db6")
|
||||
set(FFMPEG_FILE_HASH_CMAKE "5346ae1854fc7aa569a722e85af480ec")
|
||||
# Binary branch name: ffmpeg/master_20170418
|
||||
# Binaries were created for OpenCV: b993b9b7c7f6f5f37d10acacb2962812228410ba
|
||||
set(FFMPEG_BINARIES_COMMIT "86c4a841055f2612774e85b4292bb20e5fe8a783")
|
||||
set(FFMPEG_FILE_HASH_BIN32 "3dea5f7f009b44601fe95728328e0f9e")
|
||||
set(FFMPEG_FILE_HASH_BIN64 "9debe701975ef074bd6661981f3f0716")
|
||||
set(FFMPEG_FILE_HASH_CMAKE "208c00f03d2f6f39fa6262649e0bfc8d")
|
||||
|
||||
set(FFMPEG_DOWNLOAD_URL ${OPENCV_FFMPEG_URL};$ENV{OPENCV_FFMPEG_URL};https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/)
|
||||
function(download_win_ffmpeg script_var)
|
||||
set(${script_var} "" PARENT_SCOPE)
|
||||
|
||||
ocv_download(PACKAGE opencv_ffmpeg.dll
|
||||
HASH ${FFMPEG_FILE_HASH_BIN32}
|
||||
URL ${FFMPEG_DOWNLOAD_URL}
|
||||
DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(ids BIN32 BIN64 CMAKE)
|
||||
set(name_BIN32 "opencv_ffmpeg.dll")
|
||||
set(name_BIN64 "opencv_ffmpeg_64.dll")
|
||||
set(name_CMAKE "ffmpeg_version.cmake")
|
||||
|
||||
ocv_download(PACKAGE opencv_ffmpeg_64.dll
|
||||
HASH ${FFMPEG_FILE_HASH_BIN64}
|
||||
URL ${FFMPEG_DOWNLOAD_URL}
|
||||
DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
set(FFMPEG_DOWNLOAD_DIR "${OpenCV_BINARY_DIR}/3rdparty/ffmpeg")
|
||||
|
||||
ocv_download(PACKAGE ffmpeg_version.cmake
|
||||
HASH ${FFMPEG_FILE_HASH_CMAKE}
|
||||
URL ${FFMPEG_DOWNLOAD_URL}
|
||||
DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||
|
||||
include(${CMAKE_CURRENT_LIST_DIR}/ffmpeg_version.cmake)
|
||||
set(status TRUE)
|
||||
foreach(id ${ids})
|
||||
ocv_download(FILENAME ${name_${id}}
|
||||
HASH ${FFMPEG_FILE_HASH_${id}}
|
||||
URL
|
||||
"$ENV{OPENCV_FFMPEG_URL}"
|
||||
"${OPENCV_FFMPEG_URL}"
|
||||
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/"
|
||||
DESTINATION_DIR ${FFMPEG_DOWNLOAD_DIR}
|
||||
ID FFMPEG
|
||||
RELATIVE_URL
|
||||
STATUS res)
|
||||
if(NOT res)
|
||||
set(status FALSE)
|
||||
endif()
|
||||
endforeach()
|
||||
if(status)
|
||||
set(${script_var} "${FFMPEG_DOWNLOAD_DIR}/ffmpeg_version.cmake" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
downloads/
|
||||
unpack/
|
||||
Vendored
+42
@@ -0,0 +1,42 @@
|
||||
# ----------------------------------------------------------------------------
|
||||
# CMake file for IPP IW. See root CMakeLists.txt
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
project(${IPP_IW_LIBRARY})
|
||||
|
||||
ocv_include_directories(${IPP_INCLUDE_DIRS} ${IPP_IW_PATH}/include)
|
||||
add_definitions(-DIW_BUILD)
|
||||
if(HAVE_IPP_ICV_ONLY)
|
||||
add_definitions(-DICV_BASE)
|
||||
endif()
|
||||
|
||||
file(GLOB lib_srcs ${IPP_IW_PATH}/src/*.c)
|
||||
file(GLOB lib_hdrs ${IPP_IW_PATH}/include/*.h ${IPP_IW_PATH}/include/iw/*.h ${IPP_IW_PATH}/include/iw++/*.hpp)
|
||||
|
||||
# ----------------------------------------------------------------------------------
|
||||
# Define the library target:
|
||||
# ----------------------------------------------------------------------------------
|
||||
|
||||
add_library(${IPP_IW_LIBRARY} STATIC ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if(UNIX)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CV_ICC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fPIC -Wno-unused-function")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set_target_properties(${IPP_IW_LIBRARY}
|
||||
PROPERTIES OUTPUT_NAME ${IPP_IW_LIBRARY}
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
COMPILE_PDB_NAME ${IPP_IW_LIBRARY}
|
||||
COMPILE_PDB_NAME_DEBUG "${IPP_IW_LIBRARY}${OPENCV_DEBUG_POSTFIX}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${3P_LIBRARY_OUTPUT_PATH}
|
||||
)
|
||||
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
set_target_properties(${IPP_IW_LIBRARY} PROPERTIES FOLDER "3rdparty")
|
||||
endif()
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
ocv_install_target(${IPP_IW_LIBRARY} EXPORT OpenCVModules ARCHIVE DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
endif()
|
||||
Vendored
-110
@@ -1,110 +0,0 @@
|
||||
#
|
||||
# The script downloads ICV package
|
||||
#
|
||||
# On return this will define:
|
||||
# OPENCV_ICV_PATH - path to unpacked downloaded package
|
||||
#
|
||||
|
||||
function(_icv_downloader)
|
||||
# Commit SHA in the opencv_3rdparty repo
|
||||
set(IPPICV_BINARIES_COMMIT "81a676001ca8075ada498583e4166079e5744668")
|
||||
# Define actual ICV versions
|
||||
if(APPLE)
|
||||
set(OPENCV_ICV_PACKAGE_NAME "ippicv_macosx_20151201.tgz")
|
||||
set(OPENCV_ICV_PACKAGE_HASH "4ff1fde9a7cfdfe7250bfcd8334e0f2f")
|
||||
set(OPENCV_ICV_PLATFORM "macosx")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_osx")
|
||||
elseif(UNIX)
|
||||
if(ANDROID AND NOT (ANDROID_ABI STREQUAL x86 OR ANDROID_ABI STREQUAL x86_64))
|
||||
return()
|
||||
endif()
|
||||
set(OPENCV_ICV_PACKAGE_NAME "ippicv_linux_20151201.tgz")
|
||||
set(OPENCV_ICV_PACKAGE_HASH "808b791a6eac9ed78d32a7666804320e")
|
||||
set(OPENCV_ICV_PLATFORM "linux")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_lnx")
|
||||
elseif(WIN32 AND NOT ARM)
|
||||
set(OPENCV_ICV_PACKAGE_NAME "ippicv_windows_20151201.zip")
|
||||
set(OPENCV_ICV_PACKAGE_HASH "04e81ce5d0e329c3fbc606ae32cad44d")
|
||||
set(OPENCV_ICV_PLATFORM "windows")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "/ippicv_win")
|
||||
else()
|
||||
return() # Not supported
|
||||
endif()
|
||||
|
||||
set(OPENCV_ICV_UNPACK_PATH "${CMAKE_BINARY_DIR}/3rdparty/ippicv")
|
||||
set(OPENCV_ICV_PATH "${OPENCV_ICV_UNPACK_PATH}${OPENCV_ICV_PACKAGE_SUBDIR}")
|
||||
|
||||
if(DEFINED OPENCV_ICV_PACKAGE_DOWNLOADED
|
||||
AND OPENCV_ICV_PACKAGE_DOWNLOADED STREQUAL OPENCV_ICV_PACKAGE_HASH
|
||||
AND EXISTS ${OPENCV_ICV_PATH})
|
||||
# Package has been downloaded and checked by the previous build
|
||||
set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
|
||||
return()
|
||||
else()
|
||||
if(EXISTS ${OPENCV_ICV_UNPACK_PATH})
|
||||
message(STATUS "ICV: Removing previous unpacked package: ${OPENCV_ICV_UNPACK_PATH}")
|
||||
file(REMOVE_RECURSE ${OPENCV_ICV_UNPACK_PATH})
|
||||
endif()
|
||||
endif()
|
||||
unset(OPENCV_ICV_PACKAGE_DOWNLOADED CACHE)
|
||||
|
||||
set(OPENCV_ICV_PACKAGE_ARCHIVE "${CMAKE_CURRENT_LIST_DIR}/downloads/${OPENCV_ICV_PLATFORM}-${OPENCV_ICV_PACKAGE_HASH}/${OPENCV_ICV_PACKAGE_NAME}")
|
||||
get_filename_component(OPENCV_ICV_PACKAGE_ARCHIVE_DIR "${OPENCV_ICV_PACKAGE_ARCHIVE}" PATH)
|
||||
if(EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
file(MD5 "${OPENCV_ICV_PACKAGE_ARCHIVE}" archive_md5)
|
||||
if(NOT archive_md5 STREQUAL OPENCV_ICV_PACKAGE_HASH)
|
||||
message(WARNING "ICV: Local copy of ICV package has invalid MD5 hash: ${archive_md5} (expected: ${OPENCV_ICV_PACKAGE_HASH})")
|
||||
file(REMOVE "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
file(REMOVE_RECURSE "${OPENCV_ICV_PACKAGE_ARCHIVE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
if(NOT DEFINED OPENCV_ICV_URL)
|
||||
if(DEFINED ENV{OPENCV_ICV_URL})
|
||||
set(OPENCV_ICV_URL $ENV{OPENCV_ICV_URL})
|
||||
else()
|
||||
set(OPENCV_ICV_URL "https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_BINARIES_COMMIT}/ippicv")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
file(MAKE_DIRECTORY ${OPENCV_ICV_PACKAGE_ARCHIVE_DIR})
|
||||
message(STATUS "ICV: Downloading ${OPENCV_ICV_PACKAGE_NAME}...")
|
||||
file(DOWNLOAD "${OPENCV_ICV_URL}/${OPENCV_ICV_PACKAGE_NAME}" "${OPENCV_ICV_PACKAGE_ARCHIVE}"
|
||||
TIMEOUT 600 STATUS __status
|
||||
EXPECTED_MD5 ${OPENCV_ICV_PACKAGE_HASH})
|
||||
if(NOT __status EQUAL 0)
|
||||
message(FATAL_ERROR "ICV: Failed to download ICV package: ${OPENCV_ICV_PACKAGE_NAME}. Status=${__status}")
|
||||
else()
|
||||
# Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step
|
||||
# on wrong hash
|
||||
file(MD5 "${OPENCV_ICV_PACKAGE_ARCHIVE}" archive_md5)
|
||||
if(NOT archive_md5 STREQUAL OPENCV_ICV_PACKAGE_HASH)
|
||||
message(FATAL_ERROR "ICV: Downloaded copy of ICV package has invalid MD5 hash: ${archive_md5} (expected: ${OPENCV_ICV_PACKAGE_HASH})")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ocv_assert(EXISTS "${OPENCV_ICV_PACKAGE_ARCHIVE}")
|
||||
ocv_assert(NOT EXISTS "${OPENCV_ICV_UNPACK_PATH}")
|
||||
file(MAKE_DIRECTORY ${OPENCV_ICV_UNPACK_PATH})
|
||||
ocv_assert(EXISTS "${OPENCV_ICV_UNPACK_PATH}")
|
||||
|
||||
message(STATUS "ICV: Unpacking ${OPENCV_ICV_PACKAGE_NAME} to ${OPENCV_ICV_UNPACK_PATH}...")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${OPENCV_ICV_PACKAGE_ARCHIVE}"
|
||||
WORKING_DIRECTORY "${OPENCV_ICV_UNPACK_PATH}"
|
||||
RESULT_VARIABLE __result)
|
||||
|
||||
if(NOT __result EQUAL 0)
|
||||
message(FATAL_ERROR "ICV: Failed to unpack ICV package from ${OPENCV_ICV_PACKAGE_ARCHIVE} to ${OPENCV_ICV_UNPACK_PATH} with error ${__result}")
|
||||
endif()
|
||||
|
||||
ocv_assert(EXISTS "${OPENCV_ICV_PATH}")
|
||||
|
||||
set(OPENCV_ICV_PACKAGE_DOWNLOADED "${OPENCV_ICV_PACKAGE_HASH}" CACHE INTERNAL "ICV package hash")
|
||||
|
||||
message(STATUS "ICV: Package successfully downloaded")
|
||||
set(OPENCV_ICV_PATH "${OPENCV_ICV_PATH}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
_icv_downloader()
|
||||
Vendored
+56
@@ -0,0 +1,56 @@
|
||||
function(download_ippicv root_var)
|
||||
set(${root_var} "" PARENT_SCOPE)
|
||||
|
||||
# Commit SHA in the opencv_3rdparty repo
|
||||
set(IPPICV_COMMIT "a62e20676a60ee0ad6581e217fe7e4bada3b95db")
|
||||
# Define actual ICV versions
|
||||
if(APPLE)
|
||||
set(OPENCV_ICV_PLATFORM "macosx")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_mac")
|
||||
if(X86_64)
|
||||
set(OPENCV_ICV_NAME "ippicv_2017u2_mac_intel64_20170418.tgz")
|
||||
set(OPENCV_ICV_HASH "0c25953c99dbb499ff502485a9356d8d")
|
||||
else()
|
||||
set(OPENCV_ICV_NAME "ippicv_2017u2_mac_ia32_20170418.tgz")
|
||||
set(OPENCV_ICV_HASH "5f225948f3f64067c681293c098d50d8")
|
||||
endif()
|
||||
elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86"))
|
||||
set(OPENCV_ICV_PLATFORM "linux")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_lnx")
|
||||
if(X86_64)
|
||||
set(OPENCV_ICV_NAME "ippicv_2017u2_lnx_intel64_20170418.tgz")
|
||||
set(OPENCV_ICV_HASH "87cbdeb627415d8e4bc811156289fa3a")
|
||||
else()
|
||||
set(OPENCV_ICV_NAME "ippicv_2017u2_lnx_ia32_20170418.tgz")
|
||||
set(OPENCV_ICV_HASH "f2cece00d802d4dea86df52ed095257e")
|
||||
endif()
|
||||
elseif(WIN32 AND NOT ARM)
|
||||
set(OPENCV_ICV_PLATFORM "windows")
|
||||
set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_win")
|
||||
if(X86_64)
|
||||
set(OPENCV_ICV_NAME "ippicv_2017u2_win_intel64_20170418.zip")
|
||||
set(OPENCV_ICV_HASH "75060a0c662c0800f48995b7e9b085f6")
|
||||
else()
|
||||
set(OPENCV_ICV_NAME "ippicv_2017u2_win_ia32_20170418.zip")
|
||||
set(OPENCV_ICV_HASH "60fcf3ccd9a2ebc9e432ffb5cb91638b")
|
||||
endif()
|
||||
else()
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(THE_ROOT "${OpenCV_BINARY_DIR}/3rdparty/ippicv")
|
||||
ocv_download(FILENAME ${OPENCV_ICV_NAME}
|
||||
HASH ${OPENCV_ICV_HASH}
|
||||
URL
|
||||
"${OPENCV_IPPICV_URL}"
|
||||
"$ENV{OPENCV_IPPICV_URL}"
|
||||
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
|
||||
DESTINATION_DIR "${THE_ROOT}"
|
||||
ID IPPICV
|
||||
STATUS res
|
||||
UNPACK RELATIVE_URL)
|
||||
|
||||
if(res)
|
||||
set(${root_var} "${THE_ROOT}/${OPENCV_ICV_PACKAGE_SUBDIR}" PARENT_SCOPE)
|
||||
endif()
|
||||
endfunction()
|
||||
Vendored
+3
-2
@@ -11,6 +11,7 @@
|
||||
#include <cfloat>
|
||||
#include <climits>
|
||||
#include <cmath>
|
||||
#include <cstring>
|
||||
|
||||
//==================================================================================================
|
||||
// utility
|
||||
@@ -600,7 +601,7 @@ int ovx_hal_sepFilterInit(cvhalFilter2D **filter_context, int src_type, int dst_
|
||||
{
|
||||
if (!filter_context || !kernelx_data || !kernely_data || delta != 0 ||
|
||||
src_type != CV_8UC1 || (dst_type != CV_8UC1 && dst_type != CV_16SC1) ||
|
||||
kernelx_length % 2 == 0 || kernely_length % 2 == 0 || anchor_x != kernelx_length / 2 || anchor_y != kernely_length / 2)
|
||||
kernelx_length != 3 || kernely_length != 3 || anchor_x != 1 || anchor_y != 1)
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
ivx::border_t border;
|
||||
@@ -1076,7 +1077,7 @@ int ovx_hal_integral(int depth, int sdepth, int, const uchar * a, size_t astep,
|
||||
ib = ivx::Image::createFromHandle(ctx, VX_DF_IMAGE_U32,
|
||||
ivx::Image::createAddressing(w, h, 4, (vx_int32)bstep), (unsigned int *)(b + bstep + sizeof(unsigned int)));
|
||||
ivx::IVX_CHECK_STATUS(vxuIntegralImage(ctx, ia, ib));
|
||||
memset(b, 0, (w + 1) * sizeof(unsigned int));
|
||||
std::memset(b, 0, (w + 1) * sizeof(unsigned int));
|
||||
b += bstep;
|
||||
for (int i = 0; i < h; i++, b += bstep)
|
||||
{
|
||||
|
||||
Vendored
+12
-6
@@ -32,6 +32,12 @@ static const vx_enum VX_INTERPOLATION_NEAREST_NEIGHBOR = VX_INTERPOLATION_TYPE_N
|
||||
static const vx_enum VX_BORDER_CONSTANT = VX_BORDER_MODE_CONSTANT;
|
||||
static const vx_enum VX_BORDER_REPLICATE = VX_BORDER_MODE_REPLICATE;
|
||||
|
||||
#else
|
||||
|
||||
#ifdef IVX_RENAMED_REFS
|
||||
static const vx_enum VX_REF_ATTRIBUTE_TYPE = VX_REFERENCE_TYPE;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#ifndef IVX_USE_CXX98
|
||||
@@ -2502,10 +2508,10 @@ public:
|
||||
{
|
||||
if (!areTypesCompatible(TypeToEnum<T>::value, dataType()))
|
||||
throw WrapperError(std::string(__func__) + "(): destination type is wrong");
|
||||
if (data.size() != size())
|
||||
if (data.size()*sizeof(T) != size())
|
||||
{
|
||||
if (data.size() == 0)
|
||||
data.resize(size());
|
||||
data.resize(size()/sizeof(T));
|
||||
else
|
||||
throw WrapperError(std::string(__func__) + "(): destination size is wrong");
|
||||
}
|
||||
@@ -2516,7 +2522,7 @@ public:
|
||||
{
|
||||
if (!areTypesCompatible(TypeToEnum<T>::value, dataType()))
|
||||
throw WrapperError(std::string(__func__) + "(): source type is wrong");
|
||||
if (data.size() != size()) throw WrapperError(std::string(__func__) + "(): source size is wrong");
|
||||
if (data.size()*sizeof(T) != size()) throw WrapperError(std::string(__func__) + "(): source size is wrong");
|
||||
copyFrom(&data[0]);
|
||||
}
|
||||
|
||||
@@ -2664,10 +2670,10 @@ public:
|
||||
{
|
||||
if (!areTypesCompatible(TypeToEnum<T>::value, dataType()))
|
||||
throw WrapperError(std::string(__func__) + "(): destination type is wrong");
|
||||
if (data.size() != size())
|
||||
if (data.size()*sizeof(T) != size())
|
||||
{
|
||||
if (data.size() == 0)
|
||||
data.resize(size());
|
||||
data.resize(size()/sizeof(T));
|
||||
else
|
||||
throw WrapperError(std::string(__func__) + "(): destination size is wrong");
|
||||
}
|
||||
@@ -2678,7 +2684,7 @@ public:
|
||||
{
|
||||
if (!areTypesCompatible(TypeToEnum<T>::value, dataType()))
|
||||
throw WrapperError(std::string(__func__) + "(): source type is wrong");
|
||||
if (data.size() != size()) throw WrapperError(std::string(__func__) + "(): source size is wrong");
|
||||
if (data.size()*sizeof(T) != size()) throw WrapperError(std::string(__func__) + "(): source size is wrong");
|
||||
copyFrom(&data[0]);
|
||||
}
|
||||
|
||||
|
||||
Vendored
+17
-101
@@ -6,112 +6,28 @@ if (WIN32 AND NOT ARM)
|
||||
endif()
|
||||
|
||||
set(tbb_ver "tbb44_20160128oss")
|
||||
set(tbb_url "http://www.threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb44_20160128oss_src_0.tgz")
|
||||
set(tbb_md5 "9d8a4cdf43496f1b3f7c473a5248e5cc")
|
||||
set(tbb_filename "4.4.3.tar.gz")
|
||||
set(tbb_subdir "tbb-4.4.3")
|
||||
set(tbb_md5 "8e7200af3ac16e91a0d1535c606a485c")
|
||||
set(tbb_version_file "version_string.ver")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
|
||||
# 4.1 update 4 - The first release that supports Windows RT. Hangs on some Android devices
|
||||
#set(tbb_ver "tbb41_20130613oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130613oss_src.tgz")
|
||||
#set(tbb_md5 "108c8c1e481b0aaea61878289eb28b6a")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
#ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
|
||||
|
||||
# 4.1 update 2 - works fine
|
||||
#set(tbb_ver "tbb41_20130116oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
|
||||
#set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
#ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
|
||||
# 4.1 update 3 dev - Hangs on some Android devices
|
||||
#set(tbb_ver "tbb41_20130401oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130401oss_src.tgz")
|
||||
#set(tbb_md5 "f2f591a0d2ca8f801e221ce7d9ea84bb")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
#ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
|
||||
# 4.1 update 2 - works fine
|
||||
#set(tbb_ver "tbb41_20130116oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
|
||||
#set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
#ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
|
||||
# 4.1 update 1 - works fine
|
||||
#set(tbb_ver "tbb41_20121003oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20121003oss_src.tgz")
|
||||
#set(tbb_md5 "2a684fefb855d2d0318d1ef09afa75ff")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
|
||||
# 4.1 - works fine
|
||||
#set(tbb_ver "tbb41_20120718oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20120718oss_src.tgz")
|
||||
#set(tbb_md5 "31b9ec300f3d09da2504d5d882788dd4")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
|
||||
# 4.0 update 5 - works fine
|
||||
#set(tbb_ver "tbb40_20120613oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120613oss_src.tgz")
|
||||
#set(tbb_md5 "da01ed74944ec5950cfae3476901a172")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
|
||||
# 4.0 update 4 - works fine
|
||||
#set(tbb_ver "tbb40_20120408oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120408oss_src.tgz")
|
||||
#set(tbb_md5 "734b356da7fe0ed308741f3e6018251e")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
|
||||
# 4.0 update 3 - build broken
|
||||
#set(tbb_ver "tbb40_20120201oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb40_20120201oss_src.tgz")
|
||||
#set(tbb_md5 "4669e7d4adee018de7a7b8b972987218")
|
||||
#set(tbb_version_file "version_string.tmp")
|
||||
|
||||
set(tbb_tarball "${CMAKE_CURRENT_SOURCE_DIR}/${tbb_ver}_src.tgz")
|
||||
set(tbb_src_dir "${CMAKE_CURRENT_BINARY_DIR}/${tbb_ver}")
|
||||
|
||||
if(EXISTS "${tbb_tarball}")
|
||||
file(MD5 "${tbb_tarball}" tbb_local_md5)
|
||||
if(NOT tbb_local_md5 STREQUAL tbb_md5)
|
||||
message(WARNING "Local copy of TBB source tarball has invalid MD5 hash: ${tbb_local_md5} (expected: ${tbb_md5})")
|
||||
file(REMOVE "${tbb_tarball}")
|
||||
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/${tbb_ver}")
|
||||
file(REMOVE_RECURSE "${CMAKE_CURRENT_BINARY_DIR}/${tbb_ver}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${tbb_tarball}")
|
||||
message(STATUS "Downloading ${tbb_ver}_src.tgz")
|
||||
file(DOWNLOAD "${tbb_url}" "${tbb_tarball}" TIMEOUT 600 STATUS __statvar)
|
||||
if(NOT __statvar EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to download TBB sources (${__statvar}): ${tbb_url}")
|
||||
endif()
|
||||
file(MD5 "${tbb_tarball}" tbb_local_md5)
|
||||
if(NOT tbb_local_md5 STREQUAL tbb_md5)
|
||||
file(REMOVE "${tbb_tarball}")
|
||||
message(FATAL_ERROR "Downloaded TBB source tarball has invalid MD5 hash: ${tbb_local_md5} (expected: ${tbb_md5})")
|
||||
endif()
|
||||
|
||||
if(EXISTS "${tbb_src_dir}")
|
||||
file(REMOVE_RECURSE "${tbb_src_dir}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# untar TBB sources
|
||||
if(NOT EXISTS "${tbb_src_dir}")
|
||||
message(STATUS "Unpacking ${tbb_ver}_src.tgz to ${tbb_src_dir}")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E tar xz "${tbb_tarball}"
|
||||
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
RESULT_VARIABLE tbb_untar_RESULT)
|
||||
|
||||
if(NOT tbb_untar_RESULT EQUAL 0 OR NOT EXISTS "${tbb_src_dir}")
|
||||
message(FATAL_ERROR "Failed to unpack TBB sources from ${tbb_tarball} to ${tbb_src_dir} with error ${tbb_untar_RESULT}")
|
||||
endif()
|
||||
set(tbb_src_dir "${OpenCV_BINARY_DIR}/3rdparty/tbb")
|
||||
ocv_download(FILENAME ${tbb_filename}
|
||||
HASH ${tbb_md5}
|
||||
URL
|
||||
"${OPENCV_TBB_URL}"
|
||||
"$ENV{OPENCV_TBB_URL}"
|
||||
"https://github.com/01org/tbb/archive/"
|
||||
DESTINATION_DIR ${tbb_src_dir}
|
||||
ID TBB
|
||||
STATUS res
|
||||
UNPACK RELATIVE_URL)
|
||||
if(NOT res)
|
||||
return()
|
||||
endif()
|
||||
set(tbb_src_dir "${tbb_src_dir}/${tbb_subdir}")
|
||||
|
||||
ocv_include_directories("${tbb_src_dir}/include"
|
||||
"${tbb_src_dir}/src/"
|
||||
|
||||
+66
-27
@@ -6,6 +6,13 @@
|
||||
#
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
# Disable in-source builds to prevent source tree corruption.
|
||||
if(" ${CMAKE_SOURCE_DIR}" STREQUAL " ${CMAKE_BINARY_DIR}")
|
||||
message(FATAL_ERROR "
|
||||
FATAL: In-source builds are not allowed.
|
||||
You should create separate directory for build files.
|
||||
")
|
||||
endif()
|
||||
|
||||
|
||||
include(cmake/OpenCVMinDepVersions.cmake)
|
||||
@@ -91,6 +98,14 @@ if(POLICY CMP0042)
|
||||
cmake_policy(SET CMP0042 NEW)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0051)
|
||||
cmake_policy(SET CMP0051 NEW)
|
||||
endif()
|
||||
|
||||
if(POLICY CMP0056)
|
||||
cmake_policy(SET CMP0056 NEW)
|
||||
endif()
|
||||
|
||||
include(cmake/OpenCVUtils.cmake)
|
||||
|
||||
# must go before the project command
|
||||
@@ -111,6 +126,8 @@ ocv_cmake_eval(DEBUG_PRE ONCE)
|
||||
|
||||
ocv_clear_vars(OpenCVModules_TARGETS)
|
||||
|
||||
include(cmake/OpenCVDownload.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Break in case of popular CMake configuration mistakes
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -260,6 +277,7 @@ OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 O
|
||||
OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR ANDROID OR APPLE )
|
||||
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (WIN32 OR ANDROID OR APPLE) AND NOT WINRT)
|
||||
OCV_OPTION(BUILD_TBB "Download and build TBB from source" ANDROID )
|
||||
OCV_OPTION(BUILD_IPP_IW "Build IPP IW from source" NOT MINGW IF (X86_64 OR X86) AND NOT WINRT )
|
||||
|
||||
# OpenCV installation options
|
||||
# ===================================================
|
||||
@@ -280,16 +298,6 @@ OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov"
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) )
|
||||
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE2 "Enable SSE2 instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX OR CV_ICC) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_POPCNT "Enable POPCNT instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_AVX2 "Enable AVX2 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_FMA3 "Enable FMA3 instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" "${NEON}" IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
|
||||
@@ -299,8 +307,9 @@ OCV_OPTION(ENABLE_IMPL_COLLECTION "Collect implementation data on function c
|
||||
OCV_OPTION(ENABLE_INSTRUMENTATION "Instrument functions to collect calls trace and performance" OFF )
|
||||
OCV_OPTION(ENABLE_GNU_STL_DEBUG "Enable GNU STL Debug mode (defines _GLIBCXX_DEBUG)" OFF IF ((NOT CMAKE_VERSION VERSION_LESS "2.8.11") AND CMAKE_COMPILER_IS_GNUCXX) )
|
||||
OCV_OPTION(GENERATE_ABI_DESCRIPTOR "Generate XML file for abi_compliance_checker tool" OFF IF UNIX)
|
||||
OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
|
||||
OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
|
||||
|
||||
OCV_OPTION(DOWNLOAD_EXTERNAL_TEST_DATA "Download external test data (Python executable and OPENCV_TEST_DATA_PATH environment variable may be required)" OFF )
|
||||
|
||||
|
||||
if(ENABLE_IMPL_COLLECTION)
|
||||
@@ -499,6 +508,9 @@ if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja" AND "${CMAKE_BUILD_TYPE}" STREQUAL
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
# --- Python Support ---
|
||||
include(cmake/OpenCVDetectPython.cmake)
|
||||
|
||||
include(cmake/OpenCVCompilerOptions.cmake)
|
||||
|
||||
|
||||
@@ -578,9 +590,6 @@ else()
|
||||
unset(DOXYGEN_FOUND CACHE)
|
||||
endif()
|
||||
|
||||
# --- Python Support ---
|
||||
include(cmake/OpenCVDetectPython.cmake)
|
||||
|
||||
# --- Java Support ---
|
||||
include(cmake/OpenCVDetectApacheAnt.cmake)
|
||||
if(ANDROID)
|
||||
@@ -869,6 +878,33 @@ if(NOT CMAKE_GENERATOR MATCHES "Xcode|Visual Studio")
|
||||
status(" Configuration:" ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
||||
|
||||
# ========================= CPU code generation mode =========================
|
||||
status("")
|
||||
status(" CPU/HW features:")
|
||||
status(" Baseline:" "${CPU_BASELINE_FINAL}")
|
||||
if(NOT CPU_BASELINE STREQUAL CPU_BASELINE_FINAL)
|
||||
status(" requested:" "${CPU_BASELINE}")
|
||||
endif()
|
||||
if(CPU_BASELINE_REQUIRE)
|
||||
status(" required:" "${CPU_BASELINE_REQUIRE}")
|
||||
endif()
|
||||
if(CPU_BASELINE_DISABLE)
|
||||
status(" disabled:" "${CPU_BASELINE_DISABLE}")
|
||||
endif()
|
||||
if(CPU_DISPATCH_FINAL OR CPU_DISPATCH)
|
||||
status(" Dispatched code generation:" "${CPU_DISPATCH_FINAL}")
|
||||
if(NOT CPU_DISPATCH STREQUAL CPU_DISPATCH_FINAL)
|
||||
status(" requested:" "${CPU_DISPATCH}")
|
||||
endif()
|
||||
if(CPU_DISPATCH_REQUIRE)
|
||||
status(" required:" "${CPU_DISPATCH_REQUIRE}")
|
||||
endif()
|
||||
foreach(OPT ${CPU_DISPATCH_FINAL})
|
||||
status(" ${OPT} (${CPU_${OPT}_USAGE_COUNT} files):" "+ ${CPU_DISPATCH_${OPT}_INCLUDED}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# ========================== C/C++ options ==========================
|
||||
if(CMAKE_CXX_COMPILER_VERSION)
|
||||
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_CXX_COMPILER_VERSION})")
|
||||
@@ -1080,7 +1116,7 @@ endif(DEFINED WITH_1394)
|
||||
|
||||
if(DEFINED WITH_FFMPEG OR HAVE_FFMPEG)
|
||||
if(WIN32)
|
||||
status(" FFMPEG:" WITH_FFMPEG THEN "YES (prebuilt binaries)" ELSE NO)
|
||||
status(" FFMPEG:" HAVE_FFMPEG THEN "YES (prebuilt binaries)" ELSE NO)
|
||||
else()
|
||||
status(" FFMPEG:" HAVE_FFMPEG THEN YES ELSE NO)
|
||||
endif()
|
||||
@@ -1210,17 +1246,27 @@ status("")
|
||||
status(" Other third-party libraries:")
|
||||
|
||||
if(WITH_IPP AND HAVE_IPP)
|
||||
status(" Use IPP:" "${IPP_VERSION_STR} [${IPP_VERSION_MAJOR}.${IPP_VERSION_MINOR}.${IPP_VERSION_BUILD}]")
|
||||
status(" at:" "${IPP_ROOT_DIR}")
|
||||
status(" Use Intel IPP:" "${IPP_VERSION_STR} [${IPP_VERSION_MAJOR}.${IPP_VERSION_MINOR}.${IPP_VERSION_BUILD}]")
|
||||
status(" at:" "${IPP_ROOT_DIR}")
|
||||
if(NOT HAVE_IPP_ICV_ONLY)
|
||||
status(" linked:" BUILD_WITH_DYNAMIC_IPP THEN "dynamic" ELSE "static")
|
||||
status(" linked:" BUILD_WITH_DYNAMIC_IPP THEN "dynamic" ELSE "static")
|
||||
endif()
|
||||
if(HAVE_IPP_IW)
|
||||
if(BUILD_IPP_IW)
|
||||
status(" Use Intel IPP IW:" "build (${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE})")
|
||||
else()
|
||||
status(" Use Intel IPP IW:" "prebuilt binaries (${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE})")
|
||||
endif()
|
||||
else()
|
||||
status(" Use Intel IPP IW:" NO)
|
||||
endif()
|
||||
else()
|
||||
status(" Use IPP:" WITH_IPP AND NOT HAVE_IPP THEN "IPP not found or implicitly disabled" ELSE NO)
|
||||
status(" Use Intel IPP:" WITH_IPP AND NOT HAVE_IPP THEN "IPP not found or implicitly disabled" ELSE NO)
|
||||
status(" Use Intel IPP IW:" WITH_IPP AND NOT HAVE_IPP AND HAVE_IPP_IW THEN "IPP not found or implicitly disabled" ELSE NO)
|
||||
endif()
|
||||
|
||||
if(DEFINED WITH_IPP_A)
|
||||
status(" Use IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
|
||||
status(" Use Intel IPP Async:" HAVE_IPP_A THEN "YES" ELSE NO)
|
||||
endif(DEFINED WITH_IPP_A)
|
||||
|
||||
if(DEFINED WITH_VA)
|
||||
@@ -1358,13 +1404,6 @@ status("")
|
||||
|
||||
ocv_finalize_status()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Warn in the case of in-source build
|
||||
# ----------------------------------------------------------------------------
|
||||
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
|
||||
message(WARNING "The source directory is the same as binary directory. \"make clean\" may damage the source tree")
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# CPack stuff
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
set(OPENCV_INTERACTIVECALIBRATION_DEPS opencv_core opencv_imgproc opencv_features2d opencv_aruco opencv_highgui opencv_calib3d opencv_videoio)
|
||||
set(OPENCV_INTERACTIVECALIBRATION_DEPS opencv_core opencv_imgproc opencv_features2d opencv_highgui opencv_calib3d opencv_videoio)
|
||||
if(${BUILD_opencv_aruco})
|
||||
list(APPEND OPENCV_INTERACTIVECALIBRATION_DEPS opencv_aruco)
|
||||
endif()
|
||||
ocv_check_dependencies(${OPENCV_INTERACTIVECALIBRATION_DEPS})
|
||||
|
||||
if(NOT OCV_DEPENDENCIES_FOUND)
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <opencv2/calib3d.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
#include <opencv2/aruco/charuco.hpp>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
#include <vector>
|
||||
@@ -75,6 +74,7 @@ bool CalibProcessor::detectAndParseChessboard(const cv::Mat &frame)
|
||||
|
||||
bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame)
|
||||
{
|
||||
#ifdef HAVE_OPENCV_ARUCO
|
||||
cv::Ptr<cv::aruco::Board> board = mCharucoBoard.staticCast<cv::aruco::Board>();
|
||||
|
||||
std::vector<std::vector<cv::Point2f> > corners, rejected;
|
||||
@@ -95,14 +95,16 @@ bool CalibProcessor::detectAndParseChAruco(const cv::Mat &frame)
|
||||
}
|
||||
centerX /= currentCharucoCorners.size[0];
|
||||
centerY /= currentCharucoCorners.size[0];
|
||||
//cv::circle(frame, cv::Point2f(centerX, centerY), 10, cv::Scalar(0, 255, 0), 10);
|
||||
|
||||
mTemplateLocations.insert(mTemplateLocations.begin(), cv::Point2f(centerX, centerY));
|
||||
cv::aruco::drawDetectedCornersCharuco(frame, currentCharucoCorners, currentCharucoIds);
|
||||
mCurrentCharucoCorners = currentCharucoCorners;
|
||||
mCurrentCharucoIds = currentCharucoIds;
|
||||
return true;
|
||||
}
|
||||
|
||||
#else
|
||||
(void)frame;
|
||||
#endif
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -231,6 +233,7 @@ bool CalibProcessor::checkLastFrame()
|
||||
}
|
||||
}
|
||||
else {
|
||||
#ifdef HAVE_OPENCV_ARUCO
|
||||
cv::Mat r, t, angles;
|
||||
std::vector<cv::Point3f> allObjPoints;
|
||||
allObjPoints.reserve(mCurrentCharucoIds.total());
|
||||
@@ -248,6 +251,7 @@ bool CalibProcessor::checkLastFrame()
|
||||
mCalibData->allCharucoCorners.pop_back();
|
||||
mCalibData->allCharucoIds.pop_back();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
return isFrameBad;
|
||||
}
|
||||
@@ -266,10 +270,12 @@ CalibProcessor::CalibProcessor(cv::Ptr<calibrationData> data, captureParameters
|
||||
switch(mBoardType)
|
||||
{
|
||||
case chAruco:
|
||||
#ifdef HAVE_OPENCV_ARUCO
|
||||
mArucoDictionary = cv::aruco::getPredefinedDictionary(
|
||||
cv::aruco::PREDEFINED_DICTIONARY_NAME(capParams.charucoDictName));
|
||||
mCharucoBoard = cv::aruco::CharucoBoard::create(mBoardSize.width, mBoardSize.height, capParams.charucoSquareLenght,
|
||||
capParams.charucoMarkerSize, mArucoDictionary);
|
||||
#endif
|
||||
break;
|
||||
case AcirclesGrid:
|
||||
mBlobDetectorPtr = cv::SimpleBlobDetector::create();
|
||||
|
||||
@@ -6,8 +6,10 @@
|
||||
#define FRAME_PROCESSOR_HPP
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/aruco/charuco.hpp>
|
||||
#include <opencv2/calib3d.hpp>
|
||||
#ifdef HAVE_OPENCV_ARUCO
|
||||
#include <opencv2/aruco/charuco.hpp>
|
||||
#endif
|
||||
|
||||
#include "calibCommon.hpp"
|
||||
#include "calibController.hpp"
|
||||
@@ -37,8 +39,10 @@ protected:
|
||||
cv::Mat mCurrentCharucoIds;
|
||||
|
||||
cv::Ptr<cv::SimpleBlobDetector> mBlobDetectorPtr;
|
||||
#ifdef HAVE_OPENCV_ARUCO
|
||||
cv::Ptr<cv::aruco::Dictionary> mArucoDictionary;
|
||||
cv::Ptr<cv::aruco::CharucoBoard> mCharucoBoard;
|
||||
#endif
|
||||
|
||||
int mNeededFramesNum;
|
||||
unsigned mDelayBetweenCaptures;
|
||||
|
||||
@@ -4,10 +4,13 @@
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
#include <opencv2/calib3d.hpp>
|
||||
#include <opencv2/aruco/charuco.hpp>
|
||||
#include <opencv2/cvconfig.h>
|
||||
#include <opencv2/highgui.hpp>
|
||||
|
||||
#ifdef HAVE_OPENCV_ARUCO
|
||||
#include <opencv2/aruco/charuco.hpp>
|
||||
#endif
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdexcept>
|
||||
@@ -50,31 +53,27 @@ bool calib::showOverlayMessage(const std::string& message)
|
||||
#endif
|
||||
}
|
||||
|
||||
static void deleteButton(int state, void* data)
|
||||
static void deleteButton(int, void* data)
|
||||
{
|
||||
state++; //to avoid gcc warnings
|
||||
(static_cast<cv::Ptr<calibDataController>*>(data))->get()->deleteLastFrame();
|
||||
calib::showOverlayMessage("Last frame deleted");
|
||||
}
|
||||
|
||||
static void deleteAllButton(int state, void* data)
|
||||
static void deleteAllButton(int, void* data)
|
||||
{
|
||||
state++;
|
||||
(static_cast<cv::Ptr<calibDataController>*>(data))->get()->deleteAllData();
|
||||
calib::showOverlayMessage("All frames deleted");
|
||||
}
|
||||
|
||||
static void saveCurrentParamsButton(int state, void* data)
|
||||
static void saveCurrentParamsButton(int, void* data)
|
||||
{
|
||||
state++;
|
||||
if((static_cast<cv::Ptr<calibDataController>*>(data))->get()->saveCurrentCameraParameters())
|
||||
calib::showOverlayMessage("Calibration parameters saved");
|
||||
}
|
||||
|
||||
#ifdef HAVE_QT
|
||||
static void switchVisualizationModeButton(int state, void* data)
|
||||
static void switchVisualizationModeButton(int, void* data)
|
||||
{
|
||||
state++;
|
||||
ShowProcessor* processor = static_cast<ShowProcessor*>(((cv::Ptr<FrameProcessor>*)data)->get());
|
||||
processor->switchVisualizationMode();
|
||||
}
|
||||
@@ -103,6 +102,11 @@ int main(int argc, char** argv)
|
||||
|
||||
captureParameters capParams = paramsController.getCaptureParameters();
|
||||
internalParameters intParams = paramsController.getInternalParameters();
|
||||
#ifndef HAVE_OPENCV_ARUCO
|
||||
if(capParams.board == chAruco)
|
||||
CV_Error(cv::Error::StsNotImplemented, "Aruco module is disabled in current build configuration."
|
||||
" Consider usage of another calibration pattern\n");
|
||||
#endif
|
||||
|
||||
cv::TermCriteria solverTermCrit = cv::TermCriteria(cv::TermCriteria::COUNT+cv::TermCriteria::EPS,
|
||||
intParams.solverMaxIters, intParams.solverEps);
|
||||
@@ -172,6 +176,7 @@ int main(int argc, char** argv)
|
||||
calibrationFlags, solverTermCrit);
|
||||
}
|
||||
else {
|
||||
#ifdef HAVE_OPENCV_ARUCO
|
||||
cv::Ptr<cv::aruco::Dictionary> dictionary =
|
||||
cv::aruco::getPredefinedDictionary(cv::aruco::PREDEFINED_DICTIONARY_NAME(capParams.charucoDictName));
|
||||
cv::Ptr<cv::aruco::CharucoBoard> charucoboard =
|
||||
@@ -183,6 +188,7 @@ int main(int argc, char** argv)
|
||||
globalData->cameraMatrix, globalData->distCoeffs,
|
||||
cv::noArray(), cv::noArray(), globalData->stdDeviations, cv::noArray(),
|
||||
globalData->perViewErrors, calibrationFlags, solverTermCrit);
|
||||
#endif
|
||||
}
|
||||
dataController->updateUndistortMap();
|
||||
dataController->printParametersToConsole(std::cout);
|
||||
|
||||
@@ -25,6 +25,20 @@ endif()
|
||||
|
||||
if(OPENVX_INCLUDE_DIR AND OPENVX_LIBRARIES)
|
||||
set(HAVE_OPENVX TRUE)
|
||||
|
||||
try_compile(OPENVX_RENAMED_REF
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/openvx_refenum_test.cpp"
|
||||
CMAKE_FLAGS "-DINCLUDE_DIRECTORIES:STRING=${OPENVX_INCLUDE_DIR}"
|
||||
LINK_LIBRARIES ${OPENVX_LIBRARIES}
|
||||
OUTPUT_VARIABLE OUTPUT
|
||||
)
|
||||
if(OPENVX_RENAMED_REF)
|
||||
add_definitions(-DIVX_RENAMED_REFS=1)
|
||||
message(STATUS "OpenVX: Checking reference attribute name convention... New")
|
||||
else()
|
||||
message(STATUS "OpenVX: Checking reference attribute name convention... Old")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_OPENVX)
|
||||
|
||||
@@ -38,6 +38,9 @@ if(MSVC AND WINRT)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_DEBUG "${CMAKE_SHARED_LINKER_FLAGS_DEBUG} /INCREMENTAL:NO /OPT:NOREF /OPT:NOICF")
|
||||
endif()
|
||||
|
||||
# Ignore warning: This object file does not define any previously undefined public symbols, ...
|
||||
set(CMAKE_STATIC_LINKER_FLAGS "${CMAKE_STATIC_LINKER_FLAGS} /IGNORE:4221")
|
||||
|
||||
if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
|
||||
foreach(flag_var
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
@@ -52,9 +55,9 @@ if(NOT BUILD_SHARED_LIBS AND BUILD_WITH_STATIC_CRT)
|
||||
endif()
|
||||
endforeach(flag_var)
|
||||
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:msvcrt.lib /NODEFAULTLIB:msvcrtd.lib")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /NODEFAULTLIB:atlthunk.lib")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /NODEFAULTLIB:libcmt.lib /NODEFAULTLIB:libcpmt.lib /NODEFAULTLIB:msvcrt.lib")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /NODEFAULTLIB:libcmtd.lib /NODEFAULTLIB:libcpmtd.lib /NODEFAULTLIB:msvcrtd.lib")
|
||||
else()
|
||||
foreach(flag_var
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
|
||||
|
||||
@@ -0,0 +1,734 @@
|
||||
# x86/x86-64 arch:
|
||||
# SSE / SSE2 (always available on 64-bit CPUs)
|
||||
# SSE3 / SSSE3
|
||||
# SSE4_1 / SSE4_2 / POPCNT
|
||||
# AVX / AVX2 / AVX512
|
||||
# FMA3
|
||||
|
||||
# CPU_{opt}_SUPPORTED=ON/OFF - compiler support (possibly with additional flag)
|
||||
# CPU_{opt}_IMPLIES=<list>
|
||||
# CPU_{opt}_FORCE=<list> - subset of "implies" list
|
||||
# CPU_{opt}_FLAGS_ON=""
|
||||
# CPU_{opt}_FEATURE_ALIAS - mapping to CV_CPU_* HWFeature enum
|
||||
|
||||
# Input variables:
|
||||
# CPU_BASELINE=<list> - preferred list of baseline optimizations
|
||||
# CPU_DISPATCH=<list> - preferred list of dispatched optimizations
|
||||
|
||||
# Advanced input variables:
|
||||
# CPU_BASELINE_REQUIRE=<list> - list of required baseline optimizations
|
||||
# CPU_DISPATCH_REQUIRE=<list> - list of required dispatched optimizations
|
||||
# CPU_BASELINE_DISABLE=<list> - list of disabled baseline optimizations
|
||||
|
||||
# Output variables:
|
||||
# CPU_BASELINE_FINAL=<list> - final list of enabled compiler optimizations
|
||||
# CPU_DISPATCH_FINAL=<list> - final list of dispatched optimizations
|
||||
#
|
||||
# CPU_DISPATCH_FLAGS_${opt} - flags for source files compiled separately (_opt_avx2.cpp)
|
||||
|
||||
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3") # without AVX512
|
||||
list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16)
|
||||
list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS)
|
||||
|
||||
ocv_update(CPU_VFPV3_FEATURE_ALIAS "")
|
||||
|
||||
|
||||
set(HELP_CPU_BASELINE "Specify list of enabled baseline CPU optimizations")
|
||||
set(HELP_CPU_BASELINE_REQUIRE "Specify list of required baseline CPU optimizations")
|
||||
set(HELP_CPU_BASELINE_DISABLE "Specify list of forbidden baseline CPU optimizations")
|
||||
set(HELP_CPU_DISPATCH "Specify list of dispatched CPU optimizations")
|
||||
set(HELP_CPU_DISPATCH_REQUIRE "Specify list of required dispatched CPU optimizations")
|
||||
|
||||
foreach(var CPU_BASELINE CPU_BASELINE_REQUIRE CPU_BASELINE_DISABLE CPU_DISPATCH CPU_DISPATCH_REQUIRE)
|
||||
if(DEFINED ${var})
|
||||
string(REPLACE "," ";" _list "${${var}}")
|
||||
set(${var} "${_list}" CACHE STRING "${HELP_${var}}" FORCE)
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# process legacy flags
|
||||
macro(ocv_optimization_process_obsolete_option legacy_flag OPT legacy_warn)
|
||||
if(DEFINED ${legacy_flag})
|
||||
if(${legacy_warn})
|
||||
message(STATUS "WARNING: Option ${legacy_flag}='${${legacy_flag}}' is deprecated and should not be used anymore")
|
||||
message(STATUS " Behaviour of this option is not backward compatible")
|
||||
message(STATUS " Refer to 'CPU_BASELINE'/'CPU_DISPATCH' CMake options documentation")
|
||||
endif()
|
||||
if(${legacy_flag})
|
||||
if(NOT ";${CPU_BASELINE_REQUIRE};" MATCHES ";${OPT};")
|
||||
set(CPU_BASELINE_REQUIRE "${CPU_BASELINE_REQUIRE};${OPT}" CACHE STRING "${HELP_CPU_BASELINE_REQUIRE}" FORCE)
|
||||
endif()
|
||||
else()
|
||||
if(NOT ";${CPU_BASELINE_DISABLE};" MATCHES ";${OPT};")
|
||||
set(CPU_BASELINE_DISABLE "${CPU_BASELINE_DISABLE};${OPT}" CACHE STRING "${HELP_CPU_BASELINE_DISABLE}" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
ocv_optimization_process_obsolete_option(ENABLE_SSE SSE ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_SSE2 SSE2 ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_SSE3 SSE3 ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_SSSE3 SSSE3 ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_SSE41 SSE4_1 ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_SSE42 SSE4_2 ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_POPCNT POPCNT ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_AVX AVX ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_AVX2 AVX2 ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
|
||||
|
||||
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
|
||||
|
||||
|
||||
macro(ocv_is_optimization_in_list resultvar check_opt)
|
||||
set(__checked "")
|
||||
set(__queue ${ARGN})
|
||||
set(${resultvar} 0)
|
||||
while(__queue AND NOT ${resultvar})
|
||||
list(REMOVE_DUPLICATES __queue)
|
||||
set(__queue_current ${__queue})
|
||||
set(__queue "")
|
||||
foreach(OPT ${__queue_current})
|
||||
if("x${OPT}" STREQUAL "x${check_opt}")
|
||||
set(${resultvar} 1)
|
||||
break()
|
||||
elseif(NOT ";${__checked};" MATCHES ";${OPT};")
|
||||
list(APPEND __queue ${CPU_${OPT}_IMPLIES})
|
||||
endif()
|
||||
list(APPEND __checked ${OPT})
|
||||
endforeach()
|
||||
endwhile()
|
||||
endmacro()
|
||||
|
||||
macro(ocv_is_optimization_in_force_list resultvar check_opt)
|
||||
set(__checked "")
|
||||
set(__queue ${ARGN})
|
||||
set(${resultvar} 0)
|
||||
while(__queue AND NOT ${resultvar})
|
||||
list(REMOVE_DUPLICATES __queue)
|
||||
set(__queue_current ${__queue})
|
||||
set(__queue "")
|
||||
foreach(OPT ${__queue_current})
|
||||
if(OPT STREQUAL "${check_opt}")
|
||||
set(${resultvar} 1)
|
||||
break()
|
||||
elseif(NOT ";${__checked};" MATCHES ";${OPT};")
|
||||
list(APPEND __queue ${CPU_${OPT}_FORCE})
|
||||
endif()
|
||||
list(APPEND __checked ${OPT})
|
||||
endforeach()
|
||||
endwhile()
|
||||
endmacro()
|
||||
|
||||
macro(ocv_append_optimization_flag var OPT)
|
||||
if(CPU_${OPT}_FLAGS_CONFLICT)
|
||||
string(REGEX REPLACE " ${CPU_${OPT}_FLAGS_CONFLICT}" "" ${var} " ${${var}}")
|
||||
string(REGEX REPLACE "^ +" "" ${var} "${${var}}")
|
||||
endif()
|
||||
set(${var} "${${var}} ${CPU_${OPT}_FLAGS_ON}")
|
||||
endmacro()
|
||||
|
||||
# Support GCC -march=native or Intel Compiler -xHost flags
|
||||
if(";${CPU_BASELINE};" MATCHES ";NATIVE;" OR ";${CPU_BASELINE};" MATCHES ";HOST;")
|
||||
set(CPU_BASELINE_DETECT ON)
|
||||
set(_add_native_flag ON)
|
||||
elseif(";${CPU_BASELINE};" MATCHES ";DETECT;")
|
||||
set(CPU_BASELINE_DETECT ON)
|
||||
elseif(" ${CMAKE_CXX_FLAGS} " MATCHES " -march=native | -xHost | /QxHost ")
|
||||
if(DEFINED CPU_BASELINE)
|
||||
message(STATUS "CPU: Detected '-march=native' or '-xHost' compiler flag. Force CPU_BASELINE=DETECT.")
|
||||
endif()
|
||||
set(CPU_BASELINE "DETECT" CACHE STRING "${HELP_CPU_BASELINE}")
|
||||
set(CPU_BASELINE_DETECT ON)
|
||||
endif()
|
||||
|
||||
if(X86 OR X86_64)
|
||||
ocv_update(CPU_KNOWN_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;POPCNT;SSE4_2;FP16;FMA3;AVX;AVX2;AVX512")
|
||||
|
||||
ocv_update(CPU_SSE_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse.cpp")
|
||||
ocv_update(CPU_SSE2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse2.cpp")
|
||||
ocv_update(CPU_SSE3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse3.cpp")
|
||||
ocv_update(CPU_SSSE3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_ssse3.cpp")
|
||||
ocv_update(CPU_SSE4_1_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse41.cpp")
|
||||
ocv_update(CPU_SSE4_2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_sse42.cpp")
|
||||
ocv_update(CPU_POPCNT_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_popcnt.cpp")
|
||||
ocv_update(CPU_AVX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx.cpp")
|
||||
ocv_update(CPU_AVX2_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx2.cpp")
|
||||
ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
|
||||
ocv_update(CPU_AVX512_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_avx512.cpp")
|
||||
|
||||
if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE)
|
||||
ocv_update(CPU_AVX512_IMPLIES "AVX2")
|
||||
ocv_update(CPU_AVX512_FORCE "") # Don't force other optimizations
|
||||
ocv_update(CPU_AVX2_IMPLIES "AVX;FMA3;FP16")
|
||||
ocv_update(CPU_FMA3_IMPLIES "AVX2")
|
||||
ocv_update(CPU_FMA3_FORCE "") # Don't force other optimizations
|
||||
ocv_update(CPU_FP16_IMPLIES "AVX")
|
||||
ocv_update(CPU_FP16_FORCE "") # Don't force other optimizations
|
||||
ocv_update(CPU_AVX_IMPLIES "SSE4_2")
|
||||
ocv_update(CPU_SSE4_2_IMPLIES "SSE4_1;POPCNT")
|
||||
ocv_update(CPU_POPCNT_IMPLIES "SSE4_1")
|
||||
ocv_update(CPU_POPCNT_FORCE "") # Don't force other optimizations
|
||||
ocv_update(CPU_SSE4_1_IMPLIES "SSE3;SSSE3")
|
||||
ocv_update(CPU_SSSE3_IMPLIES "SSE3")
|
||||
ocv_update(CPU_SSE3_IMPLIES "SSE2")
|
||||
ocv_update(CPU_SSE2_IMPLIES "SSE")
|
||||
endif()
|
||||
|
||||
if(CV_ICC)
|
||||
macro(ocv_intel_compiler_optimization_option name unix_flags msvc_flags)
|
||||
ocv_update(CPU_${name}_FLAGS_NAME "${name}")
|
||||
if(MSVC)
|
||||
set(enable_flags "${msvc_flags}")
|
||||
set(flags_conflict "/arch:[^ ]+")
|
||||
else()
|
||||
set(enable_flags "${unix_flags}")
|
||||
set(flags_conflict "-msse[^ ]*|-mssse3|-mavx[^ ]*|-march[^ ]+")
|
||||
endif()
|
||||
ocv_update(CPU_${name}_FLAGS_ON "${enable_flags}")
|
||||
if(flags_conflict)
|
||||
ocv_update(CPU_${name}_FLAGS_CONFLICT "${flags_conflict}")
|
||||
endif()
|
||||
endmacro()
|
||||
ocv_intel_compiler_optimization_option(AVX2 "-march=core-avx2" "/arch:CORE-AVX2")
|
||||
ocv_intel_compiler_optimization_option(FP16 "-mavx" "/arch:AVX")
|
||||
ocv_intel_compiler_optimization_option(AVX "-mavx" "/arch:AVX")
|
||||
ocv_intel_compiler_optimization_option(FMA3 "" "")
|
||||
ocv_intel_compiler_optimization_option(POPCNT "" "")
|
||||
ocv_intel_compiler_optimization_option(SSE4_2 "-msse4.2" "/arch:SSE4.2")
|
||||
ocv_intel_compiler_optimization_option(SSE4_1 "-msse4.1" "/arch:SSE4.1")
|
||||
ocv_intel_compiler_optimization_option(SSE3 "-msse3" "/arch:SSE3")
|
||||
ocv_intel_compiler_optimization_option(SSSE3 "-mssse3" "/arch:SSSE3")
|
||||
ocv_intel_compiler_optimization_option(SSE2 "-msse2" "/arch:SSE2")
|
||||
if(NOT X86_64) # x64 compiler doesn't support /arch:sse
|
||||
ocv_intel_compiler_optimization_option(SSE "-msse" "/arch:SSE")
|
||||
endif()
|
||||
#ocv_intel_compiler_optimization_option(AVX512 "-march=core-avx512")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
ocv_update(CPU_AVX2_FLAGS_ON "-mavx2")
|
||||
ocv_update(CPU_FP16_FLAGS_ON "-mf16c")
|
||||
ocv_update(CPU_AVX_FLAGS_ON "-mavx")
|
||||
ocv_update(CPU_FMA3_FLAGS_ON "-mfma")
|
||||
ocv_update(CPU_POPCNT_FLAGS_ON "-mpopcnt")
|
||||
ocv_update(CPU_SSE4_2_FLAGS_ON "-msse4.2")
|
||||
ocv_update(CPU_SSE4_1_FLAGS_ON "-msse4.1")
|
||||
ocv_update(CPU_SSE3_FLAGS_ON "-msse3")
|
||||
ocv_update(CPU_SSSE3_FLAGS_ON "-mssse3")
|
||||
ocv_update(CPU_SSE2_FLAGS_ON "-msse2")
|
||||
ocv_update(CPU_SSE_FLAGS_ON "-msse")
|
||||
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
|
||||
ocv_update(CPU_AVX512_FLAGS_ON "-mavx512f -mavx512pf -mavx512er -mavx512cd -mavx512vl -mavx512bw -mavx512dq -mavx512ifma -mavx512vbmi")
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
ocv_update(CPU_AVX2_FLAGS_ON "/arch:AVX2")
|
||||
ocv_update(CPU_AVX_FLAGS_ON "/arch:AVX")
|
||||
if(NOT MSVC64)
|
||||
# 64-bit MSVC compiler uses SSE/SSE2 by default
|
||||
ocv_update(CPU_SSE_FLAGS_ON "/arch:SSE")
|
||||
ocv_update(CPU_SSE_SUPPORTED ON)
|
||||
ocv_update(CPU_SSE2_FLAGS_ON "/arch:SSE2")
|
||||
ocv_update(CPU_SSE2_SUPPORTED ON)
|
||||
else()
|
||||
ocv_update(CPU_SSE_SUPPORTED ON)
|
||||
ocv_update(CPU_SSE2_SUPPORTED ON)
|
||||
endif()
|
||||
# Other instruction sets are supported by default since MSVC 2008 at least
|
||||
else()
|
||||
message(WARNING "TODO: Unsupported compiler")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CPU_DISPATCH)
|
||||
set(CPU_DISPATCH "SSE4_1;AVX;FP16;AVX2" CACHE STRING "${HELP_CPU_DISPATCH}")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED CPU_BASELINE)
|
||||
if(X86_64)
|
||||
set(CPU_BASELINE "SSSE3" CACHE STRING "${HELP_CPU_BASELINE}")
|
||||
else()
|
||||
set(CPU_BASELINE "SSE2" CACHE STRING "${HELP_CPU_BASELINE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
elseif(ARM OR AARCH64)
|
||||
ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
|
||||
if(NOT AARCH64)
|
||||
ocv_update(CPU_KNOWN_OPTIMIZATIONS "VFPV3;NEON;FP16")
|
||||
ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
|
||||
ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
|
||||
ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
|
||||
set(CPU_BASELINE "DETECT" CACHE STRING "${HELP_CPU_BASELINE}")
|
||||
else()
|
||||
ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16")
|
||||
ocv_update(CPU_NEON_FLAGS_ON "")
|
||||
set(CPU_BASELINE "NEON" CACHE STRING "${HELP_CPU_BASELINE}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Helper values for cmake-gui
|
||||
set(CPU_BASELINE "DETECT" CACHE STRING "${HELP_CPU_BASELINE}")
|
||||
set(CPU_DISPATCH "" CACHE STRING "${HELP_CPU_DISPATCH}")
|
||||
set_property(CACHE CPU_BASELINE PROPERTY STRINGS "" ${CPU_KNOWN_OPTIMIZATIONS})
|
||||
set_property(CACHE CPU_DISPATCH PROPERTY STRINGS "" ${CPU_KNOWN_OPTIMIZATIONS})
|
||||
|
||||
set(CPU_BASELINE_FLAGS "")
|
||||
|
||||
set(CPU_BASELINE_FINAL "")
|
||||
set(CPU_DISPATCH_FINAL "")
|
||||
|
||||
if(CV_DISABLE_OPTIMIZATION)
|
||||
set(CPU_DISPATCH "")
|
||||
set(CPU_DISPATCH_REQUIRE "")
|
||||
endif()
|
||||
|
||||
macro(ocv_check_compiler_optimization OPT)
|
||||
if(NOT DEFINED CPU_${OPT}_SUPPORTED)
|
||||
if((DEFINED CPU_${OPT}_FLAGS_ON AND NOT "x${CPU_${OPT}_FLAGS_ON}" STREQUAL "x") OR CPU_${OPT}_TEST_FILE)
|
||||
set(_varname "")
|
||||
if(CPU_${OPT}_TEST_FILE)
|
||||
set(__available 0)
|
||||
if(CPU_BASELINE_DETECT)
|
||||
set(_varname "HAVE_CPU_${OPT}_SUPPORT")
|
||||
ocv_check_compiler_flag(CXX "${CPU_BASELINE_FLAGS}" "${_varname}" "${CPU_${OPT}_TEST_FILE}")
|
||||
if(${_varname})
|
||||
list(APPEND CPU_BASELINE_FINAL ${OPT})
|
||||
set(__available 1)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT __available)
|
||||
if(NOT "x${CPU_${OPT}_FLAGS_NAME}" STREQUAL "x")
|
||||
set(_varname "HAVE_CPU_${CPU_${OPT}_FLAGS_NAME}")
|
||||
set(_compile_flags "${CPU_BASELINE_FLAGS}")
|
||||
ocv_append_optimization_flag(_compile_flags ${OPT})
|
||||
ocv_check_compiler_flag(CXX "${_compile_flags}" "${_varname}" "${CPU_${OPT}_TEST_FILE}")
|
||||
elseif(NOT "x${CPU_${OPT}_FLAGS_ON}" STREQUAL "x")
|
||||
ocv_check_flag_support(CXX "${CPU_${OPT}_FLAGS_ON}" _varname "" "${CPU_${OPT}_TEST_FILE}")
|
||||
else()
|
||||
set(_varname "HAVE_CPU_${OPT}_SUPPORT")
|
||||
set(_compile_flags "${CPU_BASELINE_FLAGS}")
|
||||
ocv_append_optimization_flag(_compile_flags ${OPT})
|
||||
ocv_check_compiler_flag(CXX "${_compile_flags}" "${_varname}" "${CPU_${OPT}_TEST_FILE}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
ocv_check_flag_support(CXX "${CPU_${OPT}_FLAGS_ON}" _varname "")
|
||||
endif()
|
||||
if(_varname AND ${_varname})
|
||||
set(CPU_${OPT}_SUPPORTED ON)
|
||||
elseif(NOT CPU_${OPT}_SUPPORTED)
|
||||
message(STATUS "${OPT} is not supported by C++ compiler")
|
||||
endif()
|
||||
else()
|
||||
set(CPU_${OPT}_SUPPORTED ON)
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
|
||||
set(CPU_${OPT}_USAGE_COUNT 0 CACHE INTERNAL "")
|
||||
if(NOT DEFINED CPU_${OPT}_FORCE)
|
||||
set(CPU_${OPT}_FORCE "${CPU_${OPT}_IMPLIES}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(_add_native_flag)
|
||||
set(_varname "HAVE_CPU_NATIVE_SUPPORT")
|
||||
ocv_check_compiler_flag(CXX "-march=native" "${_varname}" "")
|
||||
if(_varname)
|
||||
set(CPU_BASELINE_FLAGS "${CPU_BASELINE_FLAGS} -march=native")
|
||||
else()
|
||||
set(_varname "HAVE_CPU_HOST_SUPPORT")
|
||||
if(MSVC)
|
||||
set(_flag "/QxHost")
|
||||
else()
|
||||
set(_flag "-xHost")
|
||||
endif()
|
||||
ocv_check_compiler_flag(CXX "${_flag}" "${_varname}" "")
|
||||
if(_varname)
|
||||
set(CPU_BASELINE_FLAGS "${CPU_BASELINE_FLAGS} ${flag}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
|
||||
set(__is_disabled 0)
|
||||
foreach(OPT2 ${CPU_BASELINE_DISABLE})
|
||||
ocv_is_optimization_in_list(__is_disabled ${OPT2} ${OPT})
|
||||
if(__is_disabled)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(__is_disabled)
|
||||
set(__is_from_baseline 0)
|
||||
else()
|
||||
ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE_REQUIRE})
|
||||
if(NOT __is_from_baseline)
|
||||
ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE})
|
||||
endif()
|
||||
endif()
|
||||
ocv_is_optimization_in_list(__is_from_dispatch ${OPT} ${CPU_DISPATCH_REQUIRE})
|
||||
if(NOT __is_from_dispatch)
|
||||
ocv_is_optimization_in_list(__is_from_dispatch ${OPT} ${CPU_DISPATCH})
|
||||
endif()
|
||||
if(__is_from_dispatch OR __is_from_baseline OR CPU_BASELINE_DETECT)
|
||||
ocv_check_compiler_optimization(${OPT})
|
||||
endif()
|
||||
if(CPU_BASELINE_DETECT AND NOT __is_from_baseline AND NOT __is_disabled)
|
||||
ocv_is_optimization_in_list(__is_from_baseline ${OPT} ${CPU_BASELINE_FINAL})
|
||||
endif()
|
||||
if(CPU_${OPT}_SUPPORTED)
|
||||
if(";${CPU_DISPATCH};" MATCHES ";${OPT};" AND NOT __is_from_baseline)
|
||||
list(APPEND CPU_DISPATCH_FINAL ${OPT})
|
||||
elseif(__is_from_baseline AND NOT CPU_BASELINE_DETECT)
|
||||
list(APPEND CPU_BASELINE_FINAL ${OPT})
|
||||
ocv_append_optimization_flag(CPU_BASELINE_FLAGS ${OPT})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(OPT ${CPU_BASELINE_REQUIRE})
|
||||
if(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
|
||||
message(SEND_ERROR "Required baseline optimization is not supported: ${OPT} (CPU_BASELINE_REQUIRE=${CPU_BASELINE_REQUIRE})")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(OPT ${CPU_BASELINE})
|
||||
if(OPT STREQUAL "DETECT" OR OPT STREQUAL "HOST" OR OPT STREQUAL "NATIVE")
|
||||
# nothing
|
||||
elseif(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
|
||||
message(STATUS "Optimization ${OPT} is not available, skipped")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(OPT ${CPU_DISPATCH_REQUIRE})
|
||||
if(";${CPU_DISPATCH_FINAL};" MATCHES ";${OPT};")
|
||||
# OK
|
||||
elseif(";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
|
||||
message(SEND_ERROR "Dispatched optimization ${OPT} is in baseline list (CPU_DISPATCH_REQUIRE=${CPU_DISPATCH_REQUIRE})")
|
||||
else()
|
||||
message(SEND_ERROR "Required dispatch optimization is not supported: ${OPT} (CPU_DISPATCH_REQUIRE=${CPU_DISPATCH_REQUIRE})")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(OPT ${CPU_DISPATCH})
|
||||
if(";${CPU_DISPATCH_FINAL};" MATCHES ";${OPT};")
|
||||
# OK
|
||||
elseif(";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
|
||||
# OK
|
||||
else()
|
||||
message(STATUS "Dispatch optimization ${OPT} is not available, skipped")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
#message(STATUS "CPU_BASELINE_FINAL=${CPU_BASELINE_FINAL}")
|
||||
#message(STATUS "CPU_DISPATCH_FINAL=${CPU_DISPATCH_FINAL}")
|
||||
|
||||
#if(CPU_DISPATCH_FINAL AND NOT PYTHON_DEFAULT_EXECUTABLE)
|
||||
# message(FATAL_ERROR "Python is required for CPU dispatched optimization support")
|
||||
#endif()
|
||||
|
||||
macro(ocv_compiler_optimization_options)
|
||||
set(__flags "${OPENCV_EXTRA_CXX_FLAGS} ${CPU_BASELINE_FLAGS}")
|
||||
if(NOT __flags STREQUAL CACHED_CPU_BASELINE_FLAGS)
|
||||
set(CACHED_CPU_BASELINE_FLAGS "${__flags}" CACHE INTERNAL "" FORCE)
|
||||
ocv_clear_vars(HAVE_CPU_BASELINE_FLAGS)
|
||||
endif()
|
||||
ocv_check_compiler_flag(CXX "${__flags}" HAVE_CPU_BASELINE_FLAGS)
|
||||
if(NOT HAVE_CPU_BASELINE_FLAGS)
|
||||
message(FATAL_ERROR "Compiler doesn't support baseline optimization flags: ${CPU_BASELINE_FLAGS}")
|
||||
endif()
|
||||
add_extra_compiler_option_force("${CPU_BASELINE_FLAGS}")
|
||||
|
||||
foreach(OPT ${CPU_DISPATCH_FINAL})
|
||||
set(__dispatch_flags "")
|
||||
set(__dispatch_definitions "")
|
||||
set(__dispatch_opts "")
|
||||
set(__dispatch_opts_force "")
|
||||
foreach(OPT2 ${CPU_KNOWN_OPTIMIZATIONS})
|
||||
if(NOT CPU_${OPT2}_SUPPORTED)
|
||||
#continue()
|
||||
else()
|
||||
ocv_is_optimization_in_list(__is_from_baseline ${OPT2} ${CPU_BASELINE_FINAL})
|
||||
if(NOT __is_from_baseline)
|
||||
ocv_is_optimization_in_list(__is_active ${OPT2} ${OPT})
|
||||
if(__is_active)
|
||||
ocv_append_optimization_flag(__dispatch_flags ${OPT2})
|
||||
list(APPEND __dispatch_definitions "CV_CPU_COMPILE_${OPT2}=1")
|
||||
list(APPEND __dispatch_opts "${OPT2}")
|
||||
endif()
|
||||
ocv_is_optimization_in_force_list(__is_force ${OPT2} ${OPT})
|
||||
if(__is_force)
|
||||
list(APPEND __dispatch_opts_force "${OPT2}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(__flags "${OPENCV_EXTRA_CXX_FLAGS} ${__dispatch_flags}")
|
||||
if(NOT __flags STREQUAL CACHED_CPU_DISPATCH_${OPT}_FLAGS)
|
||||
set(CACHED_CPU_DISPATCH_${OPT}_FLAGS "${__flags}" CACHE INTERNAL "" FORCE)
|
||||
ocv_clear_vars(HAVE_CPU_DISPATCH_FLAGS_${OPT})
|
||||
endif()
|
||||
ocv_check_compiler_flag(CXX "${__flags}" HAVE_CPU_DISPATCH_FLAGS_${OPT})
|
||||
if(NOT HAVE_CPU_DISPATCH_FLAGS_${OPT})
|
||||
message(FATAL_ERROR "Compiler doesn't support optimization flags for ${OPT} dispatch mode: ${__dispatch_flags}")
|
||||
endif()
|
||||
set(CPU_DISPATCH_FLAGS_${OPT} "${__dispatch_flags}")
|
||||
set(CPU_DISPATCH_DEFINITIONS_${OPT} "${__dispatch_definitions}")
|
||||
set(CPU_DISPATCH_${OPT}_INCLUDED "${__dispatch_opts}")
|
||||
set(CPU_DISPATCH_${OPT}_FORCED "${__dispatch_opts_force}")
|
||||
endforeach()
|
||||
|
||||
if(ENABLE_POWERPC)
|
||||
add_extra_compiler_option("-mcpu=G3 -mtune=G5")
|
||||
endif()
|
||||
if(ARM)
|
||||
add_extra_compiler_option("-mfp16-format=ieee")
|
||||
endif(ARM)
|
||||
if(ENABLE_NEON)
|
||||
add_extra_compiler_option("-mfpu=neon")
|
||||
endif()
|
||||
if(ENABLE_VFPV3 AND NOT ENABLE_NEON)
|
||||
add_extra_compiler_option("-mfpu=vfpv3")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(ocv_compiler_optimization_options_finalize)
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64))
|
||||
if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
if(OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)")
|
||||
add_extra_compiler_option(-mfpmath=sse) # !! important - be on the same wave with x64 compilers
|
||||
else()
|
||||
add_extra_compiler_option(-mfpmath=387)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
# Generate Intrinsic Functions
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
|
||||
|
||||
if((X86 OR X86_64) AND CMAKE_SIZEOF_VOID_P EQUAL 4 AND ";${CPU_BASELINE_FINAL};" MATCHES ";SSE;")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast") # !! important - be on the same wave with x64 compilers
|
||||
endif()
|
||||
endif(MSVC)
|
||||
endmacro()
|
||||
|
||||
macro(ocv_compiler_optimization_process_sources SOURCES_VAR_NAME LIBS_VAR_NAME TARGET_BASE_NAME)
|
||||
set(__result "")
|
||||
set(__result_libs "")
|
||||
foreach(OPT ${CPU_DISPATCH_FINAL})
|
||||
set(__result_${OPT} "")
|
||||
endforeach()
|
||||
foreach(fname ${${SOURCES_VAR_NAME}})
|
||||
string(TOLOWER "${fname}" fname_LOWER)
|
||||
get_filename_component(fname_LOWER "${fname_LOWER}" NAME)
|
||||
if(fname_LOWER MATCHES "\\.(.*)\\.cpp$")
|
||||
string(TOUPPER "${CMAKE_MATCH_1}" OPT_)
|
||||
if(OPT_ MATCHES "(CUDA.*|DISPATCH.*|OCL)") # don't touch files like filename.cuda.cpp
|
||||
list(APPEND __result "${fname}")
|
||||
#continue()
|
||||
elseif(CV_DISABLE_OPTIMIZATION OR NOT CV_ENABLE_INTRINSICS)
|
||||
message(STATUS "Excluding from source files list (optimization is disabled): ${fname}")
|
||||
#continue()
|
||||
else()
|
||||
get_source_file_property(__definitions "${fname}" COMPILE_DEFINITIONS)
|
||||
if(__definitions)
|
||||
list(APPEND __definitions "CV_CPU_DISPATCH_MODE=${OPT_}")
|
||||
else()
|
||||
set(__definitions "CV_CPU_DISPATCH_MODE=${OPT_}")
|
||||
endif()
|
||||
set_source_files_properties("${fname}" PROPERTIES COMPILE_DEFINITIONS "${__definitions}")
|
||||
|
||||
set(__opt_found 0)
|
||||
foreach(OPT ${CPU_BASELINE_FINAL})
|
||||
string(TOLOWER "${OPT}" OPT_LOWER)
|
||||
if(fname_LOWER MATCHES "\\.${OPT_LOWER}\\.cpp$")
|
||||
#message("${fname} BASELINE-${OPT}")
|
||||
set(__opt_found 1)
|
||||
list(APPEND __result "${fname}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
foreach(OPT ${CPU_DISPATCH_FINAL})
|
||||
foreach(OPT2 ${CPU_DISPATCH_${OPT}_FORCED})
|
||||
string(TOLOWER "${OPT2}" OPT2_LOWER)
|
||||
if(fname_LOWER MATCHES "\\.${OPT2_LOWER}\\.cpp$")
|
||||
list(APPEND __result_${OPT} "${fname}")
|
||||
math(EXPR CPU_${OPT}_USAGE_COUNT "${CPU_${OPT}_USAGE_COUNT}+1")
|
||||
set(CPU_${OPT}_USAGE_COUNT "${CPU_${OPT}_USAGE_COUNT}" CACHE INTERNAL "" FORCE)
|
||||
#message("(${CPU_${OPT}_USAGE_COUNT})${fname} ${OPT}")
|
||||
#message(" ${CPU_DISPATCH_${OPT}_INCLUDED}")
|
||||
#message(" ${CPU_DISPATCH_DEFINITIONS_${OPT}}")
|
||||
#message(" ${CPU_DISPATCH_FLAGS_${OPT}}")
|
||||
set(__opt_found 1)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(__opt_found)
|
||||
set(__opt_found 1)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if(NOT __opt_found)
|
||||
message(STATUS "Excluding from source files list: ${fname}")
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
list(APPEND __result "${fname}")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
foreach(OPT ${CPU_DISPATCH_FINAL})
|
||||
if(__result_${OPT})
|
||||
#message("${OPT}: ${__result_${OPT}}")
|
||||
if(CMAKE_GENERATOR MATCHES "^Visual")
|
||||
# extra flags are added before common flags, so switching between optimizations doesn't work correctly
|
||||
# Also CMAKE_CXX_FLAGS doesn't work (it is directory-based, so add_subdirectory is required)
|
||||
add_library(${TARGET_BASE_NAME}_${OPT} OBJECT ${__result_${OPT}})
|
||||
ocv_append_dependant_targets(${TARGET_BASE_NAME} ${TARGET_BASE_NAME}_${OPT})
|
||||
set_target_properties(${TARGET_BASE_NAME}_${OPT} PROPERTIES COMPILE_DEFINITIONS "${CPU_DISPATCH_DEFINITIONS_${OPT}}")
|
||||
set_target_properties(${TARGET_BASE_NAME}_${OPT} PROPERTIES COMPILE_FLAGS "${CPU_DISPATCH_FLAGS_${OPT}}")
|
||||
target_include_directories(${TARGET_BASE_NAME}_${OPT} PRIVATE $<TARGET_PROPERTY:${TARGET_BASE_NAME},INCLUDE_DIRECTORIES>)
|
||||
#list(APPEND __result_libs ${TARGET_BASE_NAME}_${OPT})
|
||||
list(APPEND __result "$<TARGET_OBJECTS:${TARGET_BASE_NAME}_${OPT}>")
|
||||
else()
|
||||
foreach(fname ${__result_${OPT}})
|
||||
get_source_file_property(__definitions "${fname}" COMPILE_DEFINITIONS)
|
||||
if(__definitions)
|
||||
list(APPEND __definitions "${CPU_DISPATCH_DEFINITIONS_${OPT}}")
|
||||
else()
|
||||
set(__definitions "${CPU_DISPATCH_DEFINITIONS_${OPT}}")
|
||||
endif()
|
||||
set_source_files_properties("${fname}" PROPERTIES COMPILE_DEFINITIONS "${__definitions}")
|
||||
set_source_files_properties("${fname}" PROPERTIES COMPILE_FLAGS "${CPU_DISPATCH_FLAGS_${OPT}}")
|
||||
endforeach()
|
||||
list(APPEND __result ${__result_${OPT}})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
set(${SOURCES_VAR_NAME} "${__result}")
|
||||
list(APPEND ${LIBS_VAR_NAME} ${__result_libs})
|
||||
endmacro()
|
||||
|
||||
macro(ocv_compiler_optimization_fill_cpu_config)
|
||||
set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "")
|
||||
foreach(OPT ${CPU_BASELINE_FINAL})
|
||||
set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}
|
||||
#define CV_CPU_COMPILE_${OPT} 1
|
||||
#define CV_CPU_BASELINE_COMPILE_${OPT} 1
|
||||
")
|
||||
endforeach()
|
||||
|
||||
set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}
|
||||
#define CV_CPU_BASELINE_FEATURES 0 \\")
|
||||
foreach(OPT ${CPU_BASELINE_FINAL})
|
||||
if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
|
||||
set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}
|
||||
, CV_CPU_${OPT} \\")
|
||||
endif()
|
||||
endforeach()
|
||||
set(OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE}\n")
|
||||
|
||||
set(__dispatch_modes "")
|
||||
foreach(OPT ${CPU_DISPATCH_FINAL})
|
||||
list(APPEND __dispatch_modes ${CPU_DISPATCH_${OPT}_FORCE} ${OPT})
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES __dispatch_modes)
|
||||
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "")
|
||||
foreach(OPT ${__dispatch_modes})
|
||||
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
|
||||
#define CV_CPU_DISPATCH_COMPILE_${OPT} 1")
|
||||
endforeach()
|
||||
|
||||
set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "// AUTOGENERATED, DO NOT EDIT\n")
|
||||
foreach(OPT ${CPU_ALL_OPTIMIZATIONS})
|
||||
if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
|
||||
set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE}
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_${OPT}
|
||||
# define CV_CPU_HAS_SUPPORT_${OPT} 1
|
||||
# define CV_CPU_CALL_${OPT}(fn, args) return (opt_${OPT}::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_${OPT}
|
||||
# define CV_CPU_HAS_SUPPORT_${OPT} (cv::checkHardwareSupport(CV_CPU_${OPT}))
|
||||
# define CV_CPU_CALL_${OPT}(fn, args) if (CV_CPU_HAS_SUPPORT_${OPT}) return (opt_${OPT}::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_${OPT} 0
|
||||
# define CV_CPU_CALL_${OPT}(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_${OPT}(fn, args, mode, ...) CV_CPU_CALL_${OPT}(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE}
|
||||
#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
|
||||
#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
|
||||
")
|
||||
|
||||
|
||||
set(__file "${CMAKE_SOURCE_DIR}/modules/core/include/opencv2/core/cv_cpu_helper.h")
|
||||
if(EXISTS "${__file}")
|
||||
file(READ "${__file}" __content)
|
||||
endif()
|
||||
if(__content STREQUAL OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE)
|
||||
#message(STATUS "${__file} contains same content")
|
||||
else()
|
||||
file(WRITE "${__file}" "${OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE}")
|
||||
message(WARNING "${__file} is updated")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(ocv_add_dispatched_file filename)
|
||||
if(NOT OPENCV_INITIAL_PASS)
|
||||
set(__codestr "
|
||||
#include \"precomp.hpp\"
|
||||
#include \"${filename}.simd.hpp\"
|
||||
")
|
||||
|
||||
set(__declarations_str "#define CV_CPU_SIMD_FILENAME \"${filename}.simd.hpp\"")
|
||||
set(__dispatch_modes "BASELINE")
|
||||
|
||||
set(__optimizations "${ARGN}")
|
||||
if(CV_DISABLE_OPTIMIZATION OR NOT CV_ENABLE_INTRINSICS)
|
||||
set(__optimizations "")
|
||||
endif()
|
||||
|
||||
foreach(OPT ${__optimizations})
|
||||
string(TOLOWER "${OPT}" OPT_LOWER)
|
||||
set(__file "${CMAKE_CURRENT_BINARY_DIR}/${filename}.${OPT_LOWER}.cpp")
|
||||
if(EXISTS "${__file}")
|
||||
file(READ "${__file}" __content)
|
||||
endif()
|
||||
if(__content STREQUAL __codestr)
|
||||
#message(STATUS "${__file} contains up-to-date content")
|
||||
else()
|
||||
file(WRITE "${__file}" "${__codestr}")
|
||||
endif()
|
||||
list(APPEND OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED "${__file}")
|
||||
|
||||
set(__declarations_str "${__declarations_str}
|
||||
#define CV_CPU_DISPATCH_MODE ${OPT}
|
||||
#include \"opencv2/core/private/cv_cpu_include_simd_declarations.hpp\"
|
||||
")
|
||||
set(__dispatch_modes "${OPT}, ${__dispatch_modes}")
|
||||
endforeach()
|
||||
|
||||
set(__declarations_str "${__declarations_str}
|
||||
#define CV_CPU_DISPATCH_MODES_ALL ${__dispatch_modes}
|
||||
")
|
||||
|
||||
set(__file "${CMAKE_CURRENT_BINARY_DIR}/${filename}.simd_declarations.hpp")
|
||||
if(EXISTS "${__file}")
|
||||
file(READ "${__file}" __content)
|
||||
endif()
|
||||
if(__content STREQUAL __declarations_str)
|
||||
#message(STATUS "${__file} contains up-to-date content")
|
||||
else()
|
||||
file(WRITE "${__file}" "${__declarations_str}")
|
||||
endif()
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if(CV_DISABLE_OPTIMIZATION OR CV_ICC)
|
||||
ocv_update(CV_ENABLE_UNROLLED 0)
|
||||
else()
|
||||
ocv_update(CV_ENABLE_UNROLLED 1)
|
||||
endif()
|
||||
@@ -31,24 +31,21 @@ endif()
|
||||
if(MINGW OR (X86 AND UNIX AND NOT APPLE))
|
||||
# mingw compiler is known to produce unstable SSE code with -O3 hence we are trying to use -O2 instead
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
foreach(flags CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
|
||||
string(REPLACE "-O3" "-O2" ${flags} "${${flags}}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCC)
|
||||
foreach(flags CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
|
||||
foreach(flags
|
||||
CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG
|
||||
CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_DEBUG)
|
||||
string(REPLACE "-O3" "-O2" ${flags} "${${flags}}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
string(REGEX REPLACE "^ *| * $" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REGEX REPLACE "^ *| * $" "" CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT}")
|
||||
string(STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
|
||||
string(STRIP "${CMAKE_CXX_FLAGS_INIT}" CMAKE_CXX_FLAGS_INIT)
|
||||
if(CMAKE_CXX_FLAGS STREQUAL CMAKE_CXX_FLAGS_INIT)
|
||||
# override cmake default exception handling option
|
||||
string(REPLACE "/EHsc" "/EHa" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHa")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" CACHE STRING "Flags used by the compiler during all build types." FORCE)
|
||||
endif()
|
||||
endif()
|
||||
@@ -63,9 +60,6 @@ set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "")
|
||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "")
|
||||
|
||||
macro(add_extra_compiler_option option)
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
ocv_check_flag_support(CXX "${option}" _varname "${OPENCV_EXTRA_CXX_FLAGS} ${ARGN}")
|
||||
if(${_varname})
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} ${option}")
|
||||
@@ -77,6 +71,12 @@ macro(add_extra_compiler_option option)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
macro(add_extra_compiler_option_force option)
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} ${option}")
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} ${option}")
|
||||
endmacro()
|
||||
|
||||
|
||||
# Gets environment variable and puts its value to the corresponding preprocessor definition
|
||||
# Useful for WINRT that has no access to environment variables
|
||||
macro(add_env_definitions option)
|
||||
@@ -102,7 +102,11 @@ if(MINGW)
|
||||
endif()
|
||||
|
||||
if(CV_ICC AND NOT ENABLE_FAST_MATH)
|
||||
add_extra_compiler_option("-fp-model precise")
|
||||
if(MSVC)
|
||||
add_extra_compiler_option("/fp:precise")
|
||||
else()
|
||||
add_extra_compiler_option("-fp-model precise")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
@@ -141,7 +145,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif()
|
||||
|
||||
# We need pthread's
|
||||
if(UNIX AND NOT ANDROID AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX))
|
||||
if(UNIX AND NOT ANDROID AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX)) # TODO
|
||||
add_extra_compiler_option(-pthread)
|
||||
endif()
|
||||
|
||||
@@ -170,83 +174,6 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(ENABLE_FAST_MATH)
|
||||
add_extra_compiler_option(-ffast-math)
|
||||
endif()
|
||||
if(ENABLE_POWERPC)
|
||||
add_extra_compiler_option("-mcpu=G3 -mtune=G5")
|
||||
endif()
|
||||
if(ENABLE_SSE)
|
||||
add_extra_compiler_option(-msse)
|
||||
endif()
|
||||
if(ENABLE_SSE2)
|
||||
add_extra_compiler_option(-msse2)
|
||||
elseif(X86 OR X86_64)
|
||||
add_extra_compiler_option(-mno-sse2)
|
||||
endif()
|
||||
if(ARM)
|
||||
add_extra_compiler_option("-mfp16-format=ieee")
|
||||
endif(ARM)
|
||||
if(ENABLE_NEON)
|
||||
add_extra_compiler_option("-mfpu=neon")
|
||||
endif()
|
||||
if(ENABLE_VFPV3 AND NOT ENABLE_NEON)
|
||||
add_extra_compiler_option("-mfpu=vfpv3")
|
||||
endif()
|
||||
|
||||
# SSE3 and further should be disabled under MingW because it generates compiler errors
|
||||
if(NOT MINGW)
|
||||
if(ENABLE_AVX)
|
||||
add_extra_compiler_option(-mavx)
|
||||
elseif(X86 OR X86_64)
|
||||
add_extra_compiler_option(-mno-avx)
|
||||
endif()
|
||||
if(ENABLE_AVX2)
|
||||
add_extra_compiler_option(-mavx2)
|
||||
|
||||
if(ENABLE_FMA3)
|
||||
add_extra_compiler_option(-mfma)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# GCC depresses SSEx instructions when -mavx is used. Instead, it generates new AVX instructions or AVX equivalence for all SSEx instructions when needed.
|
||||
if(NOT OPENCV_EXTRA_CXX_FLAGS MATCHES "-mavx")
|
||||
if(ENABLE_SSE3)
|
||||
add_extra_compiler_option(-msse3)
|
||||
elseif(X86 OR X86_64)
|
||||
add_extra_compiler_option(-mno-sse3)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSSE3)
|
||||
add_extra_compiler_option(-mssse3)
|
||||
elseif(X86 OR X86_64)
|
||||
add_extra_compiler_option(-mno-ssse3)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE41)
|
||||
add_extra_compiler_option(-msse4.1)
|
||||
elseif(X86 OR X86_64)
|
||||
add_extra_compiler_option(-mno-sse4.1)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE42)
|
||||
add_extra_compiler_option(-msse4.2)
|
||||
elseif(X86 OR X86_64)
|
||||
add_extra_compiler_option(-mno-sse4.2)
|
||||
endif()
|
||||
|
||||
if(ENABLE_POPCNT)
|
||||
add_extra_compiler_option(-mpopcnt)
|
||||
endif()
|
||||
endif()
|
||||
endif(NOT MINGW)
|
||||
|
||||
if(X86 OR X86_64)
|
||||
if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
if(OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)")
|
||||
add_extra_compiler_option(-mfpmath=sse)# !! important - be on the same wave with x64 compilers
|
||||
else()
|
||||
add_extra_compiler_option(-mfpmath=387)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Profiling?
|
||||
if(ENABLE_PROFILING)
|
||||
@@ -257,7 +184,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
string(REPLACE "-fomit-frame-pointer" "" ${flags} "${${flags}}")
|
||||
string(REPLACE "-ffunction-sections" "" ${flags} "${${flags}}")
|
||||
endforeach()
|
||||
elseif(NOT APPLE AND NOT ANDROID)
|
||||
elseif(NOT ((IOS OR ANDROID) AND NOT BUILD_SHARED_LIBS))
|
||||
# Remove unreferenced functions: function level linking
|
||||
add_extra_compiler_option(-ffunction-sections)
|
||||
endif()
|
||||
@@ -265,6 +192,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(ENABLE_COVERAGE)
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} --coverage")
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} --coverage")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage")
|
||||
endif()
|
||||
|
||||
if(ENABLE_INSTRUMENTATION)
|
||||
@@ -296,41 +224,6 @@ if(MSVC)
|
||||
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi")
|
||||
endif()
|
||||
|
||||
if(ENABLE_AVX2 AND NOT MSVC_VERSION LESS 1800)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX2")
|
||||
endif()
|
||||
if(ENABLE_AVX AND NOT MSVC_VERSION LESS 1600 AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE3 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3")
|
||||
endif()
|
||||
|
||||
if(NOT MSVC64)
|
||||
# 64-bit MSVC compiler uses SSE/SSE2 by default
|
||||
if(ENABLE_SSE2 AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2")
|
||||
endif()
|
||||
if(ENABLE_SSE AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX OR ENABLE_AVX2)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
|
||||
endif()
|
||||
|
||||
if(X86 OR X86_64)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND ENABLE_SSE2)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast") # !! important - be on the same wave with x64 compilers
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OPENCV_WARNINGS_ARE_ERRORS)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /WX")
|
||||
endif()
|
||||
@@ -353,6 +246,16 @@ if(NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX AND NOT ANDROID)
|
||||
set(OPENCV_EXTRA_FLAGS "-fPIC ${OPENCV_EXTRA_FLAGS}")
|
||||
endif()
|
||||
|
||||
include(cmake/OpenCVCompilerOptimizations.cmake)
|
||||
|
||||
if(COMMAND ocv_compiler_optimization_options)
|
||||
ocv_compiler_optimization_options()
|
||||
endif()
|
||||
|
||||
if(COMMAND ocv_compiler_optimization_options_finalize)
|
||||
ocv_compiler_optimization_options_finalize()
|
||||
endif()
|
||||
|
||||
# Add user supplied extra options (optimization, etc...)
|
||||
# ==========================================================
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options")
|
||||
@@ -370,34 +273,6 @@ if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_OPENCV_GCC_VERSION_NUM GREATER 399)
|
||||
add_extra_compiler_option(-fvisibility-inlines-hidden)
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_FP16_DISABLE AND NOT IOS)
|
||||
if(ARM AND ENABLE_NEON)
|
||||
set(FP16_OPTION "-mfpu=neon-fp16")
|
||||
elseif((X86 OR X86_64) AND NOT MSVC AND ENABLE_AVX)
|
||||
set(FP16_OPTION "-mf16c")
|
||||
endif()
|
||||
try_compile(__VALID_FP16
|
||||
"${OpenCV_BINARY_DIR}"
|
||||
"${OpenCV_SOURCE_DIR}/cmake/checks/fp16.cpp"
|
||||
COMPILE_DEFINITIONS "-DCHECK_FP16" "${FP16_OPTION}"
|
||||
OUTPUT_VARIABLE TRY_OUT
|
||||
)
|
||||
if(NOT __VALID_FP16)
|
||||
if((X86 OR X86_64) AND NOT MSVC AND NOT ENABLE_AVX)
|
||||
# GCC enables AVX when mf16c is passed
|
||||
message(STATUS "FP16: Feature disabled")
|
||||
else()
|
||||
message(STATUS "FP16: Compiler support is not available")
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "FP16: Compiler support is available")
|
||||
set(HAVE_FP16 1)
|
||||
if(NOT ${FP16_OPTION} STREQUAL "")
|
||||
add_extra_compiler_option(${FP16_OPTION})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#combine all "extra" options
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}")
|
||||
|
||||
@@ -88,7 +88,17 @@ if(CUDA_FOUND)
|
||||
set(__cuda_arch_bin "3.2")
|
||||
set(__cuda_arch_ptx "")
|
||||
elseif(AARCH64)
|
||||
set(__cuda_arch_bin "5.3")
|
||||
execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" "${OpenCV_SOURCE_DIR}/cmake/checks/OpenCVDetectCudaArch.cu" "--run"
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
|
||||
RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT _nvcc_res EQUAL 0)
|
||||
message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.")
|
||||
set(__cuda_arch_bin "5.3 6.2")
|
||||
else()
|
||||
set(__cuda_arch_bin "${_nvcc_out}")
|
||||
string(REPLACE "2.1" "2.1(2.0)" __cuda_arch_bin "${__cuda_arch_bin}")
|
||||
endif()
|
||||
set(__cuda_arch_ptx "")
|
||||
else()
|
||||
if(${CUDA_VERSION} VERSION_LESS "8.0")
|
||||
@@ -96,7 +106,6 @@ if(CUDA_FOUND)
|
||||
else()
|
||||
set(__cuda_arch_bin "2.0 3.0 3.5 3.7 5.0 5.2 6.0 6.1")
|
||||
endif()
|
||||
set(__cuda_arch_ptx "")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -68,7 +68,9 @@ endfunction()
|
||||
|
||||
if(BUILD_TBB)
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/tbb")
|
||||
message(STATUS "Found TBB: build")
|
||||
if(NOT TARGET tbb)
|
||||
return()
|
||||
endif()
|
||||
set(HAVE_TBB TRUE)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -0,0 +1,216 @@
|
||||
#
|
||||
# Download and optionally unpack a file
|
||||
#
|
||||
# ocv_download(FILENAME p HASH h URL u1 [u2 ...] DESTINATION_DIR d [ID id] [STATUS s] [UNPACK] [RELATIVE_URL])
|
||||
# FILENAME - filename
|
||||
# HASH - MD5 hash
|
||||
# URL - full download url (first nonempty value will be chosen)
|
||||
# DESTINATION_DIR - file will be copied to this directory
|
||||
# ID - identifier for project/group of downloaded files
|
||||
# STATUS - passed variable will be updated in parent scope,
|
||||
# function will not fail the build in case of download problem if this option is provided,
|
||||
# but will fail in case when other operations (copy, remove, etc.) failed
|
||||
# UNPACK - downloaded file will be unpacked to DESTINATION_DIR
|
||||
# RELATIVE_URL - if set, then URL is treated as a base, and FILENAME will be appended to it
|
||||
# Note: uses OPENCV_DOWNLOAD_PATH folder as cache, default is <opencv>/.cache
|
||||
|
||||
set(HELP_OPENCV_DOWNLOAD_PATH "Cache directory for downloaded files")
|
||||
if(DEFINED ENV{OPENCV_DOWNLOAD_PATH})
|
||||
set(OPENCV_DOWNLOAD_PATH "$ENV{OPENCV_DOWNLOAD_PATH}" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}")
|
||||
endif()
|
||||
set(OPENCV_DOWNLOAD_PATH "${OpenCV_SOURCE_DIR}/.cache" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}")
|
||||
set(OPENCV_DOWNLOAD_LOG "${OpenCV_BINARY_DIR}/CMakeDownloadLog.txt")
|
||||
|
||||
# Init download cache directory and log file
|
||||
if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}")
|
||||
file(MAKE_DIRECTORY ${OPENCV_DOWNLOAD_PATH})
|
||||
endif()
|
||||
if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}/.gitignore")
|
||||
file(WRITE "${OPENCV_DOWNLOAD_PATH}/.gitignore" "*\n")
|
||||
endif()
|
||||
file(WRITE "${OPENCV_DOWNLOAD_LOG}" "use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
|
||||
|
||||
|
||||
function(ocv_download)
|
||||
cmake_parse_arguments(DL "UNPACK;RELATIVE_URL" "FILENAME;HASH;DESTINATION_DIR;ID;STATUS" "URL" ${ARGN})
|
||||
|
||||
macro(ocv_download_log)
|
||||
file(APPEND "${OPENCV_DOWNLOAD_LOG}" "${ARGN}\n")
|
||||
endmacro()
|
||||
|
||||
ocv_assert(DL_FILENAME)
|
||||
ocv_assert(DL_HASH)
|
||||
ocv_assert(DL_URL)
|
||||
ocv_assert(DL_DESTINATION_DIR)
|
||||
if((NOT " ${DL_UNPARSED_ARGUMENTS}" STREQUAL " ")
|
||||
OR DL_FILENAME STREQUAL ""
|
||||
OR DL_HASH STREQUAL ""
|
||||
OR DL_URL STREQUAL ""
|
||||
OR DL_DESTINATION_DIR STREQUAL ""
|
||||
)
|
||||
set(msg_level FATAL_ERROR)
|
||||
if(DEFINED DL_STATUS)
|
||||
set(${DL_STATUS} FALSE PARENT_SCOPE)
|
||||
set(msg_level WARNING)
|
||||
endif()
|
||||
message(${msg_level} "ERROR: ocv_download() unsupported arguments: ${ARGV}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(DEFINED DL_STATUS)
|
||||
set(${DL_STATUS} TRUE PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
# Check CMake cache for already processed tasks
|
||||
string(FIND "${DL_DESTINATION_DIR}" "${CMAKE_BINARY_DIR}" DL_BINARY_PATH_POS)
|
||||
if(DL_BINARY_PATH_POS EQUAL 0)
|
||||
set(__file_id "${DL_DESTINATION_DIR}/${DL_FILENAME}")
|
||||
file(RELATIVE_PATH __file_id "${CMAKE_BINARY_DIR}" "${__file_id}")
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" __file_id "${__file_id}")
|
||||
if(DL_ID)
|
||||
string(TOUPPER ${DL_ID} __id)
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9_]" "_" __id "${__id}")
|
||||
set(OCV_DOWNLOAD_HASH_NAME "OCV_DOWNLOAD_${__id}_HASH_${__file_id}")
|
||||
else()
|
||||
set(OCV_DOWNLOAD_HASH_NAME "OCV_DOWNLOAD_HASH_${__file_id}")
|
||||
endif()
|
||||
if(" ${${OCV_DOWNLOAD_HASH_NAME}}" STREQUAL " ${DL_HASH}")
|
||||
ocv_download_log("#match_hash_in_cmake_cache \"${OCV_DOWNLOAD_HASH_NAME}\"")
|
||||
return()
|
||||
endif()
|
||||
unset("${OCV_DOWNLOAD_HASH_NAME}" CACHE)
|
||||
else()
|
||||
set(OCV_DOWNLOAD_HASH_NAME "")
|
||||
#message(WARNING "Download destination is not in CMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}: ${DL_DESTINATION_DIR}")
|
||||
endif()
|
||||
|
||||
# Select first non-empty url
|
||||
foreach(url ${DL_URL})
|
||||
if(url)
|
||||
set(DL_URL "${url}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
# Append filename to url if needed
|
||||
if(DL_RELATIVE_URL)
|
||||
set(DL_URL "${DL_URL}${DL_FILENAME}")
|
||||
endif()
|
||||
|
||||
set(mode "copy")
|
||||
if(DL_UNPACK)
|
||||
set(mode "unpack")
|
||||
endif()
|
||||
|
||||
# Log all calls to file
|
||||
ocv_download_log("do_${mode} \"${DL_FILENAME}\" \"${DL_HASH}\" \"${DL_URL}\" \"${DL_DESTINATION_DIR}\"")
|
||||
# ... and to console
|
||||
set(__msg_prefix "")
|
||||
if(DL_ID)
|
||||
set(__msg_prefix "${DL_ID}: ")
|
||||
endif()
|
||||
message(STATUS "${__msg_prefix}Download: ${DL_FILENAME}")
|
||||
|
||||
# Copy mode: check if copy destination exists and is correct
|
||||
if(NOT DL_UNPACK)
|
||||
set(COPY_DESTINATION "${DL_DESTINATION_DIR}/${DL_FILENAME}")
|
||||
if(EXISTS "${COPY_DESTINATION}")
|
||||
ocv_download_log("#check_md5 \"${COPY_DESTINATION}\"")
|
||||
file(MD5 "${COPY_DESTINATION}" target_md5)
|
||||
if(target_md5 STREQUAL DL_HASH)
|
||||
ocv_download_log("#match_md5 \"${COPY_DESTINATION}\" \"${target_md5}\"")
|
||||
if(OCV_DOWNLOAD_HASH_NAME)
|
||||
set(${OCV_DOWNLOAD_HASH_NAME} "${DL_HASH}" CACHE INTERNAL "")
|
||||
endif()
|
||||
return()
|
||||
endif()
|
||||
ocv_download_log("#mismatch_md5 \"${COPY_DESTINATION}\" \"${target_md5}\"")
|
||||
else()
|
||||
ocv_download_log("#missing \"${COPY_DESTINATION}\"")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Check cache first
|
||||
if(DL_ID)
|
||||
string(TOLOWER "${DL_ID}" __id)
|
||||
string(REGEX REPLACE "[^a-zA-Z0-9_/ ]" "_" __id "${__id}")
|
||||
set(CACHE_CANDIDATE "${OPENCV_DOWNLOAD_PATH}/${__id}/${DL_HASH}-${DL_FILENAME}")
|
||||
else()
|
||||
set(CACHE_CANDIDATE "${OPENCV_DOWNLOAD_PATH}/${DL_HASH}-${DL_FILENAME}")
|
||||
endif()
|
||||
if(EXISTS "${CACHE_CANDIDATE}")
|
||||
ocv_download_log("#check_md5 \"${CACHE_CANDIDATE}\"")
|
||||
file(MD5 "${CACHE_CANDIDATE}" target_md5)
|
||||
if(NOT target_md5 STREQUAL DL_HASH)
|
||||
ocv_download_log("#mismatch_md5 \"${CACHE_CANDIDATE}\" \"${target_md5}\"")
|
||||
ocv_download_log("#delete \"${CACHE_CANDIDATE}\"")
|
||||
file(REMOVE ${CACHE_CANDIDATE})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Download
|
||||
if(NOT EXISTS "${CACHE_CANDIDATE}")
|
||||
ocv_download_log("#cmake_download \"${CACHE_CANDIDATE}\" \"${DL_URL}\"")
|
||||
file(DOWNLOAD "${DL_URL}" "${CACHE_CANDIDATE}"
|
||||
INACTIVITY_TIMEOUT 60
|
||||
TIMEOUT 600
|
||||
STATUS status
|
||||
LOG __log)
|
||||
string(LENGTH "${__log}" __log_length)
|
||||
if(__log_length LESS 65536)
|
||||
string(REPLACE "\n" "\n# " __log "${__log}")
|
||||
ocv_download_log("# ${__log}\n")
|
||||
endif()
|
||||
if(NOT status EQUAL 0)
|
||||
set(msg_level FATAL_ERROR)
|
||||
if(DEFINED DL_STATUS)
|
||||
set(${DL_STATUS} FALSE PARENT_SCOPE)
|
||||
set(msg_level WARNING)
|
||||
endif()
|
||||
message(${msg_level} "${__msg_prefix}Download failed: ${status}")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step on wrong hash
|
||||
ocv_download_log("#check_md5 \"${CACHE_CANDIDATE}\"")
|
||||
file(MD5 "${CACHE_CANDIDATE}" target_md5)
|
||||
if(NOT target_md5 STREQUAL DL_HASH)
|
||||
ocv_download_log("#mismatch_md5 \"${CACHE_CANDIDATE}\" \"${target_md5}\"")
|
||||
set(msg_level FATAL_ERROR)
|
||||
if(DEFINED DL_STATUS)
|
||||
set(${DL_STATUS} FALSE PARENT_SCOPE)
|
||||
set(msg_level WARNING)
|
||||
endif()
|
||||
message(${msg_level} "${__msg_prefix}Hash mismatch: ${target_md5}")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Unpack or copy
|
||||
if(DL_UNPACK)
|
||||
if(EXISTS "${DL_DESTINATION_DIR}")
|
||||
ocv_download_log("#remove_unpack \"${DL_DESTINATION_DIR}\"")
|
||||
file(REMOVE_RECURSE "${DL_DESTINATION_DIR}")
|
||||
endif()
|
||||
ocv_download_log("#mkdir \"${DL_DESTINATION_DIR}\"")
|
||||
file(MAKE_DIRECTORY "${DL_DESTINATION_DIR}")
|
||||
ocv_download_log("#unpack \"${DL_DESTINATION_DIR}\" \"${CACHE_CANDIDATE}\"")
|
||||
execute_process(COMMAND "${CMAKE_COMMAND}" -E tar xz "${CACHE_CANDIDATE}"
|
||||
WORKING_DIRECTORY "${DL_DESTINATION_DIR}"
|
||||
RESULT_VARIABLE res)
|
||||
if(NOT res EQUAL 0)
|
||||
message(FATAL_ERROR "${__msg_prefix}Unpack failed: ${res}")
|
||||
endif()
|
||||
else()
|
||||
ocv_download_log("#copy \"${COPY_DESTINATION}\" \"${CACHE_CANDIDATE}\"")
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CACHE_CANDIDATE}" "${COPY_DESTINATION}"
|
||||
RESULT_VARIABLE res)
|
||||
if(NOT res EQUAL 0)
|
||||
message(FATAL_ERROR "${__msg_prefix}Copy failed: ${res}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OCV_DOWNLOAD_HASH_NAME)
|
||||
set(${OCV_DOWNLOAD_HASH_NAME} "${DL_HASH}" CACHE INTERNAL "")
|
||||
endif()
|
||||
endfunction()
|
||||
+30
-32
@@ -35,7 +35,7 @@ unset(IPP_VERSION_MINOR)
|
||||
unset(IPP_VERSION_BUILD)
|
||||
|
||||
if (X86 AND UNIX AND NOT APPLE AND NOT ANDROID AND BUILD_SHARED_LIBS)
|
||||
message(STATUS "On 32-bit Linux IPP can not currently be used with dynamic libs because of linker errors. Set BUILD_SHARED_LIBS=OFF")
|
||||
message(STATUS "On 32-bit Linux Intel IPP can not currently be used with dynamic libs because of linker errors. Set BUILD_SHARED_LIBS=OFF")
|
||||
return()
|
||||
endif()
|
||||
|
||||
@@ -47,14 +47,14 @@ if(CMAKE_CL_64)
|
||||
set(IPP_X64 1)
|
||||
endif()
|
||||
|
||||
# This function detects IPP version by analyzing .h file
|
||||
# This function detects Intel IPP version by analyzing .h file
|
||||
macro(ipp_get_version VERSION_FILE)
|
||||
unset(_VERSION_STR)
|
||||
unset(_MAJOR)
|
||||
unset(_MINOR)
|
||||
unset(_BUILD)
|
||||
|
||||
# read IPP version info from file
|
||||
# read Intel IPP version info from file
|
||||
file(STRINGS ${VERSION_FILE} STR1 REGEX "IPP_VERSION_MAJOR")
|
||||
file(STRINGS ${VERSION_FILE} STR2 REGEX "IPP_VERSION_MINOR")
|
||||
file(STRINGS ${VERSION_FILE} STR3 REGEX "IPP_VERSION_BUILD")
|
||||
@@ -96,29 +96,29 @@ macro(ipp_detect_version)
|
||||
elseif(EXISTS ${IPP_ROOT_DIR}/include/ipp.h)
|
||||
# nothing
|
||||
else()
|
||||
_ipp_not_supported("Can't resolve IPP directory: ${IPP_ROOT_DIR}")
|
||||
_ipp_not_supported("Can't resolve Intel IPP directory: ${IPP_ROOT_DIR}")
|
||||
endif()
|
||||
|
||||
ipp_get_version(${IPP_INCLUDE_DIRS}/ippversion.h)
|
||||
ocv_assert(IPP_VERSION_STR VERSION_GREATER "1.0")
|
||||
|
||||
message(STATUS "found IPP${__msg}: ${_MAJOR}.${_MINOR}.${_BUILD} [${IPP_VERSION_STR}]")
|
||||
message(STATUS "found Intel IPP${__msg}: ${_MAJOR}.${_MINOR}.${_BUILD} [${IPP_VERSION_STR}]")
|
||||
message(STATUS "at: ${IPP_ROOT_DIR}")
|
||||
|
||||
if(${IPP_VERSION_STR} VERSION_LESS "7.0")
|
||||
_ipp_not_supported("IPP ${IPP_VERSION_STR} is not supported")
|
||||
_ipp_not_supported("Intel IPP ${IPP_VERSION_STR} is not supported")
|
||||
endif()
|
||||
|
||||
set(HAVE_IPP 1)
|
||||
|
||||
macro(_ipp_set_library_dir DIR)
|
||||
if(NOT EXISTS ${DIR})
|
||||
_ipp_not_supported("IPP library directory not found")
|
||||
_ipp_not_supported("Intel IPP library directory not found")
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIR ${DIR})
|
||||
endmacro()
|
||||
|
||||
if(APPLE)
|
||||
if(APPLE AND NOT HAVE_IPP_ICV_ONLY)
|
||||
_ipp_set_library_dir(${IPP_ROOT_DIR}/lib)
|
||||
elseif(IPP_X64)
|
||||
_ipp_set_library_dir(${IPP_ROOT_DIR}/lib/intel64)
|
||||
@@ -127,17 +127,22 @@ macro(ipp_detect_version)
|
||||
endif()
|
||||
|
||||
macro(_ipp_add_library name)
|
||||
# dynamic linking is only supported for standalone version of IPP
|
||||
# dynamic linking is only supported for standalone version of Intel IPP
|
||||
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
|
||||
set(IPP_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
|
||||
set(IPP_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
if (WIN32)
|
||||
set(IPP_LIB_PREFIX ${CMAKE_IMPORT_LIBRARY_PREFIX})
|
||||
set(IPP_LIB_SUFFIX ${CMAKE_IMPORT_LIBRARY_SUFFIX})
|
||||
else (WIN32)
|
||||
set(IPP_LIB_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
|
||||
set(IPP_LIB_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
endif (WIN32)
|
||||
else ()
|
||||
set(IPP_LIB_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
|
||||
set(IPP_LIB_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
|
||||
endif ()
|
||||
if (EXISTS ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX})
|
||||
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
|
||||
# When using dynamic libraries from standalone IPP it is your responsibility to install those on the target system
|
||||
# When using dynamic libraries from standalone Intel IPP it is your responsibility to install those on the target system
|
||||
list(APPEND IPP_LIBRARIES ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX})
|
||||
else ()
|
||||
add_library(ipp${name} STATIC IMPORTED)
|
||||
@@ -156,33 +161,32 @@ macro(ipp_detect_version)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
message(STATUS "Can't find IPP library: ${name} at ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}")
|
||||
message(STATUS "Can't find Intel IPP library: ${name} at ${IPP_LIBRARY_DIR}/${IPP_LIB_PREFIX}${IPP_PREFIX}${name}${IPP_SUFFIX}${IPP_LIB_SUFFIX}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
set(IPP_PREFIX "ipp")
|
||||
if(${IPP_VERSION_STR} VERSION_LESS "8.0")
|
||||
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
|
||||
set(IPP_SUFFIX "") # dynamic not threaded libs suffix IPP 7.x
|
||||
set(IPP_SUFFIX "") # dynamic not threaded libs suffix Intel IPP 7.x
|
||||
else ()
|
||||
set(IPP_SUFFIX "_l") # static not threaded libs suffix IPP 7.x
|
||||
set(IPP_SUFFIX "_l") # static not threaded libs suffix Intel IPP 7.x
|
||||
endif ()
|
||||
else ()
|
||||
if(WIN32)
|
||||
if (BUILD_WITH_DYNAMIC_IPP AND NOT HAVE_IPP_ICV_ONLY)
|
||||
set(IPP_SUFFIX "") # dynamic not threaded libs suffix IPP 8.x for Windows
|
||||
set(IPP_SUFFIX "") # dynamic not threaded libs suffix Intel IPP 8.x for Windows
|
||||
else ()
|
||||
set(IPP_SUFFIX "mt") # static not threaded libs suffix IPP 8.x for Windows
|
||||
set(IPP_SUFFIX "mt") # static not threaded libs suffix Intel IPP 8.x for Windows
|
||||
endif ()
|
||||
else()
|
||||
set(IPP_SUFFIX "") # static not threaded libs suffix IPP 8.x for Linux/OS X
|
||||
set(IPP_SUFFIX "") # static not threaded libs suffix Intel IPP 8.x for Linux/OS X
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_IPP_ICV_ONLY)
|
||||
_ipp_add_library(icv)
|
||||
else()
|
||||
_ipp_add_library(m)
|
||||
_ipp_add_library(cv)
|
||||
_ipp_add_library(i)
|
||||
_ipp_add_library(cc)
|
||||
@@ -196,7 +200,7 @@ macro(ipp_detect_version)
|
||||
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../compiler/lib REALPATH)
|
||||
endif()
|
||||
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR})
|
||||
_ipp_not_supported("IPP configuration error: can't find Intel compiler library dir ${INTEL_COMPILER_LIBRARY_DIR}")
|
||||
_ipp_not_supported("Intel IPP configuration error: can't find Intel compiler library dir ${INTEL_COMPILER_LIBRARY_DIR}")
|
||||
endif()
|
||||
if(NOT APPLE)
|
||||
if(IPP_X64)
|
||||
@@ -226,24 +230,18 @@ macro(ipp_detect_version)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#message(STATUS "IPP libs: ${IPP_LIBRARIES}")
|
||||
#message(STATUS "Intel IPP libs: ${IPP_LIBRARIES}")
|
||||
endmacro()
|
||||
|
||||
# OPENCV_IPP_PATH is an environment variable for internal usage only, do not use it
|
||||
if(DEFINED ENV{OPENCV_IPP_PATH} AND NOT DEFINED IPPROOT)
|
||||
set(IPPROOT "$ENV{OPENCV_IPP_PATH}")
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED IPPROOT)
|
||||
if(IOS AND NOT x86_64)
|
||||
# 2016/10: There is an issue with MacOS binary .a file.
|
||||
# It is fat multiarch library, and can't be "merged" multiple times.
|
||||
# So try to ignore i386 version
|
||||
return()
|
||||
endif()
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/downloader.cmake")
|
||||
if(DEFINED OPENCV_ICV_PATH)
|
||||
set(IPPROOT "${OPENCV_ICV_PATH}")
|
||||
else()
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/ippicv.cmake")
|
||||
download_ippicv(IPPROOT)
|
||||
if(NOT IPPROOT)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
@@ -256,7 +254,7 @@ endif()
|
||||
|
||||
|
||||
if(WIN32 AND MINGW AND NOT IPP_VERSION_MAJOR LESS 7)
|
||||
# Since IPP built with Microsoft compiler and /GS option
|
||||
# Since Intel IPP built with Microsoft compiler and /GS option
|
||||
# ======================================================
|
||||
# From Windows SDK 7.1
|
||||
# (usually in "C:\Program Files\Microsoft Visual Studio 10.0\VC\lib"),
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
#
|
||||
# The script to detect Intel(R) Integrated Performance Primitives Integration Wrappers (IPP IW)
|
||||
# installation/package
|
||||
#
|
||||
#
|
||||
# On return this will define:
|
||||
#
|
||||
# HAVE_IPP_IW - True if Intel IPP found
|
||||
# IPP_IW_PATH - Root of Intel IPP IW directory
|
||||
# IPP_IW_LIBRARIES - Intel IPP IW libraries
|
||||
# IPP_IW_INCLUDES - Intel IPP IW include folder
|
||||
#
|
||||
|
||||
unset(HAVE_IPP_IW CACHE)
|
||||
unset(IPP_IW_PATH)
|
||||
unset(IPP_IW_LIBRARIES)
|
||||
unset(IPP_IW_INCLUDES)
|
||||
unset(IW_CONFIG_DEBUG)
|
||||
#set(IW_CONFIG_DEBUG 1)
|
||||
|
||||
if(NOT HAVE_IPP)
|
||||
return()
|
||||
endif()
|
||||
|
||||
macro(ippiw_debugmsg MESSAGE)
|
||||
if(DEFINED IW_CONFIG_DEBUG)
|
||||
message(STATUS "${MESSAGE}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# This function detects Intel IPP IW version by analyzing .h file
|
||||
macro(ippiw_setup PATH BUILD)
|
||||
set(FILE "${PATH}/include/iw/iw_version.h")
|
||||
ippiw_debugmsg("Checking path: ${PATH}")
|
||||
if(EXISTS "${FILE}")
|
||||
ippiw_debugmsg("vfile\tok")
|
||||
file(STRINGS "${FILE}" IW_VERSION_MAJOR REGEX "IW_VERSION_MAJOR")
|
||||
file(STRINGS "${FILE}" IW_VERSION_MINOR REGEX "IW_VERSION_MINOR")
|
||||
file(STRINGS "${FILE}" IW_VERSION_UPDATE REGEX "IW_VERSION_UPDATE")
|
||||
|
||||
file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_MAJOR REGEX "IW_MIN_COMPATIBLE_IPP_MAJOR")
|
||||
file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_MINOR REGEX "IW_MIN_COMPATIBLE_IPP_MINOR")
|
||||
file(STRINGS "${FILE}" IW_MIN_COMPATIBLE_IPP_UPDATE REGEX "IW_MIN_COMPATIBLE_IPP_UPDATE")
|
||||
|
||||
string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_MAJOR ${IW_MIN_COMPATIBLE_IPP_MAJOR})
|
||||
string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_MINOR ${IW_MIN_COMPATIBLE_IPP_MINOR})
|
||||
string(REGEX MATCH "[0-9]+" IW_MIN_COMPATIBLE_IPP_UPDATE ${IW_MIN_COMPATIBLE_IPP_UPDATE})
|
||||
|
||||
string(REGEX MATCH "[0-9]+" IW_VERSION_MAJOR ${IW_VERSION_MAJOR})
|
||||
string(REGEX MATCH "[0-9]+" IW_VERSION_MINOR ${IW_VERSION_MINOR})
|
||||
string(REGEX MATCH "[0-9]+" IW_VERSION_UPDATE ${IW_VERSION_UPDATE})
|
||||
|
||||
math(EXPR IPP_VERSION_EXP "${IPP_VERSION_MAJOR}*10000 + ${IPP_VERSION_MINOR}*100 + ${IPP_VERSION_BUILD}")
|
||||
math(EXPR IW_MIN_COMPATIBLE_IPP_EXP "${IW_MIN_COMPATIBLE_IPP_MAJOR}*10000 + ${IW_MIN_COMPATIBLE_IPP_MINOR}*100 + ${IW_MIN_COMPATIBLE_IPP_UPDATE}")
|
||||
|
||||
if((IPP_VERSION_EXP GREATER IW_MIN_COMPATIBLE_IPP_EXP) OR (IPP_VERSION_EXP EQUAL IW_MIN_COMPATIBLE_IPP_EXP))
|
||||
ippiw_debugmsg("version\tok")
|
||||
if(${BUILD})
|
||||
# check sources
|
||||
if(EXISTS "${PATH}/src/iw_core.c")
|
||||
ippiw_debugmsg("sources\tok")
|
||||
set(IPP_IW_PATH "${PATH}")
|
||||
message(STATUS "found Intel IPP IW sources: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
|
||||
message(STATUS "at: ${IPP_IW_PATH}")
|
||||
|
||||
set(IPP_IW_LIBRARY ippiw)
|
||||
set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
|
||||
set(IPP_IW_LIBRARIES ${IPP_IW_LIBRARY})
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${OpenCV_SOURCE_DIR}/3rdparty/ippicv/CMakeLists.txt" "${IPP_IW_PATH}/")
|
||||
add_subdirectory("${IPP_IW_PATH}/" ${OpenCV_BINARY_DIR}/3rdparty/ippiw)
|
||||
|
||||
set(HAVE_IPP_IW 1)
|
||||
return()
|
||||
endif()
|
||||
else()
|
||||
# check binaries
|
||||
if(IPP_X64)
|
||||
set(FILE "${PATH}/lib/intel64/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
else()
|
||||
set(FILE "${PATH}/lib/ia32/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
||||
endif()
|
||||
if(EXISTS ${FILE})
|
||||
ippiw_debugmsg("binaries\tok (64=${IPP_X64})")
|
||||
set(IPP_IW_PATH "${PATH}")
|
||||
message(STATUS "found Intel IPP IW binaries: ${IW_VERSION_MAJOR}.${IW_VERSION_MINOR}.${IW_VERSION_UPDATE}")
|
||||
message(STATUS "at: ${IPP_IW_PATH}")
|
||||
|
||||
add_library(ippiw STATIC IMPORTED)
|
||||
set_target_properties(ippiw PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES ""
|
||||
IMPORTED_LOCATION "${FILE}"
|
||||
)
|
||||
if (NOT BUILD_SHARED_LIBS)
|
||||
# CMake doesn't support "install(TARGETS ${name} ...)" command with imported targets
|
||||
install(FILES "${FILE}"
|
||||
DESTINATION ${OPENCV_3P_LIB_INSTALL_PATH} COMPONENT dev)
|
||||
set(IPPIW_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_3P_LIB_INSTALL_PATH}/${CMAKE_STATIC_LIBRARY_PREFIX}ipp_iw${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE INTERNAL "" FORCE)
|
||||
set(IPPIW_LOCATION_PATH "${FILE}" CACHE INTERNAL "" FORCE)
|
||||
endif()
|
||||
|
||||
set(IPP_IW_INCLUDES "${IPP_IW_PATH}/include")
|
||||
set(IPP_IW_LIBRARIES ippiw)
|
||||
|
||||
set(HAVE_IPP_IW 1)
|
||||
set(BUILD_IPP_IW 0)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(HAVE_IPP_IW 0)
|
||||
endmacro()
|
||||
|
||||
# check os and architecture
|
||||
if(APPLE)
|
||||
set(IW_PACKAGE_SUBDIR "ippiw_mac")
|
||||
elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86"))
|
||||
set(IW_PACKAGE_SUBDIR "ippiw_lnx")
|
||||
elseif(WIN32 AND NOT ARM)
|
||||
set(IW_PACKAGE_SUBDIR "ippiw_win")
|
||||
else()
|
||||
message(SEND_ERROR "Improper system for Intel IPP Integrations Wrappers. This message shouldn't appear. Check Intel IPP configurations steps")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check build options first
|
||||
if(BUILD_IPP_IW)
|
||||
# custom path
|
||||
if(DEFINED IPPIWROOT)
|
||||
ippiw_setup("${IPPIWROOT}/" 1)
|
||||
message(STATUS "Can't find Intel IPP IW sources at: ${IPPIWROOT}")
|
||||
endif()
|
||||
|
||||
# local sources
|
||||
ippiw_setup("${OpenCV_SOURCE_DIR}/3rdparty/ippiw" 1)
|
||||
|
||||
# Package sources
|
||||
ippiw_setup("${IPPROOT}/../${IW_PACKAGE_SUBDIR}/" 1)
|
||||
endif()
|
||||
|
||||
|
||||
# custom binaries
|
||||
if(DEFINED IPPIWROOT)
|
||||
ippiw_setup("${IPPIWROOT}/" 0)
|
||||
message(STATUS "Can't find Intel IPP IW sources at: ${IPPIWROOT}")
|
||||
endif()
|
||||
|
||||
# check binaries in IPP folder
|
||||
ippiw_setup("${IPPROOT}/" 0)
|
||||
|
||||
# check binaries near IPP folder
|
||||
ippiw_setup("${IPPROOT}/../${IW_PACKAGE_SUBDIR}/" 0)
|
||||
|
||||
|
||||
# take Intel IPP IW from ICV package
|
||||
if(NOT HAVE_IPP_ICV_ONLY AND BUILD_IPP_IW)
|
||||
message(STATUS "Cannot find Intel IPP IW. Checking \"Intel IPP for OpenCV\" package")
|
||||
set(TEMP_ROOT 0)
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ippicv/ippicv.cmake")
|
||||
download_ippicv(TEMP_ROOT)
|
||||
|
||||
# Package sources. Only sources are compatible with regular Intel IPP
|
||||
ippiw_setup("${TEMP_ROOT}/../${IW_PACKAGE_SUBDIR}/" 1)
|
||||
endif()
|
||||
|
||||
|
||||
set(HAVE_IPP_IW 0)
|
||||
message(STATUS "Cannot find Intel IPP Integration Wrappers, optimizations will be limited. Use IPPIWROOT to set custom location")
|
||||
return()
|
||||
@@ -136,6 +136,10 @@ if(WITH_LAPACK)
|
||||
unset(LAPACK_LIBRARIES)
|
||||
unset(LAPACK_LIBRARIES CACHE)
|
||||
endif()
|
||||
else()
|
||||
# LAPACK not found
|
||||
unset(LAPACK_LIBRARIES)
|
||||
unset(LAPACK_LIBRARIES CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
|
||||
@@ -36,6 +36,11 @@ endif(WITH_TBB)
|
||||
if(WITH_IPP)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPP.cmake")
|
||||
if(HAVE_IPP)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVFindIPPIW.cmake")
|
||||
if(HAVE_IPP_IW)
|
||||
ocv_include_directories(${IPP_IW_INCLUDES})
|
||||
list(APPEND OPENCV_LINKER_LIBS ${IPP_IW_LIBRARIES})
|
||||
endif()
|
||||
ocv_include_directories(${IPP_INCLUDE_DIRS})
|
||||
list(APPEND OPENCV_LINKER_LIBS ${IPP_LIBRARIES})
|
||||
endif()
|
||||
|
||||
@@ -217,7 +217,11 @@ ocv_clear_vars(HAVE_FFMPEG)
|
||||
if(WITH_FFMPEG)
|
||||
if(WIN32 AND NOT ARM)
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg.cmake")
|
||||
set(HAVE_FFMPEG TRUE)
|
||||
download_win_ffmpeg(FFMPEG_CMAKE_SCRIPT)
|
||||
if(FFMPEG_CMAKE_SCRIPT)
|
||||
set(HAVE_FFMPEG TRUE)
|
||||
include("${FFMPEG_CMAKE_SCRIPT}")
|
||||
endif()
|
||||
elseif(PKG_CONFIG_FOUND)
|
||||
ocv_check_modules(FFMPEG libavcodec libavformat libavutil libswscale)
|
||||
ocv_check_modules(FFMPEG_libavresample libavresample)
|
||||
|
||||
@@ -45,12 +45,20 @@ export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules.
|
||||
|
||||
if(TARGET ippicv AND NOT BUILD_SHARED_LIBS)
|
||||
set(USE_IPPICV TRUE)
|
||||
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE ${CMAKE_BINARY_DIR} ${IPPICV_LOCATION_PATH})
|
||||
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPICV_LOCATION_PATH}")
|
||||
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
|
||||
else()
|
||||
set(USE_IPPICV FALSE)
|
||||
endif()
|
||||
|
||||
if(TARGET ippiw AND NOT BUILD_SHARED_LIBS AND IPPIW_INSTALL_PATH)
|
||||
set(USE_IPPIW TRUE)
|
||||
file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_BINARY_DIR}" "${IPPIW_LOCATION_PATH}")
|
||||
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
|
||||
else()
|
||||
set(USE_IPPIW FALSE)
|
||||
endif()
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" @ONLY)
|
||||
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" @ONLY)
|
||||
@@ -62,9 +70,13 @@ file(RELATIVE_PATH OpenCV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PRE
|
||||
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\" \"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv\"")
|
||||
|
||||
if(USE_IPPICV)
|
||||
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" ${IPPICV_INSTALL_PATH})
|
||||
file(RELATIVE_PATH IPPICV_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPICV_INSTALL_PATH}")
|
||||
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPICV.cmake.in" IPPICV_CONFIGCMAKE @ONLY)
|
||||
endif()
|
||||
if(USE_IPPIW)
|
||||
file(RELATIVE_PATH IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE "${CMAKE_INSTALL_PREFIX}" "${IPPIW_INSTALL_PATH}")
|
||||
ocv_cmake_configure("${CMAKE_CURRENT_LIST_DIR}/templates/OpenCVConfig-IPPIW.cmake.in" IPPIW_CONFIGCMAKE @ONLY)
|
||||
endif()
|
||||
|
||||
function(ocv_gen_config TMP_DIR NESTED_PATH ROOT_NAME)
|
||||
ocv_path_join(__install_nested "${OPENCV_CONFIG_INSTALL_PATH}" "${NESTED_PATH}")
|
||||
|
||||
@@ -3,6 +3,10 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CO
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cvconfig.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/opencv2/cvconfig.h")
|
||||
install(FILES "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cvconfig.h" DESTINATION ${OPENCV_INCLUDE_INSTALL_PATH}/opencv2 COMPONENT dev)
|
||||
|
||||
# platform-specific config file
|
||||
ocv_compiler_optimization_fill_cpu_config()
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/cv_cpu_config.h.in" "${OPENCV_CONFIG_FILE_INCLUDE_DIR}/cv_cpu_config.h")
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# opencv_modules.hpp based on actual modules list
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
@@ -65,6 +65,7 @@ foreach(mod ${OPENCV_MODULES_BUILD} ${OPENCV_MODULES_DISABLED_USER} ${OPENCV_MOD
|
||||
unset(OPENCV_MODULE_${mod}_PRIVATE_OPT_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_LINK_DEPS CACHE)
|
||||
unset(OPENCV_MODULE_${mod}_WRAPPERS CACHE)
|
||||
unset(OPENCV_DEPENDANT_TARGETS_${mod} CACHE)
|
||||
endforeach()
|
||||
|
||||
# clean modules info which needs to be recalculated
|
||||
@@ -313,6 +314,7 @@ macro(ocv_glob_modules)
|
||||
set(OPENCV_INITIAL_PASS OFF)
|
||||
if(${BUILD_opencv_world})
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
set(the_module "${m}")
|
||||
if("${m}" STREQUAL opencv_world)
|
||||
add_subdirectory("${OPENCV_MODULE_opencv_world_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/world")
|
||||
elseif(NOT OPENCV_MODULE_${m}_IS_PART_OF_WORLD AND NOT ${m} STREQUAL opencv_world)
|
||||
@@ -328,6 +330,7 @@ macro(ocv_glob_modules)
|
||||
endforeach()
|
||||
else()
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
set(the_module "${m}")
|
||||
if(m MATCHES "^opencv_")
|
||||
string(REGEX REPLACE "^opencv_" "" __shortname "${m}")
|
||||
add_subdirectory("${OPENCV_MODULE_${m}_LOCATION}" "${CMAKE_CURRENT_BINARY_DIR}/${__shortname}")
|
||||
@@ -645,6 +648,10 @@ macro(ocv_set_module_sources)
|
||||
ocv_get_module_external_sources()
|
||||
endif()
|
||||
|
||||
if(OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED)
|
||||
list(APPEND OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED})
|
||||
endif()
|
||||
|
||||
# use full paths for module to be independent from the module location
|
||||
ocv_convert_to_full_paths(OPENCV_MODULE_${the_module}_HEADERS)
|
||||
|
||||
@@ -763,6 +770,11 @@ macro(ocv_create_module)
|
||||
endmacro()
|
||||
|
||||
macro(_ocv_create_module)
|
||||
|
||||
ocv_compiler_optimization_process_sources(OPENCV_MODULE_${the_module}_SOURCES OPENCV_MODULE_${the_module}_DEPS_EXT ${the_module})
|
||||
set(OPENCV_MODULE_${the_module}_HEADERS ${OPENCV_MODULE_${the_module}_HEADERS} CACHE INTERNAL "List of header files for ${the_module}")
|
||||
set(OPENCV_MODULE_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_SOURCES} CACHE INTERNAL "List of source files for ${the_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.
|
||||
|
||||
@@ -196,18 +196,20 @@ MACRO(ADD_PRECOMPILED_HEADER_TO_TARGET _targetName _input _pch_output_to_use )
|
||||
|
||||
_PCH_GET_TARGET_COMPILE_FLAGS(_target_cflags ${_name} ${_pch_output_to_use} ${_dowarn})
|
||||
#MESSAGE("Add flags ${_target_cflags} to ${_targetName} " )
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(_target_cflags "${_target_cflags} -include \"${CMAKE_CURRENT_BINARY_DIR}/${_name}\"")
|
||||
endif()
|
||||
|
||||
GET_TARGET_PROPERTY(_sources ${_targetName} SOURCES)
|
||||
FOREACH(src ${_sources})
|
||||
if(NOT "${src}" MATCHES "\\.mm$")
|
||||
get_source_file_property(_flags "${src}" COMPILE_FLAGS)
|
||||
if(_flags)
|
||||
set(_flags "${_flags} ${_target_cflags}")
|
||||
get_source_file_property(_flags2 "${src}" COMPILE_DEFINITIONS)
|
||||
if(NOT _flags AND NOT _flags2)
|
||||
set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${_target_cflags}")
|
||||
else()
|
||||
set(_flags "${_target_cflags}")
|
||||
#ocv_debug_message("Skip PCH, flags: ${oldProps} defines: ${oldProps2}, file: ${src}")
|
||||
endif()
|
||||
|
||||
set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${_flags}")
|
||||
endif()
|
||||
ENDFOREACH()
|
||||
|
||||
@@ -284,19 +286,6 @@ MACRO(ADD_PRECOMPILED_HEADER _targetName _input)
|
||||
DEPENDS ${_targetName}_pch_dephelp
|
||||
)
|
||||
|
||||
get_target_property(_sources ${_targetName} SOURCES)
|
||||
foreach(src ${_sources})
|
||||
if(NOT "${src}" MATCHES "\\.mm$")
|
||||
get_source_file_property(oldProps "${src}" COMPILE_FLAGS)
|
||||
if(NOT oldProps)
|
||||
set(newProperties "-include \"${CMAKE_CURRENT_BINARY_DIR}/${_name}\"")
|
||||
set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${newProperties}")
|
||||
else()
|
||||
ocv_debug_message("Skip PCH, flags: ${oldProps} , file: ${src}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
ADD_PRECOMPILED_HEADER_TO_TARGET(${_targetName} ${_input} ${_output} ${_dowarn})
|
||||
|
||||
ENDMACRO(ADD_PRECOMPILED_HEADER)
|
||||
@@ -334,13 +323,17 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
|
||||
|
||||
get_target_property(_sources ${_targetName} SOURCES)
|
||||
foreach(src ${_sources})
|
||||
if(NOT "${src}" MATCHES "\\.mm$")
|
||||
if(NOT "${src}" MATCHES "\\.mm$"
|
||||
AND NOT "${src}" MATCHES "\\.h$" AND NOT "${src}" MATCHES "\\.hpp$" # header files
|
||||
AND NOT "${src}" MATCHES "^\$" # CMake generator expressions
|
||||
)
|
||||
get_source_file_property(oldProps "${src}" COMPILE_FLAGS)
|
||||
if(NOT oldProps)
|
||||
get_source_file_property(oldProps2 "${src}" COMPILE_DEFINITIONS)
|
||||
if(NOT oldProps AND NOT oldProps2)
|
||||
set(newProperties "/Yu\"${_input}\" /FI\"${_input}\"")
|
||||
set_source_files_properties("${src}" PROPERTIES COMPILE_FLAGS "${newProperties}")
|
||||
else()
|
||||
ocv_debug_message("Skip PCH, flags: ${oldProps} , file: ${src}")
|
||||
ocv_debug_message("Skip PCH, flags: ${oldProps} defines: ${oldProps2}, file: ${src}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
+74
-93
@@ -37,7 +37,11 @@ endmacro()
|
||||
|
||||
macro(ocv_update VAR)
|
||||
if(NOT DEFINED ${VAR})
|
||||
set(${VAR} ${ARGN})
|
||||
if("x${ARGN}" STREQUAL "x")
|
||||
set(${VAR} "")
|
||||
else()
|
||||
set(${VAR} ${ARGN})
|
||||
endif()
|
||||
else()
|
||||
#ocv_debug_message("Preserve old value for ${VAR}: ${${VAR}}")
|
||||
endif()
|
||||
@@ -151,8 +155,15 @@ function(ocv_append_target_property target prop)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(ocv_append_dependant_targets target)
|
||||
#ocv_debug_message("ocv_append_dependant_targets(${target} ${ARGN})")
|
||||
_ocv_fix_target(target)
|
||||
set(OPENCV_DEPENDANT_TARGETS_${target} "${OPENCV_DEPENDANT_TARGETS_${target}};${ARGN}" CACHE INTERNAL "" FORCE)
|
||||
endfunction()
|
||||
|
||||
# adds include directories in such way that directories from the OpenCV source tree go first
|
||||
function(ocv_target_include_directories target)
|
||||
#ocv_debug_message("ocv_target_include_directories(${target} ${ARGN})")
|
||||
_ocv_fix_target(target)
|
||||
set(__params "")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0" AND
|
||||
@@ -173,6 +184,11 @@ function(ocv_target_include_directories target)
|
||||
else()
|
||||
if(TARGET ${target})
|
||||
target_include_directories(${target} PRIVATE ${__params})
|
||||
if(OPENCV_DEPENDANT_TARGETS_${target})
|
||||
foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
|
||||
target_include_directories(${t} PRIVATE ${__params})
|
||||
endforeach()
|
||||
endif()
|
||||
else()
|
||||
set(__new_inc "${OCV_TARGET_INCLUDE_DIRS_${target}};${__params}")
|
||||
set(OCV_TARGET_INCLUDE_DIRS_${target} "${__new_inc}" CACHE INTERNAL "")
|
||||
@@ -205,8 +221,11 @@ set(OCV_COMPILER_FAIL_REGEX
|
||||
)
|
||||
|
||||
MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
|
||||
set(_fname "${ARGN}")
|
||||
if(NOT DEFINED ${RESULT})
|
||||
if("_${LANG}_" MATCHES "_CXX_")
|
||||
if(_fname)
|
||||
# nothing
|
||||
elseif("_${LANG}_" MATCHES "_CXX_")
|
||||
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.cxx")
|
||||
if("${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror " OR "${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror=unknown-pragmas ")
|
||||
FILE(WRITE "${_fname}" "int main() { return 0; }\n")
|
||||
@@ -231,10 +250,17 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
|
||||
unset(_fname)
|
||||
endif()
|
||||
if(_fname)
|
||||
MESSAGE(STATUS "Performing Test ${RESULT}")
|
||||
if(NOT "x${ARGN}" STREQUAL "x")
|
||||
file(RELATIVE_PATH __msg "${CMAKE_SOURCE_DIR}" "${ARGN}")
|
||||
set(__msg " (check file: ${__msg})")
|
||||
else()
|
||||
set(__msg "")
|
||||
endif()
|
||||
MESSAGE(STATUS "Performing Test ${RESULT}${__msg}")
|
||||
TRY_COMPILE(${RESULT}
|
||||
"${CMAKE_BINARY_DIR}"
|
||||
"${_fname}"
|
||||
CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}" # CMP0056 do this on new CMake
|
||||
COMPILE_DEFINITIONS "${FLAG}"
|
||||
OUTPUT_VARIABLE OUTPUT)
|
||||
|
||||
@@ -278,7 +304,11 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
|
||||
endif()
|
||||
ENDMACRO()
|
||||
|
||||
macro(ocv_check_flag_support lang flag varname)
|
||||
macro(ocv_check_flag_support lang flag varname base_options)
|
||||
if(CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_TRY_COMPILE_CONFIGURATION ${CMAKE_BUILD_TYPE})
|
||||
endif()
|
||||
|
||||
if("_${lang}_" MATCHES "_CXX_")
|
||||
set(_lang CXX)
|
||||
elseif("_${lang}_" MATCHES "_C_")
|
||||
@@ -293,7 +323,7 @@ macro(ocv_check_flag_support lang flag varname)
|
||||
string(REGEX REPLACE "^(/|-)" "HAVE_${_lang}_" ${varname} "${${varname}}")
|
||||
string(REGEX REPLACE " -|-|=| |\\." "_" ${varname} "${${varname}}")
|
||||
|
||||
ocv_check_compiler_flag("${_lang}" "${ARGN} ${flag}" ${${varname}})
|
||||
ocv_check_compiler_flag("${_lang}" "${base_options} ${flag}" ${${varname}} ${ARGN})
|
||||
endmacro()
|
||||
|
||||
# turns off warnings
|
||||
@@ -327,7 +357,7 @@ macro(ocv_warnings_disable)
|
||||
string(REPLACE "${warning}" "" ${var} "${${var}}")
|
||||
string(REPLACE "-W" "-Wno-" warning "${warning}")
|
||||
endif()
|
||||
ocv_check_flag_support(${var} "${warning}" _varname)
|
||||
ocv_check_flag_support(${var} "${warning}" _varname "")
|
||||
if(${_varname})
|
||||
set(${var} "${${var}} ${warning}")
|
||||
endif()
|
||||
@@ -342,7 +372,7 @@ macro(ocv_warnings_disable)
|
||||
else()
|
||||
string(REPLACE "-wd" "-Qwd" warning "${warning}")
|
||||
endif()
|
||||
ocv_check_flag_support(${var} "${warning}" _varname)
|
||||
ocv_check_flag_support(${var} "${warning}" _varname "")
|
||||
if(${_varname})
|
||||
set(${var} "${${var}} ${warning}")
|
||||
endif()
|
||||
@@ -357,7 +387,7 @@ macro(ocv_warnings_disable)
|
||||
endmacro()
|
||||
|
||||
macro(add_apple_compiler_options the_module)
|
||||
ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS)
|
||||
ocv_check_flag_support(OBJCXX "-fobjc-exceptions" HAVE_OBJC_EXCEPTIONS "")
|
||||
if(HAVE_OBJC_EXCEPTIONS)
|
||||
foreach(source ${OPENCV_MODULE_${the_module}_SOURCES})
|
||||
if("${source}" MATCHES "\\.mm$")
|
||||
@@ -903,6 +933,11 @@ function(_ocv_append_target_includes target)
|
||||
if (TARGET ${target}_object)
|
||||
target_include_directories(${target}_object PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})
|
||||
endif()
|
||||
if(OPENCV_DEPENDANT_TARGETS_${target})
|
||||
foreach(t ${OPENCV_DEPENDANT_TARGETS_${target}})
|
||||
target_include_directories(${t} PRIVATE ${OCV_TARGET_INCLUDE_DIRS_${target}})
|
||||
endforeach()
|
||||
endif()
|
||||
unset(OCV_TARGET_INCLUDE_DIRS_${target} CACHE)
|
||||
endif()
|
||||
endfunction()
|
||||
@@ -968,6 +1003,13 @@ function(ocv_add_library target)
|
||||
_ocv_append_target_includes(${target})
|
||||
endfunction()
|
||||
|
||||
|
||||
macro(ocv_get_libname var_name)
|
||||
get_filename_component(__libname "${ARGN}" NAME)
|
||||
string(REGEX REPLACE "^lib(.+).(a|so)(.[.0-9]+)?$" "\\1" __libname "${__libname}")
|
||||
set(${var_name} "${__libname}")
|
||||
endmacro()
|
||||
|
||||
# build the list of opencv libs and dependencies for all modules
|
||||
# _modules - variable to hold list of all modules
|
||||
# _extra - variable to hold list of extra dependencies
|
||||
@@ -995,11 +1037,31 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
|
||||
foreach (dep ${deps} ${OPENCV_LINKER_LIBS})
|
||||
if (NOT DEFINED OPENCV_MODULE_${dep}_LOCATION)
|
||||
if (TARGET ${dep})
|
||||
get_target_property(_output ${dep} ARCHIVE_OUTPUT_DIRECTORY)
|
||||
if ("${_output}" STREQUAL "${3P_LIBRARY_OUTPUT_PATH}")
|
||||
list(INSERT ${_3rdparty} 0 ${dep})
|
||||
get_target_property(_type ${dep} TYPE)
|
||||
if(_type STREQUAL "STATIC_LIBRARY" AND BUILD_SHARED_LIBS)
|
||||
# nothing
|
||||
else()
|
||||
list(INSERT ${_extra} 0 ${dep})
|
||||
get_target_property(_output ${dep} IMPORTED_LOCATION)
|
||||
if(NOT _output)
|
||||
get_target_property(_output ${dep} ARCHIVE_OUTPUT_DIRECTORY)
|
||||
get_target_property(_output_name ${dep} OUTPUT_NAME)
|
||||
if(NOT _output_name)
|
||||
set(_output_name "${dep}")
|
||||
endif()
|
||||
else()
|
||||
get_filename_component(_output_name "${_output}" NAME)
|
||||
endif()
|
||||
string(FIND "${_output}" "${CMAKE_BINARY_DIR}" _POS)
|
||||
if (_POS EQUAL 0)
|
||||
ocv_get_libname(_libname "${_output_name}")
|
||||
list(INSERT ${_3rdparty} 0 ${_libname})
|
||||
else()
|
||||
if(_output)
|
||||
list(INSERT ${_extra} 0 ${_output})
|
||||
else()
|
||||
list(INSERT ${_extra} 0 ${dep})
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
list(INSERT ${_extra} 0 ${dep})
|
||||
@@ -1008,15 +1070,6 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
# ippicv specific handling
|
||||
list(FIND ${_extra} "ippicv" ippicv_idx)
|
||||
if (${ippicv_idx} GREATER -1)
|
||||
list(REMOVE_ITEM ${_extra} "ippicv")
|
||||
if(NOT BUILD_SHARED_LIBS)
|
||||
list(INSERT ${_3rdparty} 0 "ippicv")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ocv_list_filterout(${_modules} "^[\$]<")
|
||||
ocv_list_filterout(${_3rdparty} "^[\$]<")
|
||||
ocv_list_filterout(${_extra} "^[\$]<")
|
||||
@@ -1028,78 +1081,6 @@ macro(ocv_get_all_libs _modules _extra _3rdparty)
|
||||
endforeach()
|
||||
endmacro()
|
||||
|
||||
function(ocv_download)
|
||||
cmake_parse_arguments(DL "" "PACKAGE;HASH;URL;DESTINATION_DIR;DOWNLOAD_DIR" "" ${ARGN})
|
||||
if(NOT DL_DOWNLOAD_DIR)
|
||||
set(DL_DOWNLOAD_DIR "${DL_DESTINATION_DIR}/downloads")
|
||||
endif()
|
||||
if(DEFINED DL_DESTINATION_DIR)
|
||||
set(DESTINATION_TARGET "${DL_DESTINATION_DIR}/${DL_PACKAGE}")
|
||||
if(EXISTS "${DESTINATION_TARGET}")
|
||||
file(MD5 "${DESTINATION_TARGET}" target_md5)
|
||||
if(NOT target_md5 STREQUAL DL_HASH)
|
||||
file(REMOVE "${DESTINATION_TARGET}")
|
||||
else()
|
||||
set(DOWNLOAD_PACKAGE_LOCATION "" PARENT_SCOPE)
|
||||
unset(DOWNLOAD_PACKAGE_LOCATION)
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
set(DOWNLOAD_TARGET "${DL_DOWNLOAD_DIR}/${DL_HASH}/${DL_PACKAGE}")
|
||||
get_filename_component(DOWNLOAD_TARGET_DIR "${DOWNLOAD_TARGET}" PATH)
|
||||
if(EXISTS "${DOWNLOAD_TARGET}")
|
||||
file(MD5 "${DOWNLOAD_TARGET}" target_md5)
|
||||
if(NOT target_md5 STREQUAL DL_HASH)
|
||||
message(WARNING "Download: Local copy of ${DL_PACKAGE} has invalid MD5 hash: ${target_md5} (expected: ${DL_HASH})")
|
||||
file(REMOVE "${DOWNLOAD_TARGET}")
|
||||
file(REMOVE_RECURSE "${DOWNLOAD_TARGET_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${DOWNLOAD_TARGET}")
|
||||
set(__url "")
|
||||
foreach(__url_i ${DL_URL})
|
||||
if(NOT ("${__url_i}" STREQUAL ""))
|
||||
set(__url "${__url_i}")
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
if("${__url}" STREQUAL "")
|
||||
message(FATAL_ERROR "Download URL is not specified for package ${DL_PACKAGE}")
|
||||
endif()
|
||||
|
||||
if(NOT EXISTS "${DOWNLOAD_TARGET_DIR}")
|
||||
file(MAKE_DIRECTORY ${DOWNLOAD_TARGET_DIR})
|
||||
endif()
|
||||
message(STATUS "Downloading ${DL_PACKAGE}...")
|
||||
#message(STATUS " ${__url}${DL_PACKAGE}")
|
||||
file(DOWNLOAD "${__url}${DL_PACKAGE}" "${DOWNLOAD_TARGET}"
|
||||
TIMEOUT 600 STATUS __status
|
||||
EXPECTED_MD5 ${DL_HASH})
|
||||
if(NOT __status EQUAL 0)
|
||||
message(FATAL_ERROR "Failed to download ${DL_PACKAGE}. Status=${__status}")
|
||||
else()
|
||||
# Don't remove this code, because EXPECTED_MD5 parameter doesn't fail "file(DOWNLOAD)" step on wrong hash
|
||||
file(MD5 "${DOWNLOAD_TARGET}" target_md5)
|
||||
if(NOT target_md5 STREQUAL DL_HASH)
|
||||
message(FATAL_ERROR "Downloaded copy of ${DL_PACKAGE} has invalid MD5 hash: ${target_md5} (expected: ${DL_HASH})")
|
||||
endif()
|
||||
endif()
|
||||
message(STATUS "Downloading ${DL_PACKAGE}... Done")
|
||||
endif()
|
||||
|
||||
if(DEFINED DL_DESTINATION_DIR)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${DOWNLOAD_TARGET}" "${DL_DESTINATION_DIR}/"
|
||||
RESULT_VARIABLE __result)
|
||||
|
||||
if(NOT __result EQUAL 0)
|
||||
message(FATAL_ERROR "Downloader: Failed to copy package from ${DOWNLOAD_TARGET} to ${DL_DESTINATION_DIR} with error ${__result}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(DOWNLOAD_PACKAGE_LOCATION ${DOWNLOAD_TARGET} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
function(ocv_add_test_from_target test_name test_kind the_target)
|
||||
if(CMAKE_VERSION VERSION_GREATER "2.8" AND NOT CMAKE_CROSSCOMPILING)
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
#if !defined __AVX__ // MSVC supports this flag since MSVS 2013
|
||||
#error "__AVX__ define is missing"
|
||||
#endif
|
||||
#include <immintrin.h>
|
||||
void test()
|
||||
{
|
||||
__m256 a = _mm256_set1_ps(0.0f);
|
||||
}
|
||||
int main() { return 0; }
|
||||
@@ -0,0 +1,10 @@
|
||||
#if !defined __AVX2__ // MSVC supports this flag since MSVS 2013
|
||||
#error "__AVX2__ define is missing"
|
||||
#endif
|
||||
#include <immintrin.h>
|
||||
void test()
|
||||
{
|
||||
int data[8] = {0,0,0,0, 0,0,0,0};
|
||||
__m256i a = _mm256_loadu_si256((const __m256i *)data);
|
||||
}
|
||||
int main() { return 0; }
|
||||
@@ -0,0 +1,10 @@
|
||||
#if defined __AVX512__ || defined __AVX512F__
|
||||
#include <immintrin.h>
|
||||
void test()
|
||||
{
|
||||
__m512i zmm = _mm512_setzero_si512();
|
||||
}
|
||||
#else
|
||||
#error "AVX512 is not supported"
|
||||
#endif
|
||||
int main() { return 0; }
|
||||
@@ -1,6 +1,6 @@
|
||||
#include <stdio.h>
|
||||
|
||||
#if defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700)
|
||||
#if defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700) || (defined __INTEL_COMPILER && defined __AVX__)
|
||||
#include <immintrin.h>
|
||||
int test()
|
||||
{
|
||||
@@ -0,0 +1,22 @@
|
||||
#ifdef _MSC_VER
|
||||
# include <nmmintrin.h>
|
||||
# if defined(_M_X64)
|
||||
# define CV_POPCNT_U64 _mm_popcnt_u64
|
||||
# endif
|
||||
# define CV_POPCNT_U32 _mm_popcnt_u32
|
||||
#else
|
||||
# include <popcntintrin.h>
|
||||
# if defined(__x86_64__)
|
||||
# define CV_POPCNT_U64 __builtin_popcountll
|
||||
# endif
|
||||
# define CV_POPCNT_U32 __builtin_popcount
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
#ifdef CV_POPCNT_U64
|
||||
int i = CV_POPCNT_U64(1);
|
||||
#endif
|
||||
int j = CV_POPCNT_U32(1);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
#include <xmmintrin.h>
|
||||
int main() { return 0; }
|
||||
@@ -0,0 +1,2 @@
|
||||
#include <emmintrin.h>
|
||||
int main() { return 0; }
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <pmmintrin.h>
|
||||
int main() {
|
||||
__m128 u, v;
|
||||
u = _mm_set1_ps(0.0f);
|
||||
v = _mm_moveldup_ps(u); // SSE3
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
#include <smmintrin.h>
|
||||
int main() {
|
||||
__m128i a = _mm_setzero_si128(), b = _mm_setzero_si128();
|
||||
__m128i c = _mm_packus_epi32(a, b);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <nmmintrin.h>
|
||||
|
||||
int main()
|
||||
{
|
||||
unsigned int res = _mm_crc32_u8(1, 2);
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#include <tmmintrin.h>
|
||||
const double v = 0;
|
||||
int main() {
|
||||
__m128i a = _mm_setzero_si128();
|
||||
__m128i b = _mm_abs_epi32(a);
|
||||
return 0;
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
#define __STDC_CONSTANT_MACROS
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
#include <VX/vx.h>
|
||||
int main()
|
||||
{
|
||||
return VX_REFERENCE_COUNT == VX_REFERENCE_TYPE ? VX_REFERENCE_NAME : 0;
|
||||
}
|
||||
+10
-18
@@ -9,17 +9,11 @@ if (NOT cl_list)
|
||||
message(FATAL_ERROR "Can't find OpenCL kernels in directory: ${CL_DIR}")
|
||||
endif()
|
||||
|
||||
string(REPLACE ".cpp" ".hpp" OUTPUT_HPP "${OUTPUT}")
|
||||
string(REGEX REPLACE "\\.cpp$" ".hpp" OUTPUT_HPP "${OUTPUT}")
|
||||
get_filename_component(OUTPUT_HPP_NAME "${OUTPUT_HPP}" NAME)
|
||||
|
||||
if("${MODULE_NAME}" STREQUAL "ocl")
|
||||
set(nested_namespace_start "")
|
||||
set(nested_namespace_end "")
|
||||
else()
|
||||
set(new_mode ON)
|
||||
set(nested_namespace_start "namespace ${MODULE_NAME}\n{")
|
||||
set(nested_namespace_end "}")
|
||||
endif()
|
||||
set(nested_namespace_start "namespace ${MODULE_NAME}\n{")
|
||||
set(nested_namespace_end "}")
|
||||
|
||||
set(STR_CPP "// This file is auto-generated. Do not edit!
|
||||
|
||||
@@ -35,6 +29,8 @@ namespace ocl
|
||||
{
|
||||
${nested_namespace_start}
|
||||
|
||||
static const char* const moduleName = \"${MODULE_NAME}\";
|
||||
|
||||
")
|
||||
|
||||
set(STR_HPP "// This file is auto-generated. Do not edit!
|
||||
@@ -76,19 +72,15 @@ foreach(cl ${cl_list})
|
||||
|
||||
string(MD5 hash "${lines}")
|
||||
|
||||
set(STR_CPP_DECL "const struct ProgramEntry ${cl_filename}={\"${cl_filename}\",\n\"${lines}, \"${hash}\"};\n")
|
||||
set(STR_HPP_DECL "extern const struct ProgramEntry ${cl_filename};\n")
|
||||
if(new_mode)
|
||||
set(STR_CPP_DECL "${STR_CPP_DECL}ProgramSource ${cl_filename}_oclsrc(${cl_filename}.programStr);\n")
|
||||
set(STR_HPP_DECL "${STR_HPP_DECL}extern ProgramSource ${cl_filename}_oclsrc;\n")
|
||||
endif()
|
||||
set(STR_CPP_DECL "struct cv::ocl::internal::ProgramEntry ${cl_filename}_oclsrc={moduleName, \"${cl_filename}\",\n\"${lines}, \"${hash}\", NULL};\n")
|
||||
set(STR_HPP_DECL "extern struct cv::ocl::internal::ProgramEntry ${cl_filename}_oclsrc;\n")
|
||||
|
||||
set(STR_CPP "${STR_CPP}${STR_CPP_DECL}")
|
||||
set(STR_HPP "${STR_HPP}${STR_HPP_DECL}")
|
||||
endforeach()
|
||||
|
||||
set(STR_CPP "${STR_CPP}}\n${nested_namespace_end}}\n#endif\n")
|
||||
set(STR_HPP "${STR_HPP}}\n${nested_namespace_end}}\n#endif\n")
|
||||
set(STR_CPP "${STR_CPP}\n${nested_namespace_end}}}\n#endif\n")
|
||||
set(STR_HPP "${STR_HPP}\n${nested_namespace_end}}}\n#endif\n")
|
||||
|
||||
file(WRITE "${OUTPUT}" "${STR_CPP}")
|
||||
|
||||
@@ -96,7 +88,7 @@ if(EXISTS "${OUTPUT_HPP}")
|
||||
file(READ "${OUTPUT_HPP}" hpp_lines)
|
||||
endif()
|
||||
if("${hpp_lines}" STREQUAL "${STR_HPP}")
|
||||
message(STATUS "${OUTPUT_HPP} contains same content")
|
||||
message(STATUS "${OUTPUT_HPP} contains the same content")
|
||||
else()
|
||||
file(WRITE "${OUTPUT_HPP}" "${STR_HPP}")
|
||||
endif()
|
||||
|
||||
@@ -94,6 +94,8 @@ LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
|
||||
ifeq ($(OPENCV_INSTALL_MODULES),on)
|
||||
LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod))
|
||||
else
|
||||
$(call __ndk_info,OpenCV: You should ignore warning about 'non-system libraries in linker flags' and 'opencv_java' library.)
|
||||
$(call __ndk_info, 'OPENCV_INSTALL_MODULES:=on' can be used to build APK with included OpenCV binaries)
|
||||
LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib))
|
||||
endif
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
if(NOT TARGET ippiw)
|
||||
add_library(ippiw STATIC IMPORTED)
|
||||
set_target_properties(ippiw PROPERTIES
|
||||
IMPORTED_LINK_INTERFACE_LIBRARIES ""
|
||||
IMPORTED_LOCATION "${OpenCV_INSTALL_PATH}/@IPPIW_INSTALL_PATH_RELATIVE_CONFIGCMAKE@"
|
||||
)
|
||||
endif()
|
||||
@@ -97,6 +97,7 @@ endif()
|
||||
@ANDROID_CONFIGCMAKE@
|
||||
|
||||
@IPPICV_CONFIGCMAKE@
|
||||
@IPPIW_CONFIGCMAKE@
|
||||
|
||||
# Some additional settings are required if OpenCV is built as static libs
|
||||
set(OpenCV_SHARED @BUILD_SHARED_LIBS@)
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
// OpenCV CPU baseline features
|
||||
@OPENCV_CPU_BASELINE_DEFINITIONS_CONFIGMAKE@
|
||||
|
||||
// OpenCV supported CPU dispatched features
|
||||
@OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE@
|
||||
@@ -1,6 +1,15 @@
|
||||
#ifndef OPENCV_CVCONFIG_H_INCLUDED
|
||||
#define OPENCV_CVCONFIG_H_INCLUDED
|
||||
|
||||
/* OpenCV compiled as static or dynamic libs */
|
||||
#cmakedefine BUILD_SHARED_LIBS
|
||||
|
||||
/* OpenCV intrinsics optimized code */
|
||||
#cmakedefine CV_ENABLE_INTRINSICS
|
||||
|
||||
/* OpenCV additional optimized code */
|
||||
#cmakedefine CV_DISABLE_OPTIMIZATION
|
||||
|
||||
/* Compile for 'real' NVIDIA GPU architectures */
|
||||
#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}"
|
||||
|
||||
@@ -92,6 +101,7 @@
|
||||
/* Intel Integrated Performance Primitives */
|
||||
#cmakedefine HAVE_IPP
|
||||
#cmakedefine HAVE_IPP_ICV_ONLY
|
||||
#cmakedefine HAVE_IPP_IW
|
||||
|
||||
/* Intel IPP Async */
|
||||
#cmakedefine HAVE_IPP_A
|
||||
@@ -198,11 +208,12 @@
|
||||
/* Lapack */
|
||||
#cmakedefine HAVE_LAPACK
|
||||
|
||||
/* FP16 */
|
||||
#cmakedefine HAVE_FP16
|
||||
|
||||
/* Library was compiled with functions instrumentation */
|
||||
#cmakedefine ENABLE_INSTRUMENTATION
|
||||
|
||||
/* OpenVX */
|
||||
#cmakedefine HAVE_OPENVX
|
||||
|
||||
|
||||
|
||||
#endif // OPENCV_CVCONFIG_H_INCLUDED
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ FORMULA_FONTSIZE = 14
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = YES
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest
|
||||
MATHJAX_RELPATH = http://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0
|
||||
MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
|
||||
MATHJAX_CODEFILE = @CMAKE_CURRENT_SOURCE_DIR@/mymath.js
|
||||
SEARCHENGINE = YES
|
||||
|
||||
+1
-1
@@ -67,7 +67,7 @@ $("h2").each(function() {
|
||||
$smallerHeadings = $(this).nextUntil("h2").filter("h3").add($(this).nextUntil("h2").find("h3"));
|
||||
if ($smallerHeadings.length) {
|
||||
$smallerHeadings.each(function() {
|
||||
var $elements = $(this).nextUntil("h3").filter("div.newInnerHTML");
|
||||
var $elements = $(this).nextUntil("h2,h3").filter("div.newInnerHTML");
|
||||
buttonsToAdd($elements, $(this), "h3");
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -897,3 +897,10 @@
|
||||
year={2010},
|
||||
publisher={Springer}
|
||||
}
|
||||
@INPROCEEDINGS{Ke17,
|
||||
author = {Ke, Tong and Roumeliotis, Stergios},
|
||||
title = {An Efficient Algebraic Solution to the Perspective-Three-Point Problem},
|
||||
booktitle = {Computer Vision and Pattern Recognition (CVPR), 2017 IEEE Conference on},
|
||||
year = {2017},
|
||||
organization = {IEEE}
|
||||
}
|
||||
|
||||
+2
-2
@@ -99,7 +99,7 @@ will have their corresponding values. Just check it yourself and verify it.
|
||||
|
||||
Below is the result I got, and each row is hierarchy details of corresponding contour. For eg, first
|
||||
row corresponds to contour 0. Next contour is contour 1. So Next = 1. There is no previous contour,
|
||||
so Previous = 0. And the remaining two, as told before, it is -1.
|
||||
so Previous = -1. And the remaining two, as told before, it is -1.
|
||||
@code{.py}
|
||||
>>> hierarchy
|
||||
array([[[ 1, -1, -1, -1],
|
||||
@@ -195,7 +195,7 @@ Take contour-0 : It is in hierarchy-0. Next contour in same hierarchy is contour
|
||||
contours. Child is contour-1. And no parent. So array is [7,-1,1,-1].
|
||||
|
||||
Take contour-2 : It is in hierarchy-1. No contour in same level. No previous one. Child is
|
||||
contour-2. Parent is contour-0. So array is [-1,-1,2,0].
|
||||
contour-3. Parent is contour-1. So array is [-1,-1,3,1].
|
||||
|
||||
And remaining, try yourself. Below is the full answer:
|
||||
@code{.py}
|
||||
|
||||
@@ -15,15 +15,15 @@ Installing OpenCV from prebuilt binaries
|
||||
|
||||
-# Below Python packages are to be downloaded and installed to their default locations.
|
||||
|
||||
-# [Python-2.7.x](http://python.org/ftp/python/2.7.5/python-2.7.5.msi).
|
||||
-# [Python-2.7.x](http://www.python.org/ftp/python/2.7.13/python-2.7.13.msi).
|
||||
|
||||
-# [Numpy](http://sourceforge.net/projects/numpy/files/NumPy/1.7.1/numpy-1.7.1-win32-superpack-python2.7.exe/download).
|
||||
-# [Numpy](https://sourceforge.net/projects/numpy/files/NumPy/1.10.2/numpy-1.10.2-win32-superpack-python2.7.exe/download).
|
||||
|
||||
-# [Matplotlib](https://downloads.sourceforge.net/project/matplotlib/matplotlib/matplotlib-1.3.0/matplotlib-1.3.0.win32-py2.7.exe) (*Matplotlib is optional, but recommended since we use it a lot in our tutorials*).
|
||||
-# [Matplotlib](https://sourceforge.net/projects/matplotlib/files/matplotlib/matplotlib-1.5.0/windows/matplotlib-1.5.0.win32-py2.7.exe/download) (*Matplotlib is optional, but recommended since we use it a lot in our tutorials*).
|
||||
|
||||
-# Install all packages into their default locations. Python will be installed to `C:/Python27/`.
|
||||
|
||||
-# After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.
|
||||
-# After installation, open Python IDLE. Enter **import numpy** and make sure Numpy is working fine.
|
||||
|
||||
-# Download latest OpenCV release from [sourceforge
|
||||
site](http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.4.6/OpenCV-2.4.6.0.exe/download)
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
Template Matching {#tutorial_template_matching}
|
||||
=================
|
||||
|
||||
@prev_tutorial{tutorial_back_projection}
|
||||
@next_tutorial{tutorial_find_contours}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
In this tutorial you will learn how to:
|
||||
|
||||
- Use the OpenCV function @ref cv::matchTemplate to search for matches between an image patch and
|
||||
- Use the OpenCV function **matchTemplate()** to search for matches between an image patch and
|
||||
an input image
|
||||
- Use the OpenCV function @ref cv::minMaxLoc to find the maximum and minimum values (as well as
|
||||
- Use the OpenCV function **minMaxLoc()** to find the maximum and minimum values (as well as
|
||||
their positions) in a given array.
|
||||
|
||||
Theory
|
||||
@@ -42,7 +45,7 @@ that should be used to find the match.
|
||||
- By **sliding**, we mean moving the patch one pixel at a time (left to right, up to down). At
|
||||
each location, a metric is calculated so it represents how "good" or "bad" the match at that
|
||||
location is (or how similar the patch is to that particular area of the source image).
|
||||
- For each location of **T** over **I**, you *store* the metric in the *result matrix* **(R)**.
|
||||
- For each location of **T** over **I**, you *store* the metric in the *result matrix* **R**.
|
||||
Each location \f$(x,y)\f$ in **R** contains the match metric:
|
||||
|
||||

|
||||
@@ -51,9 +54,8 @@ that should be used to find the match.
|
||||
The brightest locations indicate the highest matches. As you can see, the location marked by the
|
||||
red circle is probably the one with the highest value, so that location (the rectangle formed by
|
||||
that point as a corner and width and height equal to the patch image) is considered the match.
|
||||
|
||||
- In practice, we use the function @ref cv::minMaxLoc to locate the highest value (or lower,
|
||||
depending of the type of matching method) in the *R* matrix.
|
||||
- In practice, we locate the highest value (or lower, depending of the type of matching method) in
|
||||
the *R* matrix, using the function **minMaxLoc()**
|
||||
|
||||
### How does the mask work?
|
||||
- If masking is needed for the match, three components are required:
|
||||
@@ -81,7 +83,7 @@ that should be used to find the match.
|
||||
|
||||
### Which are the matching methods available in OpenCV?
|
||||
|
||||
Good question. OpenCV implements Template matching in the function @ref cv::matchTemplate . The
|
||||
Good question. OpenCV implements Template matching in the function **matchTemplate()**. The
|
||||
available methods are 6:
|
||||
|
||||
-# **method=CV_TM_SQDIFF**
|
||||
@@ -117,119 +119,176 @@ Code
|
||||
|
||||
- **What does this program do?**
|
||||
- Loads an input image, an image patch (*template*), and optionally a mask
|
||||
- Perform a template matching procedure by using the OpenCV function @ref cv::matchTemplate
|
||||
- Perform a template matching procedure by using the OpenCV function **matchTemplate()**
|
||||
with any of the 6 matching methods described before. The user can choose the method by
|
||||
entering its selection in the Trackbar. If a mask is supplied, it will only be used for
|
||||
the methods that support masking
|
||||
- Normalize the output of the matching procedure
|
||||
- Localize the location with higher matching probability
|
||||
- Draw a rectangle around the area corresponding to the highest match
|
||||
|
||||
@add_toggle_cpp
|
||||
|
||||
- **Downloadable code**: Click
|
||||
[here](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp)
|
||||
- **Code at glance:**
|
||||
@include samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp
|
||||
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
|
||||
- **Downloadable code**: Click
|
||||
[here](https://github.com/opencv/opencv/tree/master/samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java)
|
||||
- **Code at glance:**
|
||||
@include samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java
|
||||
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
|
||||
- **Downloadable code**: Click
|
||||
[here](https://github.com/opencv/opencv/tree/master/samples/python/tutorial_code/imgProc/match_template/match_template.py)
|
||||
- **Code at glance:**
|
||||
@include samples/python/tutorial_code/imgProc/match_template/match_template.py
|
||||
|
||||
@end_toggle
|
||||
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
-# Declare some global variables, such as the image, template and result matrices, as well as the
|
||||
- Declare some global variables, such as the image, template and result matrices, as well as the
|
||||
match method and the window names:
|
||||
@code{.cpp}
|
||||
Mat img; Mat templ; Mat result;
|
||||
char* image_window = "Source Image";
|
||||
char* result_window = "Result window";
|
||||
|
||||
int match_method;
|
||||
int max_Trackbar = 5;
|
||||
@endcode
|
||||
-# Load the source image, template, and optionally, if supported for the matching method, a mask:
|
||||
@code{.cpp}
|
||||
bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED);
|
||||
if (use_mask && method_accepts_mask)
|
||||
{ matchTemplate( img, templ, result, match_method, mask); }
|
||||
else
|
||||
{ matchTemplate( img, templ, result, match_method); }
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp declare
|
||||
@end_toggle
|
||||
|
||||
@endcode
|
||||
-# Create the windows to show the results:
|
||||
@code{.cpp}
|
||||
namedWindow( image_window, WINDOW_AUTOSIZE );
|
||||
namedWindow( result_window, WINDOW_AUTOSIZE );
|
||||
@endcode
|
||||
-# Create the Trackbar to enter the kind of matching method to be used. When a change is detected
|
||||
the callback function **MatchingMethod** is called.
|
||||
@code{.cpp}
|
||||
char* trackbar_label = "Method: \n 0: SQDIFF \n 1: SQDIFF NORMED \n 2: TM CCORR \n 3: TM CCORR NORMED \n 4: TM COEFF \n 5: TM COEFF NORMED";
|
||||
createTrackbar( trackbar_label, image_window, &match_method, max_Trackbar, MatchingMethod );
|
||||
@endcode
|
||||
-# Wait until user exits the program.
|
||||
@code{.cpp}
|
||||
waitKey(0);
|
||||
return 0;
|
||||
@endcode
|
||||
-# Let's check out the callback function. First, it makes a copy of the source image:
|
||||
@code{.cpp}
|
||||
Mat img_display;
|
||||
img.copyTo( img_display );
|
||||
@endcode
|
||||
-# Next, it creates the result matrix that will store the matching results for each template
|
||||
location. Observe in detail the size of the result matrix (which matches all possible locations
|
||||
for it)
|
||||
@code{.cpp}
|
||||
int result_cols = img.cols - templ.cols + 1;
|
||||
int result_rows = img.rows - templ.rows + 1;
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java declare
|
||||
@end_toggle
|
||||
|
||||
result.create( result_rows, result_cols, CV_32FC1 );
|
||||
@endcode
|
||||
-# Perform the template matching operation:
|
||||
@code{.cpp}
|
||||
bool method_accepts_mask = (CV_TM_SQDIFF == match_method || match_method == CV_TM_CCORR_NORMED);
|
||||
if (use_mask && method_accepts_mask)
|
||||
{ matchTemplate( img, templ, result, match_method, mask); }
|
||||
else
|
||||
{ matchTemplate( img, templ, result, match_method); }
|
||||
@endcode
|
||||
the arguments are naturally the input image **I**, the template **T**, the result **R**, the
|
||||
match_method (given by the Trackbar), and optionally the mask image **M**
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py global_variables
|
||||
@end_toggle
|
||||
|
||||
-# We normalize the results:
|
||||
@code{.cpp}
|
||||
normalize( result, result, 0, 1, NORM_MINMAX, -1, Mat() );
|
||||
@endcode
|
||||
-# We localize the minimum and maximum values in the result matrix **R** by using @ref
|
||||
cv::minMaxLoc .
|
||||
@code{.cpp}
|
||||
double minVal; double maxVal; Point minLoc; Point maxLoc;
|
||||
Point matchLoc;
|
||||
- Load the source image, template, and optionally, if supported for the matching method, a mask:
|
||||
|
||||
minMaxLoc( result, &minVal, &maxVal, &minLoc, &maxLoc, Mat() );
|
||||
@endcode
|
||||
the function calls as arguments:
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp load_image
|
||||
@end_toggle
|
||||
|
||||
- **result:** The source array
|
||||
- **&minVal** and **&maxVal:** Variables to save the minimum and maximum values in **result**
|
||||
- **&minLoc** and **&maxLoc:** The Point locations of the minimum and maximum values in the
|
||||
array.
|
||||
- **Mat():** Optional mask
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java load_image
|
||||
@end_toggle
|
||||
|
||||
-# For the first two methods ( TM_SQDIFF and MT_SQDIFF_NORMED ) the best match are the lowest
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py load_image
|
||||
@end_toggle
|
||||
|
||||
- Create the Trackbar to enter the kind of matching method to be used. When a change is detected
|
||||
the callback function is called.
|
||||
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp create_trackbar
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java create_trackbar
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py create_trackbar
|
||||
@end_toggle
|
||||
|
||||
- Let's check out the callback function. First, it makes a copy of the source image:
|
||||
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp copy_source
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java copy_source
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py copy_source
|
||||
@end_toggle
|
||||
|
||||
- Perform the template matching operation. The arguments are naturally the input image **I**,
|
||||
the template **T**, the result **R** and the match_method (given by the Trackbar),
|
||||
and optionally the mask image **M**.
|
||||
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp match_template
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java match_template
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py match_template
|
||||
@end_toggle
|
||||
|
||||
- We normalize the results:
|
||||
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp normalize
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java normalize
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py normalize
|
||||
@end_toggle
|
||||
|
||||
- We localize the minimum and maximum values in the result matrix **R** by using **minMaxLoc()**.
|
||||
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp best_match
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java best_match
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py best_match
|
||||
@end_toggle
|
||||
|
||||
- For the first two methods ( TM_SQDIFF and MT_SQDIFF_NORMED ) the best match are the lowest
|
||||
values. For all the others, higher values represent better matches. So, we save the
|
||||
corresponding value in the **matchLoc** variable:
|
||||
@code{.cpp}
|
||||
if( match_method == TM_SQDIFF || match_method == TM_SQDIFF_NORMED )
|
||||
{ matchLoc = minLoc; }
|
||||
else
|
||||
{ matchLoc = maxLoc; }
|
||||
@endcode
|
||||
-# Display the source image and the result matrix. Draw a rectangle around the highest possible
|
||||
matching area:
|
||||
@code{.cpp}
|
||||
rectangle( img_display, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(0), 2, 8, 0 );
|
||||
rectangle( result, matchLoc, Point( matchLoc.x + templ.cols , matchLoc.y + templ.rows ), Scalar::all(0), 2, 8, 0 );
|
||||
|
||||
imshow( image_window, img_display );
|
||||
imshow( result_window, result );
|
||||
@endcode
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp match_loc
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java match_loc
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py match_loc
|
||||
@end_toggle
|
||||
|
||||
- Display the source image and the result matrix. Draw a rectangle around the highest possible
|
||||
matching area:
|
||||
|
||||
@add_toggle_cpp
|
||||
@snippet samples/cpp/tutorial_code/Histograms_Matching/MatchTemplate_Demo.cpp imshow
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_java
|
||||
@snippet samples/java/tutorial_code/ImgProc/tutorial_template_matching/MatchTemplateDemo.java imshow
|
||||
@end_toggle
|
||||
|
||||
@add_toggle_python
|
||||
@snippet samples/python/tutorial_code/imgProc/match_template/match_template.py imshow
|
||||
@end_toggle
|
||||
|
||||
Results
|
||||
-------
|
||||
|
||||
@@ -68,7 +68,7 @@ Code
|
||||
|
||||
-# **What does this program do?**
|
||||
- Asks the user to enter a numerical value to set the lower threshold for our *Canny Edge
|
||||
Detector* (by means of a Trackbar)
|
||||
Detector* (by means of a Trackbar).
|
||||
- Applies the *Canny Detector* and generates a **mask** (bright lines representing the edges
|
||||
on a black background).
|
||||
- Applies the mask obtained on the original image and display it in a window.
|
||||
@@ -85,19 +85,19 @@ Explanation
|
||||
|
||||
Note the following:
|
||||
|
||||
-# We establish a ratio of lower:upper threshold of 3:1 (with the variable *ratio*)
|
||||
-# We establish a ratio of lower:upper threshold of 3:1 (with the variable *ratio*).
|
||||
-# We set the kernel size of \f$3\f$ (for the Sobel operations to be performed internally by the
|
||||
Canny function)
|
||||
Canny function).
|
||||
-# We set a maximum value for the lower Threshold of \f$100\f$.
|
||||
|
||||
-# Loads the source image:
|
||||
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp load
|
||||
|
||||
-# Create a matrix of the same type and size of *src* (to be *dst*)
|
||||
-# Create a matrix of the same type and size of *src* (to be *dst*):
|
||||
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp create_mat
|
||||
-# Convert the image to grayscale (using the function @ref cv::cvtColor :
|
||||
-# Convert the image to grayscale (using the function @ref cv::cvtColor ):
|
||||
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp convert_to_gray
|
||||
-# Create a window to display the results
|
||||
-# Create a window to display the results:
|
||||
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp create_window
|
||||
-# Create a Trackbar for the user to enter the lower threshold for our Canny detector:
|
||||
@snippet cpp/tutorial_code/ImgTrans/CannyDetector_Demo.cpp create_trackbar
|
||||
|
||||
@@ -66,7 +66,7 @@ Explanation
|
||||
- *min_dist = gray.rows/16*: Minimum distance between detected centers.
|
||||
- *param_1 = 200*: Upper threshold for the internal Canny edge detector.
|
||||
- *param_2* = 100\*: Threshold for center detection.
|
||||
- *min_radius = 0*: Minimum radio to be detected. If unknown, put zero as default.
|
||||
- *min_radius = 0*: Minimum radius to be detected. If unknown, put zero as default.
|
||||
- *max_radius = 0*: Maximum radius to be detected. If unknown, put zero as default.
|
||||
|
||||
-# Draw the detected circles:
|
||||
|
||||
@@ -173,6 +173,8 @@ In this section you will learn about the image processing (manipulation) functio
|
||||
|
||||
- @subpage tutorial_template_matching
|
||||
|
||||
*Languages:* C++, Java, Python
|
||||
|
||||
*Compatibility:* \> OpenCV 2.0
|
||||
|
||||
*Author:* Ana Huamán
|
||||
|
||||
@@ -236,8 +236,8 @@ enum { SOLVEPNP_ITERATIVE = 0,
|
||||
SOLVEPNP_EPNP = 1, //!< EPnP: Efficient Perspective-n-Point Camera Pose Estimation @cite lepetit2009epnp
|
||||
SOLVEPNP_P3P = 2, //!< Complete Solution Classification for the Perspective-Three-Point Problem @cite gao2003complete
|
||||
SOLVEPNP_DLS = 3, //!< A Direct Least-Squares (DLS) Method for PnP @cite hesch2011direct
|
||||
SOLVEPNP_UPNP = 4 //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
|
||||
|
||||
SOLVEPNP_UPNP = 4, //!< Exhaustive Linearization for Robust Camera Pose and Focal Length Estimation @cite penate2013exhaustive
|
||||
SOLVEPNP_AP3P = 5 //!< An Efficient Algebraic Solution to the Perspective-Three-Point Problem @cite Ke17
|
||||
};
|
||||
|
||||
enum { CALIB_CB_ADAPTIVE_THRESH = 1,
|
||||
@@ -1862,7 +1862,8 @@ public:
|
||||
{
|
||||
MODE_SGBM = 0,
|
||||
MODE_HH = 1,
|
||||
MODE_SGBM_3WAY = 2
|
||||
MODE_SGBM_3WAY = 2,
|
||||
MODE_HH4 = 3
|
||||
};
|
||||
|
||||
CV_WRAP virtual int getPreFilterCap() const = 0;
|
||||
@@ -1917,7 +1918,7 @@ public:
|
||||
set StereoSGBM::numDisparities at minimum. The second constructor enables you to set each parameter
|
||||
to a custom value.
|
||||
*/
|
||||
CV_WRAP static Ptr<StereoSGBM> create(int minDisparity, int numDisparities, int blockSize,
|
||||
CV_WRAP static Ptr<StereoSGBM> create(int minDisparity = 0, int numDisparities = 16, int blockSize = 3,
|
||||
int P1 = 0, int P2 = 0, int disp12MaxDiff = 0,
|
||||
int preFilterCap = 0, int uniquenessRatio = 0,
|
||||
int speckleWindowSize = 0, int speckleRange = 0,
|
||||
|
||||
@@ -0,0 +1,386 @@
|
||||
#include "ap3p.h"
|
||||
|
||||
#include <cmath>
|
||||
#include <complex>
|
||||
#if defined (_MSC_VER) && (_MSC_VER <= 1700)
|
||||
static inline double cbrt(double x) { return (double)cv::cubeRoot((float)x); };
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace {
|
||||
void solveQuartic(const double *factors, double *realRoots) {
|
||||
const double &a4 = factors[0];
|
||||
const double &a3 = factors[1];
|
||||
const double &a2 = factors[2];
|
||||
const double &a1 = factors[3];
|
||||
const double &a0 = factors[4];
|
||||
|
||||
double a4_2 = a4 * a4;
|
||||
double a3_2 = a3 * a3;
|
||||
double a4_3 = a4_2 * a4;
|
||||
double a2a4 = a2 * a4;
|
||||
|
||||
double p4 = (8 * a2a4 - 3 * a3_2) / (8 * a4_2);
|
||||
double q4 = (a3_2 * a3 - 4 * a2a4 * a3 + 8 * a1 * a4_2) / (8 * a4_3);
|
||||
double r4 = (256 * a0 * a4_3 - 3 * (a3_2 * a3_2) - 64 * a1 * a3 * a4_2 + 16 * a2a4 * a3_2) / (256 * (a4_3 * a4));
|
||||
|
||||
double p3 = ((p4 * p4) / 12 + r4) / 3; // /=-3
|
||||
double q3 = (72 * r4 * p4 - 2 * p4 * p4 * p4 - 27 * q4 * q4) / 432; // /=2
|
||||
|
||||
double t; // *=2
|
||||
complex<double> w;
|
||||
if (q3 >= 0)
|
||||
w = -sqrt(static_cast<complex<double> >(q3 * q3 - p3 * p3 * p3)) - q3;
|
||||
else
|
||||
w = sqrt(static_cast<complex<double> >(q3 * q3 - p3 * p3 * p3)) - q3;
|
||||
if (w.imag() == 0.0) {
|
||||
w.real(cbrt(w.real()));
|
||||
t = 2.0 * (w.real() + p3 / w.real());
|
||||
} else {
|
||||
w = pow(w, 1.0 / 3);
|
||||
t = 4.0 * w.real();
|
||||
}
|
||||
|
||||
complex<double> sqrt_2m = sqrt(static_cast<complex<double> >(-2 * p4 / 3 + t));
|
||||
double B_4A = -a3 / (4 * a4);
|
||||
double complex1 = 4 * p4 / 3 + t;
|
||||
complex<double> complex2 = 2 * q4 / sqrt_2m;
|
||||
double sqrt_2m_rh = sqrt_2m.real() / 2;
|
||||
double sqrt1 = sqrt(-(complex1 + complex2)).real() / 2;
|
||||
realRoots[0] = B_4A + sqrt_2m_rh + sqrt1;
|
||||
realRoots[1] = B_4A + sqrt_2m_rh - sqrt1;
|
||||
double sqrt2 = sqrt(-(complex1 - complex2)).real() / 2;
|
||||
realRoots[2] = B_4A - sqrt_2m_rh + sqrt2;
|
||||
realRoots[3] = B_4A - sqrt_2m_rh - sqrt2;
|
||||
}
|
||||
|
||||
void polishQuarticRoots(const double *coeffs, double *roots) {
|
||||
const int iterations = 2;
|
||||
for (int i = 0; i < iterations; ++i) {
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
double error =
|
||||
(((coeffs[0] * roots[j] + coeffs[1]) * roots[j] + coeffs[2]) * roots[j] + coeffs[3]) * roots[j] +
|
||||
coeffs[4];
|
||||
double
|
||||
derivative =
|
||||
((4 * coeffs[0] * roots[j] + 3 * coeffs[1]) * roots[j] + 2 * coeffs[2]) * roots[j] + coeffs[3];
|
||||
roots[j] -= error / derivative;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline void vect_cross(const double *a, const double *b, double *result) {
|
||||
result[0] = a[1] * b[2] - a[2] * b[1];
|
||||
result[1] = -(a[0] * b[2] - a[2] * b[0]);
|
||||
result[2] = a[0] * b[1] - a[1] * b[0];
|
||||
}
|
||||
|
||||
inline double vect_dot(const double *a, const double *b) {
|
||||
return a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
|
||||
}
|
||||
|
||||
inline double vect_norm(const double *a) {
|
||||
return sqrt(a[0] * a[0] + a[1] * a[1] + a[2] * a[2]);
|
||||
}
|
||||
|
||||
inline void vect_scale(const double s, const double *a, double *result) {
|
||||
result[0] = a[0] * s;
|
||||
result[1] = a[1] * s;
|
||||
result[2] = a[2] * s;
|
||||
}
|
||||
|
||||
inline void vect_sub(const double *a, const double *b, double *result) {
|
||||
result[0] = a[0] - b[0];
|
||||
result[1] = a[1] - b[1];
|
||||
result[2] = a[2] - b[2];
|
||||
}
|
||||
|
||||
inline void vect_divide(const double *a, const double d, double *result) {
|
||||
result[0] = a[0] / d;
|
||||
result[1] = a[1] / d;
|
||||
result[2] = a[2] / d;
|
||||
}
|
||||
|
||||
inline void mat_mult(const double a[3][3], const double b[3][3], double result[3][3]) {
|
||||
result[0][0] = a[0][0] * b[0][0] + a[0][1] * b[1][0] + a[0][2] * b[2][0];
|
||||
result[0][1] = a[0][0] * b[0][1] + a[0][1] * b[1][1] + a[0][2] * b[2][1];
|
||||
result[0][2] = a[0][0] * b[0][2] + a[0][1] * b[1][2] + a[0][2] * b[2][2];
|
||||
|
||||
result[1][0] = a[1][0] * b[0][0] + a[1][1] * b[1][0] + a[1][2] * b[2][0];
|
||||
result[1][1] = a[1][0] * b[0][1] + a[1][1] * b[1][1] + a[1][2] * b[2][1];
|
||||
result[1][2] = a[1][0] * b[0][2] + a[1][1] * b[1][2] + a[1][2] * b[2][2];
|
||||
|
||||
result[2][0] = a[2][0] * b[0][0] + a[2][1] * b[1][0] + a[2][2] * b[2][0];
|
||||
result[2][1] = a[2][0] * b[0][1] + a[2][1] * b[1][1] + a[2][2] * b[2][1];
|
||||
result[2][2] = a[2][0] * b[0][2] + a[2][1] * b[1][2] + a[2][2] * b[2][2];
|
||||
}
|
||||
}
|
||||
|
||||
namespace cv {
|
||||
void ap3p::init_inverse_parameters() {
|
||||
inv_fx = 1. / fx;
|
||||
inv_fy = 1. / fy;
|
||||
cx_fx = cx / fx;
|
||||
cy_fy = cy / fy;
|
||||
}
|
||||
|
||||
ap3p::ap3p(cv::Mat cameraMatrix) {
|
||||
if (cameraMatrix.depth() == CV_32F)
|
||||
init_camera_parameters<float>(cameraMatrix);
|
||||
else
|
||||
init_camera_parameters<double>(cameraMatrix);
|
||||
init_inverse_parameters();
|
||||
}
|
||||
|
||||
ap3p::ap3p(double _fx, double _fy, double _cx, double _cy) {
|
||||
fx = _fx;
|
||||
fy = _fy;
|
||||
cx = _cx;
|
||||
cy = _cy;
|
||||
init_inverse_parameters();
|
||||
}
|
||||
|
||||
// This algorithm is from "Tong Ke, Stergios Roumeliotis, An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (Accepted by CVPR 2017)
|
||||
// See https://arxiv.org/pdf/1701.08237.pdf
|
||||
// featureVectors: The 3 bearing measurements (normalized) stored as column vectors
|
||||
// worldPoints: The positions of the 3 feature points stored as column vectors
|
||||
// solutionsR: 4 possible solutions of rotation matrix of the world w.r.t the camera frame
|
||||
// solutionsT: 4 possible solutions of translation of the world origin w.r.t the camera frame
|
||||
int ap3p::computePoses(const double featureVectors[3][3],
|
||||
const double worldPoints[3][3],
|
||||
double solutionsR[4][3][3],
|
||||
double solutionsT[4][3]) {
|
||||
|
||||
//world point vectors
|
||||
double w1[3] = {worldPoints[0][0], worldPoints[1][0], worldPoints[2][0]};
|
||||
double w2[3] = {worldPoints[0][1], worldPoints[1][1], worldPoints[2][1]};
|
||||
double w3[3] = {worldPoints[0][2], worldPoints[1][2], worldPoints[2][2]};
|
||||
// k1
|
||||
double u0[3];
|
||||
vect_sub(w1, w2, u0);
|
||||
|
||||
double nu0 = vect_norm(u0);
|
||||
double k1[3];
|
||||
vect_divide(u0, nu0, k1);
|
||||
// bi
|
||||
double b1[3] = {featureVectors[0][0], featureVectors[1][0], featureVectors[2][0]};
|
||||
double b2[3] = {featureVectors[0][1], featureVectors[1][1], featureVectors[2][1]};
|
||||
double b3[3] = {featureVectors[0][2], featureVectors[1][2], featureVectors[2][2]};
|
||||
// k3,tz
|
||||
double k3[3];
|
||||
vect_cross(b1, b2, k3);
|
||||
double nk3 = vect_norm(k3);
|
||||
vect_divide(k3, nk3, k3);
|
||||
|
||||
double tz[3];
|
||||
vect_cross(b1, k3, tz);
|
||||
// ui,vi
|
||||
double v1[3];
|
||||
vect_cross(b1, b3, v1);
|
||||
double v2[3];
|
||||
vect_cross(b2, b3, v2);
|
||||
|
||||
double u1[3];
|
||||
vect_sub(w1, w3, u1);
|
||||
// coefficients related terms
|
||||
double u1k1 = vect_dot(u1, k1);
|
||||
double k3b3 = vect_dot(k3, b3);
|
||||
// f1i
|
||||
double f11 = k3b3;
|
||||
double f13 = vect_dot(k3, v1);
|
||||
double f15 = -u1k1 * f11;
|
||||
//delta
|
||||
double nl[3];
|
||||
vect_cross(u1, k1, nl);
|
||||
double delta = vect_norm(nl);
|
||||
vect_divide(nl, delta, nl);
|
||||
f11 *= delta;
|
||||
f13 *= delta;
|
||||
// f2i
|
||||
double u2k1 = u1k1 - nu0;
|
||||
double f21 = vect_dot(tz, v2);
|
||||
double f22 = nk3 * k3b3;
|
||||
double f23 = vect_dot(k3, v2);
|
||||
double f24 = u2k1 * f22;
|
||||
double f25 = -u2k1 * f21;
|
||||
f21 *= delta;
|
||||
f22 *= delta;
|
||||
f23 *= delta;
|
||||
double g1 = f13 * f22;
|
||||
double g2 = f13 * f25 - f15 * f23;
|
||||
double g3 = f11 * f23 - f13 * f21;
|
||||
double g4 = -f13 * f24;
|
||||
double g5 = f11 * f22;
|
||||
double g6 = f11 * f25 - f15 * f21;
|
||||
double g7 = -f15 * f24;
|
||||
double coeffs[5] = {g5 * g5 + g1 * g1 + g3 * g3,
|
||||
2 * (g5 * g6 + g1 * g2 + g3 * g4),
|
||||
g6 * g6 + 2 * g5 * g7 + g2 * g2 + g4 * g4 - g1 * g1 - g3 * g3,
|
||||
2 * (g6 * g7 - g1 * g2 - g3 * g4),
|
||||
g7 * g7 - g2 * g2 - g4 * g4};
|
||||
double s[4];
|
||||
solveQuartic(coeffs, s);
|
||||
polishQuarticRoots(coeffs, s);
|
||||
|
||||
double temp[3];
|
||||
vect_cross(k1, nl, temp);
|
||||
|
||||
double Ck1nl[3][3] =
|
||||
{{k1[0], nl[0], temp[0]},
|
||||
{k1[1], nl[1], temp[1]},
|
||||
{k1[2], nl[2], temp[2]}};
|
||||
|
||||
double Cb1k3tzT[3][3] =
|
||||
{{b1[0], b1[1], b1[2]},
|
||||
{k3[0], k3[1], k3[2]},
|
||||
{tz[0], tz[1], tz[2]}};
|
||||
|
||||
double b3p[3];
|
||||
vect_scale((delta / k3b3), b3, b3p);
|
||||
|
||||
int nb_solutions = 0;
|
||||
for (int i = 0; i < 4; ++i) {
|
||||
double ctheta1p = s[i];
|
||||
if (abs(ctheta1p) > 1)
|
||||
continue;
|
||||
double stheta1p = sqrt(1 - ctheta1p * ctheta1p);
|
||||
stheta1p = (k3b3 > 0) ? stheta1p : -stheta1p;
|
||||
double ctheta3 = g1 * ctheta1p + g2;
|
||||
double stheta3 = g3 * ctheta1p + g4;
|
||||
double ntheta3 = stheta1p / ((g5 * ctheta1p + g6) * ctheta1p + g7);
|
||||
ctheta3 *= ntheta3;
|
||||
stheta3 *= ntheta3;
|
||||
|
||||
double C13[3][3] =
|
||||
{{ctheta3, 0, -stheta3},
|
||||
{stheta1p * stheta3, ctheta1p, stheta1p * ctheta3},
|
||||
{ctheta1p * stheta3, -stheta1p, ctheta1p * ctheta3}};
|
||||
|
||||
double temp_matrix[3][3];
|
||||
double R[3][3];
|
||||
mat_mult(Ck1nl, C13, temp_matrix);
|
||||
mat_mult(temp_matrix, Cb1k3tzT, R);
|
||||
|
||||
// R' * p3
|
||||
double rp3[3] =
|
||||
{w3[0] * R[0][0] + w3[1] * R[1][0] + w3[2] * R[2][0],
|
||||
w3[0] * R[0][1] + w3[1] * R[1][1] + w3[2] * R[2][1],
|
||||
w3[0] * R[0][2] + w3[1] * R[1][2] + w3[2] * R[2][2]};
|
||||
|
||||
double pxstheta1p[3];
|
||||
vect_scale(stheta1p, b3p, pxstheta1p);
|
||||
|
||||
vect_sub(pxstheta1p, rp3, solutionsT[nb_solutions]);
|
||||
|
||||
solutionsR[nb_solutions][0][0] = R[0][0];
|
||||
solutionsR[nb_solutions][1][0] = R[0][1];
|
||||
solutionsR[nb_solutions][2][0] = R[0][2];
|
||||
solutionsR[nb_solutions][0][1] = R[1][0];
|
||||
solutionsR[nb_solutions][1][1] = R[1][1];
|
||||
solutionsR[nb_solutions][2][1] = R[1][2];
|
||||
solutionsR[nb_solutions][0][2] = R[2][0];
|
||||
solutionsR[nb_solutions][1][2] = R[2][1];
|
||||
solutionsR[nb_solutions][2][2] = R[2][2];
|
||||
|
||||
nb_solutions++;
|
||||
}
|
||||
|
||||
return nb_solutions;
|
||||
}
|
||||
|
||||
bool ap3p::solve(cv::Mat &R, cv::Mat &tvec, const cv::Mat &opoints, const cv::Mat &ipoints) {
|
||||
CV_INSTRUMENT_REGION()
|
||||
|
||||
double rotation_matrix[3][3], translation[3];
|
||||
std::vector<double> points;
|
||||
if (opoints.depth() == ipoints.depth()) {
|
||||
if (opoints.depth() == CV_32F)
|
||||
extract_points<cv::Point3f, cv::Point2f>(opoints, ipoints, points);
|
||||
else
|
||||
extract_points<cv::Point3d, cv::Point2d>(opoints, ipoints, points);
|
||||
} else if (opoints.depth() == CV_32F)
|
||||
extract_points<cv::Point3f, cv::Point2d>(opoints, ipoints, points);
|
||||
else
|
||||
extract_points<cv::Point3d, cv::Point2f>(opoints, ipoints, points);
|
||||
|
||||
bool result = solve(rotation_matrix, translation, points[0], points[1], points[2], points[3], points[4], points[5],
|
||||
points[6], points[7], points[8], points[9], points[10], points[11], points[12], points[13],
|
||||
points[14],
|
||||
points[15], points[16], points[17], points[18], points[19]);
|
||||
cv::Mat(3, 1, CV_64F, translation).copyTo(tvec);
|
||||
cv::Mat(3, 3, CV_64F, rotation_matrix).copyTo(R);
|
||||
return result;
|
||||
}
|
||||
|
||||
bool
|
||||
ap3p::solve(double R[3][3], double t[3], double mu0, double mv0, double X0, double Y0, double Z0, double mu1,
|
||||
double mv1,
|
||||
double X1, double Y1, double Z1, double mu2, double mv2, double X2, double Y2, double Z2, double mu3,
|
||||
double mv3, double X3, double Y3, double Z3) {
|
||||
double Rs[4][3][3], ts[4][3];
|
||||
|
||||
int n = solve(Rs, ts, mu0, mv0, X0, Y0, Z0, mu1, mv1, X1, Y1, Z1, mu2, mv2, X2, Y2, Z2);
|
||||
if (n == 0)
|
||||
return false;
|
||||
|
||||
int ns = 0;
|
||||
double min_reproj = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
double X3p = Rs[i][0][0] * X3 + Rs[i][0][1] * Y3 + Rs[i][0][2] * Z3 + ts[i][0];
|
||||
double Y3p = Rs[i][1][0] * X3 + Rs[i][1][1] * Y3 + Rs[i][1][2] * Z3 + ts[i][1];
|
||||
double Z3p = Rs[i][2][0] * X3 + Rs[i][2][1] * Y3 + Rs[i][2][2] * Z3 + ts[i][2];
|
||||
double mu3p = cx + fx * X3p / Z3p;
|
||||
double mv3p = cy + fy * Y3p / Z3p;
|
||||
double reproj = (mu3p - mu3) * (mu3p - mu3) + (mv3p - mv3) * (mv3p - mv3);
|
||||
if (i == 0 || min_reproj > reproj) {
|
||||
ns = i;
|
||||
min_reproj = reproj;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
for (int j = 0; j < 3; j++)
|
||||
R[i][j] = Rs[ns][i][j];
|
||||
t[i] = ts[ns][i];
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
int ap3p::solve(double R[4][3][3], double t[4][3], double mu0, double mv0, double X0, double Y0, double Z0, double mu1,
|
||||
double mv1, double X1, double Y1, double Z1, double mu2, double mv2, double X2, double Y2, double Z2) {
|
||||
double mk0, mk1, mk2;
|
||||
double norm;
|
||||
|
||||
mu0 = inv_fx * mu0 - cx_fx;
|
||||
mv0 = inv_fy * mv0 - cy_fy;
|
||||
norm = sqrt(mu0 * mu0 + mv0 * mv0 + 1);
|
||||
mk0 = 1. / norm;
|
||||
mu0 *= mk0;
|
||||
mv0 *= mk0;
|
||||
|
||||
mu1 = inv_fx * mu1 - cx_fx;
|
||||
mv1 = inv_fy * mv1 - cy_fy;
|
||||
norm = sqrt(mu1 * mu1 + mv1 * mv1 + 1);
|
||||
mk1 = 1. / norm;
|
||||
mu1 *= mk1;
|
||||
mv1 *= mk1;
|
||||
|
||||
mu2 = inv_fx * mu2 - cx_fx;
|
||||
mv2 = inv_fy * mv2 - cy_fy;
|
||||
norm = sqrt(mu2 * mu2 + mv2 * mv2 + 1);
|
||||
mk2 = 1. / norm;
|
||||
mu2 *= mk2;
|
||||
mv2 *= mk2;
|
||||
|
||||
double featureVectors[3][3] = {{mu0, mu1, mu2},
|
||||
{mv0, mv1, mv2},
|
||||
{mk0, mk1, mk2}};
|
||||
double worldPoints[3][3] = {{X0, X1, X2},
|
||||
{Y0, Y1, Y2},
|
||||
{Z0, Z1, Z2}};
|
||||
|
||||
return computePoses(featureVectors, worldPoints, R, t);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
#ifndef P3P_P3P_H
|
||||
#define P3P_P3P_H
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
namespace cv {
|
||||
class ap3p {
|
||||
private:
|
||||
template<typename T>
|
||||
void init_camera_parameters(const cv::Mat &cameraMatrix) {
|
||||
cx = cameraMatrix.at<T>(0, 2);
|
||||
cy = cameraMatrix.at<T>(1, 2);
|
||||
fx = cameraMatrix.at<T>(0, 0);
|
||||
fy = cameraMatrix.at<T>(1, 1);
|
||||
}
|
||||
|
||||
template<typename OpointType, typename IpointType>
|
||||
void extract_points(const cv::Mat &opoints, const cv::Mat &ipoints, std::vector<double> &points) {
|
||||
points.clear();
|
||||
points.resize(20);
|
||||
for (int i = 0; i < 4; i++) {
|
||||
points[i * 5] = ipoints.at<IpointType>(i).x * fx + cx;
|
||||
points[i * 5 + 1] = ipoints.at<IpointType>(i).y * fy + cy;
|
||||
points[i * 5 + 2] = opoints.at<OpointType>(i).x;
|
||||
points[i * 5 + 3] = opoints.at<OpointType>(i).y;
|
||||
points[i * 5 + 4] = opoints.at<OpointType>(i).z;
|
||||
}
|
||||
}
|
||||
|
||||
void init_inverse_parameters();
|
||||
|
||||
double fx, fy, cx, cy;
|
||||
double inv_fx, inv_fy, cx_fx, cy_fy;
|
||||
public:
|
||||
ap3p() {}
|
||||
|
||||
ap3p(double fx, double fy, double cx, double cy);
|
||||
|
||||
ap3p(cv::Mat cameraMatrix);
|
||||
|
||||
bool solve(cv::Mat &R, cv::Mat &tvec, const cv::Mat &opoints, const cv::Mat &ipoints);
|
||||
|
||||
int solve(double R[4][3][3], double t[4][3],
|
||||
double mu0, double mv0, double X0, double Y0, double Z0,
|
||||
double mu1, double mv1, double X1, double Y1, double Z1,
|
||||
double mu2, double mv2, double X2, double Y2, double Z2);
|
||||
|
||||
bool solve(double R[3][3], double t[3],
|
||||
double mu0, double mv0, double X0, double Y0, double Z0,
|
||||
double mu1, double mv1, double X1, double Y1, double Z1,
|
||||
double mu2, double mv2, double X2, double Y2, double Z2,
|
||||
double mu3, double mv3, double X3, double Y3, double Z3);
|
||||
|
||||
// This algorithm is from "Tong Ke, Stergios Roumeliotis, An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (Accepted by CVPR 2017)
|
||||
// See https://arxiv.org/pdf/1701.08237.pdf
|
||||
// featureVectors: 3 bearing measurements (normalized) stored as column vectors
|
||||
// worldPoints: Positions of the 3 feature points stored as column vectors
|
||||
// solutionsR: 4 possible solutions of rotation matrix of the world w.r.t the camera frame
|
||||
// solutionsT: 4 possible solutions of translation of the world origin w.r.t the camera frame
|
||||
int computePoses(const double featureVectors[3][3], const double worldPoints[3][3], double solutionsR[4][3][3],
|
||||
double solutionsT[4][3]);
|
||||
|
||||
};
|
||||
}
|
||||
#endif //P3P_P3P_H
|
||||
@@ -839,7 +839,11 @@ Mat CirclesGridFinder::rectifyGrid(Size detectedGridSize, const std::vector<Poin
|
||||
//Mat H = findHomography( Mat( corners ), Mat( dstPoints ) );
|
||||
|
||||
if (H.empty())
|
||||
{
|
||||
H = Mat::zeros(3, 3, CV_64FC1);
|
||||
warpedKeypoints.clear();
|
||||
return H;
|
||||
}
|
||||
|
||||
std::vector<Point2f> srcKeypoints;
|
||||
for (size_t i = 0; i < keypoints.size(); i++)
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include "dls.h"
|
||||
#include "epnp.h"
|
||||
#include "p3p.h"
|
||||
#include "ap3p.h"
|
||||
#include "opencv2/calib3d/calib3d_c.h"
|
||||
|
||||
#include <iostream>
|
||||
@@ -118,6 +119,18 @@ bool solvePnP( InputArray _opoints, InputArray _ipoints,
|
||||
if (result)
|
||||
Rodrigues(R, rvec);
|
||||
}
|
||||
else if (flags == SOLVEPNP_AP3P)
|
||||
{
|
||||
CV_Assert( npoints == 4);
|
||||
Mat undistortedPoints;
|
||||
undistortPoints(ipoints, undistortedPoints, cameraMatrix, distCoeffs);
|
||||
ap3p P3Psolver(cameraMatrix);
|
||||
|
||||
Mat R;
|
||||
result = P3Psolver.solve(R, tvec, opoints, undistortedPoints);
|
||||
if (result)
|
||||
Rodrigues(R, rvec);
|
||||
}
|
||||
else if (flags == SOLVEPNP_ITERATIVE)
|
||||
{
|
||||
CvMat c_objectPoints = opoints, c_imagePoints = ipoints;
|
||||
@@ -291,7 +304,8 @@ bool solvePnPRansac(InputArray _opoints, InputArray _ipoints,
|
||||
opoints_inliers.resize(npoints1);
|
||||
ipoints_inliers.resize(npoints1);
|
||||
result = solvePnP(opoints_inliers, ipoints_inliers, cameraMatrix,
|
||||
distCoeffs, rvec, tvec, false, flags == SOLVEPNP_P3P ? SOLVEPNP_EPNP : flags) ? 1 : -1;
|
||||
distCoeffs, rvec, tvec, false,
|
||||
(flags == SOLVEPNP_P3P || flags == SOLVEPNP_AP3P) ? SOLVEPNP_EPNP : flags) ? 1 : -1;
|
||||
}
|
||||
|
||||
if( result <= 0 || _local_model.rows <= 0)
|
||||
|
||||
@@ -1184,8 +1184,8 @@ public:
|
||||
parallel_for_(Range(0, 2), PrefilterInvoker(left0, right0, left, right, _buf, _buf + bufSize1, ¶ms), 1);
|
||||
|
||||
Rect validDisparityRect(0, 0, width, height), R1 = params.roi1, R2 = params.roi2;
|
||||
validDisparityRect = getValidDisparityROI(R1.area() > 0 ? Rect(0, 0, width, height) : validDisparityRect,
|
||||
R2.area() > 0 ? Rect(0, 0, width, height) : validDisparityRect,
|
||||
validDisparityRect = getValidDisparityROI(R1.area() > 0 ? R1 : validDisparityRect,
|
||||
R2.area() > 0 ? R2 : validDisparityRect,
|
||||
params.minDisparity, params.numDisparities,
|
||||
params.SADWindowSize);
|
||||
|
||||
|
||||
@@ -110,6 +110,7 @@ struct StereoSGBMParams
|
||||
int mode;
|
||||
};
|
||||
|
||||
static const int DEFAULT_RIGHT_BORDER = -1;
|
||||
/*
|
||||
For each pixel row1[x], max(maxD, 0) <= minX <= x < maxX <= width - max(0, -minD),
|
||||
and for each disparity minD<=d<maxD the function
|
||||
@@ -123,12 +124,20 @@ struct StereoSGBMParams
|
||||
static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
|
||||
int minD, int maxD, CostType* cost,
|
||||
PixType* buffer, const PixType* tab,
|
||||
int tabOfs, int )
|
||||
int tabOfs, int , int xrange_min = 0, int xrange_max = DEFAULT_RIGHT_BORDER )
|
||||
{
|
||||
int x, c, width = img1.cols, cn = img1.channels();
|
||||
int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
|
||||
int D = maxD - minD, width1 = maxX1 - minX1;
|
||||
//This minX1 & maxX2 correction is defining which part of calculatable line must be calculated
|
||||
//That is needs of parallel algorithm
|
||||
xrange_min = (xrange_min < 0) ? 0: xrange_min;
|
||||
xrange_max = (xrange_max == DEFAULT_RIGHT_BORDER) || (xrange_max > width1) ? width1 : xrange_max;
|
||||
maxX1 = minX1 + xrange_max;
|
||||
minX1 += xrange_min;
|
||||
width1 = maxX1 - minX1;
|
||||
int minX2 = std::max(minX1 - maxD, 0), maxX2 = std::min(maxX1 - minD, width);
|
||||
int D = maxD - minD, width1 = maxX1 - minX1, width2 = maxX2 - minX2;
|
||||
int width2 = maxX2 - minX2;
|
||||
const PixType *row1 = img1.ptr<PixType>(y), *row2 = img2.ptr<PixType>(y);
|
||||
PixType *prow1 = buffer + width2*2, *prow2 = prow1 + width*cn*2;
|
||||
#if CV_SIMD128
|
||||
@@ -179,10 +188,10 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
|
||||
}
|
||||
}
|
||||
|
||||
memset( cost, 0, width1*D*sizeof(cost[0]) );
|
||||
memset( cost + xrange_min*D, 0, width1*D*sizeof(cost[0]) );
|
||||
|
||||
buffer -= minX2;
|
||||
cost -= minX1*D + minD; // simplify the cost indices inside the loop
|
||||
buffer -= width-1-maxX2;
|
||||
cost -= (minX1-xrange_min)*D + minD; // simplify the cost indices inside the loop
|
||||
|
||||
for( c = 0; c < cn*2; c++, prow1 += width, prow2 += width )
|
||||
{
|
||||
@@ -191,7 +200,7 @@ static void calcPixelCostBT( const Mat& img1, const Mat& img2, int y,
|
||||
// precompute
|
||||
// v0 = min(row2[x-1/2], row2[x], row2[x+1/2]) and
|
||||
// v1 = max(row2[x-1/2], row2[x], row2[x+1/2]) and
|
||||
for( x = minX2; x < maxX2; x++ )
|
||||
for( x = width-1-maxX2; x < width-1- minX2; x++ )
|
||||
{
|
||||
int v = prow2[x];
|
||||
int vl = x > 0 ? (v + prow2[x-1])/2 : v;
|
||||
@@ -513,6 +522,7 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
||||
6: r=(1, -dy*2)
|
||||
7: r=(2, -dy)
|
||||
*/
|
||||
|
||||
for( x = x1; x != x2; x += dx )
|
||||
{
|
||||
int xm = x*NR2, xd = xm*D2;
|
||||
@@ -828,6 +838,512 @@ static void computeDisparitySGBM( const Mat& img1, const Mat& img2,
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////
|
||||
struct CalcVerticalSums: public ParallelLoopBody
|
||||
{
|
||||
CalcVerticalSums(const Mat& _img1, const Mat& _img2, const StereoSGBMParams& params,
|
||||
CostType* alignedBuf, PixType* _clipTab): img1(_img1), img2(_img2), clipTab(_clipTab)
|
||||
{
|
||||
minD = params.minDisparity;
|
||||
maxD = minD + params.numDisparities;
|
||||
SW2 = SH2 = (params.SADWindowSize > 0 ? params.SADWindowSize : 5)/2;
|
||||
ftzero = std::max(params.preFilterCap, 15) | 1;
|
||||
P1 = params.P1 > 0 ? params.P1 : 2;
|
||||
P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1);
|
||||
height = img1.rows;
|
||||
width = img1.cols;
|
||||
int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
|
||||
D = maxD - minD;
|
||||
width1 = maxX1 - minX1;
|
||||
D2 = D + 16;
|
||||
costBufSize = width1*D;
|
||||
CSBufSize = costBufSize*height;
|
||||
minLrSize = width1;
|
||||
LrSize = minLrSize*D2;
|
||||
hsumBufNRows = SH2*2 + 2;
|
||||
Cbuf = alignedBuf;
|
||||
Sbuf = Cbuf + CSBufSize;
|
||||
hsumBuf = Sbuf + CSBufSize;
|
||||
}
|
||||
|
||||
void operator()( const Range& range ) const
|
||||
{
|
||||
static const CostType MAX_COST = SHRT_MAX;
|
||||
static const int ALIGN = 16;
|
||||
static const int TAB_OFS = 256*4;
|
||||
static const int npasses = 2;
|
||||
int x1 = range.start, x2 = range.end, k;
|
||||
size_t pixDiffSize = ((x2 - x1) + 2*SW2)*D;
|
||||
size_t auxBufsSize = pixDiffSize*sizeof(CostType) + //pixdiff size
|
||||
width*16*img1.channels()*sizeof(PixType) + 32; //tempBuf
|
||||
Mat auxBuff;
|
||||
auxBuff.create(1, (int)auxBufsSize, CV_8U);
|
||||
CostType* pixDiff = (CostType*)alignPtr(auxBuff.ptr(), ALIGN);
|
||||
PixType* tempBuf = (PixType*)(pixDiff + pixDiffSize);
|
||||
|
||||
// Simplification of index calculation
|
||||
pixDiff -= (x1>SW2 ? (x1 - SW2): 0)*D;
|
||||
|
||||
for( int pass = 1; pass <= npasses; pass++ )
|
||||
{
|
||||
int y1, y2, dy;
|
||||
|
||||
if( pass == 1 )
|
||||
{
|
||||
y1 = 0; y2 = height; dy = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
y1 = height-1; y2 = -1; dy = -1;
|
||||
}
|
||||
|
||||
CostType *Lr[NLR]={0}, *minLr[NLR]={0};
|
||||
|
||||
for( k = 0; k < NLR; k++ )
|
||||
{
|
||||
// shift Lr[k] and minLr[k] pointers, because we allocated them with the borders,
|
||||
// and will occasionally use negative indices with the arrays
|
||||
// we need to shift Lr[k] pointers by 1, to give the space for d=-1.
|
||||
// however, then the alignment will be imperfect, i.e. bad for SSE,
|
||||
// thus we shift the pointers by 8 (8*sizeof(short) == 16 - ideal alignment)
|
||||
Lr[k] = hsumBuf + costBufSize*hsumBufNRows + LrSize*k + 8;
|
||||
memset( Lr[k] + x1*D2 - 8, 0, (x2-x1)*D2*sizeof(CostType) );
|
||||
minLr[k] = hsumBuf + costBufSize*hsumBufNRows + LrSize*NLR + minLrSize*k;
|
||||
memset( minLr[k] + x1, 0, (x2-x1)*sizeof(CostType) );
|
||||
}
|
||||
|
||||
for( int y = y1; y != y2; y += dy )
|
||||
{
|
||||
int x, d;
|
||||
CostType* C = Cbuf + y*costBufSize;
|
||||
CostType* S = Sbuf + y*costBufSize;
|
||||
|
||||
if( pass == 1 ) // compute C on the first pass, and reuse it on the second pass, if any.
|
||||
{
|
||||
int dy1 = y == 0 ? 0 : y + SH2, dy2 = y == 0 ? SH2 : dy1;
|
||||
|
||||
for( k = dy1; k <= dy2; k++ )
|
||||
{
|
||||
CostType* hsumAdd = hsumBuf + (std::min(k, height-1) % hsumBufNRows)*costBufSize;
|
||||
|
||||
if( k < height )
|
||||
{
|
||||
calcPixelCostBT( img1, img2, k, minD, maxD, pixDiff, tempBuf, clipTab, TAB_OFS, ftzero, x1 - SW2, x2 + SW2);
|
||||
|
||||
memset(hsumAdd + x1*D, 0, D*sizeof(CostType));
|
||||
for( x = (x1 - SW2)*D; x <= (x1 + SW2)*D; x += D )
|
||||
{
|
||||
int xbord = x <= 0 ? 0 : (x > (width1 - 1)*D? (width1 - 1)*D : x);
|
||||
for( d = 0; d < D; d++ )
|
||||
hsumAdd[x1*D + d] = (CostType)(hsumAdd[x1*D + d] + pixDiff[xbord + d]);
|
||||
}
|
||||
|
||||
if( y > 0 )
|
||||
{
|
||||
const CostType* hsumSub = hsumBuf + (std::max(y - SH2 - 1, 0) % hsumBufNRows)*costBufSize;
|
||||
const CostType* Cprev = C - costBufSize;
|
||||
|
||||
for( d = 0; d < D; d++ )
|
||||
C[x1*D + d] = (CostType)(Cprev[x1*D + d] + hsumAdd[x1*D + d] - hsumSub[x1*D + d]);
|
||||
|
||||
for( x = (x1+1)*D; x < x2*D; x += D )
|
||||
{
|
||||
const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D);
|
||||
const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0);
|
||||
|
||||
{
|
||||
for( d = 0; d < D; d++ )
|
||||
{
|
||||
int hv = hsumAdd[x + d] = (CostType)(hsumAdd[x - D + d] + pixAdd[d] - pixSub[d]);
|
||||
C[x + d] = (CostType)(Cprev[x + d] + hv - hsumSub[x + d]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for( x = (x1+1)*D; x < x2*D; x += D )
|
||||
{
|
||||
const CostType* pixAdd = pixDiff + std::min(x + SW2*D, (width1-1)*D);
|
||||
const CostType* pixSub = pixDiff + std::max(x - (SW2+1)*D, 0);
|
||||
|
||||
for( d = 0; d < D; d++ )
|
||||
hsumAdd[x + d] = (CostType)(hsumAdd[x - D + d] + pixAdd[d] - pixSub[d]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( y == 0 )
|
||||
{
|
||||
int scale = k == 0 ? SH2 + 1 : 1;
|
||||
for( x = x1*D; x < x2*D; x++ )
|
||||
C[x] = (CostType)(C[x] + hsumAdd[x]*scale);
|
||||
}
|
||||
}
|
||||
|
||||
// also, clear the S buffer
|
||||
for( k = x1*D; k < x2*D; k++ )
|
||||
S[k] = 0;
|
||||
}
|
||||
|
||||
// [formula 13 in the paper]
|
||||
// compute L_r(p, d) = C(p, d) +
|
||||
// min(L_r(p-r, d),
|
||||
// L_r(p-r, d-1) + P1,
|
||||
// L_r(p-r, d+1) + P1,
|
||||
// min_k L_r(p-r, k) + P2) - min_k L_r(p-r, k)
|
||||
// where p = (x,y), r is one of the directions.
|
||||
// we process one directions on first pass and other on second:
|
||||
// r=(0, dy), where dy=1 on first pass and dy=-1 on second
|
||||
|
||||
for( x = x1; x != x2; x++ )
|
||||
{
|
||||
int xd = x*D2;
|
||||
|
||||
int delta = minLr[1][x] + P2;
|
||||
|
||||
CostType* Lr_ppr = Lr[1] + xd;
|
||||
|
||||
Lr_ppr[-1] = Lr_ppr[D] = MAX_COST;
|
||||
|
||||
CostType* Lr_p = Lr[0] + xd;
|
||||
const CostType* Cp = C + x*D;
|
||||
CostType* Sp = S + x*D;
|
||||
|
||||
{
|
||||
int minL = MAX_COST;
|
||||
|
||||
for( d = 0; d < D; d++ )
|
||||
{
|
||||
int Cpd = Cp[d], L;
|
||||
|
||||
L = Cpd + std::min((int)Lr_ppr[d], std::min(Lr_ppr[d-1] + P1, std::min(Lr_ppr[d+1] + P1, delta))) - delta;
|
||||
|
||||
Lr_p[d] = (CostType)L;
|
||||
minL = std::min(minL, L);
|
||||
|
||||
Sp[d] = saturate_cast<CostType>(Sp[d] + L);
|
||||
}
|
||||
minLr[0][x] = (CostType)minL;
|
||||
}
|
||||
}
|
||||
|
||||
// now shift the cyclic buffers
|
||||
std::swap( Lr[0], Lr[1] );
|
||||
std::swap( minLr[0], minLr[1] );
|
||||
}
|
||||
}
|
||||
}
|
||||
static const int NLR = 2;
|
||||
const Mat& img1;
|
||||
const Mat& img2;
|
||||
CostType* Cbuf;
|
||||
CostType* Sbuf;
|
||||
CostType* hsumBuf;
|
||||
PixType* clipTab;
|
||||
int minD;
|
||||
int maxD;
|
||||
int D;
|
||||
int D2;
|
||||
int SH2;
|
||||
int SW2;
|
||||
int width;
|
||||
int width1;
|
||||
int height;
|
||||
int P1;
|
||||
int P2;
|
||||
size_t costBufSize;
|
||||
size_t CSBufSize;
|
||||
size_t minLrSize;
|
||||
size_t LrSize;
|
||||
size_t hsumBufNRows;
|
||||
int ftzero;
|
||||
};
|
||||
|
||||
struct CalcHorizontalSums: public ParallelLoopBody
|
||||
{
|
||||
CalcHorizontalSums(const Mat& _img1, const Mat& _img2, Mat& _disp1, const StereoSGBMParams& params,
|
||||
CostType* alignedBuf): img1(_img1), img2(_img2), disp1(_disp1)
|
||||
{
|
||||
minD = params.minDisparity;
|
||||
maxD = minD + params.numDisparities;
|
||||
P1 = params.P1 > 0 ? params.P1 : 2;
|
||||
P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1);
|
||||
uniquenessRatio = params.uniquenessRatio >= 0 ? params.uniquenessRatio : 10;
|
||||
disp12MaxDiff = params.disp12MaxDiff > 0 ? params.disp12MaxDiff : 1;
|
||||
height = img1.rows;
|
||||
width = img1.cols;
|
||||
minX1 = std::max(maxD, 0);
|
||||
maxX1 = width + std::min(minD, 0);
|
||||
INVALID_DISP = minD - 1;
|
||||
INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;
|
||||
D = maxD - minD;
|
||||
width1 = maxX1 - minX1;
|
||||
costBufSize = width1*D;
|
||||
CSBufSize = costBufSize*height;
|
||||
D2 = D + 16;
|
||||
LrSize = 2 * D2;
|
||||
Cbuf = alignedBuf;
|
||||
Sbuf = Cbuf + CSBufSize;
|
||||
}
|
||||
|
||||
void operator()( const Range& range ) const
|
||||
{
|
||||
int y1 = range.start, y2 = range.end;
|
||||
size_t auxBufsSize = LrSize * sizeof(CostType) + width*(sizeof(CostType) + sizeof(DispType)) + 32;
|
||||
|
||||
Mat auxBuff;
|
||||
auxBuff.create(1, (int)auxBufsSize, CV_8U);
|
||||
CostType *Lr = ((CostType*)alignPtr(auxBuff.ptr(), ALIGN)) + 8;
|
||||
CostType* disp2cost = Lr + LrSize;
|
||||
DispType* disp2ptr = (DispType*)(disp2cost + width);
|
||||
|
||||
CostType minLr;
|
||||
|
||||
for( int y = y1; y != y2; y++)
|
||||
{
|
||||
int x, d;
|
||||
DispType* disp1ptr = disp1.ptr<DispType>(y);
|
||||
CostType* C = Cbuf + y*costBufSize;
|
||||
CostType* S = Sbuf + y*costBufSize;
|
||||
|
||||
for( x = 0; x < width; x++ )
|
||||
{
|
||||
disp1ptr[x] = disp2ptr[x] = (DispType)INVALID_DISP_SCALED;
|
||||
disp2cost[x] = MAX_COST;
|
||||
}
|
||||
|
||||
// clear buffers
|
||||
memset( Lr - 8, 0, LrSize*sizeof(CostType) );
|
||||
Lr[-1] = Lr[D] = Lr[D2 - 1] = Lr[D2 + D] = MAX_COST;
|
||||
|
||||
minLr = 0;
|
||||
// [formula 13 in the paper]
|
||||
// compute L_r(p, d) = C(p, d) +
|
||||
// min(L_r(p-r, d),
|
||||
// L_r(p-r, d-1) + P1,
|
||||
// L_r(p-r, d+1) + P1,
|
||||
// min_k L_r(p-r, k) + P2) - min_k L_r(p-r, k)
|
||||
// where p = (x,y), r is one of the directions.
|
||||
// we process all the directions at once:
|
||||
// we process one directions on first pass and other on second:
|
||||
// r=(dx, 0), where dx=1 on first pass and dx=-1 on second
|
||||
for( x = 0; x != width1; x++)
|
||||
{
|
||||
int delta = minLr + P2;
|
||||
|
||||
CostType* Lr_ppr = Lr + ((x&1)? 0 : D2);
|
||||
|
||||
CostType* Lr_p = Lr + ((x&1)? D2 :0);
|
||||
const CostType* Cp = C + x*D;
|
||||
CostType* Sp = S + x*D;
|
||||
|
||||
int minL = MAX_COST;
|
||||
|
||||
for( d = 0; d < D; d++ )
|
||||
{
|
||||
int Cpd = Cp[d], L;
|
||||
|
||||
L = Cpd + std::min((int)Lr_ppr[d], std::min(Lr_ppr[d-1] + P1, std::min(Lr_ppr[d+1] + P1, delta))) - delta;
|
||||
|
||||
Lr_p[d] = (CostType)L;
|
||||
minL = std::min(minL, L);
|
||||
|
||||
Sp[d] = saturate_cast<CostType>(Sp[d] + L);
|
||||
}
|
||||
minLr = (CostType)minL;
|
||||
}
|
||||
|
||||
memset( Lr - 8, 0, LrSize*sizeof(CostType) );
|
||||
Lr[-1] = Lr[D] = Lr[D2 - 1] = Lr[D2 + D] = MAX_COST;
|
||||
|
||||
minLr = 0;
|
||||
|
||||
for( x = width1-1; x != -1; x--)
|
||||
{
|
||||
int delta = minLr + P2;
|
||||
|
||||
CostType* Lr_ppr = Lr + ((x&1)? 0 :D2);
|
||||
|
||||
CostType* Lr_p = Lr + ((x&1)? D2 :0);
|
||||
const CostType* Cp = C + x*D;
|
||||
CostType* Sp = S + x*D;
|
||||
int minS = MAX_COST, bestDisp = -1;
|
||||
|
||||
int minL = MAX_COST;
|
||||
|
||||
for( d = 0; d < D; d++ )
|
||||
{
|
||||
int Cpd = Cp[d], L;
|
||||
|
||||
L = Cpd + std::min((int)Lr_ppr[d], std::min(Lr_ppr[d-1] + P1, std::min(Lr_ppr[d+1] + P1, delta))) - delta;
|
||||
|
||||
Lr_p[d] = (CostType)L;
|
||||
minL = std::min(minL, L);
|
||||
|
||||
Sp[d] = saturate_cast<CostType>(Sp[d] + L);
|
||||
if( Sp[d] < minS )
|
||||
{
|
||||
minS = Sp[d];
|
||||
bestDisp = d;
|
||||
}
|
||||
}
|
||||
minLr = (CostType)minL;
|
||||
//Some postprocessing procedures and saving
|
||||
for( d = 0; d < D; d++ )
|
||||
{
|
||||
if( Sp[d]*(100 - uniquenessRatio) < minS*100 && std::abs(bestDisp - d) > 1 )
|
||||
break;
|
||||
}
|
||||
if( d < D )
|
||||
continue;
|
||||
d = bestDisp;
|
||||
int _x2 = x + minX1 - d - minD;
|
||||
if( disp2cost[_x2] > minS )
|
||||
{
|
||||
disp2cost[_x2] = (CostType)minS;
|
||||
disp2ptr[_x2] = (DispType)(d + minD);
|
||||
}
|
||||
|
||||
if( 0 < d && d < D-1 )
|
||||
{
|
||||
// do subpixel quadratic interpolation:
|
||||
// fit parabola into (x1=d-1, y1=Sp[d-1]), (x2=d, y2=Sp[d]), (x3=d+1, y3=Sp[d+1])
|
||||
// then find minimum of the parabola.
|
||||
int denom2 = std::max(Sp[d-1] + Sp[d+1] - 2*Sp[d], 1);
|
||||
d = d*DISP_SCALE + ((Sp[d-1] - Sp[d+1])*DISP_SCALE + denom2)/(denom2*2);
|
||||
}
|
||||
else
|
||||
d *= DISP_SCALE;
|
||||
disp1ptr[x + minX1] = (DispType)(d + minD*DISP_SCALE);
|
||||
}
|
||||
//Left-right check sanity procedure
|
||||
for( x = minX1; x < maxX1; x++ )
|
||||
{
|
||||
// we round the computed disparity both towards -inf and +inf and check
|
||||
// if either of the corresponding disparities in disp2 is consistent.
|
||||
// This is to give the computed disparity a chance to look valid if it is.
|
||||
int d1 = disp1ptr[x];
|
||||
if( d1 == INVALID_DISP_SCALED )
|
||||
continue;
|
||||
int _d = d1 >> DISP_SHIFT;
|
||||
int d_ = (d1 + DISP_SCALE-1) >> DISP_SHIFT;
|
||||
int _x = x - _d, x_ = x - d_;
|
||||
if( 0 <= _x && _x < width && disp2ptr[_x] >= minD && std::abs(disp2ptr[_x] - _d) > disp12MaxDiff &&
|
||||
0 <= x_ && x_ < width && disp2ptr[x_] >= minD && std::abs(disp2ptr[x_] - d_) > disp12MaxDiff )
|
||||
disp1ptr[x] = (DispType)INVALID_DISP_SCALED;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static const int DISP_SHIFT = StereoMatcher::DISP_SHIFT;
|
||||
static const int DISP_SCALE = (1 << DISP_SHIFT);
|
||||
static const CostType MAX_COST = SHRT_MAX;
|
||||
static const int ALIGN = 16;
|
||||
const Mat& img1;
|
||||
const Mat& img2;
|
||||
Mat& disp1;
|
||||
CostType* Cbuf;
|
||||
CostType* Sbuf;
|
||||
int minD;
|
||||
int maxD;
|
||||
int D;
|
||||
int D2;
|
||||
int width;
|
||||
int width1;
|
||||
int height;
|
||||
int P1;
|
||||
int P2;
|
||||
int minX1;
|
||||
int maxX1;
|
||||
size_t costBufSize;
|
||||
size_t CSBufSize;
|
||||
size_t LrSize;
|
||||
int INVALID_DISP;
|
||||
int INVALID_DISP_SCALED;
|
||||
int uniquenessRatio;
|
||||
int disp12MaxDiff;
|
||||
};
|
||||
/*
|
||||
computes disparity for "roi" in img1 w.r.t. img2 and write it to disp1buf.
|
||||
that is, disp1buf(x, y)=d means that img1(x+roi.x, y+roi.y) ~ img2(x+roi.x-d, y+roi.y).
|
||||
minD <= d < maxD.
|
||||
|
||||
note that disp1buf will have the same size as the roi and
|
||||
On exit disp1buf is not the final disparity, it is an intermediate result that becomes
|
||||
final after all the tiles are processed.
|
||||
|
||||
the disparity in disp1buf is written with sub-pixel accuracy
|
||||
(4 fractional bits, see StereoSGBM::DISP_SCALE),
|
||||
using quadratic interpolation, while the disparity in disp2buf
|
||||
is written as is, without interpolation.
|
||||
*/
|
||||
static void computeDisparitySGBM_HH4( const Mat& img1, const Mat& img2,
|
||||
Mat& disp1, const StereoSGBMParams& params,
|
||||
Mat& buffer )
|
||||
{
|
||||
const int ALIGN = 16;
|
||||
const int DISP_SHIFT = StereoMatcher::DISP_SHIFT;
|
||||
const int DISP_SCALE = (1 << DISP_SHIFT);
|
||||
int minD = params.minDisparity, maxD = minD + params.numDisparities;
|
||||
Size SADWindowSize;
|
||||
SADWindowSize.width = SADWindowSize.height = params.SADWindowSize > 0 ? params.SADWindowSize : 5;
|
||||
int ftzero = std::max(params.preFilterCap, 15) | 1;
|
||||
int P1 = params.P1 > 0 ? params.P1 : 2, P2 = std::max(params.P2 > 0 ? params.P2 : 5, P1+1);
|
||||
int k, width = disp1.cols, height = disp1.rows;
|
||||
int minX1 = std::max(maxD, 0), maxX1 = width + std::min(minD, 0);
|
||||
int D = maxD - minD, width1 = maxX1 - minX1;
|
||||
int SH2 = SADWindowSize.height/2;
|
||||
int INVALID_DISP = minD - 1;
|
||||
int INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;
|
||||
const int TAB_OFS = 256*4, TAB_SIZE = 256 + TAB_OFS*2;
|
||||
PixType clipTab[TAB_SIZE];
|
||||
|
||||
for( k = 0; k < TAB_SIZE; k++ )
|
||||
clipTab[k] = (PixType)(std::min(std::max(k - TAB_OFS, -ftzero), ftzero) + ftzero);
|
||||
|
||||
if( minX1 >= maxX1 )
|
||||
{
|
||||
disp1 = Scalar::all(INVALID_DISP_SCALED);
|
||||
return;
|
||||
}
|
||||
|
||||
CV_Assert( D % 16 == 0 );
|
||||
|
||||
int D2 = D+16;
|
||||
|
||||
// the number of L_r(.,.) and min_k L_r(.,.) lines in the buffer:
|
||||
// for dynamic programming we need the current row and
|
||||
// the previous row, i.e. 2 rows in total
|
||||
const int NLR = 2;
|
||||
|
||||
// for each possible stereo match (img1(x,y) <=> img2(x-d,y))
|
||||
// we keep pixel difference cost (C) and the summary cost over 4 directions (S).
|
||||
// we also keep all the partial costs for the previous line L_r(x,d) and also min_k L_r(x, k)
|
||||
size_t costBufSize = width1*D;
|
||||
size_t CSBufSize = costBufSize*height;
|
||||
size_t minLrSize = width1 , LrSize = minLrSize*D2;
|
||||
int hsumBufNRows = SH2*2 + 2;
|
||||
size_t totalBufSize = (LrSize + minLrSize)*NLR*sizeof(CostType) + // minLr[] and Lr[]
|
||||
costBufSize*hsumBufNRows*sizeof(CostType) + // hsumBuf
|
||||
CSBufSize*2*sizeof(CostType) + 1024; // C, S
|
||||
|
||||
if( buffer.empty() || !buffer.isContinuous() ||
|
||||
buffer.cols*buffer.rows*buffer.elemSize() < totalBufSize )
|
||||
buffer.create(1, (int)totalBufSize, CV_8U);
|
||||
|
||||
// summary cost over different (nDirs) directions
|
||||
CostType* Cbuf = (CostType*)alignPtr(buffer.ptr(), ALIGN);
|
||||
|
||||
// add P2 to every C(x,y). it saves a few operations in the inner loops
|
||||
for(k = 0; k < (int)CSBufSize; k++ )
|
||||
Cbuf[k] = (CostType)P2;
|
||||
|
||||
parallel_for_(Range(0,width1),CalcVerticalSums(img1, img2, params, Cbuf, clipTab),8);
|
||||
parallel_for_(Range(0,height),CalcHorizontalSums(img1, img2, disp1, params, Cbuf),8);
|
||||
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void getBufferPointers(Mat& buffer, int width, int width1, int D, int num_ch, int SH2, int P2,
|
||||
@@ -1482,6 +1998,8 @@ public:
|
||||
|
||||
if(params.mode==MODE_SGBM_3WAY)
|
||||
computeDisparity3WaySGBM( left, right, disp, params, buffers, num_stripes );
|
||||
else if(params.mode==MODE_HH4)
|
||||
computeDisparitySGBM_HH4( left, right, disp, params, buffer );
|
||||
else
|
||||
computeDisparitySGBM( left, right, disp, params, buffer );
|
||||
|
||||
@@ -1705,43 +2223,37 @@ void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDif
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_filterSpeckles(Mat &img, int maxSpeckleSize, int newVal, int maxDiff)
|
||||
static bool ipp_filterSpeckles(Mat &img, int maxSpeckleSize, int newVal, int maxDiff, Mat &buffer)
|
||||
{
|
||||
#if IPP_VERSION_X100 >= 810
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
#if IPP_VERSION_X100 >= 810
|
||||
int type = img.type();
|
||||
Ipp32s bufsize = 0;
|
||||
IppiSize roisize = { img.cols, img.rows };
|
||||
IppDataType datatype = type == CV_8UC1 ? ipp8u : ipp16s;
|
||||
Ipp8u *pBuffer = NULL;
|
||||
IppStatus status = ippStsNoErr;
|
||||
IppDataType dataType = ippiGetDataType(img.depth());
|
||||
IppiSize size = ippiSize(img.size());
|
||||
int bufferSize;
|
||||
|
||||
if(ippiMarkSpecklesGetBufferSize(roisize, datatype, CV_MAT_CN(type), &bufsize) < 0)
|
||||
if(img.channels() != 1)
|
||||
return false;
|
||||
|
||||
pBuffer = (Ipp8u*)ippMalloc(bufsize);
|
||||
if(!pBuffer && bufsize)
|
||||
if(dataType != ipp8u && dataType != ipp16s)
|
||||
return false;
|
||||
|
||||
if (type == CV_8UC1)
|
||||
{
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_8u_C1IR, img.ptr<Ipp8u>(), (int)img.step, roisize,
|
||||
(Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, pBuffer);
|
||||
}
|
||||
else
|
||||
{
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_16s_C1IR, img.ptr<Ipp16s>(), (int)img.step, roisize,
|
||||
(Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, pBuffer);
|
||||
}
|
||||
if(pBuffer) ippFree(pBuffer);
|
||||
if(ippiMarkSpecklesGetBufferSize(size, dataType, 1, &bufferSize) < 0)
|
||||
return false;
|
||||
|
||||
if (status >= 0)
|
||||
return true;
|
||||
if(bufferSize && (buffer.empty() || (int)(buffer.step*buffer.rows) < bufferSize))
|
||||
buffer.create(1, (int)bufferSize, CV_8U);
|
||||
|
||||
switch(dataType)
|
||||
{
|
||||
case ipp8u: return CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_8u_C1IR, img.ptr<Ipp8u>(), (int)img.step, size, (Ipp8u)newVal, maxSpeckleSize, (Ipp8u)maxDiff, ippiNormL1, buffer.ptr<Ipp8u>()) >= 0;
|
||||
case ipp16s: return CV_INSTRUMENT_FUN_IPP(ippiMarkSpeckles_16s_C1IR, img.ptr<Ipp16s>(), (int)img.step, size, (Ipp16s)newVal, maxSpeckleSize, (Ipp16s)maxDiff, ippiNormL1, buffer.ptr<Ipp8u>()) >= 0;
|
||||
default: return false;
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(img); CV_UNUSED(maxSpeckleSize); CV_UNUSED(newVal); CV_UNUSED(maxDiff);
|
||||
#endif
|
||||
CV_UNUSED(img); CV_UNUSED(maxSpeckleSize); CV_UNUSED(newVal); CV_UNUSED(maxDiff); CV_UNUSED(buffer);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1759,7 +2271,7 @@ void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSi
|
||||
|
||||
int newVal = cvRound(_newval), maxDiff = cvRound(_maxDiff);
|
||||
|
||||
CV_IPP_RUN(IPP_VERSION_X100 >= 810 && !__buf.needed() && (type == CV_8UC1 || type == CV_16SC1), ipp_filterSpeckles(img, maxSpeckleSize, newVal, maxDiff));
|
||||
CV_IPP_RUN_FAST(ipp_filterSpeckles(img, maxSpeckleSize, newVal, maxDiff, _buf));
|
||||
|
||||
if (type == CV_8UC1)
|
||||
filterSpecklesImpl<uchar>(img, newVal, maxSpeckleSize, maxDiff, _buf);
|
||||
|
||||
@@ -1570,7 +1570,8 @@ void CV_StereoCalibrationTest::run( int )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "The file %s can not be opened or has invalid content\n", filepath.c_str() );
|
||||
ts->set_failed_test_info( f ? cvtest::TS::FAIL_INVALID_TEST_DATA : cvtest::TS::FAIL_MISSING_TEST_DATA );
|
||||
fclose(f);
|
||||
if (f)
|
||||
fclose(f);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -245,13 +245,13 @@ TEST_F(fisheyeTest, Calibration)
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
int flag = 0;
|
||||
@@ -280,13 +280,13 @@ TEST_F(fisheyeTest, Homography)
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::internal::IntrinsicParams param;
|
||||
@@ -330,7 +330,7 @@ TEST_F(fisheyeTest, Homography)
|
||||
EXPECT_MAT_NEAR(std_err, correct_std_err, 1e-12);
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, EtimateUncertainties)
|
||||
TEST_F(fisheyeTest, EstimateUncertainties)
|
||||
{
|
||||
const int n_images = 34;
|
||||
|
||||
@@ -341,13 +341,13 @@ TEST_F(fisheyeTest, EtimateUncertainties)
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left[cv::format("image_%d", i )] >> imagePoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
int flag = 0;
|
||||
@@ -435,9 +435,9 @@ TEST_F(fisheyeTest, rectify)
|
||||
|
||||
if (correct.empty())
|
||||
cv::imwrite(combine(datasets_repository_path, cv::format("rectification_AB_%03d.png", i)), rectification);
|
||||
else
|
||||
EXPECT_MAT_NEAR(correct, rectification, 1e-10);
|
||||
}
|
||||
else
|
||||
EXPECT_MAT_NEAR(correct, rectification, 1e-10);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_F(fisheyeTest, stereoCalibrate)
|
||||
@@ -453,19 +453,19 @@ TEST_F(fisheyeTest, stereoCalibrate)
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> leftPoints[i];
|
||||
fs_left[cv::format("image_%d", i )] >> leftPoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_right(combine(folder, "right.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_right.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_right[cv::format("image_%d", i )] >> rightPoints[i];
|
||||
fs_right[cv::format("image_%d", i )] >> rightPoints[i];
|
||||
fs_right.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::Matx33d K1, K2, theR;
|
||||
@@ -476,7 +476,6 @@ TEST_F(fisheyeTest, stereoCalibrate)
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
flag |= cv::fisheye::CALIB_CHECK_COND;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
// flag |= cv::fisheye::CALIB_FIX_INTRINSIC;
|
||||
|
||||
cv::fisheye::stereoCalibrate(objectPoints, leftPoints, rightPoints,
|
||||
K1, D1, K2, D2, imageSize, theR, theT, flag,
|
||||
@@ -521,19 +520,19 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
|
||||
cv::FileStorage fs_left(combine(folder, "left.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_left.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_left[cv::format("image_%d", i )] >> leftPoints[i];
|
||||
fs_left[cv::format("image_%d", i )] >> leftPoints[i];
|
||||
fs_left.release();
|
||||
|
||||
cv::FileStorage fs_right(combine(folder, "right.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_right.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_right[cv::format("image_%d", i )] >> rightPoints[i];
|
||||
fs_right[cv::format("image_%d", i )] >> rightPoints[i];
|
||||
fs_right.release();
|
||||
|
||||
cv::FileStorage fs_object(combine(folder, "object.xml"), cv::FileStorage::READ);
|
||||
CV_Assert(fs_object.isOpened());
|
||||
for(int i = 0; i < n_images; ++i)
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object[cv::format("image_%d", i )] >> objectPoints[i];
|
||||
fs_object.release();
|
||||
|
||||
cv::Matx33d theR;
|
||||
@@ -572,44 +571,44 @@ TEST_F(fisheyeTest, stereoCalibrateFixIntrinsic)
|
||||
|
||||
TEST_F(fisheyeTest, CalibrationWithDifferentPointsNumber)
|
||||
{
|
||||
const int n_images = 2;
|
||||
const int n_images = 2;
|
||||
|
||||
std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
|
||||
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
|
||||
std::vector<std::vector<cv::Point2d> > imagePoints(n_images);
|
||||
std::vector<std::vector<cv::Point3d> > objectPoints(n_images);
|
||||
|
||||
std::vector<cv::Point2d> imgPoints1(10);
|
||||
std::vector<cv::Point2d> imgPoints2(15);
|
||||
std::vector<cv::Point2d> imgPoints1(10);
|
||||
std::vector<cv::Point2d> imgPoints2(15);
|
||||
|
||||
std::vector<cv::Point3d> objectPoints1(imgPoints1.size());
|
||||
std::vector<cv::Point3d> objectPoints2(imgPoints2.size());
|
||||
std::vector<cv::Point3d> objectPoints1(imgPoints1.size());
|
||||
std::vector<cv::Point3d> objectPoints2(imgPoints2.size());
|
||||
|
||||
for (size_t i = 0; i < imgPoints1.size(); i++)
|
||||
{
|
||||
imgPoints1[i] = cv::Point2d((double)i, (double)i);
|
||||
objectPoints1[i] = cv::Point3d((double)i, (double)i, 10.0);
|
||||
}
|
||||
for (size_t i = 0; i < imgPoints1.size(); i++)
|
||||
{
|
||||
imgPoints1[i] = cv::Point2d((double)i, (double)i);
|
||||
objectPoints1[i] = cv::Point3d((double)i, (double)i, 10.0);
|
||||
}
|
||||
|
||||
for (size_t i = 0; i < imgPoints2.size(); i++)
|
||||
{
|
||||
imgPoints2[i] = cv::Point2d(i + 0.5, i + 0.5);
|
||||
objectPoints2[i] = cv::Point3d(i + 0.5, i + 0.5, 10.0);
|
||||
}
|
||||
for (size_t i = 0; i < imgPoints2.size(); i++)
|
||||
{
|
||||
imgPoints2[i] = cv::Point2d(i + 0.5, i + 0.5);
|
||||
objectPoints2[i] = cv::Point3d(i + 0.5, i + 0.5, 10.0);
|
||||
}
|
||||
|
||||
imagePoints[0] = imgPoints1;
|
||||
imagePoints[1] = imgPoints2;
|
||||
objectPoints[0] = objectPoints1;
|
||||
objectPoints[1] = objectPoints2;
|
||||
imagePoints[0] = imgPoints1;
|
||||
imagePoints[1] = imgPoints2;
|
||||
objectPoints[0] = objectPoints1;
|
||||
objectPoints[1] = objectPoints2;
|
||||
|
||||
cv::Matx33d theK = cv::Matx33d::eye();
|
||||
cv::Vec4d theD;
|
||||
cv::Matx33d theK = cv::Matx33d::eye();
|
||||
cv::Vec4d theD;
|
||||
|
||||
int flag = 0;
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
flag |= cv::fisheye::CALIB_USE_INTRINSIC_GUESS;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
int flag = 0;
|
||||
flag |= cv::fisheye::CALIB_RECOMPUTE_EXTRINSIC;
|
||||
flag |= cv::fisheye::CALIB_USE_INTRINSIC_GUESS;
|
||||
flag |= cv::fisheye::CALIB_FIX_SKEW;
|
||||
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, cv::Size(100, 100), theK, theD,
|
||||
cv::noArray(), cv::noArray(), flag, cv::TermCriteria(3, 20, 1e-6));
|
||||
cv::fisheye::calibrate(objectPoints, imagePoints, cv::Size(100, 100), theK, theD,
|
||||
cv::noArray(), cv::noArray(), flag, cv::TermCriteria(3, 20, 1e-6));
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -57,6 +57,7 @@ public:
|
||||
eps[SOLVEPNP_ITERATIVE] = 1.0e-2;
|
||||
eps[SOLVEPNP_EPNP] = 1.0e-2;
|
||||
eps[SOLVEPNP_P3P] = 1.0e-2;
|
||||
eps[SOLVEPNP_AP3P] = 1.0e-2;
|
||||
eps[SOLVEPNP_DLS] = 1.0e-2;
|
||||
eps[SOLVEPNP_UPNP] = 1.0e-2;
|
||||
totalTestsCount = 10;
|
||||
@@ -161,7 +162,7 @@ protected:
|
||||
points.resize(pointsCount);
|
||||
generate3DPointCloud(points);
|
||||
|
||||
const int methodsCount = 5;
|
||||
const int methodsCount = 6;
|
||||
RNG rng = ts->get_rng();
|
||||
|
||||
|
||||
@@ -189,7 +190,7 @@ protected:
|
||||
}
|
||||
}
|
||||
}
|
||||
double eps[5];
|
||||
double eps[6];
|
||||
int totalTestsCount;
|
||||
};
|
||||
|
||||
@@ -201,6 +202,7 @@ public:
|
||||
eps[SOLVEPNP_ITERATIVE] = 1.0e-6;
|
||||
eps[SOLVEPNP_EPNP] = 1.0e-6;
|
||||
eps[SOLVEPNP_P3P] = 1.0e-4;
|
||||
eps[SOLVEPNP_AP3P] = 1.0e-4;
|
||||
eps[SOLVEPNP_DLS] = 1.0e-4;
|
||||
eps[SOLVEPNP_UPNP] = 1.0e-4;
|
||||
totalTestsCount = 1000;
|
||||
@@ -222,7 +224,7 @@ protected:
|
||||
generatePose(trueRvec, trueTvec, rng);
|
||||
|
||||
std::vector<Point3f> opoints;
|
||||
if (method == 2)
|
||||
if (method == 2 || method == 5)
|
||||
{
|
||||
opoints = std::vector<Point3f>(points.begin(), points.begin()+4);
|
||||
}
|
||||
|
||||
@@ -784,3 +784,22 @@ protected:
|
||||
|
||||
TEST(Calib3d_StereoBM, regression) { CV_StereoBMTest test; test.safe_run(); }
|
||||
TEST(Calib3d_StereoSGBM, regression) { CV_StereoSGBMTest test; test.safe_run(); }
|
||||
|
||||
TEST(Calib3d_StereoSGBM_HH4, regression)
|
||||
{
|
||||
String path = cvtest::TS::ptr()->get_data_path() + "cv/stereomatching/datasets/teddy/";
|
||||
Mat leftImg = imread(path + "im2.png", 0);
|
||||
Mat rightImg = imread(path + "im6.png", 0);
|
||||
Mat testData = imread(path + "disp2_hh4.png",-1);
|
||||
Mat leftDisp;
|
||||
Mat toCheck;
|
||||
{
|
||||
Ptr<StereoSGBM> sgbm = StereoSGBM::create( 0, 48, 3, 90, 360, 1, 63, 10, 100, 32, StereoSGBM::MODE_HH4);
|
||||
sgbm->compute( leftImg, rightImg, leftDisp);
|
||||
CV_Assert( leftDisp.type() == CV_16SC1 );
|
||||
leftDisp.convertTo(toCheck, CV_16UC1,1,16);
|
||||
}
|
||||
Mat diff;
|
||||
absdiff(toCheck, testData,diff);
|
||||
CV_Assert( countNonZero(diff)==0);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
set(the_description "The Core Functionality")
|
||||
|
||||
ocv_add_dispatched_file(mathfuncs_core SSE2 AVX AVX2)
|
||||
|
||||
ocv_add_module(core
|
||||
"${OPENCV_HAL_LINKER_LIBS}"
|
||||
OPTIONAL opencv_cudev
|
||||
|
||||
@@ -2762,7 +2762,7 @@ public:
|
||||
double a1 = rng.uniform((double)0, (double)1);
|
||||
|
||||
// produces float from [0, 1)
|
||||
double b = rng.uniform(0.f, 1.f);
|
||||
float b = rng.uniform(0.f, 1.f);
|
||||
|
||||
// produces double from [0, 1)
|
||||
double c = rng.uniform(0., 1.);
|
||||
@@ -2778,8 +2778,8 @@ public:
|
||||
want a floating-point random number, but the range boundaries are
|
||||
integer numbers, either put dots in the end, if they are constants, or
|
||||
use explicit type cast operators, as in the a1 initialization above.
|
||||
@param a lower inclusive boundary of the returned random numbers.
|
||||
@param b upper non-inclusive boundary of the returned random numbers.
|
||||
@param a lower inclusive boundary of the returned random number.
|
||||
@param b upper non-inclusive boundary of the returned random number.
|
||||
*/
|
||||
int uniform(int a, int b);
|
||||
/** @overload */
|
||||
|
||||
@@ -213,11 +213,13 @@ cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
|
||||
{
|
||||
rotation(data(Rect(0, 0, 3, 3)));
|
||||
translation(data(Rect(3, 0, 1, 3)));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
rotation(data);
|
||||
translation(t);
|
||||
}
|
||||
|
||||
rotation(data);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
@@ -73,30 +73,30 @@ enum Code {
|
||||
StsNoMem= -4, //!< insufficient memory
|
||||
StsBadArg= -5, //!< function arg/param is bad
|
||||
StsBadFunc= -6, //!< unsupported function
|
||||
StsNoConv= -7, //!< iter. didn't converge
|
||||
StsNoConv= -7, //!< iteration didn't converge
|
||||
StsAutoTrace= -8, //!< tracing
|
||||
HeaderIsNull= -9, //!< image header is NULL
|
||||
BadImageSize= -10, //!< image size is invalid
|
||||
BadOffset= -11, //!< offset is invalid
|
||||
BadDataPtr= -12, //!<
|
||||
BadStep= -13, //!<
|
||||
BadStep= -13, //!< image step is wrong, this may happen for a non-continuous matrix.
|
||||
BadModelOrChSeq= -14, //!<
|
||||
BadNumChannels= -15, //!<
|
||||
BadNumChannels= -15, //!< bad number of channels, for example, some functions accept only single channel matrices.
|
||||
BadNumChannel1U= -16, //!<
|
||||
BadDepth= -17, //!<
|
||||
BadDepth= -17, //!< input image depth is not supported by the function
|
||||
BadAlphaChannel= -18, //!<
|
||||
BadOrder= -19, //!<
|
||||
BadOrigin= -20, //!<
|
||||
BadAlign= -21, //!<
|
||||
BadOrder= -19, //!< number of dimensions is out of range
|
||||
BadOrigin= -20, //!< incorrect input origin
|
||||
BadAlign= -21, //!< incorrect input align
|
||||
BadCallBack= -22, //!<
|
||||
BadTileSize= -23, //!<
|
||||
BadCOI= -24, //!<
|
||||
BadROISize= -25, //!<
|
||||
BadCOI= -24, //!< input COI is not supported
|
||||
BadROISize= -25, //!< incorrect input roi
|
||||
MaskIsTiled= -26, //!<
|
||||
StsNullPtr= -27, //!< null pointer
|
||||
StsVecLengthErr= -28, //!< incorrect vector length
|
||||
StsFilterStructContentErr= -29, //!< incorr. filter structure content
|
||||
StsKernelStructContentErr= -30, //!< incorr. transform kernel content
|
||||
StsFilterStructContentErr= -29, //!< incorrect filter structure content
|
||||
StsKernelStructContentErr= -30, //!< incorrect transform kernel content
|
||||
StsFilterOffsetErr= -31, //!< incorrect filter offset value
|
||||
StsBadSize= -201, //!< the input/output structure size is incorrect
|
||||
StsDivByZero= -202, //!< division by zero
|
||||
@@ -113,13 +113,13 @@ enum Code {
|
||||
StsNotImplemented= -213, //!< the requested function/feature is not implemented
|
||||
StsBadMemBlock= -214, //!< an allocated block has been corrupted
|
||||
StsAssert= -215, //!< assertion failed
|
||||
GpuNotSupported= -216,
|
||||
GpuApiCallError= -217,
|
||||
OpenGlNotSupported= -218,
|
||||
OpenGlApiCallError= -219,
|
||||
OpenCLApiCallError= -220,
|
||||
GpuNotSupported= -216, //!< no CUDA support
|
||||
GpuApiCallError= -217, //!< GPU API call error
|
||||
OpenGlNotSupported= -218, //!< no OpenGL support
|
||||
OpenGlApiCallError= -219, //!< OpenGL API call error
|
||||
OpenCLApiCallError= -220, //!< OpenCL API call error
|
||||
OpenCLDoubleNotSupported= -221,
|
||||
OpenCLInitError= -222,
|
||||
OpenCLInitError= -222, //!< OpenCL initialization error
|
||||
OpenCLNoAMDBlasFft= -223
|
||||
};
|
||||
} //Error
|
||||
@@ -239,6 +239,10 @@ enum DftFlags {
|
||||
into a real array and inverse transformation is executed, the function treats the input as a
|
||||
packed complex-conjugate symmetrical array, and the output will also be a real array). */
|
||||
DFT_REAL_OUTPUT = 32,
|
||||
/** specifies that input is complex input. If this flag is set, the input must have 2 channels.
|
||||
On the other hand, for backwards compatibility reason, if input has 2 channels, input is
|
||||
already considered complex. */
|
||||
DFT_COMPLEX_INPUT = 64,
|
||||
/** performs an inverse 1D or 2D transform instead of the default forward transform. */
|
||||
DCT_INVERSE = DFT_INVERSE,
|
||||
/** performs a forward or inverse transform of every individual row of the input
|
||||
@@ -667,7 +671,11 @@ namespace cudev
|
||||
|
||||
namespace ipp
|
||||
{
|
||||
#if OPENCV_ABI_COMPATIBILITY > 300
|
||||
CV_EXPORTS unsigned long long getIppFeatures();
|
||||
#else
|
||||
CV_EXPORTS int getIppFeatures();
|
||||
#endif
|
||||
CV_EXPORTS void setIppStatus(int status, const char * const funcname = NULL, const char * const filename = NULL,
|
||||
int line = 0);
|
||||
CV_EXPORTS int getIppStatus();
|
||||
|
||||
@@ -327,6 +327,34 @@ The function does not reallocate memory if the matrix has proper attributes alre
|
||||
*/
|
||||
CV_EXPORTS void ensureSizeIsEnough(int rows, int cols, int type, OutputArray arr);
|
||||
|
||||
/** @brief BufferPool for use with CUDA streams
|
||||
|
||||
* BufferPool utilizes cuda::Stream's allocator to create new buffers. It is
|
||||
* particularly useful when BufferPoolUsage is set to true, or a custom
|
||||
* allocator is specified for the cuda::Stream, and you want to implement your
|
||||
* own stream based functions utilizing the same underlying GPU memory
|
||||
* management.
|
||||
*/
|
||||
class CV_EXPORTS BufferPool
|
||||
{
|
||||
public:
|
||||
|
||||
//! Gets the BufferPool for the given stream.
|
||||
explicit BufferPool(Stream& stream);
|
||||
|
||||
//! Allocates a new GpuMat of given size and type.
|
||||
GpuMat getBuffer(int rows, int cols, int type);
|
||||
|
||||
//! Allocates a new GpuMat of given size and type.
|
||||
GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); }
|
||||
|
||||
//! Returns the allocator associated with the stream.
|
||||
Ptr<GpuMat::Allocator> getAllocator() const { return allocator_; }
|
||||
|
||||
private:
|
||||
Ptr<GpuMat::Allocator> allocator_;
|
||||
};
|
||||
|
||||
//! BufferPool management (must be called before Stream creation)
|
||||
CV_EXPORTS void setBufferPoolUsage(bool on);
|
||||
CV_EXPORTS void setBufferPoolConfig(int deviceId, size_t stackSize, int stackCount);
|
||||
@@ -479,6 +507,9 @@ public:
|
||||
//! creates a new asynchronous stream
|
||||
Stream();
|
||||
|
||||
//! creates a new asynchronous stream with custom allocator
|
||||
Stream(const Ptr<GpuMat::Allocator>& allocator);
|
||||
|
||||
/** @brief Returns true if the current stream queue is finished. Otherwise, it returns false.
|
||||
*/
|
||||
bool queryIfComplete() const;
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace cv { namespace cuda { namespace device
|
||||
static __device__ __forceinline__ unsigned int laneId()
|
||||
{
|
||||
unsigned int ret;
|
||||
asm("mov.u32 %0, %laneid;" : "=r"(ret) );
|
||||
asm("mov.u32 %0, %%laneid;" : "=r"(ret) );
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,200 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#if defined __OPENCV_BUILD \
|
||||
|
||||
#include "cv_cpu_config.h"
|
||||
#include "cv_cpu_helper.h"
|
||||
|
||||
#ifdef CV_CPU_DISPATCH_MODE
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE __CV_CAT(opt_, CV_CPU_DISPATCH_MODE)
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) {
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
|
||||
#else
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE cpu_baseline
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace cpu_baseline {
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
|
||||
#endif
|
||||
|
||||
|
||||
#define __CV_CPU_DISPATCH_CHAIN_END(fn, args, mode, ...) /* done */
|
||||
#define __CV_CPU_DISPATCH(fn, args, mode, ...) __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
#define __CV_CPU_DISPATCH_EXPAND(fn, args, ...) __CV_EXPAND(__CV_CPU_DISPATCH(fn, args, __VA_ARGS__))
|
||||
#define CV_CPU_DISPATCH(fn, args, ...) __CV_CPU_DISPATCH_EXPAND(fn, args, __VA_ARGS__, END) // expand macros
|
||||
|
||||
|
||||
#if defined CV_ENABLE_INTRINSICS \
|
||||
&& !defined CV_DISABLE_OPTIMIZATION \
|
||||
&& !defined __CUDACC__ /* do not include SSE/AVX/NEON headers for NVCC compiler */ \
|
||||
|
||||
#ifdef CV_CPU_COMPILE_SSE2
|
||||
# include <emmintrin.h>
|
||||
# define CV_MMX 1
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSE3
|
||||
# include <pmmintrin.h>
|
||||
# define CV_SSE3 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSSE3
|
||||
# include <tmmintrin.h>
|
||||
# define CV_SSSE3 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSE4_1
|
||||
# include <smmintrin.h>
|
||||
# define CV_SSE4_1 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_SSE4_2
|
||||
# include <nmmintrin.h>
|
||||
# define CV_SSE4_2 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_POPCNT
|
||||
# ifdef _MSC_VER
|
||||
# include <nmmintrin.h>
|
||||
# if defined(_M_X64)
|
||||
# define CV_POPCNT_U64 _mm_popcnt_u64
|
||||
# endif
|
||||
# define CV_POPCNT_U32 _mm_popcnt_u32
|
||||
# else
|
||||
# include <popcntintrin.h>
|
||||
# if defined(__x86_64__)
|
||||
# define CV_POPCNT_U64 __builtin_popcountll
|
||||
# endif
|
||||
# define CV_POPCNT_U32 __builtin_popcount
|
||||
# endif
|
||||
# define CV_POPCNT 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_AVX
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_FP16
|
||||
# include <immintrin.h>
|
||||
# define CV_FP16 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_AVX2
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX2 1
|
||||
#endif
|
||||
#ifdef CV_CPU_COMPILE_FMA3
|
||||
# define CV_FMA3 1
|
||||
#endif
|
||||
|
||||
#if (defined WIN32 || defined _WIN32) && defined(_M_ARM)
|
||||
# include <Intrin.h>
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#endif
|
||||
|
||||
#if defined(__ARM_NEON__) || defined(__aarch64__)
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__
|
||||
|
||||
#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX
|
||||
struct VZeroUpperGuard {
|
||||
#ifdef __GNUC__
|
||||
__attribute__((always_inline))
|
||||
#endif
|
||||
inline ~VZeroUpperGuard() { _mm256_zeroupper(); }
|
||||
};
|
||||
#define __CV_AVX_GUARD VZeroUpperGuard __vzeroupper_guard;
|
||||
#endif
|
||||
|
||||
#endif // __OPENCV_BUILD
|
||||
|
||||
|
||||
|
||||
#if !defined __OPENCV_BUILD // Compatibility code
|
||||
|
||||
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
|
||||
# include <emmintrin.h>
|
||||
# define CV_MMX 1
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
#elif (defined WIN32 || defined _WIN32) && defined(_M_ARM)
|
||||
# include <Intrin.h>
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#endif
|
||||
|
||||
#endif // !__OPENCV_BUILD (Compatibility code)
|
||||
|
||||
|
||||
|
||||
#ifndef CV_MMX
|
||||
# define CV_MMX 0
|
||||
#endif
|
||||
#ifndef CV_SSE
|
||||
# define CV_SSE 0
|
||||
#endif
|
||||
#ifndef CV_SSE2
|
||||
# define CV_SSE2 0
|
||||
#endif
|
||||
#ifndef CV_SSE3
|
||||
# define CV_SSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSSE3
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_1
|
||||
# define CV_SSE4_1 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_2
|
||||
# define CV_SSE4_2 0
|
||||
#endif
|
||||
#ifndef CV_POPCNT
|
||||
# define CV_POPCNT 0
|
||||
#endif
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_FP16
|
||||
# define CV_FP16 0
|
||||
#endif
|
||||
#ifndef CV_AVX2
|
||||
# define CV_AVX2 0
|
||||
#endif
|
||||
#ifndef CV_FMA3
|
||||
# define CV_FMA3 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512F
|
||||
# define CV_AVX_512F 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512BW
|
||||
# define CV_AVX_512BW 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512CD
|
||||
# define CV_AVX_512CD 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512DQ
|
||||
# define CV_AVX_512DQ 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512ER
|
||||
# define CV_AVX_512ER 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512IFMA512
|
||||
# define CV_AVX_512IFMA512 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512PF
|
||||
# define CV_AVX_512PF 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VBMI
|
||||
# define CV_AVX_512VBMI 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VL
|
||||
# define CV_AVX_512VL 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
@@ -0,0 +1,148 @@
|
||||
// AUTOGENERATED, DO NOT EDIT
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE
|
||||
# define CV_CPU_HAS_SUPPORT_SSE 1
|
||||
# define CV_CPU_CALL_SSE(fn, args) return (opt_SSE::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE
|
||||
# define CV_CPU_HAS_SUPPORT_SSE (cv::checkHardwareSupport(CV_CPU_SSE))
|
||||
# define CV_CPU_CALL_SSE(fn, args) if (CV_CPU_HAS_SUPPORT_SSE) return (opt_SSE::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_SSE 0
|
||||
# define CV_CPU_CALL_SSE(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE(fn, args, mode, ...) CV_CPU_CALL_SSE(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE2
|
||||
# define CV_CPU_HAS_SUPPORT_SSE2 1
|
||||
# define CV_CPU_CALL_SSE2(fn, args) return (opt_SSE2::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE2
|
||||
# define CV_CPU_HAS_SUPPORT_SSE2 (cv::checkHardwareSupport(CV_CPU_SSE2))
|
||||
# define CV_CPU_CALL_SSE2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE2) return (opt_SSE2::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_SSE2 0
|
||||
# define CV_CPU_CALL_SSE2(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE2(fn, args, mode, ...) CV_CPU_CALL_SSE2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE3
|
||||
# define CV_CPU_HAS_SUPPORT_SSE3 1
|
||||
# define CV_CPU_CALL_SSE3(fn, args) return (opt_SSE3::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE3
|
||||
# define CV_CPU_HAS_SUPPORT_SSE3 (cv::checkHardwareSupport(CV_CPU_SSE3))
|
||||
# define CV_CPU_CALL_SSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSE3) return (opt_SSE3::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_SSE3 0
|
||||
# define CV_CPU_CALL_SSE3(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE3(fn, args, mode, ...) CV_CPU_CALL_SSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSSE3
|
||||
# define CV_CPU_HAS_SUPPORT_SSSE3 1
|
||||
# define CV_CPU_CALL_SSSE3(fn, args) return (opt_SSSE3::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSSE3
|
||||
# define CV_CPU_HAS_SUPPORT_SSSE3 (cv::checkHardwareSupport(CV_CPU_SSSE3))
|
||||
# define CV_CPU_CALL_SSSE3(fn, args) if (CV_CPU_HAS_SUPPORT_SSSE3) return (opt_SSSE3::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_SSSE3 0
|
||||
# define CV_CPU_CALL_SSSE3(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSSE3(fn, args, mode, ...) CV_CPU_CALL_SSSE3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_1 1
|
||||
# define CV_CPU_CALL_SSE4_1(fn, args) return (opt_SSE4_1::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_1
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_1 (cv::checkHardwareSupport(CV_CPU_SSE4_1))
|
||||
# define CV_CPU_CALL_SSE4_1(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_1) return (opt_SSE4_1::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_1 0
|
||||
# define CV_CPU_CALL_SSE4_1(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE4_1(fn, args, mode, ...) CV_CPU_CALL_SSE4_1(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_SSE4_2
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_2 1
|
||||
# define CV_CPU_CALL_SSE4_2(fn, args) return (opt_SSE4_2::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_SSE4_2
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_2 (cv::checkHardwareSupport(CV_CPU_SSE4_2))
|
||||
# define CV_CPU_CALL_SSE4_2(fn, args) if (CV_CPU_HAS_SUPPORT_SSE4_2) return (opt_SSE4_2::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_SSE4_2 0
|
||||
# define CV_CPU_CALL_SSE4_2(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_SSE4_2(fn, args, mode, ...) CV_CPU_CALL_SSE4_2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_POPCNT
|
||||
# define CV_CPU_HAS_SUPPORT_POPCNT 1
|
||||
# define CV_CPU_CALL_POPCNT(fn, args) return (opt_POPCNT::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_POPCNT
|
||||
# define CV_CPU_HAS_SUPPORT_POPCNT (cv::checkHardwareSupport(CV_CPU_POPCNT))
|
||||
# define CV_CPU_CALL_POPCNT(fn, args) if (CV_CPU_HAS_SUPPORT_POPCNT) return (opt_POPCNT::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_POPCNT 0
|
||||
# define CV_CPU_CALL_POPCNT(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_POPCNT(fn, args, mode, ...) CV_CPU_CALL_POPCNT(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX
|
||||
# define CV_CPU_HAS_SUPPORT_AVX 1
|
||||
# define CV_CPU_CALL_AVX(fn, args) return (opt_AVX::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX
|
||||
# define CV_CPU_HAS_SUPPORT_AVX (cv::checkHardwareSupport(CV_CPU_AVX))
|
||||
# define CV_CPU_CALL_AVX(fn, args) if (CV_CPU_HAS_SUPPORT_AVX) return (opt_AVX::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_AVX 0
|
||||
# define CV_CPU_CALL_AVX(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_AVX(fn, args, mode, ...) CV_CPU_CALL_AVX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FP16
|
||||
# define CV_CPU_HAS_SUPPORT_FP16 1
|
||||
# define CV_CPU_CALL_FP16(fn, args) return (opt_FP16::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FP16
|
||||
# define CV_CPU_HAS_SUPPORT_FP16 (cv::checkHardwareSupport(CV_CPU_FP16))
|
||||
# define CV_CPU_CALL_FP16(fn, args) if (CV_CPU_HAS_SUPPORT_FP16) return (opt_FP16::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_FP16 0
|
||||
# define CV_CPU_CALL_FP16(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_FP16(fn, args, mode, ...) CV_CPU_CALL_FP16(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_AVX2
|
||||
# define CV_CPU_HAS_SUPPORT_AVX2 1
|
||||
# define CV_CPU_CALL_AVX2(fn, args) return (opt_AVX2::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_AVX2
|
||||
# define CV_CPU_HAS_SUPPORT_AVX2 (cv::checkHardwareSupport(CV_CPU_AVX2))
|
||||
# define CV_CPU_CALL_AVX2(fn, args) if (CV_CPU_HAS_SUPPORT_AVX2) return (opt_AVX2::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_AVX2 0
|
||||
# define CV_CPU_CALL_AVX2(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_AVX2(fn, args, mode, ...) CV_CPU_CALL_AVX2(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_FMA3
|
||||
# define CV_CPU_HAS_SUPPORT_FMA3 1
|
||||
# define CV_CPU_CALL_FMA3(fn, args) return (opt_FMA3::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_FMA3
|
||||
# define CV_CPU_HAS_SUPPORT_FMA3 (cv::checkHardwareSupport(CV_CPU_FMA3))
|
||||
# define CV_CPU_CALL_FMA3(fn, args) if (CV_CPU_HAS_SUPPORT_FMA3) return (opt_FMA3::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_FMA3 0
|
||||
# define CV_CPU_CALL_FMA3(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_FMA3(fn, args, mode, ...) CV_CPU_CALL_FMA3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_NEON
|
||||
# define CV_CPU_HAS_SUPPORT_NEON 1
|
||||
# define CV_CPU_CALL_NEON(fn, args) return (opt_NEON::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_NEON
|
||||
# define CV_CPU_HAS_SUPPORT_NEON (cv::checkHardwareSupport(CV_CPU_NEON))
|
||||
# define CV_CPU_CALL_NEON(fn, args) if (CV_CPU_HAS_SUPPORT_NEON) return (opt_NEON::fn args)
|
||||
#else
|
||||
# define CV_CPU_HAS_SUPPORT_NEON 0
|
||||
# define CV_CPU_CALL_NEON(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
|
||||
#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
|
||||
@@ -48,6 +48,21 @@
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
#ifdef __OPENCV_BUILD
|
||||
#include "cvconfig.h"
|
||||
#endif
|
||||
|
||||
#ifndef __CV_EXPAND
|
||||
#define __CV_EXPAND(x) x
|
||||
#endif
|
||||
|
||||
#ifndef __CV_CAT
|
||||
#define __CV_CAT__(x, y) x ## y
|
||||
#define __CV_CAT_(x, y) __CV_CAT__(x, y)
|
||||
#define __CV_CAT(x, y) __CV_CAT_(x, y)
|
||||
#endif
|
||||
|
||||
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */
|
||||
#endif
|
||||
@@ -59,10 +74,6 @@
|
||||
#undef abs
|
||||
#undef Complex
|
||||
|
||||
#if !defined _CRT_SECURE_NO_DEPRECATE && defined _MSC_VER && _MSC_VER > 1300
|
||||
# define _CRT_SECURE_NO_DEPRECATE /* to avoid multiple Visual Studio warnings */
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include "opencv2/core/hal/interface.h"
|
||||
|
||||
@@ -88,7 +99,7 @@
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined CV_ICC && !defined CV_ENABLE_UNROLLED
|
||||
#if defined CV_DISABLE_OPTIMIZATION || (defined CV_ICC && !defined CV_ENABLE_UNROLLED)
|
||||
# define CV_ENABLE_UNROLLED 0
|
||||
#else
|
||||
# define CV_ENABLE_UNROLLED 1
|
||||
@@ -161,150 +172,9 @@ enum CpuFeatures {
|
||||
CPU_NEON = 100
|
||||
};
|
||||
|
||||
// do not include SSE/AVX/NEON headers for NVCC compiler
|
||||
#ifndef __CUDACC__
|
||||
|
||||
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
|
||||
# include <emmintrin.h>
|
||||
# define CV_MMX 1
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <pmmintrin.h>
|
||||
# define CV_SSE3 1
|
||||
# endif
|
||||
# if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <tmmintrin.h>
|
||||
# define CV_SSSE3 1
|
||||
# endif
|
||||
# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <smmintrin.h>
|
||||
# define CV_SSE4_1 1
|
||||
# endif
|
||||
# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <nmmintrin.h>
|
||||
# define CV_SSE4_2 1
|
||||
# endif
|
||||
# if defined __POPCNT__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# ifdef _MSC_VER
|
||||
# include <nmmintrin.h>
|
||||
# if defined(_M_X64)
|
||||
# define CV_POPCNT_U64 _mm_popcnt_u64
|
||||
# endif
|
||||
# define CV_POPCNT_U32 _mm_popcnt_u32
|
||||
# else
|
||||
# include <popcntintrin.h>
|
||||
# if defined(__x86_64__)
|
||||
# define CV_POPCNT_U64 __builtin_popcountll
|
||||
# endif
|
||||
# define CV_POPCNT_U32 __builtin_popcount
|
||||
# endif
|
||||
# define CV_POPCNT 1
|
||||
# endif
|
||||
# if defined __AVX__ || (defined _MSC_VER && _MSC_VER >= 1600 && 0)
|
||||
// MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX
|
||||
// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX 1
|
||||
# if defined(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# else
|
||||
# define __xgetbv() 0
|
||||
# endif
|
||||
# endif
|
||||
# if defined __AVX2__ || (defined _MSC_VER && _MSC_VER >= 1800 && 0)
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX2 1
|
||||
# if defined __FMA__
|
||||
# define CV_FMA3 1
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#include "cv_cpu_dispatch.h"
|
||||
|
||||
#if (defined WIN32 || defined _WIN32) && defined(_M_ARM)
|
||||
# include <Intrin.h>
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
# define CPU_HAS_NEON_FEATURE (true)
|
||||
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#endif
|
||||
|
||||
#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__
|
||||
# define CV_VFP 1
|
||||
#endif
|
||||
|
||||
#endif // __CUDACC__
|
||||
|
||||
#ifndef CV_POPCNT
|
||||
#define CV_POPCNT 0
|
||||
#endif
|
||||
#ifndef CV_MMX
|
||||
# define CV_MMX 0
|
||||
#endif
|
||||
#ifndef CV_SSE
|
||||
# define CV_SSE 0
|
||||
#endif
|
||||
#ifndef CV_SSE2
|
||||
# define CV_SSE2 0
|
||||
#endif
|
||||
#ifndef CV_SSE3
|
||||
# define CV_SSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSSE3
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_1
|
||||
# define CV_SSE4_1 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_2
|
||||
# define CV_SSE4_2 0
|
||||
#endif
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_AVX2
|
||||
# define CV_AVX2 0
|
||||
#endif
|
||||
#ifndef CV_FMA3
|
||||
# define CV_FMA3 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512F
|
||||
# define CV_AVX_512F 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512BW
|
||||
# define CV_AVX_512BW 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512CD
|
||||
# define CV_AVX_512CD 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512DQ
|
||||
# define CV_AVX_512DQ 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512ER
|
||||
# define CV_AVX_512ER 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512IFMA512
|
||||
# define CV_AVX_512IFMA512 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512PF
|
||||
# define CV_AVX_512PF 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VBMI
|
||||
# define CV_AVX_512VBMI 0
|
||||
#endif
|
||||
#ifndef CV_AVX_512VL
|
||||
# define CV_AVX_512VL 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_VFP
|
||||
# define CV_VFP 0
|
||||
#endif
|
||||
|
||||
/* fundamental constants */
|
||||
#define CV_PI 3.1415926535897932384626433832795
|
||||
@@ -494,6 +364,21 @@ Cv64suf;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* C++11 std::array *
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifndef CV_CXX_STD_ARRAY
|
||||
# if __cplusplus >= 201103L
|
||||
# define CV_CXX_STD_ARRAY 1
|
||||
# include <array>
|
||||
# endif
|
||||
#else
|
||||
# if CV_CXX_STD_ARRAY == 0
|
||||
# undef CV_CXX_STD_ARRAY
|
||||
# endif
|
||||
#endif
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // OPENCV_CORE_CVDEF_H
|
||||
|
||||
@@ -270,6 +270,17 @@ std::ostream& operator << (std::ostream& out, const Rect_<_Tp>& rect)
|
||||
return out << "[" << rect.width << " x " << rect.height << " from (" << rect.x << ", " << rect.y << ")]";
|
||||
}
|
||||
|
||||
static inline std::ostream& operator << (std::ostream& out, const MatSize& msize)
|
||||
{
|
||||
int i, dims = msize.p[-1];
|
||||
for( i = 0; i < dims; i++ )
|
||||
{
|
||||
out << msize.p[i];
|
||||
if( i < dims-1 )
|
||||
out << " x ";
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif // OPENCV_NOSTL
|
||||
} // cv
|
||||
|
||||
@@ -47,6 +47,12 @@
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
|
||||
&& defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
#include <emmintrin.h>
|
||||
#endif
|
||||
|
||||
|
||||
//! @addtogroup core_utils
|
||||
//! @{
|
||||
|
||||
@@ -68,7 +74,7 @@
|
||||
# include "tegra_round.hpp"
|
||||
#endif
|
||||
|
||||
#if CV_VFP
|
||||
#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__ && !defined(__CUDACC__)
|
||||
// 1. general scheme
|
||||
#define ARM_ROUND(_value, _asm_string) \
|
||||
int res; \
|
||||
@@ -84,7 +90,7 @@
|
||||
#endif
|
||||
// 3. version for float
|
||||
#define ARM_ROUND_FLT(value) ARM_ROUND(value, "vcvtr.s32.f32 %[temp], %[value]\n vmov %[res], %[temp]")
|
||||
#endif // CV_VFP
|
||||
#endif
|
||||
|
||||
/** @brief Rounds floating-point number to the nearest integer
|
||||
|
||||
@@ -95,7 +101,7 @@ CV_INLINE int
|
||||
cvRound( double value )
|
||||
{
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
|
||||
&& defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
|
||||
__m128d t = _mm_set_sd( value );
|
||||
return _mm_cvtsd_si32(t);
|
||||
#elif defined _MSC_VER && defined _M_IX86
|
||||
@@ -110,7 +116,7 @@ cvRound( double value )
|
||||
defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND_DBL(value);
|
||||
#elif defined CV_ICC || defined __GNUC__
|
||||
# if CV_VFP
|
||||
# if defined ARM_ROUND_DBL
|
||||
ARM_ROUND_DBL(value);
|
||||
# else
|
||||
return (int)lrint(value);
|
||||
@@ -132,18 +138,8 @@ cvRound( double value )
|
||||
*/
|
||||
CV_INLINE int cvFloor( double value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128d t = _mm_set_sd( value );
|
||||
int i = _mm_cvtsd_si32(t);
|
||||
return i - _mm_movemask_pd(_mm_cmplt_sd(t, _mm_cvtsi32_sd(t,i)));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i - (i > value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(value - i);
|
||||
return i - (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @brief Rounds floating-point number to the nearest integer not smaller than the original.
|
||||
@@ -155,18 +151,8 @@ CV_INLINE int cvFloor( double value )
|
||||
*/
|
||||
CV_INLINE int cvCeil( double value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128d t = _mm_set_sd( value );
|
||||
int i = _mm_cvtsd_si32(t);
|
||||
return i + _mm_movemask_pd(_mm_cmplt_sd(_mm_cvtsi32_sd(t,i), t));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i + (i < value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(i - value);
|
||||
return i + (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @brief Determines if the argument is Not A Number.
|
||||
@@ -202,8 +188,8 @@ CV_INLINE int cvIsInf( double value )
|
||||
/** @overload */
|
||||
CV_INLINE int cvRound(float value)
|
||||
{
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ && \
|
||||
defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
#if ((defined _MSC_VER && defined _M_X64) || (defined __GNUC__ && defined __x86_64__ \
|
||||
&& defined __SSE2__ && !defined __APPLE__) || CV_SSE2) && !defined(__CUDACC__)
|
||||
__m128 t = _mm_set_ss( value );
|
||||
return _mm_cvtss_si32(t);
|
||||
#elif defined _MSC_VER && defined _M_IX86
|
||||
@@ -218,7 +204,7 @@ CV_INLINE int cvRound(float value)
|
||||
defined __GNUC__) && defined HAVE_TEGRA_OPTIMIZATION
|
||||
TEGRA_ROUND_FLT(value);
|
||||
#elif defined CV_ICC || defined __GNUC__
|
||||
# if CV_VFP
|
||||
# if defined ARM_ROUND_FLT
|
||||
ARM_ROUND_FLT(value);
|
||||
# else
|
||||
return (int)lrintf(value);
|
||||
@@ -239,18 +225,8 @@ CV_INLINE int cvRound( int value )
|
||||
/** @overload */
|
||||
CV_INLINE int cvFloor( float value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__ && !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128 t = _mm_set_ss( value );
|
||||
int i = _mm_cvtss_si32(t);
|
||||
return i - _mm_movemask_ps(_mm_cmplt_ss(t, _mm_cvtsi32_ss(t,i)));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i - (i > value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(value - i);
|
||||
return i - (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @overload */
|
||||
@@ -262,18 +238,8 @@ CV_INLINE int cvFloor( int value )
|
||||
/** @overload */
|
||||
CV_INLINE int cvCeil( float value )
|
||||
{
|
||||
#if (defined _MSC_VER && defined _M_X64 || (defined __GNUC__ && defined __SSE2__&& !defined __APPLE__)) && !defined(__CUDACC__)
|
||||
__m128 t = _mm_set_ss( value );
|
||||
int i = _mm_cvtss_si32(t);
|
||||
return i + _mm_movemask_ps(_mm_cmplt_ss(_mm_cvtsi32_ss(t,i), t));
|
||||
#elif defined __GNUC__
|
||||
int i = (int)value;
|
||||
return i + (i < value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
float diff = (float)(i - value);
|
||||
return i + (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
/** @overload */
|
||||
|
||||
@@ -60,6 +60,25 @@
|
||||
// access from within opencv code more accessible
|
||||
namespace cv {
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
|
||||
#ifdef CV_CPU_DISPATCH_MODE
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE __CV_CAT(hal_, CV_CPU_DISPATCH_MODE)
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) {
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
|
||||
#else
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_baseline
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_baseline {
|
||||
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
|
||||
#endif
|
||||
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE;
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
#endif
|
||||
|
||||
//! @addtogroup core_hal_intrin
|
||||
//! @{
|
||||
|
||||
@@ -281,6 +300,9 @@ template <typename T> struct V_SIMD128Traits
|
||||
|
||||
//! @}
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef CV_DOXYGEN
|
||||
@@ -323,6 +345,10 @@ template <typename T> struct V_SIMD128Traits
|
||||
|
||||
namespace cv {
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
#endif
|
||||
|
||||
template <typename R> struct V_RegTrait128;
|
||||
|
||||
template <> struct V_RegTrait128<uchar> {
|
||||
@@ -407,6 +433,10 @@ template <> struct V_RegTrait128<double> {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#endif
|
||||
|
||||
} // cv::
|
||||
|
||||
//! @endcond
|
||||
|
||||
@@ -53,6 +53,10 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
#endif
|
||||
|
||||
/** @addtogroup core_hal_intrin
|
||||
|
||||
"Universal intrinsics" is a types and functions set intended to simplify vectorization of code on
|
||||
@@ -717,7 +721,7 @@ inline v_reg<typename V_TypeTraits<_Tp>::abs_type, n> v_absdiff(const v_reg<_Tp,
|
||||
{
|
||||
typedef typename V_TypeTraits<_Tp>::abs_type rtype;
|
||||
v_reg<rtype, n> c;
|
||||
const rtype mask = std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0;
|
||||
const rtype mask = (rtype)(std::numeric_limits<_Tp>::is_signed ? (1 << (sizeof(rtype)*8 - 1)) : 0);
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
rtype ua = a.s[i] ^ mask;
|
||||
@@ -1827,7 +1831,9 @@ static inline bool hasSIMD128()
|
||||
|
||||
//! @}
|
||||
|
||||
|
||||
#ifndef CV_DOXYGEN
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -53,6 +53,8 @@ namespace cv
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
#define CV_SIMD128 1
|
||||
#if defined(__aarch64__)
|
||||
#define CV_SIMD128_64F 1
|
||||
@@ -276,7 +278,7 @@ struct v_float64x2
|
||||
};
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_FP16)
|
||||
#if CV_FP16
|
||||
// Workaround for old comiplers
|
||||
template <typename T> static inline int16x4_t vreinterpret_s16_f16(T a)
|
||||
{ return (int16x4_t)a; }
|
||||
@@ -773,7 +775,7 @@ OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float32x4, float, f32)
|
||||
OPENCV_HAL_IMPL_NEON_LOADSTORE_OP(v_float64x2, double, f64)
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_FP16)
|
||||
#if CV_FP16
|
||||
// Workaround for old comiplers
|
||||
inline v_float16x4 v_load_f16(const short* ptr)
|
||||
{ return v_float16x4(vld1_f16(ptr)); }
|
||||
@@ -1221,7 +1223,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined (HAVE_FP16)
|
||||
#if CV_FP16
|
||||
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
|
||||
{
|
||||
return v_float32x4(vcvt_f32_f16(a.val));
|
||||
@@ -1238,11 +1240,13 @@ inline v_float16x4 v_cvt_f16(const v_float32x4& a)
|
||||
//! @brief Check CPU capability of SIMD operation
|
||||
static inline bool hasSIMD128()
|
||||
{
|
||||
return checkHardwareSupport(CV_CPU_NEON);
|
||||
return (CV_CPU_HAS_SUPPORT_NEON) ? true : false;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
|
||||
@@ -56,6 +56,8 @@ namespace cv
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
struct v_uint8x16
|
||||
{
|
||||
typedef uchar lane_type;
|
||||
@@ -253,7 +255,7 @@ struct v_float64x2
|
||||
__m128d val;
|
||||
};
|
||||
|
||||
#if defined(HAVE_FP16)
|
||||
#if CV_FP16
|
||||
struct v_float16x4
|
||||
{
|
||||
typedef short lane_type;
|
||||
@@ -1054,7 +1056,7 @@ inline void v_store_high(_Tp* ptr, const _Tpvec& a) \
|
||||
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float32x4, float, ps)
|
||||
OPENCV_HAL_IMPL_SSE_LOADSTORE_FLT_OP(v_float64x2, double, pd)
|
||||
|
||||
#if defined(HAVE_FP16)
|
||||
#if CV_FP16
|
||||
inline v_float16x4 v_load_f16(const short* ptr)
|
||||
{ return v_float16x4(_mm_loadl_epi64((const __m128i*)ptr)); }
|
||||
inline void v_store_f16(short* ptr, v_float16x4& a)
|
||||
@@ -1774,7 +1776,7 @@ inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
||||
return v_float64x2(_mm_cvtps_pd(_mm_castsi128_ps(_mm_srli_si128(_mm_castps_si128(a.val),8))));
|
||||
}
|
||||
|
||||
#if defined(HAVE_FP16)
|
||||
#if CV_FP16
|
||||
inline v_float32x4 v_cvt_f32(const v_float16x4& a)
|
||||
{
|
||||
return v_float32x4(_mm_cvtph_ps(a.val));
|
||||
@@ -1791,11 +1793,13 @@ inline v_float16x4 v_cvt_f16(const v_float32x4& a)
|
||||
//! @brief Check CPU capability of SIMD operation
|
||||
static inline bool hasSIMD128()
|
||||
{
|
||||
return checkHardwareSupport(CV_CPU_SSE2);
|
||||
return (CV_CPU_HAS_SUPPORT_SSE2) ? true : false;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
|
||||
@@ -165,7 +165,9 @@ public:
|
||||
UMAT =10 << KIND_SHIFT,
|
||||
STD_VECTOR_UMAT =11 << KIND_SHIFT,
|
||||
STD_BOOL_VECTOR =12 << KIND_SHIFT,
|
||||
STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT
|
||||
STD_VECTOR_CUDA_GPU_MAT = 13 << KIND_SHIFT,
|
||||
STD_ARRAY =14 << KIND_SHIFT,
|
||||
STD_ARRAY_MAT =15 << KIND_SHIFT
|
||||
};
|
||||
|
||||
_InputArray();
|
||||
@@ -177,6 +179,7 @@ public:
|
||||
template<typename _Tp> _InputArray(const std::vector<_Tp>& vec);
|
||||
_InputArray(const std::vector<bool>& vec);
|
||||
template<typename _Tp> _InputArray(const std::vector<std::vector<_Tp> >& vec);
|
||||
_InputArray(const std::vector<std::vector<bool> >&);
|
||||
template<typename _Tp> _InputArray(const std::vector<Mat_<_Tp> >& vec);
|
||||
template<typename _Tp> _InputArray(const _Tp* vec, int n);
|
||||
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
|
||||
@@ -189,6 +192,11 @@ public:
|
||||
_InputArray(const UMat& um);
|
||||
_InputArray(const std::vector<UMat>& umv);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> _InputArray(const std::array<_Tp, _Nm>& arr);
|
||||
template<std::size_t _Nm> _InputArray(const std::array<Mat, _Nm>& arr);
|
||||
#endif
|
||||
|
||||
Mat getMat(int idx=-1) const;
|
||||
Mat getMat_(int idx=-1) const;
|
||||
UMat getUMat(int idx=-1) const;
|
||||
@@ -293,6 +301,7 @@ public:
|
||||
template<typename _Tp> _OutputArray(std::vector<_Tp>& vec);
|
||||
_OutputArray(std::vector<bool>& vec);
|
||||
template<typename _Tp> _OutputArray(std::vector<std::vector<_Tp> >& vec);
|
||||
_OutputArray(std::vector<std::vector<bool> >&);
|
||||
template<typename _Tp> _OutputArray(std::vector<Mat_<_Tp> >& vec);
|
||||
template<typename _Tp> _OutputArray(Mat_<_Tp>& m);
|
||||
template<typename _Tp> _OutputArray(_Tp* vec, int n);
|
||||
@@ -316,6 +325,13 @@ public:
|
||||
_OutputArray(const UMat& m);
|
||||
_OutputArray(const std::vector<UMat>& vec);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> _OutputArray(std::array<_Tp, _Nm>& arr);
|
||||
template<typename _Tp, std::size_t _Nm> _OutputArray(const std::array<_Tp, _Nm>& arr);
|
||||
template<std::size_t _Nm> _OutputArray(std::array<Mat, _Nm>& arr);
|
||||
template<std::size_t _Nm> _OutputArray(const std::array<Mat, _Nm>& arr);
|
||||
#endif
|
||||
|
||||
bool fixedSize() const;
|
||||
bool fixedType() const;
|
||||
bool needed() const;
|
||||
@@ -374,6 +390,14 @@ public:
|
||||
template<typename _Tp, int m, int n> _InputOutputArray(const Matx<_Tp, m, n>& matx);
|
||||
_InputOutputArray(const UMat& m);
|
||||
_InputOutputArray(const std::vector<UMat>& vec);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> _InputOutputArray(std::array<_Tp, _Nm>& arr);
|
||||
template<typename _Tp, std::size_t _Nm> _InputOutputArray(const std::array<_Tp, _Nm>& arr);
|
||||
template<std::size_t _Nm> _InputOutputArray(std::array<Mat, _Nm>& arr);
|
||||
template<std::size_t _Nm> _InputOutputArray(const std::array<Mat, _Nm>& arr);
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
typedef const _InputArray& InputArray;
|
||||
@@ -955,6 +979,12 @@ public:
|
||||
*/
|
||||
template<typename _Tp> explicit Mat(const std::vector<_Tp>& vec, bool copyData=false);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
/** @overload
|
||||
*/
|
||||
template<typename _Tp, size_t _Nm> explicit Mat(const std::array<_Tp, _Nm>& arr, bool copyData=false);
|
||||
#endif
|
||||
|
||||
/** @overload
|
||||
*/
|
||||
template<typename _Tp, int n> explicit Mat(const Vec<_Tp, n>& vec, bool copyData=true);
|
||||
@@ -1215,6 +1245,9 @@ public:
|
||||
/** @overload */
|
||||
Mat reshape(int cn, int newndims, const int* newsz) const;
|
||||
|
||||
/** @overload */
|
||||
Mat reshape(int cn, const std::vector<int>& newshape) const;
|
||||
|
||||
/** @brief Transposes a matrix.
|
||||
|
||||
The method performs matrix transposition by means of matrix expressions. It does not perform the
|
||||
@@ -1575,6 +1608,10 @@ public:
|
||||
template<typename _Tp, int n> operator Vec<_Tp, n>() const;
|
||||
template<typename _Tp, int m, int n> operator Matx<_Tp, m, n>() const;
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> operator std::array<_Tp, _Nm>() const;
|
||||
#endif
|
||||
|
||||
/** @brief Reports whether the matrix is continuous or not.
|
||||
|
||||
The method returns true if the matrix elements are stored continuously without gaps at the end of
|
||||
@@ -1717,6 +1754,12 @@ public:
|
||||
*/
|
||||
size_t total() const;
|
||||
|
||||
/** @brief Returns the total number of array elements.
|
||||
|
||||
The method returns the number of elements within a certain sub-array slice with startDim <= dim < endDim
|
||||
*/
|
||||
size_t total(int startDim, int endDim=INT_MAX) const;
|
||||
|
||||
//! returns N if the matrix is 1-channel (N x ptdim) or ptdim-channel (1 x N) or (N x 1); negative number otherwise
|
||||
int checkVector(int elemChannels, int depth=-1, bool requireContinuous=true) const;
|
||||
|
||||
@@ -2114,6 +2157,10 @@ public:
|
||||
explicit Mat_(const Point3_<typename DataType<_Tp>::channel_type>& pt, bool copyData=true);
|
||||
explicit Mat_(const MatCommaInitializer_<_Tp>& commaInitializer);
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template <std::size_t _Nm> explicit Mat_(const std::array<_Tp, _Nm>& arr, bool copyData=false);
|
||||
#endif
|
||||
|
||||
Mat_& operator = (const Mat& m);
|
||||
Mat_& operator = (const Mat_& m);
|
||||
//! set all the elements to s.
|
||||
@@ -2207,6 +2254,12 @@ public:
|
||||
|
||||
//! conversion to vector.
|
||||
operator std::vector<_Tp>() const;
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
//! conversion to array.
|
||||
template<std::size_t _Nm> operator std::array<_Tp, _Nm>() const;
|
||||
#endif
|
||||
|
||||
//! conversion to Vec
|
||||
template<int n> operator Vec<typename DataType<_Tp>::channel_type, n>() const;
|
||||
//! conversion to Matx
|
||||
@@ -2281,6 +2334,7 @@ public:
|
||||
UMat(const UMat& m, const std::vector<Range>& ranges);
|
||||
//! builds matrix from std::vector with or without copying the data
|
||||
template<typename _Tp> explicit UMat(const std::vector<_Tp>& vec, bool copyData=false);
|
||||
|
||||
//! builds matrix from cv::Vec; the data is copied by default
|
||||
template<typename _Tp, int n> explicit UMat(const Vec<_Tp, n>& vec, bool copyData=true);
|
||||
//! builds matrix from cv::Matx; the data is copied by default
|
||||
@@ -2421,6 +2475,10 @@ public:
|
||||
UMat& operator = (UMat&& m);
|
||||
#endif
|
||||
|
||||
/*! Returns the OpenCL buffer handle on which UMat operates on.
|
||||
The UMat instance should be kept alive during the use of the handle to prevent the buffer to be
|
||||
returned to the OpenCV buffer pool.
|
||||
*/
|
||||
void* handle(int accessFlags) const;
|
||||
void ndoffset(size_t* ofs) const;
|
||||
|
||||
|
||||
@@ -77,6 +77,16 @@ template<typename _Tp> inline
|
||||
_InputArray::_InputArray(const std::vector<_Tp>& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_READ, &vec); }
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
_InputArray::_InputArray(const std::array<_Tp, _Nm>& arr)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_READ, arr.data(), Size(1, _Nm)); }
|
||||
|
||||
template<std::size_t _Nm> inline
|
||||
_InputArray::_InputArray(const std::array<Mat, _Nm>& arr)
|
||||
{ init(STD_ARRAY_MAT + ACCESS_READ, arr.data(), Size(1, _Nm)); }
|
||||
#endif
|
||||
|
||||
inline
|
||||
_InputArray::_InputArray(const std::vector<bool>& vec)
|
||||
{ init(FIXED_TYPE + STD_BOOL_VECTOR + DataType<bool>::type + ACCESS_READ, &vec); }
|
||||
@@ -85,6 +95,10 @@ template<typename _Tp> inline
|
||||
_InputArray::_InputArray(const std::vector<std::vector<_Tp> >& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_READ, &vec); }
|
||||
|
||||
inline
|
||||
_InputArray::_InputArray(const std::vector<std::vector<bool> >&)
|
||||
{ CV_Error(Error::StsUnsupportedFormat, "std::vector<std::vector<bool> > is not supported!\n"); }
|
||||
|
||||
template<typename _Tp> inline
|
||||
_InputArray::_InputArray(const std::vector<Mat_<_Tp> >& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_READ, &vec); }
|
||||
@@ -133,7 +147,9 @@ inline bool _InputArray::isUMat() const { return kind() == _InputArray::UMAT; }
|
||||
inline bool _InputArray::isMatVector() const { return kind() == _InputArray::STD_VECTOR_MAT; }
|
||||
inline bool _InputArray::isUMatVector() const { return kind() == _InputArray::STD_VECTOR_UMAT; }
|
||||
inline bool _InputArray::isMatx() const { return kind() == _InputArray::MATX; }
|
||||
inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR || kind() == _InputArray::STD_BOOL_VECTOR; }
|
||||
inline bool _InputArray::isVector() const { return kind() == _InputArray::STD_VECTOR ||
|
||||
kind() == _InputArray::STD_BOOL_VECTOR ||
|
||||
kind() == _InputArray::STD_ARRAY; }
|
||||
inline bool _InputArray::isGpuMatVector() const { return kind() == _InputArray::STD_VECTOR_CUDA_GPU_MAT; }
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -149,6 +165,16 @@ template<typename _Tp> inline
|
||||
_OutputArray::_OutputArray(std::vector<_Tp>& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
_OutputArray::_OutputArray(std::array<_Tp, _Nm>& arr)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
|
||||
|
||||
template<std::size_t _Nm> inline
|
||||
_OutputArray::_OutputArray(std::array<Mat, _Nm>& arr)
|
||||
{ init(STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
|
||||
#endif
|
||||
|
||||
inline
|
||||
_OutputArray::_OutputArray(std::vector<bool>&)
|
||||
{ CV_Error(Error::StsUnsupportedFormat, "std::vector<bool> cannot be an output array\n"); }
|
||||
@@ -157,6 +183,10 @@ template<typename _Tp> inline
|
||||
_OutputArray::_OutputArray(std::vector<std::vector<_Tp> >& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
|
||||
|
||||
inline
|
||||
_OutputArray::_OutputArray(std::vector<std::vector<bool> >&)
|
||||
{ CV_Error(Error::StsUnsupportedFormat, "std::vector<std::vector<bool> > cannot be an output array\n"); }
|
||||
|
||||
template<typename _Tp> inline
|
||||
_OutputArray::_OutputArray(std::vector<Mat_<_Tp> >& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR_MAT + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
|
||||
@@ -177,6 +207,16 @@ template<typename _Tp> inline
|
||||
_OutputArray::_OutputArray(const std::vector<_Tp>& vec)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
_OutputArray::_OutputArray(const std::array<_Tp, _Nm>& arr)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
|
||||
|
||||
template<std::size_t _Nm> inline
|
||||
_OutputArray::_OutputArray(const std::array<Mat, _Nm>& arr)
|
||||
{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_WRITE, arr.data(), Size(1, _Nm)); }
|
||||
#endif
|
||||
|
||||
template<typename _Tp> inline
|
||||
_OutputArray::_OutputArray(const std::vector<std::vector<_Tp> >& vec)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_WRITE, &vec); }
|
||||
@@ -244,6 +284,16 @@ template<typename _Tp> inline
|
||||
_InputOutputArray::_InputOutputArray(std::vector<_Tp>& vec)
|
||||
{ init(FIXED_TYPE + STD_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); }
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
_InputOutputArray::_InputOutputArray(std::array<_Tp, _Nm>& arr)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_RW, arr.data(), Size(1, _Nm)); }
|
||||
|
||||
template<std::size_t _Nm> inline
|
||||
_InputOutputArray::_InputOutputArray(std::array<Mat, _Nm>& arr)
|
||||
{ init(STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); }
|
||||
#endif
|
||||
|
||||
inline _InputOutputArray::_InputOutputArray(std::vector<bool>&)
|
||||
{ CV_Error(Error::StsUnsupportedFormat, "std::vector<bool> cannot be an input/output array\n"); }
|
||||
|
||||
@@ -271,6 +321,16 @@ template<typename _Tp> inline
|
||||
_InputOutputArray::_InputOutputArray(const std::vector<_Tp>& vec)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); }
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
_InputOutputArray::_InputOutputArray(const std::array<_Tp, _Nm>& arr)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_ARRAY + DataType<_Tp>::type + ACCESS_RW, arr.data(), Size(1, _Nm)); }
|
||||
|
||||
template<std::size_t _Nm> inline
|
||||
_InputOutputArray::_InputOutputArray(const std::array<Mat, _Nm>& arr)
|
||||
{ init(FIXED_SIZE + STD_ARRAY_MAT + ACCESS_RW, arr.data(), Size(1, _Nm)); }
|
||||
#endif
|
||||
|
||||
template<typename _Tp> inline
|
||||
_InputOutputArray::_InputOutputArray(const std::vector<std::vector<_Tp> >& vec)
|
||||
{ init(FIXED_TYPE + FIXED_SIZE + STD_VECTOR_VECTOR + DataType<_Tp>::type + ACCESS_RW, &vec); }
|
||||
@@ -505,6 +565,25 @@ Mat::Mat(const std::vector<_Tp>& vec, bool copyData)
|
||||
Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this);
|
||||
}
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
Mat::Mat(const std::array<_Tp, _Nm>& arr, bool copyData)
|
||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows((int)arr.size()),
|
||||
cols(1), data(0), datastart(0), dataend(0), allocator(0), u(0), size(&rows)
|
||||
{
|
||||
if(arr.empty())
|
||||
return;
|
||||
if( !copyData )
|
||||
{
|
||||
step[0] = step[1] = sizeof(_Tp);
|
||||
datastart = data = (uchar*)arr.data();
|
||||
datalimit = dataend = datastart + rows * step[0];
|
||||
}
|
||||
else
|
||||
Mat((int)arr.size(), 1, DataType<_Tp>::type, (uchar*)arr.data()).copyTo(*this);
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp, int n> inline
|
||||
Mat::Mat(const Vec<_Tp, n>& vec, bool copyData)
|
||||
: flags(MAGIC_VAL | DataType<_Tp>::type | CV_MAT_CONT_FLAG), dims(2), rows(n), cols(1), data(0),
|
||||
@@ -807,6 +886,17 @@ size_t Mat::total() const
|
||||
return p;
|
||||
}
|
||||
|
||||
inline
|
||||
size_t Mat::total(int startDim, int endDim) const
|
||||
{
|
||||
CV_Assert( 0 <= startDim && startDim <= endDim);
|
||||
size_t p = 1;
|
||||
int endDim_ = endDim <= dims ? endDim : dims;
|
||||
for( int i = startDim; i < endDim_; i++ )
|
||||
p *= size[i];
|
||||
return p;
|
||||
}
|
||||
|
||||
inline
|
||||
uchar* Mat::ptr(int y)
|
||||
{
|
||||
@@ -1114,6 +1204,16 @@ Mat::operator std::vector<_Tp>() const
|
||||
return v;
|
||||
}
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp, std::size_t _Nm> inline
|
||||
Mat::operator std::array<_Tp, _Nm>() const
|
||||
{
|
||||
std::array<_Tp, _Nm> v;
|
||||
copyTo(v);
|
||||
return v;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp, int n> inline
|
||||
Mat::operator Vec<_Tp, n>() const
|
||||
{
|
||||
@@ -1468,6 +1568,13 @@ Mat_<_Tp>::Mat_(const std::vector<_Tp>& vec, bool copyData)
|
||||
: Mat(vec, copyData)
|
||||
{}
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp> template<std::size_t _Nm> inline
|
||||
Mat_<_Tp>::Mat_(const std::array<_Tp, _Nm>& arr, bool copyData)
|
||||
: Mat(arr, copyData)
|
||||
{}
|
||||
#endif
|
||||
|
||||
template<typename _Tp> inline
|
||||
Mat_<_Tp>& Mat_<_Tp>::operator = (const Mat& m)
|
||||
{
|
||||
@@ -1745,6 +1852,16 @@ Mat_<_Tp>::operator std::vector<_Tp>() const
|
||||
return v;
|
||||
}
|
||||
|
||||
#ifdef CV_CXX_STD_ARRAY
|
||||
template<typename _Tp> template<std::size_t _Nm> inline
|
||||
Mat_<_Tp>::operator std::array<_Tp, _Nm>() const
|
||||
{
|
||||
std::array<_Tp, _Nm> a;
|
||||
copyTo(a);
|
||||
return a;
|
||||
}
|
||||
#endif
|
||||
|
||||
template<typename _Tp> template<int n> inline
|
||||
Mat_<_Tp>::operator Vec<typename DataType<_Tp>::channel_type, n>() const
|
||||
{
|
||||
@@ -1818,7 +1935,7 @@ Mat_<_Tp>::Mat_(Mat_&& m)
|
||||
template<typename _Tp> inline
|
||||
Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m)
|
||||
{
|
||||
Mat::operator = (m);
|
||||
Mat::operator = (std::move(m));
|
||||
return *this;
|
||||
}
|
||||
|
||||
@@ -3426,7 +3543,6 @@ cols(1), allocator(0), usageFlags(USAGE_DEFAULT), u(0), offset(0), size(&rows)
|
||||
Mat((int)vec.size(), 1, DataType<_Tp>::type, (uchar*)&vec[0]).copyTo(*this);
|
||||
}
|
||||
|
||||
|
||||
inline
|
||||
UMat& UMat::operator = (const UMat& m)
|
||||
{
|
||||
|
||||
@@ -160,6 +160,8 @@ public:
|
||||
uint imagePitchAlignment() const;
|
||||
uint imageBaseAddressAlignment() const;
|
||||
|
||||
bool intelSubgroupsSupport() const;
|
||||
|
||||
size_t image2DMaxWidth() const;
|
||||
size_t image2DMaxHeight() const;
|
||||
|
||||
@@ -627,17 +629,18 @@ protected:
|
||||
class CV_EXPORTS ProgramSource
|
||||
{
|
||||
public:
|
||||
typedef uint64 hash_t;
|
||||
typedef uint64 hash_t; // deprecated
|
||||
|
||||
ProgramSource();
|
||||
explicit ProgramSource(const String& prog);
|
||||
explicit ProgramSource(const char* prog);
|
||||
explicit ProgramSource(const String& module, const String& name, const String& codeStr, const String& codeHash);
|
||||
explicit ProgramSource(const String& prog); // deprecated
|
||||
explicit ProgramSource(const char* prog); // deprecated
|
||||
~ProgramSource();
|
||||
ProgramSource(const ProgramSource& prog);
|
||||
ProgramSource& operator = (const ProgramSource& prog);
|
||||
|
||||
const String& source() const;
|
||||
hash_t hash() const;
|
||||
hash_t hash() const; // deprecated
|
||||
|
||||
protected:
|
||||
struct Impl;
|
||||
|
||||
@@ -42,23 +42,28 @@
|
||||
#ifndef OPENCV_OPENCL_GENBASE_HPP
|
||||
#define OPENCV_OPENCL_GENBASE_HPP
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace ocl
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
struct ProgramEntry
|
||||
namespace cv {
|
||||
namespace ocl {
|
||||
|
||||
class ProgramSource;
|
||||
|
||||
namespace internal {
|
||||
|
||||
struct CV_EXPORTS ProgramEntry
|
||||
{
|
||||
const char* module;
|
||||
const char* name;
|
||||
const char* programStr;
|
||||
const char* programCode;
|
||||
const char* programHash;
|
||||
ProgramSource* pProgramSource;
|
||||
|
||||
operator ProgramSource& () const;
|
||||
};
|
||||
|
||||
} } } // namespace
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -73,7 +73,7 @@ public:
|
||||
/** @brief Getter for the optimized function.
|
||||
|
||||
The optimized function is represented by Function interface, which requires derivatives to
|
||||
implement the sole method calc(double*) to evaluate the function.
|
||||
implement the calc(double*) and getDim() methods to evaluate the function.
|
||||
|
||||
@return Smart-pointer to an object that implements Function interface - it represents the
|
||||
function that is being optimized. It can be empty, if no function was given so far.
|
||||
|
||||
@@ -102,20 +102,6 @@ static inline void throw_no_cuda() { CV_Error(cv::Error::StsNotImplemented, "The
|
||||
|
||||
namespace cv { namespace cuda
|
||||
{
|
||||
class CV_EXPORTS BufferPool
|
||||
{
|
||||
public:
|
||||
explicit BufferPool(Stream& stream);
|
||||
|
||||
GpuMat getBuffer(int rows, int cols, int type);
|
||||
GpuMat getBuffer(Size size, int type) { return getBuffer(size.height, size.width, type); }
|
||||
|
||||
GpuMat::Allocator* getAllocator() const { return allocator_; }
|
||||
|
||||
private:
|
||||
GpuMat::Allocator* allocator_;
|
||||
};
|
||||
|
||||
static inline void checkNppError(int code, const char* file, const int line, const char* func)
|
||||
{
|
||||
if (code < 0)
|
||||
|
||||
@@ -66,17 +66,6 @@
|
||||
# undef max
|
||||
#endif
|
||||
|
||||
#if defined HAVE_FP16 && (defined __F16C__ || (defined _MSC_VER && _MSC_VER >= 1700))
|
||||
# include <immintrin.h>
|
||||
# define CV_FP16 1
|
||||
#elif defined HAVE_FP16 && defined __GNUC__
|
||||
# define CV_FP16 1
|
||||
#endif
|
||||
|
||||
#ifndef CV_FP16
|
||||
# define CV_FP16 0
|
||||
#endif
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
namespace cv
|
||||
@@ -196,28 +185,76 @@ CV_EXPORTS void scalarToRawData(const cv::Scalar& s, void* buf, int type, int un
|
||||
* Structures and macros for integration with IPP *
|
||||
\****************************************************************************************/
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#include "ipp.h"
|
||||
// Temporary disabled named IPP region. Accuracy
|
||||
#define IPP_DISABLE_PYRAMIDS_UP 1 // Different results
|
||||
#define IPP_DISABLE_PYRAMIDS_DOWN 1 // Different results
|
||||
#define IPP_DISABLE_PYRAMIDS_BUILD 1 // Different results
|
||||
#define IPP_DISABLE_WARPAFFINE 1 // Different results
|
||||
#define IPP_DISABLE_WARPPERSPECTIVE 1 // Different results
|
||||
#define IPP_DISABLE_REMAP 1 // Different results
|
||||
#define IPP_DISABLE_MORPH_ADV 1 // mask flipping in IPP
|
||||
#define IPP_DISABLE_SORT_IDX 0 // different order in index tables
|
||||
#define IPP_DISABLE_YUV_RGB 1 // accuracy difference
|
||||
#define IPP_DISABLE_RGB_YUV 1 // breaks OCL accuracy tests
|
||||
#define IPP_DISABLE_RGB_HSV 1 // breaks OCL accuracy tests
|
||||
#define IPP_DISABLE_RGB_LAB 1 // breaks OCL accuracy tests
|
||||
#define IPP_DISABLE_LAB_RGB 1 // breaks OCL accuracy tests
|
||||
#define IPP_DISABLE_RGB_XYZ 1 // big accuracy difference
|
||||
#define IPP_DISABLE_XYZ_RGB 1 // big accuracy difference
|
||||
#define IPP_DISABLE_HAAR 1 // improper integration/results
|
||||
#define IPP_DISABLE_HOUGH 1 // improper integration/results
|
||||
#define IPP_DISABLE_RESIZE_8U 1 // Incompatible accuracy
|
||||
#define IPP_DISABLE_RESIZE_NEAREST 1 // Accuracy mismatch (max diff 1)
|
||||
#define IPP_DISABLE_RESIZE_AREA 1 // Accuracy mismatch (max diff 1)
|
||||
|
||||
// Temporary disabled named IPP region. Performance
|
||||
#define IPP_DISABLE_PERF_COPYMAKE 1 // performance variations
|
||||
#define IPP_DISABLE_PERF_LUT 1 // there are no performance benefits (PR #2653)
|
||||
#define IPP_DISABLE_PERF_TRUE_DIST_MT 1 // cv::distanceTransform OpenCV MT performance is better
|
||||
#define IPP_DISABLE_PERF_CANNY_MT 1 // cv::Canny OpenCV MT performance is better
|
||||
#define IPP_DISABLE_PERF_HISTU32F_SSE42 1 // cv::calcHist optimizations problem
|
||||
#define IPP_DISABLE_PERF_MORPH_SSE42 1 // cv::erode, cv::dilate optimizations problem
|
||||
#define IPP_DISABLE_PERF_MAG_SSE42 1 // cv::magnitude optimizations problem
|
||||
#define IPP_DISABLE_PERF_BOX16S_SSE42 1 // cv::boxFilter optimizations problem
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#include "ippversion.h"
|
||||
#ifndef IPP_VERSION_UPDATE // prior to 7.1
|
||||
#define IPP_VERSION_UPDATE 0
|
||||
#endif
|
||||
|
||||
#define IPP_VERSION_X100 (IPP_VERSION_MAJOR * 100 + IPP_VERSION_MINOR*10 + IPP_VERSION_UPDATE)
|
||||
|
||||
// General define for ipp function disabling
|
||||
#define IPP_DISABLE_BLOCK 0
|
||||
#ifdef HAVE_IPP_ICV_ONLY
|
||||
#define ICV_BASE
|
||||
#if IPP_VERSION_X100 >= 201700
|
||||
#include "ippicv.h"
|
||||
#else
|
||||
#include "ipp.h"
|
||||
#endif
|
||||
#else
|
||||
#include "ipp.h"
|
||||
#endif
|
||||
#ifdef HAVE_IPP_IW
|
||||
#include "iw++/iw.hpp"
|
||||
#endif
|
||||
|
||||
#ifdef CV_MALLOC_ALIGN
|
||||
#undef CV_MALLOC_ALIGN
|
||||
#endif
|
||||
#define CV_MALLOC_ALIGN 32 // required for AVX optimization
|
||||
|
||||
#if IPP_VERSION_X100 >= 201700
|
||||
#define CV_IPP_MALLOC(SIZE) ippMalloc_L(SIZE)
|
||||
#else
|
||||
#define CV_IPP_MALLOC(SIZE) ippMalloc((int)SIZE)
|
||||
#endif
|
||||
|
||||
#define setIppErrorStatus() cv::ipp::setIppStatus(-1, CV_Func, __FILE__, __LINE__)
|
||||
|
||||
static inline IppiSize ippiSize(int width, int height)
|
||||
static inline IppiSize ippiSize(size_t width, size_t height)
|
||||
{
|
||||
IppiSize size = { width, height };
|
||||
IppiSize size = { (int)width, (int)height };
|
||||
return size;
|
||||
}
|
||||
|
||||
@@ -227,6 +264,20 @@ static inline IppiSize ippiSize(const cv::Size & _size)
|
||||
return size;
|
||||
}
|
||||
|
||||
#if IPP_VERSION_X100 >= 201700
|
||||
static inline IppiSizeL ippiSizeL(size_t width, size_t height)
|
||||
{
|
||||
IppiSizeL size = { (IppSizeL)width, (IppSizeL)height };
|
||||
return size;
|
||||
}
|
||||
|
||||
static inline IppiSizeL ippiSizeL(const cv::Size & _size)
|
||||
{
|
||||
IppiSizeL size = { _size.width, _size.height };
|
||||
return size;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline IppiPoint ippiPoint(const cv::Point & _point)
|
||||
{
|
||||
IppiPoint point = { _point.x, _point.y };
|
||||
@@ -241,34 +292,177 @@ static inline IppiPoint ippiPoint(int x, int y)
|
||||
|
||||
static inline IppiBorderType ippiGetBorderType(int borderTypeNI)
|
||||
{
|
||||
return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst :
|
||||
borderTypeNI == cv::BORDER_WRAP ? ippBorderWrap :
|
||||
borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl :
|
||||
borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror :
|
||||
borderTypeNI == cv::BORDER_REFLECT ? ippBorderMirrorR : (IppiBorderType)-1;
|
||||
return borderTypeNI == cv::BORDER_CONSTANT ? ippBorderConst :
|
||||
borderTypeNI == cv::BORDER_TRANSPARENT ? ippBorderTransp :
|
||||
borderTypeNI == cv::BORDER_REPLICATE ? ippBorderRepl :
|
||||
borderTypeNI == cv::BORDER_REFLECT_101 ? ippBorderMirror :
|
||||
(IppiBorderType)-1;
|
||||
}
|
||||
|
||||
static inline IppiMaskSize ippiGetMaskSize(int kx, int ky)
|
||||
{
|
||||
return (kx == 1 && ky == 3) ? ippMskSize1x3 :
|
||||
(kx == 1 && ky == 5) ? ippMskSize1x5 :
|
||||
(kx == 3 && ky == 1) ? ippMskSize3x1 :
|
||||
(kx == 3 && ky == 3) ? ippMskSize3x3 :
|
||||
(kx == 5 && ky == 1) ? ippMskSize5x1 :
|
||||
(kx == 5 && ky == 5) ? ippMskSize5x5 :
|
||||
(IppiMaskSize)-1;
|
||||
}
|
||||
|
||||
static inline IppDataType ippiGetDataType(int depth)
|
||||
{
|
||||
depth = CV_MAT_DEPTH(depth);
|
||||
return depth == CV_8U ? ipp8u :
|
||||
depth == CV_8S ? ipp8s :
|
||||
depth == CV_16U ? ipp16u :
|
||||
depth == CV_16S ? ipp16s :
|
||||
depth == CV_32S ? ipp32s :
|
||||
depth == CV_32F ? ipp32f :
|
||||
depth == CV_64F ? ipp64f : (IppDataType)-1;
|
||||
depth == CV_64F ? ipp64f :
|
||||
(IppDataType)-1;
|
||||
}
|
||||
|
||||
// IPP temporary buffer hepler
|
||||
#ifdef HAVE_IPP_IW
|
||||
static inline IwiDerivativeType ippiGetDerivType(int dx, int dy, bool nvert)
|
||||
{
|
||||
return (dx == 1 && dy == 0) ? ((nvert)?iwiDerivNVerFirst:iwiDerivVerFirst) :
|
||||
(dx == 0 && dy == 1) ? iwiDerivHorFirst :
|
||||
(dx == 2 && dy == 0) ? iwiDerivVerSecond :
|
||||
(dx == 0 && dy == 2) ? iwiDerivHorSecond :
|
||||
(IwiDerivativeType)-1;
|
||||
}
|
||||
|
||||
static inline void ippiGetImage(const cv::Mat &src, ::ipp::IwiImage &dst)
|
||||
{
|
||||
::ipp::IwiBorderSize inMemBorder;
|
||||
if(src.isSubmatrix()) // already have physical border
|
||||
{
|
||||
cv::Size origSize;
|
||||
cv::Point offset;
|
||||
src.locateROI(origSize, offset);
|
||||
|
||||
inMemBorder.borderLeft = (Ipp32u)offset.x;
|
||||
inMemBorder.borderTop = (Ipp32u)offset.y;
|
||||
inMemBorder.borderRight = (Ipp32u)(origSize.width - src.cols - offset.x);
|
||||
inMemBorder.borderBottom = (Ipp32u)(origSize.height - src.rows - offset.y);
|
||||
}
|
||||
|
||||
dst.Init(ippiSize(src.size()), ippiGetDataType(src.depth()), src.channels(), inMemBorder, (void*)src.ptr(), src.step);
|
||||
}
|
||||
|
||||
static inline ::ipp::IwiImage ippiGetImage(const cv::Mat &src)
|
||||
{
|
||||
::ipp::IwiImage image;
|
||||
ippiGetImage(src, image);
|
||||
return image;
|
||||
}
|
||||
|
||||
static inline IppiBorderType ippiGetBorder(::ipp::IwiImage &image, int ocvBorderType, IppiBorderSize &borderSize)
|
||||
{
|
||||
int inMemFlags = 0;
|
||||
IppiBorderType border = ippiGetBorderType(ocvBorderType & ~cv::BORDER_ISOLATED);
|
||||
if((int)border == -1)
|
||||
return (IppiBorderType)0;
|
||||
|
||||
if(!(ocvBorderType & cv::BORDER_ISOLATED))
|
||||
{
|
||||
if(image.m_inMemSize.borderLeft)
|
||||
{
|
||||
if(image.m_inMemSize.borderLeft >= borderSize.borderLeft)
|
||||
inMemFlags |= ippBorderInMemLeft;
|
||||
else
|
||||
return (IppiBorderType)0;
|
||||
}
|
||||
else
|
||||
borderSize.borderLeft = 0;
|
||||
if(image.m_inMemSize.borderTop)
|
||||
{
|
||||
if(image.m_inMemSize.borderTop >= borderSize.borderTop)
|
||||
inMemFlags |= ippBorderInMemTop;
|
||||
else
|
||||
return (IppiBorderType)0;
|
||||
}
|
||||
else
|
||||
borderSize.borderTop = 0;
|
||||
if(image.m_inMemSize.borderRight)
|
||||
{
|
||||
if(image.m_inMemSize.borderRight >= borderSize.borderRight)
|
||||
inMemFlags |= ippBorderInMemRight;
|
||||
else
|
||||
return (IppiBorderType)0;
|
||||
}
|
||||
else
|
||||
borderSize.borderRight = 0;
|
||||
if(image.m_inMemSize.borderBottom)
|
||||
{
|
||||
if(image.m_inMemSize.borderBottom >= borderSize.borderBottom)
|
||||
inMemFlags |= ippBorderInMemBottom;
|
||||
else
|
||||
return (IppiBorderType)0;
|
||||
}
|
||||
else
|
||||
borderSize.borderBottom = 0;
|
||||
}
|
||||
else
|
||||
borderSize.borderLeft = borderSize.borderRight = borderSize.borderTop = borderSize.borderBottom = 0;
|
||||
|
||||
return (IppiBorderType)(border|inMemFlags);
|
||||
}
|
||||
|
||||
static inline ::ipp::IwValue ippiGetValue(const cv::Scalar &scalar)
|
||||
{
|
||||
return ::ipp::IwValue(scalar[0], scalar[1], scalar[2], scalar[3]);
|
||||
}
|
||||
|
||||
static inline int ippiSuggestThreadsNum(const ::ipp::IwiImage &image, double multiplier)
|
||||
{
|
||||
int threads = cv::getNumThreads();
|
||||
if(image.m_size.height > threads)
|
||||
{
|
||||
size_t opMemory = (int)(image.m_step*image.m_size.height*multiplier);
|
||||
int l2cache = 0;
|
||||
#if IPP_VERSION_X100 >= 201700
|
||||
ippGetL2CacheSize(&l2cache);
|
||||
#endif
|
||||
if(!l2cache)
|
||||
l2cache = 1 << 18;
|
||||
|
||||
return IPP_MAX(1, (IPP_MIN((int)(opMemory/l2cache), threads)));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline int ippiSuggestThreadsNum(const cv::Mat &image, double multiplier)
|
||||
{
|
||||
int threads = cv::getNumThreads();
|
||||
if(image.rows > threads)
|
||||
{
|
||||
size_t opMemory = (int)(image.total()*multiplier);
|
||||
int l2cache = 0;
|
||||
#if IPP_VERSION_X100 >= 201700
|
||||
ippGetL2CacheSize(&l2cache);
|
||||
#endif
|
||||
if(!l2cache)
|
||||
l2cache = 1 << 18;
|
||||
|
||||
return IPP_MAX(1, (IPP_MIN((int)(opMemory/l2cache), threads)));
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
// IPP temporary buffer helper
|
||||
template<typename T>
|
||||
class IppAutoBuffer
|
||||
{
|
||||
public:
|
||||
IppAutoBuffer() { m_pBuffer = NULL; }
|
||||
IppAutoBuffer(int size) { Alloc(size); }
|
||||
~IppAutoBuffer() { Release(); }
|
||||
T* Alloc(int size) { m_pBuffer = (T*)ippMalloc(size); return m_pBuffer; }
|
||||
void Release() { if(m_pBuffer) ippFree(m_pBuffer); }
|
||||
IppAutoBuffer() { m_size = 0; m_pBuffer = NULL; }
|
||||
IppAutoBuffer(size_t size) { m_size = 0; m_pBuffer = NULL; allocate(size); }
|
||||
~IppAutoBuffer() { deallocate(); }
|
||||
T* allocate(size_t size) { if(m_size < size) { deallocate(); m_pBuffer = (T*)CV_IPP_MALLOC(size); m_size = size; } return m_pBuffer; }
|
||||
void deallocate() { if(m_pBuffer) { ippFree(m_pBuffer); m_pBuffer = NULL; } m_size = 0; }
|
||||
inline T* get() { return (T*)m_pBuffer;}
|
||||
inline operator T* () { return (T*)m_pBuffer;}
|
||||
inline operator const T* () const { return (const T*)m_pBuffer;}
|
||||
private:
|
||||
@@ -276,9 +470,17 @@ private:
|
||||
IppAutoBuffer(IppAutoBuffer &) {}
|
||||
IppAutoBuffer& operator =(const IppAutoBuffer &) {return *this;}
|
||||
|
||||
T* m_pBuffer;
|
||||
size_t m_size;
|
||||
T* m_pBuffer;
|
||||
};
|
||||
|
||||
// Extracts border interpolation type without flags
|
||||
#if IPP_VERSION_MAJOR >= 2017
|
||||
#define IPP_BORDER_INTER(BORDER) (IppiBorderType)((BORDER)&0xF|((((BORDER)&ippBorderInMem) == ippBorderInMem)?ippBorderInMem:0));
|
||||
#else
|
||||
#define IPP_BORDER_INTER(BORDER) (IppiBorderType)((BORDER)&0xF);
|
||||
#endif
|
||||
|
||||
#else
|
||||
#define IPP_VERSION_X100 0
|
||||
#endif
|
||||
@@ -540,7 +742,7 @@ CV_EXPORTS InstrNode* getCurrentNode();
|
||||
|
||||
///// General instrumentation
|
||||
// General OpenCV region instrumentation macro
|
||||
#define CV_INSTRUMENT_REGION() CV_INSTRUMENT_REGION_META(__FUNCTION__, false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN)
|
||||
#define CV_INSTRUMENT_REGION_() CV_INSTRUMENT_REGION_META(__FUNCTION__, false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN)
|
||||
// Custom OpenCV region instrumentation macro
|
||||
#define CV_INSTRUMENT_REGION_NAME(NAME) CV_INSTRUMENT_REGION_CUSTOM_META(NAME, false, ::cv::instr::TYPE_GENERAL, ::cv::instr::IMPL_PLAIN)
|
||||
// Instrumentation for parallel_for_ or other regions which forks and gathers threads
|
||||
@@ -566,7 +768,7 @@ CV_EXPORTS InstrNode* getCurrentNode();
|
||||
#else
|
||||
#define CV_INSTRUMENT_REGION_META(...)
|
||||
|
||||
#define CV_INSTRUMENT_REGION()
|
||||
#define CV_INSTRUMENT_REGION_()
|
||||
#define CV_INSTRUMENT_REGION_NAME(...)
|
||||
#define CV_INSTRUMENT_REGION_MT_FORK()
|
||||
|
||||
@@ -580,6 +782,12 @@ CV_EXPORTS InstrNode* getCurrentNode();
|
||||
#define CV_INSTRUMENT_MARK_OPENCL(...)
|
||||
#endif
|
||||
|
||||
#ifdef __CV_AVX_GUARD
|
||||
#define CV_INSTRUMENT_REGION() __CV_AVX_GUARD CV_INSTRUMENT_REGION_()
|
||||
#else
|
||||
#define CV_INSTRUMENT_REGION() CV_INSTRUMENT_REGION_()
|
||||
#endif
|
||||
|
||||
//! @endcond
|
||||
|
||||
#endif // OPENCV_CORE_PRIVATE_HPP
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
// Helper file to include dispatched functions declaration:
|
||||
//
|
||||
// Usage:
|
||||
// #define CV_CPU_SIMD_FILENAME "<filename>.simd.hpp"
|
||||
// #define CV_CPU_DISPATCH_MODE AVX2
|
||||
// #include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp"
|
||||
// #define CV_CPU_DISPATCH_MODE SSE2
|
||||
// #include "opencv2/core/private/cv_cpu_include_simd_declarations.hpp"
|
||||
|
||||
#ifndef CV_DISABLE_OPTIMIZATION
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(disable: 4702) // unreachable code
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
#define CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
|
||||
#endif
|
||||
|
||||
#undef CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
#undef CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN namespace __CV_CAT(opt_, CV_CPU_DISPATCH_MODE) {
|
||||
#define CV_CPU_OPTIMIZATION_NAMESPACE_END }
|
||||
|
||||
#include CV_CPU_SIMD_FILENAME
|
||||
|
||||
#undef CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
|
||||
#undef CV_CPU_OPTIMIZATION_NAMESPACE_END
|
||||
#undef CV_CPU_DISPATCH_MODE
|
||||
@@ -130,24 +130,24 @@ enum {
|
||||
CV_BadImageSize= -10, /**< image size is invalid */
|
||||
CV_BadOffset= -11, /**< offset is invalid */
|
||||
CV_BadDataPtr= -12, /**/
|
||||
CV_BadStep= -13, /**/
|
||||
CV_BadStep= -13, /**< image step is wrong, this may happen for a non-continuous matrix */
|
||||
CV_BadModelOrChSeq= -14, /**/
|
||||
CV_BadNumChannels= -15, /**/
|
||||
CV_BadNumChannels= -15, /**< bad number of channels, for example, some functions accept only single channel matrices */
|
||||
CV_BadNumChannel1U= -16, /**/
|
||||
CV_BadDepth= -17, /**/
|
||||
CV_BadDepth= -17, /**< input image depth is not supported by the function */
|
||||
CV_BadAlphaChannel= -18, /**/
|
||||
CV_BadOrder= -19, /**/
|
||||
CV_BadOrigin= -20, /**/
|
||||
CV_BadAlign= -21, /**/
|
||||
CV_BadOrder= -19, /**< number of dimensions is out of range */
|
||||
CV_BadOrigin= -20, /**< incorrect input origin */
|
||||
CV_BadAlign= -21, /**< incorrect input align */
|
||||
CV_BadCallBack= -22, /**/
|
||||
CV_BadTileSize= -23, /**/
|
||||
CV_BadCOI= -24, /**/
|
||||
CV_BadROISize= -25, /**/
|
||||
CV_BadCOI= -24, /**< input COI is not supported */
|
||||
CV_BadROISize= -25, /**< incorrect input roi */
|
||||
CV_MaskIsTiled= -26, /**/
|
||||
CV_StsNullPtr= -27, /**< null pointer */
|
||||
CV_StsVecLengthErr= -28, /**< incorrect vector length */
|
||||
CV_StsFilterStructContentErr= -29, /**< incorr. filter structure content */
|
||||
CV_StsKernelStructContentErr= -30, /**< incorr. transform kernel content */
|
||||
CV_StsFilterStructContentErr= -29, /**< incorrect filter structure content */
|
||||
CV_StsKernelStructContentErr= -30, /**< incorrect transform kernel content */
|
||||
CV_StsFilterOffsetErr= -31, /**< incorrect filter offset value */
|
||||
CV_StsBadSize= -201, /**< the input/output structure size is incorrect */
|
||||
CV_StsDivByZero= -202, /**< division by zero */
|
||||
@@ -163,14 +163,14 @@ enum {
|
||||
CV_StsParseError= -212, /**< invalid syntax/structure of the parsed file */
|
||||
CV_StsNotImplemented= -213, /**< the requested function/feature is not implemented */
|
||||
CV_StsBadMemBlock= -214, /**< an allocated block has been corrupted */
|
||||
CV_StsAssert= -215, /**< assertion failed */
|
||||
CV_GpuNotSupported= -216,
|
||||
CV_GpuApiCallError= -217,
|
||||
CV_OpenGlNotSupported= -218,
|
||||
CV_OpenGlApiCallError= -219,
|
||||
CV_OpenCLApiCallError= -220,
|
||||
CV_StsAssert= -215, /**< assertion failed */
|
||||
CV_GpuNotSupported= -216, /**< no CUDA support */
|
||||
CV_GpuApiCallError= -217, /**< GPU API call error */
|
||||
CV_OpenGlNotSupported= -218, /**< no OpenGL support */
|
||||
CV_OpenGlApiCallError= -219, /**< OpenGL API call error */
|
||||
CV_OpenCLApiCallError= -220, /**< OpenCL API call error */
|
||||
CV_OpenCLDoubleNotSupported= -221,
|
||||
CV_OpenCLInitError= -222,
|
||||
CV_OpenCLInitError= -222, /**< OpenCL initialization error */
|
||||
CV_OpenCLNoAMDBlasFft= -223
|
||||
};
|
||||
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#endif
|
||||
|
||||
#include "opencv2/core.hpp"
|
||||
#include <ostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
@@ -507,7 +508,7 @@ void Mat::forEach_impl(const Functor& operation) {
|
||||
this->rowCall2(row, COLS);
|
||||
}
|
||||
} else {
|
||||
std::vector<int> idx(COLS); /// idx is modified in this->rowCall
|
||||
std::vector<int> idx(DIMS); /// idx is modified in this->rowCall
|
||||
idx[DIMS - 2] = range.start - 1;
|
||||
|
||||
for (int line_num = range.start; line_num < range.end; ++line_num) {
|
||||
|
||||
@@ -45,9 +45,6 @@ public class DMatch {
|
||||
distance = _distance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Less is better.
|
||||
*/
|
||||
public boolean lessThan(DMatch it) {
|
||||
return distance < it.distance;
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ OCL_PERF_TEST_P(CopyToFixture, CopyToWithMaskUninit,
|
||||
dst.release();
|
||||
startTimer();
|
||||
src.copyTo(dst, mask);
|
||||
cv::ocl::finish();
|
||||
cvtest::ocl::perf::safeFinish();
|
||||
stopTimer();
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace perf;
|
||||
|
||||
typedef perf::TestBaseWithParam<Size> SizePrm;
|
||||
|
||||
PERF_TEST_P( SizePrm, LUT,
|
||||
testing::Values(szQVGA, szVGA, sz1080p)
|
||||
)
|
||||
{
|
||||
Size sz = GetParam();
|
||||
|
||||
int maxValue = 255;
|
||||
|
||||
Mat src(sz, CV_8UC1);
|
||||
randu(src, 0, maxValue);
|
||||
Mat lut(1, 256, CV_8UC1);
|
||||
randu(lut, 0, maxValue);
|
||||
Mat dst(sz, CV_8UC1);
|
||||
|
||||
TEST_CYCLE() LUT(src, lut, dst);
|
||||
|
||||
SANITY_CHECK(dst, 0.1);
|
||||
}
|
||||
+289
-50
@@ -85,6 +85,66 @@ static MergeFunc getMergeFunc(int depth)
|
||||
return mergeTab[depth];
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#ifdef HAVE_IPP_IW
|
||||
extern "C" {
|
||||
IW_DECL(IppStatus) llwiCopySplit(const void *pSrc, int srcStep, void* const pDstOrig[], int dstStep,
|
||||
IppiSize size, int typeSize, int channels);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
static bool ipp_split(const Mat& src, Mat* mv, int channels)
|
||||
{
|
||||
#ifdef HAVE_IPP_IW
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
if(channels != 3 && channels != 4)
|
||||
return false;
|
||||
|
||||
if(src.dims <= 2)
|
||||
{
|
||||
IppiSize size = ippiSize(src.size());
|
||||
void *dstPtrs[4] = {NULL};
|
||||
size_t dstStep = mv[0].step;
|
||||
for(int i = 0; i < channels; i++)
|
||||
{
|
||||
dstPtrs[i] = mv[i].ptr();
|
||||
if(dstStep != mv[i].step)
|
||||
return false;
|
||||
}
|
||||
|
||||
return CV_INSTRUMENT_FUN_IPP(llwiCopySplit, src.ptr(), (int)src.step, dstPtrs, (int)dstStep, size, (int)src.elemSize1(), channels) >= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[5] = {NULL};
|
||||
uchar *ptrs[5] = {NULL};
|
||||
arrays[0] = &src;
|
||||
|
||||
for(int i = 1; i < channels; i++)
|
||||
{
|
||||
arrays[i] = &mv[i-1];
|
||||
}
|
||||
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
IppiSize size = { (int)it.size, 1 };
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(llwiCopySplit, ptrs[0], 0, (void**)&ptrs[1], 0, size, (int)src.elemSize1(), channels) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(src); CV_UNUSED(mv); CV_UNUSED(channels);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::split(const Mat& src, Mat* mv)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -96,6 +156,13 @@ void cv::split(const Mat& src, Mat* mv)
|
||||
return;
|
||||
}
|
||||
|
||||
for( k = 0; k < cn; k++ )
|
||||
{
|
||||
mv[k].create(src.dims, src.size, depth);
|
||||
}
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_split(src, mv, cn));
|
||||
|
||||
SplitFunc func = getSplitFunc(depth);
|
||||
CV_Assert( func != 0 );
|
||||
|
||||
@@ -108,7 +175,6 @@ void cv::split(const Mat& src, Mat* mv)
|
||||
arrays[0] = &src;
|
||||
for( k = 0; k < cn; k++ )
|
||||
{
|
||||
mv[k].create(src.dims, src.size, depth);
|
||||
arrays[k+1] = &mv[k];
|
||||
}
|
||||
|
||||
@@ -206,6 +272,66 @@ void cv::split(InputArray _m, OutputArrayOfArrays _mv)
|
||||
split(m, &dst[0]);
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#ifdef HAVE_IPP_IW
|
||||
extern "C" {
|
||||
IW_DECL(IppStatus) llwiCopyMerge(const void* const pSrc[], int srcStep, void *pDst, int dstStep,
|
||||
IppiSize size, int typeSize, int channels);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
static bool ipp_merge(const Mat* mv, Mat& dst, int channels)
|
||||
{
|
||||
#ifdef HAVE_IPP_IW
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
if(channels != 3 && channels != 4)
|
||||
return false;
|
||||
|
||||
if(mv[0].dims <= 2)
|
||||
{
|
||||
IppiSize size = ippiSize(mv[0].size());
|
||||
const void *srcPtrs[4] = {NULL};
|
||||
size_t srcStep = mv[0].step;
|
||||
for(int i = 0; i < channels; i++)
|
||||
{
|
||||
srcPtrs[i] = mv[i].ptr();
|
||||
if(srcStep != mv[i].step)
|
||||
return false;
|
||||
}
|
||||
|
||||
return CV_INSTRUMENT_FUN_IPP(llwiCopyMerge, srcPtrs, (int)srcStep, dst.ptr(), (int)dst.step, size, (int)mv[0].elemSize1(), channels) >= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[5] = {NULL};
|
||||
uchar *ptrs[5] = {NULL};
|
||||
arrays[0] = &dst;
|
||||
|
||||
for(int i = 1; i < channels; i++)
|
||||
{
|
||||
arrays[i] = &mv[i-1];
|
||||
}
|
||||
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
IppiSize size = { (int)it.size, 1 };
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(llwiCopyMerge, (const void**)&ptrs[1], 0, ptrs[0], 0, size, (int)mv[0].elemSize1(), channels) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(dst); CV_UNUSED(mv); CV_UNUSED(channels);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -234,6 +360,8 @@ void cv::merge(const Mat* mv, size_t n, OutputArray _dst)
|
||||
return;
|
||||
}
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_merge(mv, dst, (int)n));
|
||||
|
||||
if( !allch1 )
|
||||
{
|
||||
AutoBuffer<int> pairs(cn*2);
|
||||
@@ -637,9 +765,11 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
|
||||
ocl_mixChannels(src, dst, fromTo, npairs))
|
||||
|
||||
bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT &&
|
||||
src.kind() != _InputArray::STD_ARRAY_MAT &&
|
||||
src.kind() != _InputArray::STD_VECTOR_VECTOR &&
|
||||
src.kind() != _InputArray::STD_VECTOR_UMAT;
|
||||
bool dst_is_mat = dst.kind() != _InputArray::STD_VECTOR_MAT &&
|
||||
dst.kind() != _InputArray::STD_ARRAY_MAT &&
|
||||
dst.kind() != _InputArray::STD_VECTOR_VECTOR &&
|
||||
dst.kind() != _InputArray::STD_VECTOR_UMAT;
|
||||
int i;
|
||||
@@ -668,9 +798,11 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
|
||||
ocl_mixChannels(src, dst, &fromTo[0], fromTo.size()>>1))
|
||||
|
||||
bool src_is_mat = src.kind() != _InputArray::STD_VECTOR_MAT &&
|
||||
src.kind() != _InputArray::STD_ARRAY_MAT &&
|
||||
src.kind() != _InputArray::STD_VECTOR_VECTOR &&
|
||||
src.kind() != _InputArray::STD_VECTOR_UMAT;
|
||||
bool dst_is_mat = dst.kind() != _InputArray::STD_VECTOR_MAT &&
|
||||
dst.kind() != _InputArray::STD_ARRAY_MAT &&
|
||||
dst.kind() != _InputArray::STD_VECTOR_VECTOR &&
|
||||
dst.kind() != _InputArray::STD_VECTOR_UMAT;
|
||||
int i;
|
||||
@@ -687,6 +819,59 @@ void cv::mixChannels(InputArrayOfArrays src, InputOutputArrayOfArrays dst,
|
||||
mixChannels(&buf[0], nsrc, &buf[nsrc], ndst, &fromTo[0], fromTo.size()/2);
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
#ifdef HAVE_IPP_IW
|
||||
extern "C" {
|
||||
IW_DECL(IppStatus) llwiCopyMixed(const void *pSrc, int srcStep, int srcChannels, void *pDst, int dstStep, int dstChannels,
|
||||
IppiSize size, int typeSize, int channelsShift);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
static bool ipp_extractInsertChannel(const Mat &src, Mat &dst, int channel)
|
||||
{
|
||||
#ifdef HAVE_IPP_IW
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
int srcChannels = src.channels();
|
||||
int dstChannels = dst.channels();
|
||||
|
||||
if(src.dims != dst.dims)
|
||||
return false;
|
||||
|
||||
if(srcChannels == dstChannels || (srcChannels != 1 && dstChannels != 1))
|
||||
return false;
|
||||
|
||||
if(src.dims <= 2)
|
||||
{
|
||||
IppiSize size = ippiSize(src.size());
|
||||
|
||||
return CV_INSTRUMENT_FUN_IPP(llwiCopyMixed, src.ptr(), (int)src.step, srcChannels, dst.ptr(), (int)dst.step, dstChannels, size, (int)src.elemSize1(), channel) >= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[] = {&dst, NULL};
|
||||
uchar *ptrs[2] = {NULL};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
|
||||
IppiSize size = {(int)it.size, 1};
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(llwiCopyMixed, ptrs[0], 0, srcChannels, ptrs[1], 0, dstChannels, size, (int)src.elemSize1(), channel) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(channel);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::extractChannel(InputArray _src, OutputArray _dst, int coi)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -707,6 +892,9 @@ void cv::extractChannel(InputArray _src, OutputArray _dst, int coi)
|
||||
Mat src = _src.getMat();
|
||||
_dst.create(src.dims, &src.size[0], depth);
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_extractInsertChannel(src, dst, coi))
|
||||
|
||||
mixChannels(&src, 1, &dst, 1, ch, 1);
|
||||
}
|
||||
|
||||
@@ -728,6 +916,9 @@ void cv::insertChannel(InputArray _src, InputOutputArray _dst, int coi)
|
||||
}
|
||||
|
||||
Mat src = _src.getMat(), dst = _dst.getMat();
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_extractInsertChannel(src, dst, coi))
|
||||
|
||||
mixChannels(&src, 1, &dst, 1, ch, 1);
|
||||
}
|
||||
|
||||
@@ -5260,6 +5451,72 @@ void cv::convertFp16( InputArray _src, OutputArray _dst)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
namespace cv
|
||||
{
|
||||
static bool ipp_convertTo(Mat &src, Mat &dst, double alpha, double beta)
|
||||
{
|
||||
#ifdef HAVE_IPP_IW
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
IppDataType srcDepth = ippiGetDataType(src.depth());
|
||||
IppDataType dstDepth = ippiGetDataType(dst.depth());
|
||||
int channels = src.channels();
|
||||
|
||||
if(src.dims == 0)
|
||||
return false;
|
||||
|
||||
::ipp::IwiImage iwSrc;
|
||||
::ipp::IwiImage iwDst;
|
||||
|
||||
try
|
||||
{
|
||||
IppHintAlgorithm mode = ippAlgHintFast;
|
||||
if(dstDepth == ipp64f ||
|
||||
(dstDepth == ipp32f && (srcDepth == ipp32s || srcDepth == ipp64f)) ||
|
||||
(dstDepth == ipp32s && (srcDepth == ipp32s || srcDepth == ipp64f)))
|
||||
mode = ippAlgHintAccurate;
|
||||
|
||||
if(src.dims <= 2)
|
||||
{
|
||||
Size sz = getContinuousSize(src, dst, channels);
|
||||
|
||||
iwSrc.Init(ippiSize(sz), srcDepth, 1, NULL, (void*)src.ptr(), src.step);
|
||||
iwDst.Init(ippiSize(sz), dstDepth, 1, NULL, (void*)dst.ptr(), dst.step);
|
||||
|
||||
CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwSrc, &iwDst, alpha, beta, mode);
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[] = {&src, &dst, NULL};
|
||||
uchar *ptrs[2] = {NULL};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
|
||||
iwSrc.Init(ippiSize(it.size, 1), srcDepth, channels);
|
||||
iwDst.Init(ippiSize(it.size, 1), dstDepth, channels);
|
||||
|
||||
for(size_t i = 0; i < it.nplanes; i++, ++it)
|
||||
{
|
||||
iwSrc.m_ptr = ptrs[0];
|
||||
iwDst.m_ptr = ptrs[1];
|
||||
|
||||
CV_INSTRUMENT_FUN_IPP(::ipp::iwiScale, &iwSrc, &iwDst, alpha, beta, mode);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (::ipp::IwException)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(alpha); CV_UNUSED(beta);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta) const
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -5279,6 +5536,13 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta)
|
||||
}
|
||||
|
||||
Mat src = *this;
|
||||
if( dims <= 2 )
|
||||
_dst.create( size(), _type );
|
||||
else
|
||||
_dst.create( dims, size, _type );
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_convertTo(src, dst, alpha, beta ));
|
||||
|
||||
BinaryFunc func = noScale ? getConvertFunc(sdepth, ddepth) : getConvertScaleFunc(sdepth, ddepth);
|
||||
double scale[] = {alpha, beta};
|
||||
@@ -5287,15 +5551,12 @@ void cv::Mat::convertTo(OutputArray _dst, int _type, double alpha, double beta)
|
||||
|
||||
if( dims <= 2 )
|
||||
{
|
||||
_dst.create( size(), _type );
|
||||
Mat dst = _dst.getMat();
|
||||
Size sz = getContinuousSize(src, dst, cn);
|
||||
|
||||
func( src.data, src.step, 0, 0, dst.data, dst.step, sz, scale );
|
||||
}
|
||||
else
|
||||
{
|
||||
_dst.create( dims, size, _type );
|
||||
Mat dst = _dst.getMat();
|
||||
const Mat* arrays[] = {&src, &dst, 0};
|
||||
uchar* ptrs[2];
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
@@ -5432,9 +5693,9 @@ static bool openvx_LUT(Mat src, Mat dst, Mat _lut)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_IPP)
|
||||
#if !IPP_DISABLE_PERF_LUT // there are no performance benefits (PR #2653)
|
||||
namespace ipp {
|
||||
|
||||
#if IPP_DISABLE_BLOCK // there are no performance benefits (PR #2653)
|
||||
class IppLUTParallelBody_LUTC1 : public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
@@ -5443,25 +5704,17 @@ public:
|
||||
const Mat& lut_;
|
||||
Mat& dst_;
|
||||
|
||||
typedef IppStatus (*IppFn)(const Ipp8u* pSrc, int srcStep, void* pDst, int dstStep,
|
||||
IppiSize roiSize, const void* pTable, int nBitSize);
|
||||
IppFn fn;
|
||||
|
||||
int width;
|
||||
size_t elemSize1;
|
||||
|
||||
IppLUTParallelBody_LUTC1(const Mat& src, const Mat& lut, Mat& dst, bool* _ok)
|
||||
: ok(_ok), src_(src), lut_(lut), dst_(dst)
|
||||
{
|
||||
width = dst.cols * dst.channels();
|
||||
elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
||||
|
||||
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
||||
|
||||
fn =
|
||||
elemSize1 == 1 ? (IppFn)ippiLUTPalette_8u_C1R :
|
||||
elemSize1 == 4 ? (IppFn)ippiLUTPalette_8u32u_C1R :
|
||||
NULL;
|
||||
|
||||
*ok = (fn != NULL);
|
||||
CV_DbgAssert(elemSize1 == 1 || elemSize1 == 4);
|
||||
*ok = true;
|
||||
}
|
||||
|
||||
void operator()( const cv::Range& range ) const
|
||||
@@ -5477,19 +5730,22 @@ public:
|
||||
|
||||
IppiSize sz = { width, dst.rows };
|
||||
|
||||
CV_DbgAssert(fn != NULL);
|
||||
if (fn(src.data, (int)src.step[0], dst.data, (int)dst.step[0], sz, lut_.data, 8) < 0)
|
||||
if (elemSize1 == 1)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
*ok = false;
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C1R, (const Ipp8u*)src.data, (int)src.step[0], dst.data, (int)dst.step[0], sz, lut_.data, 8) >= 0)
|
||||
return;
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
else if (elemSize1 == 4)
|
||||
{
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u32u_C1R, (const Ipp8u*)src.data, (int)src.step[0], (Ipp32u*)dst.data, (int)dst.step[0], sz, (Ipp32u*)lut_.data, 8) >= 0)
|
||||
return;
|
||||
}
|
||||
*ok = false;
|
||||
}
|
||||
private:
|
||||
IppLUTParallelBody_LUTC1(const IppLUTParallelBody_LUTC1&);
|
||||
IppLUTParallelBody_LUTC1& operator=(const IppLUTParallelBody_LUTC1&);
|
||||
};
|
||||
#endif
|
||||
|
||||
class IppLUTParallelBody_LUTCN : public ParallelLoopBody
|
||||
{
|
||||
@@ -5512,7 +5768,7 @@ public:
|
||||
|
||||
size_t elemSize1 = dst.elemSize1();
|
||||
CV_DbgAssert(elemSize1 == 1);
|
||||
lutBuffer = (uchar*)ippMalloc(256 * (int)elemSize1 * 4);
|
||||
lutBuffer = (uchar*)CV_IPP_MALLOC(256 * (int)elemSize1 * 4);
|
||||
lutTable[0] = lutBuffer + 0;
|
||||
lutTable[1] = lutBuffer + 1 * 256 * elemSize1;
|
||||
lutTable[2] = lutBuffer + 2 * 256 * elemSize1;
|
||||
@@ -5523,21 +5779,13 @@ public:
|
||||
{
|
||||
IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C3P3R, lut.ptr(), (int)lut.step[0], lutTable, (int)lut.step[0], sz256);
|
||||
if (status < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
return;
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
}
|
||||
else if (lutcn == 4)
|
||||
{
|
||||
IppStatus status = CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C4P4R, lut.ptr(), (int)lut.step[0], lutTable, (int)lut.step[0], sz256);
|
||||
if (status < 0)
|
||||
{
|
||||
setIppErrorStatus();
|
||||
return;
|
||||
}
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
}
|
||||
|
||||
*ok = true;
|
||||
@@ -5564,25 +5812,14 @@ public:
|
||||
|
||||
if (lutcn == 3)
|
||||
{
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C3R,
|
||||
src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0],
|
||||
ippiSize(dst.size()), lutTable, 8) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C3R, src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0], ippiSize(dst.size()), lutTable, 8) >= 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (lutcn == 4)
|
||||
{
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C4R,
|
||||
src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0],
|
||||
ippiSize(dst.size()), lutTable, 8) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP|CV_IMPL_MT);
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiLUTPalette_8u_C4R, src.ptr(), (int)src.step[0], dst.ptr(), (int)dst.step[0], ippiSize(dst.size()), lutTable, 8) >= 0)
|
||||
return;
|
||||
}
|
||||
}
|
||||
setIppErrorStatus();
|
||||
*ok = false;
|
||||
}
|
||||
private:
|
||||
@@ -5604,15 +5841,13 @@ static bool ipp_lut(Mat &src, Mat &lut, Mat &dst)
|
||||
Ptr<ParallelLoopBody> body;
|
||||
|
||||
size_t elemSize1 = CV_ELEM_SIZE1(dst.depth());
|
||||
#if IPP_DISABLE_BLOCK // there are no performance benefits (PR #2653)
|
||||
|
||||
if (lutcn == 1)
|
||||
{
|
||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTC1(src, lut, dst, &ok);
|
||||
body.reset(p);
|
||||
}
|
||||
else
|
||||
#endif
|
||||
if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
|
||||
else if ((lutcn == 3 || lutcn == 4) && elemSize1 == 1)
|
||||
{
|
||||
ParallelLoopBody* p = new ipp::IppLUTParallelBody_LUTCN(src, lut, dst, &ok);
|
||||
body.reset(p);
|
||||
@@ -5631,6 +5866,8 @@ static bool ipp_lut(Mat &src, Mat &lut, Mat &dst)
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif // IPP
|
||||
|
||||
class LUTParallelBody : public ParallelLoopBody
|
||||
@@ -5699,7 +5936,9 @@ void cv::LUT( InputArray _src, InputArray _lut, OutputArray _dst )
|
||||
CV_OVX_RUN(true,
|
||||
openvx_LUT(src, dst, lut))
|
||||
|
||||
#if !IPP_DISABLE_PERF_LUT
|
||||
CV_IPP_RUN(_src.dims() <= 2, ipp_lut(src, lut, dst));
|
||||
#endif
|
||||
|
||||
if (_src.dims() <= 2)
|
||||
{
|
||||
|
||||
+151
-283
@@ -49,6 +49,19 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencl_kernels_core.hpp"
|
||||
|
||||
#ifdef HAVE_IPP_IW
|
||||
extern "C" {
|
||||
IW_DECL(IppStatus) llwiCopyMask(const void *pSrc, int srcStep, void *pDst, int dstStep,
|
||||
IppiSize size, int typeSize, int channels, const Ipp8u *pMask, int maskStep);
|
||||
IW_DECL(IppStatus) llwiSet(const double *pValue, void *pDst, int dstStep,
|
||||
IppiSize size, IppDataType dataType, int channels);
|
||||
IW_DECL(IppStatus) llwiSetMask(const double *pValue, void *pDst, int dstStep,
|
||||
IppiSize size, IppDataType dataType, int channels, const Ipp8u *pMask, int maskStep);
|
||||
IW_DECL(IppStatus) llwiCopyMakeBorder(const void *pSrc, IppSizeL srcStep, void *pDst, IppSizeL dstStep,
|
||||
IppiSizeL size, IppDataType dataType, int channels, IppiBorderSize *pBorderSize, IppiBorderType border, const Ipp64f *pBorderVal);
|
||||
}
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -298,13 +311,7 @@ void Mat::copyTo( OutputArray _dst ) const
|
||||
const uchar* sptr = data;
|
||||
uchar* dptr = dst.data;
|
||||
|
||||
CV_IPP_RUN(
|
||||
(size_t)cols*elemSize() <= (size_t)INT_MAX &&
|
||||
(size_t)step <= (size_t)INT_MAX &&
|
||||
(size_t)dst.step <= (size_t)INT_MAX
|
||||
,
|
||||
CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C1R, sptr, (int)step, dptr, (int)dst.step, ippiSize((int)(cols*elemSize()), rows)) >= 0
|
||||
)
|
||||
CV_IPP_RUN_FAST(CV_INSTRUMENT_FUN_IPP(ippiCopy_8u_C1R_L, sptr, (int)step, dptr, (int)dst.step, ippiSizeL((int)(cols*elemSize()), rows)) >= 0)
|
||||
|
||||
Size sz = getContinuousSize(*this, dst);
|
||||
size_t len = sz.width*elemSize();
|
||||
@@ -332,6 +339,42 @@ void Mat::copyTo( OutputArray _dst ) const
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_copyTo(const Mat &src, Mat &dst, const Mat &mask)
|
||||
{
|
||||
#ifdef HAVE_IPP_IW
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
if(mask.channels() > 1 && mask.depth() != CV_8U)
|
||||
return false;
|
||||
|
||||
if (src.dims <= 2)
|
||||
{
|
||||
IppiSize size = ippiSize(src.size());
|
||||
return CV_INSTRUMENT_FUN_IPP(llwiCopyMask, src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, size, (int)src.elemSize1(), src.channels(), mask.ptr(), (int)mask.step) >= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[] = {&src, &dst, &mask, NULL};
|
||||
uchar *ptrs[3] = {NULL};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
|
||||
IppiSize size = ippiSize(it.size, 1);
|
||||
|
||||
for (size_t i = 0; i < it.nplanes; i++, ++it)
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(llwiCopyMask, ptrs[0], 0, ptrs[1], 0, size, (int)src.elemSize1(), src.channels(), ptrs[2], 0) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(mask);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -346,9 +389,10 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
|
||||
int cn = channels(), mcn = mask.channels();
|
||||
CV_Assert( mask.depth() == CV_8U && (mcn == 1 || mcn == cn) );
|
||||
bool colorMask = mcn > 1;
|
||||
|
||||
size_t esz = colorMask ? elemSize1() : elemSize();
|
||||
BinaryFunc copymask = getCopyMaskFunc(esz);
|
||||
if( dims <= 2 )
|
||||
{
|
||||
CV_Assert( size() == mask.size() );
|
||||
}
|
||||
|
||||
uchar* data0 = _dst.getMat().data;
|
||||
_dst.create( dims, size, type() );
|
||||
@@ -357,9 +401,13 @@ void Mat::copyTo( OutputArray _dst, InputArray _mask ) const
|
||||
if( dst.data != data0 ) // do not leave dst uninitialized
|
||||
dst = Scalar(0);
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_copyTo(*this, dst, mask))
|
||||
|
||||
size_t esz = colorMask ? elemSize1() : elemSize();
|
||||
BinaryFunc copymask = getCopyMaskFunc(esz);
|
||||
|
||||
if( dims <= 2 )
|
||||
{
|
||||
CV_Assert( size() == mask.size() );
|
||||
Size sz = getContinuousSize(*this, dst, mask, mcn);
|
||||
copymask(data, step, mask.data, mask.step, dst.data, dst.step, sz, &esz);
|
||||
return;
|
||||
@@ -386,36 +434,6 @@ Mat& Mat::operator = (const Scalar& s)
|
||||
|
||||
if( is[0] == 0 && is[1] == 0 && is[2] == 0 && is[3] == 0 )
|
||||
{
|
||||
#if defined HAVE_IPP && IPP_DISABLE_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
if (dims <= 2 || isContinuous())
|
||||
{
|
||||
IppiSize roisize = { cols, rows };
|
||||
if (isContinuous())
|
||||
{
|
||||
roisize.width = (int)total();
|
||||
roisize.height = 1;
|
||||
|
||||
if (ippsZero_8u(data, static_cast<int>(roisize.width * elemSize())) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP)
|
||||
return *this;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
roisize.width *= (int)elemSize();
|
||||
|
||||
if (ippiSet_8u_C1R(0, data, (int)step, roisize) >= 0)
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP)
|
||||
return *this;
|
||||
}
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
memset( dptr, 0, elsize );
|
||||
}
|
||||
@@ -443,89 +461,55 @@ Mat& Mat::operator = (const Scalar& s)
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if defined HAVE_IPP
|
||||
static bool ipp_Mat_setTo(Mat *src, Mat &value, Mat &mask)
|
||||
#ifdef HAVE_IPP
|
||||
static bool ipp_Mat_setTo_Mat(Mat &dst, Mat &_val, Mat &mask)
|
||||
{
|
||||
#ifdef HAVE_IPP_IW
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
int cn = src->channels(), depth0 = src->depth();
|
||||
if(mask.empty())
|
||||
return false;
|
||||
|
||||
if (!mask.empty() && (src->dims <= 2 || (src->isContinuous() && mask.isContinuous())) &&
|
||||
(/*depth0 == CV_8U ||*/ depth0 == CV_16U || depth0 == CV_16S || depth0 == CV_32S || depth0 == CV_32F) &&
|
||||
(cn == 1 || cn == 3 || cn == 4))
|
||||
if(mask.depth() != CV_8U || mask.channels() > 1)
|
||||
return false;
|
||||
|
||||
if(dst.channels() > 4)
|
||||
return false;
|
||||
|
||||
if(dst.dims <= 2)
|
||||
{
|
||||
uchar _buf[32];
|
||||
void * buf = _buf;
|
||||
convertAndUnrollScalar( value, src->type(), _buf, 1 );
|
||||
IppiSize size = ippiSize(dst.size());
|
||||
IppDataType dataType = ippiGetDataType(dst.depth());
|
||||
::ipp::IwValue s;
|
||||
convertAndUnrollScalar(_val, CV_MAKETYPE(CV_64F, dst.channels()), (uchar*)((Ipp64f*)s), 1);
|
||||
|
||||
IppStatus status = (IppStatus)-1;
|
||||
IppiSize roisize = { src->cols, src->rows };
|
||||
int mstep = (int)mask.step[0], dstep = (int)src->step[0];
|
||||
|
||||
if (src->isContinuous() && mask.isContinuous())
|
||||
{
|
||||
roisize.width = (int)src->total();
|
||||
roisize.height = 1;
|
||||
}
|
||||
|
||||
if (cn == 1)
|
||||
{
|
||||
/*if (depth0 == CV_8U)
|
||||
status = ippiSet_8u_C1MR(*(Ipp8u *)buf, (Ipp8u *)data, dstep, roisize, mask.data, mstep);
|
||||
else*/ if (depth0 == CV_16U)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiSet_16u_C1MR, *(Ipp16u *)buf, (Ipp16u *)src->data, dstep, roisize, mask.data, mstep);
|
||||
else if (depth0 == CV_16S)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiSet_16s_C1MR, *(Ipp16s *)buf, (Ipp16s *)src->data, dstep, roisize, mask.data, mstep);
|
||||
else if (depth0 == CV_32S)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiSet_32s_C1MR, *(Ipp32s *)buf, (Ipp32s *)src->data, dstep, roisize, mask.data, mstep);
|
||||
else if (depth0 == CV_32F)
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiSet_32f_C1MR, *(Ipp32f *)buf, (Ipp32f *)src->data, dstep, roisize, mask.data, mstep);
|
||||
}
|
||||
else if (cn == 3 || cn == 4)
|
||||
{
|
||||
|
||||
#define IPP_SET(ippfavor, ippcn) \
|
||||
do \
|
||||
{ \
|
||||
typedef Ipp##ippfavor ipptype; \
|
||||
ipptype ippvalue[4] = { ((ipptype *)buf)[0], ((ipptype *)buf)[1], ((ipptype *)buf)[2], ((ipptype *)buf)[3] }; \
|
||||
status = CV_INSTRUMENT_FUN_IPP(ippiSet_##ippfavor##_C##ippcn##MR, ippvalue, (ipptype *)src->data, dstep, roisize, mask.data, mstep); \
|
||||
} while ((void)0, 0)
|
||||
|
||||
#define IPP_SET_CN(ippcn) \
|
||||
do \
|
||||
{ \
|
||||
if (cn == ippcn) \
|
||||
{ \
|
||||
/*if (depth0 == CV_8U) \
|
||||
IPP_SET(8u, ippcn); \
|
||||
else*/ if (depth0 == CV_16U) \
|
||||
IPP_SET(16u, ippcn); \
|
||||
else if (depth0 == CV_16S) \
|
||||
IPP_SET(16s, ippcn); \
|
||||
else if (depth0 == CV_32S) \
|
||||
IPP_SET(32s, ippcn); \
|
||||
else if (depth0 == CV_32F) \
|
||||
IPP_SET(32f, ippcn); \
|
||||
} \
|
||||
} while ((void)0, 0)
|
||||
|
||||
IPP_SET_CN(3);
|
||||
IPP_SET_CN(4);
|
||||
|
||||
#undef IPP_SET_CN
|
||||
#undef IPP_SET
|
||||
}
|
||||
|
||||
if (status >= 0)
|
||||
return true;
|
||||
return CV_INSTRUMENT_FUN_IPP(llwiSetMask, s, dst.ptr(), (int)dst.step, size, dataType, dst.channels(), mask.ptr(), (int)mask.step) >= 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
const Mat *arrays[] = {&dst, mask.empty()?NULL:&mask, NULL};
|
||||
uchar *ptrs[2] = {NULL};
|
||||
NAryMatIterator it(arrays, ptrs);
|
||||
|
||||
IppiSize size = {(int)it.size, 1};
|
||||
IppDataType dataType = ippiGetDataType(dst.depth());
|
||||
::ipp::IwValue s;
|
||||
convertAndUnrollScalar(_val, CV_MAKETYPE(CV_64F, dst.channels()), (uchar*)((Ipp64f*)s), 1);
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it)
|
||||
{
|
||||
if(CV_INSTRUMENT_FUN_IPP(llwiSetMask, s, ptrs[0], 0, size, dataType, dst.channels(), ptrs[1], 0) < 0)
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
CV_UNUSED(dst); CV_UNUSED(_val); CV_UNUSED(mask);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
Mat& Mat::setTo(InputArray _value, InputArray _mask)
|
||||
{
|
||||
CV_INSTRUMENT_REGION()
|
||||
@@ -538,7 +522,7 @@ Mat& Mat::setTo(InputArray _value, InputArray _mask)
|
||||
CV_Assert( checkScalar(value, type(), _value.kind(), _InputArray::MAT ));
|
||||
CV_Assert( mask.empty() || (mask.type() == CV_8U && size == mask.size) );
|
||||
|
||||
CV_IPP_RUN_FAST(ipp_Mat_setTo((cv::Mat*)this, value, mask), *this)
|
||||
CV_IPP_RUN_FAST(ipp_Mat_setTo_Mat(*this, value, mask), *this)
|
||||
|
||||
size_t esz = elemSize();
|
||||
BinaryFunc copymask = getCopyMaskFunc(esz);
|
||||
@@ -713,73 +697,36 @@ static bool ocl_flip(InputArray _src, OutputArray _dst, int flipCode )
|
||||
#endif
|
||||
|
||||
#if defined HAVE_IPP
|
||||
static bool ipp_flip( Mat &src, Mat &dst, int flip_mode )
|
||||
static bool ipp_flip(Mat &src, Mat &dst, int flip_mode)
|
||||
{
|
||||
#ifdef HAVE_IPP_IW
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
int type = src.type();
|
||||
|
||||
typedef IppStatus (CV_STDCALL * IppiMirror)(const void * pSrc, int srcStep, void * pDst, int dstStep, IppiSize roiSize, IppiAxis flip);
|
||||
typedef IppStatus (CV_STDCALL * IppiMirrorI)(const void * pSrcDst, int srcDstStep, IppiSize roiSize, IppiAxis flip);
|
||||
IppiMirror ippiMirror = 0;
|
||||
IppiMirrorI ippiMirror_I = 0;
|
||||
|
||||
if (src.data == dst.data)
|
||||
{
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippiMirror_I =
|
||||
type == CV_8UC1 ? (IppiMirrorI)ippiMirror_8u_C1IR :
|
||||
type == CV_8UC3 ? (IppiMirrorI)ippiMirror_8u_C3IR :
|
||||
type == CV_8UC4 ? (IppiMirrorI)ippiMirror_8u_C4IR :
|
||||
type == CV_16UC1 ? (IppiMirrorI)ippiMirror_16u_C1IR :
|
||||
type == CV_16UC3 ? (IppiMirrorI)ippiMirror_16u_C3IR :
|
||||
type == CV_16UC4 ? (IppiMirrorI)ippiMirror_16u_C4IR :
|
||||
type == CV_16SC1 ? (IppiMirrorI)ippiMirror_16s_C1IR :
|
||||
type == CV_16SC3 ? (IppiMirrorI)ippiMirror_16s_C3IR :
|
||||
type == CV_16SC4 ? (IppiMirrorI)ippiMirror_16s_C4IR :
|
||||
type == CV_32SC1 ? (IppiMirrorI)ippiMirror_32s_C1IR :
|
||||
type == CV_32SC3 ? (IppiMirrorI)ippiMirror_32s_C3IR :
|
||||
type == CV_32SC4 ? (IppiMirrorI)ippiMirror_32s_C4IR :
|
||||
type == CV_32FC1 ? (IppiMirrorI)ippiMirror_32f_C1IR :
|
||||
type == CV_32FC3 ? (IppiMirrorI)ippiMirror_32f_C3IR :
|
||||
type == CV_32FC4 ? (IppiMirrorI)ippiMirror_32f_C4IR : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
IppiAxis ippMode;
|
||||
if(flip_mode < 0)
|
||||
ippMode = ippAxsBoth;
|
||||
else if(flip_mode == 0)
|
||||
ippMode = ippAxsHorizontal;
|
||||
else
|
||||
{
|
||||
ippiMirror =
|
||||
type == CV_8UC1 ? (IppiMirror)ippiMirror_8u_C1R :
|
||||
type == CV_8UC3 ? (IppiMirror)ippiMirror_8u_C3R :
|
||||
type == CV_8UC4 ? (IppiMirror)ippiMirror_8u_C4R :
|
||||
type == CV_16UC1 ? (IppiMirror)ippiMirror_16u_C1R :
|
||||
type == CV_16UC3 ? (IppiMirror)ippiMirror_16u_C3R :
|
||||
type == CV_16UC4 ? (IppiMirror)ippiMirror_16u_C4R :
|
||||
type == CV_16SC1 ? (IppiMirror)ippiMirror_16s_C1R :
|
||||
type == CV_16SC3 ? (IppiMirror)ippiMirror_16s_C3R :
|
||||
type == CV_16SC4 ? (IppiMirror)ippiMirror_16s_C4R :
|
||||
type == CV_32SC1 ? (IppiMirror)ippiMirror_32s_C1R :
|
||||
type == CV_32SC3 ? (IppiMirror)ippiMirror_32s_C3R :
|
||||
type == CV_32SC4 ? (IppiMirror)ippiMirror_32s_C4R :
|
||||
type == CV_32FC1 ? (IppiMirror)ippiMirror_32f_C1R :
|
||||
type == CV_32FC3 ? (IppiMirror)ippiMirror_32f_C3R :
|
||||
type == CV_32FC4 ? (IppiMirror)ippiMirror_32f_C4R : 0;
|
||||
}
|
||||
IppiAxis axis = flip_mode == 0 ? ippAxsHorizontal :
|
||||
flip_mode > 0 ? ippAxsVertical : ippAxsBoth;
|
||||
IppiSize roisize = { dst.cols, dst.rows };
|
||||
ippMode = ippAxsVertical;
|
||||
|
||||
if (ippiMirror != 0)
|
||||
try
|
||||
{
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiMirror, src.ptr(), (int)src.step, dst.ptr(), (int)dst.step, ippiSize(src.cols, src.rows), axis) >= 0)
|
||||
return true;
|
||||
::ipp::IwiImage iwSrc = ippiGetImage(src);
|
||||
::ipp::IwiImage iwDst = ippiGetImage(dst);
|
||||
|
||||
CV_INSTRUMENT_FUN_IPP(::ipp::iwiMirror, &iwSrc, &iwDst, ippMode);
|
||||
}
|
||||
else if (ippiMirror_I != 0)
|
||||
catch(::ipp::IwException)
|
||||
{
|
||||
if (CV_INSTRUMENT_FUN_IPP(ippiMirror_I, dst.ptr(), (int)dst.step, roisize, axis) >= 0)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
#else
|
||||
CV_UNUSED(src); CV_UNUSED(dst); CV_UNUSED(flip_mode);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -1184,7 +1131,41 @@ static bool ocl_copyMakeBorder( InputArray _src, OutputArray _dst, int top, int
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_IPP
|
||||
namespace cv {
|
||||
|
||||
static bool ipp_copyMakeBorder( Mat &_src, Mat &_dst, int top, int bottom,
|
||||
int left, int right, int _borderType, const Scalar& value )
|
||||
{
|
||||
#if defined HAVE_IPP_IW && !IPP_DISABLE_PERF_COPYMAKE
|
||||
CV_INSTRUMENT_REGION_IPP()
|
||||
|
||||
::ipp::IwiBorderSize borderSize(left, top, right, bottom);
|
||||
::ipp::IwiSize size(_src.cols, _src.rows);
|
||||
IppDataType dataType = ippiGetDataType(_src.depth());
|
||||
IppiBorderType borderType = ippiGetBorderType(_borderType);
|
||||
if((int)borderType == -1)
|
||||
return false;
|
||||
|
||||
if(_src.dims > 2)
|
||||
return false;
|
||||
|
||||
Rect dstRect(borderSize.borderLeft, borderSize.borderTop,
|
||||
_dst.cols - borderSize.borderRight - borderSize.borderLeft,
|
||||
_dst.rows - borderSize.borderBottom - borderSize.borderTop);
|
||||
Mat subDst = Mat(_dst, dstRect);
|
||||
Mat *pSrc = &_src;
|
||||
|
||||
return CV_INSTRUMENT_FUN_IPP(llwiCopyMakeBorder, pSrc->ptr(), pSrc->step, subDst.ptr(), subDst.step, size, dataType, _src.channels(), &borderSize, borderType, &value[0]) >= 0;
|
||||
#else
|
||||
CV_UNUSED(_src); CV_UNUSED(_dst); CV_UNUSED(top); CV_UNUSED(bottom); CV_UNUSED(left); CV_UNUSED(right);
|
||||
CV_UNUSED(_borderType); CV_UNUSED(value);
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
|
||||
@@ -1228,120 +1209,7 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
|
||||
|
||||
borderType &= ~BORDER_ISOLATED;
|
||||
|
||||
#if defined HAVE_IPP && IPP_DISABLE_BLOCK
|
||||
CV_IPP_CHECK()
|
||||
{
|
||||
typedef IppStatus (CV_STDCALL * ippiCopyMakeBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst,
|
||||
int dstStep, IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth);
|
||||
typedef IppStatus (CV_STDCALL * ippiCopyMakeBorderI)(const void * pSrc, int srcDstStep, IppiSize srcRoiSize, IppiSize dstRoiSize,
|
||||
int topBorderHeight, int leftborderwidth);
|
||||
typedef IppStatus (CV_STDCALL * ippiCopyConstBorder)(const void * pSrc, int srcStep, IppiSize srcRoiSize, void * pDst, int dstStep,
|
||||
IppiSize dstRoiSize, int topBorderHeight, int leftBorderWidth, void * value);
|
||||
|
||||
IppiSize srcRoiSize = { src.cols, src.rows }, dstRoiSize = { dst.cols, dst.rows };
|
||||
ippiCopyMakeBorder ippFunc = 0;
|
||||
ippiCopyMakeBorderI ippFuncI = 0;
|
||||
ippiCopyConstBorder ippFuncConst = 0;
|
||||
bool inplace = dst.datastart == src.datastart;
|
||||
|
||||
if (borderType == BORDER_CONSTANT)
|
||||
{
|
||||
ippFuncConst =
|
||||
// type == CV_8UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C1R : bug in IPP 8.1
|
||||
type == CV_16UC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C1R :
|
||||
// type == CV_16SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C1R : bug in IPP 8.1
|
||||
// type == CV_32SC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C1R : bug in IPP 8.1
|
||||
// type == CV_32FC1 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C1R : bug in IPP 8.1
|
||||
type == CV_8UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C3R :
|
||||
type == CV_16UC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C3R :
|
||||
type == CV_16SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C3R :
|
||||
type == CV_32SC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C3R :
|
||||
type == CV_32FC3 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C3R :
|
||||
type == CV_8UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_8u_C4R :
|
||||
type == CV_16UC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16u_C4R :
|
||||
type == CV_16SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_16s_C4R :
|
||||
type == CV_32SC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32s_C4R :
|
||||
type == CV_32FC4 ? (ippiCopyConstBorder)ippiCopyConstBorder_32f_C4R : 0;
|
||||
}
|
||||
else if (borderType == BORDER_WRAP)
|
||||
{
|
||||
if (inplace)
|
||||
{
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippFuncI =
|
||||
type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR :
|
||||
type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyWrapBorder_32s_C1IR : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
else
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R :
|
||||
type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyWrapBorder_32s_C1R : 0;
|
||||
}
|
||||
}
|
||||
else if (borderType == BORDER_REPLICATE)
|
||||
{
|
||||
if (inplace)
|
||||
{
|
||||
CV_SUPPRESS_DEPRECATED_START
|
||||
ippFuncI =
|
||||
type == CV_8UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C1IR :
|
||||
type == CV_16UC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C1IR :
|
||||
type == CV_16SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C1IR :
|
||||
type == CV_32SC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C1IR :
|
||||
type == CV_32FC1 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C1IR :
|
||||
type == CV_8UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C3IR :
|
||||
type == CV_16UC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C3IR :
|
||||
type == CV_16SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C3IR :
|
||||
type == CV_32SC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C3IR :
|
||||
type == CV_32FC3 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C3IR :
|
||||
type == CV_8UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_8u_C4IR :
|
||||
type == CV_16UC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16u_C4IR :
|
||||
type == CV_16SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_16s_C4IR :
|
||||
type == CV_32SC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32s_C4IR :
|
||||
type == CV_32FC4 ? (ippiCopyMakeBorderI)ippiCopyReplicateBorder_32f_C4IR : 0;
|
||||
CV_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
else
|
||||
{
|
||||
ippFunc =
|
||||
type == CV_8UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C1R :
|
||||
type == CV_16UC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C1R :
|
||||
type == CV_16SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C1R :
|
||||
type == CV_32SC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C1R :
|
||||
type == CV_32FC1 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C1R :
|
||||
type == CV_8UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C3R :
|
||||
type == CV_16UC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C3R :
|
||||
type == CV_16SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C3R :
|
||||
type == CV_32SC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C3R :
|
||||
type == CV_32FC3 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C3R :
|
||||
type == CV_8UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_8u_C4R :
|
||||
type == CV_16UC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16u_C4R :
|
||||
type == CV_16SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_16s_C4R :
|
||||
type == CV_32SC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32s_C4R :
|
||||
type == CV_32FC4 ? (ippiCopyMakeBorder)ippiCopyReplicateBorder_32f_C4R : 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (ippFunc || ippFuncI || ippFuncConst)
|
||||
{
|
||||
uchar scbuf[32];
|
||||
scalarToRawData(value, scbuf, type);
|
||||
|
||||
if ( (ippFunc && ippFunc(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step, dstRoiSize, top, left) >= 0) ||
|
||||
(ippFuncI && ippFuncI(src.data, (int)src.step, srcRoiSize, dstRoiSize, top, left) >= 0) ||
|
||||
(ippFuncConst && ippFuncConst(src.data, (int)src.step, srcRoiSize, dst.data, (int)dst.step,
|
||||
dstRoiSize, top, left, scbuf) >= 0))
|
||||
{
|
||||
CV_IMPL_ADD(CV_IMPL_IPP);
|
||||
return;
|
||||
}
|
||||
|
||||
setIppErrorStatus();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
CV_IPP_RUN_FAST(ipp_copyMakeBorder(src, dst, top, bottom, left, right, borderType, value))
|
||||
|
||||
if( borderType != BORDER_CONSTANT )
|
||||
copyMakeBorder_8u( src.ptr(), src.step, src.size(),
|
||||
|
||||
@@ -282,9 +282,10 @@ public:
|
||||
cudaStream_t stream;
|
||||
bool ownStream;
|
||||
|
||||
Ptr<StackAllocator> stackAllocator;
|
||||
Ptr<GpuMat::Allocator> allocator;
|
||||
|
||||
Impl();
|
||||
Impl(const Ptr<GpuMat::Allocator>& allocator);
|
||||
explicit Impl(cudaStream_t stream);
|
||||
|
||||
~Impl();
|
||||
@@ -295,17 +296,23 @@ cv::cuda::Stream::Impl::Impl() : stream(0), ownStream(false)
|
||||
cudaSafeCall( cudaStreamCreate(&stream) );
|
||||
ownStream = true;
|
||||
|
||||
stackAllocator = makePtr<StackAllocator>(stream);
|
||||
allocator = makePtr<StackAllocator>(stream);
|
||||
}
|
||||
|
||||
cv::cuda::Stream::Impl::Impl(const Ptr<GpuMat::Allocator>& allocator) : stream(0), ownStream(false), allocator(allocator)
|
||||
{
|
||||
cudaSafeCall( cudaStreamCreate(&stream) );
|
||||
ownStream = true;
|
||||
}
|
||||
|
||||
cv::cuda::Stream::Impl::Impl(cudaStream_t stream_) : stream(stream_), ownStream(false)
|
||||
{
|
||||
stackAllocator = makePtr<StackAllocator>(stream);
|
||||
allocator = makePtr<StackAllocator>(stream);
|
||||
}
|
||||
|
||||
cv::cuda::Stream::Impl::~Impl()
|
||||
{
|
||||
stackAllocator.release();
|
||||
allocator.release();
|
||||
|
||||
if (stream && ownStream)
|
||||
{
|
||||
@@ -417,6 +424,16 @@ cv::cuda::Stream::Stream()
|
||||
#endif
|
||||
}
|
||||
|
||||
cv::cuda::Stream::Stream(const Ptr<GpuMat::Allocator>& allocator)
|
||||
{
|
||||
#ifndef HAVE_CUDA
|
||||
(void) allocator;
|
||||
throw_no_cuda();
|
||||
#else
|
||||
impl_ = makePtr<Impl>(allocator);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::cuda::Stream::queryIfComplete() const
|
||||
{
|
||||
#ifndef HAVE_CUDA
|
||||
@@ -668,20 +685,33 @@ void cv::cuda::setBufferPoolConfig(int deviceId, size_t stackSize, int stackCoun
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
cv::cuda::BufferPool::BufferPool(Stream& stream) : allocator_(stream.impl_->stackAllocator.get())
|
||||
#ifndef HAVE_CUDA
|
||||
cv::cuda::BufferPool::BufferPool(Stream& stream)
|
||||
{
|
||||
(void) stream;
|
||||
throw_no_cuda();
|
||||
}
|
||||
#else
|
||||
cv::cuda::BufferPool::BufferPool(Stream& stream) : allocator_(stream.impl_->allocator)
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
GpuMat cv::cuda::BufferPool::getBuffer(int rows, int cols, int type)
|
||||
{
|
||||
#ifndef HAVE_CUDA
|
||||
(void) rows;
|
||||
(void) cols;
|
||||
(void) type;
|
||||
throw_no_cuda();
|
||||
return GpuMat();
|
||||
#else
|
||||
GpuMat buf(allocator_);
|
||||
buf.create(rows, cols, type);
|
||||
return buf;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////////////////////////////
|
||||
// Event
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user