1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Compare commits

...

417 Commits

Author SHA1 Message Date
Alexander Alekhin 631126c77a release: OpenCV 3.4.17 2021-12-24 16:39:15 +00:00
Alexander Alekhin 655d381ef3 Merge pull request #21341 from alalek:issue_20930_3.4 2021-12-24 16:33:19 +00:00
Alexander Alekhin cdfa8a668b python: use '((x,y), (w,h), angle)' in std::vector<RotatedRect> 2021-12-24 15:01:45 +00:00
Alexander Alekhin 92651d228d Merge pull request #21329 from alalek:cmake_openexr_find_package 2021-12-24 11:56:12 +00:00
Alexander Alekhin 90e3692603 Merge pull request #21327 from alalek:imgcodecs_openexr_runtime_disabled 2021-12-24 11:55:55 +00:00
Alexander Alekhin 3a8316ab93 Merge pull request #21320 from catree:solvePnP_doc_page 2021-12-24 11:55:34 +00:00
Alexander Alekhin 8d3f0d0eab Merge pull request #21306 from aBITnav:patch-1 2021-12-24 10:49:10 +00:00
Alexander Alekhin cdd4354256 Merge pull request #21336 from alalek:dnn_pooling_check_array_indexes 2021-12-24 08:35:11 +00:00
Alexander Alekhin bde955fc56 Merge pull request #21335 from alalek:dnn_onnx_dump_input_output 2021-12-24 08:34:47 +00:00
Alexander Alekhin abc9e98625 Merge pull request #21325 from APrigarina:fix_asift_sample 2021-12-24 08:26:16 +00:00
ABHINAV JHA d086ee14dd Fix: Grammatical mistake 2021-12-24 08:01:13 +00:00
Alexander Alekhin f43fec7ee6 cmake: use find_package(OpenEXR) to support OpenEXR 3+ 2021-12-24 00:21:48 +00:00
Alexander Alekhin 6385511e88 dnn: add checks in pooling layer implementation
- to avoid out of buffer access
2021-12-24 00:15:30 +00:00
Alexander Alekhin ed4becf007 dnn(onnx): debug dump of inputs/outputs/initializers in importer 2021-12-23 21:11:40 +00:00
Alexander Alekhin f11ab4c569 Merge pull request #21331 from alalek:issue_21289 2021-12-23 20:09:52 +00:00
Alexander Alekhin b12c2c76d1 Merge pull request #21330 from alalek:fix_highgui_gtk_mouse_callbacks 2021-12-23 20:09:40 +00:00
Alexander Alekhin f5589445b9 Merge pull request #21322 from alalek:dnn_catch_errors 2021-12-23 20:09:22 +00:00
catree 032a61b197 Summarize PnP pose computation on a single separate page. 2021-12-23 19:52:14 +01:00
Alexander Alekhin 011ed380aa Merge pull request #21323 from alalek:dnn_do_not_rebuilt_network_in_setInput 2021-12-23 15:45:28 +00:00
Alexander Alekhin 88a18c8b6a dnn(onnx): emit error in Shape for dynamic input 2021-12-23 15:42:59 +00:00
Alexander Alekhin 51e65db715 dnn(onnx): fix Resize inputs handling 2021-12-23 15:42:59 +00:00
Alexander Alekhin cc02fcd889 dnn: improve debug messages, add ONNX opset version 2021-12-23 15:42:59 +00:00
Alexander Alekhin 9f17c62533 Merge pull request #21321 from alalek:dnn_test_decompose_dynamic_axes 2021-12-23 15:26:21 +00:00
Alexander Alekhin 36bd2a65e3 highgui(gtk): repair scroll events 2021-12-23 13:06:44 +00:00
Alexander Alekhin 85d4e56bb1 highgui(gtk): fix onmouse event flags 2021-12-23 12:15:14 +00:00
Alexander Alekhin 381d9bafdf imgcodecs: disable OpenEXR in runtime for 3rdparty source code
- builtin OpenEXR source code is outdated
- external OpenEXR distributions are allowed
2021-12-23 10:41:18 +00:00
APrigarina ada16fd188 prevent index error in find_obj sample 2021-12-23 11:29:27 +03:00
Alexander Alekhin c408157a4d dnn: do not try to rebuilt network during setInput()
- this doesn't make sense in case of multiple inputs
2021-12-23 02:40:33 +00:00
Alexander Alekhin 6e299b582a dnn(test): decompose 'DynamicAxes' test 2021-12-23 00:47:27 +00:00
Alexander Alekhin 19ac54277b Merge pull request #21313 from alalek:fix_links_3.4 2021-12-22 15:53:02 +00:00
Alexander Alekhin b1a57c4cb2 fix 3.4 links 2021-12-22 12:38:21 +00:00
dwardor 54c180092d Merge pull request #21114 from dwardor:patch-1
* Fix compile against lapack-3.10.0

Fix compilation against lapack >= 3.9.1 and 3.10.0 while not breaking older versions

OpenCVFindLAPACK.cmake & CMakeLists.txt: determine OPENCV_USE_LAPACK_PREFIX from LAPACK_VERSION

hal_internal.cpp : Only apply LAPACK_FUNC to functions whose number of inputs depends on LAPACK_FORTRAN_STR_LEN in lapack >= 3.9.1

lapack_check.cpp : remove LAPACK_FUNC which is not OK as function are not used with input parameters (so lapack.h preprocessing of "LAPACK_xxxx(...)" is not applicable with lapack >= 3.9.1
If not removed lapack_check fails so LAPACK is deactivated in build (not want we want)

use OCV_ prefix and don't use Global, instead generate OCV_LAPACK_FUNC depending on CMake Conditions

Remove CONFIG from find_package(LAPACK) and use LAPACK_GLOBAL and LAPACK_NAME to figure out if using netlib's reference LAPACK implementation and how to #define OCV_LAPACK_FUNC(f)

* Fix typos and grammar in comments
2021-12-22 12:00:00 +00:00
Alexander Alekhin 6e733b65ae Merge pull request #21302 from alalek:issue_21299_3.4 2021-12-21 18:39:52 +00:00
Alexander Alekhin 947d610309 Merge pull request #21297 from rogday:div_fix 2021-12-21 15:48:40 +00:00
Alexander Alekhin 3e01a387ba highgui: fix Win32 with OPENGL=ON 2021-12-21 15:44:59 +00:00
Alexander Alekhin b9d9730b62 Merge pull request #21295 from alalek:update_ffmpeg_3.4 2021-12-20 18:11:41 +00:00
rogday 0a178a687a fix const/x in Div 2021-12-20 19:53:37 +03:00
Alexander Alekhin 8fa86d4d34 ffmpeg/3.4: update FFmpeg wrapper 2021.12
- FFmpeg 3.4.9
2021-12-20 15:32:05 +00:00
Alexander Alekhin a22dd28e02 videoio: fix ffmpeg standalone build 2021-12-20 15:03:21 +00:00
Alexander Alekhin a079acc0d9 Merge pull request #21280 from alalek:update_version_3.4.17-pre 2021-12-18 13:46:29 +00:00
Stefano Allegretti 91817bffe1 Merge pull request #21275 from stal12:CCL_improvements
Improve CCL with new algorithms and tests

* Improve CCL with new algorithms and tests

* Split CCL test into dedicated tests cases
2021-12-17 19:36:57 +00:00
Alexander Alekhin 49bef1cdbf Merge pull request #21283 from rogday:flatten_fix 2021-12-17 14:27:40 +00:00
eplankin 175bcb1734 Merge pull request #21258 from eplankin:fix_threshold_to_zero_ipp_bug
Fixed threshold(THRESH_TOZERO) at imgproc(IPP)

* Fixed #16085: imgproc(IPP): wrong result from threshold(THRESH_TOZERO)

* 1. Added test cases with float where all bits of mantissa equal 1, min and max float as inputs
2. Used nextafterf instead of cast to hex

* Used float value in test instead of hex and casts

* Changed input value in test
2021-12-17 13:31:37 +00:00
Smirnov Egor fec2c7e715 fix Flatten layer 2021-12-17 16:29:56 +03:00
Alexander Alekhin 60c093f086 pre: OpenCV 3.4.17 (version++) 2021-12-17 10:05:52 +00:00
Alexander Alekhin f071207463 Merge pull request #21277 from alalek:backport_21267 2021-12-16 18:52:23 +00:00
Maksim Shabunin 792b7e0629 (3.4) Fixed several issues found by static analysis
original commit: a079c2eb7c
2021-12-16 17:02:58 +00:00
Alexander Alekhin cee3ec6dc4 Merge pull request #21271 from vrabaud:3.4_clip 2021-12-16 11:19:53 +00:00
Vincent Rabaud 3da17c42a4 Use NaN-safe clip function.
This is to prevent more NaN to int conversions like in #21111.
2021-12-16 11:34:04 +01:00
Alexander Alekhin 2329cbc1a2 Merge pull request #21269 from mshabunin:fix-hardening-o3 2021-12-16 09:17:51 +00:00
Maksim Shabunin b39ee54103 Do not force -O2 flag in hardening-enabled builds 2021-12-16 11:40:42 +03:00
Alexander Alekhin 6a889ed3e5 Merge pull request #21261 from alalek:dnn_onnx_test_filter_update 2021-12-15 16:24:04 +00:00
Alexander Alekhin f3ba88c87c dnn(test): update ONNX conformance filters 2021-12-15 12:53:53 +00:00
Alexander Alekhin e7c5120682 Merge pull request #21259 from rogday:random_fixes 2021-12-15 10:26:49 +00:00
Alexander Alekhin 19cfaa2be7 Merge pull request #21254 from alalek:build_opencv_winpack_dldt_2021.4.2 2021-12-15 08:17:09 +00:00
Smirnov Egor e97c7e042b fix max_unpool missing attributes, add default value of keepdims in reducemean/max/sum, add support for keepdims=true in full reduction branch, add new padding type to Pad 2021-12-14 22:09:27 +03:00
Alexander Alekhin 35f27d0d3e Merge pull request #21257 from alalek:imgproc_cvtcolor_lab_fix_nan 2021-12-14 16:59:07 +00:00
Alexander Alekhin 330a11861e Merge pull request #21256 from zchrissirhcz:fix-3.4-pyramid-tutorial 2021-12-14 16:58:53 +00:00
rogday 4827fe86bb Merge pull request #21088 from rogday:onnx_tests
Onnx conformance tests

* Add ONNX conformance tests

* dnn(test): add filters for ONNX conformance tests

* add filter lists for OCV backend

* address review comments

* move test_clip_inbounds to all_denylist

* address clip issue

* avoid empty lists

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-12-14 16:58:06 +00:00
Alexander Alekhin 72c55b56f2 imgproc: catch NaNs in clip(), use table index debug check
- no NaN propagation guarantee
2021-12-14 15:31:51 +00:00
Alexander Alekhin 4eab85d364 Merge pull request #21251 from vrabaud:3.4_bayer 2021-12-14 15:15:07 +00:00
Zhuo Zhang 3cc83ce024 docs: correct normalize factor in gaussian pyramid tutorial 2021-12-14 21:06:02 +08:00
Alexander Alekhin 52c423a423 build: winpack_dldt with dldt 2021.4.2 2021-12-14 09:00:43 +00:00
Vincent Rabaud 542b3e8a64 Fix harmless signed integer overflow.
When computing:
t1 = (bayer[1] + bayer[bayer_step] + bayer[bayer_step+2] + bayer[bayer_step*2+1])*G2Y;
there is a T (unsigned short or char) multiplied by an int which can overflow.
Then again, it is stored to t1 which is unsigned so the overflow disappears.
Keeping all unsigned is safer.
2021-12-13 23:43:49 +01:00
Alexander Alekhin 4f79eb256d Merge pull request #21250 from alalek:videoio_msmf_update_camera_3.4 2021-12-13 22:24:33 +00:00
Alexander Alekhin 7620456486 videoio(MSMF): add queue for async ReadSample() 2021-12-13 21:02:24 +00:00
Alexander Alekhin 5462710103 Merge pull request #21235 from jonay2000:fix-docs 2021-12-11 15:14:43 +00:00
Jonathan Dönszelmann d1b923bee9 Update name from Gunner to Gunnar as that's the name he published his
paper under.
2021-12-11 13:10:52 +01:00
Alexander Alekhin 04020f391a Merge pull request #21193 from alalek:imgproc_test_bitexact_cvtcolor_yuv 2021-12-10 16:11:06 +00:00
Alexander Alekhin c4ab0c09ea Merge pull request #21228 from alalek:issue_21198 2021-12-10 16:07:57 +00:00
Alexander Alekhin 9b7f40ce4d Merge pull request #21074 from vrabaud:3.4_rect 2021-12-10 11:32:03 +00:00
Alexander Alekhin 659cf7249e imgproc(ocl): fix resizeLN, avoid integer overflow 2021-12-09 20:30:26 +00:00
UncleLLD 62a010a25d Merge pull request #21224 from UncleLLD:fix-cvtColor-error
fix cvtColor-error

* fix gray image channel error

* fix gray image channel error

* fix cvtColor error after the video end

* fix cvtColor error after the video end and change next variable

* fix cvtColor error after the video end

* reset next variable

* fix cvtColor error after the video end

* fix cvtColor error after the video end
2021-12-09 19:11:05 +00:00
Vincent Rabaud 6b4ea68bc7 Solve Rect overflow issues.
Fow now, it is possible to define valid rectangle for which some
functions overflow (e.g. br(), ares() ...).
This patch fixes the intersection operator so that it works with
any rectangle.
2021-12-09 12:04:26 +01:00
Andrey Senyaev d6891c705e Merge pull request #21219 from asenyaev:asen/remove_distutils
* Replaced distutils module to sysconfig

* Fixed getting a path to python lib
2021-12-08 18:51:34 +00:00
Alexander Alekhin 16b674b984 Merge pull request #21213 from alalek:issue_20850_case1 2021-12-07 16:34:54 +00:00
Alexander Alekhin 65392d5e6b cmake: fix OPENGL_LIBRARIES handling 2021-12-07 12:12:42 +00:00
UncleLLD 5aef565fb6 Merge pull request #21188 from UncleLLD:fix-markdown-error
fix issue 21187: markdown file: gray image does not have three dimensions
2021-12-06 16:14:17 +00:00
Alexander Alekhin a3287b85c5 carotene: disable YUV color conversions (bit-exact issue) 2021-12-04 07:32:57 +00:00
Alexander Alekhin 0c0b1ec9ae imgproc(test): add bit-exact tests for YUV cvtColor conversions 2021-12-04 04:36:57 +00:00
Alexander Alekhin 35ff9af6ce Merge pull request #21162 from rogday:softmax_simplification 2021-12-02 17:14:48 +00:00
Alexander Alekhin dad2b9aac8 Merge pull request #21160 from rogday:elu_alpha 2021-12-02 17:13:57 +00:00
rogday 1613d30544 Merge pull request #21159 from rogday:ceil_mode
fix ceil_mode for Average/MaxPooling

* fix ceil_mode

* add a comment
2021-12-02 20:11:11 +03:00
Alexander Alekhin b6df9debaf Merge pull request #21174 from APrigarina:fix_qr_encoder 2021-12-02 16:41:03 +00:00
Alexander Alekhin b9d0dc60b0 Merge pull request #21173 from alalek:3.4_dnn_test_reenable_ov_2021_4 2021-12-02 16:33:15 +00:00
APrigarina 37b1876807 qr encoder: fix memory and unused variables issues 2021-12-02 18:35:33 +03:00
Alexander Alekhin bd396e1fd5 dnn(test): re-enable tests which works with OpenVINO 2021.4.x (3.4) 2021-12-02 11:30:45 +00:00
Alexander Alekhin 5da69c0b9a Merge pull request #21164 from rogday:sum_identity 2021-12-01 22:49:02 +00:00
Alexander Alekhin a806e8cc58 Merge pull request #21163 from rogday:transpose_default 2021-12-01 22:47:57 +00:00
Vincent Rabaud 1a1a7bbbfd Merge pull request #21112 from vrabaud:3.4_luv_overflow
* Fix integer overflow in cv::Luv2RGBinteger::process.

For LL=49, uu=205, vv=23, we end up with x=7373056 and y=458
which overflows y*x.

* imgproc(test): adjust test parameters to cover SIMD code
2021-12-01 15:46:03 +03:00
Smirnov Egor 33e97e994d add sum of 1 input 2021-11-30 15:42:20 +03:00
Smirnov Egor 11e6848bb9 add default order to transpose 2021-11-30 15:34:34 +03:00
Smirnov Egor 829410729c add new (Log)SoftMax simplification passes 2021-11-30 15:20:52 +03:00
Smirnov Egor 0e2a3686c0 add alpha parameter to ELU layer 2021-11-30 12:20:35 +03:00
Alexander Alekhin 0d2857a242 Merge pull request #21152 from rogday:fix_defaults 2021-11-29 22:39:27 +00:00
Alexander Alekhin 17d99e6266 Merge pull request #21142 from alalek:dnn_two_inputs_ocl_fp16_3.4 2021-11-29 21:44:59 +00:00
Andrew Ryrie ea7d4be3f8 Merge pull request #20658 from smbz:lstm_optimisation
* dnn: LSTM optimisation

This uses the AVX-optimised fastGEMM1T for matrix multiplications where available, instead of the standard cv::gemm.

fastGEMM1T is already used by the fully-connected layer.  This commit involves two minor modifications:
 - Use unaligned access.  I don't believe this involves any performance hit in on modern CPUs (Nehalem and Bulldozer onwards) in the case where the address is actually aligned.
 - Allow for weight matrices where the number of columns is not a multiple of 8.

I have not enabled AVX-512 as I don't have an AVX-512 CPU to test on.

* Fix warning about initialisation order

* Remove C++11 syntax

* Fix build when AVX(2) is not available

In this case the CV_TRY_X macros are defined to 0, rather than being undefined.

* Minor changes as requested:

 - Don't check hardware support for AVX(2) when dispatch is disabled for these
 - Add braces

* Fix out-of-bounds access in fully connected layer

The old tail handling in fastGEMM1T implicitly rounded vecsize up to the next multiple of 8, and the fully connected layer implements padding up to the next multiple of 8 to cope with this.  The new tail handling does not round the vecsize upwards like this but it does require that the vecsize is at least 8.  To adapt to the new tail handling, the fully connected layer now rounds vecsize itself at the same time as adding the padding(which makes more sense anyway).

This also means that the fully connected layer always passes a vecsize of at least 8 to fastGEMM1T, which fixes the out-of-bounds access problems.

* Improve tail mask handling

 - Use static array for generating tail masks (as requested)
 - Apply tail mask to the weights as well as the input vectors to prevent spurious propagation of NaNs/Infs

* Revert whitespace change

* Improve readability of conditions for using AVX

* dnn(lstm): minor coding style changes, replaced left aligned load
2021-11-29 21:43:00 +00:00
Smirnov Egor 05db8784ae fix Clip, LeakyReLU, LRN, Split defaults 2021-11-29 20:20:34 +03:00
Alexander Alekhin 58b06222ff dnn(DataLayer): fix CPU/OpenCL code paths for FP16 handling 2021-11-28 07:44:05 +00:00
Alexander Alekhin 58dc397930 dnn(test): add two_inputs test with FP32/U8 data types
- remove similar test from IE scope under HAVE_INF_ENGINE
2021-11-28 07:44:04 +00:00
yuki takehara a6277370ca Merge pull request #21107 from take1014:remove_assert_21038
resolves #21038

* remove C assert

* revert C header

* fix several points in review

* fix test_ds.cpp
2021-11-27 18:34:52 +00:00
Alexander Alekhin b55d8f46f4 Merge pull request #21133 from alalek:dnn_test_ie_update_3.4 2021-11-26 20:35:58 +00:00
Alexander Alekhin 985aa0423d dnn(test): update InferenceEngine tests 2021-11-26 18:46:26 +00:00
Alexander Alekhin c14a8dce93 Merge pull request #21131 from cclauss:codespell 2021-11-26 18:32:54 +00:00
Alexander Alekhin f5d45221ca Merge pull request #21130 from cclauss:print-function 2021-11-26 18:31:32 +00:00
Christian Clauss ebe4ca6b60 Fix typos discovered by codespell 2021-11-26 12:29:56 +01:00
Alexander Alekhin f159ed20c2 Merge pull request #21128 from cclauss:patch-3 2021-11-26 11:11:58 +00:00
Christian Clauss cdbb042ce4 Use print() function in both Python 2 and Python 3 2021-11-26 11:57:54 +01:00
Christian Clauss 23bbe511fe CMakeLists.txt: Fix typo discovered by codespell
https://pypi.org/project/codespell/
2021-11-26 11:07:14 +01:00
Alexander Alekhin 444218e755 Merge pull request #21123 from cclauss:patch-3 2021-11-25 18:06:33 +00:00
Christian Clauss 9cc60c9dd3 Use ==/!= to compare constant literals (str, bytes, int, float, tuple)
Avoid `SyntaxWarning` on Python >= 3.8
```
>>> "convolutional" == "convolutional"
True
>>> "convolutional" is "convolutional"
<stdin>:1: SyntaxWarning: "is" with a literal. Did you mean "=="?
True
```
Related to #21121
2021-11-25 15:39:58 +01:00
Alexander Alekhin 2c226d597d Merge pull request #21110 from alalek:update_libjpeg-turbo 2021-11-24 20:08:27 +00:00
Alexander Alekhin c6ab32ffb9 3rdparty: libjpeg-turbo 2.1.0 => 2.1.2
https://github.com/libjpeg-turbo/libjpeg-turbo/releases/tag/2.1.2
2021-11-24 04:00:47 +00:00
Alexander Alekhin 101be77d9d Merge pull request #21092 from alalek:core_logger_show_timestamp 2021-11-22 22:44:31 +00:00
Alexander Alekhin 61f1ee2d2d core(logger): dump timestamp information with message 2021-11-20 15:34:23 +00:00
Alexander Alekhin 93b6e80cd7 Merge pull request #21063 from vrabaud:3.4_h_clamping 2021-11-19 20:28:25 +00:00
Vincent Rabaud d4741eece1 Fix H clamping for very small negative values.
In case of very small negative h (e.g. -1e-40), with the current implementation,
you will go through the first condition and end up with h = 6.f, and will miss
the second condition.
2021-11-19 16:34:09 +01:00
Alexander Alekhin 585484cb06 Merge pull request #21067 from NickJackolson:nickjackolson/imread-warning 2021-11-18 22:48:40 +00:00
nickjackolson b696928a5b add !empty assertion in seamlessClone()
issue #20617 addresses lack of warnings on
seamlessClone() function when src is None.
This commit adds source check using CV_Assert
therefore debugging would be easier.

Signed-off-by: nickjackolson <metedurlu@gmail.com>
2021-11-18 21:19:05 +01:00
nickjackolson 79d4e865fe Add warning message to imread()
Add a warning message using CV_LOG__WARNING().
This way api behaviour is preserved. Outputs are
the same but user gets an extra warning in case
fopen() fails to access image file for some reason.
This would help new users and also debugging
complex apps which use imread()

Signed-off-by: nickjackolson <metedurlu@gmail.com>
2021-11-18 21:19:05 +01:00
Alexander Alekhin 8380879804 Merge pull request #21077 from alalek:js_test_pin_cli_table 2021-11-18 18:34:44 +00:00
Alexander Alekhin de7f8eec04 js(test): pin cli-table dependency 2021-11-18 05:40:16 +00:00
Alexander Alekhin 49432009fe Merge pull request #21064 from alalek:doc_videoio_api_preference_3.4 2021-11-16 20:05:59 +00:00
Alexander Alekhin 473f10877c doc(videoio): fix apiPreference note, replace DSHOW(deprecated)->MSMF 2021-11-16 17:08:11 +00:00
Qiushi Zheng 3e51448ef0 Merge pull request #17889 from ZhengQiushi:my_3.4
QR code (encoding process)

* add qrcode encoder

* qr encoder fixes

* qr encoder: fix api and realization

* fixed qr encoder, added eci and kanji modes

* trigger CI

* qr encoder constructor fixes

Co-authored-by: APrigarina <ann73617@gmail.com>
2021-11-15 17:15:39 +00:00
Alexander Alekhin 8041ab8a61 Merge pull request #21025 from alalek:issue_21004
* dnn(ocl4dnn): fix LRN layer accuracy problems

- FP16 intermediate computation is not accurate and may provide NaN values

* dnn(test): update tolerance for FP16
2021-11-12 01:54:07 +03:00
tv3141 cb286a66be Merge pull request #21030 from tv3141:fix_seg_fault_houghlinespointset
Fix seg fault houghlinespointset

* Clarify parameter doc for HoughLinesPointSet

* Fix seg fault.

* Add regression test.

* Fix latex typo
2021-11-10 22:15:38 +03:00
Alexander Alekhin f33828a1ca Merge pull request #20870 from pkubaj:master 2021-11-10 16:08:20 +00:00
Piotr Kubaj 68e425f869 Add support for runtime CPU feature check on POWER on FreeBSD.
1. Code uses PPC_FEATURE_HAS_VSX, but it's not checked similarly to
PPC_FEATURE2_ARCH_3_00 and PPC_FEATURE2_ARCH_3_00 for availability. FreeBSD has
those macros in machine/cpu.h, but I went with the way chosen for
PPC_FEATURE2_ARCH_3_00 and PPC_FEATURE2_ARCH_3_00. Other than that, FreeBSD also
has sys/auxv.h and that's where elf_aux_info() is defined.
2. getauxval() is actually Linux-only, but code checked for __unix__. It won't
work on all UNIX, so change it back to __linux__. Add another code variant
strictly for FreeBSD.
3. Update comment. This commit adds code for FreeBSD, but recently there
appeared support for powerpc64 in OpenBSD.
2021-11-10 13:28:09 +00:00
ZaKiiiiiiiii 98b6ce353c Merge pull request #20904 from Crayon-new:fix_bug_in_maxLayer
fix bug: wrong output dimension when "keep_dims" is false in pooling layer.

* fix bug in max layer

* code align

* delete permute layer and add test case

* add name assert

* check other cases

* remove c++11 features

* style:add "const" remove assert

* style:sanitize file names
2021-11-09 19:24:04 +03:00
Alexander Alekhin 1ac7baceff Merge pull request #21005 from nikpappas:bug-samples-falsecolor-trackbar 2021-11-06 14:19:58 +00:00
Nikolaos Pappas 968d94d417 Fix trackbar in falsecolor cpp sample 2021-11-06 10:11:58 +00:00
Alexander Alekhin 2ce47fda88 Merge pull request #21011 from vrabaud:3.4 2021-11-05 09:25:50 +00:00
Vincent Rabaud ffd010767f Only use fma functions when CV_FMA3 is set.
In practice, processors offering AVX2/AVX512 also FMA, that is why it got unnoticed.
2021-11-04 23:15:49 +01:00
Alexander Alekhin edf533c83e Merge pull request #21007 from alalek:cmake_dnn_fix_wrong_tengine_order 2021-11-04 12:28:27 +00:00
Alexander Alekhin c1d61c88e9 dnn(cmake): don't hijack OpenCL options with Tengine 2021-11-04 09:59:19 +00:00
Alexander Alekhin 6360b846c6 Merge pull request #21003 from APrigarina:add_test_qrdetect_fix 2021-11-03 22:32:00 +00:00
Alexander Alekhin 57900d07f0 Merge pull request #20882 from flytogcp:flytogcp-patch-1 2021-11-03 20:30:24 +00:00
APrigarina 8e72e1ed88 add test case for QR detect fix 2021-11-03 19:56:54 +00:00
Alexander Alekhin 10c547396d Merge pull request #20990 from alalek:fix_warnings_msvc_clang_dshow_3.4 2021-11-03 19:51:31 +00:00
cpengu 66dd871288 Update qrcode.cpp
Fixed issue #20880, QRDetect::searchHorizontalLines() boundary condition will skip the matched qrcode near the end
2021-11-03 19:45:24 +00:00
Alexander Alekhin d484939c02 Merge pull request #20999 from alalek:dnn_replace_deprecated_calls
dnn(protobuf): replace deprecated calls

* dnn: replace deprecated ByteSize() => ByteSizeLong()

* dnn: replace deprecated calls, use GetRepeatedFieldRef
2021-11-03 15:59:36 +00:00
Alexander Alekhin 85fd8729ce Merge pull request #20970 from s-trinh:update_Bayer_naming 2021-11-02 20:41:17 +00:00
Alexander Alekhin b3e16c6423 videoio(dshow): eliminate build warnings from MSVC-Clang 2021-11-02 19:22:47 +00:00
Souriya Trinh 30d6766db4 Add conventional Bayer naming. 2021-11-02 20:17:57 +01:00
Alexander Alekhin bce76a7977 Merge pull request #20980 from alalek:highgui_fix_cvGetWindowImageRect_3.4 2021-10-30 13:59:08 +00:00
Alexander Alekhin 0ee61d178f highgui: drop invalid cvGetWindowImageRect
- return type is C++ template
- removal from 'extern "C"' scope broke ABI anyway, so this symbols is removed completelly
2021-10-30 12:40:20 +00:00
Alexander Alekhin 0e9453a395 Merge pull request #20971 from alalek:cmake_build_type_use_release 2021-10-29 17:45:09 +00:00
Alexander Alekhin e5647cf70d cmake: use CMAKE_BUILD_TYPE=Release by default 2021-10-29 15:15:17 +00:00
Alexander Alekhin 74cc63ba2f Merge pull request #20969 from alalek:fix_msvc_clang_warning_noreturn 2021-10-28 23:00:49 +00:00
Alexander Alekhin 0b6e360602 Merge pull request #20967 from alalek:fix_msvc_clang_unused_parameter 2021-10-28 22:27:41 +00:00
Alexander Alekhin a49cda6523 core: eliminate Winvalid-noreturn in base.hpp 2021-10-28 21:33:20 +00:00
Alexander Alekhin d612c72405 build: fix MSVC-Clang warnings about unused parameters in stubs 2021-10-28 21:08:36 +00:00
Alexander Alekhin 6bd143dd25 Merge pull request #20961 from alalek:fix_msvc_clang 2021-10-28 13:54:24 +00:00
Alexander Alekhin 770d3eabc0 Merge pull request #20960 from alalek:fix_icc_support_3.4 2021-10-28 13:54:07 +00:00
Alexander Alekhin 75e2ba5af3 core(simd): fix compilation with MSVC-Clang 2021-10-28 11:25:00 +00:00
Alexander Alekhin 1726bb6c0d build(icc): fix nodiscard attribute handling 2021-10-28 05:52:22 +00:00
Alexander Alekhin 5dfe65d53a cmake: fix popcnt detection with Intel Compiler 2021-10-28 05:37:23 +00:00
Alexander Alekhin d059cc7170 Merge pull request #20958 from noahstier:3.4_tvl1_optimization 2021-10-27 19:59:57 +00:00
Noah Stier 84a81579ba tvl1 cuda optflow optimization 2021-10-27 12:01:53 -07:00
Alexander Alekhin aa11cc19e8 Merge pull request #20919 from berak:patch-1 2021-10-22 14:08:08 +00:00
berak a6f5717567 resolves #20913
imgproc: remove asserts for circles_ in HoughCircles
2021-10-22 15:07:57 +02:00
Alexander Alekhin 12507aab8a Merge pull request #20912 from AleksandrPanov:fix_findMinEnclosingTriangle 2021-10-21 16:26:53 +00:00
AleksandrPanov d21622bef4 fix findMinEnclosingTriangle and add tests 2021-10-21 18:12:51 +03:00
Alexander Alekhin bc8eac2439 Merge pull request #20906 from alalek:backport_20903 2021-10-21 13:03:46 +00:00
Alexander Alekhin 4e65db80e8 Merge pull request #20916 from Harvey-Huang:32bit_rgb 2021-10-21 11:45:48 +00:00
Harvey ce68291d83 32bit rgb bmp file should not copy data as rgba 2021-10-21 16:47:27 +08:00
Alexander Alekhin f77fdc0ce8 samples: fix build without threading support 2021-10-19 13:35:09 +00:00
Zhuo Zhang 7da51787b9 Merge pull request #20900 from zchrissirhcz:3.4-hwfeatures-support-qnx
* fix: correctly check neon flags for QNX platform

* refactor: change __QNXNTO__ to __QNX__
2021-10-19 13:30:27 +00:00
Alexander Alekhin b1f422c1c5 Merge pull request #20894 from alalek:core_simd_int64_ctor_sse 2021-10-19 13:29:52 +00:00
rogday b3f966e2ca Merge pull request #20883 from rogday:eltwise_refactoring
* backport elementwise_layers refactor

* keep NULL
2021-10-19 13:29:22 +00:00
Alexander Alekhin 3f191e1b75 Merge pull request #20897 from ThalesGroup:master 2021-10-19 13:27:54 +00:00
Michel Promonet 9a9e457dd6 Allow to set av_log_set_level to reduce ffmpeg level below AV_LOG_ERROR 2021-10-19 10:46:41 +02:00
Alexander Alekhin c316dbe2aa Merge pull request #20895 from sergiud:avx-error-immediate 2021-10-18 19:08:50 +00:00
Alexander Alekhin b5fcb06a76 core(SIMD): update int64 SSE constructor 2021-10-18 18:59:40 +00:00
Sergiu Deitsch f8f9f3c438 fixed AVX compile error
Some older compilers do not allow to pass a `const int` as an immediate. Use an unnamed enum instead.
2021-10-18 14:56:19 +02:00
Alexander Alekhin e6c68eed51 Merge pull request #20879 from Wehzie:patch-1 2021-10-17 16:50:13 +00:00
Wehzie f9e747dbc6 Fixed typo in CV_Error message
Error was "Input parameters must be a matrices!", but "matrices" is plural and doesn't allow the unspecific article "a".
2021-10-17 15:37:14 +03:00
Nicholas Ho bd0732b1d0 Merge pull request #20740 from Nicholas-Ho-arm:3.4_SymmColumnVec_32f8u
* Add SymmColumnVec_32f8u

* Fix double to float warnings
2021-10-15 11:47:53 +00:00
Alexander Alekhin 0b5cbcefdd Merge pull request #20868 from icestraw:fix-type-error-of-slice-indices 2021-10-14 16:11:37 +00:00
icestraw e4a87f2f4f fix type error of slice indices 2021-10-14 11:52:35 +08:00
Alexander Alekhin 3c8cadf7ca Merge pull request #20867 from alalek:fix_CV_POPCNT_U64_msvs 2021-10-13 17:08:58 +00:00
Alexander Alekhin 7c0b26e8a0 Merge pull request #20834 from sthalik:msvc-shared-library-static-crt 2021-10-13 14:21:08 +00:00
Alexander Alekhin 982503e9a8 core: ensure 'int' result from CV_POPCNT_U64(x) 2021-10-13 01:14:37 +00:00
Stanislaw Halik 3d93675ff9 fix link error on shared libs with -MT 2021-10-12 17:50:31 +02:00
Alexander Alekhin 53d6c9b9c0 Merge pull request #20860 from rogday:sum_fix 2021-10-12 15:36:32 +00:00
Alexander Alekhin a02e90d502 Merge pull request #20859 from rogday:sub_const_fix 2021-10-11 18:51:46 +00:00
Smirnov Egor 238dbffb48 change asserts for Sum 2021-10-11 20:59:44 +03:00
Smirnov Egor a9d7b6eab7 fix const - input and remove unimplemented function 2021-10-11 18:58:10 +03:00
Alexander Alekhin 62252d157e Merge tag '3.4.16' 2021-10-08 19:05:00 +00:00
Alexander Alekhin b1cf550123 release: OpenCV 3.4.16 2021-10-08 18:31:56 +00:00
Alexander Alekhin 17bd9a1fa1 Merge pull request #20841 from alalek:core_keep_TlsAbstraction_singleton_3.4 2021-10-08 07:01:05 +00:00
Alexander Alekhin 0321644bbd Merge pull request #20842 from alalek:valgrind_suppression 2021-10-08 09:29:41 +03:00
Alexander Alekhin 81e7988eb9 Merge pull request #20840 from alalek:dnn_ocl_cleanup_code 2021-10-08 05:07:51 +00:00
Alexander Alekhin 4985311d46 core(tls): avoid destruction of TlsAbstraction singleton 2021-10-08 03:12:58 +00:00
Alexander Alekhin 05348f3250 Merge pull request #20839 from alalek:issue_20828_netbsd 2021-10-08 02:19:54 +00:00
Alexander Alekhin 003609e565 Merge pull request #20838 from alalek:fix_20833 2021-10-08 02:09:46 +00:00
Jonas Vautherin 9537a909f7 Merge pull request #20801 from JonasVautherin:fix-gst-error-handling
* Fix gst error handling

* Use the return value instead of the error, which gives no guarantee of being NULL in case of error
* Test err pointer before accessing it
* Remove unreachable code

* videoio(gstreamer): restore check in writer code

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-10-08 02:07:04 +00:00
Alexander Alekhin 8c2dd5fb9a dnn(ocl4dnn): cleanup dead code, improve logging 2021-10-08 00:39:40 +00:00
Alexander Alekhin 27545dcc86 core: add __NetBSD__ build fix in parallel.cpp 2021-10-07 23:29:28 +00:00
Alexander Alekhin 724e04e979 dnn(ocl4dnn): add extra checks to convolution layer
- prevent running code over unsupported/non-tested configurations
- prevent integer div by zero
2021-10-07 23:18:32 +00:00
Alexander Panov dfc94c58f0 Merge pull request #20823 from AleksandrPanov:fix_orb_integer_overflow
Fix ORB integer overflow

* set size_t step to fix integer overflow in ptr0 offset

* added issue_537 test

* minor fix tags, points

* added size_t_step and offset to remove mixed unsigned and signed operations

* features2d: update ORB checks

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-10-07 22:46:25 +00:00
Alexander Alekhin fac895d7ba Merge pull request #20831 from sthalik:fix-msvc-build-3.4 2021-10-07 16:16:59 +00:00
Stanislaw Halik 04b40ff221 add new supported MSVC version 2021-10-07 13:46:34 +02:00
Oliver Kuckertz a3d7811f24 Merge pull request #20725 from mologie:fix-dnn-tf-on-arm
* dnn: fix unaligned memory access crash on armv7

The getTensorContent function would return a Mat pointing to some
member of a Protobuf-encoded message. Protobuf does not make any
alignment guarantees, which results in a crash on armv7 when loading
models while bit 2 is set in /proc/cpu/alignment (or the relevant
kernel feature for alignment compatibility is disabled). Any read
attempt from the previously unaligned data member would send SIGBUS.

As workaround, this commit makes an aligned copy via existing clone
functionality in getTensorContent. The unsafe copy=false option is
removed. Unfortunately, a rather crude hack in PReLUSubgraph in fact
writes(!) to the Protobuf message. We limit ourselves to fixing the
alignment issues in this commit, and add getTensorContentRefUnaligned
to cover the write case with a safe memcpy. A FIXME marks the issue.

* dnn: reduce amount of .clone() calls

* dnn: update FIXME comment

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-10-06 16:41:05 +00:00
Alexander Alekhin 755e0143fb Merge pull request #20815 from alalek:fix_20649_revert_19859
features2d: repair SimpleBlobDetector

* features2d: revert code change by PR #19859

Reverted commit 76860933f0

* features2d: check SimpleBlobDetector parameters consistency
2021-10-06 15:05:45 +03:00
Alexander Alekhin dfa48094dc Merge pull request #20814 from alalek:dnn_pytest_input_3d 2021-10-06 12:02:34 +00:00
Alexander Alekhin e585192eeb Merge pull request #20802 from alalek:core_tls_init_TlsAbstraction 2021-10-06 12:01:06 +00:00
Alexander Alekhin 646924fce8 dnn(pytest/test_input_3d): reload model between switching targets 2021-10-05 23:23:08 +00:00
Alexander Alekhin c63aa7f085 Merge pull request #20808 from alalek:update_ffmpeg_3.4 2021-10-05 15:06:08 +00:00
Alexander Alekhin c54abde1bd ffmpeg/3.4: update FFmpeg wrapper 2021.10
- FFmpeg 3.4.8 (no changes)
2021-10-05 10:09:27 +03:00
Alexander Alekhin 95c1d2a887 Merge pull request #20806 from alalek:update_version_3.4.16-pre 2021-10-04 22:50:26 +00:00
Alexander Alekhin ebef84e9ea pre: OpenCV 3.4.16 (version++) 2021-10-04 20:47:07 +00:00
Alexander Alekhin b1a772d194 Merge pull request #20803 from alalek:core_parallel_workaround_tsan 2021-10-04 19:16:27 +00:00
keroiber f11f2bfb56 Merge pull request #20743 from keroiber:prefix_js_function_bindings_with_namespace
* Prefix global javascript functions with sub-namespaces

* js: handle 'namespace_prefix_override', update filtering

- avoid functions override with same name but different namespace

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-10-04 16:51:49 +00:00
xhawk18 24f43e7ae9 Merge pull request #20183 from xhawk18:3.4
* improve compatibility for qt 6.

* cmake(highgui): rework Qt dependency support

* cmake(highgui): workaround Qt5Config.cmake "components" bug

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-10-04 16:44:57 +00:00
Alexander Alekhin d94d469c86 valgrind: update suppressions 2021-10-04 16:27:05 +00:00
Alexander Alekhin d20c9bde7e core(TLS): force TlsAbstraction initialization before main() 2021-10-04 11:34:09 +00:00
Alexander Alekhin 62414e3073 core(parallel): suppress TSAN warning 2021-10-04 10:46:32 +00:00
Alexander Alekhin 48c985e775 Merge pull request #20797 from sturkmen72:restore_LSD 2021-10-02 17:50:38 +00:00
Alexander Alekhin 7358fffb0f Merge pull request #20796 from JonasVautherin:patch-1 2021-10-02 17:48:23 +00:00
Jonas Vautherin de5b6386e0 Fix gst_initializer
Use the return value of gst_init_check instead of testing the error pointer
2021-10-02 15:42:13 +00:00
Alexander Alekhin 1de2d5c2b6 Merge pull request #20795 from JBamberger:gradle-dynamic-cv-version 2021-10-02 15:35:56 +00:00
Jannik Bamberger ef53a9229f Automatically set the correct OpenCV version in build.gradle
Automatically sets the correct OpenCV version in the CMAKE example contained in the build.gradle
file of the Android SDK.
2021-10-02 16:06:33 +02:00
Suleyman TURKMEN 259c39a63a additional changes 2021-10-02 13:34:56 +03:00
Alexander Alekhin 327b98eb13 Merge pull request #20794 from alalek:dnn_ocl_fix_conv_dwconv_workgroup 2021-10-01 22:25:47 +00:00
Alexander Alekhin f977d10a19 dnn(ocl): fix conv DWCONV workgroup 2021-10-01 18:52:07 +00:00
Alexander Alekhin a0cf8c322d Merge pull request #20793 from tomoaki0705:fixGaussianOverflow 2021-10-01 15:53:15 +00:00
Tomoaki Teshima 1e74f5850b suppress GaussianBlur to generate empty images
* sharp Gaussian kernel causes over flow and ends up in blank image
2021-10-01 23:17:02 +09:00
Suleyman TURKMEN 9b76872708 restore LSD 2021-10-01 16:23:16 +03:00
Alexander Alekhin 4d587c341b Merge pull request #20774 from alalek:dnn_ocl_fix_conv_basic_workgroup 2021-09-30 10:16:26 +00:00
Alexander Alekhin 846317ef37 dnn(ocl): fix conv BASIC workgroup 2021-09-29 14:55:46 +00:00
Alexander Alekhin 7e62789edf Merge pull request #20763 from Cavendish-Koo:houghlines_sdiv_bug_fix 2021-09-29 11:04:13 +00:00
Alexander Alekhin 852663f6d2 Merge pull request #20748 from sturkmen72:clean_up_test_data 2021-09-28 20:45:39 +03:00
Alexander Alekhin a9b30984a3 Merge pull request #20762 from fishmandev:patch-1 2021-09-28 15:00:13 +00:00
Cavendish-Koo 2f83c3b689 fix the bug of HoughlinesSDIV 2021-09-28 21:18:07 +08:00
Dmitriy Fishman b25ad12f1a Update video_input_psnr_ssim.markdown 2021-09-28 15:29:47 +03:00
Alexander Alekhin d95e43a6a1 Merge pull request #20754 from asmorkalov:as/parser_verbose_print 2021-09-28 11:47:55 +00:00
Alexander Smorkalov 2cc14bd0fb Verbose output for errors found by header parser. 2021-09-27 10:53:23 +03:00
Suleyman TURKMEN fdc8ed8d05 Update perf_bgfg_mog2.cpp, perf_bgfg_knn.cpp 2021-09-25 23:06:50 +03:00
Nicholas Ho 236c64a17d Merge pull request #20712 from Nicholas-Ho-arm:3.4_RowVec_8u32f
* Add RowVec_8u32f

* Fix build errors in Linux x64 Debug and armeabi-v7a

* Reformat code to make it more clean and conventional

* Optimise with vx_load_expand_q()
2021-09-25 17:43:33 +00:00
Alexander Alekhin f96569da1e Merge pull request #20746 from easonycwang:easonycwang/inpaint_perf_opt 2021-09-24 17:38:56 +00:00
easonycwang 91ff45fbde Tile:
This submission is used to improve the performance of the inpaint algorithm for 3 channels images(RGB or BGR).

Reason:
The original algorithm implementation did not consider the cache hits.
The loop of channels is outside the core loop, so the perfmance is not very good.
Moving the channel loop inside the core loop can significantly improve cache hits, thereby improving performance.

Performance:
360P, about >= 30% improvement
iphone8P: 5.52ms -> 3.75ms
iphone6s: 14.04ms -> 9.15ms
2021-09-24 21:47:14 +08:00
Alexander Alekhin 45aabc5d0d Merge pull request #20742 from UnaNancyOwen:fix_text_detection 2021-09-24 10:56:22 +00:00
Tsukasa Sugiura f9bd83c854 fix cast in text detection sample 2021-09-24 15:56:02 +09:00
Amir Tulegenov 86a51015b1 Merge pull request #19554 from amirtu:OCV-215_cvtColorTwoPlane_wrong_output_when_Y_Plane_Mat_has_step
different paddings in cvtColorTwoPlane() for biplane YUV420

* Different paddings support in cvtColorTwoPlane() for biplane YUV420

* Build fix for dispatch case.

* Resoted old behaviour for y.step==uv.step to exclude perf regressions.

Co-authored-by: amir.tulegenov <amir.tulegenov@xperience.ai>
Co-authored-by: Alexander Smorkalov <alexander.smorkalov@xperience.ai>
2021-09-22 17:42:32 +03:00
Alexander Alekhin 998406d20e Merge pull request #20729 from MikaelUrankar:3.4 2021-09-21 22:30:49 +00:00
mikael f7b4b750d8 Detect FP16 on FreeBSD aarch64 2021-09-21 19:48:58 +02:00
Alexander Alekhin a4e2c56317 Merge pull request #20713 from SamFC10:unsqueeze-opset13 2021-09-21 15:27:48 +00:00
SamFC10 9c5d7716e2 fix for unsqueeze opset version 13 2021-09-17 17:40:57 +05:30
Alexander Alekhin 46fd26e366 Merge pull request #20699 from alalek:dnn_perf_update_convolution_tests 2021-09-16 17:11:32 +00:00
rogday c410d7a97d Merge pull request #20671 from rogday:yolov4x-mish
Add support for YOLOv4x-mish

* backport to 3.4 for supporting yolov4x-mish

* add YOLOv4x-mish test

* address review comments

Co-authored-by: Guo Xu <guoxu@1school.com.cn>
2021-09-14 17:49:49 +00:00
Alexander Alekhin 6fa63dcc0c Merge pull request #20700 from alalek:cmake_fix_handling_ie_version 2021-09-14 17:17:54 +00:00
Alexander Alekhin 96f25332ea Merge pull request #20692 from sturkmen72:update_convexhull_cpp 2021-09-14 08:59:35 +00:00
Alexander Alekhin 3385d38648 cmake: fix handling of INF_ENGINE_RELEASE
- default value should be handled earlier
2021-09-14 08:56:09 +00:00
Alexander Panov 1618c963e4 Merge pull request #20676 from AleksandrPanov:delete_createConvexHull_convertTo
* deleted dublicated createConvexHull and convertTo

* replaced checkVector(2) with points.empty()
2021-09-13 19:27:00 +03:00
Alexander Alekhin 1e3be09b3b Merge pull request #20693 from alalek:backport_merge34_fix 2021-09-12 11:09:51 +00:00
Alexander Alekhin 6e66a9222a dnn(onnx): fix format specifier 2021-09-11 22:26:52 +00:00
Suleyman TURKMEN 9d1e8b1e1d Update convexhull.cpp 2021-09-11 23:58:14 +03:00
Alexander Alekhin f605373a2b Merge pull request #20690 from alalek:build_opencv_winpack_dldt_2021.4.1 2021-09-11 16:26:51 +00:00
Alexander Alekhin 56b7622612 Merge pull request #20687 from alalek:core_ocl_fix_intel_gemm 2021-09-11 16:26:25 +00:00
Alexander Alekhin 696a6ccd57 Merge pull request #20686 from zihaomu:tf_biasadd_bug
DNN: BiasAdd tf_importer.cpp could load Const from First Place
2021-09-11 19:25:04 +03:00
Zihao Mu 51b03b87e6 BiasAdd could load Const from second place. 2021-09-11 15:34:41 +00:00
Alexander Alekhin aa7ba0bc1a build: winpack_dldt with dldt 2021.4.1 2021-09-11 06:20:53 +03:00
Alexander Alekhin 07e4076585 Merge pull request #20689 from diablodale:fix20613-selectocldevice 2021-09-10 22:26:36 +00:00
Dale Phurrough de1a459879 fix opencv/opencv#20613
* copy 4.x selectOpenCLDevice() -- it is compatible
* filter platforms rather than trying only first matching
* this works on 3.4 and 4.x master
2021-09-10 21:18:01 +02:00
Alexander Alekhin 1aacb9bb15 dnn(perf): update convolution tests 2021-09-10 13:11:02 +00:00
Alexander Alekhin 9b4ecc96f6 core(ocl): buffer bounds in intelblas_gemm_buffer_NT 2021-09-10 12:10:41 +00:00
Alexander Alekhin e3f4f874c5 Merge pull request #20670 from alalek:core_ocl_fix_intel_gpu_gemm_requirements
core(OpenCL): fix intel_gpu_gemm kernel requirements

* core(ocl): fix intel_gpu_gemm integration

- allow bailout to generic OpenCL kernel

* core(ocl): avoid failures of generic OpenCL gemm kernel

* core(ocl): define alignment requirements of intel_gpu_gemm kernels
2021-09-10 12:00:11 +00:00
Alexander Alekhin 6ace801418 Merge pull request #20661 from alalek:dnn_ocl_fix_gemm_like_kernel 2021-09-10 11:58:52 +00:00
rogday d31b93b513 Merge pull request #20674 from rogday:prelu_slope
Fix PReLU negative slope access pattern

* fix prelu negative slope access pattern

* change begin() to ptr()
2021-09-10 11:07:16 +00:00
Alexander Alekhin ac0fd6aa9a Merge pull request #20675 from diablodale:fix2-20544 2021-09-09 21:35:03 +00:00
Dale Phurrough 068f33cfdf add nodiscard to features2d clone funcs 2021-09-09 15:20:45 +02:00
rogday 4807cd8a6e Merge pull request #20605 from rogday:split_slice_shenanigans
Add Normalize subgraph, fix Slice, Mul and Expand

* Add Normalize subgraph, support for starts<0 and axis<0 in Slice, Mul broadcasting in the middle and fix Expand's unsqueeze

* remove todos

* remove range-based for loop

* address review comments

* change >> to > > in template

* fix indexation

* fix expand that does nothing
2021-09-09 14:41:40 +03:00
Alexander Alekhin 35e824c287 dnn(ocl): fix out of bound access in GEMM-like kernels
- dropped usage of CreateSubBuffer() - buffers lifetime management issue
- fixed elementwise offset
- avoid out of bounds read access
2021-09-06 18:17:21 +00:00
Alexander Alekhin 1e0d290f2e Merge pull request #20655 from alalek:dnn_ocl_fix_globalsize 2021-09-06 17:20:18 +00:00
Alexander Alekhin 0097a8d097 Merge pull request #20657 from zchrissirhcz:upd-doc-for-py_fast 2021-09-06 11:31:35 +00:00
Zhuo Zhang 36cc43170d docs: fix image path for py_fast doc 2021-09-06 13:05:58 +08:00
Alexander Alekhin 5578ad5e14 dnn(ocl): fix automatic globalsize adjusting
- if kernel code doesn't support that
2021-09-06 03:11:29 +00:00
Alexander Alekhin d11f0a709d Merge pull request #20652 from alalek:ocl_debug 2021-09-04 18:23:09 +00:00
Alexander Alekhin 0a43b23275 Merge pull request #20651 from alalek:issue_18361 2021-09-04 18:22:12 +00:00
Alexander Alekhin 7967683296 Merge pull request #20648 from alalek:issue_20615 2021-09-04 18:21:58 +00:00
Alexander Alekhin 5b2c016834 dnn(ocl): avoid out of buffer access in copyWeightsSwizzled 2021-09-04 15:45:59 +00:00
Alexander Alekhin aaff125608 core(ocl): debug capabilities 2021-09-04 15:37:39 +00:00
Alexander Alekhin 407adc7061 dnn(ocl): fix buffer offsets in IDLF kernel
- drop CreateSubBuffer
- fix FUSED_CONV_ELTWISE mode
2021-09-04 15:28:35 +00:00
rogday d0e612dc36 Merge pull request #20647 from rogday:resize_concat_optimization
Fix resize+concat optimization

* fix resize+concat optimization

* add comment and fix indentation
2021-09-03 12:32:29 +00:00
Alexander Alekhin 7c23ec90a9 Merge pull request #20646 from VadimLevin:dev/vlevin/fix-vector-conversion 2021-09-02 09:30:57 +00:00
Vadim Levin 390957fec4 fix: NumPy array allocation error message in vector conversion 2021-09-02 10:32:17 +03:00
Alexander Alekhin 060a76dc3e Merge pull request #20573 from rogday:onnx_scale_fix 2021-09-01 14:09:17 +00:00
Alexander Alekhin 6625810d2a Merge pull request #20618 from VadimLevin:dev/vlevin/fix-vector-conversion 2021-09-01 10:52:37 +00:00
WJJ1995 edc442afdb Merge pull request #20511 from wjj19950828:add_humanseg_support_0806
* support PPSeg model for dnn module

* fixed README for CI

* add test case

* fixed bug

* deal with comments

* rm dnn_model_runner

* update test case

* fixed bug for testcase

* update testcase
2021-09-01 10:10:05 +00:00
Vadim Levin 16b9514543 feat: update conversion logic for std::vector<T> in Python bindings
`PyObject*` to `std::vector<T>` conversion logic:
- If user passed Numpy Array
  - If array is planar and T is a primitive type (doesn't require
    constructor call) that matches with the element type of array, then
    copy element one by one with the respect of the step between array
    elements. If compiler is lucky (or brave enough) copy loop can be
    vectorized.
    For classes that require constructor calls this path is not
    possible, because we can't begin an object lifetime without hacks.
  - Otherwise fall-back to general case
- Otherwise - execute the general case:
  If PyObject* corresponds to Sequence protocol - iterate over the
  sequence elements and invoke the appropriate `pyopencv_to` function.

`std::vector<T>` to `PyObject*` conversion logic:
- If `std::vector<T>` is empty - return empty tuple.
- If `T` has a corresponding `Mat` `DataType` than return
  Numpy array instance of the matching `dtype` e.g.
  `std::vector<cv::Rect>` is returned as `np.ndarray` of shape `Nx4` and
  `dtype=int`.
  This branch helps to optimize further evaluations in user code.
- Otherwise - execute the general case:
  Construct a tuple of length N = `std::vector::size` and insert
  elements one by one.

Unnecessary functions were removed and code was rearranged to allow
compiler select the appropriate conversion function specialization.
2021-09-01 13:00:21 +03:00
Alexander Alekhin 95c7f4a7f0 Merge pull request #20635 from alalek:issue_20559 2021-08-31 14:42:20 +00:00
Alexander Alekhin ae6fabc6fe dnn(ocl): drop CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE check
- it is a hint and it should not block kernel execution
2021-08-30 20:40:14 +00:00
Alexander Alekhin 7eaadf616c Merge pull request #20622 from diablodale:fix20544-nodiscard 2021-08-30 18:09:51 +00:00
Alexander Alekhin 8fed5fc5ae Merge pull request #20633 from alalek:ocl_dumpValue_handle_null 2021-08-30 13:39:44 +00:00
Alexander Alekhin f25951c412 core(ocl): handle NULL in dumpValue() debug call
- NULL is used for allocation of workgroup local variables
2021-08-30 11:47:51 +00:00
Alexander Alekhin 1259a474ba Merge pull request #20625 from alalek:fix_msvc_warnings 2021-08-28 21:24:03 +00:00
Dale Phurrough 3995deaf76 fix opencv/opencv#20544 nodiscard for msvc/gcc
- includes workaround for preprocessor non-compliance
- enable attribute syntax checking in msvc
2021-08-28 20:22:47 +02:00
Alexander Alekhin 076587425e build: eliminate build warnings 2021-08-28 17:11:26 +00:00
Alexander Alekhin da6aeaca46 Merge pull request #20623 from alalek:fix_java_byte 2021-08-28 13:23:33 +00:00
Alexander Alekhin 8ee33ca551 java(test): avoid deprecation warning
- 'new Byte' => 'Byte.valueOf'
2021-08-28 02:10:05 +00:00
Alexander Alekhin ea7f13922b Merge pull request #20609 from vrabaud:3.4 2021-08-27 23:42:24 +00:00
Vincent Rabaud 38d0063c36 Do not use deprecated ReleaseCleared in protobuf library.
This is to make code work with protobuf arenas for memory
management (ReleaseCleared is incompatible).
The cleaning of the memory is also simpler.
2021-08-26 15:36:22 +02:00
Alexander Alekhin df83459721 Merge pull request #20602 from diablodale:fix20594-refcounts-wiith-exceptions 2021-08-25 22:13:43 +00:00
Dale Phurrough 54a9e00970 fix opencv/opencv#20594 - exception handling with refcounts 2021-08-25 14:38:02 +02:00
Dale Phurrough 9bda96d39e add test case 2021-08-25 14:32:40 +02:00
Alexander Alekhin 77a5c43d50 Merge pull request #20586 from alalek:issue_20585 2021-08-21 17:22:58 +00:00
Alexander Alekhin f28e4b86fb dnn(ocl): fix top initialization in verifyResult 2021-08-21 16:04:13 +00:00
Alexander Alekhin b675e6ab77 Merge pull request #20581 from alalek:issue_20571 2021-08-20 11:36:38 +00:00
Alexander Panov d6306f8ccb Merge pull request #20564 from AleksandrPanov:update_kalman_sample
Update kalman sample

* updated view and comments, fixed dims

* updated view and comments, added statePost
2021-08-20 10:57:05 +00:00
Alexander Alekhin a9817e9127 Merge pull request #20556 from rogday:onnx_split_sum_fix 2021-08-20 08:10:18 +00:00
Alexander Alekhin c08897cd10 cmake: handle empty CVPY_SUFFIX 2021-08-19 20:06:41 +00:00
Alexander Alekhin 384875f4fc Merge pull request #20386 from vrabaud:3.4 2021-08-19 14:54:02 +00:00
Vincent Rabaud 9cfa84313c Use the one argument version of SetTotalBytesLimit.
The two argument versions has been deprecated, cf
https://developers.google.com/protocol-buffers/docs/reference/cpp/google.protobuf.io.coded_stream
2021-08-19 14:31:29 +02:00
Smirnov Egor fe625a558e fix hasDynamicShapes for batch_size and fix axis selection in Scale layer 2021-08-18 19:22:24 +03:00
Smirnov Egor 9ef41f68fb fix Split partial sum 2021-08-16 15:44:54 +03:00
Julia Bareeva cfb36443fb Merge pull request #20506 from JulieBar:lstm_activations
* Support activations(Sigmoid, Tanh) for LSTM

* fix warning
2021-08-13 15:41:00 +03:00
Alexander Alekhin 9d3826c676 Merge pull request #20525 from SamFC10:fix-prior-variances 2021-08-13 10:06:55 +00:00
Iyad Ahmed 4300bb2e1f Merge pull request #20541 from iyadahmed:video_capture_timeout_prop
* VideoCapture timeout set/get

* Common formatting for enum values

* Fix enum values wrongly in videoio.hpp

* Define timeout enum values in public api and align with master
2021-08-12 19:51:02 +03:00
Alexander Alekhin 6edc438789 Merge pull request #20545 from AleksandrPanov:resize_docummentation 2021-08-12 15:13:21 +00:00
AleksandrPanov 25cd7c7c50 add note about Python's dsize to doc 2021-08-12 14:40:40 +03:00
Alexander Alekhin 732cb6c45c Merge pull request #20515 from utibenkei:fix_java_ml_testSaveLoad 2021-08-12 08:12:48 +00:00
Alexander Alekhin 266a868ba9 Merge pull request #20533 from AleksandrPanov:minAreaRect_fix_rotatingCalipers 2021-08-11 17:56:34 +00:00
AleksandrPanov 8199967b31 fix choose minimum angle in rotatingCalipers 2021-08-11 19:08:52 +03:00
utibenkei 9d61c18143 fix testSaveLoad 2021-08-11 21:52:39 +09:00
Alexander Alekhin 221bfa4c67 Merge pull request #20466 from rogday:efficientnet_fix_34 2021-08-10 22:18:17 +00:00
Alexander Alekhin 1a8b7f7513 Merge pull request #20500 from AleksandrPanov:findContours_documentation 2021-08-10 17:21:33 +00:00
AleksandrPanov 992b47b991 add 19769 and 19769_lightweight tests 2021-08-10 18:53:28 +03:00
Smirnov Egor 739ff84732 add Max layer to TFImporter 2021-08-09 14:01:51 +03:00
SamFC10 2a177052de fix bug in prior-box variances 2021-08-09 12:08:55 +05:30
Alexander Alekhin f7c82baee9 Merge pull request #20505 from AleksandrPanov:contours_tutorial_documentation 2021-08-06 07:09:26 +00:00
Alexander Alekhin 2b34e0abdc Merge pull request #20502 from ddacw:3.4 2021-08-06 07:06:51 +00:00
Julia Bareeva 633fedaa96 Merge pull request #20480 from JulieBar:lstm_pytest
Add Python's test for LSTM layer

* Add Python's test for LSTM layer

* Set different test threshold for FP16 target

* rename test to test_input_3d

Co-authored-by: Julie Bareeva <julia.bareeva@xperience.ai>
2021-08-05 18:13:17 +03:00
AleksandrPanov 65134c793b add links in python and js contours tutorial 2021-08-05 14:21:34 +03:00
Abhinav Sharma d5f34cf34c Merge pull request #20493 from abhi-bhatra:patch-1
Fix Broken Link

* Update README.md

Fix broken link

* Update Readme.txt

* Update readme.txt

Add missing link

* Update readme.txt

Fix names
2021-08-04 20:28:59 +03:00
Duong Dac cefa602601 Avoid adding false UMat/GpuMat declaration 2021-08-04 15:17:25 +02:00
AleksandrPanov d773691848 add note about hierarchy in python version 2021-08-04 15:37:20 +03:00
Alexander Alekhin f40707dc68 Merge pull request #20487 from AleksandrPanov:traincascade_documentation 2021-08-03 12:06:46 +00:00
AleksandrPanov 2d8ce500fa add note about using version 3.4 to traincascade documentation 2021-08-02 18:41:53 +03:00
Alexander Alekhin ddf1b04cce Merge pull request #20485 from VadimLevin:dev/vlevin/fix-reserved-python-keyword-arguments 2021-08-02 08:09:55 +00:00
Alexander Alekhin ad5b3a4753 Merge pull request #20451 from kumar-mahendra:patch-1 2021-08-01 14:22:09 +00:00
Vadim Levin 531ea5b3a2 fix: convert arguments names that are keywords reserved by Python 2021-08-01 12:02:36 +03:00
Mahendra Kumar b468468e7e Closing brackets missing
In line 94,  closing brackets are added which were missing .
2021-08-01 08:41:03 +00:00
rogday cff0168f3a Merge pull request #20453 from rogday:onnx_importer_fix
Split layer dispatch into functions in ONNXImporter

* split layer dispatch into functions

* fixes

* identation and comment fixes

* fix constness
2021-07-28 18:06:24 +03:00
Alexander Alekhin d83901e665 Merge pull request #20459 from xerxesb:bugfix/cuda-cmake-typo 2021-07-26 09:57:44 +00:00
Xerxes Battiwalla 1e1984a586 Fixed typo in error message in OpenCVDetectCUDA.cmake
There was a minor typo in the FATAL error message when the specified CUDA generation does not match any known generation
2021-07-26 14:54:27 +10:00
Alexander Alekhin 06dcc5a2c6 Merge pull request #20424 from sbajtl:worker-importscript-bugfix 2021-07-24 15:28:01 +00:00
Alexander Alekhin 000f762fb9 Merge pull request #20369 from shreyastaware:master 2021-07-24 13:41:01 +00:00
Alexander Alekhin 3bc3eeb5da Merge pull request #20447 from snoyes:patch-1 2021-07-23 14:34:57 +00:00
Julia Bareeva 4e5699fa71 Merge pull request #20450 from JulieBar:lstm_inside
Support non-zero hidden state for LSTM

* fully support non-zero hidden state for LSTM

* check dims of hidden state for LSTM

* fix failed test Test_Model.TextRecognition

* add new tests for LSTM w/ non-zero hidden params

Co-authored-by: Julie Bareeva <julia.bareeva@xperience.ai>
2021-07-23 17:11:50 +03:00
Scott Noyes a76274b549 minor grammar edits 2021-07-23 08:54:00 -05:00
Shreyas Taware 803ff8ebb9 Update py_canny.markdown
Fixed a word that was previously written as third argument but it is instead the fourth argument of cv.Canny() function
2021-07-23 05:01:20 +00:00
Alexander Alekhin b42152ffeb Merge pull request #20429 from rogday:tf_importer_asym_pads 2021-07-22 16:44:47 +00:00
Smirnov Egor 024b43ca06 implement asymmetric padding for conv2d, max_pool and conv2d_backprop_input 2021-07-22 16:58:40 +03:00
Alexander Alekhin 9448fe3db4 Merge pull request #20437 from pytianxxiao:fix#20430 2021-07-21 09:47:11 +00:00
Xiaoxiao Tian 3817f3a89b fix: ocv_target_link_libraries could not handle the keyword rightly #20430 2021-07-21 13:32:50 +08:00
Saša Bajtl 2062a7ca8f Bugfix on import script with web worker. 2021-07-18 10:12:39 +02:00
Alexander Alekhin 8334ee18e6 Merge pull request #20394 from SamFC10:conv-asymmetric-pads 2021-07-16 10:33:42 +00:00
Alexander Alekhin cc2592f582 Merge pull request #20200 from rmeertens:update_grabcut 2021-07-16 10:19:25 +00:00
SamFC10 96d35f7c54 Fix convolution asymmetric padding bug in onnx importer 2021-07-16 09:39:41 +05:30
Alexander Alekhin 98c5fc6ae2 Merge pull request #20410 from alalek:fix_dnn_dldt_output_layout 2021-07-15 22:43:42 +00:00
Alexander Alekhin fbde0c6c96 dnn(ie): fix handling of 1D and non-32F outputs of InferenceEngine 2021-07-15 21:47:05 +00:00
Alexander Alekhin 602e7c83e2 dnn(test): add extra IR models, more checks in IE testing code 2021-07-15 21:47:05 +00:00
Alexander Alekhin eb9218a86b Merge pull request #20420 from berak:python_fix_trackbar_warning 2021-07-15 20:06:22 +00:00
berak 9f2dcc3f13 python: fix trackbar warning 2021-07-15 17:42:06 +02:00
Alexander Alekhin bc210b292b dnn(test): backport test_ie_models.cpp from 4.5.3 2021-07-15 00:05:02 +00:00
Roland Meertens 2113af9c52 Updated grabcut example to show the background in a transparant way 2021-07-14 22:02:27 +02:00
Pablo Romero 6f417b57c1 Merge pull request #20399 from pablorcum:3.4
Improves support for Unix non-Linux systems, including QNX

* Fixes #20395. Improves support for Unix non-Linux systems. Focus on QNX Neutrino.

Signed-off-by: promero <promero@mathworks.com>

* Update system.cpp
2021-07-13 19:40:15 +00:00
Alexander Alekhin 0acd06d13c Merge pull request #20397 from alalek:fix_winpack_dldt_stale_sysroot 2021-07-12 21:14:22 +00:00
Alexander Alekhin fd22e98298 build(winpack_dldt): avoid stale sysroot contents 2021-07-12 19:33:23 +00:00
César Gouveia 167a12028d Merge pull request #20374 from cesarpgouveia:bugfix/fix_load_onnxModel_debug
* Fix bug while loading onnx model in debug

* dnn: fix other .at using

Co-authored-by: Alexander Alekhin <alexander.a.alekhin@gmail.com>
2021-07-09 18:21:56 +00:00
Alexander Alekhin 6af2faebd2 Merge pull request #20381 from berak:dnn_samples_fix_colorization_links 2021-07-09 18:15:10 +00:00
berak fd16222613 dnn: update links for the colorization samples 2021-07-09 13:21:44 +02:00
Alexander Alekhin 1ba6cd8423 Merge pull request #20368 from mightbxg:bugfix_imshowqt 2021-07-08 20:54:09 +00:00
Alexander Alekhin 4788de784b Merge pull request #20373 from kikaxa:mjpeg-VideoInputStream-alignment-fix 2021-07-07 18:21:57 +00:00
kikaxa 926535469d fix videoio/src/container_avi.cpp VideoInputStream alignment 2021-07-07 18:31:53 +03:00
Xinguang Bian 5627a0cbdf fix scale problem in DefaultViewPort::controlImagePosition() 2021-07-07 12:35:11 +08:00
Alexander Alekhin 9a9954a036 Merge tag '3.4.15' 2021-07-04 21:32:19 +00:00
Alexander Alekhin 591708903b release: OpenCV 3.4.15 2021-07-04 21:10:13 +00:00
Alexander Alekhin f9d62fba7a Merge pull request #20350 from alalek:issue_20285 2021-07-04 21:07:02 +00:00
Alexander Alekhin 9d039c206b Merge pull request #20354 from alalek:issue_20353 2021-07-04 18:41:34 +00:00
Alexander Alekhin 4c3f9b2ef4 cmake: update Halide detection 2021-07-04 13:20:52 +03:00
Alexander Alekhin 0e523618a1 cmake: exclude -pthread from Emscripten default build 2021-07-03 11:13:28 +00:00
Alexander Alekhin 3b26105f68 Merge pull request #20346 from alalek:backport_20026 2021-07-03 00:27:55 +00:00
Alexander Alekhin 0f2f966a91 Merge pull request #20345 from mitruska:update_ngraph_normalizel2 2021-07-02 23:37:03 +00:00
Alexander Alekhin d7d491d445 Merge pull request #20344 from alalek:backport_20343 2021-07-02 23:35:12 +00:00
Alexander Alekhin 9b0d6862c4 cmake(IE): extract INF_ENGINE_RELEASE from InferenceEngine package 2021-07-02 23:29:35 +00:00
Alexander Alekhin 890fcdf842 Merge pull request #20337 from alalek:build_opencv_winpack_dldt_2021.4.0 2021-07-02 21:47:14 +00:00
mitruska 18dbac203f Use explicit version of ngraph NormalizeL2 2021-07-02 21:33:05 +00:00
Alexander Alekhin 8d1f254dcc java: force using of 'Ptr<>' for OpenCV classes
backport of commit: e5841d3126
2021-07-02 21:20:08 +00:00
Alexander Alekhin 90df3af6cf build: winpack_dldt with dldt 2021.4.0 2021-07-02 09:58:00 +00:00
Alexander Alekhin b699fe7a9d Merge pull request #20335 from SamFC10:concat-const-input 2021-07-01 10:25:35 +00:00
Alexander Alekhin b2ed5c3070 Merge pull request #20333 from APrigarina:fix_samples_3.4 2021-07-01 09:41:56 +00:00
SamFC10 5b8c10f2f8 modified onnx importer to concat const input blobs 2021-07-01 10:58:31 +05:30
Alexander Alekhin 24983f62e2 Merge pull request #20325 from alalek:dnn_openvino_2021.4.0 2021-06-30 23:58:26 +00:00
Alexander Alekhin f2057ce1ab dnn(ie): replace deprecated calls 2021-06-30 22:30:15 +00:00
Alexander Alekhin 6797fd65a5 dnn(test): update tests for OpenVINO 2021.4 2021-06-30 22:30:15 +00:00
Alexander Alekhin 947e06a860 Merge pull request #20328 from alalek:backport_20321 2021-06-30 20:51:49 +00:00
Alexander Alekhin 04d5ba266f Merge pull request #20330 from Wovchena:fix-arg-for-calcHist-in-demos 2021-06-30 14:59:22 +00:00
Vladimir 90be83ae99 Fix an arg for calcHist() in demos
`float* histRange = { range };` doesn't make much sense. `histRange` is
an array of array(s), so it should have a type of ptr to ptr. Strangely
some domos are correct as well as the example for the function
https://docs.opencv.org/master/d6/dc7/group__imgproc__hist.html#ga4b2b5fd75503ff9e6844cc4dcdaed35d
2021-06-30 17:22:56 +03:00
APrigarina 5e80bd3cc9 fix samples 3.4 2021-06-30 12:50:21 +03:00
Alexander Alekhin db4b1e613c core(persistence): fix types format handling
partial backport of 4eac198270
2021-06-29 21:54:52 +00:00
Alexander Alekhin 7d842f5bcf dnn: use OpenVINO 2021.4 defines 2021-06-29 18:48:21 +00:00
Alexander Alekhin 828304d587 Merge pull request #20128 from kikaxa:master 2021-06-21 21:52:17 +00:00
Alexander Alekhin 9d584475f6 Merge pull request #20283 from SamFC10:fix-batchnorm 2021-06-21 11:27:12 +00:00
kikaxa bb60cb0bf9 Reenable filesystem for ios builds 2021-06-20 16:33:25 +00:00
SamFC10 55e1dfb778 Fix BatchNorm reinitialization 2021-06-20 13:19:29 +05:30
Alexander Alekhin c2263db7bc Merge pull request #20232 from gasparitiago:drawMatches3.4 2021-06-18 19:47:52 +00:00
Alexander Alekhin 7bbbda71df Merge pull request #20253 from rogday:gtk_modifiers 2021-06-18 15:46:44 +00:00
Alexander Alekhin 8e0baf257c Merge pull request #20263 from vrabaud:3.4 2021-06-15 18:20:21 +00:00
Vincent Rabaud c8268e65fd Fix potential NaN in cv::norm.
There can be an int overflow.
cv::norm( InputArray _src, int normType, InputArray _mask ) is fine,
not cv::norm( InputArray _src1, InputArray _src2, int normType, InputArray _mask ).
2021-06-15 14:58:11 +02:00
Tiago De Gaspari 3cf4375387 Merge pull request #19842 from gasparitiago:3.4
Update rotatedRectangleIntersection function to calculate near to origin

* Change type used in points function from RotatedRect

In the function that sets the points of a RotatedRect, the types

should be double in order to keep the precision when dealing with
RotatedRects that are defined far from the origin.

This commit solves the problem in some assertions from
rotatedRectangleIntersection when dealing with rectangles far from
origin.

* added proper type casts

* Update rotatedRectangleIntersection function to calculate near to origin

This commit changes the rotatedRectangleIntersection function in order
to calculate the intersection of two rectangles considering that they
are shifted near the coordinates origin (0, 0).

This commit solves the problem in some assertions from
rotatedRectangleIntersection when dealing with rectangles far from
origin.

* Revert type changes in types.cpp and adequate code to c++98

* Revert unnecessary casts on types.cpp

Co-authored-by: Vadim Pisarevsky <vadim.pisarevsky@gmail.com>
2021-06-12 23:28:54 +03:00
Alexander Alekhin c1adbe3189 Merge pull request #20190 from rogday:tf_importer_ref 2021-06-11 20:06:09 +00:00
rogday 7ee1816612 split if into map of functions 2021-06-11 13:20:45 +03:00
Smirnov Egor 8f4f834ce6 applied modifier mask to the state 2021-06-10 10:57:15 +03:00
Tiago De Gaspari 411fd2b761 Add Thickness parameter in drawMatches function
This commit adds the feature of selecting the thickness
of the matches drawn by the drawMatches function.

In larger images, the default thickness of 1 pixel creates images
that are hard to visualize.
2021-06-07 12:52:48 -03:00
409 changed files with 21540 additions and 6414 deletions
+26 -17
View File
@@ -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
+5 -5
View File
@@ -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
View File
@@ -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
View File
@@ -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
+3 -2
View File
@@ -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
View File
@@ -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. */
+6 -4
View File
@@ -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
View File
@@ -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 */
+10 -1
View File
@@ -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
View File
@@ -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,
+3 -3
View File
@@ -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;
+14 -1
View File
@@ -5,8 +5,9 @@
* Copyright (C) 1991-1997, Thomas G. Lane.
* Modified 1997-2009 by Guido Vollbeding.
* libjpeg-turbo Modifications:
* Copyright (C) 2015-2016, 2019, D. R. Commander.
* Copyright (C) 2015-2016, 2019, 2021, D. R. Commander.
* Copyright (C) 2015, Google, Inc.
* Copyright (C) 2021, Alex Richardson.
* For conditions of distribution and use, see the accompanying README.ijg
* file.
*
@@ -47,6 +48,18 @@ typedef enum { /* Operating modes for buffer controllers */
/* JLONG must hold at least signed 32-bit values. */
typedef long JLONG;
/* JUINTPTR must hold pointer values. */
#ifdef __UINTPTR_TYPE__
/*
* __UINTPTR_TYPE__ is GNU-specific and available in GCC 4.6+ and Clang 3.0+.
* Fortunately, that is sufficient to support the few architectures for which
* sizeof(void *) != sizeof(size_t). The only other options would require C99
* or Clang-specific builtins.
*/
typedef __UINTPTR_TYPE__ JUINTPTR;
#else
typedef size_t JUINTPTR;
#endif
/*
* Left shift macro that handles a negative operand without causing any
+9 -5
View File
@@ -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)
+3
View File
@@ -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
+4 -2
View File
@@ -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
View File
@@ -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()
-8
View File
@@ -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()
+1 -1
View File
@@ -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")
+10 -1
View File
@@ -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
+1 -1
View File
@@ -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)
+2
View File
@@ -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()
+13 -11
View File
@@ -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()
+15 -5
View File
@@ -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()
+1 -1
View File
@@ -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)
+6 -23
View File
@@ -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})")
+17
View 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()
+42 -18
View File
@@ -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()
+2
View File
@@ -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()
+21
View File
@@ -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)
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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">
+1 -1
View File
@@ -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">
@@ -1,6 +1,9 @@
Contour Features {#tutorial_js_contour_features}
================
@prev_tutorial{tutorial_js_contours_begin}
@next_tutorial{tutorial_js_contour_properties}
Goal
----
@@ -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
----
@@ -1,6 +1,8 @@
Contours Hierarchy {#tutorial_js_contours_hierarchy}
==================
@prev_tutorial{tutorial_js_contours_more_functions}
Goal
----
@@ -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:
![image](lena.jpg)
@@ -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
View File
@@ -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.
@@ -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:
@@ -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
----
@@ -1,6 +1,8 @@
Contours Hierarchy {#tutorial_py_contours_hierarchy}
==================
@prev_tutorial{tutorial_py_contours_more_functions}
Goal
----
@@ -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:
@@ -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
+7 -6
View File
@@ -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}
}
+176
View File
@@ -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).
![](pnp.jpg)
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.
+22 -251
View File
@@ -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).
![](pnp.jpg)
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).
![](pnp.jpg)
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
+6 -6
View File
@@ -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!");
+3 -3
View File
@@ -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 )
+11 -11
View File
@@ -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 )
{
+4 -4
View File
@@ -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 )
{
+17 -17
View File
@@ -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,
+1
View File
@@ -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}"
+8 -2
View File
@@ -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
+38 -3
View File
@@ -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
+31 -31
View File
@@ -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
+7 -7
View File
@@ -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;
+18 -2
View File
@@ -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
*/
+27 -7
View File
@@ -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)
+4 -4
View File
@@ -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
View File
@@ -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;
+47
View File
@@ -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
+30 -30
View File
@@ -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
View File
@@ -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;
+18 -18
View File
@@ -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);
}
+15 -10
View File
@@ -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"
+46 -21
View File
@@ -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
+2 -2
View File
@@ -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