mirror of
https://github.com/opencv/opencv.git
synced 2026-07-21 19:33:03 +04:00
Compare commits
417 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 | |||
| b1cf550123 | |||
| 17bd9a1fa1 | |||
| 0321644bbd | |||
| 81e7988eb9 | |||
| 4985311d46 | |||
| 05348f3250 | |||
| 003609e565 | |||
| 9537a909f7 | |||
| 8c2dd5fb9a | |||
| 27545dcc86 | |||
| 724e04e979 | |||
| dfc94c58f0 | |||
| fac895d7ba | |||
| 04b40ff221 | |||
| a3d7811f24 | |||
| 755e0143fb | |||
| dfa48094dc | |||
| e585192eeb | |||
| 646924fce8 | |||
| c63aa7f085 | |||
| c54abde1bd | |||
| 95c1d2a887 | |||
| ebef84e9ea | |||
| b1a772d194 | |||
| f11f2bfb56 | |||
| 24f43e7ae9 | |||
| d94d469c86 | |||
| d20c9bde7e | |||
| 62414e3073 | |||
| 48c985e775 | |||
| 7358fffb0f | |||
| de5b6386e0 | |||
| 1de2d5c2b6 | |||
| ef53a9229f | |||
| 259c39a63a | |||
| 327b98eb13 | |||
| f977d10a19 | |||
| a0cf8c322d | |||
| 1e74f5850b | |||
| 9b76872708 | |||
| 4d587c341b | |||
| 846317ef37 | |||
| 7e62789edf | |||
| 852663f6d2 | |||
| a9b30984a3 | |||
| 2f83c3b689 | |||
| b25ad12f1a | |||
| d95e43a6a1 | |||
| 2cc14bd0fb | |||
| fdc8ed8d05 | |||
| 236c64a17d | |||
| f96569da1e | |||
| 91ff45fbde | |||
| 45aabc5d0d | |||
| f9bd83c854 | |||
| 86a51015b1 | |||
| 998406d20e | |||
| f7b4b750d8 | |||
| a4e2c56317 | |||
| 9c5d7716e2 | |||
| 46fd26e366 | |||
| c410d7a97d | |||
| 6fa63dcc0c | |||
| 96f25332ea | |||
| 3385d38648 | |||
| 1618c963e4 | |||
| 1e3be09b3b | |||
| 6e66a9222a | |||
| 9d1e8b1e1d | |||
| f605373a2b | |||
| 56b7622612 | |||
| 696a6ccd57 | |||
| 51b03b87e6 | |||
| aa7ba0bc1a | |||
| 07e4076585 | |||
| de1a459879 | |||
| 1aacb9bb15 | |||
| 9b4ecc96f6 | |||
| e3f4f874c5 | |||
| 6ace801418 | |||
| d31b93b513 | |||
| ac0fd6aa9a | |||
| 068f33cfdf | |||
| 4807cd8a6e | |||
| 35e824c287 | |||
| 1e0d290f2e | |||
| 0097a8d097 | |||
| 36cc43170d | |||
| 5578ad5e14 | |||
| d11f0a709d | |||
| 0a43b23275 | |||
| 7967683296 | |||
| 5b2c016834 | |||
| aaff125608 | |||
| 407adc7061 | |||
| d0e612dc36 | |||
| 7c23ec90a9 | |||
| 390957fec4 | |||
| 060a76dc3e | |||
| 6625810d2a | |||
| edc442afdb | |||
| 16b9514543 | |||
| 95c7f4a7f0 | |||
| ae6fabc6fe | |||
| 7eaadf616c | |||
| 8fed5fc5ae | |||
| f25951c412 | |||
| 1259a474ba | |||
| 3995deaf76 | |||
| 076587425e | |||
| da6aeaca46 | |||
| 8ee33ca551 | |||
| ea7f13922b | |||
| 38d0063c36 | |||
| df83459721 | |||
| 54a9e00970 | |||
| 9bda96d39e | |||
| 77a5c43d50 | |||
| f28e4b86fb | |||
| b675e6ab77 | |||
| d6306f8ccb | |||
| a9817e9127 | |||
| c08897cd10 | |||
| 384875f4fc | |||
| 9cfa84313c | |||
| fe625a558e | |||
| 9ef41f68fb | |||
| cfb36443fb | |||
| 9d3826c676 | |||
| 4300bb2e1f | |||
| 6edc438789 | |||
| 25cd7c7c50 | |||
| 732cb6c45c | |||
| 266a868ba9 | |||
| 8199967b31 | |||
| 9d61c18143 | |||
| 221bfa4c67 | |||
| 1a8b7f7513 | |||
| 992b47b991 | |||
| 739ff84732 | |||
| 2a177052de | |||
| f7c82baee9 | |||
| 2b34e0abdc | |||
| 633fedaa96 | |||
| 65134c793b | |||
| d5f34cf34c | |||
| cefa602601 | |||
| d773691848 | |||
| f40707dc68 | |||
| 2d8ce500fa | |||
| ddf1b04cce | |||
| ad5b3a4753 | |||
| 531ea5b3a2 | |||
| b468468e7e | |||
| cff0168f3a | |||
| d83901e665 | |||
| 1e1984a586 | |||
| 06dcc5a2c6 | |||
| 000f762fb9 | |||
| 3bc3eeb5da | |||
| 4e5699fa71 | |||
| a76274b549 | |||
| 803ff8ebb9 | |||
| b42152ffeb | |||
| 024b43ca06 | |||
| 9448fe3db4 | |||
| 3817f3a89b | |||
| 2062a7ca8f | |||
| 8334ee18e6 | |||
| cc2592f582 | |||
| 96d35f7c54 | |||
| 98c5fc6ae2 | |||
| fbde0c6c96 | |||
| 602e7c83e2 | |||
| eb9218a86b | |||
| 9f2dcc3f13 | |||
| bc210b292b | |||
| 2113af9c52 | |||
| 6f417b57c1 | |||
| 0acd06d13c | |||
| fd22e98298 | |||
| 167a12028d | |||
| 6af2faebd2 | |||
| fd16222613 | |||
| 1ba6cd8423 | |||
| 4788de784b | |||
| 926535469d | |||
| 5627a0cbdf | |||
| 9a9954a036 | |||
| 591708903b | |||
| f9d62fba7a | |||
| 9d039c206b | |||
| 4c3f9b2ef4 | |||
| 0e523618a1 | |||
| 3b26105f68 | |||
| 0f2f966a91 | |||
| d7d491d445 | |||
| 9b0d6862c4 | |||
| 890fcdf842 | |||
| 18dbac203f | |||
| 8d1f254dcc | |||
| 90df3af6cf | |||
| b699fe7a9d | |||
| b2ed5c3070 | |||
| 5b8c10f2f8 | |||
| 24983f62e2 | |||
| f2057ce1ab | |||
| 6797fd65a5 | |||
| 947e06a860 | |||
| 04d5ba266f | |||
| 90be83ae99 | |||
| 5e80bd3cc9 | |||
| db4b1e613c | |||
| 7d842f5bcf | |||
| 828304d587 | |||
| 9d584475f6 | |||
| bb60cb0bf9 | |||
| 55e1dfb778 | |||
| c2263db7bc | |||
| 7bbbda71df | |||
| 8e0baf257c | |||
| c8268e65fd | |||
| 3cf4375387 | |||
| c1adbe3189 | |||
| 7ee1816612 | |||
| 8f4f834ce6 | |||
| 411fd2b761 |
Vendored
+26
-17
@@ -1778,30 +1778,30 @@ TegraCvtColor_Invoker(bgrx2hsvf, bgrx2hsv, src_data + static_cast<size_t>(range.
|
||||
: CV_HAL_ERROR_NOT_IMPLEMENTED \
|
||||
)
|
||||
|
||||
#define TEGRA_CVT2PYUVTOBGR(src_data, src_step, dst_data, dst_step, dst_width, dst_height, dcn, swapBlue, uIdx) \
|
||||
#define TEGRA_CVT2PYUVTOBGR_EX(y_data, y_step, uv_data, uv_step, dst_data, dst_step, dst_width, dst_height, dcn, swapBlue, uIdx) \
|
||||
( \
|
||||
CAROTENE_NS::isSupportedConfiguration() ? \
|
||||
dcn == 3 ? \
|
||||
uIdx == 0 ? \
|
||||
(swapBlue ? \
|
||||
CAROTENE_NS::yuv420i2rgb(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step) : \
|
||||
CAROTENE_NS::yuv420i2bgr(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step)), \
|
||||
CV_HAL_ERROR_OK : \
|
||||
uIdx == 1 ? \
|
||||
(swapBlue ? \
|
||||
CAROTENE_NS::yuv420sp2rgb(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step) : \
|
||||
CAROTENE_NS::yuv420sp2bgr(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step)), \
|
||||
CV_HAL_ERROR_OK : \
|
||||
CV_HAL_ERROR_NOT_IMPLEMENTED : \
|
||||
@@ -1809,29 +1809,32 @@ TegraCvtColor_Invoker(bgrx2hsvf, bgrx2hsv, src_data + static_cast<size_t>(range.
|
||||
uIdx == 0 ? \
|
||||
(swapBlue ? \
|
||||
CAROTENE_NS::yuv420i2rgbx(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step) : \
|
||||
CAROTENE_NS::yuv420i2bgrx(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step)), \
|
||||
CV_HAL_ERROR_OK : \
|
||||
uIdx == 1 ? \
|
||||
(swapBlue ? \
|
||||
CAROTENE_NS::yuv420sp2rgbx(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step) : \
|
||||
CAROTENE_NS::yuv420sp2bgrx(CAROTENE_NS::Size2D(dst_width, dst_height), \
|
||||
src_data, src_step, \
|
||||
src_data + src_step * dst_height, src_step, \
|
||||
y_data, y_step, \
|
||||
uv_data, uv_step, \
|
||||
dst_data, dst_step)), \
|
||||
CV_HAL_ERROR_OK : \
|
||||
CV_HAL_ERROR_NOT_IMPLEMENTED : \
|
||||
CV_HAL_ERROR_NOT_IMPLEMENTED \
|
||||
: CV_HAL_ERROR_NOT_IMPLEMENTED \
|
||||
)
|
||||
#define TEGRA_CVT2PYUVTOBGR(src_data, src_step, dst_data, dst_step, dst_width, dst_height, dcn, swapBlue, uIdx) \
|
||||
TEGRA_CVT2PYUVTOBGR_EX(src_data, src_step, src_data + src_step * dst_height, src_step, dst_data, dst_step, \
|
||||
dst_width, dst_height, dcn, swapBlue, uIdx);
|
||||
|
||||
#undef cv_hal_cvtBGRtoBGR
|
||||
#define cv_hal_cvtBGRtoBGR TEGRA_CVTBGRTOBGR
|
||||
@@ -1841,12 +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_20210302
|
||||
# Binaries were created for OpenCV: 2ab1f3f166fccc3a01497209cc01c5cea44ff201
|
||||
ocv_update(FFMPEG_BINARIES_COMMIT "e99214251d9f3cde7c48abd46b2259bddc9885b6")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN32 "fad5ada9be36120bba8966709e7953a8")
|
||||
ocv_update(FFMPEG_FILE_HASH_BIN64 "650e2272728491923e566f784f79cfef")
|
||||
# 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
|
||||
|
||||
Vendored
+9
-5
@@ -923,6 +923,11 @@ int ovx_hal_cvtGraytoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep,
|
||||
}
|
||||
|
||||
int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx)
|
||||
{
|
||||
return ovx_hal_cvtTwoPlaneYUVtoBGREx(a, astep, a + h * astep, astep, b, bstep, w, h, bcn, swapBlue, uIdx);
|
||||
}
|
||||
|
||||
int ovx_hal_cvtTwoPlaneYUVtoBGREx(const uchar * a, size_t astep, const uchar * b, size_t bstep, uchar * c, size_t cstep, int w, int h, int bcn, bool swapBlue, int uIdx)
|
||||
{
|
||||
if (skipSmallImages<VX_KERNEL_COLOR_CONVERT>(w, h))
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
@@ -933,8 +938,7 @@ int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t
|
||||
|
||||
if (w & 1 || h & 1) // It's not described in spec but sample implementation unable to convert odd sized images
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED;
|
||||
refineStep(w, h, uIdx ? VX_DF_IMAGE_NV21 : VX_DF_IMAGE_NV12, astep);
|
||||
refineStep(w, h, bcn == 3 ? VX_DF_IMAGE_RGB : VX_DF_IMAGE_RGBX, bstep);
|
||||
|
||||
try
|
||||
{
|
||||
ivx::Context ctx = getOpenVXHALContext();
|
||||
@@ -943,8 +947,8 @@ int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t
|
||||
std::vector<void *> ptrs;
|
||||
addr.push_back(ivx::Image::createAddressing(w, h, 1, (vx_int32)astep));
|
||||
ptrs.push_back((void*)a);
|
||||
addr.push_back(ivx::Image::createAddressing(w / 2, h / 2, 2, (vx_int32)astep));
|
||||
ptrs.push_back((void*)(a + h * astep));
|
||||
addr.push_back(ivx::Image::createAddressing(w / 2, h / 2, 2, (vx_int32)bstep));
|
||||
ptrs.push_back((void*)b);
|
||||
|
||||
vxImage
|
||||
ia = ivx::Image::createFromHandle(ctx, uIdx ? VX_DF_IMAGE_NV21 : VX_DF_IMAGE_NV12, addr, ptrs);
|
||||
@@ -952,7 +956,7 @@ int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t
|
||||
return CV_HAL_ERROR_NOT_IMPLEMENTED; // OpenCV store NV12/NV21 as RANGE_RESTRICTED while OpenVX expect RANGE_FULL
|
||||
vxImage
|
||||
ib = ivx::Image::createFromHandle(ctx, bcn == 3 ? VX_DF_IMAGE_RGB : VX_DF_IMAGE_RGBX,
|
||||
ivx::Image::createAddressing(w, h, bcn, (vx_int32)bstep), b);
|
||||
ivx::Image::createAddressing(w, h, bcn, (vx_int32)cstep), c);
|
||||
ivx::IVX_CHECK_STATUS(vxuColorConvert(ctx, ia, ib));
|
||||
}
|
||||
catch (ivx::RuntimeError & e)
|
||||
|
||||
Vendored
+3
@@ -49,6 +49,7 @@ int ovx_hal_morph(cvhalFilter2D *filter_context, uchar *a, size_t astep, uchar *
|
||||
int ovx_hal_cvtBGRtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int depth, int acn, int bcn, bool swapBlue);
|
||||
int ovx_hal_cvtGraytoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int depth, int bcn);
|
||||
int ovx_hal_cvtTwoPlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx);
|
||||
int ovx_hal_cvtTwoPlaneYUVtoBGREx(const uchar * a, size_t astep, const uchar * b, size_t bstep, uchar * c, size_t cstep, int w, int h, int bcn, bool swapBlue, int uIdx);
|
||||
int ovx_hal_cvtThreePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx);
|
||||
int ovx_hal_cvtBGRtoThreePlaneYUV(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int acn, bool swapBlue, int uIdx);
|
||||
int ovx_hal_cvtOnePlaneYUVtoBGR(const uchar * a, size_t astep, uchar * b, size_t bstep, int w, int h, int bcn, bool swapBlue, int uIdx, int ycn);
|
||||
@@ -130,6 +131,8 @@ int ovx_hal_integral(int depth, int sdepth, int, const uchar * a, size_t astep,
|
||||
#define cv_hal_cvtGraytoBGR ovx_hal_cvtGraytoBGR
|
||||
#undef cv_hal_cvtTwoPlaneYUVtoBGR
|
||||
#define cv_hal_cvtTwoPlaneYUVtoBGR ovx_hal_cvtTwoPlaneYUVtoBGR
|
||||
#undef cv_hal_cvtTwoPlaneYUVtoBGREx
|
||||
#define cv_hal_cvtTwoPlaneYUVtoBGREx ovx_hal_cvtTwoPlaneYUVtoBGREx
|
||||
#undef cv_hal_cvtThreePlaneYUVtoBGR
|
||||
#define cv_hal_cvtThreePlaneYUVtoBGR ovx_hal_cvtThreePlaneYUVtoBGR
|
||||
#undef cv_hal_cvtBGRtoThreePlaneYUV
|
||||
|
||||
Vendored
+4
-2
@@ -31,7 +31,7 @@ libpng Portable Network Graphics library.
|
||||
libtiff Tag Image File Format (TIFF) Software
|
||||
Copyright (c) 1988-1997 Sam Leffler
|
||||
Copyright (c) 1991-1997 Silicon Graphics, Inc.
|
||||
See libtiff home page http://www.remotesensing.org/libtiff/
|
||||
See libtiff home page http://www.libtiff.org/
|
||||
for details and links to the source code
|
||||
|
||||
WITH_TIFF CMake option must be ON to add libtiff & zlib support to imgcodecs.
|
||||
@@ -51,7 +51,9 @@ jasper JasPer is a collection of software
|
||||
Copyright (c) 1999-2000 The University of British Columbia
|
||||
Copyright (c) 2001-2003 Michael David Adams
|
||||
|
||||
The JasPer license can be found in libjasper.
|
||||
See JasPer official GitHub repository
|
||||
https://github.com/jasper-software/jasper.git
|
||||
for details and links to source code
|
||||
------------------------------------------------------------------------------------
|
||||
openexr OpenEXR is a high dynamic-range (HDR) image file format developed
|
||||
by Industrial Light & Magic for use in computer imaging applications.
|
||||
|
||||
+21
-12
@@ -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)
|
||||
|
||||
@@ -648,6 +650,8 @@ if(UNIX)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m pthread)
|
||||
elseif(EMSCRIPTEN)
|
||||
# no need to link to system libs with emscripten
|
||||
elseif(QNXNTO)
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} m)
|
||||
else()
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} dl m pthread rt)
|
||||
endif()
|
||||
@@ -1230,12 +1234,17 @@ status("")
|
||||
status(" GUI: ")
|
||||
|
||||
if(WITH_QT OR HAVE_QT)
|
||||
if(HAVE_QT5)
|
||||
status(" QT:" "YES (ver ${Qt5Core_VERSION_STRING})")
|
||||
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt5OpenGL_LIBRARIES} ${Qt5OpenGL_VERSION_STRING})" ELSE NO)
|
||||
elseif(HAVE_QT)
|
||||
if(HAVE_QT)
|
||||
status(" QT:" "YES (ver ${QT_VERSION_MAJOR}.${QT_VERSION_MINOR}.${QT_VERSION_PATCH} ${QT_EDITION})")
|
||||
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
|
||||
if(HAVE_QT_OPENGL)
|
||||
if(Qt${QT_VERSION_MAJOR}OpenGL_LIBRARIES)
|
||||
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${Qt${QT_VERSION_MAJOR}OpenGL_LIBRARIES} ${Qt${QT_VERSION_MAJOR}OpenGL_VERSION_STRING})" ELSE NO)
|
||||
else()
|
||||
status(" QT OpenGL support:" HAVE_QT_OPENGL THEN "YES (${QT_QTOPENGL_LIBRARY})" ELSE NO)
|
||||
endif()
|
||||
else()
|
||||
status(" QT OpenGL support:" "NO")
|
||||
endif()
|
||||
else()
|
||||
status(" QT:" "NO")
|
||||
endif()
|
||||
|
||||
@@ -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")
|
||||
|
||||
@@ -177,7 +177,13 @@ if(CV_GCC OR CV_CLANG)
|
||||
endif()
|
||||
|
||||
# We need pthread's
|
||||
if(UNIX AND NOT ANDROID AND NOT (APPLE AND CV_CLANG)) # TODO
|
||||
if((UNIX
|
||||
AND NOT ANDROID
|
||||
AND NOT (APPLE AND CV_CLANG)
|
||||
AND NOT EMSCRIPTEN
|
||||
)
|
||||
OR (EMSCRIPTEN AND WITH_PTHREADS_PF) # https://github.com/opencv/opencv/issues/20285
|
||||
)
|
||||
add_extra_compiler_option(-pthread)
|
||||
endif()
|
||||
|
||||
@@ -394,6 +400,9 @@ if(MSVC)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Enable [[attribute]] syntax checking to prevent silent failure: "attribute is ignored in this syntactic position"
|
||||
add_extra_compiler_option("/w15240")
|
||||
|
||||
if(NOT ENABLE_NOISY_WARNINGS)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4127) # conditional expression is constant
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4251) # class 'std::XXX' needs to have dll-interface to be used by clients of YYY
|
||||
|
||||
@@ -102,7 +102,7 @@ if(CUDA_FOUND)
|
||||
if(CUDA_GENERATION)
|
||||
if(NOT ";${_generations};" MATCHES ";${CUDA_GENERATION};")
|
||||
string(REPLACE ";" ", " _generations "${_generations}")
|
||||
message(FATAL_ERROR "ERROR: ${_generations} Generations are suppered.")
|
||||
message(FATAL_ERROR "ERROR: ${_generations} Generations are supported.")
|
||||
endif()
|
||||
unset(CUDA_ARCH_BIN CACHE)
|
||||
unset(CUDA_ARCH_PTX CACHE)
|
||||
|
||||
@@ -169,6 +169,8 @@ elseif(MSVC)
|
||||
set(OpenCV_RUNTIME vc15)
|
||||
elseif(MSVC_VERSION MATCHES "^192[0-9]$")
|
||||
set(OpenCV_RUNTIME vc16)
|
||||
elseif(MSVC_VERSION MATCHES "^193[0-9]$")
|
||||
set(OpenCV_RUNTIME vc17)
|
||||
else()
|
||||
message(WARNING "OpenCV does not recognize MSVC_VERSION \"${MSVC_VERSION}\". Cannot set OpenCV_RUNTIME")
|
||||
endif()
|
||||
|
||||
@@ -9,9 +9,14 @@ set(HALIDE_ROOT_DIR "${HALIDE_ROOT_DIR}" CACHE PATH "Halide root directory")
|
||||
if(NOT HAVE_HALIDE)
|
||||
find_package(Halide QUIET) # Try CMake-based config files
|
||||
if(Halide_FOUND)
|
||||
set(HALIDE_INCLUDE_DIRS "${Halide_INCLUDE_DIRS}" CACHE PATH "Halide include directories" FORCE)
|
||||
set(HALIDE_LIBRARIES "${Halide_LIBRARIES}" CACHE PATH "Halide libraries" FORCE)
|
||||
set(HAVE_HALIDE TRUE)
|
||||
if(TARGET Halide::Halide) # modern Halide scripts defines imported target
|
||||
set(HALIDE_INCLUDE_DIRS "")
|
||||
set(HALIDE_LIBRARIES "Halide::Halide")
|
||||
set(HAVE_HALIDE TRUE)
|
||||
else()
|
||||
# using HALIDE_INCLUDE_DIRS / Halide_LIBRARIES
|
||||
set(HAVE_HALIDE TRUE)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -28,18 +33,15 @@ if(NOT HAVE_HALIDE AND HALIDE_ROOT_DIR)
|
||||
)
|
||||
if(HALIDE_LIBRARY AND HALIDE_INCLUDE_DIR)
|
||||
# TODO try_compile
|
||||
set(HALIDE_INCLUDE_DIRS "${HALIDE_INCLUDE_DIR}" CACHE PATH "Halide include directories" FORCE)
|
||||
set(HALIDE_LIBRARIES "${HALIDE_LIBRARY}" CACHE PATH "Halide libraries" FORCE)
|
||||
set(HALIDE_INCLUDE_DIRS "${HALIDE_INCLUDE_DIR}")
|
||||
set(HALIDE_LIBRARIES "${HALIDE_LIBRARY}")
|
||||
set(HAVE_HALIDE TRUE)
|
||||
endif()
|
||||
if(NOT HAVE_HALIDE)
|
||||
ocv_clear_vars(HALIDE_LIBRARIES HALIDE_INCLUDE_DIRS CACHE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(HAVE_HALIDE)
|
||||
include_directories(${HALIDE_INCLUDE_DIRS})
|
||||
if(HALIDE_INCLUDE_DIRS)
|
||||
include_directories(${HALIDE_INCLUDE_DIRS})
|
||||
endif()
|
||||
list(APPEND OPENCV_LINKER_LIBS ${HALIDE_LIBRARIES})
|
||||
else()
|
||||
ocv_clear_vars(HALIDE_INCLUDE_DIRS HALIDE_LIBRARIES)
|
||||
endif()
|
||||
|
||||
@@ -105,6 +105,20 @@ if(InferenceEngine_FOUND)
|
||||
message(STATUS "Detected InferenceEngine: cmake package (${InferenceEngine_VERSION})")
|
||||
endif()
|
||||
|
||||
if(DEFINED InferenceEngine_VERSION)
|
||||
message(STATUS "InferenceEngine: ${InferenceEngine_VERSION}")
|
||||
if(NOT INF_ENGINE_RELEASE AND NOT (InferenceEngine_VERSION VERSION_LESS "2021.4"))
|
||||
math(EXPR INF_ENGINE_RELEASE_INIT "${InferenceEngine_VERSION_MAJOR} * 1000000 + ${InferenceEngine_VERSION_MINOR} * 10000 + ${InferenceEngine_VERSION_PATCH} * 100")
|
||||
endif()
|
||||
endif()
|
||||
if(NOT INF_ENGINE_RELEASE AND NOT INF_ENGINE_RELEASE_INIT)
|
||||
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()
|
||||
set(INF_ENGINE_RELEASE "${INF_ENGINE_RELEASE_INIT}" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
|
||||
|
||||
if(NOT INF_ENGINE_TARGET AND INF_ENGINE_LIB_DIRS AND INF_ENGINE_INCLUDE_DIRS)
|
||||
find_path(ie_custom_inc "inference_engine.hpp" PATHS "${INF_ENGINE_INCLUDE_DIRS}" NO_DEFAULT_PATH)
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
@@ -140,12 +154,8 @@ endif()
|
||||
# Add more features to the target
|
||||
|
||||
if(INF_ENGINE_TARGET)
|
||||
if(NOT INF_ENGINE_RELEASE)
|
||||
message(WARNING "InferenceEngine version has not been set, 2021.3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
|
||||
endif()
|
||||
set(INF_ENGINE_RELEASE "2021030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2020.1.0.2 -> 2020010002)")
|
||||
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
|
||||
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
|
||||
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${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)
|
||||
|
||||
@@ -26,31 +26,14 @@ if(VTK_VERSION VERSION_LESS "5.8.0")
|
||||
endif()
|
||||
|
||||
# Different Qt versions can't be linked together
|
||||
if(HAVE_QT5 AND VTK_VERSION VERSION_LESS "6.0.0")
|
||||
if(VTK_USE_QT)
|
||||
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Different Qt versions can't be linked together. VTK 6.0.0 doesn't provide a way to get Qt version it was linked with
|
||||
if(HAVE_QT5 AND VTK_VERSION VERSION_EQUAL "6.0.0" AND NOT DEFINED FORCE_VTK)
|
||||
message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt5, and VTK ver.${VTK_VERSION} with Qt4")
|
||||
message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DFORCE_VTK=TRUE' flag in CMake")
|
||||
if((HAVE_QT AND VTK_USE_QT)
|
||||
AND NOT DEFINED FORCE_VTK # deprecated
|
||||
AND NOT DEFINED OPENCV_FORCE_VTK
|
||||
)
|
||||
message(STATUS "VTK support is disabled. Possible incompatible combination: OpenCV+Qt, and VTK ver.${VTK_VERSION} with Qt")
|
||||
message(STATUS "If it is known that VTK was compiled without Qt4, please define '-DOPENCV_FORCE_VTK=TRUE' flag in CMake")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Different Qt versions can't be linked together
|
||||
if(HAVE_QT AND VTK_VERSION VERSION_GREATER "6.0.0" AND NOT ${VTK_QT_VERSION} STREQUAL "")
|
||||
if(HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "4")
|
||||
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt5 and VTK ver.${VTK_VERSION} + Qt4")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_QT5 AND ${VTK_QT_VERSION} EQUAL "5")
|
||||
message(STATUS "VTK support is disabled. Incompatible combination: OpenCV + Qt4 and VTK ver.${VTK_VERSION} + Qt5")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(HAVE_VTK ON)
|
||||
message(STATUS "Found VTK ${VTK_VERSION} (${VTK_USE_FILE})")
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -11,25 +11,50 @@ if(WITH_WIN32UI)
|
||||
CMAKE_FLAGS "-DLINK_LIBRARIES:STRING=user32;gdi32")
|
||||
endif()
|
||||
|
||||
# --- QT4 ---
|
||||
ocv_clear_vars(HAVE_QT HAVE_QT5)
|
||||
if(WITH_QT)
|
||||
if(NOT WITH_QT EQUAL 4)
|
||||
find_package(Qt5 COMPONENTS Core Gui Widgets Test Concurrent REQUIRED NO_MODULE)
|
||||
if(Qt5_FOUND)
|
||||
set(HAVE_QT5 ON)
|
||||
set(HAVE_QT ON)
|
||||
find_package(Qt5 COMPONENTS OpenGL QUIET)
|
||||
if(Qt5OpenGL_FOUND)
|
||||
set(QT_QTOPENGL_FOUND ON)
|
||||
endif()
|
||||
endif()
|
||||
macro(ocv_find_package_Qt4)
|
||||
find_package(Qt4 COMPONENTS QtCore QtGui QtTest ${ARGN})
|
||||
if(QT4_FOUND)
|
||||
set(QT_FOUND 1)
|
||||
ocv_assert(QT_VERSION_MAJOR EQUAL 4)
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
if(NOT HAVE_QT)
|
||||
find_package(Qt4 REQUIRED QtCore QtGui QtTest)
|
||||
if(QT4_FOUND)
|
||||
set(HAVE_QT TRUE)
|
||||
macro(ocv_find_package_Qt OCV_QT_VER)
|
||||
find_package(Qt${OCV_QT_VER} COMPONENTS Core Gui Widgets Test Concurrent ${ARGN} NO_MODULE)
|
||||
if(Qt${OCV_QT_VER}_FOUND)
|
||||
set(QT_FOUND 1)
|
||||
set(QT_VERSION "${Qt${OCV_QT_VER}_VERSION}")
|
||||
set(QT_VERSION_MAJOR "${Qt${OCV_QT_VER}_VERSION_MAJOR}")
|
||||
set(QT_VERSION_MINOR "${Qt${OCV_QT_VER}_VERSION_MINOR}")
|
||||
set(QT_VERSION_PATCH "${Qt${OCV_QT_VER}_VERSION_PATCH}")
|
||||
set(QT_VERSION_TWEAK "${Qt${OCV_QT_VER}_VERSION_TWEAK}")
|
||||
set(QT_VERSION_COUNT "${Qt${OCV_QT_VER}_VERSION_COUNT}")
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
# --- QT4 ---
|
||||
if(WITH_QT)
|
||||
if(NOT WITH_QT GREATER 0)
|
||||
# BUG: Qt5Config.cmake script can't handle components properly: find_package(QT NAMES Qt6 Qt5 REQUIRED NO_MODULE COMPONENTS Core Gui Widgets Test Concurrent)
|
||||
ocv_find_package_Qt(6 QUIET)
|
||||
if(NOT QT_FOUND)
|
||||
ocv_find_package_Qt(5 QUIET)
|
||||
endif()
|
||||
if(NOT QT_FOUND)
|
||||
ocv_find_package_Qt4(QUIET)
|
||||
endif()
|
||||
elseif(WITH_QT EQUAL 4)
|
||||
ocv_find_package_Qt4(REQUIRED)
|
||||
else() # WITH_QT=<major version>
|
||||
ocv_find_package_Qt("${WITH_QT}" REQUIRED)
|
||||
endif()
|
||||
if(QT_FOUND)
|
||||
set(HAVE_QT ON)
|
||||
if(QT_VERSION_MAJOR GREATER 4)
|
||||
find_package(Qt${QT_VERSION_MAJOR} COMPONENTS OpenGL QUIET)
|
||||
if(Qt${QT_VERSION_MAJOR}OpenGL_FOUND)
|
||||
set(QT_QTOPENGL_FOUND ON) # HAVE_QT_OPENGL is defined below
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@@ -76,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)
|
||||
|
||||
@@ -1488,8 +1488,8 @@ function(ocv_target_link_libraries target)
|
||||
if(NOT LINK_PENDING STREQUAL "")
|
||||
__ocv_push_target_link_libraries(${LINK_MODE} ${LINK_PENDING})
|
||||
set(LINK_PENDING "")
|
||||
set(LINK_MODE "${dep}")
|
||||
endif()
|
||||
set(LINK_MODE "${dep}")
|
||||
else()
|
||||
if(BUILD_opencv_world)
|
||||
if(OPENCV_MODULE_${dep}_IS_PART_OF_WORLD)
|
||||
|
||||
@@ -137,6 +137,20 @@ elseif(MSVC)
|
||||
set(OpenCV_RUNTIME vc14) # selecting previous compatible runtime version
|
||||
endif()
|
||||
endif()
|
||||
elseif(MSVC_VERSION MATCHES "^193[0-9]$")
|
||||
set(OpenCV_RUNTIME vc17)
|
||||
check_one_config(has_VS2022)
|
||||
if(NOT has_VS2022)
|
||||
set(OpenCV_RUNTIME vc16)
|
||||
check_one_config(has_VS2019)
|
||||
if(NOT has_VS2019)
|
||||
set(OpenCV_RUNTIME vc15) # selecting previous compatible runtime version
|
||||
check_one_config(has_VS2017)
|
||||
if(NOT has_VS2017)
|
||||
set(OpenCV_RUNTIME vc14) # selecting previous compatible runtime version
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
elseif(MINGW)
|
||||
set(OpenCV_RUNTIME mingw)
|
||||
|
||||
@@ -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">
|
||||
|
||||
+3
@@ -1,6 +1,9 @@
|
||||
Contour Features {#tutorial_js_contour_features}
|
||||
================
|
||||
|
||||
@prev_tutorial{tutorial_js_contours_begin}
|
||||
@next_tutorial{tutorial_js_contour_properties}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
+3
@@ -1,6 +1,9 @@
|
||||
Contour Properties {#tutorial_js_contour_properties}
|
||||
==================
|
||||
|
||||
@prev_tutorial{tutorial_js_contour_features}
|
||||
@next_tutorial{tutorial_js_contours_more_functions}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
Contours : Getting Started {#tutorial_js_contours_begin}
|
||||
==========================
|
||||
|
||||
@next_tutorial{tutorial_js_contour_features}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
+2
@@ -1,6 +1,8 @@
|
||||
Contours Hierarchy {#tutorial_js_contours_hierarchy}
|
||||
==================
|
||||
|
||||
@prev_tutorial{tutorial_js_contours_more_functions}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
+3
@@ -1,6 +1,9 @@
|
||||
Contours : More Functions {#tutorial_js_contours_more_functions}
|
||||
=========================
|
||||
|
||||
@prev_tutorial{tutorial_js_contour_properties}
|
||||
@next_tutorial{tutorial_js_contours_hierarchy}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
@@ -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}
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ import numpy as np
|
||||
import cv2 as cv
|
||||
from matplotlib import pyplot as plt
|
||||
|
||||
img = cv.imread('simple.jpg',0)
|
||||
img = cv.imread('blox.jpg',0) # `<opencv_root>/samples/data/blox.jpg`
|
||||
|
||||
# Initiate FAST object with default values
|
||||
fast = cv.FastFeatureDetector_create()
|
||||
@@ -113,17 +113,17 @@ print( "nonmaxSuppression:{}".format(fast.getNonmaxSuppression()) )
|
||||
print( "neighborhood: {}".format(fast.getType()) )
|
||||
print( "Total Keypoints with nonmaxSuppression: {}".format(len(kp)) )
|
||||
|
||||
cv.imwrite('fast_true.png',img2)
|
||||
cv.imwrite('fast_true.png', img2)
|
||||
|
||||
# Disable nonmaxSuppression
|
||||
fast.setNonmaxSuppression(0)
|
||||
kp = fast.detect(img,None)
|
||||
kp = fast.detect(img, None)
|
||||
|
||||
print( "Total Keypoints without nonmaxSuppression: {}".format(len(kp)) )
|
||||
|
||||
img3 = cv.drawKeypoints(img, kp, None, color=(255,0,0))
|
||||
|
||||
cv.imwrite('fast_false.png',img3)
|
||||
cv.imwrite('fast_false.png', img3)
|
||||
@endcode
|
||||
See the results. First image shows FAST with nonmaxSuppression and second one without
|
||||
nonmaxSuppression:
|
||||
|
||||
@@ -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)
|
||||
|
||||
|
||||
@@ -74,7 +74,7 @@ Canny Edge Detection in OpenCV
|
||||
|
||||
OpenCV puts all the above in single function, **cv.Canny()**. We will see how to use it. First
|
||||
argument is our input image. Second and third arguments are our minVal and maxVal respectively.
|
||||
Third argument is aperture_size. It is the size of Sobel kernel used for find image gradients. By
|
||||
Fourth argument is aperture_size. It is the size of Sobel kernel used for find image gradients. By
|
||||
default it is 3. Last argument is L2gradient which specifies the equation for finding gradient
|
||||
magnitude. If it is True, it uses the equation mentioned above which is more accurate, otherwise it
|
||||
uses this function: \f$Edge\_Gradient \; (G) = |G_x| + |G_y|\f$. By default, it is False.
|
||||
|
||||
+4
-1
@@ -1,6 +1,9 @@
|
||||
Contour Features {#tutorial_py_contour_features}
|
||||
================
|
||||
|
||||
@prev_tutorial{tutorial_py_contours_begin}
|
||||
@next_tutorial{tutorial_py_contour_properties}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
@@ -91,7 +94,7 @@ convexity defects, which are the local maximum deviations of hull from contours.
|
||||
|
||||
There is a little bit things to discuss about it its syntax:
|
||||
@code{.py}
|
||||
hull = cv.convexHull(points[, hull[, clockwise[, returnPoints]]
|
||||
hull = cv.convexHull(points[, hull[, clockwise[, returnPoints]]])
|
||||
@endcode
|
||||
Arguments details:
|
||||
|
||||
|
||||
+3
@@ -1,6 +1,9 @@
|
||||
Contour Properties {#tutorial_py_contour_properties}
|
||||
==================
|
||||
|
||||
@prev_tutorial{tutorial_py_contour_features}
|
||||
@next_tutorial{tutorial_py_contours_more_functions}
|
||||
|
||||
Here we will learn to extract some frequently used properties of objects like Solidity, Equivalent
|
||||
Diameter, Mask image, Mean Intensity etc. More features can be found at [Matlab regionprops
|
||||
documentation](http://www.mathworks.in/help/images/ref/regionprops.html).
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
Contours : Getting Started {#tutorial_py_contours_begin}
|
||||
==========================
|
||||
|
||||
@next_tutorial{tutorial_py_contour_features}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
+2
@@ -1,6 +1,8 @@
|
||||
Contours Hierarchy {#tutorial_py_contours_hierarchy}
|
||||
==================
|
||||
|
||||
@prev_tutorial{tutorial_py_contours_more_functions}
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
+4
@@ -1,6 +1,10 @@
|
||||
Contours : More Functions {#tutorial_py_contours_more_functions}
|
||||
=========================
|
||||
|
||||
@prev_tutorial{tutorial_py_contour_properties}
|
||||
@next_tutorial{tutorial_py_contours_hierarchy}
|
||||
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
|
||||
+9
-9
@@ -84,8 +84,8 @@ a new header with the new boundaries:
|
||||
Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle
|
||||
Mat E = A(Range::all(), Range(1,3)); // using row and column boundaries
|
||||
@endcode
|
||||
Now you may ask -- if the matrix itself may belong to multiple *Mat* objects who takes responsibility
|
||||
for cleaning it up when it's no longer needed. The short answer is: the last object that used it.
|
||||
Now you may ask -- if the matrix itself may belong to multiple *Mat* objects, who takes responsibility
|
||||
for cleaning it up when it's no longer needed? The short answer is: the last object that used it.
|
||||
This is handled by using a reference counting mechanism. Whenever somebody copies a header of a
|
||||
*Mat* object, a counter is increased for the matrix. Whenever a header is cleaned, this counter
|
||||
is decreased. When the counter reaches zero the matrix is freed. Sometimes you will want to copy
|
||||
@@ -95,12 +95,12 @@ Mat F = A.clone();
|
||||
Mat G;
|
||||
A.copyTo(G);
|
||||
@endcode
|
||||
Now modifying *F* or *G* will not affect the matrix pointed by the *A*'s header. What you need to
|
||||
Now modifying *F* or *G* will not affect the matrix pointed to by the *A*'s header. What you need to
|
||||
remember from all this is that:
|
||||
|
||||
- Output image allocation for OpenCV functions is automatic (unless specified otherwise).
|
||||
- You do not need to think about memory management with OpenCV's C++ interface.
|
||||
- The assignment operator and the copy constructor only copies the header.
|
||||
- The assignment operator and the copy constructor only copy the header.
|
||||
- The underlying matrix of an image may be copied using the @ref cv::Mat::clone() and @ref cv::Mat::copyTo()
|
||||
functions.
|
||||
|
||||
@@ -115,10 +115,10 @@ of these allows us to create many shades of gray.
|
||||
For *colorful* ways we have a lot more methods to choose from. Each of them breaks it down to three
|
||||
or four basic components and we can use the combination of these to create the others. The most
|
||||
popular one is RGB, mainly because this is also how our eye builds up colors. Its base colors are
|
||||
red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is
|
||||
red, green and blue. To code the transparency of a color sometimes a fourth element, alpha (A), is
|
||||
added.
|
||||
|
||||
There are, however, many other color systems each with their own advantages:
|
||||
There are, however, many other color systems, each with their own advantages:
|
||||
|
||||
- RGB is the most common as our eyes use something similar, however keep in mind that OpenCV standard display
|
||||
system composes colors using the BGR color space (red and blue channels are swapped places).
|
||||
@@ -132,11 +132,11 @@ There are, however, many other color systems each with their own advantages:
|
||||
Each of the building components has its own valid domains. This leads to the data type used. How
|
||||
we store a component defines the control we have over its domain. The smallest data type possible is
|
||||
*char*, which means one byte or 8 bits. This may be unsigned (so can store values from 0 to 255) or
|
||||
signed (values from -127 to +127). Although in case of three components this already gives 16
|
||||
million possible colors to represent (like in case of RGB) we may acquire an even finer control by
|
||||
signed (values from -127 to +127). Although this width, in the case of three components (like RGB), already gives 16
|
||||
million possible colors to represent, we may acquire an even finer control by
|
||||
using the float (4 byte = 32 bit) or double (8 byte = 64 bit) data types for each component.
|
||||
Nevertheless, remember that increasing the size of a component also increases the size of the whole
|
||||
picture in the memory.
|
||||
picture in memory.
|
||||
|
||||
Creating a Mat object explicitly
|
||||
----------------------------------
|
||||
|
||||
@@ -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.15
|
||||
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.15
|
||||
./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)
|
||||
|
||||
@@ -10,6 +10,8 @@ Working with a boosted cascade of weak classifiers includes two major stages: th
|
||||
|
||||
To support this tutorial, several official OpenCV applications will be used: [opencv_createsamples](https://github.com/opencv/opencv/tree/3.4/apps/createsamples), [opencv_annotation](https://github.com/opencv/opencv/tree/3.4/apps/annotation), [opencv_traincascade](https://github.com/opencv/opencv/tree/3.4/apps/traincascade) and [opencv_visualisation](https://github.com/opencv/opencv/tree/3.4/apps/visualisation).
|
||||
|
||||
@note Createsamples and traincascade are disabled since OpenCV 4.0. Consider using these apps for training from 3.4 branch for Cascade Classifier. Model format is the same between 3.4 and 4.x.
|
||||
|
||||
### Important notes
|
||||
|
||||
- If you come across any tutorial mentioning the old opencv_haartraining tool <i>(which is deprecated and still using the OpenCV1.x interface)</i>, then please ignore that tutorial and stick to the opencv_traincascade tool. This tool is a newer version, written in C++ in accordance to the OpenCV 2.x and OpenCV 3.x API. The opencv_traincascade supports both HAAR like wavelet features @cite Viola01 and LBP (Local Binary Patterns) @cite Liao2007 features. LBP features yield integer precision in contrast to HAAR features, yielding floating point precision, so both training and detection with LBP are several times faster then with HAAR features. Regarding the LBP and HAAR detection quality, it mainly depends on the training data used and the training parameters selected. It's possible to train a LBP-based classifier that will provide almost the same quality as HAAR-based one, within a percentage of the training time.
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -180,7 +180,7 @@ implementation below.
|
||||
|
||||
This will return a similarity index for each channel of the image. This value is between zero and
|
||||
one, where one corresponds to perfect fit. Unfortunately, the many Gaussian blurring is quite
|
||||
costly, so while the PSNR may work in a real time like environment (24 frame per second) this will
|
||||
costly, so while the PSNR may work in a real time like environment (24 frames per second) this will
|
||||
take significantly more than to accomplish similar performance results.
|
||||
|
||||
Therefore, the source code presented at the start of the tutorial will perform the PSNR measurement
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
@@ -116,6 +131,59 @@ String dumpRange(const Range& argument)
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
String testReservedKeywordConversion(int positional_argument, int lambda = 2, int from = 3)
|
||||
{
|
||||
return format("arg=%d, lambda=%d, from=%d", positional_argument, lambda, from);
|
||||
}
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfInt(const std::vector<int>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfDouble(const std::vector<double>& vec);
|
||||
|
||||
CV_EXPORTS_W String dumpVectorOfRect(const std::vector<Rect>& vec);
|
||||
|
||||
CV_WRAP static inline
|
||||
void generateVectorOfRect(size_t len, CV_OUT std::vector<Rect>& vec)
|
||||
{
|
||||
vec.resize(len);
|
||||
if (len > 0)
|
||||
{
|
||||
RNG rng(12345);
|
||||
Mat tmp(static_cast<int>(len), 1, CV_32SC4);
|
||||
rng.fill(tmp, RNG::UNIFORM, 10, 20);
|
||||
tmp.copyTo(vec);
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
void generateVectorOfInt(size_t len, CV_OUT std::vector<int>& vec)
|
||||
{
|
||||
vec.resize(len);
|
||||
if (len > 0)
|
||||
{
|
||||
RNG rng(554433);
|
||||
Mat tmp(static_cast<int>(len), 1, CV_32SC1);
|
||||
rng.fill(tmp, RNG::UNIFORM, -10, 10);
|
||||
tmp.copyTo(vec);
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
void generateVectorOfMat(size_t len, int rows, int cols, int dtype, CV_OUT std::vector<Mat>& vec)
|
||||
{
|
||||
vec.resize(len);
|
||||
if (len > 0)
|
||||
{
|
||||
RNG rng(65431);
|
||||
for (size_t i = 0; i < len; ++i)
|
||||
{
|
||||
vec[i].create(rows, cols, dtype);
|
||||
rng.fill(vec[i], RNG::UNIFORM, 0, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CV_WRAP static inline
|
||||
void testRaiseGeneralException()
|
||||
{
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -575,14 +575,49 @@ Cv64suf;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/****************************************************************************************\
|
||||
* CV_NODISCARD_STD attribute (C++17) *
|
||||
* encourages the compiler to issue a warning if the return value is discarded *
|
||||
\****************************************************************************************/
|
||||
#ifndef CV_NODISCARD_STD
|
||||
# ifndef __has_cpp_attribute
|
||||
// workaround preprocessor non-compliance https://reviews.llvm.org/D57851
|
||||
# define __has_cpp_attribute(__x) 0
|
||||
# endif
|
||||
# if __has_cpp_attribute(nodiscard)
|
||||
# define CV_NODISCARD_STD [[nodiscard]]
|
||||
# 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]]
|
||||
# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 700) && (__cplusplus >= 201103L)
|
||||
// available with GCC 7.0+; works on functions, works or silently fails on classes
|
||||
# define CV_NODISCARD_STD [[nodiscard]]
|
||||
# elif defined(__GNUC__) && (((__GNUC__ * 100) + __GNUC_MINOR__) >= 408) && (__cplusplus >= 201103L)
|
||||
// available with GCC 4.8+ but it usually does nothing and can fail noisily -- therefore not used
|
||||
// define CV_NODISCARD_STD [[gnu::warn_unused_result]]
|
||||
# endif
|
||||
#endif
|
||||
#ifndef CV_NODISCARD_STD
|
||||
# define CV_NODISCARD_STD /* nothing by default */
|
||||
#endif
|
||||
|
||||
|
||||
/****************************************************************************************\
|
||||
* CV_NODISCARD attribute *
|
||||
* encourages the compiler to issue a warning if the return value is discarded (C++17) *
|
||||
* CV_NODISCARD attribute (deprecated, GCC only) *
|
||||
* DONT USE: use instead the standard CV_NODISCARD_STD macro above *
|
||||
* this legacy method silently fails to issue warning until some version *
|
||||
* after gcc 6.3.0. Yet with gcc 7+ you can use the above standard method *
|
||||
* which makes this method useless. Don't use it. *
|
||||
* @deprecated use instead CV_NODISCARD_STD *
|
||||
\****************************************************************************************/
|
||||
#ifndef CV_NODISCARD
|
||||
# if defined(__GNUC__)
|
||||
# define CV_NODISCARD __attribute__((__warn_unused_result__)) // at least available with GCC 3.4
|
||||
# define CV_NODISCARD __attribute__((__warn_unused_result__))
|
||||
# elif defined(__clang__) && defined(__has_attribute)
|
||||
# if __has_attribute(__warn_unused_result__)
|
||||
# define CV_NODISCARD __attribute__((__warn_unused_result__))
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1204,14 +1204,14 @@ public:
|
||||
The method creates a square diagonal matrix from specified main diagonal.
|
||||
@param d One-dimensional matrix that represents the main diagonal.
|
||||
*/
|
||||
static Mat diag(const Mat& d);
|
||||
CV_NODISCARD_STD static Mat diag(const Mat& d);
|
||||
|
||||
/** @brief Creates a full copy of the array and the underlying data.
|
||||
|
||||
The method creates a full copy of the array. The original step[] is not taken into account. So, the
|
||||
array copy is a continuous array occupying total()*elemSize() bytes.
|
||||
*/
|
||||
Mat clone() const CV_NODISCARD;
|
||||
CV_NODISCARD_STD Mat clone() const;
|
||||
|
||||
/** @brief Copies the matrix to another one.
|
||||
|
||||
@@ -1375,20 +1375,20 @@ public:
|
||||
@param cols Number of columns.
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr zeros(int rows, int cols, int type);
|
||||
CV_NODISCARD_STD static MatExpr zeros(int rows, int cols, int type);
|
||||
|
||||
/** @overload
|
||||
@param size Alternative to the matrix size specification Size(cols, rows) .
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr zeros(Size size, int type);
|
||||
CV_NODISCARD_STD static MatExpr zeros(Size size, int type);
|
||||
|
||||
/** @overload
|
||||
@param ndims Array dimensionality.
|
||||
@param sz Array of integers specifying the array shape.
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr zeros(int ndims, const int* sz, int type);
|
||||
CV_NODISCARD_STD static MatExpr zeros(int ndims, const int* sz, int type);
|
||||
|
||||
/** @brief Returns an array of all 1's of the specified size and type.
|
||||
|
||||
@@ -1406,20 +1406,20 @@ public:
|
||||
@param cols Number of columns.
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr ones(int rows, int cols, int type);
|
||||
CV_NODISCARD_STD static MatExpr ones(int rows, int cols, int type);
|
||||
|
||||
/** @overload
|
||||
@param size Alternative to the matrix size specification Size(cols, rows) .
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr ones(Size size, int type);
|
||||
CV_NODISCARD_STD static MatExpr ones(Size size, int type);
|
||||
|
||||
/** @overload
|
||||
@param ndims Array dimensionality.
|
||||
@param sz Array of integers specifying the array shape.
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr ones(int ndims, const int* sz, int type);
|
||||
CV_NODISCARD_STD static MatExpr ones(int ndims, const int* sz, int type);
|
||||
|
||||
/** @brief Returns an identity matrix of the specified size and type.
|
||||
|
||||
@@ -1435,13 +1435,13 @@ public:
|
||||
@param cols Number of columns.
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr eye(int rows, int cols, int type);
|
||||
CV_NODISCARD_STD static MatExpr eye(int rows, int cols, int type);
|
||||
|
||||
/** @overload
|
||||
@param size Alternative matrix size specification as Size(cols, rows) .
|
||||
@param type Created matrix type.
|
||||
*/
|
||||
static MatExpr eye(Size size, int type);
|
||||
CV_NODISCARD_STD static MatExpr eye(Size size, int type);
|
||||
|
||||
/** @brief Allocates new array data if needed.
|
||||
|
||||
@@ -2302,7 +2302,7 @@ public:
|
||||
Mat_ row(int y) const;
|
||||
Mat_ col(int x) const;
|
||||
Mat_ diag(int d=0) const;
|
||||
Mat_ clone() const CV_NODISCARD;
|
||||
CV_NODISCARD_STD Mat_ clone() const;
|
||||
|
||||
//! overridden forms of Mat::elemSize() etc.
|
||||
size_t elemSize() const;
|
||||
@@ -2315,14 +2315,14 @@ public:
|
||||
size_t stepT(int i=0) const;
|
||||
|
||||
//! overridden forms of Mat::zeros() etc. Data type is omitted, of course
|
||||
static MatExpr zeros(int rows, int cols);
|
||||
static MatExpr zeros(Size size);
|
||||
static MatExpr zeros(int _ndims, const int* _sizes);
|
||||
static MatExpr ones(int rows, int cols);
|
||||
static MatExpr ones(Size size);
|
||||
static MatExpr ones(int _ndims, const int* _sizes);
|
||||
static MatExpr eye(int rows, int cols);
|
||||
static MatExpr eye(Size size);
|
||||
CV_NODISCARD_STD static MatExpr zeros(int rows, int cols);
|
||||
CV_NODISCARD_STD static MatExpr zeros(Size size);
|
||||
CV_NODISCARD_STD static MatExpr zeros(int _ndims, const int* _sizes);
|
||||
CV_NODISCARD_STD static MatExpr ones(int rows, int cols);
|
||||
CV_NODISCARD_STD static MatExpr ones(Size size);
|
||||
CV_NODISCARD_STD static MatExpr ones(int _ndims, const int* _sizes);
|
||||
CV_NODISCARD_STD static MatExpr eye(int rows, int cols);
|
||||
CV_NODISCARD_STD static MatExpr eye(Size size);
|
||||
|
||||
//! some more overridden methods
|
||||
Mat_& adjustROI( int dtop, int dbottom, int dleft, int dright );
|
||||
@@ -2469,10 +2469,10 @@ public:
|
||||
//! <0 - a diagonal from the lower half)
|
||||
UMat diag(int d=0) const;
|
||||
//! constructs a square diagonal matrix which main diagonal is vector "d"
|
||||
static UMat diag(const UMat& d);
|
||||
CV_NODISCARD_STD static UMat diag(const UMat& d);
|
||||
|
||||
//! returns deep copy of the matrix, i.e. the data is copied
|
||||
UMat clone() const CV_NODISCARD;
|
||||
CV_NODISCARD_STD UMat clone() const;
|
||||
//! copies the matrix content to "m".
|
||||
// It calls m.create(this->size(), this->type()).
|
||||
void copyTo( OutputArray m ) const;
|
||||
@@ -2503,14 +2503,14 @@ public:
|
||||
double dot(InputArray m) const;
|
||||
|
||||
//! Matlab-style matrix initialization
|
||||
static UMat zeros(int rows, int cols, int type);
|
||||
static UMat zeros(Size size, int type);
|
||||
static UMat zeros(int ndims, const int* sz, int type);
|
||||
static UMat ones(int rows, int cols, int type);
|
||||
static UMat ones(Size size, int type);
|
||||
static UMat ones(int ndims, const int* sz, int type);
|
||||
static UMat eye(int rows, int cols, int type);
|
||||
static UMat eye(Size size, int type);
|
||||
CV_NODISCARD_STD static UMat zeros(int rows, int cols, int type);
|
||||
CV_NODISCARD_STD static UMat zeros(Size size, int type);
|
||||
CV_NODISCARD_STD static UMat zeros(int ndims, const int* sz, int type);
|
||||
CV_NODISCARD_STD static UMat ones(int rows, int cols, int type);
|
||||
CV_NODISCARD_STD static UMat ones(Size size, int type);
|
||||
CV_NODISCARD_STD static UMat ones(int ndims, const int* sz, int type);
|
||||
CV_NODISCARD_STD static UMat eye(int rows, int cols, int type);
|
||||
CV_NODISCARD_STD static UMat eye(Size size, int type);
|
||||
|
||||
//! allocates new matrix data unless the matrix already has specified size and type.
|
||||
// previous data is unreferenced if needed.
|
||||
@@ -2767,7 +2767,7 @@ public:
|
||||
SparseMat& operator = (const Mat& m);
|
||||
|
||||
//! creates full copy of the matrix
|
||||
SparseMat clone() const CV_NODISCARD;
|
||||
CV_NODISCARD_STD SparseMat clone() const;
|
||||
|
||||
//! copies all the data to the destination matrix. All the previous content of m is erased
|
||||
void copyTo( SparseMat& m ) const;
|
||||
@@ -3004,7 +3004,7 @@ public:
|
||||
SparseMat_& operator = (const Mat& m);
|
||||
|
||||
//! makes full copy of the matrix. All the elements are duplicated
|
||||
SparseMat_ clone() const CV_NODISCARD;
|
||||
CV_NODISCARD_STD SparseMat_ clone() const;
|
||||
//! equivalent to cv::SparseMat::create(dims, _sizes, DataType<_Tp>::type)
|
||||
void create(int dims, const int* _sizes);
|
||||
//! converts sparse matrix to the old-style CvSparseMat. All the elements are copied
|
||||
|
||||
@@ -146,22 +146,22 @@ public:
|
||||
Matx(std::initializer_list<_Tp>); //!< initialize from an initializer list
|
||||
#endif
|
||||
|
||||
static Matx all(_Tp alpha);
|
||||
static Matx zeros();
|
||||
static Matx ones();
|
||||
static Matx eye();
|
||||
static Matx diag(const diag_type& d);
|
||||
CV_NODISCARD_STD static Matx all(_Tp alpha);
|
||||
CV_NODISCARD_STD static Matx zeros();
|
||||
CV_NODISCARD_STD static Matx ones();
|
||||
CV_NODISCARD_STD static Matx eye();
|
||||
CV_NODISCARD_STD static Matx diag(const diag_type& d);
|
||||
/** @brief Generates uniformly distributed random numbers
|
||||
@param a Range boundary.
|
||||
@param b The other range boundary (boundaries don't have to be ordered, the lower boundary is inclusive,
|
||||
the upper one is exclusive).
|
||||
*/
|
||||
static Matx randu(_Tp a, _Tp b);
|
||||
CV_NODISCARD_STD static Matx randu(_Tp a, _Tp b);
|
||||
/** @brief Generates normally distributed random numbers
|
||||
@param a Mean value.
|
||||
@param b Standard deviation.
|
||||
*/
|
||||
static Matx randn(_Tp a, _Tp b);
|
||||
CV_NODISCARD_STD static Matx randn(_Tp a, _Tp b);
|
||||
|
||||
//! dot product computed with the default precision
|
||||
_Tp dot(const Matx<_Tp, m, n>& v) const;
|
||||
|
||||
@@ -562,7 +562,9 @@ public:
|
||||
i = set(i, a6); i = set(i, a7); i = set(i, a8); i = set(i, a9); i = set(i, a10); i = set(i, a11);
|
||||
i = set(i, a12); i = set(i, a13); i = set(i, a14); set(i, a15); return *this;
|
||||
}
|
||||
/** @brief Run the OpenCL kernel.
|
||||
|
||||
/** @brief Run the OpenCL kernel (globalsize value may be adjusted)
|
||||
|
||||
@param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3.
|
||||
@param globalsize work items for each dimension. It is not the final globalsize passed to
|
||||
OpenCL. Each dimension will be adjusted to the nearest integer divisible by the corresponding
|
||||
@@ -571,12 +573,26 @@ public:
|
||||
@param localsize work-group size for each dimension.
|
||||
@param sync specify whether to wait for OpenCL computation to finish before return.
|
||||
@param q command queue
|
||||
|
||||
@note Use run_() if your kernel code doesn't support adjusted globalsize.
|
||||
*/
|
||||
bool run(int dims, size_t globalsize[],
|
||||
size_t localsize[], bool sync, const Queue& q=Queue());
|
||||
|
||||
/** @brief Run the OpenCL kernel
|
||||
*
|
||||
* @param dims the work problem dimensions. It is the length of globalsize and localsize. It can be either 1, 2 or 3.
|
||||
* @param globalsize work items for each dimension. This value is passed to OpenCL without changes.
|
||||
* @param localsize work-group size for each dimension.
|
||||
* @param sync specify whether to wait for OpenCL computation to finish before return.
|
||||
* @param q command queue
|
||||
*/
|
||||
bool run_(int dims, size_t globalsize[], size_t localsize[], bool sync, const Queue& q=Queue());
|
||||
|
||||
bool runTask(bool sync, const Queue& q=Queue());
|
||||
|
||||
/** @brief Similar to synchronized run() call with returning of kernel execution time
|
||||
/** @brief Similar to synchronized run_() call with returning of kernel execution time
|
||||
*
|
||||
* Separate OpenCL command queue may be used (with CL_QUEUE_PROFILING_ENABLE)
|
||||
* @return Execution time in nanoseconds or negative number on error
|
||||
*/
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 1
|
||||
# elif defined(__APPLE__)
|
||||
# include <TargetConditionals.h>
|
||||
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX) || (!defined(TARGET_OS_OSX) && !TARGET_OS_IPHONE)
|
||||
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 1 // OSX only
|
||||
# if (defined(TARGET_OS_OSX) && TARGET_OS_OSX) || (defined(TARGET_OS_IOS) && TARGET_OS_IOS)
|
||||
# define OPENCV_HAVE_FILESYSTEM_SUPPORT 1 // OSX, iOS only
|
||||
# endif
|
||||
# else
|
||||
/* unknown */
|
||||
|
||||
@@ -7,8 +7,8 @@
|
||||
|
||||
#define CV_VERSION_MAJOR 3
|
||||
#define CV_VERSION_MINOR 4
|
||||
#define CV_VERSION_REVISION 15
|
||||
#define CV_VERSION_STATUS "-pre"
|
||||
#define CV_VERSION_REVISION 17
|
||||
#define CV_VERSION_STATUS ""
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__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;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/bindings_utils.hpp"
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
namespace cv { namespace utils {
|
||||
|
||||
@@ -208,4 +209,50 @@ CV_EXPORTS_W String dumpInputOutputArrayOfArrays(InputOutputArrayOfArrays argume
|
||||
return ss.str();
|
||||
}
|
||||
|
||||
static inline std::ostream& operator<<(std::ostream& os, const cv::Rect& rect)
|
||||
{
|
||||
return os << "[x=" << rect.x << ", y=" << rect.y << ", w=" << rect.width << ", h=" << rect.height << ']';
|
||||
}
|
||||
|
||||
template <class T, class Formatter>
|
||||
static inline String dumpVector(const std::vector<T>& vec, Formatter format)
|
||||
{
|
||||
std::ostringstream oss("[", std::ios::ate);
|
||||
if (!vec.empty())
|
||||
{
|
||||
oss << format << vec[0];
|
||||
for (std::size_t i = 1; i < vec.size(); ++i)
|
||||
{
|
||||
oss << ", " << format << vec[i];
|
||||
}
|
||||
}
|
||||
oss << "]";
|
||||
return oss.str();
|
||||
}
|
||||
|
||||
static inline std::ostream& noFormat(std::ostream& os)
|
||||
{
|
||||
return os;
|
||||
}
|
||||
|
||||
static inline std::ostream& floatFormat(std::ostream& os)
|
||||
{
|
||||
return os << std::fixed << std::setprecision(2);
|
||||
}
|
||||
|
||||
String dumpVectorOfInt(const std::vector<int>& vec)
|
||||
{
|
||||
return dumpVector(vec, &noFormat);
|
||||
}
|
||||
|
||||
String dumpVectorOfDouble(const std::vector<double>& vec)
|
||||
{
|
||||
return dumpVector(vec, &floatFormat);
|
||||
}
|
||||
|
||||
String dumpVectorOfRect(const std::vector<Rect>& vec)
|
||||
{
|
||||
return dumpVector(vec, &noFormat);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -24,11 +24,6 @@
|
||||
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
#include <sstream>
|
||||
#include "opencl_kernels_core.hpp"
|
||||
#include "opencv2/core/opencl/runtime/opencl_clamdblas.hpp"
|
||||
#include "opencv2/core/opencl/runtime/opencl_core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -37,52 +32,75 @@ static bool intel_gpu_gemm(
|
||||
UMat B, Size sizeB,
|
||||
UMat D, Size sizeD,
|
||||
double alpha, double beta,
|
||||
bool atrans, bool btrans)
|
||||
bool atrans, bool btrans,
|
||||
bool& isPropagatedC2D
|
||||
)
|
||||
{
|
||||
CV_UNUSED(sizeB);
|
||||
|
||||
int M = sizeD.height, N = sizeD.width, K = ((atrans)? sizeA.height : sizeA.width);
|
||||
|
||||
std::string kernelName;
|
||||
bool ret = true;
|
||||
if (M < 4 || N < 4 || K < 4) // vload4
|
||||
return false;
|
||||
|
||||
size_t lx = 8, ly = 4;
|
||||
size_t dx = 4, dy = 8;
|
||||
CV_LOG_VERBOSE(NULL, 0, "M=" << M << " N=" << N << " K=" << K);
|
||||
|
||||
std::string kernelName;
|
||||
|
||||
unsigned int lx = 8, ly = 4;
|
||||
unsigned int dx = 4, dy = 8;
|
||||
|
||||
if(!atrans && !btrans)
|
||||
{
|
||||
|
||||
if (M % 32 == 0 && N % 32 == 0 && K % 16 == 0)
|
||||
{
|
||||
kernelName = "intelblas_gemm_buffer_NN_sp";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (M % 2 != 0)
|
||||
return false;
|
||||
// vload4(0, dst_write0) - 4 cols
|
||||
// multiply by lx: 8
|
||||
if (N % (4*8) != 0)
|
||||
return false;
|
||||
kernelName = "intelblas_gemm_buffer_NN";
|
||||
}
|
||||
}
|
||||
else if(atrans && !btrans)
|
||||
{
|
||||
if (M % 32 != 0)
|
||||
return false;
|
||||
if (N % 32 != 0)
|
||||
return false;
|
||||
kernelName = "intelblas_gemm_buffer_TN";
|
||||
}
|
||||
else if(!atrans && btrans)
|
||||
{
|
||||
if (K % 4 != 0)
|
||||
return false;
|
||||
kernelName = "intelblas_gemm_buffer_NT";
|
||||
ly = 16;
|
||||
dx = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (M % 32 != 0)
|
||||
return false;
|
||||
if (N % 32 != 0)
|
||||
return false;
|
||||
if (K % 16 != 0)
|
||||
return false;
|
||||
kernelName = "intelblas_gemm_buffer_TT";
|
||||
}
|
||||
|
||||
const size_t gx = (size_t)(N + dx - 1) / dx;
|
||||
const size_t gy = (size_t)(M + dy - 1) / dy;
|
||||
CV_LOG_DEBUG(NULL, "kernel: " << kernelName << " (M=" << M << " N=" << N << " K=" << K << ")");
|
||||
|
||||
const size_t gx = divUp((size_t)N, dx);
|
||||
const size_t gy = divUp((size_t)M, dy);
|
||||
|
||||
size_t local[] = {lx, ly, 1};
|
||||
size_t global[] = {(gx + lx - 1) / lx * lx, (gy + ly - 1) / ly * ly, 1};
|
||||
|
||||
int stride = (M * N < 1024 * 1024) ? 10000000 : 256;
|
||||
size_t global[] = {roundUp(gx, lx), roundUp(gy, ly), 1};
|
||||
|
||||
ocl::Queue q;
|
||||
String errmsg;
|
||||
@@ -110,10 +128,13 @@ static bool intel_gpu_gemm(
|
||||
(int)(D.step / sizeof(float))
|
||||
);
|
||||
|
||||
ret = k.run(2, global, local, false, q);
|
||||
bool ret = k.run(2, global, local, false, q);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
{
|
||||
int stride = (M * N < 1024 * 1024) ? 10000000 : 256;
|
||||
|
||||
for(int start_index = 0; start_index < K; start_index += stride)
|
||||
{
|
||||
ocl::Kernel k(kernelName.c_str(), program);
|
||||
@@ -132,12 +153,16 @@ static bool intel_gpu_gemm(
|
||||
(int) start_index, // 14 start_index
|
||||
stride);
|
||||
|
||||
ret = k.run(2, global, local, false, q);
|
||||
if (!ret) return ret;
|
||||
bool ret = k.run(2, global, local, false, q);
|
||||
if (!ret)
|
||||
{
|
||||
if (start_index != 0)
|
||||
isPropagatedC2D = false; // D array content is changed, need to rewrite
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
} // namespace cv
|
||||
|
||||
@@ -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 )
|
||||
{
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user