1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-25 13:23:02 +04:00

Compare commits

..

28 Commits

Author SHA1 Message Date
Alexander Alekhin fb4c2ba64d OpenCV version++
2.4.13.4
2017-10-12 14:32:33 +03:00
Alexander Alekhin e53f1b2532 Merge pull request #9808 from alalek:backport_fixes
(2.4) backport fixes
2017-10-10 13:13:23 +03:00
Yaron Inger 621a1d3b09 videoio: remove AssetsLibrary dependency.
The entire AssetsLibrary framework is deprecated since iOS 8.0. The code
used in the camera example code can use UIKit to save videos to the
camera instead, which allows to avoid linking with PhotoKit instead to
prevent increasing the iOS deployment target.
2017-10-09 15:14:25 +03:00
berak 14b686cdc7 imgcodecs: fix 4 reading channel bmp images 2017-10-09 15:11:28 +03:00
blendin 0202e52747 Fix out of bounds write 2017-10-09 15:10:03 +03:00
Benoit Blanchon 7997e7aee9 cmake: map RelWithDebInfo and MinSizeRel configuration to Release 2017-10-09 15:08:16 +03:00
Guillaume Jacob b43e5e2d21 CMakeLists.txt: fix a typo in a message 2017-10-09 15:04:40 +03:00
KUANG Fangjun c92ecc7f96 Improve the documentation. 2017-10-09 15:03:10 +03:00
Alexander Alekhin ae52d94ceb Merge pull request #9776 from IgWod:matrix-memory-leak-fix
Fix memory leak in the matrix copying constructor
2017-10-06 21:35:32 +03:00
Igor Wodiany 37d4e24806 Fix a memory leak in the Mat copying constructor
Exception may be rasied inside the body of a copying constructor after
refcount has been increased, and beacause in the case of the exception
destrcutor is never called what causes memory leak. This commit adds a
workaround that calls the release() function before the exception is
thrown outside the contructor.
2017-10-05 22:24:43 +01:00
Alexander Alekhin 7b861cac9f Merge pull request #9662 from alalek:backport_9448_9504
(2.4) imgcodecs: backport 9448 9504
2017-09-20 12:45:15 +00:00
Alexander Alekhin da9395b592 imgcodecs: fix regression 9376 2017-09-19 13:05:34 +03:00
Alexander Alekhin df1a026329 imgcodesc: fix code problems with integer overflow / address arithmetic / UB 2017-09-19 12:39:32 +03:00
Alexander Alekhin dd9bf1ba1d Merge pull request #9435 from alalek:fix_numpy_warning_2.4
(2.4) python: eliminate -Wundef warning about NPY_INTERNAL_BUILD
2017-09-15 18:26:26 +00:00
Alexander Alekhin 30f7576029 Merge pull request #9383 from alalek:imgcodecs_refactoring_2.4 2017-08-22 16:36:18 +00:00
Alexander Alekhin f548d660ba Merge pull request #9432 from alalek:cmake_deprecated_policies_2.4
(2.4) cmake deprecated policies (backport 9415)
2017-08-22 14:13:49 +00:00
Alexander Alekhin 8a2bbc57e4 python: eliminate -Wundef warning about NPY_INTERNAL_BUILD
numpy 1.13.0+
2017-08-22 11:59:54 +03:00
Alexander Alekhin e575b5ff9a cmake: remove INSTALL_NAME_DIR 2017-08-21 19:17:52 +03:00
Alexander Alekhin 355553b0a6 cmake: CMP0026 NEW 2017-08-21 18:48:17 +03:00
Alexander Alekhin d25b04149a cmake: CMP0022 NEW 2017-08-21 18:26:57 +03:00
Alexander Alekhin 268d17e086 cmake: drop CMP0017 2017-08-21 18:26:57 +03:00
Alexander Alekhin d567a79581 cmake: use CMAKE_CXX_COMPILER_VERSION (CMake 2.8.8+)
- PVAPI library detection was changed
2017-08-21 18:26:57 +03:00
Alexander Alekhin 3ba7c16670 cmake: bump minimal version 2017-08-21 16:33:05 +03:00
Alexander Alekhin f7d99f3f6a Merge pull request #9408 from alalek:backport_9228
(2.4) Update OpenCVCompilerOptions.cmake (backport 9228)
2017-08-18 16:04:16 +00:00
neok-m4700 126de0cd95 Update OpenCVCompilerOptions.cmake
misplaced else
2017-08-18 18:48:03 +03:00
Alexander Alekhin 72d29259ca imgcodecs: refactoring, improve code quality 2017-08-16 18:25:09 +00:00
Alexander Alekhin c9488c661f Merge pull request #9380 from StevenPuttemans:fix_doc_9359_2.4
backport of PR 9367
2017-08-16 10:58:14 +00:00
Steven Puttemans 4852f017fa backport of PR 9367 2017-08-16 10:57:20 +02:00
36 changed files with 374 additions and 266 deletions
+1 -1
View File
@@ -187,7 +187,7 @@ if (HAVE_LIBPTHREAD)
add_definitions(-DUSE_PTHREAD) #required for Unix
endif()
if (CMAKE_COMPILER_IS_GNUCXX)
if(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_COMPILER_IS_CLANGCXX)
add_definitions(-DTBB_USE_GCC_BUILTINS=1) #required for ARM GCC
endif()
+9 -22
View File
@@ -10,7 +10,7 @@
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.
You should create a separate directory for build files.
")
endif()
@@ -37,24 +37,15 @@ endif(NOT CMAKE_TOOLCHAIN_FILE)
# Top level OpenCV project
# --------------------------------------------------------------
if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)
cmake_minimum_required(VERSION 2.8.8)
cmake_minimum_required(VERSION 3.0)
elseif(IOS)
cmake_minimum_required(VERSION 2.8.0)
cmake_minimum_required(VERSION 3.0)
else()
cmake_minimum_required(VERSION 2.6.3)
endif()
if(POLICY CMP0017)
cmake_policy(SET CMP0017 NEW)
endif()
if(POLICY CMP0022)
cmake_policy(SET CMP0022 OLD)
cmake_minimum_required(VERSION 2.8.12.2)
endif()
if(POLICY CMP0026)
# silence cmake 3.0+ warnings about reading LOCATION attribute
cmake_policy(SET CMP0026 OLD)
cmake_policy(SET CMP0026 NEW)
endif()
if (POLICY CMP0042)
@@ -86,8 +77,8 @@ ocv_clear_vars(OpenCVModules_TARGETS)
# Break in case of popular CMake configuration mistakes
# ----------------------------------------------------------------------------
if(NOT CMAKE_SIZEOF_VOID_P GREATER 0)
message(FATAL_ERROR "CMake fails to deterimine the bitness of target platform.
Please check your CMake and compiler installation. If you are crosscompiling then ensure that your CMake toolchain file correctly sets the compiler details.")
message(FATAL_ERROR "CMake fails to determine the bitness of the target platform.
Please check your CMake and compiler installation. If you are cross-compiling then ensure that your CMake toolchain file correctly sets the compiler details.")
endif()
# ----------------------------------------------------------------------------
@@ -198,7 +189,7 @@ OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command"
OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT IOS) )
OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS) )
OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON )
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of statically linked CRT for staticaly linked OpenCV" ON IF MSVC )
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID )
@@ -712,10 +703,6 @@ 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})")
elseif(CMAKE_COMPILER_IS_CLANGCXX)
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_CLANG_REGEX_VERSION})")
elseif(CMAKE_COMPILER_IS_GNUCXX)
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_GCC_REGEX_VERSION})")
else()
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
endif()
@@ -1029,7 +1016,7 @@ if(HAVE_OPENCL)
set(__libs "")
foreach(l ${OPENCL_LIBRARIES})
if(TARGET ${l})
get_target_property(p ${l} LOCATION)
get_target_property(p ${l} IMPORTED_LOCATION)
if(p MATCHES NOTFOUND)
list(APPEND __libs "${l}")
else()
+6 -6
View File
@@ -1553,7 +1553,7 @@ macro(CUDA_ADD_LIBRARY cuda_target)
# variable will have been defined.
CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")
target_link_libraries(${cuda_target}
target_link_libraries(${cuda_target} LINK_PRIVATE
${CUDA_LIBRARIES}
)
@@ -1597,7 +1597,7 @@ macro(CUDA_ADD_EXECUTABLE cuda_target)
# variable will have been defined.
CUDA_LINK_SEPARABLE_COMPILATION_OBJECTS("${link_file}" ${cuda_target} "${_options}" "${${cuda_target}_SEPARABLE_COMPILATION_OBJECTS}")
target_link_libraries(${cuda_target}
target_link_libraries(${cuda_target} LINK_PRIVATE
${CUDA_LIBRARIES}
)
@@ -1672,9 +1672,9 @@ endmacro()
###############################################################################
macro(CUDA_ADD_CUFFT_TO_TARGET target)
if (CUDA_BUILD_EMULATION)
target_link_libraries(${target} ${CUDA_cufftemu_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cufftemu_LIBRARY})
else()
target_link_libraries(${target} ${CUDA_cufft_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cufft_LIBRARY})
endif()
endmacro()
@@ -1685,9 +1685,9 @@ endmacro()
###############################################################################
macro(CUDA_ADD_CUBLAS_TO_TARGET target)
if (CUDA_BUILD_EMULATION)
target_link_libraries(${target} ${CUDA_cublasemu_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cublasemu_LIBRARY})
else()
target_link_libraries(${target} ${CUDA_cublas_LIBRARY})
target_link_libraries(${target} LINK_PRIVATE ${CUDA_cublas_LIBRARY})
endif()
endmacro()
+2 -2
View File
@@ -18,9 +18,9 @@ if(ENABLE_CCACHE AND NOT CMAKE_COMPILER_IS_CCACHE)
message(STATUS "Unable to compile program with enabled ccache, reverting...")
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${__OLD_RULE_LAUNCH_COMPILE}")
endif()
else()
message(STATUS "Looking for ccache - not found")
endif()
else()
message(STATUS "Looking for ccache - not found")
endif()
endif()
+2 -3
View File
@@ -302,16 +302,15 @@ macro(add_android_project target path)
endif()
add_library(${JNI_LIB_NAME} SHARED ${android_proj_jni_files})
target_link_libraries(${JNI_LIB_NAME} ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS})
target_link_libraries(${JNI_LIB_NAME} LINK_PRIVATE ${OPENCV_LINKER_LIBS} ${android_proj_NATIVE_DEPS})
set_target_properties(${JNI_LIB_NAME} PROPERTIES
OUTPUT_NAME "${JNI_LIB_NAME}"
LIBRARY_OUTPUT_DIRECTORY "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}"
)
get_target_property(android_proj_jni_location "${JNI_LIB_NAME}" LOCATION)
if (NOT (CMAKE_BUILD_TYPE MATCHES "debug"))
add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${android_proj_jni_location}")
add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${JNI_LIB_NAME}>")
endif()
endif()
+1 -1
View File
@@ -212,7 +212,7 @@ if(CUDA_FOUND)
endif()
# disabled because of multiple warnings during building nvcc auto generated files
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_GCC_REGEX_VERSION VERSION_GREATER "4.6.0")
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "4.6.0")
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-but-set-variable)
endif()
+4 -42
View File
@@ -42,49 +42,11 @@ if(MSVC AND CMAKE_C_COMPILER MATCHES "icc|icl")
set(CV_ICC __INTEL_COMPILER_FOR_WINDOWS)
endif()
# ----------------------------------------------------------------------------
# Detect GNU version:
# ----------------------------------------------------------------------------
if(CMAKE_COMPILER_IS_CLANGCXX)
set(CMAKE_GCC_REGEX_VERSION "4.2.1")
set(CMAKE_OPENCV_GCC_VERSION_MAJOR 4)
set(CMAKE_OPENCV_GCC_VERSION_MINOR 2)
set(CMAKE_OPENCV_GCC_VERSION 42)
set(CMAKE_OPENCV_GCC_VERSION_NUM 402)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v
ERROR_VARIABLE CMAKE_OPENCV_CLANG_VERSION_FULL
ERROR_STRIP_TRAILING_WHITESPACE)
string(REGEX MATCH "version.*$" CMAKE_OPENCV_CLANG_VERSION_FULL "${CMAKE_OPENCV_CLANG_VERSION_FULL}")
string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_CLANG_REGEX_VERSION "${CMAKE_OPENCV_CLANG_VERSION_FULL}")
elseif(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v
ERROR_VARIABLE CMAKE_OPENCV_GCC_INFO_FULL
OUTPUT_STRIP_TRAILING_WHITESPACE)
# Typical output in CMAKE_OPENCV_GCC_VERSION_FULL: "c+//0 (whatever) 4.2.3 (...)"
# Look for the version number
string(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
if(NOT CMAKE_GCC_REGEX_VERSION)
string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_GCC_REGEX_VERSION "${CMAKE_OPENCV_GCC_VERSION_FULL}")
endif()
# Split the three parts:
string(REGEX MATCHALL "[0-9]+" CMAKE_OPENCV_GCC_VERSIONS "${CMAKE_GCC_REGEX_VERSION}")
list(GET CMAKE_OPENCV_GCC_VERSIONS 0 CMAKE_OPENCV_GCC_VERSION_MAJOR)
list(GET CMAKE_OPENCV_GCC_VERSIONS 1 CMAKE_OPENCV_GCC_VERSION_MINOR)
set(CMAKE_OPENCV_GCC_VERSION ${CMAKE_OPENCV_GCC_VERSION_MAJOR}${CMAKE_OPENCV_GCC_VERSION_MINOR})
math(EXPR CMAKE_OPENCV_GCC_VERSION_NUM "${CMAKE_OPENCV_GCC_VERSION_MAJOR}*100 + ${CMAKE_OPENCV_GCC_VERSION_MINOR}")
message(STATUS "Detected version of GNU GCC: ${CMAKE_OPENCV_GCC_VERSION} (${CMAKE_OPENCV_GCC_VERSION_NUM})")
if(NOT DEFINED CMAKE_CXX_COMPILER_VERSION)
message(WARNING "Compiler version is not available: CMAKE_CXX_COMPILER_VERSION is not set")
endif()
if(CMAKE_COMPILER_IS_GNUCXX)
if(WIN32)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpmachine
OUTPUT_VARIABLE OPENCV_GCC_TARGET_MACHINE
+9 -16
View File
@@ -84,23 +84,16 @@ if(WITH_PVAPI)
set(PVAPI_SDK_SUBDIR arm)
endif()
get_filename_component(_PVAPI_LIBRARY "${PVAPI_INCLUDE_PATH}/../lib-pc" ABSOLUTE)
if(PVAPI_SDK_SUBDIR)
set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${PVAPI_SDK_SUBDIR}")
endif()
if(NOT WIN32 AND CMAKE_COMPILER_IS_GNUCXX)
set(_PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_OPENCV_GCC_VERSION_MAJOR}.${CMAKE_OPENCV_GCC_VERSION_MINOR}")
endif()
get_filename_component(_PVAPI_LIBRARY_HINT "${PVAPI_INCLUDE_PATH}/../lib-pc" ABSOLUTE)
if(WIN32)
if(MINGW)
set(PVAPI_DEFINITIONS "-DPVDECL=__stdcall")
endif(MINGW)
set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/PvAPI.lib" CACHE PATH "The PvAPI library")
else(WIN32)
set(PVAPI_LIBRARY "${_PVAPI_LIBRARY}/${CMAKE_STATIC_LIBRARY_PREFIX}PvAPI${CMAKE_STATIC_LIBRARY_SUFFIX}" CACHE PATH "The PvAPI library")
endif(WIN32)
if(EXISTS "${PVAPI_LIBRARY}")
find_library(PVAPI_LIBRARY NAMES "PvAPI" PATHS "${_PVAPI_LIBRARY_HINT}")
if(PVAPI_LIBRARY)
if(WIN32)
if(MINGW)
set(PVAPI_DEFINITIONS "-DPVDECL=__stdcall")
endif(MINGW)
endif()
set(HAVE_PVAPI TRUE)
endif()
endif(PVAPI_INCLUDE_PATH)
+9 -9
View File
@@ -46,16 +46,16 @@ endif()
set(OpenCV_LIB_COMPONENTS_)
foreach(CVLib ${OpenCV_LIB_COMPONENTS})
get_target_property(libloc ${CVLib} LOCATION_${CMAKE_BUILD_TYPE})
if(libloc MATCHES "3rdparty")
set(libpath "\${exec_prefix}/share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH}")
else()
set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}")
get_target_property(libname ${CVLib} OUTPUT_NAME_${CMAKE_BUILD_TYPE})
if(NOT libname)
get_target_property(libname ${CVLib} OUTPUT_NAME)
endif()
if(NOT libname)
set(libname "${CVLib}")
endif()
list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}")
get_filename_component(libname ${CVLib} NAME_WE)
string(REGEX REPLACE "^lib" "" libname "${libname}")
set(libpath "\${exec_prefix}/${OPENCV_LIB_INSTALL_PATH}")
list(APPEND OpenCV_LIB_COMPONENTS_ "-L${libpath}")
list(APPEND OpenCV_LIB_COMPONENTS_ "-l${libname}")
endforeach()
@@ -66,7 +66,7 @@ if(OpenCV_EXTRA_COMPONENTS)
if(TARGET "${extra_component}")
get_target_property(extra_component_is_imported "${extra_component}" IMPORTED)
if(extra_component_is_imported)
get_target_property(extra_component "${extra_component}" LOCATION)
get_target_property(extra_component "${extra_component}" IMPORTED_LOCATION)
endif()
endif()
+4 -4
View File
@@ -578,12 +578,12 @@ macro(ocv_create_module)
${${the_module}_pch})
if(NOT "${ARGN}" STREQUAL "SKIP_LINK")
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS})
target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${OPENCV_MODULE_${the_module}_DEPS})
target_link_libraries(${the_module} LINK_PUBLIC ${OPENCV_MODULE_${the_module}_DEPS})
target_link_libraries(${the_module} LINK_PUBLIC ${OPENCV_MODULE_${the_module}_DEPS})
set(extra_deps ${OPENCV_MODULE_${the_module}_DEPS_EXT} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${ARGN})
ocv_extract_simple_libs(extra_deps _simple_deps _other_deps)
target_link_libraries(${the_module} LINK_INTERFACE_LIBRARIES ${_simple_deps}) # this list goes to "export"
target_link_libraries(${the_module} ${extra_deps})
target_link_libraries(${the_module} LINK_PRIVATE ${_simple_deps}) # this list goes to "export"
target_link_libraries(${the_module} LINK_PRIVATE ${extra_deps})
endif()
add_dependencies(opencv_modules ${the_module})
+1 -1
View File
@@ -124,7 +124,7 @@ set(STD_OPENCV_DEV libopencv-dev)
set(ABI_VERSION_SUFFIX "")
if(CMAKE_COMPILER_IS_GNUCXX)
if(${CMAKE_OPENCV_GCC_VERSION_MAJOR} EQUAL 5)
if(NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5 AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6)
set(ABI_VERSION_SUFFIX "v5")
endif()
endif()
+5 -5
View File
@@ -5,8 +5,8 @@ if(UNIX)
find_package(PkgConfig)
endif()
# Search packages for host system instead of packages for target system
# in case of cross compilation thess macro should be defined by toolchain file
# Search packages for the host system instead of packages for target system
# in case of cross compilation these macros should be defined by the toolchain file
if(NOT COMMAND find_host_package)
macro(find_host_package)
find_package(${ARGN})
@@ -82,7 +82,7 @@ macro(ocv_check_environment_variables)
endforeach()
endmacro()
# adds include directories in such way that directories from the OpenCV source tree go first
# adds include directories in such a way that directories from the OpenCV source tree go first
function(ocv_include_directories)
set(__add_before "")
foreach(dir ${ARGN})
@@ -337,7 +337,7 @@ macro(ocv_check_modules define)
endmacro()
# Macros that checks if module have been installed.
# Macro that checks if module has been installed.
# After it adds module to build and define
# constants passed as second arg
macro(CHECK_MODULE module_name define)
@@ -526,7 +526,7 @@ macro(ocv_list_add_suffix LST SUFFIX)
endmacro()
# gets and removes the first element from list
# gets and removes the first element from the list
macro(ocv_list_pop_front LST VAR)
if(${LST})
list(GET ${LST} 0 ${VAR})
+2 -2
View File
@@ -14,6 +14,6 @@ endif()
set(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}")
set(OPENCV_LIBVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
# create a dependency on version file
# we never use output of the following command but cmake will rerun automatically if the version file changes
# create a dependency on the version file
# we never use the output of the following command but cmake will rerun automatically if the version file changes
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}/junk/version.junk" COPYONLY)
+8
View File
@@ -219,6 +219,14 @@ foreach(__cvcomponent ${OpenCV_FIND_COMPONENTS})
string(TOUPPER "${__cvcomponent}" __cvcomponent)
set(${__cvcomponent}_FOUND 1)
endif()
# OpenCV supports Debug and Release only.
# RelWithDebInfo and MinSizeRel are mapped to Release
if(TARGET ${__cvcomponent})
set_target_properties(${__cvcomponent} PROPERTIES
MAP_IMPORTED_CONFIG_MINSIZEREL "Release"
MAP_IMPORTED_CONFIG_RELWITHDEBINFO "Release"
)
endif()
endforeach()
set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_})
@@ -111,7 +111,7 @@ Then the PSNR is expressed as:
PSNR = 10 \cdot \log_{10} \left( \frac{MAX_I^2}{MSE} \right)
Here the :math:`MAX_I^2` is the maximum valid value for a pixel. In case of the simple single byte image per pixel per channel this is 255. When two images are the same the MSE will give zero, resulting in an invalid divide by zero operation in the PSNR formula. In this case the PSNR is undefined and as we'll need to handle this case separately. The transition to a logarithmic scale is made because the pixel values have a very wide dynamic range. All this translated to OpenCV and a C++ function looks like:
Here the :math:`MAX_I` is the maximum valid value for a pixel. In case of the simple single byte image per pixel per channel this is 255. When two images are the same the MSE will give zero, resulting in an invalid divide by zero operation in the PSNR formula. In this case the PSNR is undefined and as we'll need to handle this case separately. The transition to a logarithmic scale is made because the pixel values have a very wide dynamic range. All this translated to OpenCV and a C++ function looks like:
.. code-block:: cpp
@@ -31,7 +31,7 @@ Aligns a buffer size to the specified number of bytes.
:param n: Alignment size that must be a power of two.
The function returns the minimum number that is greater or equal to ``sz`` and is divisible by ``n`` :
The function returns the minimum number that is greater than or equal to ``sz`` and is divisible by ``n`` :
.. math::
@@ -363,7 +363,7 @@ Always returns 0 if called outside of parallel region.
.. ocv:function:: int getThreadNum()
The exact meaning of return value depends on the threading framework used by OpenCV library:
The exact meaning of the return value depends on the threading framework used by OpenCV library:
* **TBB** Unsupported with current 4.1 TBB release. May be will be supported in future.
* **OpenMP** The thread number, within the current team, of the calling thread.
@@ -450,7 +450,7 @@ This operation is used in the simplest or most complex image processing function
setNumThreads
-----------------
OpenCV will try to set the number of threads for the next parallel region.
If ``threads == 0``, OpenCV will disable threading optimizations and run all it's
If ``threads == 0``, OpenCV will disable threading optimizations and run all its
functions sequentially. Passing ``threads < 0`` will reset threads number to system default.
This function must be called outside of parallel region.
@@ -458,14 +458,14 @@ This function must be called outside of parallel region.
:param nthreads: Number of threads used by OpenCV.
OpenCV will try to run it's functions with specified threads number, but
OpenCV will try to run its functions with specified threads number, but
some behaviour differs from framework:
* **TBB** User-defined parallel constructions will run with the same threads number,
if another does not specified. If late on user creates own scheduler, OpenCV will be use it.
if another is not specified. If late on user creates his own scheduler, OpenCV will be use it.
* **OpenMP** No special defined behaviour.
* **Concurrency** If ``threads == 1``, OpenCV will disable threading optimizations
and run it's functions sequentially.
and run its functions sequentially.
* **GCD** Supports only values <= 0.
* **C=** No special defined behaviour.
@@ -3248,6 +3248,9 @@ public:
//! returns read-only pointer to the real buffer, stack-allocated or head-allocated
operator const _Tp* () const;
//! returns number of allocated elements
size_t getSize() const;
protected:
//! pointer to the real buffer, can point to buf if the buffer is small enough
_Tp* ptr;
@@ -2581,6 +2581,9 @@ template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::op
template<typename _Tp, size_t fixed_size> inline AutoBuffer<_Tp, fixed_size>::operator const _Tp* () const
{ return ptr; }
template<typename _Tp, size_t fixed_size> inline size_t AutoBuffer<_Tp, fixed_size>::getSize() const
{ return size; }
/////////////////////////////////// Ptr ////////////////////////////////////////
@@ -50,7 +50,7 @@
#define CV_VERSION_EPOCH 2
#define CV_VERSION_MAJOR 4
#define CV_VERSION_MINOR 13
#define CV_VERSION_REVISION 3
#define CV_VERSION_REVISION 4
#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
+22 -12
View File
@@ -279,21 +279,31 @@ Mat::Mat(const Mat& m, const Range& _rowRange, const Range& _colRange) : size(&r
}
*this = m;
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
try
{
CV_Assert( 0 <= _rowRange.start && _rowRange.start <= _rowRange.end && _rowRange.end <= m.rows );
rows = _rowRange.size();
data += step*_rowRange.start;
flags |= SUBMATRIX_FLAG;
}
if( _rowRange != Range::all() && _rowRange != Range(0,rows) )
{
CV_Assert( 0 <= _rowRange.start && _rowRange.start <= _rowRange.end
&& _rowRange.end <= m.rows );
rows = _rowRange.size();
data += step*_rowRange.start;
flags |= SUBMATRIX_FLAG;
}
if( _colRange != Range::all() && _colRange != Range(0,cols) )
if( _colRange != Range::all() && _colRange != Range(0,cols) )
{
CV_Assert( 0 <= _colRange.start && _colRange.start <= _colRange.end
&& _colRange.end <= m.cols );
cols = _colRange.size();
data += _colRange.start*elemSize();
flags &= cols < m.cols ? ~CONTINUOUS_FLAG : -1;
flags |= SUBMATRIX_FLAG;
}
}
catch(...)
{
CV_Assert( 0 <= _colRange.start && _colRange.start <= _colRange.end && _colRange.end <= m.cols );
cols = _colRange.size();
data += _colRange.start*elemSize();
flags &= cols < m.cols ? ~CONTINUOUS_FLAG : -1;
flags |= SUBMATRIX_FLAG;
release();
throw;
}
if( rows == 1 )
+1 -4
View File
@@ -241,7 +241,7 @@ endif(HAVE_INTELPERC)
if(IOS)
add_definitions(-DHAVE_IOS=1)
list(APPEND highgui_srcs src/ios_conversions.mm src/cap_ios_abstract_camera.mm src/cap_ios_photo_camera.mm src/cap_ios_video_camera.mm)
list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework AssetsLibrary")
list(APPEND HIGHGUI_LIBRARIES "-framework Accelerate" "-framework AVFoundation" "-framework CoreGraphics" "-framework CoreMedia" "-framework CoreVideo" "-framework QuartzCore" "-framework UIKit")
endif()
if(WIN32)
@@ -293,9 +293,6 @@ if(MSVC)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /NODEFAULTLIB:libcmt.lib /DEBUG")
endif()
#stop automatic dependencies propagation for this module
set_target_properties(${the_module} PROPERTIES LINK_INTERFACE_LIBRARIES "")
ocv_add_precompiled_headers(${the_module})
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated-declarations -Wno-clobbered)
+2
View File
@@ -208,6 +208,8 @@ int RLByteStream::getByte()
current = m_current;
}
CV_Assert(current < m_end);
val = *((uchar*)current);
m_current = current + 1;
return val;
+13 -6
View File
@@ -48,13 +48,20 @@
namespace cv
{
enum
{
RBS_THROW_EOS=-123, // <end of stream> exception code
RBS_THROW_FORB=-124, // <forrbidden huffman code> exception code
RBS_HUFF_FORB=2047, // forrbidden huffman code "value"
RBS_BAD_HEADER=-125 // invalid header
#define DECLARE_RBS_EXCEPTION(name) \
class RBS_ ## name ## _Exception : public cv::Exception \
{ \
public: \
RBS_ ## name ## _Exception(int code_, const String& err_, const String& func_, const String& file_, int line_) : \
cv::Exception(code_, err_, func_, file_, line_) \
{} \
};
DECLARE_RBS_EXCEPTION(THROW_EOS)
#define RBS_THROW_EOS RBS_THROW_EOS_Exception(CV_StsError, "Unexpected end of input stream", CV_Func, __FILE__, __LINE__)
DECLARE_RBS_EXCEPTION(THROW_FORB)
#define RBS_THROW_FORB RBS_THROW_FORB_Exception(CV_StsError, "Forrbidden huffman code", CV_Func, __FILE__, __LINE__)
DECLARE_RBS_EXCEPTION(BAD_HEADER)
#define RBS_BAD_HEADER RBS_BAD_HEADER_Exception(CV_StsError, "Invalid header", CV_Func, __FILE__, __LINE__)
typedef unsigned long ulong;
+2 -6
View File
@@ -31,7 +31,7 @@
#import "opencv2/highgui/cap_ios.h"
#include "precomp.hpp"
#import <AssetsLibrary/AssetsLibrary.h>
#import <UIKit/UIKit.h>
static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
@@ -595,11 +595,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
return;
}
ALAssetsLibrary *library = [[ALAssetsLibrary alloc] init];
if ([library videoAtPathIsCompatibleWithSavedPhotosAlbum:[self videoFileURL]]) {
[library writeVideoAtPathToSavedPhotosAlbum:[self videoFileURL]
completionBlock:^(NSURL *assetURL, NSError *error){ (void)assetURL; (void)error; }];
}
UISaveVideoAtPathToSavedPhotosAlbum([self videoFileString], nil, nil, NULL);
}
+23 -11
View File
@@ -115,8 +115,9 @@ bool BmpDecoder::readHeader()
if( m_bpp <= 8 )
{
memset( m_palette, 0, sizeof(m_palette));
m_strm.getBytes( m_palette, (clrused == 0? 1<<m_bpp : clrused)*4 );
CV_Assert(clrused <= 256);
memset(m_palette, 0, sizeof(m_palette));
m_strm.getBytes(m_palette, (clrused == 0? 1<<m_bpp : clrused)*4 );
iscolor = IsColorPalette( m_palette, m_bpp );
}
else if( m_bpp == 16 && m_rle_code == BMP_BITFIELDS )
@@ -165,6 +166,7 @@ bool BmpDecoder::readHeader()
}
catch(...)
{
throw;
}
m_type = iscolor ? CV_8UC3 : CV_8UC1;
@@ -184,7 +186,7 @@ bool BmpDecoder::readHeader()
bool BmpDecoder::readData( Mat& img )
{
uchar* data = img.data;
int step = (int)img.step;
int step = validateToInt(img.step);
bool color = img.channels() > 1;
uchar gray_palette[256];
bool result = false;
@@ -197,7 +199,7 @@ bool BmpDecoder::readData( Mat& img )
if( m_origin == IPL_ORIGIN_BL )
{
data += (m_height - 1)*step;
data += (m_height - 1)*(size_t)step;
step = -step;
}
@@ -282,7 +284,9 @@ bool BmpDecoder::readData( Mat& img )
else if( code > 2 ) // absolute mode
{
if( data + code*nch > line_end ) goto decode_rle4_bad;
m_strm.getBytes( src, (((code + 1)>>1) + 1) & -2 );
int sz = (((code + 1)>>1) + 1) & (~1);
CV_Assert((size_t)sz < _src.getSize());
m_strm.getBytes(src, sz);
if( color )
data = FillColorRow4( data, src, code, m_palette );
else
@@ -363,6 +367,9 @@ decode_rle4_bad: ;
gray_palette[code] );
line_end_flag = y - prev_y;
if( y >= m_height )
break;
}
else if( code > 2 ) // absolute mode
{
@@ -371,7 +378,9 @@ decode_rle4_bad: ;
if( data + code3 > line_end )
goto decode_rle8_bad;
m_strm.getBytes( src, (code + 1) & -2 );
int sz = (code + 1) & (~1);
CV_Assert((size_t)sz < _src.getSize());
m_strm.getBytes(src, sz);
if( color )
data = FillColorRow8( data, src, code, m_palette );
else
@@ -464,17 +473,20 @@ decode_rle8_bad: ;
if( !color )
icvCvt_BGRA2Gray_8u_C4C1R( src, 0, data, 0, cvSize(m_width,1) );
else
icvCvt_BGRA2BGR_8u_C4C3R( src, 0, data, 0, cvSize(m_width,1) );
else if( img.channels() == 3 )
icvCvt_BGRA2BGR_8u_C4C3R(src, 0, data, 0, cvSize(m_width, 1));
else if( img.channels() == 4 )
memcpy(data, src, m_width * 4);
}
result = true;
break;
default:
assert(0);
CV_Error(CV_StsError, "Invalid/unsupported mode");
}
}
catch(...)
{
throw;
}
return result;
@@ -517,7 +529,7 @@ bool BmpEncoder::write( const Mat& img, const vector<int>& )
int bitmapHeaderSize = 40;
int paletteSize = channels > 1 ? 0 : 1024;
int headerSize = 14 /* fileheader */ + bitmapHeaderSize + paletteSize;
int fileSize = fileStep*height + headerSize;
size_t fileSize = (size_t)fileStep*height + headerSize;
PaletteEntry palette[256];
if( m_buf )
@@ -527,7 +539,7 @@ bool BmpEncoder::write( const Mat& img, const vector<int>& )
strm.putBytes( fmtSignBmp, (int)strlen(fmtSignBmp) );
// write file header
strm.putDWord( fileSize ); // file size
strm.putDWord( validateToInt(fileSize) ); // file size
strm.putDWord( 0 );
strm.putDWord( headerSize );
+5 -5
View File
@@ -188,7 +188,7 @@ bool ExrDecoder::readData( Mat& img )
bool color = img.channels() > 1;
uchar* data = img.data;
int step = img.step;
size_t step = img.step;
bool justcopy = m_native_depth;
bool chromatorgb = false;
bool rgbtogray = false;
@@ -196,8 +196,8 @@ bool ExrDecoder::readData( Mat& img )
FrameBuffer frame;
int xsample[3] = {1, 1, 1};
char *buffer;
int xstep;
int ystep;
size_t xstep = 0;
size_t ystep = 0;
xstep = m_native_depth ? 4 : 1;
@@ -589,7 +589,7 @@ bool ExrEncoder::write( const Mat& img, const vector<int>& )
bool isfloat = depth == CV_32F || depth == CV_64F;
depth = CV_ELEM_SIZE1(depth)*8;
uchar* data = img.data;
int step = img.step;
size_t step = img.step;
Header header( width, height );
Imf::PixelType type;
@@ -619,7 +619,7 @@ bool ExrEncoder::write( const Mat& img, const vector<int>& )
FrameBuffer frame;
char *buffer;
int bufferstep;
size_t bufferstep;
int size;
if( type == FLOAT && depth == 32 )
{
+1 -1
View File
@@ -392,7 +392,7 @@ int my_jpeg_load_dht (struct jpeg_decompress_struct *info, unsigned char *dht,
bool JpegDecoder::readData( Mat& img )
{
bool result = false;
int step = (int)img.step;
size_t step = img.step;
bool color = img.channels() > 1;
if( m_state && m_width && m_height )
+3 -3
View File
@@ -156,7 +156,7 @@ bool Jpeg2KDecoder::readData( Mat& img )
bool result = false;
int color = img.channels() > 1;
uchar* data = img.data;
int step = (int)img.step;
size_t step = img.step;
jas_stream_t* stream = (jas_stream_t*)m_stream;
jas_image_t* image = (jas_image_t*)m_image;
@@ -252,9 +252,9 @@ bool Jpeg2KDecoder::readData( Mat& img )
if( !jas_image_readcmpt( image, cmptlut[i], 0, 0, xend / xstep, yend / ystep, buffer ))
{
if( img.depth() == CV_8U )
result = readComponent8u( data + i, buffer, step, cmptlut[i], maxval, offset, ncmpts );
result = readComponent8u( data + i, buffer, validateToInt(step), cmptlut[i], maxval, offset, ncmpts );
else
result = readComponent16u( ((unsigned short *)data) + i, buffer, step / 2, cmptlut[i], maxval, offset, ncmpts );
result = readComponent16u( ((unsigned short *)data) + i, buffer, validateToInt(step / 2), cmptlut[i], maxval, offset, ncmpts );
if( !result )
{
i = ncmpts;
+74 -45
View File
@@ -43,50 +43,58 @@
#include "precomp.hpp"
#include "utils.hpp"
#include "grfmt_pxm.hpp"
#include <iostream>
namespace cv
{
///////////////////////// P?M reader //////////////////////////////
static int ReadNumber( RLByteStream& strm, int maxdigits )
static int ReadNumber(RLByteStream& strm, int maxdigits = 0)
{
int code;
int val = 0;
int64 val = 0;
int digits = 0;
code = strm.getByte();
if( !isdigit(code))
while (!isdigit(code))
{
do
if (code == '#' )
{
if( code == '#' )
do
{
do
{
code = strm.getByte();
}
while( code != '\n' && code != '\r' );
code = strm.getByte();
}
while (code != '\n' && code != '\r');
code = strm.getByte();
while( isspace(code))
}
else if (isspace(code))
{
while (isspace(code))
code = strm.getByte();
}
while( !isdigit( code ));
else
{
#if 1
CV_Error_(CV_StsError, ("PXM: Unexpected code in ReadNumber(): 0x%x (%d)", code, code));
#else
code = strm.getByte();
#endif
}
}
do
{
val = val*10 + code - '0';
if( ++digits >= maxdigits ) break;
val = val*10 + (code - '0');
CV_Assert(val <= INT_MAX && "PXM: ReadNumber(): result is too large");
digits++;
if (maxdigits != 0 && digits >= maxdigits) break;
code = strm.getByte();
}
while( isdigit(code));
while (isdigit(code));
return val;
return (int)val;
}
@@ -119,13 +127,13 @@ ImageDecoder PxMDecoder::newDecoder() const
return new PxMDecoder;
}
void PxMDecoder::close()
void PxMDecoder::close()
{
m_strm.close();
}
bool PxMDecoder::readHeader()
bool PxMDecoder::readHeader()
{
bool result = false;
@@ -155,10 +163,10 @@ bool PxMDecoder::readHeader()
m_binary = code >= '4';
m_type = m_bpp > 8 ? CV_8UC3 : CV_8UC1;
m_width = ReadNumber( m_strm, INT_MAX );
m_height = ReadNumber( m_strm, INT_MAX );
m_width = ReadNumber(m_strm);
m_height = ReadNumber(m_strm);
m_maxval = m_bpp == 1 ? 1 : ReadNumber( m_strm, INT_MAX );
m_maxval = m_bpp == 1 ? 1 : ReadNumber(m_strm);
if( m_maxval > 65535 )
throw RBS_BAD_HEADER;
@@ -172,8 +180,14 @@ bool PxMDecoder::readHeader()
result = true;
}
}
catch(...)
catch (const cv::Exception&)
{
throw;
}
catch (...)
{
std::cerr << "PXM::readHeader(): unknown C++ exception" << std::endl << std::flush;
throw;
}
if( !result )
@@ -193,27 +207,23 @@ bool PxMDecoder::readData( Mat& img )
int step = (int)img.step;
PaletteEntry palette[256];
bool result = false;
int bit_depth = CV_ELEM_SIZE1(m_type)*8;
int src_pitch = (m_width*m_bpp*bit_depth/8 + 7)/8;
const int bit_depth = CV_ELEM_SIZE1(m_type)*8;
const int src_pitch = (m_width*m_bpp*(bit_depth/8) + 7) / 8;
int nch = CV_MAT_CN(m_type);
int width3 = m_width*nch;
int i, x, y;
if( m_offset < 0 || !m_strm.isOpened())
return false;
AutoBuffer<uchar,1024> _src(src_pitch + 32);
uchar* src = _src;
AutoBuffer<uchar,1024> _gray_palette;
uchar* gray_palette = _gray_palette;
uchar gray_palette[256] = {0};
// create LUT for converting colors
if( bit_depth == 8 )
{
_gray_palette.allocate(m_maxval + 1);
gray_palette = _gray_palette;
CV_Assert(m_maxval < 256);
for( i = 0; i <= m_maxval; i++ )
for (int i = 0; i <= m_maxval; i++)
gray_palette[i] = (uchar)((i*255/m_maxval)^(m_bpp == 1 ? 255 : 0));
FillGrayPalette( palette, m_bpp==1 ? 1 : 8 , m_bpp == 1 );
@@ -227,12 +237,16 @@ bool PxMDecoder::readData( Mat& img )
{
////////////////////////// 1 BPP /////////////////////////
case 1:
CV_Assert(CV_MAT_DEPTH(m_type) == CV_8U);
if( !m_binary )
{
for( y = 0; y < m_height; y++, data += step )
AutoBuffer<uchar> _src(m_width);
uchar* src = _src;
for (int y = 0; y < m_height; y++, data += step)
{
for( x = 0; x < m_width; x++ )
src[x] = ReadNumber( m_strm, 1 ) != 0;
for (int x = 0; x < m_width; x++)
src[x] = ReadNumber(m_strm, 1) != 0;
if( color )
FillColorRow8( data, src, m_width, palette );
@@ -242,7 +256,10 @@ bool PxMDecoder::readData( Mat& img )
}
else
{
for( y = 0; y < m_height; y++, data += step )
AutoBuffer<uchar> _src(src_pitch);
uchar* src = _src;
for (int y = 0; y < m_height; y++, data += step)
{
m_strm.getBytes( src, src_pitch );
@@ -258,11 +275,15 @@ bool PxMDecoder::readData( Mat& img )
////////////////////////// 8 BPP /////////////////////////
case 8:
case 24:
for( y = 0; y < m_height; y++, data += step )
{
AutoBuffer<uchar> _src(std::max<size_t>(width3*2, src_pitch));
uchar* src = _src;
for (int y = 0; y < m_height; y++, data += step)
{
if( !m_binary )
{
for( x = 0; x < width3; x++ )
for (int x = 0; x < width3; x++)
{
int code = ReadNumber( m_strm, INT_MAX );
if( (unsigned)code > (unsigned)m_maxval ) code = m_maxval;
@@ -277,7 +298,7 @@ bool PxMDecoder::readData( Mat& img )
m_strm.getBytes( src, src_pitch );
if( bit_depth == 16 && !isBigEndian() )
{
for( x = 0; x < width3; x++ )
for (int x = 0; x < width3; x++)
{
uchar v = src[x * 2];
src[x * 2] = src[x * 2 + 1];
@@ -288,7 +309,7 @@ bool PxMDecoder::readData( Mat& img )
if( img.depth() == CV_8U && bit_depth == 16 )
{
for( x = 0; x < width3; x++ )
for (int x = 0; x < width3; x++)
{
int v = ((ushort *)src)[x];
src[x] = (uchar)(v >> 8);
@@ -329,12 +350,19 @@ bool PxMDecoder::readData( Mat& img )
}
result = true;
break;
}
default:
assert(0);
CV_Error(CV_StsError, "m_bpp is not supported");
}
}
catch(...)
catch (const cv::Exception&)
{
throw;
}
catch (...)
{
std::cerr << "PXM::readData(): unknown exception" << std::endl << std::flush;
throw;
}
return result;
@@ -410,8 +438,9 @@ bool PxMEncoder::write( const Mat& img, const vector<int>& params )
char* buffer = _buffer;
// write header;
sprintf( buffer, "P%c\n%d %d\n%d\n",
sprintf( buffer, "P%c\n# Generated by OpenCV %s\n%d %d\n%d\n",
'2' + (channels > 1 ? 1 : 0) + (isBinary ? 3 : 0),
CV_VERSION,
width, height, (1 << depth) - 1 );
strm.putBytes( buffer, (int)strlen(buffer) );
+3 -3
View File
@@ -156,7 +156,7 @@ bool SunRasterDecoder::readData( Mat& img )
{
int color = img.channels() > 1;
uchar* data = img.data;
int step = (int)img.step;
size_t step = img.step;
uchar gray_palette[256];
bool result = false;
int src_pitch = ((m_width*m_bpp + 7)/8 + 1) & -2;
@@ -304,11 +304,11 @@ bad_decoding_1bpp:
code = m_strm.getByte();
if( color )
data = FillUniColor( data, line_end, step, width3,
data = FillUniColor( data, line_end, validateToInt(step), width3,
y, m_height, len,
m_palette[code] );
else
data = FillUniGray( data, line_end, step, width3,
data = FillUniGray( data, line_end, validateToInt(step), width3,
y, m_height, len,
gray_palette[code] );
if( y >= m_height )
+104 -18
View File
@@ -48,12 +48,32 @@
#undef min
#undef max
#include <iostream>
/****************************************************************************************\
* Image Codecs *
\****************************************************************************************/
namespace cv
{
// TODO Add runtime configuration
#define CV_IO_MAX_IMAGE_PARAMS (50)
#define CV_IO_MAX_IMAGE_WIDTH (1<<20)
#define CV_IO_MAX_IMAGE_HEIGHT (1<<20)
#define CV_IO_MAX_IMAGE_PIXELS (1<<30) // 1 Gigapixel
static Size validateInputImageSize(const Size& size)
{
CV_Assert(size.width > 0);
CV_Assert(size.width <= CV_IO_MAX_IMAGE_WIDTH);
CV_Assert(size.height > 0);
CV_Assert(size.height <= CV_IO_MAX_IMAGE_HEIGHT);
uint64 pixels = (uint64)size.width * (uint64)size.height;
CV_Assert(pixels <= CV_IO_MAX_IMAGE_PIXELS);
return size;
}
struct ImageCodecInitializer
{
ImageCodecInitializer()
@@ -203,12 +223,26 @@ imread_( const string& filename, int flags, int hdrtype, Mat* mat=0 )
if( decoder.empty() )
return 0;
decoder->setSource(filename);
if( !decoder->readHeader() )
return 0;
CvSize size;
size.width = decoder->width();
size.height = decoder->height();
try
{
// read the header to make sure it succeeds
if (!decoder->readHeader())
return 0;
}
catch (const cv::Exception& e)
{
std::cerr << "imread_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
return 0;
}
catch (...)
{
std::cerr << "imread_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
return 0;
}
Size size = validateInputImageSize(Size(decoder->width(), decoder->height()));
int type = decoder->type();
if( flags != -1 )
@@ -242,7 +276,21 @@ imread_( const string& filename, int flags, int hdrtype, Mat* mat=0 )
temp = cvarrToMat(image);
}
if( !decoder->readData( *data ))
bool success = false;
try
{
if (decoder->readData(*data))
success = true;
}
catch (const cv::Exception& e)
{
std::cerr << "imread_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
}
catch (...)
{
std::cerr << "imread_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
}
if (!success)
{
cvReleaseImage( &image );
cvReleaseMat( &matrix );
@@ -288,6 +336,7 @@ static bool imwrite_( const string& filename, const Mat& image,
}
encoder->setDestination( filename );
CV_Assert(params.size() <= CV_IO_MAX_IMAGE_PARAMS*2);
bool code = encoder->write( *pimage, params );
// CV_Assert( code );
@@ -326,16 +375,34 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
decoder->setSource(filename);
}
if( !decoder->readHeader() )
bool success = false;
try
{
if( !filename.empty() )
remove(filename.c_str());
if (decoder->readHeader())
success = true;
}
catch (const cv::Exception& e)
{
std::cerr << "imdecode_('" << filename << "'): can't read header: " << e.what() << std::endl << std::flush;
}
catch (...)
{
std::cerr << "imdecode_('" << filename << "'): can't read header: unknown exception" << std::endl << std::flush;
}
if (!success)
{
if (!filename.empty())
{
if (0 != remove(filename.c_str()))
{
std::cerr << "unable to remove temporary file:" << filename << std::endl << std::flush;
}
}
return 0;
}
CvSize size;
size.width = decoder->width();
size.height = decoder->height();
// established the required input image size
Size size = validateInputImageSize(Size(decoder->width(), decoder->height()));
int type = decoder->type();
if( flags != -1 )
@@ -369,11 +436,30 @@ imdecode_( const Mat& buf, int flags, int hdrtype, Mat* mat=0 )
temp = cvarrToMat(image);
}
bool code = decoder->readData( *data );
if( !filename.empty() )
remove(filename.c_str());
success = false;
try
{
if (decoder->readData(*data))
success = true;
}
catch (const cv::Exception& e)
{
std::cerr << "imdecode_('" << filename << "'): can't read data: " << e.what() << std::endl << std::flush;
}
catch (...)
{
std::cerr << "imdecode_('" << filename << "'): can't read data: unknown exception" << std::endl << std::flush;
}
if( !code )
if (!filename.empty())
{
if (0 != remove(filename.c_str()))
{
std::cerr << "unable to remove temporary file:" << filename << std::endl << std::flush;
}
}
if (!success)
{
cvReleaseImage( &image );
cvReleaseMat( &matrix );
@@ -490,7 +576,7 @@ cvSaveImage( const char* filename, const CvArr* arr, const int* _params )
if( _params )
{
for( ; _params[i] > 0; i += 2 )
;
CV_Assert(i < CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
}
return cv::imwrite_(filename, cv::cvarrToMat(arr),
i > 0 ? cv::vector<int>(_params, _params+i) : cv::vector<int>(),
@@ -521,7 +607,7 @@ cvEncodeImage( const char* ext, const CvArr* arr, const int* _params )
if( _params )
{
for( ; _params[i] > 0; i += 2 )
;
CV_Assert(i < CV_IO_MAX_IMAGE_PARAMS*2); // Limit number of params for security reasons
}
cv::Mat img = cv::cvarrToMat(arr);
if( CV_IS_IMAGE(arr) && ((const IplImage*)arr)->origin == IPL_ORIGIN_BL )
+31 -20
View File
@@ -42,6 +42,13 @@
#include "precomp.hpp"
#include "utils.hpp"
int validateToInt(size_t sz)
{
int valueInt = (int)sz;
CV_Assert((size_t)valueInt == sz);
return valueInt;
}
#define SCALE 14
#define cR (int)(0.299*(1 << SCALE) + 0.5)
#define cG (int)(0.587*(1 << SCALE) + 0.5)
@@ -537,23 +544,25 @@ uchar* FillColorRow1( uchar* data, uchar* indices, int len, PaletteEntry* palett
{
uchar* end = data + len*3;
const PaletteEntry p0 = palette[0], p1 = palette[1];
while( (data += 24) < end )
{
int idx = *indices++;
*((PaletteEntry*)(data - 24)) = palette[(idx & 128) != 0];
*((PaletteEntry*)(data - 21)) = palette[(idx & 64) != 0];
*((PaletteEntry*)(data - 18)) = palette[(idx & 32) != 0];
*((PaletteEntry*)(data - 15)) = palette[(idx & 16) != 0];
*((PaletteEntry*)(data - 12)) = palette[(idx & 8) != 0];
*((PaletteEntry*)(data - 9)) = palette[(idx & 4) != 0];
*((PaletteEntry*)(data - 6)) = palette[(idx & 2) != 0];
*((PaletteEntry*)(data - 3)) = palette[(idx & 1) != 0];
*((PaletteEntry*)(data - 24)) = (idx & 128) ? p1 : p0;
*((PaletteEntry*)(data - 21)) = (idx & 64) ? p1 : p0;
*((PaletteEntry*)(data - 18)) = (idx & 32) ? p1 : p0;
*((PaletteEntry*)(data - 15)) = (idx & 16) ? p1 : p0;
*((PaletteEntry*)(data - 12)) = (idx & 8) ? p1 : p0;
*((PaletteEntry*)(data - 9)) = (idx & 4) ? p1 : p0;
*((PaletteEntry*)(data - 6)) = (idx & 2) ? p1 : p0;
*((PaletteEntry*)(data - 3)) = (idx & 1) ? p1 : p0;
}
int idx = indices[0] << 24;
int idx = indices[0];
for( data -= 24; data < end; data += 3, idx += idx )
{
PaletteEntry clr = palette[idx < 0];
const PaletteEntry clr = (idx & 128) ? p1 : p0;
WRITE_PIX( data, clr );
}
@@ -565,23 +574,25 @@ uchar* FillGrayRow1( uchar* data, uchar* indices, int len, uchar* palette )
{
uchar* end = data + len;
const uchar p0 = palette[0], p1 = palette[1];
while( (data += 8) < end )
{
int idx = *indices++;
*((uchar*)(data - 8)) = palette[(idx & 128) != 0];
*((uchar*)(data - 7)) = palette[(idx & 64) != 0];
*((uchar*)(data - 6)) = palette[(idx & 32) != 0];
*((uchar*)(data - 5)) = palette[(idx & 16) != 0];
*((uchar*)(data - 4)) = palette[(idx & 8) != 0];
*((uchar*)(data - 3)) = palette[(idx & 4) != 0];
*((uchar*)(data - 2)) = palette[(idx & 2) != 0];
*((uchar*)(data - 1)) = palette[(idx & 1) != 0];
*((uchar*)(data - 8)) = (idx & 128) ? p1 : p0;
*((uchar*)(data - 7)) = (idx & 64) ? p1 : p0;
*((uchar*)(data - 6)) = (idx & 32) ? p1 : p0;
*((uchar*)(data - 5)) = (idx & 16) ? p1 : p0;
*((uchar*)(data - 4)) = (idx & 8) ? p1 : p0;
*((uchar*)(data - 3)) = (idx & 4) ? p1 : p0;
*((uchar*)(data - 2)) = (idx & 2) ? p1 : p0;
*((uchar*)(data - 1)) = (idx & 1) ? p1 : p0;
}
int idx = indices[0] << 24;
int idx = indices[0];
for( data -= 8; data < end; data++, idx += idx )
{
data[0] = palette[idx < 0];
data[0] = (idx & 128) ? p1 : p0;
}
return data;
+2
View File
@@ -42,6 +42,8 @@
#ifndef _UTILS_H_
#define _UTILS_H_
int validateToInt(size_t step);
struct PaletteEntry
{
unsigned char b, g, r, a;
+8 -9
View File
@@ -314,25 +314,26 @@ if(BUILD_FAT_JAVA_LIB)
endif()
if(APPLE)
foreach(_dep ${__deps})
target_link_libraries(${the_module} -Wl,-force_load "${_dep}")
target_link_libraries(${the_module} LINK_PRIVATE -Wl,-force_load "${_dep}")
endforeach()
else()
target_link_libraries(${the_module} -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive)
target_link_libraries(${the_module} LINK_PRIVATE -Wl,-whole-archive ${__deps} -Wl,-no-whole-archive)
endif()
target_link_libraries(${the_module} ${__extradeps} ${OPENCV_LINKER_LIBS})
target_link_libraries(${the_module} LINK_PRIVATE ${__extradeps} ${OPENCV_LINKER_LIBS})
else()
target_link_libraries(${the_module} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
endif()
if(ANDROID)
target_link_libraries(${the_module} jnigraphics) # for Mat <=> Bitmap converters
target_link_libraries(${the_module} LINK_PUBLIC jnigraphics) # for Mat <=> Bitmap converters
target_link_libraries(${the_module} LINK_PUBLIC log dl z)
target_link_libraries(${the_module} LINK_PRIVATE ${OPENCV_LINKER_LIBS})
# force strip library after the build command
# because samples and tests will make a copy of the library before install
get_target_property(__opencv_java_location ${the_module} LOCATION)
# Turn off stripping in debug build
if ( NOT (CMAKE_BUILD_TYPE MATCHES "Debug"))
add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${__opencv_java_location}")
add_custom_command(TARGET ${the_module} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "$<TARGET_FILE:${the_module}>")
endif()
endif()
@@ -342,8 +343,6 @@ set_target_properties(${the_module} PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
INSTALL_NAME_DIR ${OPENCV_LIB_INSTALL_PATH}
LINK_INTERFACE_LIBRARIES ""
)
if(WIN32)
+2
View File
@@ -97,6 +97,8 @@ if(MSVC AND NOT ENABLE_NOISY_WARNINGS)
string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef) # accurate guard via #pragma doesn't work (C++ preprocessor doesn't handle #pragma)
if(MSVC AND NOT BUILD_SHARED_LIBS)
set_target_properties(${the_module} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:atlthunk.lib /NODEFAULTLIB:atlsd.lib /DEBUG")
endif()
+1 -1
View File
@@ -7,7 +7,7 @@ set(the_description "Viz")
ocv_define_module(viz opencv_core ${VTK_LIBRARIES})
if(APPLE AND BUILD_opencv_viz)
target_link_libraries(opencv_viz "-framework Cocoa")
target_link_libraries(opencv_viz LINK_PRIVATE "-framework Cocoa")
endif()
if(TARGET opencv_test_viz)