-# 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")
+function(download_win_ffmpeg script_var)
+ set(${script_var} "" PARENT_SCOPE)
-set(FFMPEG_DOWNLOAD_URL ${OPENCV_FFMPEG_URL};$ENV{OPENCV_FFMPEG_URL};https://raw.githubusercontent.com/opencv/opencv_3rdparty/${FFMPEG_BINARIES_COMMIT}/ffmpeg/)
+ 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.dll
- HASH ${FFMPEG_FILE_HASH_BIN32}
- URL ${FFMPEG_DOWNLOAD_URL}
- DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
+ # 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")
-ocv_download(PACKAGE opencv_ffmpeg_64.dll
- HASH ${FFMPEG_FILE_HASH_BIN64}
- URL ${FFMPEG_DOWNLOAD_URL}
- DESTINATION_DIR ${CMAKE_CURRENT_LIST_DIR})
+ set(FFMPEG_BINARIES_COMMIT "2a19d0006415955c79431116e4634f04d5eb5a74")
+ 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()
+++ /dev/null
-downloads/
-unpack/
+++ /dev/null
-#
-# 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()
--- /dev/null
+function(download_ippicv root_var)
+ set(${root_var} "" PARENT_SCOPE)
+
+ # Commit SHA in the opencv_3rdparty repo
+ set(IPPICV_COMMIT "81a676001ca8075ada498583e4166079e5744668")
+ # Define actual ICV versions
+ if(APPLE)
+ set(OPENCV_ICV_NAME "ippicv_macosx_20151201.tgz")
+ set(OPENCV_ICV_HASH "4ff1fde9a7cfdfe7250bfcd8334e0f2f")
+ set(OPENCV_ICV_PLATFORM "macosx")
+ set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_osx")
+ elseif((UNIX AND NOT ANDROID) OR (UNIX AND ANDROID_ABI MATCHES "x86"))
+ set(OPENCV_ICV_NAME "ippicv_linux_20151201.tgz")
+ set(OPENCV_ICV_HASH "808b791a6eac9ed78d32a7666804320e")
+ set(OPENCV_ICV_PLATFORM "linux")
+ set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_lnx")
+ elseif(WIN32 AND NOT ARM)
+ set(OPENCV_ICV_NAME "ippicv_windows_20151201.zip")
+ set(OPENCV_ICV_HASH "04e81ce5d0e329c3fbc606ae32cad44d")
+ set(OPENCV_ICV_PLATFORM "windows")
+ set(OPENCV_ICV_PACKAGE_SUBDIR "ippicv_win")
+ 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()
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/"
ocv_clear_vars(OpenCVModules_TARGETS)
+include(cmake/OpenCVDownload.cmake)
+
# ----------------------------------------------------------------------------
# Break in case of popular CMake configuration mistakes
# ----------------------------------------------------------------------------
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)
add_definitions(-DCV_COLLECT_IMPL_DATA)
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()
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()
--- /dev/null
+#
+# 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()
macro(_ipp_add_library name)
# dynamic linking is only supported for standalone version of 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})
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.
# 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()
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)
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)
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],
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}
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);
# include "tegra_round.hpp"
#endif
-#if defined __GNUC__ && defined __arm__ && (defined __ARM_PCS_VFP || defined __ARM_VFPV3__ || defined __ARM_NEON__) && !defined __SOFTFP__
+#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; \
template<typename _Tp> inline
Mat_<_Tp>& Mat_<_Tp>::operator = (Mat_&& m)
{
- Mat::operator = (m);
+ Mat::operator = (std::move(m));
return *this;
}
/** @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.
}
}
+static const int MAX_SIZE = 16;
/*
marks domain border with +/-<constant> and stores the contour into CvSeq.
int _method )
{
const schar nbd = 2;
- int deltas[16];
+ int deltas[MAX_SIZE];
CvSeqWriter writer;
schar *i0 = ptr, *i1, *i3, *i4 = 0;
int prev_s = -1, s, s_end;
for( ;; )
{
s_end = s;
+ s = std::min(s, MAX_SIZE - 1);
- for( ;; )
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
if( *i4 != 0 )
static int
icvTraceContour( schar *ptr, int step, schar *stop_ptr, int is_hole )
{
- int deltas[16];
- schar *i0 = ptr, *i1, *i3, *i4;
+ int deltas[MAX_SIZE];
+ schar *i0 = ptr, *i1, *i3, *i4 = NULL;
int s, s_end;
/* initialize local state */
for( ;; )
{
- for( ;; )
+ s = std::min(s, MAX_SIZE - 1);
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
if( *i4 != 0 )
int nbd,
CvRect* _rect )
{
- int deltas[16];
+ int deltas[MAX_SIZE];
CvSeqWriter writer;
- schar *i0 = ptr, *i1, *i3, *i4;
+ schar *i0 = ptr, *i1, *i3, *i4 = NULL;
CvRect rect;
int prev_s = -1, s, s_end;
int method = _method - 1;
for( ;; )
{
s_end = s;
+ s = std::min(s, MAX_SIZE - 1);
- for( ;; )
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
if( *i4 != 0 )
static int
icvTraceContour_32s( int *ptr, int step, int *stop_ptr, int is_hole )
{
- int deltas[16];
- int *i0 = ptr, *i1, *i3, *i4;
+ int deltas[MAX_SIZE];
+ int *i0 = ptr, *i1, *i3, *i4 = NULL;
int s, s_end;
const int right_flag = INT_MIN;
const int new_flag = (int)((unsigned)INT_MIN >> 1);
for( ;; )
{
s_end = s;
+ s = std::min(s, MAX_SIZE - 1);
- for( ;; )
+ while( s < MAX_SIZE - 1 )
{
i4 = i3 + deltas[++s];
if( (*i4 & value_mask) == ccomp_val )
int _method,
CvRect* _rect )
{
- int deltas[16];
+ int deltas[MAX_SIZE];
CvSeqWriter writer;
int *i0 = ptr, *i1, *i3, *i4;
CvRect rect;
s = (s - 1) & 7;
i1 = i0 + deltas[s];
}
- while( (*i1 & value_mask) != ccomp_val && s != s_end );
+ while( (*i1 & value_mask) != ccomp_val && s != s_end && ( s < MAX_SIZE - 1 ) );
if( s == s_end ) /* single pixel domain */
{
{
s_end = s;
- for( ;; )
+ do
{
i4 = i3 + deltas[++s];
- if( (*i4 & value_mask) == ccomp_val )
- break;
}
+ while( (*i4 & value_mask) != ccomp_val && ( s < MAX_SIZE - 1 ) );
s &= 7;
/* check "right" bound */
CV_Assert(ksize <= MAX_ESIZE);
}
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Warray-bounds"
-#endif
virtual void operator() (const Range& range) const
{
int dy, cn = src.channels();
int sy = clip(sy0 - ksize2 + 1 + k, 0, ssize.height);
for( k1 = std::max(k1, k); k1 < ksize; k1++ )
{
- if( sy == prev_sy[k1] ) // if the sy-th row has been computed already, reuse it.
+ if( k1 < MAX_ESIZE && sy == prev_sy[k1] ) // if the sy-th row has been computed already, reuse it.
{
if( k1 > k )
memcpy( rows[k], rows[k1], bufstep*sizeof(rows[0][0]) );
vresize( (const WT**)rows, (T*)(dst.data + dst.step*dy), beta, dsize.width );
}
}
-#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
-# pragma GCC diagnostic pop
-#endif
private:
Mat src;
"nu30", m.nu30, "nu21", m.nu21, "nu12", m.nu12, "nu03", m.nu03);
}
+template<typename T>
+PyObject* pyopencv_from(const cv::Ptr<T>& p)
+{
+ if (!p)
+ Py_RETURN_NONE;
+ return pyopencv_from(*p);
+}
+
template <typename T>
bool pyopencv_to(PyObject *o, Ptr<T>& p, const char *name)
{
+ if (!o || o == Py_None)
+ return true;
p = makePtr<T>();
return pyopencv_to(o, *p, name);
}
const std::vector<MatchesInfo> &pairwise_matches,
std::vector<CameraParams> &cameras)
{
- cameras.resize(features.size());
+ cameras.assign(features.size(), CameraParams());
const int num_images = static_cast<int>(features.size());
// find maximum spaning tree on pairwise matches
//go through all modes
//////
- //renormalize weights
- totalWeight = 1.f/totalWeight;
+ // Renormalize weights. In the special case that the pixel does
+ // not agree with any modes, set weights to zero (a new mode will be added below).
+ float invWeight = 0.f;
+ if (std::abs(totalWeight) > FLT_EPSILON) {
+ invWeight = 1.f/totalWeight;
+ }
+
for( int mode = 0; mode < nmodes; mode++ )
{
- gmm[mode].weight *= totalWeight;
+ gmm[mode].weight *= invWeight;
}
//make new mode if needed and exit
if(totalWeight > backgroundRatio)
break;
}
- float invWeight = 1.f/totalWeight;
+ float invWeight = 0.f;
+ if (std::abs(totalWeight) > FLT_EPSILON) {
+ invWeight = 1.f/totalWeight;
+ }
meanBackground.at<Vec<T,CN> >(row, col) = Vec<T,CN>(meanVal * invWeight);
meanVal = 0.f;
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations)
-if(WIN32 AND WITH_FFMPEG)
+if(WIN32 AND HAVE_FFMPEG)
#copy ffmpeg dll to the output folder
if(MSVC64 OR MINGW64)
set(FFMPEG_SUFFIX _64)
endif()
+ set(ffmpeg_dir "${OpenCV_BINARY_DIR}/3rdparty/ffmpeg")
set(ffmpeg_bare_name "opencv_ffmpeg${FFMPEG_SUFFIX}.dll")
set(ffmpeg_bare_name_ver "opencv_ffmpeg${OPENCV_DLLVERSION}${FFMPEG_SUFFIX}.dll")
- set(ffmpeg_path "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/${ffmpeg_bare_name}")
+ set(ffmpeg_path "${ffmpeg_dir}/${ffmpeg_bare_name}")
if(MSVC_IDE)
add_custom_command(TARGET ${the_module} POST_BUILD
install(FILES "${ffmpeg_path}" DESTINATION ${OPENCV_BIN_INSTALL_PATH} COMPONENT libs RENAME "${ffmpeg_bare_name_ver}")
if(INSTALL_CREATE_DISTRIB)
- install(FILES "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/opencv_ffmpeg.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}.dll")
- install(FILES "${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/opencv_ffmpeg_64.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}_64.dll")
+ install(FILES "${ffmpeg_dir}/opencv_ffmpeg.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}.dll")
+ install(FILES "${ffmpeg_dir}/opencv_ffmpeg_64.dll" DESTINATION "bin/" COMPONENT libs RENAME "opencv_ffmpeg${OPENCV_DLLVERSION}_64.dll")
endif()
endif()
endmacro()
c - clear targets
[1] David S. Bolme et al. "Visual Object Tracking using Adaptive Correlation Filters"
- http://www.cs.colostate.edu/~bolme/publications/Bolme2010Tracking.pdf
+ http://www.cs.colostate.edu/~draper/papers/bolme_cvpr10.pdf
'''
# Python 2/3 compatibility