mirror of
https://github.com/opencv/opencv.git
synced 2026-07-23 12:23:02 +04:00
Compare commits
190 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 631126c77a | |||
| 655d381ef3 | |||
| cdfa8a668b | |||
| 92651d228d | |||
| 90e3692603 | |||
| 3a8316ab93 | |||
| 8d3f0d0eab | |||
| cdd4354256 | |||
| bde955fc56 | |||
| abc9e98625 | |||
| d086ee14dd | |||
| f43fec7ee6 | |||
| 6385511e88 | |||
| ed4becf007 | |||
| f11ab4c569 | |||
| b12c2c76d1 | |||
| f5589445b9 | |||
| 032a61b197 | |||
| 011ed380aa | |||
| 88a18c8b6a | |||
| 51e65db715 | |||
| cc02fcd889 | |||
| 9f17c62533 | |||
| 36bd2a65e3 | |||
| 85d4e56bb1 | |||
| 381d9bafdf | |||
| ada16fd188 | |||
| c408157a4d | |||
| 6e299b582a | |||
| 19ac54277b | |||
| b1a57c4cb2 | |||
| 54c180092d | |||
| 6e733b65ae | |||
| 947d610309 | |||
| 3e01a387ba | |||
| b9d9730b62 | |||
| 0a178a687a | |||
| 8fa86d4d34 | |||
| a22dd28e02 | |||
| a079acc0d9 | |||
| 91817bffe1 | |||
| 49bef1cdbf | |||
| 175bcb1734 | |||
| fec2c7e715 | |||
| 60c093f086 | |||
| f071207463 | |||
| 792b7e0629 | |||
| cee3ec6dc4 | |||
| 3da17c42a4 | |||
| 2329cbc1a2 | |||
| b39ee54103 | |||
| 6a889ed3e5 | |||
| f3ba88c87c | |||
| e7c5120682 | |||
| 19cfaa2be7 | |||
| e97c7e042b | |||
| 35f27d0d3e | |||
| 330a11861e | |||
| 4827fe86bb | |||
| 72c55b56f2 | |||
| 4eab85d364 | |||
| 3cc83ce024 | |||
| 52c423a423 | |||
| 542b3e8a64 | |||
| 4f79eb256d | |||
| 7620456486 | |||
| 5462710103 | |||
| d1b923bee9 | |||
| 04020f391a | |||
| c4ab0c09ea | |||
| 9b7f40ce4d | |||
| 659cf7249e | |||
| 62a010a25d | |||
| 6b4ea68bc7 | |||
| d6891c705e | |||
| 16b674b984 | |||
| 65392d5e6b | |||
| 5aef565fb6 | |||
| a3287b85c5 | |||
| 0c0b1ec9ae | |||
| 35ff9af6ce | |||
| dad2b9aac8 | |||
| 1613d30544 | |||
| b6df9debaf | |||
| b9d0dc60b0 | |||
| 37b1876807 | |||
| bd396e1fd5 | |||
| 5da69c0b9a | |||
| a806e8cc58 | |||
| 1a1a7bbbfd | |||
| 33e97e994d | |||
| 11e6848bb9 | |||
| 829410729c | |||
| 0e2a3686c0 | |||
| 0d2857a242 | |||
| 17d99e6266 | |||
| ea7d4be3f8 | |||
| 05db8784ae | |||
| 58b06222ff | |||
| 58dc397930 | |||
| a6277370ca | |||
| b55d8f46f4 | |||
| 985aa0423d | |||
| c14a8dce93 | |||
| f5d45221ca | |||
| ebe4ca6b60 | |||
| f159ed20c2 | |||
| cdbb042ce4 | |||
| 23bbe511fe | |||
| 444218e755 | |||
| 9cc60c9dd3 | |||
| 2c226d597d | |||
| c6ab32ffb9 | |||
| 101be77d9d | |||
| 61f1ee2d2d | |||
| 93b6e80cd7 | |||
| d4741eece1 | |||
| 585484cb06 | |||
| b696928a5b | |||
| 79d4e865fe | |||
| 8380879804 | |||
| de7f8eec04 | |||
| 49432009fe | |||
| 473f10877c | |||
| 3e51448ef0 | |||
| 8041ab8a61 | |||
| cb286a66be | |||
| f33828a1ca | |||
| 68e425f869 | |||
| 98b6ce353c | |||
| 1ac7baceff | |||
| 968d94d417 | |||
| 2ce47fda88 | |||
| ffd010767f | |||
| edf533c83e | |||
| c1d61c88e9 | |||
| 6360b846c6 | |||
| 57900d07f0 | |||
| 8e72e1ed88 | |||
| 10c547396d | |||
| 66dd871288 | |||
| d484939c02 | |||
| 85fd8729ce | |||
| b3e16c6423 | |||
| 30d6766db4 | |||
| bce76a7977 | |||
| 0ee61d178f | |||
| 0e9453a395 | |||
| e5647cf70d | |||
| 74cc63ba2f | |||
| 0b6e360602 | |||
| a49cda6523 | |||
| d612c72405 | |||
| 6bd143dd25 | |||
| 770d3eabc0 | |||
| 75e2ba5af3 | |||
| 1726bb6c0d | |||
| 5dfe65d53a | |||
| d059cc7170 | |||
| 84a81579ba | |||
| aa11cc19e8 | |||
| a6f5717567 | |||
| 12507aab8a | |||
| d21622bef4 | |||
| bc8eac2439 | |||
| 4e65db80e8 | |||
| ce68291d83 | |||
| f77fdc0ce8 | |||
| 7da51787b9 | |||
| b1f422c1c5 | |||
| b3f966e2ca | |||
| 3f191e1b75 | |||
| 9a9e457dd6 | |||
| c316dbe2aa | |||
| b5fcb06a76 | |||
| f8f9f3c438 | |||
| e6c68eed51 | |||
| f9e747dbc6 | |||
| bd0732b1d0 | |||
| 0b5cbcefdd | |||
| e4a87f2f4f | |||
| 3c8cadf7ca | |||
| 7c0b26e8a0 | |||
| 982503e9a8 | |||
| 3d93675ff9 | |||
| 53d6c9b9c0 | |||
| a02e90d502 | |||
| 238dbffb48 | |||
| a9d7b6eab7 | |||
| 62252d157e |
Vendored
+4
@@ -1844,14 +1844,18 @@ TegraCvtColor_Invoker(bgrx2hsvf, bgrx2hsv, src_data + static_cast<size_t>(range.
|
||||
#define cv_hal_cvtBGRtoGray TEGRA_CVTBGRTOGRAY
|
||||
#undef cv_hal_cvtGraytoBGR
|
||||
#define cv_hal_cvtGraytoBGR TEGRA_CVTGRAYTOBGR
|
||||
#if 0 // bit-exact tests are failed
|
||||
#undef cv_hal_cvtBGRtoYUV
|
||||
#define cv_hal_cvtBGRtoYUV TEGRA_CVTBGRTOYUV
|
||||
#endif
|
||||
#undef cv_hal_cvtBGRtoHSV
|
||||
#define cv_hal_cvtBGRtoHSV TEGRA_CVTBGRTOHSV
|
||||
#if 0 // bit-exact tests are failed
|
||||
#undef cv_hal_cvtTwoPlaneYUVtoBGR
|
||||
#define cv_hal_cvtTwoPlaneYUVtoBGR TEGRA_CVT2PYUVTOBGR
|
||||
#undef cv_hal_cvtTwoPlaneYUVtoBGREx
|
||||
#define cv_hal_cvtTwoPlaneYUVtoBGREx TEGRA_CVT2PYUVTOBGR_EX
|
||||
#endif
|
||||
|
||||
#endif // OPENCV_IMGPROC_HAL_INTERFACE_H
|
||||
|
||||
|
||||
Vendored
+5
-5
@@ -1,8 +1,8 @@
|
||||
# Binaries branch name: ffmpeg/3.4_20211005
|
||||
# Binaries were created for OpenCV: 95c1d2a8872b222f32bd88db9f1efcbd9f70a9cf
|
||||
ocv_update(FFMPEG_BINARIES_COMMIT "0bf6c0753d435d2c82c03c48db0c6e18ac79976c")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN32 "55c25bbc13e4a12d4339b70d3b76987f")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN64 "67caee9231c6843483b4de9815d6526e")
|
||||
# Binaries branch name: ffmpeg/3.4_20211220
|
||||
# Binaries were created for OpenCV: a22dd28e0272ec0f1cfee8811d3f5f0392827c65
|
||||
ocv_update(FFMPEG_BINARIES_COMMIT "5a7644ec3940c6eed41c6ebb5a0602a5615fdb3f")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN32 "8ad9de6f1f2ca77786748d1f3a4e83ea")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN64 "2c670f068252e7cd28d3883993dc1d6e")
|
||||
ocv_update(FFMPEG_FILE_HASH_CMAKE "3b90f67f4b429e77d3da36698cef700c")
|
||||
|
||||
function(download_win_ffmpeg script_var)
|
||||
|
||||
+2
-2
@@ -4,9 +4,9 @@ ocv_warnings_disable(CMAKE_C_FLAGS -Wunused-parameter -Wsign-compare -Wshorten-6
|
||||
|
||||
set(VERSION_MAJOR 2)
|
||||
set(VERSION_MINOR 1)
|
||||
set(VERSION_REVISION 0)
|
||||
set(VERSION_REVISION 2)
|
||||
set(VERSION ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_REVISION})
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 2001000)
|
||||
set(LIBJPEG_TURBO_VERSION_NUMBER 2001002)
|
||||
|
||||
string(TIMESTAMP BUILD "opencv-${OPENCV_VERSION}-libjpeg-turbo")
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
|
||||
+10
@@ -40,3 +40,13 @@
|
||||
#define HAVE_BITSCANFORWARD
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(__has_attribute)
|
||||
#if __has_attribute(fallthrough)
|
||||
#define FALLTHROUGH __attribute__((fallthrough));
|
||||
#else
|
||||
#define FALLTHROUGH
|
||||
#endif
|
||||
#else
|
||||
#define FALLTHROUGH
|
||||
#endif
|
||||
|
||||
Vendored
+3
-2
@@ -44,8 +44,9 @@
|
||||
* flags (this defines __thumb__).
|
||||
*/
|
||||
|
||||
#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || \
|
||||
defined(_M_ARM64)
|
||||
/* NOTE: Both GCC and Clang define __GNUC__ */
|
||||
#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
|
||||
defined(_M_ARM) || defined(_M_ARM64)
|
||||
#if !defined(__thumb__) || defined(__thumb2__)
|
||||
#define USE_CLZ_INTRINSIC
|
||||
#endif
|
||||
|
||||
+1
-1
@@ -493,7 +493,7 @@ prepare_for_pass(j_compress_ptr cinfo)
|
||||
master->pass_type = output_pass;
|
||||
master->pass_number++;
|
||||
#endif
|
||||
/*FALLTHROUGH*/
|
||||
FALLTHROUGH /*FALLTHROUGH*/
|
||||
case output_pass:
|
||||
/* Do a data-output pass. */
|
||||
/* We need not repeat per-scan setup if prior optimization pass did it. */
|
||||
|
||||
Vendored
+6
-4
@@ -7,6 +7,7 @@
|
||||
* Copyright (C) 2011, 2015, 2018, 2021, D. R. Commander.
|
||||
* Copyright (C) 2016, 2018, Matthieu Darbois.
|
||||
* Copyright (C) 2020, Arm Limited.
|
||||
* Copyright (C) 2021, Alex Richardson.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -52,8 +53,9 @@
|
||||
* flags (this defines __thumb__).
|
||||
*/
|
||||
|
||||
#if defined(__arm__) || defined(__aarch64__) || defined(_M_ARM) || \
|
||||
defined(_M_ARM64)
|
||||
/* NOTE: Both GCC and Clang define __GNUC__ */
|
||||
#if (defined(__GNUC__) && (defined(__arm__) || defined(__aarch64__))) || \
|
||||
defined(_M_ARM) || defined(_M_ARM64)
|
||||
#if !defined(__thumb__) || defined(__thumb2__)
|
||||
#define USE_CLZ_INTRINSIC
|
||||
#endif
|
||||
@@ -679,7 +681,7 @@ encode_mcu_AC_first(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
emit_restart(entropy, entropy->next_restart_num);
|
||||
|
||||
#ifdef WITH_SIMD
|
||||
cvalue = values = (JCOEF *)PAD((size_t)values_unaligned, 16);
|
||||
cvalue = values = (JCOEF *)PAD((JUINTPTR)values_unaligned, 16);
|
||||
#else
|
||||
/* Not using SIMD, so alignment is not needed */
|
||||
cvalue = values = values_unaligned;
|
||||
@@ -944,7 +946,7 @@ encode_mcu_AC_refine(j_compress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
emit_restart(entropy, entropy->next_restart_num);
|
||||
|
||||
#ifdef WITH_SIMD
|
||||
cabsvalue = absvalues = (JCOEF *)PAD((size_t)absvalues_unaligned, 16);
|
||||
cabsvalue = absvalues = (JCOEF *)PAD((JUINTPTR)absvalues_unaligned, 16);
|
||||
#else
|
||||
/* Not using SIMD, so alignment is not needed */
|
||||
cabsvalue = absvalues = absvalues_unaligned;
|
||||
|
||||
+2
-1
@@ -23,6 +23,7 @@
|
||||
#include "jinclude.h"
|
||||
#include "jpeglib.h"
|
||||
#include "jdmaster.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -308,7 +309,7 @@ jpeg_consume_input(j_decompress_ptr cinfo)
|
||||
/* Initialize application's data source module */
|
||||
(*cinfo->src->init_source) (cinfo);
|
||||
cinfo->global_state = DSTATE_INHEADER;
|
||||
/*FALLTHROUGH*/
|
||||
FALLTHROUGH /*FALLTHROUGH*/
|
||||
case DSTATE_INHEADER:
|
||||
retcode = (*cinfo->inputctl->consume_input) (cinfo);
|
||||
if (retcode == JPEG_REACHED_SOS) { /* Found SOS, prepare to decompress */
|
||||
|
||||
Vendored
+10
-1
@@ -584,7 +584,7 @@ decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
* behavior is, to the best of our understanding, innocuous, and it is
|
||||
* unclear how to work around it without potentially affecting
|
||||
* performance. Thus, we (hopefully temporarily) suppress UBSan integer
|
||||
* overflow errors for this function.
|
||||
* overflow errors for this function and decode_mcu_fast().
|
||||
*/
|
||||
s += state.last_dc_val[ci];
|
||||
state.last_dc_val[ci] = s;
|
||||
@@ -651,6 +651,12 @@ decode_mcu_slow(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
}
|
||||
|
||||
|
||||
#if defined(__has_feature)
|
||||
#if __has_feature(undefined_behavior_sanitizer)
|
||||
__attribute__((no_sanitize("signed-integer-overflow"),
|
||||
no_sanitize("unsigned-integer-overflow")))
|
||||
#endif
|
||||
#endif
|
||||
LOCAL(boolean)
|
||||
decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
{
|
||||
@@ -681,6 +687,9 @@ decode_mcu_fast(j_decompress_ptr cinfo, JBLOCKROW *MCU_data)
|
||||
|
||||
if (entropy->dc_needed[blkn]) {
|
||||
int ci = cinfo->MCU_membership[blkn];
|
||||
/* Refer to the comment in decode_mcu_slow() regarding the supression of
|
||||
* a UBSan integer overflow error in this line of code.
|
||||
*/
|
||||
s += state.last_dc_val[ci];
|
||||
state.last_dc_val[ci] = s;
|
||||
if (block)
|
||||
|
||||
+3
-2
@@ -18,6 +18,7 @@
|
||||
|
||||
#include "jinclude.h"
|
||||
#include "jdmainct.h"
|
||||
#include "jconfigint.h"
|
||||
|
||||
|
||||
/*
|
||||
@@ -360,7 +361,7 @@ process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
main_ptr->context_state = CTX_PREPARE_FOR_IMCU;
|
||||
if (*out_row_ctr >= out_rows_avail)
|
||||
return; /* Postprocessor exactly filled output buf */
|
||||
/*FALLTHROUGH*/
|
||||
FALLTHROUGH /*FALLTHROUGH*/
|
||||
case CTX_PREPARE_FOR_IMCU:
|
||||
/* Prepare to process first M-1 row groups of this iMCU row */
|
||||
main_ptr->rowgroup_ctr = 0;
|
||||
@@ -371,7 +372,7 @@ process_data_context_main(j_decompress_ptr cinfo, JSAMPARRAY output_buf,
|
||||
if (main_ptr->iMCU_row_ctr == cinfo->total_iMCU_rows)
|
||||
set_bottom_pointers(cinfo);
|
||||
main_ptr->context_state = CTX_PROCESS_IMCU;
|
||||
/*FALLTHROUGH*/
|
||||
FALLTHROUGH /*FALLTHROUGH*/
|
||||
case CTX_PROCESS_IMCU:
|
||||
/* Call postprocessor using previously set pointers */
|
||||
(*cinfo->post->post_process_data) (cinfo,
|
||||
|
||||
Vendored
+3
-3
@@ -4,7 +4,7 @@
|
||||
* This file was part of the Independent JPEG Group's software:
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2016, D. R. Commander.
|
||||
* Copyright (C) 2016, 2021, D. R. Commander.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -1032,7 +1032,7 @@ free_pool(j_common_ptr cinfo, int pool_id)
|
||||
large_pool_ptr next_lhdr_ptr = lhdr_ptr->next;
|
||||
space_freed = lhdr_ptr->bytes_used +
|
||||
lhdr_ptr->bytes_left +
|
||||
sizeof(large_pool_hdr);
|
||||
sizeof(large_pool_hdr) + ALIGN_SIZE - 1;
|
||||
jpeg_free_large(cinfo, (void *)lhdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
lhdr_ptr = next_lhdr_ptr;
|
||||
@@ -1045,7 +1045,7 @@ free_pool(j_common_ptr cinfo, int pool_id)
|
||||
while (shdr_ptr != NULL) {
|
||||
small_pool_ptr next_shdr_ptr = shdr_ptr->next;
|
||||
space_freed = shdr_ptr->bytes_used + shdr_ptr->bytes_left +
|
||||
sizeof(small_pool_hdr);
|
||||
sizeof(small_pool_hdr) + ALIGN_SIZE - 1;
|
||||
jpeg_free_small(cinfo, (void *)shdr_ptr, space_freed);
|
||||
mem->total_space_allocated -= space_freed;
|
||||
shdr_ptr = next_shdr_ptr;
|
||||
|
||||
Vendored
+14
-1
@@ -5,8 +5,9 @@
|
||||
* Copyright (C) 1991-1997, Thomas G. Lane.
|
||||
* Modified 1997-2009 by Guido Vollbeding.
|
||||
* libjpeg-turbo Modifications:
|
||||
* Copyright (C) 2015-2016, 2019, D. R. Commander.
|
||||
* Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
|
||||
* Copyright (C) 2015, Google, Inc.
|
||||
* Copyright (C) 2021, Alex Richardson.
|
||||
* For conditions of distribution and use, see the accompanying README.ijg
|
||||
* file.
|
||||
*
|
||||
@@ -47,6 +48,18 @@ typedef enum { /* Operating modes for buffer controllers */
|
||||
/* JLONG must hold at least signed 32-bit values. */
|
||||
typedef long JLONG;
|
||||
|
||||
/* JUINTPTR must hold pointer values. */
|
||||
#ifdef __UINTPTR_TYPE__
|
||||
/*
|
||||
* __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+.
|
||||
* Fortunately, that is sufficient to support the few architectures for which
|
||||
* sizeof(void *) != sizeof(size_t). The only other options would require C99
|
||||
* or Clang-specific builtins.
|
||||
*/
|
||||
typedef __UINTPTR_TYPE__ JUINTPTR;
|
||||
#else
|
||||
typedef size_t JUINTPTR;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Left shift macro that handles a negative operand without causing any
|
||||
|
||||
+9
-7
@@ -98,6 +98,12 @@ ocv_cmake_hook(CMAKE_INIT)
|
||||
|
||||
# must go before the project()/enable_language() commands
|
||||
ocv_update(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE
|
||||
AND NOT OPENCV_SKIP_DEFAULT_BUILD_TYPE
|
||||
)
|
||||
message(STATUS "'Release' build type is used by default. Use CMAKE_BUILD_TYPE to specify build type (Release or Debug)")
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Choose the type of build")
|
||||
endif()
|
||||
if(DEFINED CMAKE_BUILD_TYPE)
|
||||
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS "${CMAKE_CONFIGURATION_TYPES}")
|
||||
endif()
|
||||
@@ -107,7 +113,7 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ${ENABLE_PIC})
|
||||
|
||||
ocv_cmake_hook(PRE_CMAKE_BOOTSTRAP)
|
||||
|
||||
# Bootstap CMake system: setup CMAKE_SYSTEM_NAME and other vars
|
||||
# Bootstrap CMake system: setup CMAKE_SYSTEM_NAME and other vars
|
||||
enable_language(CXX C)
|
||||
|
||||
ocv_cmake_hook(POST_CMAKE_BOOTSTRAP)
|
||||
@@ -218,7 +224,7 @@ OCV_OPTION(BUILD_TIFF "Build libtiff from source" (WIN32
|
||||
OCV_OPTION(BUILD_JASPER "Build libjasper from source" (WIN32 OR ANDROID OR APPLE OR OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
OCV_OPTION(BUILD_JPEG "Build libjpeg from source" (WIN32 OR ANDROID OR APPLE OR OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
OCV_OPTION(BUILD_PNG "Build libpng from source" (WIN32 OR ANDROID OR APPLE OR OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (((WIN32 OR ANDROID OR APPLE) AND NOT WINRT) OR OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" (OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
OCV_OPTION(BUILD_WEBP "Build WebP from source" (((WIN32 OR ANDROID OR APPLE) AND NOT WINRT) OR OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
OCV_OPTION(BUILD_TBB "Download and build TBB from source" (ANDROID OR OPENCV_FORCE_3RDPARTY_BUILD) )
|
||||
OCV_OPTION(BUILD_IPP_IW "Build IPP IW from source" (NOT MINGW OR OPENCV_FORCE_3RDPARTY_BUILD) IF (X86_64 OR X86) AND NOT WINRT )
|
||||
@@ -300,7 +306,7 @@ OCV_OPTION(WITH_JPEG "Include JPEG support" ON
|
||||
OCV_OPTION(WITH_WEBP "Include WebP support" ON
|
||||
VISIBLE_IF NOT WINRT
|
||||
VERIFY HAVE_WEBP)
|
||||
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" BUILD_OPENEXR OR NOT CMAKE_CROSSCOMPILING
|
||||
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ((WIN32 OR ANDROID OR APPLE) OR BUILD_OPENEXR) OR NOT CMAKE_CROSSCOMPILING
|
||||
VISIBLE_IF NOT APPLE_FRAMEWORK AND NOT WINRT
|
||||
VERIFY HAVE_OPENEXR)
|
||||
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF
|
||||
@@ -599,10 +605,6 @@ endif()
|
||||
# ----------------------------------------------------------------------------
|
||||
# OpenCV compiler and linker options
|
||||
# ----------------------------------------------------------------------------
|
||||
# In case of Makefiles if the user does not setup CMAKE_BUILD_TYPE, assume it's Release:
|
||||
if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja" AND "${CMAKE_BUILD_TYPE}" STREQUAL "")
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
ocv_cmake_hook(POST_CMAKE_BUILD_OPTIONS)
|
||||
|
||||
|
||||
@@ -87,11 +87,3 @@ endif()
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_LINKER_DEFENSES_FLAGS_COMMON}" )
|
||||
|
||||
if(CV_GCC OR CV_CLANG)
|
||||
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()
|
||||
|
||||
@@ -238,7 +238,7 @@ if(X86 OR X86_64)
|
||||
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(POPCNT "-mpopcnt" "") # -mpopcnt is available since ICC 19.0.0
|
||||
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")
|
||||
|
||||
@@ -112,8 +112,8 @@ if(DEFINED InferenceEngine_VERSION)
|
||||
endif()
|
||||
endif()
|
||||
if(NOT INF_ENGINE_RELEASE AND NOT INF_ENGINE_RELEASE_INIT)
|
||||
message(STATUS "WARNING: InferenceEngine version has not been set, 2021.4.1 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
|
||||
set(INF_ENGINE_RELEASE_INIT "2021040100")
|
||||
message(STATUS "WARNING: InferenceEngine version has not been set, 2021.4.2 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
|
||||
set(INF_ENGINE_RELEASE_INIT "2021040200")
|
||||
elseif(DEFINED INF_ENGINE_RELEASE)
|
||||
set(INF_ENGINE_RELEASE_INIT "${INF_ENGINE_RELEASE}")
|
||||
endif()
|
||||
|
||||
@@ -177,7 +177,7 @@ if(NOT ${found})
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
if(CMAKE_HOST_UNIX)
|
||||
execute_process(COMMAND ${_executable} -c "from distutils.sysconfig import *; print(get_python_lib())"
|
||||
execute_process(COMMAND ${_executable} -c "from sysconfig import *; print(get_path('purelib'))"
|
||||
RESULT_VARIABLE _cvpy_process
|
||||
OUTPUT_VARIABLE _std_packages_path
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
@@ -51,6 +51,23 @@ macro(ocv_lapack_check)
|
||||
if(NOT "${OPENCV_CBLAS_H_PATH_${_lapack_impl}}" STREQUAL "${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}")
|
||||
list(APPEND _lapack_content "#include \"${OPENCV_LAPACKE_H_PATH_${_lapack_impl}}\"")
|
||||
endif()
|
||||
list(APPEND _lapack_content "
|
||||
#if defined(LAPACK_GLOBAL) || defined(LAPACK_NAME)
|
||||
/*
|
||||
* Using netlib's reference LAPACK implementation version >= 3.4.0 (first with C interface).
|
||||
* Use LAPACK_xxxx to transparently (via predefined lapack macros) deal with pre and post 3.9.1 versions.
|
||||
* LAPACK 3.9.1 introduces LAPACK_FORTRAN_STRLEN_END and modifies (through preprocessing) the declarations of the following functions used in opencv
|
||||
* sposv_, dposv_, spotrf_, dpotrf_, sgesdd_, dgesdd_, sgels_, dgels_
|
||||
* which end up with an extra parameter.
|
||||
* So we also need to preprocess the function calls in opencv coding by prefixing them with LAPACK_.
|
||||
* The good news is the preprocessing works fine whatever netlib's LAPACK version.
|
||||
*/
|
||||
#define OCV_LAPACK_FUNC(f) LAPACK_##f
|
||||
#else
|
||||
/* Using other LAPACK implementations so fall back to opencv's assumption until now */
|
||||
#define OCV_LAPACK_FUNC(f) f##_
|
||||
#endif
|
||||
")
|
||||
if(${_lapack_add_extern_c})
|
||||
list(APPEND _lapack_content "}")
|
||||
endif()
|
||||
|
||||
@@ -101,7 +101,6 @@ if(WITH_OPENGL)
|
||||
find_package (OpenGL QUIET)
|
||||
if(OPENGL_FOUND)
|
||||
set(HAVE_OPENGL TRUE)
|
||||
list(APPEND OPENCV_LINKER_LIBS ${OPENGL_LIBRARIES})
|
||||
if(QT_QTOPENGL_FOUND)
|
||||
set(HAVE_QT_OPENGL TRUE)
|
||||
else()
|
||||
|
||||
@@ -240,7 +240,9 @@ if(WITH_OPENEXR)
|
||||
set(OPENEXR_LIBRARIES IlmImf)
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/openexr")
|
||||
if(OPENEXR_VERSION) # check via TARGET doesn't work
|
||||
set(BUILD_OPENEXR ON)
|
||||
set(HAVE_OPENEXR YES)
|
||||
set(BUILD_OPENEXR ON)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -9,6 +9,27 @@
|
||||
# OPENEXR_LIBRARIES = libraries that are needed to use OpenEXR.
|
||||
#
|
||||
|
||||
if(NOT HAVE_CXX11)
|
||||
message(STATUS "OpenEXR: enable C++11 to use external OpenEXR")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_SKIP_OPENEXR_FIND_PACKAGE)
|
||||
find_package(OpenEXR 3 QUIET)
|
||||
#ocv_cmake_dump_vars(EXR)
|
||||
if(OpenEXR_FOUND)
|
||||
if(TARGET OpenEXR::OpenEXR) # OpenEXR 3+
|
||||
set(OPENEXR_LIBRARIES OpenEXR::OpenEXR)
|
||||
set(OPENEXR_INCLUDE_PATHS "")
|
||||
set(OPENEXR_VERSION "${OpenEXR_VERSION}")
|
||||
set(OPENEXR_FOUND 1)
|
||||
return()
|
||||
else()
|
||||
message(STATUS "Unsupported find_package(OpenEXR) - missing OpenEXR::OpenEXR target (version ${OpenEXR_VERSION})")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
SET(OPENEXR_LIBRARIES "")
|
||||
SET(OPENEXR_LIBSEARCH_SUFFIXES "")
|
||||
file(TO_CMAKE_PATH "$ENV{ProgramFiles}" ProgramFiles_ENV_PATH)
|
||||
|
||||
@@ -77,7 +77,7 @@ cv.normalize(roiHist, roiHist, 0, 255, cv.NORM_MINMAX);
|
||||
// delete useless mats.
|
||||
roi.delete(); hsvRoi.delete(); mask.delete(); low.delete(); high.delete(); hsvRoiVec.delete();
|
||||
|
||||
// Setup the termination criteria, either 10 iteration or move by atleast 1 pt
|
||||
// Setup the termination criteria, either 10 iteration or move by at least 1 pt
|
||||
let termCrit = new cv.TermCriteria(cv.TERM_CRITERIA_EPS | cv.TERM_CRITERIA_COUNT, 10, 1);
|
||||
|
||||
let hsv = new cv.Mat(video.height, video.width, cv.CV_8UC3);
|
||||
|
||||
@@ -116,7 +116,7 @@ swapRB = false;
|
||||
needSoftmax = false;
|
||||
|
||||
// url for label file, can from local or Internet
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt";
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/classification_classes_ILSVRC2012.txt";
|
||||
</script>
|
||||
|
||||
<script id="codeSnippet1" type="text/code-snippet">
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"std": "1",
|
||||
"swapRB": "false",
|
||||
"needSoftmax": "false",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"modelUrl": "http://dl.caffe.berkeleyvision.org/bvlc_alexnet.caffemodel",
|
||||
"configUrl": "https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_alexnet/deploy.prototxt"
|
||||
},
|
||||
@@ -16,7 +16,7 @@
|
||||
"std": "0.007843",
|
||||
"swapRB": "false",
|
||||
"needSoftmax": "true",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"modelUrl": "https://drive.google.com/open?id=0B7ubpZO7HnlCcHlfNmJkU2VPelE",
|
||||
"configUrl": "https://raw.githubusercontent.com/shicai/DenseNet-Caffe/master/DenseNet_121.prototxt"
|
||||
},
|
||||
@@ -26,7 +26,7 @@
|
||||
"std": "1",
|
||||
"swapRB": "false",
|
||||
"needSoftmax": "false",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"modelUrl": "http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel",
|
||||
"configUrl": "https://raw.githubusercontent.com/BVLC/caffe/master/models/bvlc_googlenet/deploy.prototxt"
|
||||
},
|
||||
@@ -36,7 +36,7 @@
|
||||
"std": "1",
|
||||
"swapRB": "false",
|
||||
"needSoftmax": "false",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"modelUrl": "https://raw.githubusercontent.com/forresti/SqueezeNet/master/SqueezeNet_v1.0/squeezenet_v1.0.caffemodel",
|
||||
"configUrl": "https://raw.githubusercontent.com/forresti/SqueezeNet/master/SqueezeNet_v1.0/deploy.prototxt"
|
||||
},
|
||||
@@ -46,7 +46,7 @@
|
||||
"std": "1",
|
||||
"swapRB": "false",
|
||||
"needSoftmax": "false",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/classification_classes_ILSVRC2012.txt",
|
||||
"modelUrl": "http://www.robots.ox.ac.uk/~vgg/software/very_deep/caffe/VGG_ILSVRC_19_layers.caffemodel",
|
||||
"configUrl": "https://gist.githubusercontent.com/ksimonyan/3785162f95cd2d5fee77/raw/f02f8769e64494bcd3d7e97d5d747ac275825721/VGG_ILSVRC_19_layers_deploy.prototxt"
|
||||
}
|
||||
|
||||
@@ -116,7 +116,7 @@ swapRB = false;
|
||||
needSoftmax = false;
|
||||
|
||||
// url for label file, can from local or Internet
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/classification_classes_ILSVRC2012.txt";
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/classification_classes_ILSVRC2012.txt";
|
||||
</script>
|
||||
|
||||
<script id="codeSnippet1" type="text/code-snippet">
|
||||
|
||||
@@ -77,7 +77,7 @@ cv.normalize(roiHist, roiHist, 0, 255, cv.NORM_MINMAX);
|
||||
// delete useless mats.
|
||||
roi.delete(); hsvRoi.delete(); mask.delete(); low.delete(); high.delete(); hsvRoiVec.delete();
|
||||
|
||||
// Setup the termination criteria, either 10 iteration or move by atleast 1 pt
|
||||
// Setup the termination criteria, either 10 iteration or move by at least 1 pt
|
||||
let termCrit = new cv.TermCriteria(cv.TERM_CRITERIA_EPS | cv.TERM_CRITERIA_COUNT, 10, 1);
|
||||
|
||||
let hsv = new cv.Mat(video.height, video.width, cv.CV_8UC3);
|
||||
|
||||
@@ -94,7 +94,7 @@ nmsThreshold = 0.4;
|
||||
outType = "SSD";
|
||||
|
||||
// url for label file, can from local or Internet
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/object_detection_classes_pascal_voc.txt";
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/object_detection_classes_pascal_voc.txt";
|
||||
</script>
|
||||
|
||||
<script id="codeSnippet1" type="text/code-snippet">
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
"std": "0.007843",
|
||||
"swapRB": "false",
|
||||
"outType": "SSD",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/object_detection_classes_pascal_voc.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/object_detection_classes_pascal_voc.txt",
|
||||
"modelUrl": "https://raw.githubusercontent.com/chuanqi305/MobileNet-SSD/master/mobilenet_iter_73000.caffemodel",
|
||||
"configUrl": "https://raw.githubusercontent.com/chuanqi305/MobileNet-SSD/master/deploy.prototxt"
|
||||
},
|
||||
@@ -18,7 +18,7 @@
|
||||
"std": "1",
|
||||
"swapRB": "false",
|
||||
"outType": "SSD",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/object_detection_classes_pascal_voc.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/object_detection_classes_pascal_voc.txt",
|
||||
"modelUrl": "https://drive.google.com/uc?id=0BzKzrI_SkD1_WVVTSmQxU0dVRzA&export=download",
|
||||
"configUrl": "https://drive.google.com/uc?id=0BzKzrI_SkD1_WVVTSmQxU0dVRzA&export=download"
|
||||
}
|
||||
@@ -31,7 +31,7 @@
|
||||
"std": "0.00392",
|
||||
"swapRB": "false",
|
||||
"outType": "YOLO",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/object_detection_classes_yolov3.txt",
|
||||
"labelsUrl": "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/object_detection_classes_yolov3.txt",
|
||||
"modelUrl": "https://pjreddie.com/media/files/yolov2-tiny.weights",
|
||||
"configUrl": "https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov2-tiny.cfg"
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ nmsThreshold = 0.4;
|
||||
outType = "SSD";
|
||||
|
||||
// url for label file, can from local or Internet
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/master/samples/data/dnn/object_detection_classes_pascal_voc.txt";
|
||||
labelsUrl = "https://raw.githubusercontent.com/opencv/opencv/3.4/samples/data/dnn/object_detection_classes_pascal_voc.txt";
|
||||
</script>
|
||||
|
||||
<script id="codeSnippet1" type="text/code-snippet">
|
||||
|
||||
@@ -333,7 +333,7 @@ function installDOM(){
|
||||
### Execute it ###
|
||||
|
||||
- Save the file as `exampleNodeCanvasData.js`.
|
||||
- Make sure the files `aarcascade_frontalface_default.xml` and `haarcascade_eye.xml` are present in project's directory. They can be obtained from [OpenCV sources](https://github.com/opencv/opencv/tree/master/data/haarcascades).
|
||||
- Make sure the files `aarcascade_frontalface_default.xml` and `haarcascade_eye.xml` are present in project's directory. They can be obtained from [OpenCV sources](https://github.com/opencv/opencv/tree/3.4/data/haarcascades).
|
||||
- Make sure a sample image file `lena.jpg` exists in project's directory. It should display people's faces for this example to make sense. The following image is known to work:
|
||||
|
||||

|
||||
|
||||
@@ -4,7 +4,9 @@ Using OpenCV.js {#tutorial_js_usage}
|
||||
Steps
|
||||
-----
|
||||
|
||||
In this tutorial, you will learn how to include and start to use `opencv.js` inside a web page. You can get a copy of `opencv.js` from `opencv-{VERSION_NUMBER}-docs.zip` in each [release](https://github.com/opencv/opencv/releases), or simply download the prebuilt script from the online documentations at "https://docs.opencv.org/{VERSION_NUMBER}/opencv.js" (For example, [https://docs.opencv.org/3.4.0/opencv.js](https://docs.opencv.org/3.4.0/opencv.js). Use `master` if you want the latest build). You can also build your own copy by following the tutorial on Build Opencv.js.
|
||||
In this tutorial, you will learn how to include and start to use `opencv.js` inside a web page.
|
||||
You can get a copy of `opencv.js` from `opencv-{VERSION_NUMBER}-docs.zip` in each [release](https://github.com/opencv/opencv/releases), or simply download the prebuilt script from the online documentations at "https://docs.opencv.org/{VERSION_NUMBER}/opencv.js" (For example, [https://docs.opencv.org/3.4.0/opencv.js](https://docs.opencv.org/3.4.0/opencv.js). Use `3.4` if you want the latest build).
|
||||
You can also build your own copy by following the tutorial @ref tutorial_js_setup.
|
||||
|
||||
### Create a web page
|
||||
|
||||
|
||||
@@ -133,9 +133,9 @@ Dense Optical Flow in OpenCV.js
|
||||
|
||||
Lucas-Kanade method computes optical flow for a sparse feature set (in our example, corners detected
|
||||
using Shi-Tomasi algorithm). OpenCV.js provides another algorithm to find the dense optical flow. It
|
||||
computes the optical flow for all the points in the frame. It is based on Gunner Farneback's
|
||||
computes the optical flow for all the points in the frame. It is based on Gunnar Farneback's
|
||||
algorithm which is explained in "Two-Frame Motion Estimation Based on Polynomial Expansion" by
|
||||
Gunner Farneback in 2003.
|
||||
Gunnar Farneback in 2003.
|
||||
|
||||
We use the function: **cv.calcOpticalFlowFarneback (prev, next, flow, pyrScale, levels, winsize,
|
||||
iterations, polyN, polySigma, flags)**
|
||||
|
||||
+15
-1
@@ -240,7 +240,7 @@
|
||||
hal_id = {inria-00350283},
|
||||
hal_version = {v1},
|
||||
}
|
||||
@article{Collins14
|
||||
@article{Collins14,
|
||||
year = {2014},
|
||||
issn = {0920-5691},
|
||||
journal = {International Journal of Computer Vision},
|
||||
@@ -1271,6 +1271,12 @@
|
||||
number={2},
|
||||
pages={117-135},
|
||||
}
|
||||
@inproceedings{Zuliani2014RANSACFD,
|
||||
title={RANSAC for Dummies With examples using the RANSAC toolbox for Matlab \& Octave and more...},
|
||||
author={Marco Zuliani},
|
||||
year={2014},
|
||||
url = {https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.475.1243&rep=rep1&type=pdf}
|
||||
}
|
||||
@inproceedings{forstner1987fast,
|
||||
title={A fast operator for detection and precise location of distincs points, corners and center of circular features},
|
||||
author={FORSTNER, W},
|
||||
@@ -1278,3 +1284,11 @@
|
||||
pages={281--305},
|
||||
year={1987}
|
||||
}
|
||||
@article{Bolelli2021,
|
||||
title={One DAG to Rule Them All},
|
||||
author={Bolelli, Federico and Allegretti, Stefano and Grana, Costantino},
|
||||
journal={IEEE Transactions on Pattern Analysis and Machine Intelligence},
|
||||
year={2021},
|
||||
publisher={IEEE},
|
||||
doi = {10.1109/TPAMI.2021.3055337}
|
||||
}
|
||||
|
||||
@@ -78,7 +78,7 @@ if len(good)>MIN_MATCH_COUNT:
|
||||
M, mask = cv.findHomography(src_pts, dst_pts, cv.RANSAC,5.0)
|
||||
matchesMask = mask.ravel().tolist()
|
||||
|
||||
h,w,d = img1.shape
|
||||
h,w = img1.shape
|
||||
pts = np.float32([ [0,0],[0,h-1],[w-1,h-1],[w-1,0] ]).reshape(-1,1,2)
|
||||
dst = cv.perspectiveTransform(pts,M)
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ for i in range(5,0,-1):
|
||||
LS = []
|
||||
for la,lb in zip(lpA,lpB):
|
||||
rows,cols,dpt = la.shape
|
||||
ls = np.hstack((la[:,0:cols/2], lb[:,cols/2:]))
|
||||
ls = np.hstack((la[:,0:cols//2], lb[:,cols//2:]))
|
||||
LS.append(ls)
|
||||
|
||||
# now reconstruct
|
||||
@@ -127,7 +127,7 @@ for i in range(1,6):
|
||||
ls_ = cv.add(ls_, LS[i])
|
||||
|
||||
# image with direct connecting each half
|
||||
real = np.hstack((A[:,:cols/2],B[:,cols/2:]))
|
||||
real = np.hstack((A[:,:cols//2],B[:,cols//2:]))
|
||||
|
||||
cv.imwrite('Pyramid_blending2.jpg',ls_)
|
||||
cv.imwrite('Direct_blending.jpg',real)
|
||||
|
||||
@@ -95,7 +95,7 @@ QR faster than SVD, but potentially less precise
|
||||
- *camera_resolution*: resolution of camera which is used for calibration
|
||||
|
||||
**Note:** *charuco_dict*, *charuco_square_length* and *charuco_marker_size* are used for chAruco pattern generation
|
||||
(see Aruco module description for details: [Aruco tutorials](https://github.com/opencv/opencv_contrib/tree/master/modules/aruco/tutorials))
|
||||
(see Aruco module description for details: [Aruco tutorials](https://github.com/opencv/opencv_contrib/tree/3.4/modules/aruco/tutorials))
|
||||
|
||||
Default chAruco pattern:
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Explanation
|
||||
-----------
|
||||
|
||||
-# Firstly, download GoogLeNet model files:
|
||||
[bvlc_googlenet.prototxt ](https://github.com/opencv/opencv_extra/blob/master/testdata/dnn/bvlc_googlenet.prototxt) and
|
||||
[bvlc_googlenet.prototxt](https://github.com/opencv/opencv_extra/blob/3.4/testdata/dnn/bvlc_googlenet.prototxt) and
|
||||
[bvlc_googlenet.caffemodel](http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel)
|
||||
|
||||
Also you need file with names of [ILSVRC2012](http://image-net.org/challenges/LSVRC/2012/browse-synsets) classes:
|
||||
|
||||
@@ -38,7 +38,7 @@ correspondingly. In example, for variable `x` in range `[0, 10)` directive
|
||||
`split: { x: 2 }` gives new ones `xo` in range `[0, 5)` and `xi` in range `[0, 2)`.
|
||||
Variable name `x` is no longer available in the same scheduling node.
|
||||
|
||||
You can find scheduling examples at [opencv_extra/testdata/dnn](https://github.com/opencv/opencv_extra/tree/master/testdata/dnn)
|
||||
You can find scheduling examples at [opencv_extra/testdata/dnn](https://github.com/opencv/opencv_extra/tree/3.4/testdata/dnn)
|
||||
and use it for schedule your networks.
|
||||
|
||||
## Layers fusing
|
||||
|
||||
@@ -273,7 +273,7 @@ Results
|
||||
|
||||
Compile the code above and execute it (or run the script if using python) with an image as argument.
|
||||
If you do not provide an image as argument the default sample image
|
||||
([LinuxLogo.jpg](https://github.com/opencv/opencv/tree/master/samples/data/LinuxLogo.jpg)) will be used.
|
||||
([LinuxLogo.jpg](https://github.com/opencv/opencv/tree/3.4/samples/data/LinuxLogo.jpg)) will be used.
|
||||
|
||||
For instance, using this image:
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ Theory
|
||||
- To produce layer \f$(i+1)\f$ in the Gaussian pyramid, we do the following:
|
||||
- Convolve \f$G_{i}\f$ with a Gaussian kernel:
|
||||
|
||||
\f[\frac{1}{16} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\f]
|
||||
\f[\frac{1}{256} \begin{bmatrix} 1 & 4 & 6 & 4 & 1 \\ 4 & 16 & 24 & 16 & 4 \\ 6 & 24 & 36 & 24 & 6 \\ 4 & 16 & 24 & 16 & 4 \\ 1 & 4 & 6 & 4 & 1 \end{bmatrix}\f]
|
||||
|
||||
- Remove every even-numbered row and column.
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ Code
|
||||
to populate our image with a big number of geometric figures. Since we will be initializing them
|
||||
in a random fashion, this process will be automatic and made by using *loops* .
|
||||
- This code is in your OpenCV sample folder. Otherwise you can grab it from
|
||||
[here](http://code.opencv.org/projects/opencv/repository/revisions/master/raw/samples/cpp/tutorial_code/core/Matrix/Drawing_2.cpp)
|
||||
[here](https://github.com/opencv/opencv/blob/3.4/samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_2.cpp)
|
||||
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
@@ -39,14 +39,14 @@ Open your Doxyfile using your favorite text editor and search for the key
|
||||
`TAGFILES`. Change it as follows:
|
||||
|
||||
@code
|
||||
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.16
|
||||
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.17
|
||||
@endcode
|
||||
|
||||
If you had other definitions already, you can append the line using a `\`:
|
||||
|
||||
@code
|
||||
TAGFILES = ./docs/doxygen-tags/libstdc++.tag=https://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen \
|
||||
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.16
|
||||
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.17
|
||||
@endcode
|
||||
|
||||
Doxygen can now use the information from the tag file to link to the OpenCV
|
||||
|
||||
@@ -360,7 +360,7 @@ libraries). If you do not need the support for some of these, you can just freel
|
||||
Set the OpenCV environment variable and add it to the systems path {#tutorial_windows_install_path}
|
||||
=================================================================
|
||||
|
||||
First we set an environment variable to make easier our work. This will hold the build directory of
|
||||
First, we set an environment variable to make our work easier. This will hold the build directory of
|
||||
our OpenCV library that we use in our projects. Start up a command window and enter:
|
||||
@code
|
||||
setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc11 (suggested for Visual Studio 2012 - 32 bit Windows)
|
||||
|
||||
@@ -136,9 +136,9 @@ Dense Optical Flow in OpenCV
|
||||
|
||||
Lucas-Kanade method computes optical flow for a sparse feature set (in our example, corners detected
|
||||
using Shi-Tomasi algorithm). OpenCV provides another algorithm to find the dense optical flow. It
|
||||
computes the optical flow for all the points in the frame. It is based on Gunner Farneback's
|
||||
computes the optical flow for all the points in the frame. It is based on Gunnar Farneback's
|
||||
algorithm which is explained in "Two-Frame Motion Estimation Based on Polynomial Expansion" by
|
||||
Gunner Farneback in 2003.
|
||||
Gunnar Farneback in 2003.
|
||||
|
||||
Below sample shows how to find the dense optical flow using above algorithm. We get a 2-channel
|
||||
array with optical flow vectors, \f$(u,v)\f$. We find their magnitude and direction. We color code the
|
||||
|
||||
@@ -40,10 +40,11 @@
|
||||
publisher={IEEE}
|
||||
}
|
||||
|
||||
@inproceedings{Terzakis20,
|
||||
author = {Terzakis, George and Lourakis, Manolis},
|
||||
year = {2020},
|
||||
month = {09},
|
||||
pages = {},
|
||||
title = {A Consistently Fast and Globally Optimal Solution to the Perspective-n-Point Problem}
|
||||
@inproceedings{Terzakis2020SQPnP,
|
||||
title={A Consistently Fast and Globally Optimal Solution to the Perspective-n-Point Problem},
|
||||
author={George Terzakis and Manolis Lourakis},
|
||||
booktitle={European Conference on Computer Vision},
|
||||
pages={478--494},
|
||||
year={2020},
|
||||
publisher={Springer International Publishing}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,176 @@
|
||||
# Perspective-n-Point (PnP) pose computation {#calib3d_solvePnP}
|
||||
|
||||
## Pose computation overview
|
||||
|
||||
The pose computation problem @cite Marchand16 consists in solving for the rotation and translation that minimizes the reprojection error from 3D-2D point correspondences.
|
||||
|
||||
The `solvePnP` and related functions estimate the object pose given a set of object points, their corresponding image projections, as well as the camera intrinsic matrix and the distortion coefficients, see the figure below (more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward and the Z-axis forward).
|
||||
|
||||

|
||||
|
||||
Points expressed in the world frame \f$ \bf{X}_w \f$ are projected into the image plane \f$ \left[ u, v \right] \f$
|
||||
using the perspective projection model \f$ \Pi \f$ and the camera intrinsic parameters matrix \f$ \bf{A} \f$ (also denoted \f$ \bf{K} \f$ in the literature):
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\bf{A} \hspace{0.1em} \Pi \hspace{0.2em} ^{c}\bf{T}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
f_x & 0 & c_x \\
|
||||
0 & f_y & c_y \\
|
||||
0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
1 & 0 & 0 & 0 \\
|
||||
0 & 1 & 0 & 0 \\
|
||||
0 & 0 & 1 & 0
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
|
||||
The estimated pose is thus the rotation (`rvec`) and the translation (`tvec`) vectors that allow transforming
|
||||
a 3D point expressed in the world frame into the camera frame:
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\hspace{0.2em} ^{c}\bf{T}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
|
||||
## Pose computation methods
|
||||
@anchor calib3d_solvePnP_flags
|
||||
|
||||
Refer to the cv::SolvePnPMethod enum documentation for the list of possible values. Some details about each method are described below:
|
||||
|
||||
- cv::SOLVEPNP_ITERATIVE Iterative method is based on a Levenberg-Marquardt optimization. In
|
||||
this case the function finds such a pose that minimizes reprojection error, that is the sum
|
||||
of squared distances between the observed projections "imagePoints" and the projected (using
|
||||
cv::projectPoints ) "objectPoints". Initial solution for non-planar "objectPoints" needs at least 6 points and uses the DLT algorithm.
|
||||
Initial solution for planar "objectPoints" needs at least 4 points and uses pose from homography decomposition.
|
||||
- cv::SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
|
||||
"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- cv::SOLVEPNP_AP3P Method is based on the paper of T. Ke, S. Roumeliotis
|
||||
"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- cv::SOLVEPNP_EPNP Method has been introduced by F. Moreno-Noguer, V. Lepetit and P. Fua in the
|
||||
paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" (@cite lepetit2009epnp).
|
||||
- cv::SOLVEPNP_DLS **Broken implementation. Using this flag will fallback to EPnP.** \n
|
||||
Method is based on the paper of J. Hesch and S. Roumeliotis.
|
||||
"A Direct Least-Squares (DLS) Method for PnP" (@cite hesch2011direct).
|
||||
- cv::SOLVEPNP_UPNP **Broken implementation. Using this flag will fallback to EPnP.** \n
|
||||
Method is based on the paper of A. Penate-Sanchez, J. Andrade-Cetto,
|
||||
F. Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
|
||||
Estimation" (@cite penate2013exhaustive). In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
|
||||
assuming that both have the same value. Then the cameraMatrix is updated with the estimated
|
||||
focal length.
|
||||
- cv::SOLVEPNP_IPPE Method is based on the paper of T. Collins and A. Bartoli.
|
||||
"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method requires coplanar object points.
|
||||
- cv::SOLVEPNP_IPPE_SQUARE Method is based on the paper of Toby Collins and Adrien Bartoli.
|
||||
"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method is suitable for marker pose estimation.
|
||||
It requires 4 coplanar object points defined in the following order:
|
||||
- point 0: [-squareLength / 2, squareLength / 2, 0]
|
||||
- point 1: [ squareLength / 2, squareLength / 2, 0]
|
||||
- point 2: [ squareLength / 2, -squareLength / 2, 0]
|
||||
- point 3: [-squareLength / 2, -squareLength / 2, 0]
|
||||
- cv::SOLVEPNP_SQPNP Method is based on the paper "A Consistently Fast and Globally Optimal Solution to the
|
||||
Perspective-n-Point Problem" by G. Terzakis and M.Lourakis (@cite Terzakis2020SQPnP). It requires 3 or more points.
|
||||
|
||||
## P3P
|
||||
|
||||
The cv::solveP3P() computes an object pose from exactly 3 3D-2D point correspondences. A P3P problem has up to 4 solutions.
|
||||
|
||||
@note The solutions are sorted by reprojection errors (lowest to highest).
|
||||
|
||||
## PnP
|
||||
|
||||
The cv::solvePnP() returns the rotation and the translation vectors that transform a 3D point expressed in the object
|
||||
coordinate frame to the camera coordinate frame, using different methods:
|
||||
- P3P methods (cv::SOLVEPNP_P3P, cv::SOLVEPNP_AP3P): need 4 input points to return a unique solution.
|
||||
- cv::SOLVEPNP_IPPE Input points must be >= 4 and object points must be coplanar.
|
||||
- cv::SOLVEPNP_IPPE_SQUARE Special case suitable for marker pose estimation.
|
||||
Number of input points must be 4. Object points must be defined in the following order:
|
||||
- point 0: [-squareLength / 2, squareLength / 2, 0]
|
||||
- point 1: [ squareLength / 2, squareLength / 2, 0]
|
||||
- point 2: [ squareLength / 2, -squareLength / 2, 0]
|
||||
- point 3: [-squareLength / 2, -squareLength / 2, 0]
|
||||
- for all the other flags, number of input points must be >= 4 and object points can be in any configuration.
|
||||
|
||||
## Generic PnP
|
||||
|
||||
The cv::solvePnPGeneric() allows retrieving all the possible solutions.
|
||||
|
||||
Currently, only cv::SOLVEPNP_P3P, cv::SOLVEPNP_AP3P, cv::SOLVEPNP_IPPE, cv::SOLVEPNP_IPPE_SQUARE, cv::SOLVEPNP_SQPNP can return multiple solutions.
|
||||
|
||||
## RANSAC PnP
|
||||
|
||||
The cv::solvePnPRansac() computes the object pose wrt. the camera frame using a RANSAC scheme to deal with outliers.
|
||||
|
||||
More information can be found in @cite Zuliani2014RANSACFD
|
||||
|
||||
## Pose refinement
|
||||
|
||||
Pose refinement consists in estimating the rotation and translation that minimizes the reprojection error using a non-linear minimization method and starting from an initial estimate of the solution. OpenCV proposes cv::solvePnPRefineLM() and cv::solvePnPRefineVVS() for this problem.
|
||||
|
||||
cv::solvePnPRefineLM() uses a non-linear Levenberg-Marquardt minimization scheme @cite Madsen04 @cite Eade13 and the current implementation computes the rotation update as a perturbation and not on SO(3).
|
||||
|
||||
cv::solvePnPRefineVVS() uses a Gauss-Newton non-linear minimization scheme @cite Marchand16 and with an update of the rotation part computed using the exponential map.
|
||||
|
||||
@note at least three 3D-2D point correspondences are necessary.
|
||||
@@ -447,7 +447,9 @@ enum { LMEDS = 4, //!< least-median of squares algorithm
|
||||
};
|
||||
|
||||
enum SolvePnPMethod {
|
||||
SOLVEPNP_ITERATIVE = 0,
|
||||
SOLVEPNP_ITERATIVE = 0, //!< Pose refinement using non-linear Levenberg-Marquardt minimization scheme @cite Madsen04 @cite Eade13 \n
|
||||
//!< Initial solution for non-planar "objectPoints" needs at least 6 points and uses the DLT algorithm. \n
|
||||
//!< Initial solution for planar "objectPoints" needs at least 4 points and uses pose from homography decomposition.
|
||||
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, //!< **Broken implementation. Using this flag will fallback to EPnP.** \n
|
||||
@@ -464,7 +466,7 @@ enum SolvePnPMethod {
|
||||
//!< - point 1: [ squareLength / 2, squareLength / 2, 0]
|
||||
//!< - point 2: [ squareLength / 2, -squareLength / 2, 0]
|
||||
//!< - point 3: [-squareLength / 2, -squareLength / 2, 0]
|
||||
SOLVEPNP_SQPNP = 8, //!< SQPnP: A Consistently Fast and Globally OptimalSolution to the Perspective-n-Point Problem @cite Terzakis20
|
||||
SOLVEPNP_SQPNP = 8, //!< SQPnP: A Consistently Fast and Globally OptimalSolution to the Perspective-n-Point Problem @cite Terzakis2020SQPnP
|
||||
#ifndef CV_DOXYGEN
|
||||
SOLVEPNP_MAX_COUNT //!< Used for count
|
||||
#endif
|
||||
@@ -779,6 +781,9 @@ Check @ref tutorial_homography "the corresponding tutorial" for more details
|
||||
*/
|
||||
|
||||
/** @brief Finds an object pose from 3D-2D point correspondences.
|
||||
|
||||
@see @ref calib3d_solvePnP
|
||||
|
||||
This function returns the rotation and the translation vectors that transform a 3D point expressed in the object
|
||||
coordinate frame to the camera coordinate frame, using different methods:
|
||||
- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): need 4 input points to return a unique solution.
|
||||
@@ -805,133 +810,9 @@ the model coordinate system to the camera coordinate system.
|
||||
@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
|
||||
the provided rvec and tvec values as initial approximations of the rotation and translation
|
||||
vectors, respectively, and further optimizes them.
|
||||
@param flags Method for solving a PnP problem:
|
||||
- @ref SOLVEPNP_ITERATIVE Iterative method is based on a Levenberg-Marquardt optimization. In
|
||||
this case the function finds such a pose that minimizes reprojection error, that is the sum
|
||||
of squared distances between the observed projections imagePoints and the projected (using
|
||||
@ref projectPoints ) objectPoints .
|
||||
- @ref SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
|
||||
"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- @ref SOLVEPNP_AP3P Method is based on the paper of T. Ke, S. Roumeliotis
|
||||
"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- @ref SOLVEPNP_EPNP Method has been introduced by F. Moreno-Noguer, V. Lepetit and P. Fua in the
|
||||
paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" (@cite lepetit2009epnp).
|
||||
- @ref SOLVEPNP_DLS **Broken implementation. Using this flag will fallback to EPnP.** \n
|
||||
Method is based on the paper of J. Hesch and S. Roumeliotis.
|
||||
"A Direct Least-Squares (DLS) Method for PnP" (@cite hesch2011direct).
|
||||
- @ref SOLVEPNP_UPNP **Broken implementation. Using this flag will fallback to EPnP.** \n
|
||||
Method is based on the paper of A. Penate-Sanchez, J. Andrade-Cetto,
|
||||
F. Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
|
||||
Estimation" (@cite penate2013exhaustive). In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
|
||||
assuming that both have the same value. Then the cameraMatrix is updated with the estimated
|
||||
focal length.
|
||||
- @ref SOLVEPNP_IPPE Method is based on the paper of T. Collins and A. Bartoli.
|
||||
"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method requires coplanar object points.
|
||||
- @ref SOLVEPNP_IPPE_SQUARE Method is based on the paper of Toby Collins and Adrien Bartoli.
|
||||
"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method is suitable for marker pose estimation.
|
||||
It requires 4 coplanar object points defined in the following order:
|
||||
- point 0: [-squareLength / 2, squareLength / 2, 0]
|
||||
- point 1: [ squareLength / 2, squareLength / 2, 0]
|
||||
- point 2: [ squareLength / 2, -squareLength / 2, 0]
|
||||
- point 3: [-squareLength / 2, -squareLength / 2, 0]
|
||||
- @ref SOLVEPNP_SQPNP Method is based on the paper "A Consistently Fast and Globally Optimal Solution to the
|
||||
Perspective-n-Point Problem" by G. Terzakis and M.Lourakis (@cite Terzakis20). It requires 3 or more points.
|
||||
@param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags
|
||||
|
||||
|
||||
The function estimates the object pose given a set of object points, their corresponding image
|
||||
projections, as well as the camera intrinsic matrix and the distortion coefficients, see the figure below
|
||||
(more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward
|
||||
and the Z-axis forward).
|
||||
|
||||

|
||||
|
||||
Points expressed in the world frame \f$ \bf{X}_w \f$ are projected into the image plane \f$ \left[ u, v \right] \f$
|
||||
using the perspective projection model \f$ \Pi \f$ and the camera intrinsic parameters matrix \f$ \bf{A} \f$:
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\bf{A} \hspace{0.1em} \Pi \hspace{0.2em} ^{c}\bf{T}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
f_x & 0 & c_x \\
|
||||
0 & f_y & c_y \\
|
||||
0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
1 & 0 & 0 & 0 \\
|
||||
0 & 1 & 0 & 0 \\
|
||||
0 & 0 & 1 & 0
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
|
||||
The estimated pose is thus the rotation (`rvec`) and the translation (`tvec`) vectors that allow transforming
|
||||
a 3D point expressed in the world frame into the camera frame:
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\hspace{0.2em} ^{c}\bf{T}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
More information about Perspective-n-Points is described in @ref calib3d_solvePnP
|
||||
|
||||
@note
|
||||
- An example of how to use solvePnP for planar augmented reality can be found at
|
||||
@@ -971,6 +852,8 @@ CV_EXPORTS_W bool solvePnP( InputArray objectPoints, InputArray imagePoints,
|
||||
|
||||
/** @brief Finds an object pose from 3D-2D point correspondences using the RANSAC scheme.
|
||||
|
||||
@see @ref calib3d_solvePnP
|
||||
|
||||
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or
|
||||
1xN/Nx1 3-channel, where N is the number of points. vector\<Point3d\> can be also passed here.
|
||||
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
|
||||
@@ -1019,6 +902,8 @@ CV_EXPORTS_W bool solvePnPRansac( InputArray objectPoints, InputArray imagePoint
|
||||
|
||||
/** @brief Finds an object pose from 3 3D-2D point correspondences.
|
||||
|
||||
@see @ref calib3d_solvePnP
|
||||
|
||||
@param objectPoints Array of object points in the object coordinate space, 3x3 1-channel or
|
||||
1x3/3x1 3-channel. vector\<Point3f\> can be also passed here.
|
||||
@param imagePoints Array of corresponding image points, 3x2 1-channel or 1x3/3x1 2-channel.
|
||||
@@ -1050,6 +935,8 @@ CV_EXPORTS_W int solveP3P( InputArray objectPoints, InputArray imagePoints,
|
||||
/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
|
||||
to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
|
||||
|
||||
@see @ref calib3d_solvePnP
|
||||
|
||||
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
|
||||
where N is the number of points. vector\<Point3d\> can also be passed here.
|
||||
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
|
||||
@@ -1077,6 +964,8 @@ CV_EXPORTS_W void solvePnPRefineLM( InputArray objectPoints, InputArray imagePoi
|
||||
/** @brief Refine a pose (the translation and the rotation that transform a 3D point expressed in the object coordinate frame
|
||||
to the camera coordinate frame) from a 3D-2D point correspondences and starting from an initial solution.
|
||||
|
||||
@see @ref calib3d_solvePnP
|
||||
|
||||
@param objectPoints Array of object points in the object coordinate space, Nx3 1-channel or 1xN/Nx1 3-channel,
|
||||
where N is the number of points. vector\<Point3d\> can also be passed here.
|
||||
@param imagePoints Array of corresponding image points, Nx2 1-channel or 1xN/Nx1 2-channel,
|
||||
@@ -1105,6 +994,9 @@ CV_EXPORTS_W void solvePnPRefineVVS( InputArray objectPoints, InputArray imagePo
|
||||
double VVSlambda = 1);
|
||||
|
||||
/** @brief Finds an object pose from 3D-2D point correspondences.
|
||||
|
||||
@see @ref calib3d_solvePnP
|
||||
|
||||
This function returns a list of all the possible solutions (a solution is a <rotation vector, translation vector>
|
||||
couple), depending on the number of input points and the chosen method:
|
||||
- P3P methods (@ref SOLVEPNP_P3P, @ref SOLVEPNP_AP3P): 3 or 4 input points. Number of returned solutions can be between 0 and 4 with 3 input points.
|
||||
@@ -1132,37 +1024,7 @@ the model coordinate system to the camera coordinate system.
|
||||
@param useExtrinsicGuess Parameter used for #SOLVEPNP_ITERATIVE. If true (1), the function uses
|
||||
the provided rvec and tvec values as initial approximations of the rotation and translation
|
||||
vectors, respectively, and further optimizes them.
|
||||
@param flags Method for solving a PnP problem:
|
||||
- @ref SOLVEPNP_ITERATIVE Iterative method is based on a Levenberg-Marquardt optimization. In
|
||||
this case the function finds such a pose that minimizes reprojection error, that is the sum
|
||||
of squared distances between the observed projections imagePoints and the projected (using
|
||||
projectPoints ) objectPoints .
|
||||
- @ref SOLVEPNP_P3P Method is based on the paper of X.S. Gao, X.-R. Hou, J. Tang, H.-F. Chang
|
||||
"Complete Solution Classification for the Perspective-Three-Point Problem" (@cite gao2003complete).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- @ref SOLVEPNP_AP3P Method is based on the paper of T. Ke, S. Roumeliotis
|
||||
"An Efficient Algebraic Solution to the Perspective-Three-Point Problem" (@cite Ke17).
|
||||
In this case the function requires exactly four object and image points.
|
||||
- @ref SOLVEPNP_EPNP Method has been introduced by F.Moreno-Noguer, V.Lepetit and P.Fua in the
|
||||
paper "EPnP: Efficient Perspective-n-Point Camera Pose Estimation" (@cite lepetit2009epnp).
|
||||
- @ref SOLVEPNP_DLS **Broken implementation. Using this flag will fallback to EPnP.** \n
|
||||
Method is based on the paper of Joel A. Hesch and Stergios I. Roumeliotis.
|
||||
"A Direct Least-Squares (DLS) Method for PnP" (@cite hesch2011direct).
|
||||
- @ref SOLVEPNP_UPNP **Broken implementation. Using this flag will fallback to EPnP.** \n
|
||||
Method is based on the paper of A.Penate-Sanchez, J.Andrade-Cetto,
|
||||
F.Moreno-Noguer. "Exhaustive Linearization for Robust Camera Pose and Focal Length
|
||||
Estimation" (@cite penate2013exhaustive). In this case the function also estimates the parameters \f$f_x\f$ and \f$f_y\f$
|
||||
assuming that both have the same value. Then the cameraMatrix is updated with the estimated
|
||||
focal length.
|
||||
- @ref SOLVEPNP_IPPE Method is based on the paper of T. Collins and A. Bartoli.
|
||||
"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method requires coplanar object points.
|
||||
- @ref SOLVEPNP_IPPE_SQUARE Method is based on the paper of Toby Collins and Adrien Bartoli.
|
||||
"Infinitesimal Plane-Based Pose Estimation" (@cite Collins14). This method is suitable for marker pose estimation.
|
||||
It requires 4 coplanar object points defined in the following order:
|
||||
- point 0: [-squareLength / 2, squareLength / 2, 0]
|
||||
- point 1: [ squareLength / 2, squareLength / 2, 0]
|
||||
- point 2: [ squareLength / 2, -squareLength / 2, 0]
|
||||
- point 3: [-squareLength / 2, -squareLength / 2, 0]
|
||||
@param flags Method for solving a PnP problem: see @ref calib3d_solvePnP_flags
|
||||
@param rvec Rotation vector used to initialize an iterative PnP refinement algorithm, when flag is @ref SOLVEPNP_ITERATIVE
|
||||
and useExtrinsicGuess is set to true.
|
||||
@param tvec Translation vector used to initialize an iterative PnP refinement algorithm, when flag is @ref SOLVEPNP_ITERATIVE
|
||||
@@ -1171,98 +1033,7 @@ and useExtrinsicGuess is set to true.
|
||||
(\f$ \text{RMSE} = \sqrt{\frac{\sum_{i}^{N} \left ( \hat{y_i} - y_i \right )^2}{N}} \f$) between the input image points
|
||||
and the 3D object points projected with the estimated pose.
|
||||
|
||||
The function estimates the object pose given a set of object points, their corresponding image
|
||||
projections, as well as the camera intrinsic matrix and the distortion coefficients, see the figure below
|
||||
(more precisely, the X-axis of the camera frame is pointing to the right, the Y-axis downward
|
||||
and the Z-axis forward).
|
||||
|
||||

|
||||
|
||||
Points expressed in the world frame \f$ \bf{X}_w \f$ are projected into the image plane \f$ \left[ u, v \right] \f$
|
||||
using the perspective projection model \f$ \Pi \f$ and the camera intrinsic parameters matrix \f$ \bf{A} \f$:
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\bf{A} \hspace{0.1em} \Pi \hspace{0.2em} ^{c}\bf{T}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
u \\
|
||||
v \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
f_x & 0 & c_x \\
|
||||
0 & f_y & c_y \\
|
||||
0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
1 & 0 & 0 & 0 \\
|
||||
0 & 1 & 0 & 0 \\
|
||||
0 & 0 & 1 & 0
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
|
||||
The estimated pose is thus the rotation (`rvec`) and the translation (`tvec`) vectors that allow transforming
|
||||
a 3D point expressed in the world frame into the camera frame:
|
||||
|
||||
\f[
|
||||
\begin{align*}
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\hspace{0.2em} ^{c}\bf{T}_w
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix} \\
|
||||
\begin{bmatrix}
|
||||
X_c \\
|
||||
Y_c \\
|
||||
Z_c \\
|
||||
1
|
||||
\end{bmatrix} &=
|
||||
\begin{bmatrix}
|
||||
r_{11} & r_{12} & r_{13} & t_x \\
|
||||
r_{21} & r_{22} & r_{23} & t_y \\
|
||||
r_{31} & r_{32} & r_{33} & t_z \\
|
||||
0 & 0 & 0 & 1
|
||||
\end{bmatrix}
|
||||
\begin{bmatrix}
|
||||
X_{w} \\
|
||||
Y_{w} \\
|
||||
Z_{w} \\
|
||||
1
|
||||
\end{bmatrix}
|
||||
\end{align*}
|
||||
\f]
|
||||
More information is described in @ref calib3d_solvePnP
|
||||
|
||||
@note
|
||||
- An example of how to use solvePnP for planar augmented reality can be found at
|
||||
|
||||
@@ -1737,7 +1737,7 @@ void cvCalibrationMatrixValues( const CvMat *calibMatr, CvSize imgSize,
|
||||
CV_Error(CV_StsNullPtr, "Some of parameters is a NULL pointer!");
|
||||
|
||||
if(!CV_IS_MAT(calibMatr))
|
||||
CV_Error(CV_StsUnsupportedFormat, "Input parameters must be a matrices!");
|
||||
CV_Error(CV_StsUnsupportedFormat, "Input parameters must be matrices!");
|
||||
|
||||
double dummy = .0;
|
||||
Point2d pp;
|
||||
@@ -2125,7 +2125,7 @@ static double cvStereoCalibrateImpl( const CvMat* _objectPoints, const CvMat* _i
|
||||
if( solver.state == CvLevMarq::CALC_J )
|
||||
{
|
||||
int iofs = (nimages+1)*6 + k*NINTRINSIC, eofs = (i+1)*6;
|
||||
assert( JtJ && JtErr );
|
||||
CV_Assert( JtJ && JtErr );
|
||||
|
||||
Mat _JtJ(cvarrToMat(JtJ)), _JtErr(cvarrToMat(JtErr));
|
||||
|
||||
@@ -2929,7 +2929,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
|
||||
CvMat Qx = cvMat(3, 3, CV_64F, _Qx);
|
||||
|
||||
cvMatMul(&M, &Qx, &R);
|
||||
assert(fabs(matR[2][1]) < FLT_EPSILON);
|
||||
CV_DbgAssert(fabs(matR[2][1]) < FLT_EPSILON);
|
||||
matR[2][1] = 0;
|
||||
|
||||
/* Find Givens rotation for y axis. */
|
||||
@@ -2948,7 +2948,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
|
||||
CvMat Qy = cvMat(3, 3, CV_64F, _Qy);
|
||||
cvMatMul(&R, &Qy, &M);
|
||||
|
||||
assert(fabs(matM[2][0]) < FLT_EPSILON);
|
||||
CV_DbgAssert(fabs(matM[2][0]) < FLT_EPSILON);
|
||||
matM[2][0] = 0;
|
||||
|
||||
/* Find Givens rotation for z axis. */
|
||||
@@ -2968,7 +2968,7 @@ cvRQDecomp3x3( const CvMat *matrixM, CvMat *matrixR, CvMat *matrixQ,
|
||||
CvMat Qz = cvMat(3, 3, CV_64F, _Qz);
|
||||
|
||||
cvMatMul(&M, &Qz, &R);
|
||||
assert(fabs(matR[1][0]) < FLT_EPSILON);
|
||||
CV_DbgAssert(fabs(matR[1][0]) < FLT_EPSILON);
|
||||
matR[1][0] = 0;
|
||||
|
||||
// Solve the decomposition ambiguity.
|
||||
@@ -3078,7 +3078,7 @@ cvDecomposeProjectionMatrix( const CvMat *projMatr, CvMat *calibMatr,
|
||||
CV_Error(CV_StsNullPtr, "Some of parameters is a NULL pointer!");
|
||||
|
||||
if(!CV_IS_MAT(projMatr) || !CV_IS_MAT(calibMatr) || !CV_IS_MAT(rotMatr) || !CV_IS_MAT(posVect))
|
||||
CV_Error(CV_StsUnsupportedFormat, "Input parameters must be a matrices!");
|
||||
CV_Error(CV_StsUnsupportedFormat, "Input parameters must be matrices!");
|
||||
|
||||
if(projMatr->cols != 4 || projMatr->rows != 3)
|
||||
CV_Error(CV_StsUnmatchedSizes, "Size of projection matrix must be 3x4!");
|
||||
|
||||
@@ -121,7 +121,7 @@ bool CvLevMarq::update( const CvMat*& _param, CvMat*& matJ, CvMat*& _err )
|
||||
{
|
||||
matJ = _err = 0;
|
||||
|
||||
assert( !err.empty() );
|
||||
CV_Assert( !err.empty() );
|
||||
if( state == DONE )
|
||||
{
|
||||
_param = param;
|
||||
@@ -154,7 +154,7 @@ bool CvLevMarq::update( const CvMat*& _param, CvMat*& matJ, CvMat*& _err )
|
||||
return true;
|
||||
}
|
||||
|
||||
assert( state == CHECK_ERR );
|
||||
CV_Assert( state == CHECK_ERR );
|
||||
errNorm = cvNorm( err, 0, CV_L2 );
|
||||
if( errNorm > prevErrNorm )
|
||||
{
|
||||
@@ -222,7 +222,7 @@ bool CvLevMarq::updateAlt( const CvMat*& _param, CvMat*& _JtJ, CvMat*& _JtErr, d
|
||||
return true;
|
||||
}
|
||||
|
||||
assert( state == CHECK_ERR );
|
||||
CV_Assert( state == CHECK_ERR );
|
||||
if( errNorm > prevErrNorm )
|
||||
{
|
||||
if( ++lambdaLg10 <= 16 )
|
||||
|
||||
@@ -831,30 +831,30 @@ void CV_CameraCalibrationTest_CPP::calibrate(int imageCount, int* pointCounts,
|
||||
perViewErrorsMat,
|
||||
flags );
|
||||
|
||||
assert( stdDevsMatInt.type() == CV_64F );
|
||||
assert( stdDevsMatInt.total() == static_cast<size_t>(CV_CALIB_NINTRINSIC) );
|
||||
CV_Assert( stdDevsMatInt.type() == CV_64F );
|
||||
CV_Assert( stdDevsMatInt.total() == static_cast<size_t>(CV_CALIB_NINTRINSIC) );
|
||||
memcpy( stdDevs, stdDevsMatInt.ptr(), CV_CALIB_NINTRINSIC*sizeof(double) );
|
||||
|
||||
assert( stdDevsMatExt.type() == CV_64F );
|
||||
assert( stdDevsMatExt.total() == static_cast<size_t>(6*imageCount) );
|
||||
CV_Assert( stdDevsMatExt.type() == CV_64F );
|
||||
CV_Assert( stdDevsMatExt.total() == static_cast<size_t>(6*imageCount) );
|
||||
memcpy( stdDevs + CV_CALIB_NINTRINSIC, stdDevsMatExt.ptr(), 6*imageCount*sizeof(double) );
|
||||
|
||||
assert( perViewErrorsMat.type() == CV_64F);
|
||||
assert( perViewErrorsMat.total() == static_cast<size_t>(imageCount) );
|
||||
CV_Assert( perViewErrorsMat.type() == CV_64F);
|
||||
CV_Assert( perViewErrorsMat.total() == static_cast<size_t>(imageCount) );
|
||||
memcpy( perViewErrors, perViewErrorsMat.ptr(), imageCount*sizeof(double) );
|
||||
|
||||
assert( cameraMatrix.type() == CV_64FC1 );
|
||||
CV_Assert( cameraMatrix.type() == CV_64FC1 );
|
||||
memcpy( _cameraMatrix, cameraMatrix.ptr(), 9*sizeof(double) );
|
||||
|
||||
assert( cameraMatrix.type() == CV_64FC1 );
|
||||
CV_Assert( cameraMatrix.type() == CV_64FC1 );
|
||||
memcpy( _distortionCoeffs, distCoeffs.ptr(), 4*sizeof(double) );
|
||||
|
||||
vector<Mat>::iterator rvecsIt = rvecs.begin();
|
||||
vector<Mat>::iterator tvecsIt = tvecs.begin();
|
||||
double *rm = rotationMatrices,
|
||||
*tm = translationVectors;
|
||||
assert( rvecsIt->type() == CV_64FC1 );
|
||||
assert( tvecsIt->type() == CV_64FC1 );
|
||||
CV_Assert( rvecsIt->type() == CV_64FC1 );
|
||||
CV_Assert( tvecsIt->type() == CV_64FC1 );
|
||||
for( int i = 0; i < imageCount; ++rvecsIt, ++tvecsIt, i++, rm+=9, tm+=3 )
|
||||
{
|
||||
Mat r9( 3, 3, CV_64FC1 );
|
||||
@@ -1141,7 +1141,7 @@ void CV_ProjectPointsTest::run(int)
|
||||
imgPoints, dpdrot, dpdt, dpdf, dpdc, dpddist, 0 );
|
||||
|
||||
// calculate and check image points
|
||||
assert( (int)imgPoints.size() == pointCount );
|
||||
CV_Assert( (int)imgPoints.size() == pointCount );
|
||||
vector<Point2f>::const_iterator it = imgPoints.begin();
|
||||
for( int i = 0; i < pointCount; i++, ++it )
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ static int cvTsRodrigues( const CvMat* src, CvMat* dst, CvMat* jacobian )
|
||||
|
||||
if( jacobian )
|
||||
{
|
||||
assert( (jacobian->rows == 9 && jacobian->cols == 3) ||
|
||||
CV_Assert( (jacobian->rows == 9 && jacobian->cols == 3) ||
|
||||
(jacobian->rows == 3 && jacobian->cols == 9) );
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ static int cvTsRodrigues( const CvMat* src, CvMat* dst, CvMat* jacobian )
|
||||
double r[3], theta;
|
||||
CvMat _r = cvMat( src->rows, src->cols, CV_MAKETYPE(CV_64F,CV_MAT_CN(src->type)), r);
|
||||
|
||||
assert( dst->rows == 3 && dst->cols == 3 );
|
||||
CV_Assert( dst->rows == 3 && dst->cols == 3 );
|
||||
|
||||
cvConvert( src, &_r );
|
||||
|
||||
@@ -320,7 +320,7 @@ static int cvTsRodrigues( const CvMat* src, CvMat* dst, CvMat* jacobian )
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -404,7 +404,7 @@ static void test_convertHomogeneous( const Mat& _src, Mat& _dst )
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( count == dst.cols );
|
||||
CV_Assert( count == dst.cols );
|
||||
ddims = dst.channels()*dst.rows;
|
||||
if( dst.rows == 1 )
|
||||
{
|
||||
|
||||
@@ -406,7 +406,7 @@ void CV_StereoMatchingTest::run(int)
|
||||
{
|
||||
string dataPath = ts->get_data_path() + "cv/";
|
||||
string algorithmName = name;
|
||||
assert( !algorithmName.empty() );
|
||||
CV_Assert( !algorithmName.empty() );
|
||||
if( dataPath.empty() )
|
||||
{
|
||||
ts->printf( cvtest::TS::LOG, "dataPath is empty" );
|
||||
@@ -553,22 +553,22 @@ int CV_StereoMatchingTest::processStereoMatchingResults( FileStorage& fs, int ca
|
||||
{
|
||||
// rightDisp is not used in current test virsion
|
||||
int code = cvtest::TS::OK;
|
||||
assert( fs.isOpened() );
|
||||
assert( trueLeftDisp.type() == CV_32FC1 );
|
||||
assert( trueRightDisp.empty() || trueRightDisp.type() == CV_32FC1 );
|
||||
assert( leftDisp.type() == CV_32FC1 && (rightDisp.empty() || rightDisp.type() == CV_32FC1) );
|
||||
CV_Assert( fs.isOpened() );
|
||||
CV_Assert( trueLeftDisp.type() == CV_32FC1 );
|
||||
CV_Assert( trueRightDisp.empty() || trueRightDisp.type() == CV_32FC1 );
|
||||
CV_Assert( leftDisp.type() == CV_32FC1 && (rightDisp.empty() || rightDisp.type() == CV_32FC1) );
|
||||
|
||||
// get masks for unknown ground truth disparity values
|
||||
Mat leftUnknMask, rightUnknMask;
|
||||
DatasetParams params = datasetsParams[caseDatasets[caseIdx]];
|
||||
absdiff( trueLeftDisp, Scalar(params.dispUnknVal), leftUnknMask );
|
||||
leftUnknMask = leftUnknMask < std::numeric_limits<float>::epsilon();
|
||||
assert(leftUnknMask.type() == CV_8UC1);
|
||||
CV_Assert(leftUnknMask.type() == CV_8UC1);
|
||||
if( !trueRightDisp.empty() )
|
||||
{
|
||||
absdiff( trueRightDisp, Scalar(params.dispUnknVal), rightUnknMask );
|
||||
rightUnknMask = rightUnknMask < std::numeric_limits<float>::epsilon();
|
||||
assert(rightUnknMask.type() == CV_8UC1);
|
||||
CV_Assert(rightUnknMask.type() == CV_8UC1);
|
||||
}
|
||||
|
||||
// calculate errors
|
||||
@@ -623,7 +623,7 @@ int CV_StereoMatchingTest::readDatasetsParams( FileStorage& fs )
|
||||
}
|
||||
datasetsParams.clear();
|
||||
FileNode fn = fs.getFirstTopLevelNode();
|
||||
assert(fn.isSeq());
|
||||
CV_Assert(fn.isSeq());
|
||||
for( int i = 0; i < (int)fn.size(); i+=3 )
|
||||
{
|
||||
String _name = fn[i];
|
||||
@@ -649,7 +649,7 @@ int CV_StereoMatchingTest::readRunParams( FileStorage& fs )
|
||||
|
||||
void CV_StereoMatchingTest::writeErrors( const string& errName, const vector<float>& errors, FileStorage* fs )
|
||||
{
|
||||
assert( (int)errors.size() == ERROR_KINDS_COUNT );
|
||||
CV_Assert( (int)errors.size() == ERROR_KINDS_COUNT );
|
||||
vector<float>::const_iterator it = errors.begin();
|
||||
if( fs )
|
||||
for( int i = 0; i < ERROR_KINDS_COUNT; i++, ++it )
|
||||
@@ -696,9 +696,9 @@ void CV_StereoMatchingTest::readROI( FileNode& fn, Rect& validROI )
|
||||
int CV_StereoMatchingTest::compareErrors( const vector<float>& calcErrors, const vector<float>& validErrors,
|
||||
const vector<float>& eps, const string& errName )
|
||||
{
|
||||
assert( (int)calcErrors.size() == ERROR_KINDS_COUNT );
|
||||
assert( (int)validErrors.size() == ERROR_KINDS_COUNT );
|
||||
assert( (int)eps.size() == ERROR_KINDS_COUNT );
|
||||
CV_Assert( (int)calcErrors.size() == ERROR_KINDS_COUNT );
|
||||
CV_Assert( (int)validErrors.size() == ERROR_KINDS_COUNT );
|
||||
CV_Assert( (int)eps.size() == ERROR_KINDS_COUNT );
|
||||
vector<float>::const_iterator calcIt = calcErrors.begin(),
|
||||
validIt = validErrors.begin(),
|
||||
epsIt = eps.begin();
|
||||
@@ -757,7 +757,7 @@ protected:
|
||||
{
|
||||
int code = CV_StereoMatchingTest::readRunParams( fs );
|
||||
FileNode fn = fs.getFirstTopLevelNode();
|
||||
assert(fn.isSeq());
|
||||
CV_Assert(fn.isSeq());
|
||||
for( int i = 0; i < (int)fn.size(); i+=5 )
|
||||
{
|
||||
String caseName = fn[i], datasetName = fn[i+1];
|
||||
@@ -776,8 +776,8 @@ protected:
|
||||
Rect& calcROI, Mat& leftDisp, Mat& /*rightDisp*/, int caseIdx )
|
||||
{
|
||||
RunParams params = caseRunParams[caseIdx];
|
||||
assert( params.ndisp%16 == 0 );
|
||||
assert( _leftImg.type() == CV_8UC3 && _rightImg.type() == CV_8UC3 );
|
||||
CV_Assert( params.ndisp%16 == 0 );
|
||||
CV_Assert( _leftImg.type() == CV_8UC3 && _rightImg.type() == CV_8UC3 );
|
||||
Mat leftImg; cvtColor( _leftImg, leftImg, COLOR_BGR2GRAY );
|
||||
Mat rightImg; cvtColor( _rightImg, rightImg, COLOR_BGR2GRAY );
|
||||
|
||||
@@ -883,7 +883,7 @@ protected:
|
||||
{
|
||||
int code = CV_StereoMatchingTest::readRunParams(fs);
|
||||
FileNode fn = fs.getFirstTopLevelNode();
|
||||
assert(fn.isSeq());
|
||||
CV_Assert(fn.isSeq());
|
||||
for( int i = 0; i < (int)fn.size(); i+=5 )
|
||||
{
|
||||
String caseName = fn[i], datasetName = fn[i+1];
|
||||
@@ -902,7 +902,7 @@ protected:
|
||||
Rect& calcROI, Mat& leftDisp, Mat& /*rightDisp*/, int caseIdx )
|
||||
{
|
||||
RunParams params = caseRunParams[caseIdx];
|
||||
assert( params.ndisp%16 == 0 );
|
||||
CV_Assert( params.ndisp%16 == 0 );
|
||||
Ptr<StereoSGBM> sgbm = StereoSGBM::create( 0, params.ndisp, params.winSize,
|
||||
10*params.winSize*params.winSize,
|
||||
40*params.winSize*params.winSize,
|
||||
|
||||
@@ -107,6 +107,7 @@ ocv_create_module(${extra_libs})
|
||||
|
||||
ocv_target_link_libraries(${the_module} PRIVATE
|
||||
"${ZLIB_LIBRARIES}" "${OPENCL_LIBRARIES}" "${VA_LIBRARIES}"
|
||||
"${OPENGL_LIBRARIES}"
|
||||
"${LAPACK_LIBRARIES}" "${CPUFEATURES_LIBRARIES}" "${HALIDE_LIBRARIES}"
|
||||
"${ITT_LIBRARIES}"
|
||||
"${OPENCV_HAL_LINKER_LIBS}"
|
||||
|
||||
@@ -297,7 +297,10 @@ It is possible to alternate error processing by using redirectError().
|
||||
*/
|
||||
CV_EXPORTS void error(int _code, const String& _err, const char* _func, const char* _file, int _line);
|
||||
|
||||
#ifdef __GNUC__
|
||||
#if defined(__clang__) && defined(_MSC_VER) // MSVC-Clang
|
||||
# pragma clang diagnostic push
|
||||
# pragma clang diagnostic ignored "-Winvalid-noreturn"
|
||||
#elif defined(__GNUC__)
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Winvalid-noreturn"
|
||||
@@ -316,7 +319,10 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
|
||||
# endif
|
||||
#endif
|
||||
}
|
||||
#ifdef __GNUC__
|
||||
|
||||
#if defined(__clang__) && defined(_MSC_VER) // MSVC-Clang
|
||||
# pragma clang diagnostic pop
|
||||
#elif defined(__GNUC__)
|
||||
# if defined __clang__ || defined __APPLE__
|
||||
# pragma GCC diagnostic pop
|
||||
# endif
|
||||
|
||||
@@ -103,6 +103,21 @@ String dumpRotatedRect(const RotatedRect& argument)
|
||||
argument.size.height, argument.angle);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
RotatedRect testRotatedRect(float x, float y, float w, float h, float angle)
|
||||
{
|
||||
return RotatedRect(Point2f(x, y), Size2f(w, h), angle);
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
std::vector<RotatedRect> testRotatedRectVector(float x, float y, float w, float h, float angle)
|
||||
{
|
||||
std::vector<RotatedRect> result;
|
||||
for (int i = 0; i < 10; i++)
|
||||
result.push_back(RotatedRect(Point2f(x + i, y + 2 * i), Size2f(w, h), angle + 10 * i));
|
||||
return result;
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String dumpRange(const Range& argument)
|
||||
{
|
||||
|
||||
@@ -55,7 +55,7 @@
|
||||
# ifdef _MSC_VER
|
||||
# include <nmmintrin.h>
|
||||
# if defined(_M_X64)
|
||||
# define CV_POPCNT_U64 _mm_popcnt_u64
|
||||
# define CV_POPCNT_U64 (int)_mm_popcnt_u64
|
||||
# endif
|
||||
# define CV_POPCNT_U32 _mm_popcnt_u32
|
||||
# else
|
||||
|
||||
@@ -589,6 +589,8 @@ Cv64suf;
|
||||
# elif __cplusplus >= 201703L
|
||||
// available when compiler is C++17 compliant
|
||||
# define CV_NODISCARD_STD [[nodiscard]]
|
||||
# elif defined(__INTEL_COMPILER)
|
||||
// see above, available when C++17 is enabled
|
||||
# elif defined(_MSC_VER) && _MSC_VER >= 1911 && _MSVC_LANG >= 201703L
|
||||
// available with VS2017 v15.3+ with /std:c++17 or higher; works on functions and classes
|
||||
# define CV_NODISCARD_STD [[nodiscard]]
|
||||
|
||||
@@ -1390,11 +1390,21 @@ OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_int16x16)
|
||||
////////// Other math /////////
|
||||
|
||||
/** Some frequent operations **/
|
||||
#if CV_FMA3
|
||||
#define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \
|
||||
inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } \
|
||||
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); } \
|
||||
{ return _Tpvec(_mm256_fmadd_##suffix(a.val, b.val, c.val)); }
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_AVX_MULADD(_Tpvec, suffix) \
|
||||
inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); } \
|
||||
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm256_add_##suffix(_mm256_mul_##suffix(a.val, b.val), c.val)); }
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_AVX_MISC(_Tpvec, suffix) \
|
||||
inline _Tpvec v_sqrt(const _Tpvec& x) \
|
||||
{ return _Tpvec(_mm256_sqrt_##suffix(x.val)); } \
|
||||
inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
@@ -1404,6 +1414,8 @@ OPENCV_HAL_IMPL_AVX_CHECK_SHORT(v_int16x16)
|
||||
|
||||
OPENCV_HAL_IMPL_AVX_MULADD(v_float32x8, ps)
|
||||
OPENCV_HAL_IMPL_AVX_MULADD(v_float64x4, pd)
|
||||
OPENCV_HAL_IMPL_AVX_MISC(v_float32x8, ps)
|
||||
OPENCV_HAL_IMPL_AVX_MISC(v_float64x4, pd)
|
||||
|
||||
inline v_int32x8 v_fma(const v_int32x8& a, const v_int32x8& b, const v_int32x8& c)
|
||||
{
|
||||
@@ -2379,7 +2391,7 @@ inline void v_load_deinterleave( const unsigned* ptr, v_uint32x8& a, v_uint32x8&
|
||||
__m256i ab0 = _mm256_loadu_si256((const __m256i*)ptr);
|
||||
__m256i ab1 = _mm256_loadu_si256((const __m256i*)(ptr + 8));
|
||||
|
||||
const int sh = 0+2*4+1*16+3*64;
|
||||
enum { sh = 0+2*4+1*16+3*64 };
|
||||
__m256i p0 = _mm256_shuffle_epi32(ab0, sh);
|
||||
__m256i p1 = _mm256_shuffle_epi32(ab1, sh);
|
||||
__m256i pl = _mm256_permute2x128_si256(p0, p1, 0 + 2*16);
|
||||
|
||||
@@ -1385,11 +1385,21 @@ inline v_uint64x8 v_popcount(const v_uint64x8& a) { return v_popcount(v_reinte
|
||||
////////// Other math /////////
|
||||
|
||||
/** Some frequent operations **/
|
||||
#if CV_FMA3
|
||||
#define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \
|
||||
inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } \
|
||||
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); } \
|
||||
{ return _Tpvec(_mm512_fmadd_##suffix(a.val, b.val, c.val)); }
|
||||
#else
|
||||
#define OPENCV_HAL_IMPL_AVX512_MULADD(_Tpvec, suffix) \
|
||||
inline _Tpvec v_fma(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); } \
|
||||
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(_mm512_add_##suffix(_mm512_mul_##suffix(a.val, b.val), c.val)); }
|
||||
#endif
|
||||
|
||||
#define OPENCV_HAL_IMPL_AVX512_MISC(_Tpvec, suffix) \
|
||||
inline _Tpvec v_sqrt(const _Tpvec& x) \
|
||||
{ return _Tpvec(_mm512_sqrt_##suffix(x.val)); } \
|
||||
inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
@@ -1399,6 +1409,8 @@ inline v_uint64x8 v_popcount(const v_uint64x8& a) { return v_popcount(v_reinte
|
||||
|
||||
OPENCV_HAL_IMPL_AVX512_MULADD(v_float32x16, ps)
|
||||
OPENCV_HAL_IMPL_AVX512_MULADD(v_float64x8, pd)
|
||||
OPENCV_HAL_IMPL_AVX512_MISC(v_float32x16, ps)
|
||||
OPENCV_HAL_IMPL_AVX512_MISC(v_float64x8, pd)
|
||||
|
||||
inline v_int32x16 v_fma(const v_int32x16& a, const v_int32x16& b, const v_int32x16& c)
|
||||
{ return a * b + c; }
|
||||
|
||||
@@ -244,7 +244,13 @@ struct v_uint64x2
|
||||
explicit v_uint64x2(__m128i v) : val(v) {}
|
||||
v_uint64x2(uint64 v0, uint64 v1)
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__)
|
||||
val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1);
|
||||
#elif defined(__GNUC__)
|
||||
val = _mm_setr_epi64((__m64)v0, (__m64)v1);
|
||||
#else
|
||||
val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32));
|
||||
#endif
|
||||
}
|
||||
|
||||
uint64 get0() const
|
||||
@@ -272,7 +278,13 @@ struct v_int64x2
|
||||
explicit v_int64x2(__m128i v) : val(v) {}
|
||||
v_int64x2(int64 v0, int64 v1)
|
||||
{
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1920/*MSVS 2019*/ && defined(_M_X64) && !defined(__clang__)
|
||||
val = _mm_setr_epi64x((int64_t)v0, (int64_t)v1);
|
||||
#elif defined(__GNUC__)
|
||||
val = _mm_setr_epi64((__m64)v0, (__m64)v1);
|
||||
#else
|
||||
val = _mm_setr_epi32((int)v0, (int)(v0 >> 32), (int)v1, (int)(v1 >> 32));
|
||||
#endif
|
||||
}
|
||||
|
||||
int64 get0() const
|
||||
|
||||
@@ -1895,13 +1895,33 @@ Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b )
|
||||
template<typename _Tp> static inline
|
||||
Rect_<_Tp>& operator &= ( Rect_<_Tp>& a, const Rect_<_Tp>& b )
|
||||
{
|
||||
_Tp x1 = std::max(a.x, b.x);
|
||||
_Tp y1 = std::max(a.y, b.y);
|
||||
a.width = std::min(a.x + a.width, b.x + b.width) - x1;
|
||||
a.height = std::min(a.y + a.height, b.y + b.height) - y1;
|
||||
a.x = x1;
|
||||
a.y = y1;
|
||||
if( a.width <= 0 || a.height <= 0 )
|
||||
if (a.empty() || b.empty()) {
|
||||
a = Rect();
|
||||
return a;
|
||||
}
|
||||
const Rect_<_Tp>& Rx_min = (a.x < b.x) ? a : b;
|
||||
const Rect_<_Tp>& Rx_max = (a.x < b.x) ? b : a;
|
||||
const Rect_<_Tp>& Ry_min = (a.y < b.y) ? a : b;
|
||||
const Rect_<_Tp>& Ry_max = (a.y < b.y) ? b : a;
|
||||
// Looking at the formula below, we will compute Rx_min.width - (Rx_max.x - Rx_min.x)
|
||||
// but we want to avoid overflows. Rx_min.width >= 0 and (Rx_max.x - Rx_min.x) >= 0
|
||||
// by definition so the difference does not overflow. The only thing that can overflow
|
||||
// is (Rx_max.x - Rx_min.x). And it can only overflow if Rx_min.x < 0.
|
||||
// Let us first deal with the following case.
|
||||
if ((Rx_min.x < 0 && Rx_min.x + Rx_min.width < Rx_max.x) ||
|
||||
(Ry_min.y < 0 && Ry_min.y + Ry_min.height < Ry_max.y)) {
|
||||
a = Rect();
|
||||
return a;
|
||||
}
|
||||
// We now know that either Rx_min.x >= 0, or
|
||||
// Rx_min.x < 0 && Rx_min.x + Rx_min.width >= Rx_max.x and therefore
|
||||
// Rx_min.width >= (Rx_max.x - Rx_min.x) which means (Rx_max.x - Rx_min.x)
|
||||
// is inferior to a valid int and therefore does not overflow.
|
||||
a.width = std::min(Rx_min.width - (Rx_max.x - Rx_min.x), Rx_max.width);
|
||||
a.height = std::min(Ry_min.height - (Ry_max.y - Ry_min.y), Ry_max.height);
|
||||
a.x = Rx_max.x;
|
||||
a.y = Ry_max.y;
|
||||
if (a.empty())
|
||||
a = Rect();
|
||||
return a;
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#define CV_VERSION_MAJOR 3
|
||||
#define CV_VERSION_MINOR 4
|
||||
#define CV_VERSION_REVISION 16
|
||||
#define CV_VERSION_REVISION 17
|
||||
#define CV_VERSION_STATUS ""
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
|
||||
@@ -236,11 +236,11 @@ protected:
|
||||
void operator=(const WImage&);
|
||||
|
||||
explicit WImage(IplImage* img) : image_(img) {
|
||||
assert(!img || img->depth == Depth());
|
||||
CV_Assert(!img || img->depth == Depth());
|
||||
}
|
||||
|
||||
void SetIpl(IplImage* image) {
|
||||
assert(!image || image->depth == Depth());
|
||||
CV_Assert(!image || image->depth == Depth());
|
||||
image_ = image;
|
||||
}
|
||||
|
||||
@@ -260,7 +260,7 @@ public:
|
||||
enum { kChannels = C };
|
||||
|
||||
explicit WImageC(IplImage* img) : WImage<T>(img) {
|
||||
assert(!img || img->nChannels == Channels());
|
||||
CV_Assert(!img || img->nChannels == Channels());
|
||||
}
|
||||
|
||||
// Construct a view into a region of this image
|
||||
@@ -283,7 +283,7 @@ protected:
|
||||
void operator=(const WImageC&);
|
||||
|
||||
void SetIpl(IplImage* image) {
|
||||
assert(!image || image->depth == WImage<T>::Depth());
|
||||
CV_Assert(!image || image->depth == WImage<T>::Depth());
|
||||
WImage<T>::SetIpl(image);
|
||||
}
|
||||
};
|
||||
|
||||
+10
-10
@@ -497,7 +497,7 @@ cvInitNArrayIterator( int count, CvArr** arrs,
|
||||
// returns zero value if iteration is finished, non-zero otherwise
|
||||
CV_IMPL int cvNextNArraySlice( CvNArrayIterator* iterator )
|
||||
{
|
||||
assert( iterator != 0 );
|
||||
CV_Assert( iterator != 0 );
|
||||
int i, dims;
|
||||
|
||||
for( dims = iterator->dims; dims > 0; dims-- )
|
||||
@@ -648,7 +648,7 @@ icvGetNodePtr( CvSparseMat* mat, const int* idx, int* _type,
|
||||
int i, tabidx;
|
||||
unsigned hashval = 0;
|
||||
CvSparseNode *node;
|
||||
assert( CV_IS_SPARSE_MAT( mat ));
|
||||
CV_Assert( CV_IS_SPARSE_MAT( mat ));
|
||||
|
||||
if( !precalc_hashval )
|
||||
{
|
||||
@@ -697,7 +697,7 @@ icvGetNodePtr( CvSparseMat* mat, const int* idx, int* _type,
|
||||
int newrawsize = newsize*sizeof(newtable[0]);
|
||||
|
||||
CvSparseMatIterator iterator;
|
||||
assert( (newsize & (newsize - 1)) == 0 );
|
||||
CV_Assert( (newsize & (newsize - 1)) == 0 );
|
||||
|
||||
// resize hash table
|
||||
newtable = (void**)cvAlloc( newrawsize );
|
||||
@@ -742,7 +742,7 @@ icvDeleteNode( CvSparseMat* mat, const int* idx, unsigned* precalc_hashval )
|
||||
int i, tabidx;
|
||||
unsigned hashval = 0;
|
||||
CvSparseNode *node, *prev = 0;
|
||||
assert( CV_IS_SPARSE_MAT( mat ));
|
||||
CV_Assert( CV_IS_SPARSE_MAT( mat ));
|
||||
|
||||
if( !precalc_hashval )
|
||||
{
|
||||
@@ -1462,7 +1462,7 @@ cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_1
|
||||
int cn = CV_MAT_CN( type );
|
||||
int depth = type & CV_MAT_DEPTH_MASK;
|
||||
|
||||
assert( scalar && data );
|
||||
CV_Assert( scalar && data );
|
||||
if( (unsigned)(cn - 1) >= 4 )
|
||||
CV_Error( CV_StsOutOfRange, "The number of channels must be 1, 2, 3 or 4" );
|
||||
|
||||
@@ -1509,7 +1509,7 @@ cvScalarToRawData( const CvScalar* scalar, void* data, int type, int extend_to_1
|
||||
((double*)data)[cn] = (double)(scalar->val[cn]);
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
CV_Error( CV_BadDepth, "" );
|
||||
}
|
||||
|
||||
@@ -1534,7 +1534,7 @@ cvRawDataToScalar( const void* data, int flags, CvScalar* scalar )
|
||||
{
|
||||
int cn = CV_MAT_CN( flags );
|
||||
|
||||
assert( scalar && data );
|
||||
CV_Assert( scalar && data );
|
||||
|
||||
if( (unsigned)(cn - 1) >= 4 )
|
||||
CV_Error( CV_StsOutOfRange, "The number of channels must be 1, 2, 3 or 4" );
|
||||
@@ -1572,7 +1572,7 @@ cvRawDataToScalar( const void* data, int flags, CvScalar* scalar )
|
||||
scalar->val[cn] = ((double*)data)[cn];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
CV_Error( CV_BadDepth, "" );
|
||||
}
|
||||
}
|
||||
@@ -2623,7 +2623,7 @@ cvReshapeMatND( const CvArr* arr,
|
||||
|
||||
{
|
||||
CvMatND* mat = (CvMatND*)arr;
|
||||
assert( new_cn > 0 );
|
||||
CV_Assert( new_cn > 0 );
|
||||
int last_dim_size = mat->dim[mat->dims-1].size*CV_MAT_CN(mat->type);
|
||||
int new_size = last_dim_size/new_cn;
|
||||
|
||||
@@ -2901,7 +2901,7 @@ CV_IMPL IplImage *
|
||||
cvCreateImage( CvSize size, int depth, int channels )
|
||||
{
|
||||
IplImage *img = cvCreateImageHeader( size, depth, channels );
|
||||
assert( img );
|
||||
CV_Assert( img );
|
||||
cvCreateData( img );
|
||||
|
||||
return img;
|
||||
|
||||
@@ -97,7 +97,7 @@ icvInitMemStorage( CvMemStorage* storage, int block_size )
|
||||
block_size = CV_STORAGE_BLOCK_SIZE;
|
||||
|
||||
block_size = cvAlign( block_size, CV_STRUCT_ALIGN );
|
||||
assert( sizeof(CvMemBlock) % CV_STRUCT_ALIGN == 0 );
|
||||
CV_Assert( sizeof(CvMemBlock) % CV_STRUCT_ALIGN == 0 );
|
||||
|
||||
memset( storage, 0, sizeof( *storage ));
|
||||
storage->signature = CV_STORAGE_MAGIC_VAL;
|
||||
@@ -240,7 +240,7 @@ icvGoNextMemBlock( CvMemStorage * storage )
|
||||
|
||||
if( block == parent->top ) /* the single allocated block */
|
||||
{
|
||||
assert( parent->bottom == block );
|
||||
CV_Assert( parent->bottom == block );
|
||||
parent->top = parent->bottom = 0;
|
||||
parent->free_space = 0;
|
||||
}
|
||||
@@ -266,7 +266,7 @@ icvGoNextMemBlock( CvMemStorage * storage )
|
||||
if( storage->top->next )
|
||||
storage->top = storage->top->next;
|
||||
storage->free_space = storage->block_size - sizeof(CvMemBlock);
|
||||
assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
|
||||
CV_Assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -331,7 +331,7 @@ cvMemStorageAlloc( CvMemStorage* storage, size_t size )
|
||||
if( size > INT_MAX )
|
||||
CV_Error( CV_StsOutOfRange, "Too large memory block is requested" );
|
||||
|
||||
assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
|
||||
CV_Assert( storage->free_space % CV_STRUCT_ALIGN == 0 );
|
||||
|
||||
if( (size_t)storage->free_space < size )
|
||||
{
|
||||
@@ -343,7 +343,7 @@ cvMemStorageAlloc( CvMemStorage* storage, size_t size )
|
||||
}
|
||||
|
||||
ptr = ICV_FREE_PTR(storage);
|
||||
assert( (size_t)ptr % CV_STRUCT_ALIGN == 0 );
|
||||
CV_Assert( (size_t)ptr % CV_STRUCT_ALIGN == 0 );
|
||||
storage->free_space = cvAlignLeft(storage->free_space - (int)size, CV_STRUCT_ALIGN );
|
||||
|
||||
return ptr;
|
||||
@@ -683,7 +683,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of )
|
||||
else
|
||||
{
|
||||
icvGoNextMemBlock( storage );
|
||||
assert( storage->free_space >= delta );
|
||||
CV_Assert( storage->free_space >= delta );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -716,7 +716,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of )
|
||||
* For used blocks it means current number
|
||||
* of sequence elements in the block:
|
||||
*/
|
||||
assert( block->count % seq->elem_size == 0 && block->count > 0 );
|
||||
CV_Assert( block->count % seq->elem_size == 0 && block->count > 0 );
|
||||
|
||||
if( !in_front_of )
|
||||
{
|
||||
@@ -732,7 +732,7 @@ icvGrowSeq( CvSeq *seq, int in_front_of )
|
||||
|
||||
if( block != block->prev )
|
||||
{
|
||||
assert( seq->first->start_index == 0 );
|
||||
CV_Assert( seq->first->start_index == 0 );
|
||||
seq->first = block;
|
||||
}
|
||||
else
|
||||
@@ -760,7 +760,7 @@ icvFreeSeqBlock( CvSeq *seq, int in_front_of )
|
||||
{
|
||||
CvSeqBlock *block = seq->first;
|
||||
|
||||
assert( (in_front_of ? block : block->prev)->count == 0 );
|
||||
CV_Assert( (in_front_of ? block : block->prev)->count == 0 );
|
||||
|
||||
if( block == block->prev ) /* single block case */
|
||||
{
|
||||
@@ -775,7 +775,7 @@ icvFreeSeqBlock( CvSeq *seq, int in_front_of )
|
||||
if( !in_front_of )
|
||||
{
|
||||
block = block->prev;
|
||||
assert( seq->ptr == block->data );
|
||||
CV_Assert( seq->ptr == block->data );
|
||||
|
||||
block->count = (int)(seq->block_max - seq->ptr);
|
||||
seq->block_max = seq->ptr = block->prev->data +
|
||||
@@ -804,7 +804,7 @@ icvFreeSeqBlock( CvSeq *seq, int in_front_of )
|
||||
block->next->prev = block->prev;
|
||||
}
|
||||
|
||||
assert( block->count > 0 && block->count % seq->elem_size == 0 );
|
||||
CV_Assert( block->count > 0 && block->count % seq->elem_size == 0 );
|
||||
block->next = seq->free_blocks;
|
||||
seq->free_blocks = block;
|
||||
}
|
||||
@@ -861,7 +861,7 @@ cvFlushSeqWriter( CvSeqWriter * writer )
|
||||
CvSeqBlock *block = first_block;
|
||||
|
||||
writer->block->count = (int)((writer->ptr - writer->block->data) / seq->elem_size);
|
||||
assert( writer->block->count > 0 );
|
||||
CV_Assert( writer->block->count > 0 );
|
||||
|
||||
do
|
||||
{
|
||||
@@ -891,7 +891,7 @@ cvEndWriteSeq( CvSeqWriter * writer )
|
||||
CvMemStorage *storage = seq->storage;
|
||||
schar *storage_block_max = (schar *) storage->top + storage->block_size;
|
||||
|
||||
assert( writer->block->count > 0 );
|
||||
CV_Assert( writer->block->count > 0 );
|
||||
|
||||
if( (unsigned)((storage_block_max - storage->free_space)
|
||||
- seq->block_max) < CV_STRUCT_ALIGN )
|
||||
@@ -1147,7 +1147,7 @@ cvSeqPush( CvSeq *seq, const void *element )
|
||||
icvGrowSeq( seq, 0 );
|
||||
|
||||
ptr = seq->ptr;
|
||||
assert( ptr + elem_size <= seq->block_max /*&& ptr == seq->block_min */ );
|
||||
CV_Assert( ptr + elem_size <= seq->block_max /*&& ptr == seq->block_min */ );
|
||||
}
|
||||
|
||||
if( element )
|
||||
@@ -1183,7 +1183,7 @@ cvSeqPop( CvSeq *seq, void *element )
|
||||
if( --(seq->first->prev->count) == 0 )
|
||||
{
|
||||
icvFreeSeqBlock( seq, 0 );
|
||||
assert( seq->ptr == seq->block_max );
|
||||
CV_Assert( seq->ptr == seq->block_max );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1207,7 +1207,7 @@ cvSeqPushFront( CvSeq *seq, const void *element )
|
||||
icvGrowSeq( seq, 1 );
|
||||
|
||||
block = seq->first;
|
||||
assert( block->start_index > 0 );
|
||||
CV_Assert( block->start_index > 0 );
|
||||
}
|
||||
|
||||
ptr = block->data -= elem_size;
|
||||
@@ -1289,7 +1289,7 @@ cvSeqInsert( CvSeq *seq, int before_index, const void *element )
|
||||
icvGrowSeq( seq, 0 );
|
||||
|
||||
ptr = seq->ptr + elem_size;
|
||||
assert( ptr <= seq->block_max );
|
||||
CV_Assert( ptr <= seq->block_max );
|
||||
}
|
||||
|
||||
delta_index = seq->first->start_index;
|
||||
@@ -1307,7 +1307,7 @@ cvSeqInsert( CvSeq *seq, int before_index, const void *element )
|
||||
block = prev_block;
|
||||
|
||||
/* Check that we don't fall into an infinite loop: */
|
||||
assert( block != seq->first->prev );
|
||||
CV_Assert( block != seq->first->prev );
|
||||
}
|
||||
|
||||
before_index = (before_index - block->start_index + delta_index) * elem_size;
|
||||
@@ -1346,7 +1346,7 @@ cvSeqInsert( CvSeq *seq, int before_index, const void *element )
|
||||
block = next_block;
|
||||
|
||||
/* Check that we don't fall into an infinite loop: */
|
||||
assert( block != seq->first );
|
||||
CV_Assert( block != seq->first );
|
||||
}
|
||||
|
||||
before_index = (before_index - block->start_index + delta_index) * elem_size;
|
||||
@@ -1502,7 +1502,7 @@ cvSeqPushMulti( CvSeq *seq, const void *_elements, int count, int front )
|
||||
icvGrowSeq( seq, 1 );
|
||||
|
||||
block = seq->first;
|
||||
assert( block->start_index > 0 );
|
||||
CV_Assert( block->start_index > 0 );
|
||||
}
|
||||
|
||||
delta = MIN( block->start_index, count );
|
||||
@@ -1543,7 +1543,7 @@ cvSeqPopMulti( CvSeq *seq, void *_elements, int count, int front )
|
||||
int delta = seq->first->prev->count;
|
||||
|
||||
delta = MIN( delta, count );
|
||||
assert( delta > 0 );
|
||||
CV_Assert( delta > 0 );
|
||||
|
||||
seq->first->prev->count -= delta;
|
||||
seq->total -= delta;
|
||||
@@ -1568,7 +1568,7 @@ cvSeqPopMulti( CvSeq *seq, void *_elements, int count, int front )
|
||||
int delta = seq->first->count;
|
||||
|
||||
delta = MIN( delta, count );
|
||||
assert( delta > 0 );
|
||||
CV_Assert( delta > 0 );
|
||||
|
||||
seq->first->count -= delta;
|
||||
seq->total -= delta;
|
||||
@@ -2418,7 +2418,7 @@ cvSeqPartition( const CvSeq* seq, CvMemStorage* storage, CvSeq** labels,
|
||||
root2->rank += root->rank == root2->rank;
|
||||
root = root2;
|
||||
}
|
||||
assert( root->parent == 0 );
|
||||
CV_Assert( root->parent == 0 );
|
||||
|
||||
// Compress path from node2 to the root:
|
||||
while( node2->parent )
|
||||
@@ -2521,7 +2521,7 @@ cvSetAdd( CvSet* set, CvSetElem* element, CvSetElem** inserted_element )
|
||||
((CvSetElem*)ptr)->flags = count | CV_SET_ELEM_FREE_FLAG;
|
||||
((CvSetElem*)ptr)->next_free = (CvSetElem*)(ptr + elem_size);
|
||||
}
|
||||
assert( count <= CV_SET_ELEM_IDX_MASK+1 );
|
||||
CV_Assert( count <= CV_SET_ELEM_IDX_MASK+1 );
|
||||
((CvSetElem*)(ptr - elem_size))->next_free = 0;
|
||||
set->first->prev->count += count - set->total;
|
||||
set->total = count;
|
||||
@@ -2720,7 +2720,7 @@ cvFindGraphEdgeByPtr( const CvGraph* graph,
|
||||
for( ; edge; edge = edge->next[ofs] )
|
||||
{
|
||||
ofs = start_vtx == edge->vtx[1];
|
||||
assert( ofs == 1 || start_vtx == edge->vtx[0] );
|
||||
CV_Assert( ofs == 1 || start_vtx == edge->vtx[0] );
|
||||
if( edge->vtx[1] == end_vtx )
|
||||
break;
|
||||
}
|
||||
@@ -2784,7 +2784,7 @@ cvGraphAddEdgeByPtr( CvGraph* graph,
|
||||
"vertex pointers coincide (or set to NULL)" );
|
||||
|
||||
edge = (CvGraphEdge*)cvSetNew( (CvSet*)(graph->edges) );
|
||||
assert( edge->flags >= 0 );
|
||||
CV_Assert( edge->flags >= 0 );
|
||||
|
||||
edge->vtx[0] = start_vtx;
|
||||
edge->vtx[1] = end_vtx;
|
||||
@@ -2861,7 +2861,7 @@ cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, CvGraphVtx* end_v
|
||||
prev_ofs = ofs, prev_edge = edge, edge = edge->next[ofs] )
|
||||
{
|
||||
ofs = start_vtx == edge->vtx[1];
|
||||
assert( ofs == 1 || start_vtx == edge->vtx[0] );
|
||||
CV_Assert( ofs == 1 || start_vtx == edge->vtx[0] );
|
||||
if( edge->vtx[1] == end_vtx )
|
||||
break;
|
||||
}
|
||||
@@ -2879,7 +2879,7 @@ cvGraphRemoveEdgeByPtr( CvGraph* graph, CvGraphVtx* start_vtx, CvGraphVtx* end_v
|
||||
prev_ofs = ofs, prev_edge = edge, edge = edge->next[ofs] )
|
||||
{
|
||||
ofs = end_vtx == edge->vtx[1];
|
||||
assert( ofs == 1 || end_vtx == edge->vtx[0] );
|
||||
CV_Assert( ofs == 1 || end_vtx == edge->vtx[0] );
|
||||
if( edge->vtx[0] == start_vtx )
|
||||
break;
|
||||
}
|
||||
@@ -3396,7 +3396,7 @@ cvInsertNodeIntoTree( void* _node, void* _parent, void* _frame )
|
||||
node->v_prev = _parent != _frame ? parent : 0;
|
||||
node->h_next = parent->v_next;
|
||||
|
||||
assert( parent->v_next != node );
|
||||
CV_Assert( parent->v_next != node );
|
||||
|
||||
if( parent->v_next )
|
||||
parent->v_next->h_prev = node;
|
||||
@@ -3430,7 +3430,7 @@ cvRemoveNodeFromTree( void* _node, void* _frame )
|
||||
|
||||
if( parent )
|
||||
{
|
||||
assert( parent->v_next == node );
|
||||
CV_Assert( parent->v_next == node );
|
||||
parent->v_next = node->h_next;
|
||||
}
|
||||
}
|
||||
|
||||
+13
-13
@@ -238,7 +238,7 @@ DFTInit( int n0, int nf, const int* factors, int* itab, int elem_size, void* _wa
|
||||
else
|
||||
{
|
||||
// radix[] is initialized from index 'nf' down to zero
|
||||
assert (nf < 34);
|
||||
CV_Assert (nf < 34);
|
||||
radix[nf] = 1;
|
||||
digits[nf] = 0;
|
||||
for( i = 0; i < nf; i++ )
|
||||
@@ -374,7 +374,7 @@ DFTInit( int n0, int nf, const int* factors, int* itab, int elem_size, void* _wa
|
||||
else
|
||||
{
|
||||
Complex<float>* wave = (Complex<float>*)_wave;
|
||||
assert( elem_size == sizeof(Complex<float>) );
|
||||
CV_Assert( elem_size == sizeof(Complex<float>) );
|
||||
|
||||
wave[0].re = 1.f;
|
||||
wave[0].im = 0.f;
|
||||
@@ -874,13 +874,13 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
|
||||
// 0. shuffle data
|
||||
if( dst != src )
|
||||
{
|
||||
assert( !c.noPermute );
|
||||
CV_Assert( !c.noPermute );
|
||||
if( !inv )
|
||||
{
|
||||
for( i = 0; i <= n - 2; i += 2, itab += 2*tab_step )
|
||||
{
|
||||
int k0 = itab[0], k1 = itab[tab_step];
|
||||
assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
|
||||
CV_Assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
|
||||
dst[i] = src[k0]; dst[i+1] = src[k1];
|
||||
}
|
||||
|
||||
@@ -892,7 +892,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
|
||||
for( i = 0; i <= n - 2; i += 2, itab += 2*tab_step )
|
||||
{
|
||||
int k0 = itab[0], k1 = itab[tab_step];
|
||||
assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
|
||||
CV_Assert( (unsigned)k0 < (unsigned)n && (unsigned)k1 < (unsigned)n );
|
||||
t.re = src[k0].re; t.im = -src[k0].im;
|
||||
dst[i] = t;
|
||||
t.re = src[k1].re; t.im = -src[k1].im;
|
||||
@@ -921,7 +921,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
|
||||
for( i = 0; i < n2; i += 2, itab += tab_step*2 )
|
||||
{
|
||||
j = itab[0];
|
||||
assert( (unsigned)j < (unsigned)n2 );
|
||||
CV_Assert( (unsigned)j < (unsigned)n2 );
|
||||
|
||||
CV_SWAP(dst[i+1], dsth[j], t);
|
||||
if( j > i )
|
||||
@@ -938,7 +938,7 @@ DFT(const OcvDftOptions & c, const Complex<T>* src, Complex<T>* dst)
|
||||
for( i = 0; i < n; i++, itab += tab_step )
|
||||
{
|
||||
j = itab[0];
|
||||
assert( (unsigned)j < (unsigned)n );
|
||||
CV_Assert( (unsigned)j < (unsigned)n );
|
||||
if( j > i )
|
||||
CV_SWAP(dst[i], dst[j], t);
|
||||
}
|
||||
@@ -1218,7 +1218,7 @@ RealDFT(const OcvDftOptions & c, const T* src, T* dst)
|
||||
setIppErrorStatus();
|
||||
#endif
|
||||
}
|
||||
assert( c.tab_size == n );
|
||||
CV_Assert( c.tab_size == n );
|
||||
|
||||
if( n == 1 )
|
||||
{
|
||||
@@ -1338,11 +1338,11 @@ CCSIDFT(const OcvDftOptions & c, const T* src, T* dst)
|
||||
T save_s1 = 0.;
|
||||
T t0, t1, t2, t3, t;
|
||||
|
||||
assert( c.tab_size == n );
|
||||
CV_Assert( c.tab_size == n );
|
||||
|
||||
if( complex_input )
|
||||
{
|
||||
assert( src != dst );
|
||||
CV_Assert( src != dst );
|
||||
save_s1 = src[1];
|
||||
((T*)src)[1] = src[0];
|
||||
src++;
|
||||
@@ -3175,7 +3175,7 @@ protected:
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( !inv );
|
||||
CV_Assert( !inv );
|
||||
CopyColumn( dbuf0, complex_elem_size, dptr0,
|
||||
dst_step, len, complex_elem_size );
|
||||
if( even )
|
||||
@@ -3872,7 +3872,7 @@ DCTInit( int n, int elem_size, void* _wave, int inv )
|
||||
if( n == 1 )
|
||||
return;
|
||||
|
||||
assert( (n&1) == 0 );
|
||||
CV_Assert( (n&1) == 0 );
|
||||
|
||||
if( (n & (n - 1)) == 0 )
|
||||
{
|
||||
@@ -3910,7 +3910,7 @@ DCTInit( int n, int elem_size, void* _wave, int inv )
|
||||
else
|
||||
{
|
||||
Complex<float>* wave = (Complex<float>*)_wave;
|
||||
assert( elem_size == sizeof(Complex<float>) );
|
||||
CV_Assert( elem_size == sizeof(Complex<float>) );
|
||||
|
||||
w.re = (float)scale;
|
||||
w.im = 0.f;
|
||||
|
||||
@@ -163,9 +163,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
|
||||
if(n == 1 && b_step == sizeof(fptype))
|
||||
{
|
||||
if(typeid(fptype) == typeid(float))
|
||||
sposv_(L, &m, &n, (float*)a, &lda, (float*)b, &m, &lapackStatus);
|
||||
OCV_LAPACK_FUNC(sposv)(L, &m, &n, (float*)a, &lda, (float*)b, &m, &lapackStatus);
|
||||
else if(typeid(fptype) == typeid(double))
|
||||
dposv_(L, &m, &n, (double*)a, &lda, (double*)b, &m, &lapackStatus);
|
||||
OCV_LAPACK_FUNC(dposv)(L, &m, &n, (double*)a, &lda, (double*)b, &m, &lapackStatus);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -174,9 +174,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
|
||||
transpose(b, ldb, tmpB, m, m, n);
|
||||
|
||||
if(typeid(fptype) == typeid(float))
|
||||
sposv_(L, &m, &n, (float*)a, &lda, (float*)tmpB, &m, &lapackStatus);
|
||||
OCV_LAPACK_FUNC(sposv)(L, &m, &n, (float*)a, &lda, (float*)tmpB, &m, &lapackStatus);
|
||||
else if(typeid(fptype) == typeid(double))
|
||||
dposv_(L, &m, &n, (double*)a, &lda, (double*)tmpB, &m, &lapackStatus);
|
||||
OCV_LAPACK_FUNC(dposv)(L, &m, &n, (double*)a, &lda, (double*)tmpB, &m, &lapackStatus);
|
||||
|
||||
transpose(tmpB, m, b, ldb, n, m);
|
||||
delete[] tmpB;
|
||||
@@ -185,9 +185,9 @@ lapack_Cholesky(fptype* a, size_t a_step, int m, fptype* b, size_t b_step, int n
|
||||
else
|
||||
{
|
||||
if(typeid(fptype) == typeid(float))
|
||||
spotrf_(L, &m, (float*)a, &lda, &lapackStatus);
|
||||
OCV_LAPACK_FUNC(spotrf)(L, &m, (float*)a, &lda, &lapackStatus);
|
||||
else if(typeid(fptype) == typeid(double))
|
||||
dpotrf_(L, &m, (double*)a, &lda, &lapackStatus);
|
||||
OCV_LAPACK_FUNC(dpotrf)(L, &m, (double*)a, &lda, &lapackStatus);
|
||||
}
|
||||
|
||||
if(lapackStatus == 0) *info = true;
|
||||
@@ -227,17 +227,17 @@ lapack_SVD(fptype* a, size_t a_step, fptype *w, fptype* u, size_t u_step, fptype
|
||||
}
|
||||
|
||||
if(typeid(fptype) == typeid(float))
|
||||
sgesdd_(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu, (float*)vt, &ldv, (float*)&work1, &lwork, iworkBuf, info);
|
||||
OCV_LAPACK_FUNC(sgesdd)(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu, (float*)vt, &ldv, (float*)&work1, &lwork, iworkBuf, info);
|
||||
else if(typeid(fptype) == typeid(double))
|
||||
dgesdd_(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)&work1, &lwork, iworkBuf, info);
|
||||
OCV_LAPACK_FUNC(dgesdd)(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)&work1, &lwork, iworkBuf, info);
|
||||
|
||||
lwork = (int)round(work1); //optimal buffer size
|
||||
fptype* buffer = new fptype[lwork + 1];
|
||||
|
||||
if(typeid(fptype) == typeid(float))
|
||||
sgesdd_(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu, (float*)vt, &ldv, (float*)buffer, &lwork, iworkBuf, info);
|
||||
OCV_LAPACK_FUNC(sgesdd)(mode, &m, &n, (float*)a, &lda, (float*)w, (float*)u, &ldu, (float*)vt, &ldv, (float*)buffer, &lwork, iworkBuf, info);
|
||||
else if(typeid(fptype) == typeid(double))
|
||||
dgesdd_(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)buffer, &lwork, iworkBuf, info);
|
||||
OCV_LAPACK_FUNC(dgesdd)(mode, &m, &n, (double*)a, &lda, (double*)w, (double*)u, &ldu, (double*)vt, &ldv, (double*)buffer, &lwork, iworkBuf, info);
|
||||
|
||||
if(!(flags & CV_HAL_SVD_NO_UV))
|
||||
transpose_square_inplace(vt, ldv, n);
|
||||
@@ -288,18 +288,18 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
|
||||
if (k == 1 && b_step == sizeof(fptype))
|
||||
{
|
||||
if (typeid(fptype) == typeid(float))
|
||||
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)&work1, &lwork, info);
|
||||
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)&work1, &lwork, info);
|
||||
else if (typeid(fptype) == typeid(double))
|
||||
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)&work1, &lwork, info);
|
||||
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)&work1, &lwork, info);
|
||||
|
||||
lwork = cvRound(work1); //optimal buffer size
|
||||
std::vector<fptype> workBufMemHolder(lwork + 1);
|
||||
fptype* buffer = &workBufMemHolder.front();
|
||||
|
||||
if (typeid(fptype) == typeid(float))
|
||||
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)buffer, &lwork, info);
|
||||
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)b, &m, (float*)buffer, &lwork, info);
|
||||
else if (typeid(fptype) == typeid(double))
|
||||
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)buffer, &lwork, info);
|
||||
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)b, &m, (double*)buffer, &lwork, info);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -309,18 +309,18 @@ lapack_QR(fptype* a, size_t a_step, int m, int n, int k, fptype* b, size_t b_ste
|
||||
transpose(b, ldb, tmpB, m, m, k);
|
||||
|
||||
if (typeid(fptype) == typeid(float))
|
||||
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)&work1, &lwork, info);
|
||||
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)&work1, &lwork, info);
|
||||
else if (typeid(fptype) == typeid(double))
|
||||
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)&work1, &lwork, info);
|
||||
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)&work1, &lwork, info);
|
||||
|
||||
lwork = cvRound(work1); //optimal buffer size
|
||||
std::vector<fptype> workBufMemHolder(lwork + 1);
|
||||
fptype* buffer = &workBufMemHolder.front();
|
||||
|
||||
if (typeid(fptype) == typeid(float))
|
||||
sgels_(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)buffer, &lwork, info);
|
||||
OCV_LAPACK_FUNC(sgels)(mode, &m, &n, &k, (float*)tmpA, &ldtmpA, (float*)tmpB, &m, (float*)buffer, &lwork, info);
|
||||
else if (typeid(fptype) == typeid(double))
|
||||
dgels_(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)buffer, &lwork, info);
|
||||
OCV_LAPACK_FUNC(dgels)(mode, &m, &n, &k, (double*)tmpA, &ldtmpA, (double*)tmpB, &m, (double*)buffer, &lwork, info);
|
||||
|
||||
transpose(tmpB, m, b, ldb, k, m);
|
||||
}
|
||||
|
||||
@@ -47,12 +47,15 @@
|
||||
|
||||
#include "opencv2/core/hal/interface.h"
|
||||
|
||||
#if defined __GNUC__
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#elif defined _MSC_VER
|
||||
# pragma warning( push )
|
||||
# pragma warning( disable: 4100 )
|
||||
#if defined(__clang__) // clang or MSVC clang
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wunused-parameter"
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable : 4100)
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wunused-parameter"
|
||||
#endif
|
||||
|
||||
//! @addtogroup core_hal_interface
|
||||
@@ -731,10 +734,12 @@ inline int hal_ni_minMaxIdx(const uchar* src_data, size_t src_step, int width, i
|
||||
//! @}
|
||||
|
||||
|
||||
#if defined __GNUC__
|
||||
# pragma GCC diagnostic pop
|
||||
#elif defined _MSC_VER
|
||||
# pragma warning( pop )
|
||||
#if defined(__clang__)
|
||||
#pragma clang diagnostic pop
|
||||
#elif defined(_MSC_VER)
|
||||
#pragma warning(pop)
|
||||
#elif defined(__GNUC__)
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
#include "hal_internal.hpp"
|
||||
|
||||
@@ -1020,7 +1020,7 @@ double invert( InputArray _src, OutputArray _dst, int method )
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( n == 1 );
|
||||
CV_Assert( n == 1 );
|
||||
|
||||
if( type == CV_32FC1 )
|
||||
{
|
||||
@@ -1208,7 +1208,7 @@ bool solve( InputArray _src, InputArray _src2arg, OutputArray _dst, int method )
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( src.rows == 1 );
|
||||
CV_Assert( src.rows == 1 );
|
||||
|
||||
if( type == CV_32FC1 )
|
||||
{
|
||||
|
||||
@@ -71,17 +71,33 @@ LogLevel getLogLevel()
|
||||
|
||||
namespace internal {
|
||||
|
||||
static int getShowTimestampMode()
|
||||
{
|
||||
static bool param_timestamp_enable = utils::getConfigurationParameterBool("OPENCV_LOG_TIMESTAMP", true);
|
||||
static bool param_timestamp_ns_enable = utils::getConfigurationParameterBool("OPENCV_LOG_TIMESTAMP_NS", false);
|
||||
return (param_timestamp_enable ? 1 : 0) + (param_timestamp_ns_enable ? 2 : 0);
|
||||
}
|
||||
|
||||
void writeLogMessage(LogLevel logLevel, const char* message)
|
||||
{
|
||||
const int threadID = cv::utils::getThreadID();
|
||||
|
||||
std::string message_id;
|
||||
switch (getShowTimestampMode())
|
||||
{
|
||||
case 1: message_id = cv::format("%d@%0.3f", threadID, getTimestampNS() * 1e-9); break;
|
||||
case 1+2: message_id = cv::format("%d@%llu", threadID, getTimestampNS()); break;
|
||||
default: message_id = cv::format("%d", threadID); break;
|
||||
}
|
||||
|
||||
std::ostringstream ss;
|
||||
switch (logLevel)
|
||||
{
|
||||
case LOG_LEVEL_FATAL: ss << "[FATAL:" << threadID << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_ERROR: ss << "[ERROR:" << threadID << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_WARNING: ss << "[ WARN:" << threadID << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_INFO: ss << "[ INFO:" << threadID << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_DEBUG: ss << "[DEBUG:" << threadID << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_FATAL: ss << "[FATAL:" << message_id << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_ERROR: ss << "[ERROR:" << message_id << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_WARNING: ss << "[ WARN:" << message_id << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_INFO: ss << "[ INFO:" << message_id << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_DEBUG: ss << "[DEBUG:" << message_id << "] " << message << std::endl; break;
|
||||
case LOG_LEVEL_VERBOSE: ss << message << std::endl; break;
|
||||
case LOG_LEVEL_SILENT: return; // avoid compiler warning about incomplete switch
|
||||
case ENUM_LOG_LEVEL_FORCE_INT: return; // avoid compiler warning about incomplete switch
|
||||
|
||||
@@ -169,7 +169,7 @@ GEMM_TransposeBlock( const uchar* src, size_t src_step,
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2062,7 +2062,7 @@ MulTransposedR(const Mat& srcmat, const Mat& dstmat, const Mat& deltamat, double
|
||||
|
||||
if( delta && delta_cols < size.width )
|
||||
{
|
||||
assert( delta_cols == 1 );
|
||||
CV_Assert( delta_cols == 1 );
|
||||
buf_size *= 5;
|
||||
}
|
||||
buf.allocate(buf_size);
|
||||
|
||||
@@ -638,7 +638,7 @@ void SparseMat::resizeHashTab(size_t newsize)
|
||||
uchar* SparseMat::newNode(const int* idx, size_t hashval)
|
||||
{
|
||||
const int HASH_MAX_FILL_FACTOR=3;
|
||||
assert(hdr);
|
||||
CV_Assert(hdr);
|
||||
size_t hsize = hdr->hashtab.size();
|
||||
if( ++hdr->nodeCount > hsize*HASH_MAX_FILL_FACTOR )
|
||||
{
|
||||
|
||||
@@ -113,7 +113,7 @@ static void* openclamdblas_check_fn(int ID);
|
||||
|
||||
static void* openclamdblas_check_fn(int ID)
|
||||
{
|
||||
assert(ID >= 0 && ID < (int)(sizeof(openclamdblas_fn)/sizeof(openclamdblas_fn[0])));
|
||||
CV_Assert(ID >= 0 && ID < (int)(sizeof(openclamdblas_fn)/sizeof(openclamdblas_fn[0])));
|
||||
const struct DynamicFnEntry* e = openclamdblas_fn[ID];
|
||||
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
|
||||
if (!func)
|
||||
|
||||
@@ -113,7 +113,7 @@ static void* openclamdfft_check_fn(int ID);
|
||||
|
||||
static void* openclamdfft_check_fn(int ID)
|
||||
{
|
||||
assert(ID >= 0 && ID < (int)(sizeof(openclamdfft_fn)/sizeof(openclamdfft_fn[0])));
|
||||
CV_Assert(ID >= 0 && ID < (int)(sizeof(openclamdfft_fn)/sizeof(openclamdfft_fn[0])));
|
||||
const struct DynamicFnEntry* e = openclamdfft_fn[ID];
|
||||
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
|
||||
if (!func)
|
||||
|
||||
@@ -360,7 +360,7 @@ static void* opencl_gl_check_fn(int ID);
|
||||
static void* opencl_gl_check_fn(int ID)
|
||||
{
|
||||
const struct DynamicFnEntry* e = NULL;
|
||||
assert(ID >= 0 && ID < (int)(sizeof(opencl_gl_fn_list)/sizeof(opencl_gl_fn_list[0])));
|
||||
CV_Assert(ID >= 0 && ID < (int)(sizeof(opencl_gl_fn_list)/sizeof(opencl_gl_fn_list[0])));
|
||||
e = opencl_gl_fn_list[ID];
|
||||
void* func = CV_CL_GET_PROC_ADDRESS(e->fnName);
|
||||
if (!func)
|
||||
|
||||
@@ -160,7 +160,7 @@ void icvFSCreateCollection( CvFileStorage* fs, int tag, CvFileNode* collection )
|
||||
{
|
||||
if( collection->tag != CV_NODE_NONE )
|
||||
{
|
||||
assert( fs->fmt == CV_STORAGE_FORMAT_XML );
|
||||
CV_Assert( fs->fmt == CV_STORAGE_FORMAT_XML );
|
||||
CV_PARSE_ERROR( "Sequence element should not have name (use <_></_>)" );
|
||||
}
|
||||
|
||||
@@ -551,7 +551,7 @@ int icvDecodeFormat( const char* dt, int* fmt_pairs, int max_len )
|
||||
if( !dt || !len )
|
||||
return 0;
|
||||
|
||||
assert( fmt_pairs != 0 && max_len > 0 );
|
||||
CV_Assert( fmt_pairs != 0 && max_len > 0 );
|
||||
fmt_pairs[0] = 0;
|
||||
max_len *= 2;
|
||||
|
||||
|
||||
@@ -756,7 +756,7 @@ void icvJSONEndWriteStruct( CvFileStorage* fs )
|
||||
cvSeqPop( fs->write_stack, &parent_flags );
|
||||
fs->struct_indent -= 4;
|
||||
fs->struct_flags = parent_flags & ~CV_NODE_EMPTY;
|
||||
assert( fs->struct_indent >= 0 );
|
||||
CV_Assert( fs->struct_indent >= 0 );
|
||||
|
||||
if ( CV_NODE_IS_COLLECTION(struct_flags) )
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ static void icvWriteMat( CvFileStorage* fs, const char* name, const void* struct
|
||||
cv::Size size;
|
||||
int y;
|
||||
|
||||
assert( CV_IS_MAT_HDR_Z(mat) );
|
||||
CV_Assert( CV_IS_MAT_HDR_Z(mat) );
|
||||
|
||||
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_MAT );
|
||||
cvWriteInt( fs, "rows", mat->rows );
|
||||
@@ -121,7 +121,7 @@ static void icvWriteMatND( CvFileStorage* fs, const char* name, const void* stru
|
||||
int dims, sizes[CV_MAX_DIM];
|
||||
char dt[16];
|
||||
|
||||
assert( CV_IS_MATND_HDR(mat) );
|
||||
CV_Assert( CV_IS_MATND_HDR(mat) );
|
||||
|
||||
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_MATND );
|
||||
dims = cvGetDims( mat, sizes );
|
||||
@@ -237,7 +237,7 @@ static void icvWriteSparseMat( CvFileStorage* fs, const char* name, const void*
|
||||
int *prev_idx = 0;
|
||||
char dt[16];
|
||||
|
||||
assert( CV_IS_SPARSE_MAT(mat) );
|
||||
CV_Assert( CV_IS_SPARSE_MAT(mat) );
|
||||
|
||||
memstorage = cvCreateMemStorage();
|
||||
|
||||
@@ -273,7 +273,7 @@ static void icvWriteSparseMat( CvFileStorage* fs, const char* name, const void*
|
||||
if( i > 0 )
|
||||
{
|
||||
for( ; idx[k] == prev_idx[k]; k++ )
|
||||
assert( k < dims );
|
||||
CV_Assert( k < dims );
|
||||
if( k < dims - 1 )
|
||||
fs->write_int( fs, 0, k - dims + 1 );
|
||||
}
|
||||
@@ -383,7 +383,7 @@ static void icvWriteImage( CvFileStorage* fs, const char* name, const void* stru
|
||||
cv::Size size;
|
||||
int y, depth;
|
||||
|
||||
assert( CV_IS_IMAGE(image) );
|
||||
CV_Assert( CV_IS_IMAGE(image) );
|
||||
|
||||
if( image->dataOrder == IPL_DATA_ORDER_PLANE )
|
||||
CV_Error( CV_StsUnsupportedFormat,
|
||||
@@ -623,7 +623,7 @@ static void icvWriteSeq( CvFileStorage* fs, const char* name, const void* struct
|
||||
char buf[128];
|
||||
char dt_buf[128], *dt;
|
||||
|
||||
assert( CV_IS_SEQ( seq ));
|
||||
CV_Assert( CV_IS_SEQ( seq ));
|
||||
cvStartWriteStruct( fs, name, CV_NODE_MAP, CV_TYPE_NAME_SEQ );
|
||||
|
||||
if( level >= 0 )
|
||||
@@ -671,7 +671,7 @@ static void icvWriteSeqTree( CvFileStorage* fs, const char* name, const void* st
|
||||
strcmp(recursive_value,"False") != 0 &&
|
||||
strcmp(recursive_value,"FALSE") != 0;
|
||||
|
||||
assert( CV_IS_SEQ( seq ));
|
||||
CV_Assert( CV_IS_SEQ( seq ));
|
||||
|
||||
if( !is_recursive )
|
||||
{
|
||||
@@ -873,7 +873,7 @@ static void* icvReadSeqTree( CvFileStorage* fs, CvFileNode* node )
|
||||
root = seq;
|
||||
if( level > prev_level )
|
||||
{
|
||||
assert( level == prev_level + 1 );
|
||||
CV_Assert( level == prev_level + 1 );
|
||||
parent = prev_seq;
|
||||
prev_seq = 0;
|
||||
if( parent )
|
||||
@@ -933,7 +933,7 @@ static void icvWriteGraph( CvFileStorage* fs, const char* name, const void* stru
|
||||
char edge_dt_buf[128], *edge_dt;
|
||||
int write_buf_size;
|
||||
|
||||
assert( CV_IS_GRAPH(graph) );
|
||||
CV_Assert( CV_IS_GRAPH(graph) );
|
||||
vtx_count = cvGraphGetVtxCount( graph );
|
||||
edge_count = cvGraphGetEdgeCount( graph );
|
||||
flag_buf = (int*)cvAlloc( vtx_count*sizeof(flag_buf[0]));
|
||||
|
||||
@@ -37,7 +37,7 @@ icvXMLSkipSpaces( CvFileStorage* fs, char* ptr, int mode )
|
||||
|
||||
if( c == '-' )
|
||||
{
|
||||
assert( ptr[1] == '-' && ptr[2] == '>' );
|
||||
CV_Assert( ptr[1] == '-' && ptr[2] == '>' );
|
||||
mode = 0;
|
||||
ptr += 3;
|
||||
}
|
||||
@@ -484,7 +484,7 @@ icvXMLParseTag( CvFileStorage* fs, char* ptr, CvStringHashNode** _tag,
|
||||
else if( *ptr == '!' )
|
||||
{
|
||||
tag_type = CV_XML_DIRECTIVE_TAG;
|
||||
assert( ptr[1] != '-' || ptr[2] != '-' );
|
||||
CV_Assert( ptr[1] != '-' || ptr[2] != '-' );
|
||||
ptr++;
|
||||
}
|
||||
else
|
||||
@@ -549,7 +549,7 @@ icvXMLParseTag( CvFileStorage* fs, char* ptr, CvStringHashNode** _tag,
|
||||
}
|
||||
|
||||
ptr = icvXMLParseValue( fs, ptr, &stub, CV_NODE_STRING );
|
||||
assert( stub.tag == CV_NODE_STRING );
|
||||
CV_Assert( stub.tag == CV_NODE_STRING );
|
||||
last->attr[count*2+1] = stub.data.str.ptr;
|
||||
count++;
|
||||
}
|
||||
|
||||
@@ -797,7 +797,7 @@ void icvYMLEndWriteStruct( CvFileStorage* fs )
|
||||
|
||||
if( !CV_NODE_IS_FLOW(parent_flags) )
|
||||
fs->struct_indent -= CV_YML_INDENT + CV_NODE_IS_FLOW(struct_flags);
|
||||
assert( fs->struct_indent >= 0 );
|
||||
CV_Assert( fs->struct_indent >= 0 );
|
||||
|
||||
fs->struct_flags = parent_flags;
|
||||
}
|
||||
|
||||
@@ -374,6 +374,10 @@ bool __termination; // skip some cleanups, because process is terminating
|
||||
|
||||
cv::Mutex& getInitializationMutex();
|
||||
|
||||
/// @brief Returns timestamp in nanoseconds since program launch
|
||||
int64 getTimestampNS();
|
||||
|
||||
|
||||
// TODO Memory barriers?
|
||||
#define CV_SINGLETON_LAZY_INIT_(TYPE, INITIALIZER, RET_VALUE) \
|
||||
static TYPE* volatile instance = NULL; \
|
||||
|
||||
@@ -129,7 +129,7 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
|
||||
#if defined __ANDROID__ || defined __unix__ || defined __FreeBSD__ || defined __OpenBSD__ || defined __HAIKU__
|
||||
# include <unistd.h>
|
||||
# include <fcntl.h>
|
||||
#if defined __QNXNTO__
|
||||
#if defined __QNX__
|
||||
# include <sys/elf.h>
|
||||
#else
|
||||
# include <elf.h>
|
||||
@@ -155,6 +155,9 @@ void* allocSingletonNewBuffer(size_t size) { return malloc(size); }
|
||||
# ifndef PPC_FEATURE2_ARCH_3_00
|
||||
# define PPC_FEATURE2_ARCH_3_00 0x00800000
|
||||
# endif
|
||||
# ifndef PPC_FEATURE_HAS_VSX
|
||||
# define PPC_FEATURE_HAS_VSX 0x00000080
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined WINCE
|
||||
@@ -545,7 +548,7 @@ struct HWFeatures
|
||||
}
|
||||
#endif // CV_CPUID_X86
|
||||
|
||||
#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__
|
||||
#if defined __ANDROID__ || defined __linux__ || defined __FreeBSD__ || defined __QNX__
|
||||
#ifdef __aarch64__
|
||||
have[CV_CPU_NEON] = true;
|
||||
have[CV_CPU_FP16] = true;
|
||||
@@ -607,7 +610,7 @@ struct HWFeatures
|
||||
have[CV_CPU_MSA] = true;
|
||||
#endif
|
||||
|
||||
#if (defined __ppc64__ || defined __PPC64__) && defined __unix__
|
||||
#if (defined __ppc64__ || defined __PPC64__) && defined __linux__
|
||||
unsigned int hwcap = getauxval(AT_HWCAP);
|
||||
if (hwcap & PPC_FEATURE_HAS_VSX) {
|
||||
hwcap = getauxval(AT_HWCAP2);
|
||||
@@ -617,8 +620,19 @@ struct HWFeatures
|
||||
have[CV_CPU_VSX] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0;
|
||||
}
|
||||
}
|
||||
#elif (defined __ppc64__ || defined __PPC64__) && defined __FreeBSD__
|
||||
unsigned int hwcap = 0;
|
||||
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
|
||||
if (hwcap & PPC_FEATURE_HAS_VSX) {
|
||||
elf_aux_info(AT_HWCAP2, &hwcap, sizeof(hwcap));
|
||||
if (hwcap & PPC_FEATURE2_ARCH_3_00) {
|
||||
have[CV_CPU_VSX] = have[CV_CPU_VSX3] = true;
|
||||
} else {
|
||||
have[CV_CPU_VSX] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0;
|
||||
}
|
||||
}
|
||||
#else
|
||||
// TODO: AIX, FreeBSD
|
||||
// TODO: AIX, OpenBSD
|
||||
#if CV_VSX || defined _ARCH_PWR8 || defined __POWER9_VECTOR__
|
||||
have[CV_CPU_VSX] = true;
|
||||
#endif
|
||||
@@ -920,6 +934,51 @@ int64 getCPUTickCount(void)
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
namespace internal {
|
||||
|
||||
class Timestamp
|
||||
{
|
||||
public:
|
||||
const int64 zeroTickCount;
|
||||
const double ns_in_ticks;
|
||||
|
||||
Timestamp()
|
||||
: zeroTickCount(getTickCount())
|
||||
, ns_in_ticks(1e9 / getTickFrequency())
|
||||
{
|
||||
// nothing
|
||||
}
|
||||
|
||||
int64 getTimestamp()
|
||||
{
|
||||
int64 t = getTickCount();
|
||||
return (int64)((t - zeroTickCount) * ns_in_ticks);
|
||||
}
|
||||
|
||||
static Timestamp& getInstance()
|
||||
{
|
||||
static Timestamp g_timestamp;
|
||||
return g_timestamp;
|
||||
}
|
||||
};
|
||||
|
||||
class InitTimestamp {
|
||||
public:
|
||||
InitTimestamp() {
|
||||
Timestamp::getInstance();
|
||||
}
|
||||
};
|
||||
static InitTimestamp g_initialize_timestamp; // force zero timestamp initialization
|
||||
|
||||
} // namespace
|
||||
|
||||
int64 getTimestampNS()
|
||||
{
|
||||
return internal::Timestamp::getInstance().getTimestamp();
|
||||
}
|
||||
|
||||
|
||||
const String& getBuildInformation()
|
||||
{
|
||||
static String build_info =
|
||||
|
||||
@@ -63,15 +63,6 @@ namespace details {
|
||||
#pragma warning(disable:4065) // switch statement contains 'default' but no 'case' labels
|
||||
#endif
|
||||
|
||||
static int64 g_zero_timestamp = 0;
|
||||
|
||||
static int64 getTimestamp()
|
||||
{
|
||||
int64 t = getTickCount();
|
||||
static double tick_to_ns = 1e9 / getTickFrequency();
|
||||
return (int64)((t - g_zero_timestamp) * tick_to_ns);
|
||||
}
|
||||
|
||||
static bool getParameterTraceEnable()
|
||||
{
|
||||
static bool param_traceEnable = utils::getConfigurationParameterBool("OPENCV_TRACE", false);
|
||||
@@ -485,7 +476,7 @@ Region::Region(const LocationStaticStorage& location) :
|
||||
}
|
||||
}
|
||||
|
||||
int64 beginTimestamp = getTimestamp();
|
||||
int64 beginTimestamp = getTimestampNS();
|
||||
|
||||
int currentDepth = ctx.getCurrentDepth() + 1;
|
||||
switch (location.flags & REGION_FLAG_IMPL_MASK)
|
||||
@@ -635,7 +626,7 @@ void Region::destroy()
|
||||
}
|
||||
}
|
||||
|
||||
int64 endTimestamp = getTimestamp();
|
||||
int64 endTimestamp = getTimestampNS();
|
||||
int64 duration = endTimestamp - ctx.stackTopBeginTimestamp();
|
||||
|
||||
bool active = isActive();
|
||||
@@ -844,7 +835,7 @@ static bool isInitialized = false;
|
||||
|
||||
TraceManager::TraceManager()
|
||||
{
|
||||
g_zero_timestamp = cv::getTickCount();
|
||||
(void)cv::getTimestampNS();
|
||||
|
||||
isInitialized = true;
|
||||
CV_LOG("TraceManager ctor: " << (void*)this);
|
||||
@@ -990,7 +981,7 @@ void parallelForFinalize(const Region& rootRegion)
|
||||
{
|
||||
TraceManagerThreadLocal& ctx = getTraceManager().tls.getRef();
|
||||
|
||||
int64 endTimestamp = getTimestamp();
|
||||
int64 endTimestamp = getTimestampNS();
|
||||
int64 duration = endTimestamp - ctx.stackTopBeginTimestamp();
|
||||
CV_LOG_PARALLEL(NULL, "parallel_for duration: " << duration << " " << &rootRegion);
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ static void cvTsReleaseSimpleSeq( CvTsSimpleSeq** seq )
|
||||
|
||||
static schar* cvTsSimpleSeqElem( CvTsSimpleSeq* seq, int index )
|
||||
{
|
||||
assert( 0 <= index && index < seq->count );
|
||||
CV_Assert( 0 <= index && index < seq->count );
|
||||
return seq->array + index * seq->elem_size;
|
||||
}
|
||||
|
||||
@@ -50,7 +50,11 @@ static void cvTsSimpleSeqShiftAndCopy( CvTsSimpleSeq* seq, int from_idx, int to_
|
||||
|
||||
if( from_idx == to_idx )
|
||||
return;
|
||||
assert( (from_idx > to_idx && !elem) || (from_idx < to_idx && elem) );
|
||||
|
||||
if (elem)
|
||||
CV_Assert(from_idx < to_idx);
|
||||
else
|
||||
CV_Assert(from_idx > to_idx);
|
||||
|
||||
if( from_idx < seq->count )
|
||||
{
|
||||
@@ -128,7 +132,7 @@ static void cvTsReleaseSimpleSet( CvTsSimpleSet** set_header )
|
||||
static schar* cvTsSimpleSetFind( CvTsSimpleSet* set_header, int index )
|
||||
{
|
||||
int idx = index * set_header->elem_size;
|
||||
assert( 0 <= index && index < set_header->max_count );
|
||||
CV_Assert( 0 <= index && index < set_header->max_count );
|
||||
return set_header->array[idx] ? set_header->array + idx + 1 : 0;
|
||||
}
|
||||
|
||||
@@ -136,11 +140,11 @@ static schar* cvTsSimpleSetFind( CvTsSimpleSet* set_header, int index )
|
||||
static int cvTsSimpleSetAdd( CvTsSimpleSet* set_header, void* elem )
|
||||
{
|
||||
int idx, idx2;
|
||||
assert( set_header->free_count > 0 );
|
||||
CV_Assert( set_header->free_count > 0 );
|
||||
|
||||
idx = set_header->free_stack[--set_header->free_count];
|
||||
idx2 = idx * set_header->elem_size;
|
||||
assert( set_header->array[idx2] == 0 );
|
||||
CV_Assert( set_header->array[idx2] == 0 );
|
||||
set_header->array[idx2] = 1;
|
||||
if( set_header->elem_size > 1 )
|
||||
memcpy( set_header->array + idx2 + 1, elem, set_header->elem_size - 1 );
|
||||
@@ -152,9 +156,9 @@ static int cvTsSimpleSetAdd( CvTsSimpleSet* set_header, void* elem )
|
||||
|
||||
static void cvTsSimpleSetRemove( CvTsSimpleSet* set_header, int index )
|
||||
{
|
||||
assert( set_header->free_count < set_header->max_count &&
|
||||
0 <= index && index < set_header->max_count );
|
||||
assert( set_header->array[index * set_header->elem_size] == 1 );
|
||||
CV_Assert( set_header->free_count < set_header->max_count &&
|
||||
0 <= index && index < set_header->max_count );
|
||||
CV_Assert( set_header->array[index * set_header->elem_size] == 1 );
|
||||
|
||||
set_header->free_stack[set_header->free_count++] = index;
|
||||
set_header->array[index * set_header->elem_size] = 0;
|
||||
@@ -187,7 +191,7 @@ static CvTsSimpleGraph* cvTsCreateSimpleGraph( int max_vtx_count, int vtx_size,
|
||||
{
|
||||
CvTsSimpleGraph* graph;
|
||||
|
||||
assert( max_vtx_count > 1 && vtx_size >= 0 && edge_size >= 0 );
|
||||
CV_Assert( max_vtx_count > 1 && vtx_size >= 0 && edge_size >= 0 );
|
||||
graph = (CvTsSimpleGraph*)cvAlloc( sizeof(*graph) +
|
||||
max_vtx_count * max_vtx_count * (edge_size + 1));
|
||||
graph->vtx = cvTsCreateSimpleSet( max_vtx_count, vtx_size );
|
||||
@@ -235,13 +239,13 @@ static void cvTsSimpleGraphAddEdge( CvTsSimpleGraph* graph, int idx1, int idx2,
|
||||
{
|
||||
int i, t, n = graph->oriented ? 1 : 2;
|
||||
|
||||
assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
|
||||
cvTsSimpleSetFind( graph->vtx, idx2 ));
|
||||
CV_Assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
|
||||
cvTsSimpleSetFind( graph->vtx, idx2 ));
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
int ofs = (idx1*graph->vtx->max_count + idx2)*graph->edge_size;
|
||||
assert( graph->matrix[ofs] == 0 );
|
||||
CV_Assert( graph->matrix[ofs] == 0 );
|
||||
graph->matrix[ofs] = 1;
|
||||
if( graph->edge_size > 1 )
|
||||
memcpy( graph->matrix + ofs + 1, edge, graph->edge_size - 1 );
|
||||
@@ -255,13 +259,13 @@ static void cvTsSimpleGraphRemoveEdge( CvTsSimpleGraph* graph, int idx1, int id
|
||||
{
|
||||
int i, t, n = graph->oriented ? 1 : 2;
|
||||
|
||||
assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
|
||||
CV_Assert( cvTsSimpleSetFind( graph->vtx, idx1 ) &&
|
||||
cvTsSimpleSetFind( graph->vtx, idx2 ));
|
||||
|
||||
for( i = 0; i < n; i++ )
|
||||
{
|
||||
int ofs = (idx1*graph->vtx->max_count + idx2)*graph->edge_size;
|
||||
assert( graph->matrix[ofs] == 1 );
|
||||
CV_Assert( graph->matrix[ofs] == 1 );
|
||||
graph->matrix[ofs] = 0;
|
||||
CV_SWAP( idx1, idx2, t );
|
||||
}
|
||||
@@ -291,7 +295,7 @@ static int cvTsSimpleGraphVertexDegree( CvTsSimpleGraph* graph, int index )
|
||||
int i, count = 0;
|
||||
int edge_size = graph->edge_size;
|
||||
int max_vtx_count = graph->vtx->max_count;
|
||||
assert( cvTsSimpleGraphFindVertex( graph, index ) != 0 );
|
||||
CV_Assert( cvTsSimpleGraphFindVertex( graph, index ) != 0 );
|
||||
|
||||
for( i = 0; i < max_vtx_count; i++ )
|
||||
{
|
||||
@@ -301,7 +305,7 @@ static int cvTsSimpleGraphVertexDegree( CvTsSimpleGraph* graph, int index )
|
||||
|
||||
if( !graph->oriented )
|
||||
{
|
||||
assert( count % 2 == 0 );
|
||||
CV_Assert( count % 2 == 0 );
|
||||
count /= 2;
|
||||
}
|
||||
return count;
|
||||
@@ -609,7 +613,7 @@ int Core_SeqBaseTest::test_get_seq_elem( int _struct_idx, int iters )
|
||||
CvTsSimpleSeq* sseq = (CvTsSimpleSeq*)simple_struct[_struct_idx];
|
||||
struct_idx = _struct_idx;
|
||||
|
||||
assert( seq->total == sseq->count );
|
||||
CV_Assert( seq->total == sseq->count );
|
||||
|
||||
if( sseq->count == 0 )
|
||||
return 0;
|
||||
@@ -656,7 +660,7 @@ int Core_SeqBaseTest::test_get_seq_reading( int _struct_idx, int iters )
|
||||
vector<schar> _elem(sseq->elem_size);
|
||||
schar* elem = &_elem[0];
|
||||
|
||||
assert( total == sseq->count );
|
||||
CV_Assert( total == sseq->count );
|
||||
this->struct_idx = _struct_idx;
|
||||
|
||||
int pos = cvtest::randInt(rng) % 2;
|
||||
@@ -964,7 +968,7 @@ int Core_SeqBaseTest::test_seq_ops( int iters )
|
||||
"The sequence doesn't become empty after clear" );
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
return -1;
|
||||
}
|
||||
|
||||
@@ -1903,7 +1907,7 @@ int Core_GraphScanTest::create_random_graph( int _struct_idx )
|
||||
for( i = 0; i < vtx_count; i++ )
|
||||
cvGraphAddVtx( graph );
|
||||
|
||||
assert( graph->active_count == vtx_count );
|
||||
CV_Assert( graph->active_count == vtx_count );
|
||||
|
||||
for( i = 0; i < edge_count; i++ )
|
||||
{
|
||||
@@ -1914,7 +1918,7 @@ int Core_GraphScanTest::create_random_graph( int _struct_idx )
|
||||
cvGraphAddEdge( graph, j, k );
|
||||
}
|
||||
|
||||
assert( graph->active_count == vtx_count && graph->edges->active_count <= edge_count );
|
||||
CV_Assert( graph->active_count == vtx_count && graph->edges->active_count <= edge_count );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -204,7 +204,7 @@ static void DCT_1D( const Mat& _src, Mat& _dst, int flags, const Mat& _wave=Mat(
|
||||
}
|
||||
}
|
||||
else
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -373,6 +373,23 @@ template<typename R> struct TheTest
|
||||
EXPECT_EQ((LaneType)12, vx_setall_res2_[i]);
|
||||
}
|
||||
|
||||
#if CV_SIMD_WIDTH == 16
|
||||
{
|
||||
uint64 a = CV_BIG_INT(0x7fffffffffffffff);
|
||||
uint64 b = (uint64)CV_BIG_INT(0xcfffffffffffffff);
|
||||
v_uint64x2 uint64_vec(a, b);
|
||||
EXPECT_EQ(a, uint64_vec.get0());
|
||||
EXPECT_EQ(b, v_extract_n<1>(uint64_vec));
|
||||
}
|
||||
{
|
||||
int64 a = CV_BIG_INT(0x7fffffffffffffff);
|
||||
int64 b = CV_BIG_INT(-1);
|
||||
v_int64x2 int64_vec(a, b);
|
||||
EXPECT_EQ(a, int64_vec.get0());
|
||||
EXPECT_EQ(b, v_extract_n<1>(int64_vec));
|
||||
}
|
||||
#endif
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ protected:
|
||||
template<class Type>
|
||||
void testReduce( const Mat& src, Mat& sum, Mat& avg, Mat& max, Mat& min, int dim )
|
||||
{
|
||||
assert( src.channels() == 1 );
|
||||
CV_Assert( src.channels() == 1 );
|
||||
if( dim == 0 ) // row
|
||||
{
|
||||
sum.create( 1, src.cols, CV_64FC1 );
|
||||
@@ -138,7 +138,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
|
||||
eps = 0.6;
|
||||
}
|
||||
|
||||
assert( opRes.type() == CV_64FC1 );
|
||||
CV_Assert( opRes.type() == CV_64FC1 );
|
||||
Mat _dst, dst, diff;
|
||||
cv::reduce( src, _dst, dim, opType, dstType );
|
||||
_dst.convertTo( dst, CV_64FC1 );
|
||||
@@ -192,7 +192,7 @@ int Core_ReduceTest::checkCase( int srcType, int dstType, int dim, Size sz )
|
||||
else if( srcType == CV_64FC1 )
|
||||
testReduce<double>( src, sum, avg, max, min, dim );
|
||||
else
|
||||
assert( 0 );
|
||||
CV_Assert( 0 );
|
||||
|
||||
// 1. sum
|
||||
tempCode = checkOp( src, dstType, CV_REDUCE_SUM, sum, dim );
|
||||
|
||||
@@ -1039,7 +1039,7 @@ static void cvTsPerspectiveTransform( const CvArr* _src, CvArr* _dst, const CvMa
|
||||
}
|
||||
else
|
||||
{
|
||||
assert( mat_depth == CV_64F );
|
||||
CV_Assert( mat_depth == CV_64F );
|
||||
for( i = 0; i < transmat->rows; i++ )
|
||||
for( j = 0; j < cols; j++ )
|
||||
mat[i*cols + j] = ((double*)(transmat->data.ptr + transmat->step*i))[j];
|
||||
@@ -1065,7 +1065,7 @@ static void cvTsPerspectiveTransform( const CvArr* _src, CvArr* _dst, const CvMa
|
||||
buf[j] = ((double*)src)[j];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
}
|
||||
|
||||
switch( cn )
|
||||
@@ -1095,7 +1095,7 @@ static void cvTsPerspectiveTransform( const CvArr* _src, CvArr* _dst, const CvMa
|
||||
}
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
}
|
||||
|
||||
switch( depth )
|
||||
@@ -1109,7 +1109,7 @@ static void cvTsPerspectiveTransform( const CvArr* _src, CvArr* _dst, const CvMa
|
||||
((double*)dst)[j] = buf[j];
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
CV_Assert(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1458,8 +1458,8 @@ static double cvTsLU( CvMat* a, CvMat* b=NULL, CvMat* x=NULL, int* rank=0 )
|
||||
double *a0 = a->data.db, *b0 = b ? b->data.db : 0;
|
||||
double *x0 = x ? x->data.db : 0;
|
||||
double t, det = 1.;
|
||||
assert( CV_MAT_TYPE(a->type) == CV_64FC1 &&
|
||||
(!b || CV_ARE_TYPES_EQ(a,b)) && (!x || CV_ARE_TYPES_EQ(a,x)));
|
||||
CV_Assert( CV_MAT_TYPE(a->type) == CV_64FC1 &&
|
||||
(!b || CV_ARE_TYPES_EQ(a,b)) && (!x || CV_ARE_TYPES_EQ(a,x)));
|
||||
|
||||
for( i = 0; i < Nm; i++ )
|
||||
{
|
||||
@@ -1514,7 +1514,7 @@ static double cvTsLU( CvMat* a, CvMat* b=NULL, CvMat* x=NULL, int* rank=0 )
|
||||
|
||||
if( x )
|
||||
{
|
||||
assert( b );
|
||||
CV_Assert( b );
|
||||
|
||||
for( i = N-1; i >= 0; i-- )
|
||||
{
|
||||
|
||||
@@ -784,4 +784,36 @@ TEST(Core_Check, testSize_1)
|
||||
}
|
||||
|
||||
|
||||
template <typename T> class Rect_Test : public testing::Test {};
|
||||
|
||||
TYPED_TEST_CASE_P(Rect_Test);
|
||||
|
||||
// Reimplement C++11 std::numeric_limits<>::lowest.
|
||||
template<typename T> T cv_numeric_limits_lowest();
|
||||
template<> int cv_numeric_limits_lowest<int>() { return INT_MIN; }
|
||||
template<> float cv_numeric_limits_lowest<float>() { return -FLT_MAX; }
|
||||
template<> double cv_numeric_limits_lowest<double>() { return -DBL_MAX; }
|
||||
|
||||
TYPED_TEST_P(Rect_Test, Overflows) {
|
||||
typedef Rect_<TypeParam> R;
|
||||
TypeParam num_max = std::numeric_limits<TypeParam>::max();
|
||||
TypeParam num_lowest = cv_numeric_limits_lowest<TypeParam>();
|
||||
EXPECT_EQ(R(0, 0, 10, 10), R(0, 0, 10, 10) & R(0, 0, 10, 10));
|
||||
EXPECT_EQ(R(5, 6, 4, 3), R(0, 0, 10, 10) & R(5, 6, 4, 3));
|
||||
EXPECT_EQ(R(5, 6, 3, 2), R(0, 0, 8, 8) & R(5, 6, 4, 3));
|
||||
// Test with overflowing dimenions.
|
||||
EXPECT_EQ(R(5, 0, 5, 10), R(0, 0, 10, 10) & R(5, 0, num_max, num_max));
|
||||
// Test with overflowing dimensions for floats/doubles.
|
||||
EXPECT_EQ(R(num_max, 0, num_max / 4, 10), R(num_max, 0, num_max / 2, 10) & R(num_max, 0, num_max / 4, 10));
|
||||
// Test with overflowing coordinates.
|
||||
EXPECT_EQ(R(), R(20, 0, 10, 10) & R(num_lowest, 0, 10, 10));
|
||||
EXPECT_EQ(R(), R(20, 0, 10, 10) & R(0, num_lowest, 10, 10));
|
||||
EXPECT_EQ(R(), R(num_lowest, 0, 10, 10) & R(0, num_lowest, 10, 10));
|
||||
}
|
||||
REGISTER_TYPED_TEST_CASE_P(Rect_Test, Overflows);
|
||||
|
||||
typedef ::testing::Types<int, float, double> RectTypes;
|
||||
INSTANTIATE_TYPED_TEST_CASE_P(Negative_Test, Rect_Test, RectTypes);
|
||||
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -162,7 +162,9 @@ namespace
|
||||
GpuMat p32_buf;
|
||||
|
||||
GpuMat diff_buf;
|
||||
GpuMat norm_buf;
|
||||
|
||||
GpuMat diff_sum_dev;
|
||||
Mat diff_sum_host;
|
||||
};
|
||||
|
||||
void OpticalFlowDual_TVL1_Impl::calc(InputArray _frame0, InputArray _frame1, InputOutputArray _flow, Stream& stream)
|
||||
@@ -361,8 +363,11 @@ namespace
|
||||
estimateU(I1wx, I1wy, grad, rho_c, p11, p12, p21, p22, p31, p32, u1, u2, u3, diff, l_t, static_cast<float>(theta_), gamma_, calcError, stream);
|
||||
if (calcError)
|
||||
{
|
||||
cuda::calcSum(diff, diff_sum_dev, cv::noArray(), _stream);
|
||||
diff_sum_dev.download(diff_sum_host, _stream);
|
||||
_stream.waitForCompletion();
|
||||
error = cuda::sum(diff, norm_buf)[0];
|
||||
|
||||
error = diff_sum_host.at<double>(0,0);
|
||||
prevError = error;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -13,9 +13,6 @@ ocv_add_dispatched_file_force_all("layers/layers_common" AVX AVX2 AVX512_SKX)
|
||||
ocv_add_module(dnn opencv_core opencv_imgproc WRAP python java js)
|
||||
|
||||
ocv_option(OPENCV_DNN_OPENCL "Build with OpenCL support" HAVE_OPENCL AND NOT APPLE)
|
||||
if(HAVE_TENGINE)
|
||||
add_definitions(-DHAVE_TENGINE=1)
|
||||
endif()
|
||||
|
||||
if(OPENCV_DNN_OPENCL AND HAVE_OPENCL)
|
||||
add_definitions(-DCV_OCL4DNN=1)
|
||||
@@ -23,6 +20,10 @@ else()
|
||||
ocv_cmake_hook_append(INIT_MODULE_SOURCES_opencv_dnn "${CMAKE_CURRENT_LIST_DIR}/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake")
|
||||
endif()
|
||||
|
||||
if(HAVE_TENGINE)
|
||||
add_definitions(-DHAVE_TENGINE=1)
|
||||
endif()
|
||||
|
||||
if(MSVC)
|
||||
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
|
||||
|
||||
@@ -453,6 +453,8 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
class CV_EXPORTS ELULayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
float alpha;
|
||||
|
||||
static Ptr<ELULayer> create(const LayerParams ¶ms);
|
||||
};
|
||||
|
||||
|
||||
@@ -47,9 +47,9 @@
|
||||
#include "opencv2/core/async.hpp"
|
||||
|
||||
#if !defined CV_DOXYGEN && !defined CV_STATIC_ANALYSIS && !defined CV_DNN_DONT_ADD_EXPERIMENTAL_NS
|
||||
#define CV__DNN_EXPERIMENTAL_NS_BEGIN namespace experimental_dnn_34_v23 {
|
||||
#define CV__DNN_EXPERIMENTAL_NS_BEGIN namespace experimental_dnn_34_v24 {
|
||||
#define CV__DNN_EXPERIMENTAL_NS_END }
|
||||
namespace cv { namespace dnn { namespace experimental_dnn_34_v23 { } using namespace experimental_dnn_34_v23; }}
|
||||
namespace cv { namespace dnn { namespace experimental_dnn_34_v24 { } using namespace experimental_dnn_34_v24; }}
|
||||
#else
|
||||
#define CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
#define CV__DNN_EXPERIMENTAL_NS_END
|
||||
|
||||
@@ -18,7 +18,7 @@ parser = argparse.ArgumentParser(description="Use this script to create TensorFl
|
||||
"with weights from OpenCV's face detection network. "
|
||||
"Only backbone part of SSD model is converted this way. "
|
||||
"Look for .pbtxt configuration file at "
|
||||
"https://github.com/opencv/opencv_extra/tree/master/testdata/dnn/opencv_face_detector.pbtxt")
|
||||
"https://github.com/opencv/opencv_extra/tree/3.4/testdata/dnn/opencv_face_detector.pbtxt")
|
||||
parser.add_argument('--model', help='Path to .caffemodel weights', required=True)
|
||||
parser.add_argument('--proto', help='Path to .prototxt Caffe model definition', required=True)
|
||||
parser.add_argument('--pb', help='Path to output .pb TensorFlow model', required=True)
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
// 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.
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
struct LstmParams {
|
||||
// Batch size
|
||||
int nrSamples;
|
||||
|
||||
// Size of the input vector
|
||||
int inputSize;
|
||||
|
||||
// Size of the internal state vector
|
||||
int hiddenSize;
|
||||
|
||||
// Number of timesteps for the LSTM
|
||||
int nrSteps;
|
||||
};
|
||||
|
||||
static inline void PrintTo(const LstmParams& params, ::std::ostream* os) {
|
||||
(*os) << "BATCH=" << params.nrSamples
|
||||
<< ", IN=" << params.inputSize
|
||||
<< ", HIDDEN=" << params.hiddenSize
|
||||
<< ", TS=" << params.nrSteps;
|
||||
}
|
||||
|
||||
static const LstmParams testLstmConfigs[] = {
|
||||
{1, 192, 192, 100},
|
||||
{1, 1024, 192, 100},
|
||||
{1, 64, 192, 100},
|
||||
{1, 192, 512, 100},
|
||||
{64, 192, 192, 2},
|
||||
{64, 1024, 192, 2},
|
||||
{64, 64, 192, 2},
|
||||
{64, 192, 512, 2},
|
||||
{128, 192, 192, 2},
|
||||
{128, 1024, 192, 2},
|
||||
{128, 64, 192, 2},
|
||||
{128, 192, 512, 2}
|
||||
};
|
||||
|
||||
class Layer_LSTM : public TestBaseWithParam<LstmParams> {};
|
||||
|
||||
PERF_TEST_P_(Layer_LSTM, lstm) {
|
||||
const LstmParams& params = GetParam();
|
||||
LayerParams lp;
|
||||
lp.type = "LSTM";
|
||||
lp.name = "testLstm";
|
||||
lp.set("produce_cell_output", false);
|
||||
lp.set("use_timestamp_dim", true);
|
||||
|
||||
Mat weightH(params.hiddenSize * 4, params.hiddenSize, CV_32FC1, cv::Scalar(0));
|
||||
Mat weightX(params.hiddenSize * 4, params.inputSize, CV_32FC1, cv::Scalar(0));
|
||||
Mat bias(params.hiddenSize * 4, 1, CV_32FC1, cv::Scalar(0));
|
||||
Mat hInternal(params.nrSteps, params.hiddenSize, CV_32FC1, cv::Scalar(0));
|
||||
Mat cInternal(params.nrSteps, params.hiddenSize, CV_32FC1, cv::Scalar(0));
|
||||
lp.blobs.push_back(weightH);
|
||||
lp.blobs.push_back(weightX);
|
||||
lp.blobs.push_back(bias);
|
||||
lp.blobs.push_back(hInternal);
|
||||
lp.blobs.push_back(cInternal);
|
||||
|
||||
std::vector<int> inputDims;
|
||||
inputDims.push_back(params.nrSamples);
|
||||
inputDims.push_back(params.nrSteps);
|
||||
inputDims.push_back(params.inputSize);
|
||||
Mat input(inputDims.size(), inputDims.data(), CV_32FC1);
|
||||
input = cv::Scalar(0);
|
||||
|
||||
Net net;
|
||||
net.addLayerToPrev(lp.name, lp.type, lp);
|
||||
net.setInput(input);
|
||||
|
||||
// Warm up
|
||||
std::vector<Mat> outputs(2);
|
||||
net.forward(outputs, "testLstm");
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
net.forward(outputs, "testLstm");
|
||||
}
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Layer_LSTM, testing::ValuesIn(testLstmConfigs));
|
||||
|
||||
} // namespace
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <google/protobuf/message.h>
|
||||
#include <google/protobuf/text_format.h>
|
||||
#include <google/protobuf/io/zero_copy_stream_impl.h>
|
||||
#include <google/protobuf/reflection.h>
|
||||
#include "caffe_io.hpp"
|
||||
#endif
|
||||
|
||||
@@ -57,8 +58,7 @@ namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
|
||||
#ifdef HAVE_PROTOBUF
|
||||
using ::google::protobuf::RepeatedField;
|
||||
using ::google::protobuf::RepeatedPtrField;
|
||||
using ::google::protobuf::RepeatedFieldRef;
|
||||
using ::google::protobuf::Message;
|
||||
using ::google::protobuf::Descriptor;
|
||||
using ::google::protobuf::FieldDescriptor;
|
||||
@@ -136,7 +136,7 @@ public:
|
||||
|
||||
#define SET_UP_FILED(getter, arrayConstr, gtype) \
|
||||
if (isRepeated) { \
|
||||
const RepeatedField<gtype> &v = refl->GetRepeatedField<gtype>(msg, field); \
|
||||
const RepeatedFieldRef<gtype> v = refl->GetRepeatedFieldRef<gtype>(msg, field); \
|
||||
params.set(name, DictValue::arrayConstr(v.begin(), (int)v.size())); \
|
||||
} \
|
||||
else { \
|
||||
@@ -168,7 +168,7 @@ public:
|
||||
break;
|
||||
case FieldDescriptor::CPPTYPE_STRING:
|
||||
if (isRepeated) {
|
||||
const RepeatedPtrField<std::string> &v = refl->GetRepeatedPtrField<std::string>(msg, field);
|
||||
const RepeatedFieldRef<std::string> v = refl->GetRepeatedFieldRef<std::string>(msg, field);
|
||||
params.set(name, DictValue::arrayString(v.begin(), (int)v.size()));
|
||||
}
|
||||
else {
|
||||
|
||||
+146
-95
@@ -247,8 +247,6 @@ std::vector<Target> getAvailableTargets(Backend be)
|
||||
|
||||
namespace
|
||||
{
|
||||
typedef std::vector<MatShape> ShapesVec;
|
||||
|
||||
struct LayerShapes
|
||||
{
|
||||
ShapesVec in, out, internal;
|
||||
@@ -597,29 +595,26 @@ struct DataLayer : public Layer
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
|
||||
// FIXIT: add wrapper without exception suppression
|
||||
CV_OCL_RUN(IS_DNN_OPENCL_TARGET(preferableTarget),
|
||||
forward_ocl(inputs_arr, outputs_arr, internals_arr))
|
||||
|
||||
if (outputs_arr.depth() == CV_16S)
|
||||
{
|
||||
forward_fallback(inputs_arr, outputs_arr, internals_arr);
|
||||
return;
|
||||
}
|
||||
bool isFP16 = outputs_arr.depth() == CV_16S;
|
||||
|
||||
std::vector<Mat> outputs, internals;
|
||||
outputs_arr.getMatVector(outputs);
|
||||
internals_arr.getMatVector(internals);
|
||||
|
||||
// Supported modes:
|
||||
// | Input type | Output type |
|
||||
// | fp32 | fp32 |
|
||||
// | uint8 | fp32 |
|
||||
for (int i = 0; i < inputsData.size(); ++i)
|
||||
{
|
||||
double scale = scaleFactors[i];
|
||||
Scalar& mean = means[i];
|
||||
|
||||
CV_Assert(mean == Scalar() || inputsData[i].size[1] <= 4);
|
||||
CV_CheckTypeEQ(outputs[i].type(), CV_32FC1, "");
|
||||
if (isFP16)
|
||||
CV_CheckTypeEQ(outputs[i].type(), CV_16SC1, "");
|
||||
else
|
||||
CV_CheckTypeEQ(outputs[i].type(), CV_32FC1, "");
|
||||
|
||||
bool singleMean = true;
|
||||
for (int j = 1; j < std::min(4, inputsData[i].size[1]) && singleMean; ++j)
|
||||
@@ -629,34 +624,49 @@ struct DataLayer : public Layer
|
||||
|
||||
if (singleMean)
|
||||
{
|
||||
inputsData[i].convertTo(outputs[i], CV_32F, scale, -mean[0] * scale);
|
||||
if (isFP16)
|
||||
{
|
||||
Mat input_f32;
|
||||
inputsData[i].convertTo(input_f32, CV_32F, scale, -mean[0] * scale);
|
||||
convertFp16(input_f32, outputs[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
inputsData[i].convertTo(outputs[i], CV_32F, scale, -mean[0] * scale);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int n = 0; n < inputsData[i].size[0]; ++n)
|
||||
{
|
||||
for (int c = 0; c < inputsData[i].size[1]; ++c)
|
||||
{
|
||||
Mat inp = getPlane(inputsData[i], n, c);
|
||||
Mat out = getPlane(outputs[i], n, c);
|
||||
inp.convertTo(out, CV_32F, scale, -mean[c] * scale);
|
||||
if (isFP16)
|
||||
{
|
||||
Mat input_f32;
|
||||
inp.convertTo(input_f32, CV_32F, scale, -mean[c] * scale);
|
||||
convertFp16(input_f32, out);
|
||||
}
|
||||
else
|
||||
{
|
||||
inp.convertTo(out, CV_32F, scale, -mean[c] * scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
std::vector<Mat> tmp_expressions;
|
||||
bool forward_ocl(InputArrayOfArrays, OutputArrayOfArrays outputs_, OutputArrayOfArrays internals_)
|
||||
{
|
||||
// Supported modes:
|
||||
// | Input type | Output type |
|
||||
// | fp32 | fp32 |
|
||||
// | fp32 | fp16 |
|
||||
// | uint8 | fp32 |
|
||||
bool isFP16 = outputs_.depth() == CV_16S;
|
||||
|
||||
std::vector<UMat> outputs;
|
||||
outputs_.getUMatVector(outputs);
|
||||
|
||||
tmp_expressions.clear();
|
||||
for (int i = 0; i < inputsData.size(); ++i)
|
||||
{
|
||||
Mat inputData = inputsData[i];
|
||||
@@ -664,58 +674,55 @@ struct DataLayer : public Layer
|
||||
double scale = scaleFactors[i];
|
||||
Scalar& mean = means[i];
|
||||
|
||||
CV_Assert(mean == Scalar() || inputsData[i].size[1] <= 4);
|
||||
CV_Assert(mean == Scalar() || inputData.size[1] <= 4);
|
||||
if (isFP16)
|
||||
CV_CheckTypeEQ(outputs[i].type(), CV_16SC1, "");
|
||||
else
|
||||
CV_CheckTypeEQ(outputs[i].type(), CV_32FC1, "");
|
||||
|
||||
bool singleMean = true;
|
||||
for (int j = 1; j < std::min(4, inputsData[i].size[1]) && singleMean; ++j)
|
||||
for (int j = 1; j < std::min(4, inputData.size[1]) && singleMean; ++j)
|
||||
{
|
||||
singleMean = mean[j] == mean[j - 1];
|
||||
}
|
||||
|
||||
if (outputs_.depth() == CV_16S)
|
||||
if (singleMean)
|
||||
{
|
||||
if (singleMean)
|
||||
if (isFP16)
|
||||
{
|
||||
tmp_expressions.push_back(Mat(scale * (inputsData[i] - mean[0])));
|
||||
convertFp16(tmp_expressions.back(), outputs[i]);
|
||||
UMat input_i;
|
||||
inputData.convertTo(input_i, CV_32F, scale, -mean[0] * scale);
|
||||
convertFp16(input_i, outputs[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int n = 0; n < inputsData[i].size[0]; ++n)
|
||||
for (int c = 0; c < inputsData[i].size[1]; ++c)
|
||||
{
|
||||
Mat inp = getPlane(inputsData[i], n, c);
|
||||
|
||||
std::vector<cv::Range> plane(4, Range::all());
|
||||
plane[0] = Range(n, n + 1);
|
||||
plane[1] = Range(c, c + 1);
|
||||
UMat out = outputs[i](plane).reshape(1, inp.dims, inp.size);
|
||||
|
||||
tmp_expressions.push_back(scale * (inp - mean[c]));
|
||||
convertFp16(tmp_expressions.back(), out);
|
||||
}
|
||||
inputData.convertTo(outputs[i], CV_32F, scale, -mean[0] * scale);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(outputs_.depth() == CV_32F);
|
||||
if (singleMean)
|
||||
for (int n = 0; n < inputData.size[0]; ++n)
|
||||
{
|
||||
inputsData[i].convertTo(outputs[i], CV_32F, scale, -mean[0] * scale);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int n = 0; n < inputsData[i].size[0]; ++n)
|
||||
for (int c = 0; c < inputsData[i].size[1]; ++c)
|
||||
for (int c = 0; c < inputData.size[1]; ++c)
|
||||
{
|
||||
Mat inp = getPlane(inputData, n, c);
|
||||
|
||||
std::vector<cv::Range> plane(4, Range::all());
|
||||
plane[0] = Range(n, n + 1);
|
||||
plane[1] = Range(c, c + 1);
|
||||
UMat out = outputs[i](plane).reshape(1, inp.dims, inp.size);
|
||||
|
||||
if (isFP16)
|
||||
{
|
||||
UMat input_i;
|
||||
inp.convertTo(input_i, CV_32F, scale, -mean[c] * scale);
|
||||
convertFp16(input_i, out);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat inp = getPlane(inputsData[i], n, c);
|
||||
|
||||
std::vector<cv::Range> plane(4, Range::all());
|
||||
plane[0] = Range(n, n + 1);
|
||||
plane[1] = Range(c, c + 1);
|
||||
UMat out = outputs[i](plane).reshape(1, inp.dims, inp.size);
|
||||
|
||||
inp.convertTo(out, CV_32F, scale, -mean[c] * scale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1330,6 +1337,11 @@ struct Net::Impl : public detail::NetImplBase
|
||||
#endif
|
||||
clear();
|
||||
|
||||
if (hasDynamicShapes)
|
||||
{
|
||||
updateLayersShapes();
|
||||
}
|
||||
|
||||
this->blobsToKeep = blobsToKeep_;
|
||||
|
||||
allocateLayers(blobsToKeep_);
|
||||
@@ -2972,20 +2984,24 @@ struct Net::Impl : public detail::NetImplBase
|
||||
|
||||
void getLayerShapesRecursively(int id, LayersShapesMap& inOutShapes)
|
||||
{
|
||||
std::vector<LayerPin>& inputLayerIds = layers[id].inputBlobsId;
|
||||
CV_CheckGE(id, 0, "");
|
||||
CV_CheckLT(id, (int)layers.size(), "");
|
||||
LayerData& layerData = layers[id];
|
||||
std::vector<LayerPin>& inputLayerIds = layerData.inputBlobsId;
|
||||
LayerShapes& layerShapes = inOutShapes[id];
|
||||
|
||||
if (id == 0 && inOutShapes[id].in[0].empty())
|
||||
if (id == 0 && layerShapes.in[0].empty())
|
||||
{
|
||||
if (!layers[0].outputBlobs.empty())
|
||||
if (!layerData.outputBlobs.empty())
|
||||
{
|
||||
ShapesVec shapes;
|
||||
for (int i = 0; i < layers[0].outputBlobs.size(); i++)
|
||||
for (int i = 0; i < layerData.outputBlobs.size(); i++)
|
||||
{
|
||||
Mat& inp = layers[0].outputBlobs[i];
|
||||
CV_Assert(inp.total());
|
||||
Mat& inp = layerData.outputBlobs[i];
|
||||
CV_Assert(!inp.empty());
|
||||
shapes.push_back(shape(inp));
|
||||
}
|
||||
inOutShapes[0].in = shapes;
|
||||
layerShapes.in = shapes;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -3001,17 +3017,17 @@ struct Net::Impl : public detail::NetImplBase
|
||||
}
|
||||
if (none)
|
||||
{
|
||||
inOutShapes[0].out.clear();
|
||||
layerShapes.out.clear();
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
inOutShapes[0].in = inputShapes;
|
||||
layerShapes.in = inputShapes;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (inOutShapes[id].in.empty())
|
||||
if (layerShapes.in.empty())
|
||||
{
|
||||
for(int i = 0; i < inputLayerIds.size(); i++)
|
||||
{
|
||||
@@ -3024,14 +3040,14 @@ struct Net::Impl : public detail::NetImplBase
|
||||
getLayerShapesRecursively(layerId, inOutShapes);
|
||||
}
|
||||
const MatShape& shape = inOutShapes[layerId].out[inputLayerIds[i].oid];
|
||||
inOutShapes[id].in.push_back(shape);
|
||||
layerShapes.in.push_back(shape);
|
||||
}
|
||||
}
|
||||
const ShapesVec& is = inOutShapes[id].in;
|
||||
ShapesVec& os = inOutShapes[id].out;
|
||||
ShapesVec& ints = inOutShapes[id].internal;
|
||||
int requiredOutputs = layers[id].requiredOutputs.size();
|
||||
Ptr<Layer> l = layers[id].getLayerInstance();
|
||||
const ShapesVec& is = layerShapes.in;
|
||||
ShapesVec& os = layerShapes.out;
|
||||
ShapesVec& ints = layerShapes.internal;
|
||||
int requiredOutputs = layerData.requiredOutputs.size();
|
||||
Ptr<Layer> l = layerData.getLayerInstance();
|
||||
CV_Assert(l);
|
||||
bool layerSupportInPlace = false;
|
||||
try
|
||||
@@ -3059,13 +3075,38 @@ struct Net::Impl : public detail::NetImplBase
|
||||
CV_LOG_ERROR(NULL, "Exception message: " << e.what());
|
||||
throw;
|
||||
}
|
||||
inOutShapes[id].supportInPlace = layerSupportInPlace;
|
||||
layerShapes.supportInPlace = layerSupportInPlace;
|
||||
|
||||
for (int i = 0; i < ints.size(); i++)
|
||||
CV_Assert(total(ints[i]) > 0);
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < ints.size(); i++)
|
||||
CV_CheckGT(total(ints[i]), 0, "");
|
||||
|
||||
for (int i = 0; i < os.size(); i++)
|
||||
CV_Assert(total(os[i]) > 0);
|
||||
for (int i = 0; i < os.size(); i++)
|
||||
CV_CheckGT(total(os[i]), 0, "");
|
||||
}
|
||||
catch (const cv::Exception& e)
|
||||
{
|
||||
CV_LOG_ERROR(NULL, "OPENCV/DNN: [" << l->type << "]:(" << l->name << "): getMemoryShapes() post validation failed." <<
|
||||
" inputs=" << is.size() <<
|
||||
" outputs=" << os.size() << "/" << requiredOutputs <<
|
||||
" blobs=" << l->blobs.size() <<
|
||||
" inplace=" << layerSupportInPlace);
|
||||
for (size_t i = 0; i < is.size(); ++i)
|
||||
{
|
||||
CV_LOG_ERROR(NULL, " input[" << i << "] = " << toString(is[i]));
|
||||
}
|
||||
for (size_t i = 0; i < os.size(); ++i)
|
||||
{
|
||||
CV_LOG_ERROR(NULL, " output[" << i << "] = " << toString(os[i]));
|
||||
}
|
||||
for (size_t i = 0; i < l->blobs.size(); ++i)
|
||||
{
|
||||
CV_LOG_ERROR(NULL, " blobs[" << i << "] = " << typeToString(l->blobs[i].type()) << " " << toString(shape(l->blobs[i])));
|
||||
}
|
||||
CV_LOG_ERROR(NULL, "Exception message: " << e.what());
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void getLayersShapes(const ShapesVec& netInputShapes,
|
||||
@@ -3093,42 +3134,57 @@ struct Net::Impl : public detail::NetImplBase
|
||||
|
||||
void updateLayersShapes()
|
||||
{
|
||||
CV_Assert(!layers[0].outputBlobs.empty());
|
||||
CV_LOG_DEBUG(NULL, "updateLayersShapes() with layers.size=" << layers.size());
|
||||
CV_Assert(netInputLayer);
|
||||
DataLayer& inputLayer = *netInputLayer;
|
||||
LayerData& inputLayerData = layers[0];
|
||||
CV_Assert(inputLayerData.layerInstance.get() == &inputLayer);
|
||||
CV_Assert(!inputLayerData.outputBlobs.empty());
|
||||
ShapesVec inputShapes;
|
||||
for(int i = 0; i < layers[0].outputBlobs.size(); i++)
|
||||
for(int i = 0; i < inputLayerData.outputBlobs.size(); i++)
|
||||
{
|
||||
Mat& inp = layers[0].outputBlobs[i];
|
||||
CV_Assert(inp.total());
|
||||
if (preferableBackend == DNN_BACKEND_OPENCV &&
|
||||
Mat& inp = inputLayerData.outputBlobs[i];
|
||||
CV_Assert(!inp.empty());
|
||||
if (preferableBackend == DNN_BACKEND_OPENCV && // FIXIT: wrong place for output allocation
|
||||
preferableTarget == DNN_TARGET_OPENCL_FP16)
|
||||
{
|
||||
layers[0].outputBlobs[i].create(inp.dims, inp.size, CV_16S);
|
||||
inp.create(inp.dims, inp.size, CV_16S);
|
||||
}
|
||||
inputShapes.push_back(shape(inp));
|
||||
}
|
||||
CV_LOG_DEBUG(NULL, toString(inputShapes, "Network input shapes"));
|
||||
LayersShapesMap layersShapes;
|
||||
layersShapes[0].in = inputShapes;
|
||||
for (MapIdToLayerData::iterator it = layers.begin();
|
||||
it != layers.end(); it++)
|
||||
{
|
||||
int layerId = it->first;
|
||||
std::vector<LayerPin>& inputLayerIds = it->second.inputBlobsId;
|
||||
if (layersShapes[layerId].in.empty())
|
||||
LayerData& layerData = it->second;
|
||||
std::vector<LayerPin>& inputLayerIds = layerData.inputBlobsId;
|
||||
LayerShapes& layerShapes = layersShapes[layerId];
|
||||
CV_LOG_DEBUG(NULL, "layer " << layerId << ": [" << layerData.type << "]:(" << layerData.name << ") with inputs.size=" << inputLayerIds.size());
|
||||
if (layerShapes.in.empty())
|
||||
{
|
||||
for(int i = 0; i < inputLayerIds.size(); i++)
|
||||
{
|
||||
int inputLayerId = inputLayerIds[i].lid;
|
||||
const LayerPin& inputPin = inputLayerIds[i];
|
||||
int inputLayerId = inputPin.lid;
|
||||
CV_LOG_DEBUG(NULL, " input[" << i << "] " << inputLayerId << ":" << inputPin.oid << " as [" << layers[inputLayerId].type << "]:(" << layers[inputLayerId].name << ")");
|
||||
LayersShapesMap::iterator inputIt = layersShapes.find(inputLayerId);
|
||||
if(inputIt == layersShapes.end() || inputIt->second.out.empty())
|
||||
if (inputIt == layersShapes.end() || inputIt->second.out.empty())
|
||||
{
|
||||
getLayerShapesRecursively(inputLayerId, layersShapes);
|
||||
}
|
||||
const MatShape& shape = layersShapes[inputLayerId].out[inputLayerIds[i].oid];
|
||||
layersShapes[layerId].in.push_back(shape);
|
||||
const MatShape& shape = layersShapes[inputLayerId].out[inputPin.oid];
|
||||
layerShapes.in.push_back(shape);
|
||||
}
|
||||
it->second.layerInstance->updateMemoryShapes(layersShapes[layerId].in);
|
||||
layerData.layerInstance->updateMemoryShapes(layerShapes.in);
|
||||
}
|
||||
CV_LOG_DEBUG(NULL, "Layer " << layerId << ": " << toString(layerShapes.in, "input shapes"));
|
||||
CV_LOG_IF_DEBUG(NULL, !layerShapes.out.empty(), "Layer " << layerId << ": " << toString(layerShapes.out, "output shapes"));
|
||||
CV_LOG_IF_DEBUG(NULL, !layerShapes.internal.empty(), "Layer " << layerId << ": " << toString(layerShapes.internal, "internal shapes"));
|
||||
}
|
||||
CV_LOG_DEBUG(NULL, "updateLayersShapes() - DONE");
|
||||
}
|
||||
|
||||
LayerPin getLatestLayerPin(const std::vector<LayerPin>& pins)
|
||||
@@ -3877,13 +3933,8 @@ void Net::setInput(InputArray blob, const String& name, double scalefactor, cons
|
||||
bool oldShape = prevShape == blobShape;
|
||||
|
||||
blob_.copyTo(impl->netInputLayer->inputsData[pin.oid]);
|
||||
if (!oldShape) {
|
||||
if (!oldShape)
|
||||
ld.outputBlobs[pin.oid] = impl->netInputLayer->inputsData[pin.oid];
|
||||
if (impl->hasDynamicShapes)
|
||||
{
|
||||
impl->updateLayersShapes();
|
||||
}
|
||||
}
|
||||
|
||||
if (!ld.outputBlobsWrappers[pin.oid].empty())
|
||||
{
|
||||
|
||||
@@ -29,6 +29,43 @@ struct NetImplBase
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
||||
typedef std::vector<MatShape> ShapesVec;
|
||||
|
||||
static inline std::string toString(const ShapesVec& shapes, const std::string& name = std::string())
|
||||
{
|
||||
std::ostringstream ss;
|
||||
if (!name.empty())
|
||||
ss << name << ' ';
|
||||
ss << '[';
|
||||
for(size_t i = 0, n = shapes.size(); i < n; ++i)
|
||||
ss << ' ' << toString(shapes[i]);
|
||||
ss << " ]";
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static inline std::string toString(const Mat& blob, const std::string& name = std::string())
|
||||
{
|
||||
std::ostringstream ss;
|
||||
if (!name.empty())
|
||||
ss << name << ' ';
|
||||
if (blob.empty())
|
||||
{
|
||||
ss << "<empty>";
|
||||
}
|
||||
else if (blob.dims == 1)
|
||||
{
|
||||
Mat blob_ = blob;
|
||||
blob_.dims = 2; // hack
|
||||
ss << blob_.t();
|
||||
}
|
||||
else
|
||||
{
|
||||
ss << blob.reshape(1, 1);
|
||||
}
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}} // namespace
|
||||
|
||||
|
||||
@@ -500,16 +500,9 @@ struct ReLU6Functor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return 2; }
|
||||
};
|
||||
|
||||
struct TanHFunctor : public BaseFunctor
|
||||
template <class T>
|
||||
struct BaseDefaultFunctor : public BaseFunctor
|
||||
{
|
||||
typedef TanHLayer Layer;
|
||||
|
||||
bool supportBackend(int backendId, int)
|
||||
{
|
||||
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE ||
|
||||
backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
{
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
@@ -517,7 +510,7 @@ struct TanHFunctor : public BaseFunctor
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = tanh(x);
|
||||
dstptr[i] = static_cast<T const*>(this)->calculate(x);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -537,10 +530,11 @@ struct TanHFunctor : public BaseFunctor
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("TanHForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
ocl::Kernel kernel(ocl_kernel_name, ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, static_cast<int>(src.total()));
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
static_cast<T const*>(this)->setKernelParams(kernel);
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
@@ -550,6 +544,41 @@ struct TanHFunctor : public BaseFunctor
|
||||
}
|
||||
#endif
|
||||
|
||||
inline void setKernelParams(ocl::Kernel& kernel) const {}
|
||||
|
||||
#ifdef HAVE_DNN_IE_NN_BUILDER_2019
|
||||
InferenceEngine::Builder::Layer initInfEngineBuilderAPI()
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
}
|
||||
#endif // HAVE_DNN_IE_NN_BUILDER_2019
|
||||
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
}
|
||||
#endif // HAVE_DNN_NGRAPH
|
||||
|
||||
private:
|
||||
static const char* const ocl_kernel_name;
|
||||
};
|
||||
|
||||
struct TanHFunctor : public BaseDefaultFunctor<TanHFunctor>
|
||||
{
|
||||
typedef TanHLayer Layer;
|
||||
|
||||
bool supportBackend(int backendId, int)
|
||||
{
|
||||
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE ||
|
||||
backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
return tanh(x);
|
||||
}
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
{
|
||||
@@ -575,56 +604,24 @@ struct TanHFunctor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return 1; }
|
||||
};
|
||||
|
||||
struct SwishFunctor : public BaseFunctor
|
||||
template<>
|
||||
const char* const TanHFunctor::BaseDefaultFunctor<TanHFunctor>::ocl_kernel_name = "TanHForward";
|
||||
|
||||
struct SwishFunctor : public BaseDefaultFunctor<SwishFunctor>
|
||||
{
|
||||
typedef SwishLayer Layer;
|
||||
|
||||
bool supportBackend(int backendId, int)
|
||||
{
|
||||
return backendId == DNN_BACKEND_OPENCV ||
|
||||
backendId == DNN_BACKEND_HALIDE || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;;
|
||||
backendId == DNN_BACKEND_HALIDE || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = x / (1.0f + exp(-x));
|
||||
}
|
||||
}
|
||||
return x / (1.f + exp(-x));
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool applyOCL(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
|
||||
{
|
||||
std::vector<UMat> inputs;
|
||||
std::vector<UMat> outputs;
|
||||
|
||||
inps.getUMatVector(inputs);
|
||||
outs.getUMatVector(outputs);
|
||||
String buildopt = oclGetTMacro(inputs[0]);
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("SwishForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
{
|
||||
@@ -633,13 +630,6 @@ struct SwishFunctor : public BaseFunctor
|
||||
}
|
||||
#endif // HAVE_HALIDE
|
||||
|
||||
#ifdef HAVE_DNN_IE_NN_BUILDER_2019
|
||||
InferenceEngine::Builder::Layer initInfEngineBuilderAPI()
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
}
|
||||
#endif // HAVE_DNN_IE_NN_BUILDER_2019
|
||||
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
@@ -651,7 +641,10 @@ struct SwishFunctor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return 3; }
|
||||
};
|
||||
|
||||
struct MishFunctor : public BaseFunctor
|
||||
template<>
|
||||
const char* const SwishFunctor::BaseDefaultFunctor<SwishFunctor>::ocl_kernel_name = "SwishForward";
|
||||
|
||||
struct MishFunctor : public BaseDefaultFunctor<MishFunctor>
|
||||
{
|
||||
typedef MishLayer Layer;
|
||||
|
||||
@@ -661,53 +654,18 @@ struct MishFunctor : public BaseFunctor
|
||||
backendId == DNN_BACKEND_HALIDE || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
// Use fast approximation introduced in https://github.com/opencv/opencv/pull/17200
|
||||
if (x >= 8.f)
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
// Use fast approximation introduced in https://github.com/opencv/opencv/pull/17200
|
||||
float x = srcptr[i];
|
||||
if (x >= 8.f)
|
||||
dstptr[i] = x;
|
||||
else
|
||||
{
|
||||
float eX = exp(x);
|
||||
float n = (eX + 2) * eX;
|
||||
dstptr[i] = (x * n) / (n + 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool applyOCL(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
|
||||
{
|
||||
std::vector<UMat> inputs;
|
||||
std::vector<UMat> outputs;
|
||||
|
||||
inps.getUMatVector(inputs);
|
||||
outs.getUMatVector(outputs);
|
||||
String buildopt = oclGetTMacro(inputs[0]);
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("MishForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
return x;
|
||||
}
|
||||
|
||||
return true;
|
||||
float eX = exp(x);
|
||||
float n = (eX + 2.f) * eX;
|
||||
return (x * n) / (n + 2.f);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
@@ -717,13 +675,6 @@ struct MishFunctor : public BaseFunctor
|
||||
}
|
||||
#endif // HAVE_HALIDE
|
||||
|
||||
#ifdef HAVE_DNN_IE_NN_BUILDER_2019
|
||||
InferenceEngine::Builder::Layer initInfEngineBuilderAPI()
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
}
|
||||
#endif // HAVE_DNN_IE_NN_BUILDER_2019
|
||||
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
@@ -740,7 +691,10 @@ struct MishFunctor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return 3; }
|
||||
};
|
||||
|
||||
struct SigmoidFunctor : public BaseFunctor
|
||||
template<>
|
||||
const char* const MishFunctor::BaseDefaultFunctor<MishFunctor>::ocl_kernel_name = "MishForward";
|
||||
|
||||
struct SigmoidFunctor : public BaseDefaultFunctor<SigmoidFunctor>
|
||||
{
|
||||
typedef SigmoidLayer Layer;
|
||||
|
||||
@@ -750,46 +704,11 @@ struct SigmoidFunctor : public BaseFunctor
|
||||
backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = 1.f/(1.f + exp(-x));
|
||||
}
|
||||
}
|
||||
return 1.f / (1.f + exp(-x));
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool applyOCL(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
|
||||
{
|
||||
std::vector<UMat> inputs;
|
||||
std::vector<UMat> outputs;
|
||||
|
||||
inps.getUMatVector(inputs);
|
||||
outs.getUMatVector(outputs);
|
||||
String buildopt = oclGetTMacro(inputs[0]);
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("SigmoidForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
{
|
||||
@@ -815,9 +734,15 @@ struct SigmoidFunctor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return 3; }
|
||||
};
|
||||
|
||||
struct ELUFunctor : public BaseFunctor
|
||||
template<>
|
||||
const char* const SigmoidFunctor::BaseDefaultFunctor<SigmoidFunctor>::ocl_kernel_name = "SigmoidForward";
|
||||
|
||||
struct ELUFunctor : public BaseDefaultFunctor<ELUFunctor>
|
||||
{
|
||||
typedef ELULayer Layer;
|
||||
float alpha;
|
||||
|
||||
explicit ELUFunctor(float alpha_ = 1.f) : alpha(alpha_) {}
|
||||
|
||||
bool supportBackend(int backendId, int)
|
||||
{
|
||||
@@ -825,51 +750,21 @@ struct ELUFunctor : public BaseFunctor
|
||||
backendId == DNN_BACKEND_INFERENCE_ENGINE_NN_BUILDER_2019 || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
{
|
||||
for(int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = x >= 0.f ? x : exp(x) - 1;
|
||||
}
|
||||
}
|
||||
return x >= 0.f ? x : alpha * (exp(x) - 1.f);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool applyOCL(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
|
||||
inline void setKernelParams(ocl::Kernel& kernel) const
|
||||
{
|
||||
std::vector<UMat> inputs;
|
||||
std::vector<UMat> outputs;
|
||||
|
||||
inps.getUMatVector(inputs);
|
||||
outs.getUMatVector(outputs);
|
||||
String buildopt = oclGetTMacro(inputs[0]);
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("ELUForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
}
|
||||
|
||||
return true;
|
||||
kernel.set(3, alpha);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
{
|
||||
Halide::Var x("x"), y("y"), c("c"), n("n");
|
||||
top(x, y, c, n) = select(input >= 0.0f, input, exp(input) - 1);
|
||||
top(x, y, c, n) = select(input >= 0.0f, input, alpha * (exp(input) - 1));
|
||||
}
|
||||
#endif // HAVE_HALIDE
|
||||
|
||||
@@ -883,14 +778,17 @@ struct ELUFunctor : public BaseFunctor
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
return std::make_shared<ngraph::op::Elu>(node, 1.0);
|
||||
return std::make_shared<ngraph::op::Elu>(node, alpha);
|
||||
}
|
||||
#endif // HAVE_DNN_NGRAPH
|
||||
|
||||
int64 getFLOPSPerElement() const { return 2; }
|
||||
};
|
||||
|
||||
struct AbsValFunctor : public BaseFunctor
|
||||
template<>
|
||||
const char* const ELUFunctor::BaseDefaultFunctor<ELUFunctor>::ocl_kernel_name = "ELUForward";
|
||||
|
||||
struct AbsValFunctor : public BaseDefaultFunctor<AbsValFunctor>
|
||||
{
|
||||
typedef AbsLayer Layer;
|
||||
|
||||
@@ -903,46 +801,11 @@ struct AbsValFunctor : public BaseFunctor
|
||||
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = abs(x);
|
||||
}
|
||||
}
|
||||
return abs(x);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool applyOCL(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
|
||||
{
|
||||
std::vector<UMat> inputs;
|
||||
std::vector<UMat> outputs;
|
||||
|
||||
inps.getUMatVector(inputs);
|
||||
outs.getUMatVector(outputs);
|
||||
String buildopt = oclGetTMacro(inputs[0]);
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("AbsValForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
{
|
||||
@@ -971,7 +834,10 @@ struct AbsValFunctor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return 1; }
|
||||
};
|
||||
|
||||
struct BNLLFunctor : public BaseFunctor
|
||||
template<>
|
||||
const char* const AbsValFunctor::BaseDefaultFunctor<AbsValFunctor>::ocl_kernel_name = "AbsValForward";
|
||||
|
||||
struct BNLLFunctor : public BaseDefaultFunctor<BNLLFunctor>
|
||||
{
|
||||
typedef BNLLLayer Layer;
|
||||
|
||||
@@ -980,47 +846,12 @@ struct BNLLFunctor : public BaseFunctor
|
||||
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
// https://github.com/BVLC/caffe/blame/1.0/src/caffe/layers/bnll_layer.cpp#L17
|
||||
dstptr[i] = x > 0 ? x + log(1. + exp(-x)) : log(1. + exp(x));
|
||||
}
|
||||
}
|
||||
// https://github.com/BVLC/caffe/blame/1.0/src/caffe/layers/bnll_layer.cpp#L17
|
||||
return x > 0 ? x + log(1.f + exp(-x)) : log(1.f + exp(x));
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool applyOCL(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
|
||||
{
|
||||
std::vector<UMat> inputs;
|
||||
std::vector<UMat> outputs;
|
||||
|
||||
inps.getUMatVector(inputs);
|
||||
outs.getUMatVector(outputs);
|
||||
String buildopt = oclGetTMacro(inputs[0]);
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("BNLLForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
{
|
||||
@@ -1030,23 +861,12 @@ struct BNLLFunctor : public BaseFunctor
|
||||
}
|
||||
#endif // HAVE_HALIDE
|
||||
|
||||
#ifdef HAVE_DNN_IE_NN_BUILDER_2019
|
||||
InferenceEngine::Builder::Layer initInfEngineBuilderAPI()
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
}
|
||||
#endif // HAVE_DNN_IE_NN_BUILDER_2019
|
||||
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
}
|
||||
#endif // HAVE_DNN_NGRAPH
|
||||
|
||||
int64 getFLOPSPerElement() const { return 5; }
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* const BNLLFunctor::BaseDefaultFunctor<BNLLFunctor>::ocl_kernel_name = "BNLLForward";
|
||||
|
||||
struct PowerFunctor : public BaseFunctor
|
||||
{
|
||||
typedef PowerLayer Layer;
|
||||
@@ -1206,7 +1026,7 @@ struct PowerFunctor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return power == 1 ? 2 : 10; }
|
||||
};
|
||||
|
||||
struct ExpFunctor : public BaseFunctor
|
||||
struct ExpFunctor : public BaseDefaultFunctor<ExpFunctor>
|
||||
{
|
||||
typedef ExpLayer Layer;
|
||||
float base, scale, shift;
|
||||
@@ -1232,47 +1052,16 @@ struct ExpFunctor : public BaseFunctor
|
||||
backendId == DNN_BACKEND_HALIDE || backendId == DNN_BACKEND_INFERENCE_ENGINE_NGRAPH;
|
||||
}
|
||||
|
||||
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
|
||||
inline float calculate(float x) const
|
||||
{
|
||||
float a = normScale, b = normShift;
|
||||
for( int cn = cn0; cn < cn1; cn++, srcptr += planeSize, dstptr += planeSize )
|
||||
{
|
||||
for( int i = 0; i < len; i++ )
|
||||
{
|
||||
float x = srcptr[i];
|
||||
dstptr[i] = exp(a*x + b);
|
||||
}
|
||||
}
|
||||
return exp(normScale * x + normShift);
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
bool applyOCL(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
|
||||
inline void setKernelParams(ocl::Kernel& kernel) const
|
||||
{
|
||||
std::vector<UMat> inputs;
|
||||
std::vector<UMat> outputs;
|
||||
|
||||
inps.getUMatVector(inputs);
|
||||
outs.getUMatVector(outputs);
|
||||
String buildopt = oclGetTMacro(inputs[0]);
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
UMat& src = inputs[i];
|
||||
UMat& dst = outputs[i];
|
||||
|
||||
ocl::Kernel kernel("ExpForward", ocl::dnn::activations_oclsrc, buildopt);
|
||||
kernel.set(0, (int)src.total());
|
||||
kernel.set(1, ocl::KernelArg::PtrReadOnly(src));
|
||||
kernel.set(2, ocl::KernelArg::PtrWriteOnly(dst));
|
||||
kernel.set(3, (float)normScale);
|
||||
kernel.set(4, (float)normShift);
|
||||
|
||||
size_t gSize = src.total();
|
||||
CV_Assert(kernel.run(1, &gSize, NULL, false));
|
||||
}
|
||||
return true;
|
||||
kernel.set(3, normScale);
|
||||
kernel.set(4, normShift);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void attachHalide(const Halide::Expr& input, Halide::Func& top)
|
||||
@@ -1282,13 +1071,6 @@ struct ExpFunctor : public BaseFunctor
|
||||
}
|
||||
#endif // HAVE_HALIDE
|
||||
|
||||
#ifdef HAVE_DNN_IE_NN_BUILDER_2019
|
||||
InferenceEngine::Builder::Layer initInfEngineBuilderAPI()
|
||||
{
|
||||
CV_Error(Error::StsNotImplemented, "");
|
||||
}
|
||||
#endif // HAVE_DNN_IE_NN_BUILDER_2019
|
||||
|
||||
#ifdef HAVE_DNN_NGRAPH
|
||||
std::shared_ptr<ngraph::Node> initNgraphAPI(const std::shared_ptr<ngraph::Node>& node)
|
||||
{
|
||||
@@ -1305,6 +1087,9 @@ struct ExpFunctor : public BaseFunctor
|
||||
int64 getFLOPSPerElement() const { return 3; }
|
||||
};
|
||||
|
||||
template<>
|
||||
const char* const ExpFunctor::BaseDefaultFunctor<ExpFunctor>::ocl_kernel_name = "ExpForward";
|
||||
|
||||
struct ChannelsPReLUFunctor : public BaseFunctor
|
||||
{
|
||||
typedef ChannelsPReLULayer Layer;
|
||||
@@ -1486,8 +1271,10 @@ Ptr<SigmoidLayer> SigmoidLayer::create(const LayerParams& params)
|
||||
|
||||
Ptr<ELULayer> ELULayer::create(const LayerParams& params)
|
||||
{
|
||||
Ptr<ELULayer> l(new ElementWiseLayer<ELUFunctor>(ELUFunctor()));
|
||||
float alpha = params.get<float>("alpha", 1.0f);
|
||||
Ptr<ELULayer> l(new ElementWiseLayer<ELUFunctor>(ELUFunctor(alpha)));
|
||||
l->setParamsFrom(params);
|
||||
l->alpha = alpha;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -100,7 +100,6 @@ public:
|
||||
{
|
||||
outputShapeVec.push_back(inputs[0][i]);
|
||||
}
|
||||
CV_Assert(outputShapeVec.size() <= 4);
|
||||
|
||||
outputs.resize(inputs.size(), outputShapeVec);
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user