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

Compare commits

...

320 Commits

Author SHA1 Message Date
Alexander Alekhin b38c50b3d0 OpenCV 3.4.3 2018-08-28 15:58:21 +03:00
Alexander Alekhin dd06540e1f openvino: use 2018R3 defines 2018-08-28 15:57:19 +03:00
Alexander Alekhin 50b61668e2 Merge pull request #12326 from alalek:issue_12325 2018-08-28 12:51:33 +00:00
Alexander Alekhin 1df84f7246 Merge pull request #12319 from dkurt:dnn_enable_ie_tests 2018-08-28 12:50:32 +00:00
Alexander Alekhin bdc34984f1 Merge pull request #12323 from alalek:android_ndk17_support 2018-08-28 12:09:13 +00:00
Alexander Alekhin af0c930e77 ts: don't pass NULL for std::string() constructor 2018-08-28 14:19:56 +03:00
Alexander Alekhin bb45bf9695 android: NDK17 support
tested with NDK 17b (17.1.4828580)
2018-08-27 21:07:34 +00:00
Alexander Alekhin 4e0d2a3e6c Merge pull request #12193 from alalek:fix_vaapi_sample 2018-08-27 20:56:20 +00:00
Alexander Alekhin da6d8961fc Merge pull request #12286 from logic1988:master 2018-08-27 19:05:23 +00:00
Dmitry Kurtaev 3e027df583 Enable more deep learning tests using Intel's Inference Engine backend 2018-08-27 18:37:35 +03:00
Alexander Alekhin 6477262e63 Merge pull request #12306 from berak:python_nmsboxes 2018-08-25 16:35:00 +00:00
Alexander Alekhin f79599f949 Merge pull request #12308 from StrangeTcy:patch-1 2018-08-25 16:32:32 +00:00
Maxim Smirnov c94d75874b CV_Asserts changed
Some `CV_Assert`s changed to `CV_Assert_N`s according to https://github.com/opencv/opencv/issues/12304
2018-08-25 14:52:27 +03:00
berak 21f3987d53 python: add support for NMSBoxes 2018-08-25 08:44:45 +02:00
Alexander Alekhin d10a219833 Merge pull request #12298 from berak:java_matofrotatedrect 2018-08-24 15:54:27 +00:00
berak bd7bf39b4b java: change MatOfRotatedRect to CV_32FC5 2018-08-24 14:20:36 +02:00
Dmitry Kurtaev 472b71ecef Merge pull request #12243 from dkurt:dnn_tf_mask_rcnn
* Support Mask-RCNN from TensorFlow

* Fix a sample
2018-08-24 14:47:32 +03:00
Alexander Alekhin 4f360f8b1a Merge pull request #12295 from alalek:cmake_gphoto_off_by_default 2018-08-24 09:10:44 +00:00
Alexander Alekhin e8d45a9cdd Merge pull request #12274 from alalek:fix_10945 2018-08-24 08:30:52 +00:00
Alexander Alekhin ff2eface19 Merge pull request #12126 from alalek:reproducer_12121 2018-08-24 08:08:17 +00:00
Alexander Alekhin 29ce348c4d Merge pull request #12287 from berak:java_matofrotatedrect 2018-08-24 07:03:13 +00:00
Alexander Alekhin b2a4069f55 Merge pull request #12291 from cv3d:fix/cuda_pow 2018-08-23 23:58:48 +03:00
Hamdi Sahloul 4d78342919 Closes #12281 - a bug in cuda::pow with negative base values 2018-08-24 05:12:14 +09:00
Alexander Alekhin 1272332ae3 cmake: WITH_GPHOTO2=OFF by default 2018-08-23 19:48:23 +00:00
logic1988 b47c9ac643 Update aff_trans.cpp
When the fullAffine parameter is set to false, the estimateRigidTransform function maybe return empty, then the _localAffineEstimate function will be called, but the bug in it will result in incorrect results.
2018-08-23 21:52:27 +08:00
berak 1c20a7f008 java: add a MatOfRotatedRect class 2018-08-23 12:01:36 +02:00
Alexander Alekhin 6700fdb81f Merge pull request #12275 from alalek:fix_build_dnn_inf_engine 2018-08-22 14:38:05 +00:00
Alexander Alekhin 096366738b dnn(build): fix CV_Assert() usage 2018-08-22 16:04:40 +03:00
Alexander Alekhin 6a6506b02d viz: call "mapper->Update()" before and after SetInputData() 2018-08-22 15:40:51 +03:00
Alexander Alekhin 59ccf2c9e0 Merge pull request #12272 from alalek:fix_build_static_analysis 2018-08-22 12:18:53 +00:00
Alexander Alekhin 2c42361ecd build: fix build with defined CV_STATIC_ANALYSIS 2018-08-22 14:19:21 +03:00
Alexander Alekhin 18833d5121 Merge pull request #12267 from alalek:dnn_unstable_tests 2018-08-21 15:26:06 +00:00
Alexander Alekhin f25450791b dnn(test): mark unstable OpenCL tests 2018-08-21 16:31:41 +03:00
Alexander Alekhin c9faa09d55 Merge pull request #12266 from mshabunin:fix-windows-ie-build 2018-08-21 13:07:44 +00:00
Alexander Alekhin 1deeca985f Merge pull request #12262 from sivaraam:v4l2_mainloop 2018-08-21 12:47:29 +00:00
Alexander Alekhin 6acabd1fd8 Merge pull request #12256 from alalek:core_intrin_fp16_fix 2018-08-21 12:47:08 +00:00
Alexander Alekhin 5ac9a2a7d0 Merge pull request #12219 from alalek:fix_assert_messages 2018-08-21 12:46:35 +00:00
Maksim Shabunin 808c89adc1 Fixed windows build with InferenceEngine 2018-08-21 14:59:13 +03:00
Kaartic Sivaraam a527e8cc73 cap-v4l: remove unwanted loop in V4L2 mainloop
The while loop would run only once making it useless and leading
to confusion.

So, remove the unwanted while loop and just keep an infinite for
loop.
2018-08-21 16:41:01 +05:30
Alexander Alekhin 10c570b558 Merge pull request #12263 from doctorcolinsmith:3.4 2018-08-21 10:12:14 +00:00
Colin Smith 76f47548b3 Add export macro for ios conversion functions 2018-08-20 14:10:54 -07:00
Alexander Alekhin 67d46dfc6c core(intrin): restrict FP16 operations
Intrinsics must be effective, so don't declare FP16 type/operations if there is no native support.

- CV_FP16: supports load/store into/from float32
- CV_SIMD_FP16: declares FP16 types and native FP16 operations
2018-08-20 19:24:33 +03:00
Alexander Alekhin 3c03fb56e0 Merge pull request #12258 from savuor:fix/trace_fname_slash 2018-08-20 16:22:06 +00:00
Rostislav Vasilikhin 378cf2ab63 fixed filename slash processing 2018-08-20 18:02:49 +03:00
Alexander Alekhin c6f5b013ec Merge pull request #12242 from alalek:fix_12236 2018-08-20 13:53:27 +00:00
Alexander Alekhin e593d5bbc5 Merge pull request #12255 from csukuangfj:patch_5 2018-08-20 13:47:41 +00:00
Alexander Alekhin 3f5c3ddd27 Merge pull request #12254 from csukuangfj:patch_4 2018-08-20 08:46:57 +00:00
Kuang Fangjun ab8ba047a5 fix a typo. 2018-08-20 15:52:18 +08:00
Kuang Fangjun cecc19381f fix an error in the formula for cv::cornerSubPix 2018-08-20 15:49:35 +08:00
Alexander Alekhin 6e84abc746 ml: don't use "getSubVector()" with 2D matrix
It is designed for 1D vectors only
2018-08-18 20:50:36 +00:00
Alexander Alekhin 322c6b1ba4 Merge pull request #12235 from alalek:core_perf_scalar_tests 2018-08-18 20:45:47 +00:00
Alexander Alekhin 73d44c7881 Merge pull request #12172 from alalek:core_move_const_table 2018-08-17 14:03:01 +00:00
Alexander Alekhin 31fef14d76 Merge pull request #12136 from sturkmen72:update_documentation 2018-08-17 14:02:20 +00:00
Alexander Alekhin 7ee69740e8 ml(test): test different samples layout of TrainData 2018-08-17 16:57:20 +03:00
Suleyman TURKMEN c61bc3a0cb Update documentation and samples 2018-08-17 14:21:29 +03:00
Alexander Alekhin b24fc6954d core(perf): fix addScalar test
keep the same type for passed Scalar values
2018-08-16 19:36:28 +03:00
Alexander Alekhin 828cb4286d Merge pull request #12220 from sturkmen72:update_seamless_cloning 2018-08-16 16:26:27 +00:00
Alexander Alekhin ee5e0e16d9 Merge pull request #12233 from mshabunin:fix-world-install-headers 2018-08-16 16:03:10 +00:00
Alexander Alekhin b907bfe3e7 Merge pull request #12222 from NCBee:master 2018-08-16 16:02:39 +00:00
Maksim Shabunin f84eb3dde6 Fixed core headers installation in world builds 2018-08-16 17:16:02 +03:00
Alexander Alekhin b996b618e0 Merge pull request #12228 from tomoaki0705:fixTypoCalib3d 2018-08-16 12:29:10 +00:00
Alexander Alekhin 98c5ce9347 imgproc(test): refactor test_intersection.cpp
don't use legacy test API
2018-08-16 15:27:24 +03:00
Alexander Alekhin f89defad5d imgproc: fix rotatedRectangleIntersection() 2018-08-16 15:27:24 +03:00
Bahram Dahi 96f92c6705 imgproc(tests): intersetion calculation of RotatedRect 2018-08-16 15:00:01 +03:00
Tomoaki Teshima f0c46a4c74 fix typo 2018-08-16 19:11:40 +09:00
Alexander Alekhin 9752d45c87 Merge pull request #12216 from hirocob:fix-typo 2018-08-16 05:16:58 +00:00
Suleyman TURKMEN 860ae77ec9 Update seamless_cloning 2018-08-15 22:59:18 +03:00
Hiro Kobayashi 1567a65475 Fix a typo in the tutorial 2018-08-15 19:34:38 +03:00
Alexander Alekhin d2e08a524e core: repair CV_Assert() messages
Multi-argument CV_Assert() is accessible via CV_Assert_N() (with malformed messages).
2018-08-15 17:43:10 +03:00
Alexander Alekhin c1df9ad456 OpenCV version++
OpenCV 3.4.3
2018-08-14 14:10:37 +03:00
Alexander Alekhin 781721ca50 experimental version++ 2018-08-14 14:10:37 +03:00
Alexander Alekhin b9b66ca437 Merge pull request #12205 from dkurt:dnn_update_tf_face_detection 2018-08-14 10:53:12 +00:00
Dmitry Kurtaev 22cb65ada9 Update face detection network in samples 2018-08-14 13:16:23 +03:00
Alexander Alekhin 90b8a03a89 Merge pull request #12203 from berak:fix_interactive_calibration 2018-08-13 15:40:42 +00:00
Dmitry Kurtaev f056c0f137 UINT8 face detection network using Intel's Inference Engine backend 2018-08-13 18:38:47 +03:00
berak 49e0126b8e apps: fix interactive calibration 2018-08-13 11:51:08 +02:00
Alexander Alekhin a24a829490 Merge pull request #12191 from weblucas:patch-2 2018-08-10 14:15:39 +00:00
Alexander Alekhin 615883977f Merge pull request #12128 from dkurt:dnn_fix_12066 2018-08-10 14:14:16 +00:00
Alexander Alekhin 216cd7dc61 cmake: allow to specify own libva paths
via CMake:
- `-DVA_LIBRARIES=/opt/intel/mediasdk/lib64/libva.so.2\;/opt/intel/mediasdk/lib64/libva-drm.so.2`
2018-08-10 16:03:10 +03:00
Alexander Alekhin 4910f16f16 core(libva): support YV12 too
Added to CPU path only.
OpenCL code path still expects NV12 only (according to Intel OpenCL extension)
2018-08-10 16:02:05 +03:00
Lucas Teixeira f2d363feb2 Fix a Typo in the comment of asift.py 2018-08-09 23:43:39 +02:00
Alexander Alekhin 8b2122e12f Merge pull request #12174 from alalek:dnn_move_range_ostream_operator 2018-08-08 20:51:26 +00:00
Alexander Alekhin f16f818f5f Merge pull request #12184 from alalek:issue_12163 2018-08-08 20:50:54 +00:00
Alexander Alekhin 5b3ac112fe core: move const tables outside of dispatched code
To avoid duplicates in binaries
2018-08-08 17:54:54 +03:00
Alexander Alekhin a0cff0be94 imgproc(cvtColor): slightly improve error messages
Do not try to process empty inputs.
2018-08-08 17:16:42 +03:00
Alexander Alekhin 509de3fa2c Merge pull request #12178 from alalek:ipp_cvtColor_12176 2018-08-08 13:30:32 +00:00
Alexander Alekhin b00758babe imgproc(cvtColor): temporary disable IPP for 8U GRAY2BGR mode
Details 12176
2018-08-08 13:58:45 +03:00
Alexander Alekhin 9f2edc1135 Merge pull request #12173 from gdemarcq:Decolor_corrections 2018-08-07 17:07:19 +00:00
Alexander Alekhin a56b221559 core: cv::Range() ostream write operator
remove from DNN module headers
2018-08-07 20:03:21 +03:00
yom fb2b26c419 photo: Decolor corrections
* Keep image aspect ratio in resize called in grad_system and
weak_order
	* Bug correction in loop inside Decolor::gradvector
2018-08-07 19:08:57 +03:00
Alexander Alekhin 377e51df83 Merge pull request #12169 from berak:photo_decolor 2018-08-07 16:01:42 +00:00
Alexander Alekhin 7453a6938a core(test): extra tests/fixes for merge/split (#12171)
* core(test): merge hang test

* core(merge/split): fix intrin optimization
2018-08-07 18:11:05 +03:00
Maksim Shabunin 39f5e57321 Merge pull request #12159 from zarelaky:master 2018-08-07 13:15:19 +00:00
berak f49f6d52b4 photo: avoid resizing a const Mat in decolor() 2018-08-07 15:14:22 +02:00
zarelaky 715f23127c Update cap_gstreamer.cpp
fixed call open(int id) failed
2018-08-07 15:21:46 +03:00
Maksim Shabunin f0f652f9e9 Merge pull request #12161 from alalek:cache_dump_neighbor_directories_for_cleanup 2018-08-07 12:09:39 +00:00
Maksim Shabunin 731aa963bd Merge pull request #12166 from berak:fix_mjpeg_decoder 2018-08-07 12:09:13 +00:00
berak 7e353a1ec5 videoio: check iterator in mjpeg_encoder.cpp 2018-08-07 11:43:37 +02:00
Alexander Alekhin 4fe900c399 Merge pull request #12162 from alalek:fix_intrin_12146 2018-08-06 20:39:23 +00:00
Alexander Alekhin 5c3880d302 core(intrin): avoid symbols duplication from SIMD128/256 cases
All vx_call() must be wrapped into own simd128/simd256/simd512 namespace

```
namespace CV__SIMD_NAMESPACE {
... vx_call declaration is here ...
}
```
2018-08-06 19:29:46 +00:00
Alexander Alekhin 9eaa583bfb core: dump neighbour cache directories (from old OpenCV versions)
- use '3.4.x' cache name for current maintenance series (there are no serious changes between releases)
- message is shown only once during creation of new cache directory
- use OPENCV_CACHE_SHOW_CLEANUP_MESSAGE=0 to hide this warning
2018-08-06 19:05:35 +03:00
Vadim Pisarevsky 6500700d6f Merge pull request #12157 from allnes:detect_qr_code 2018-08-06 14:50:28 +00:00
Alexander Nesterov f95a411ba3 Update binarization 2018-08-06 12:10:45 -03:00
Vadim Pisarevsky 7c8ab271fc Merge pull request #12125 from dkurt:dnn_mobilenet_ppn 2018-08-06 14:40:50 +00:00
Vadim Pisarevsky 70b893333d Merge pull request #12130 from dkurt:dnn_ie_mvn 2018-08-06 14:37:46 +00:00
Dmitry Kurtaev 449696f1e5 Enable reshape-as-shape layer from TensorFlow 2018-08-06 17:35:06 +03:00
Vadim Pisarevsky e0c93bcf6c Merge pull request #12082 from dkurt:dnn_ie_faster_rcnn 2018-08-06 14:28:58 +00:00
Vadim Pisarevsky 23022f3ffb Merge pull request #12121 from maver1:amatyuko/sse2_convert_with_saturation_fix 2018-08-06 14:26:37 +00:00
Alexander Alekhin ac4a6aad15 Merge pull request #12050 from alalek:dnn_ocl_avoid_memory_access_violation 2018-08-05 14:47:01 +00:00
Alexander Alekhin 7d7767ba42 Merge pull request #12134 from mshabunin:add-yuv420-v4l 2018-08-04 13:48:34 +00:00
Alexander Alekhin 183cfd3a2e Merge pull request #12097 from xsacha:master 2018-08-04 13:14:22 +00:00
Alexander Alekhin 9cb3e9abf0 Merge pull request #12135 from tompollok:3.4
imgproc: update cornerSubPix documentation
2018-08-04 16:02:21 +03:00
Alexander Alekhin b4cea8d6d1 Merge pull request #12120 from alalek:core_test_intrin_dispatched 2018-08-03 17:07:17 +00:00
Alexander Alekhin 8f57fc93ec Merge pull request #12123 from allnes:detect_qr_code 2018-08-03 16:52:26 +00:00
Sacha 9ff4475695 Support WITH_CUDA with clang compiler. 2018-08-03 16:42:28 +10:00
Alexander Alekhin 1c73e66edf Merge pull request #12131 from alalek:issue_12083 2018-08-02 16:50:51 +00:00
tompollok 061149cbbd imgproc: update cornerSubPix documentation 2018-08-02 18:00:43 +02:00
Maksim Shabunin a2daf0c83c videoio: added YUV420 format (UV order) support to v4l capture 2018-08-02 18:34:11 +03:00
Alexander Alekhin 2dbb5871e0 Merge pull request #12129 from pierrejeambrun:stitching_detailed_sift 2018-08-02 15:22:06 +00:00
Dmitry Kurtaev be08730cd6 MVN layer using Intel's Inference Engine backend 2018-08-02 17:49:03 +03:00
Alexander Alekhin 3082ea82f9 core(merge): fix SIMD loop head processing 2018-08-02 17:23:19 +03:00
Pierre Jeambrun 5131619a1a feat(stitching): Add Sift support for the FeaturesFinder 2018-08-02 17:22:13 +03:00
Alexander Alekhin b056ce33aa Merge pull request #12124 from mshabunin:download-improve 2018-08-02 12:13:44 +00:00
Maksim Shabunin df9efbbd1f Install data for samples to correct directories, do not download face_detector models in cmake 2018-08-02 14:24:05 +03:00
Alexander Alekhin f2e1710dd5 core(test): regression test for 12121 2018-08-01 19:42:54 +03:00
Alexander Nesterov 05830874d7 Refactor code 2018-08-01 12:15:40 -03:00
Dmitry Kurtaev 4fb086d6c3 MobileNet-SSD v1 from TensorFlow with shared convolution weights 2018-08-01 16:16:48 +03:00
amatyuko 3ea2586a5a Fix for SSE2 intrinsics problem in the part of saturation arithmetic processing during 32s->16u packed conversion -
for some big negative values less than -INT_MAX+32767 the sign of the numbers is lost due to overflow that leads to
incorrect saturation to MAX value, instead of zero.
The issue is not reproduced with CV_ENABLED_INTRINSICS=OFF
2018-08-01 16:04:08 +03:00
Maksim Shabunin 2df0345985 cmake: add download helper scripts 2018-08-01 15:57:53 +03:00
Alexander Alekhin 47e3e89e30 Merge pull request #12116 from luzpaz:misc-typos 2018-08-01 11:35:57 +00:00
Alexander Alekhin 3f302cabb8 core(test): intrinsic tests for all dispatched CPU optimizations
- tests for both SIMD128 / SIMD256
- different dispatched + baseline(SIMD128) intrinsics
2018-08-01 13:50:42 +03:00
Dmitry Kurtaev 8e034053af Faster-RCNN from TensorFlow on CPU with Intel's Inference Engine backend 2018-08-01 11:29:58 +03:00
Alexander Alekhin 67f79aabdd Merge pull request #12119 from mshabunin:fix-IE-dnn-test 2018-07-31 18:32:52 +00:00
Maksim Shabunin 5aceee5a36 Restored tests dependencies processing 2018-07-31 19:34:19 +03:00
luz.paz 1e1a1855ae Source typo fixes 2018-07-31 18:44:23 +03:00
luz.paz 2003eb1b9b Misc. typos
Found via `codespell -q 3 -I ../opencv-whitelist.txt --skip="./3rdparty"`
2018-07-31 18:44:23 +03:00
Alexander Alekhin 17196bb4fa Merge pull request #12036 from sturkmen72:update_create_mask_cpp 2018-07-31 15:02:16 +00:00
Alexander Alekhin 7e71b1079e Merge pull request #12103 from alalek:ocl_fix_crash 2018-07-31 14:55:43 +00:00
Alexander Alekhin 814ebe39ae Merge pull request #12113 from dkurt:dnn_fix_ssd_on_myriad 2018-07-31 14:55:18 +00:00
Alexander Alekhin 61c870ae09 Merge pull request #12080 from mshabunin:fix-static-3 2018-07-31 14:53:28 +00:00
Alexander Alekhin 6949bc9ef9 Merge pull request #12105 from mshabunin:fix-ie-R2 2018-07-31 14:22:45 +00:00
Maksim Shabunin 7cf52de47e dnn: modified IE search, R2 compatibility fixed 2018-07-31 14:48:06 +03:00
Alexander Alekhin 9433784e47 Merge pull request #12111 from seiko2plus:issue12110 2018-07-31 09:21:41 +00:00
Dmitry Kurtaev ed0e79cb61 Add missing parameter to DetectionOutput layer from Intel's Inference Engine 2018-07-31 11:37:45 +03:00
Sayed Adel bb82cdc928 core:test Fix fp16 build if AVX2 sets as baseline 2018-07-31 10:02:20 +02:00
Suleyman TURKMEN db8585701d Update create_mask.cpp 2018-07-30 21:42:22 +03:00
Alexander Alekhin 28d0e97c09 Merge pull request #12004 from mshabunin:more-asserts 2018-07-30 16:42:09 +00:00
Alexander Alekhin 5d12c070ea Merge pull request #12046 from VladKarpushin:tutorial-using-out-of-focus-deblur-filter 2018-07-30 16:36:39 +00:00
Alexander Alekhin 5bde800ee3 Merge pull request #12088 from alalek:ocl_callback_catch_exceptions 2018-07-30 16:33:41 +00:00
Alexander Alekhin 29a1dc5719 Merge pull request #12087 from alalek:docs_videowriter_write_bgr_input 2018-07-30 16:33:23 +00:00
Alexander Alekhin dbf3362c4d Merge pull request #12056 from seiko2plus:coreExpandTests 2018-07-30 16:23:11 +00:00
Alexander Alekhin c4e0f4b2b5 Merge pull request #12102 from csukuangfj:patch_3 2018-07-30 12:48:06 +00:00
Alexander Alekhin e90e398e7a core(ocl): do not split refcount operations / compare
- check result from CV_XADD() directly
- decrease urefcount after unmap() call only
2018-07-30 15:42:09 +03:00
Alexander Alekhin 4937eeddb5 Merge pull request #12101 from miaow1988:dev-fix-mat-pushback 2018-07-30 11:26:25 +00:00
miaow1988 2988260107 Fixed the int size overflow bug of cv::Mat.push_back().
Changed the type of variable *r* from int to size_t.
This change makes sure that a valid result of std::max(r + delta,
(r*3+1)/2) can be passed into the reserve function.
2018-07-30 18:36:19 +08:00
Kuang Fangjun 83039c8752 fix a typo. 2018-07-30 18:18:18 +08:00
Sayed Adel 6499263b41 core:test Expand hal_intrin tests to support SIMD256 2018-07-30 08:50:50 +02:00
Alexander Alekhin 80cab4a163 Merge pull request #12094 from seiko2plus:coreFixAvx2Interleave32 2018-07-29 20:51:55 +00:00
Sayed Adel 47202b3349 core:avx2 fix unaligned store for v_store_interleave v_uint32x8-3ch 2018-07-29 18:22:46 +02:00
Alexander Alekhin 9076bb6089 Merge pull request #12081 from mshabunin:fix-ie-build 2018-07-28 20:34:19 +00:00
Alexander Alekhin 89528d7c3a core(ocl): don't expose exceptions from OpenCL callback
to avoid silent crashes of OpenCL worker threads.
2018-07-28 10:29:26 +00:00
Alexander Alekhin 0bef42ba12 videoio: add note about image BGR format VideoWriter::write() 2018-07-28 09:08:09 +00:00
Alexander Alekhin b41bc0ae59 Merge pull request #12067 from mshabunin:clean-test-case-list 2018-07-28 06:21:53 +00:00
Maksim Shabunin fb1f12021b Fixed build with latest IE version 2018-07-27 19:56:35 +03:00
Maksim Shabunin dd8e990451 Fixed several issues found by static analysis, GStreamer backend 2018-07-27 18:41:39 +03:00
Maksim Shabunin e031bada7d Fixed several issues found by static analysis, Windows-specific 2018-07-27 18:25:55 +03:00
Alexander Alekhin 2b7ff90e63 Merge pull request #12078 from mshabunin:fix-plus-dir 2018-07-27 15:00:33 +00:00
Alexander Alekhin b597c87bed dnn(ocl): avoid memory access violation 2018-07-27 15:35:11 +03:00
Maksim Shabunin 0aded5aae6 cmake: fixed builds in directories containing plus sign 2018-07-27 15:05:56 +03:00
Karpushin Vladislav a8e9a3a88d doc: add new tutorial "Out of focus deblur filter"
In this tutorial you will learn:
- what is a degradation image model
- what is a PSF of an out-of-focus image
- how to restore a blurred image
- what is the Wiener filter
2018-07-27 17:12:24 +07:00
Alexander Alekhin 2f0fc920dd Merge pull request #12061 from alalek:dnn_test_skip_checks_only 2018-07-26 15:15:32 +00:00
Alexander Alekhin 9137e2d635 Merge pull request #12060 from alalek:dnn_debug_layers 2018-07-26 15:14:32 +00:00
Alexander Alekhin c37d1a53b5 Merge pull request #12025 from Triplesalt:tfimport-relu 2018-07-26 15:08:05 +00:00
Maksim Shabunin 1165fdd0f5 Added more strict checks for empty inputs to compare, meanStdDev and RNG::fill 2018-07-26 18:06:38 +03:00
Maksim Shabunin 597db69151 ts: test case list is printed after cmd line parsing, refactored 2018-07-26 16:43:43 +03:00
Triplesalt 9eb79926df Allow a different input order for Mul+Maximum.
Squashed : ReLU operand order tests.
2018-07-26 14:19:11 +02:00
Vadim Pisarevsky fa466b022d Merge pull request #12052 from dkurt:dnn_ie_torch_tests 2018-07-26 09:09:35 +00:00
Vadim Pisarevsky 43820d89b4 further improvements in split & merge; started using non-temporary store instructions (#12063)
* 1. changed static const __m128/256 to const __m128/256 to avoid wierd instructions and calls inserted by compiler.
2. added universal intrinsics that wrap MOVNTPS and other such (non-temporary or "no cache" store) instructions. v_store_interleave() and v_store() got respective flags/overloaded variants
3. rewrote split & merge to use the "no cache" store instructions. It resulted in dramatic performance improvement when processing big arrays

* hopefully, fixed some test failures where 4-channel v_store_interleave() is used

* added missing implementation of the new universal intrinsics (v_store_aligned_nocache() etc.)

* fixed silly typo in the new intrinsics in intrin_vsx.hpp

* still trying to fix VSX compiler errors

* still trying to fix VSX compiler errors

* still trying to fix VSX compiler errors

* still trying to fix VSX compiler errors
2018-07-26 12:04:28 +03:00
Dmitry Kurtaev faa6c4e1e1 Faster-RCNN anf RFCN models on CPU using Intel's Inference Engine backend.
Enable Torch layers tests with Intel's Inference Engine backend.
2018-07-25 19:04:55 +03:00
Alexander Alekhin dd8701c1a0 dnn(test): skip checks only for unstable tests
but execute tested functions in Layer_Test_Halide/Convolution.Accuracy
2018-07-25 16:55:21 +03:00
Alexander Alekhin 74cf48b5d7 dnn(test): use Backend/Target enums
instead of 'int'
2018-07-25 16:55:21 +03:00
Alexander Alekhin 45b5b3c13a dnn: check layer output for NaN/Inf 2018-07-25 16:25:18 +03:00
Alexander Alekhin 5336b9ad19 Merge pull request #12048 from mshabunin:fix-static-2 2018-07-24 19:45:27 +00:00
Alexander Alekhin a16254de2b Merge pull request #12047 from alalek:issue_12045 2018-07-24 19:44:25 +00:00
Alexander Alekhin 8a2ce75d96 Merge pull request #12020 from alalek:videoio_backends_query_api 2018-07-24 19:43:49 +00:00
Vadim Pisarevsky 9c7040802c converted split() & merge() to wide univ intrinsics (#12044)
* fixed/updated v_load_deinterleave and v_store_interleave intrinsics; modified split() and merge() functions to use those intrinsics

* fixed a few compile errors and bug in v_load_deinterleave(ptr, v_uint32x4& a, v_uint32x4& b)

* fixed few more compile errors
2018-07-24 17:27:56 +03:00
Maksim Shabunin cbb1e867e5 More issues found by static analysis 2018-07-24 16:04:42 +03:00
Alexander Alekhin 8de08e0463 Merge pull request #12021 from dkurt:dnn_ie_tf_ssd 2018-07-24 13:03:41 +00:00
Alexander Alekhin 236f383969 Merge pull request #12037 from dkurt:test_openvino_models 2018-07-24 12:34:04 +00:00
Alexander Alekhin 93abdbf25e Merge pull request #12041 from mshabunin:fix-static-2 2018-07-24 11:10:01 +00:00
Alexander Alekhin 8f80565d9c objdetect(qr): update test code
improve error checks
2018-07-24 13:56:55 +03:00
Alexander Alekhin 391b9586ac Merge pull request #12042 from dkurt:fix_opencv_as_submodule 2018-07-24 08:17:20 +00:00
Alexander Alekhin 4283309daa dnn: update tests for OpenVINO models 2018-07-24 09:41:14 +03:00
Alexander Alekhin 6e767e2376 ts: add findDataDirectory() function 2018-07-24 09:40:58 +03:00
Dmitry Kurtaev 0c4d5ffecd Do not copy cv_cpu_helper.h to parent if OpenCV is a submodule 2018-07-24 09:36:28 +03:00
Dmitry Kurtaev 28e08ae0bd Add a sample which tests OpenVINO models 2018-07-23 19:08:51 +03:00
Maksim Shabunin e0603bb45f Fixed several issues found by static analysis tools 2018-07-23 17:22:47 +03:00
Alexander Alekhin 7d40fcead5 Merge pull request #12031 from alalek:dnn_ocl_eliminate_getUMat_with_bad_lifetime 2018-07-23 07:52:42 +00:00
Paul92 8c7555523b Merge pull request #12032 from Paul92:mser-sample-improvments
Mser sample improvments (#12032)

* Fixed bug in detect_mser sample
Wrong number of colors used to generate the synthetic images

* Formatting improvements

* Using safer casts

* Improved readability of legend generation

* Various readability fixes in detect_mser sample
2018-07-22 17:08:29 +03:00
Alexander Alekhin b117302bca Merge pull request #12016 from tyl12:fix_videoio_static_para 2018-07-21 03:50:58 +00:00
Alexander Alekhin e1205d046a Merge pull request #12003 from mshabunin:avi-error-messages 2018-07-21 03:30:55 +00:00
Teng Yiliang dadde75ef0 use struct member width_set/height_set to replace static width/height.
the static variables will cause race-condition when operating in
multithread scenarios.

Signed-off-by: Teng Yiliang <ylteng@outlook.com>
Signed-off-by: Teng Yiliang <yiliang.teng@weimob.com>
2018-07-21 07:27:17 +08:00
Alexander Alekhin ee743afebe dnn(ocl): don't use getUMat() for long live objects 2018-07-20 17:53:55 +03:00
Alexander Alekhin 767b31cfbf Merge pull request #12029 from tomoaki0705:fixBuildVS2013BinarySuffix 2018-07-20 11:27:27 +00:00
Tomoaki Teshima 18abe54497 fix build error on Visual Studio 2013
* replace binary literal prefix to hexadecimal literal prefix
2018-07-20 18:09:17 +09:00
Alexander Alekhin 05f0cb16de Merge pull request #12022 from mshabunin:fix-ie-build 2018-07-19 20:50:42 +00:00
Maksim Shabunin a4060e15a4 dnn, IE backend: updated to match new interface 2018-07-19 19:22:23 +03:00
Alexander Alekhin 7198b9e461 Merge pull request #12019 from mshabunin:static-debug-assert 2018-07-19 15:50:33 +00:00
Alexander Alekhin ab9b6e806c Merge pull request #11781 from dkurt:dnn_uint8_inputs 2018-07-19 14:38:46 +00:00
Alexander Alekhin 270cc3bcbc videoio: add routines to query information about backends API
into cv::videoio_registry namespace
2018-07-19 17:27:37 +03:00
Dmitry Kurtaev c213a3823e Run entire SSDs from TensorFlow using Intel's Inference Engine 2018-07-19 17:05:56 +03:00
Alexander Alekhin 51074b9743 Merge pull request #12007 from alalek:fix_ts_perf_test_macro 2018-07-19 12:09:48 +00:00
Dmitry Kurtaev 070393dfda uint8 inputs for deep learning networks 2018-07-19 14:37:33 +03:00
Alexander Alekhin f4df537e27 ts: fix PERF_TEST() macro to allow test_case name reusing
Example (reuse 'Transform' test case):
PERF_TEST(Transform, getPerspectiveTransform_1000) { ... }
PERF_TEST(Transform, getPerspectiveTransform_QR_1000) { ... }
2018-07-19 13:20:54 +03:00
Alexander Alekhin 905da2994a Merge pull request #12008 from alalek:test_remove_verbose_messages 2018-07-19 09:37:36 +00:00
Alexander Alekhin e526c4bfe4 core(test): remove verbose messages 2018-07-18 16:09:27 +03:00
Maksim Shabunin fe806878be Enable debug assertions for static analysis builds 2018-07-18 15:53:16 +03:00
Maksim Shabunin a2a9a01e05 AVI container: verbose error messages 2018-07-18 15:22:42 +03:00
Alexander Alekhin 6c4f618db5 Merge pull request #11104 from asciian:reading_from_stream 2018-07-17 16:24:06 +00:00
Alexander Alekhin f3ee07ca11 Merge pull request #11986 from alalek:build_eliminate_gcc8_warnings 2018-07-17 15:41:36 +00:00
Alexander Alekhin 7cc84ce8ab Merge pull request #11984 from mshabunin:fix-static-1 2018-07-17 15:40:48 +00:00
Alexander Alekhin 40b8ca2eed Merge pull request #11968 from allnes:detect_qr_code 2018-07-17 15:38:46 +00:00
Alexander Alekhin 4dcef28023 Merge pull request #11964 from mshabunin:avi-container-fixes 2018-07-17 15:35:07 +00:00
Alexander Alekhin 0a41b3df45 Merge pull request #11990 from alalek:clone_nodiscard_attribute 2018-07-17 15:34:08 +00:00
Alexander Alekhin f086fc5b18 Merge pull request #11994 from alalek:cmake_find_package_inference_engine 2018-07-17 15:14:41 +00:00
Maksim Shabunin c473718bc2 Check for empty Mat in compare, operator= and RNG::fill, fixed related tests 2018-07-17 17:50:50 +03:00
Maksim Shabunin 1da46fe6fb Fixed issues found by static analysis (mostly DBZ) 2018-07-17 16:14:54 +03:00
Alexander Alekhin 5b72e83687 cmake: prefer using find_package(InferenceEngine) 2018-07-17 15:31:11 +03:00
Alexander Alekhin 78d07e841d Merge pull request #11959 from pengli:3.4 2018-07-17 11:20:02 +00:00
Dmitry Kurtaev f38808a39f Add Java overloads for each default argument (#11940)
* Add Java overloads for each default argument

* Add "fisheye_" prefix for cv::fisheye:: functions and enums
2018-07-17 13:41:46 +03:00
Alexander Alekhin 540415dc5e Merge pull request #11989 from csukuangfj:patch_2 2018-07-17 10:27:21 +00:00
Li Peng f0cadaa6e3 enable concat layer fuse for OCL target
Signed-off-by: Li Peng <peng.li@intel.com>
2018-07-17 12:46:16 +08:00
Vadim Pisarevsky f058b5fb1e Wide univ intrinsics (#11953)
* core:OE-27 prepare universal intrinsics to expand (#11022)

* core:OE-27 prepare universal intrinsics to expand (#11022)

* core: Add universal intrinsics for AVX2

* updated implementation of wide univ. intrinsics; converted several OpenCV HAL functions: sqrt, invsqrt, magnitude, phase, exp to the wide universal intrinsics.

* converted log to universal intrinsics; cleaned up the code a bit; added v_lut_deinterleave intrinsics.

* core: Add universal intrinsics for AVX2

* fixed multiple compile errors

* fixed many more compile errors and hopefully some test failures

* fixed some more compile errors

* temporarily disabled IPP to debug exp & log; hopefully fixed Doxygen complains

* fixed some more compile errors

* fixed v_store(short*, v_float16&) signatures

* trying to fix the test failures on Linux

* fixed some issues found by alalek

* restored IPP optimization after the patch with AVX wide intrinsics has been properly tested

* restored IPP optimization after the patch with AVX wide intrinsics has been properly tested
2018-07-16 18:57:24 +03:00
Alexander Alekhin 481829a81b Merge pull request #11957 from alalek:issue_11956 2018-07-16 15:54:34 +00:00
Alexander Alekhin c9439476da Merge pull request #11970 from dkurt:dnn_enable_tf_tests 2018-07-16 15:51:27 +00:00
Alexander Alekhin 60994389a6 Merge pull request #11985 from alalek:cmake_update_inference_engine_detection 2018-07-16 15:49:19 +00:00
Alexander Alekhin b0ee5d9023 core: CV_NODISCARD macro with semantic of [[nodiscard]] attr
[[nodiscard]] is defined in C++17.
There is fallback alias for modern GCC / Clang compilers.
2018-07-16 18:03:32 +03:00
Kuang Fangjun 84f2f37680 remove a useless statement. 2018-07-16 22:44:11 +08:00
Alexander Alekhin d5951bc033 build: eliminate GCC8 warnings 2018-07-16 17:24:12 +03:00
Alexander Alekhin a5e8ae2183 Merge pull request #11969 from alalek:core_Matx_inv_solve_templates 2018-07-16 14:18:12 +00:00
Alexander Alekhin 1dec480974 Merge pull request #11951 from alalek:cuda_use_external_cmake_module 2018-07-16 13:41:45 +00:00
Alexander Alekhin d6c669f5cf Merge pull request #11963 from dkurt:dnn_cl_fix_matmul 2018-07-16 11:10:32 +00:00
Alexander Alekhin 014ae55379 cmake: update DL IE detection to align with OpenVINO 2018 R2
These CMake options are enough:
- `-DWITH_INF_ENGINE=ON`
- `-DIE_PLUGINS_PATH=lib/ubuntu_16.04/intel64`
- `-DENABLE_CXX11=ON` (OpenCV 3.4 only)
2018-07-16 14:02:23 +03:00
Maksim Shabunin 53eb27f508 AVI container: use C++ streams for file operations, check some operations for overflow 2018-07-16 13:46:28 +03:00
Alexander Alekhin 4a3dfffd46 Merge pull request #11965 from alalek:issue_11944 2018-07-16 09:48:33 +00:00
Alexander Alekhin 50751ae6ff Merge pull request #11967 from catree:add_tutorial_ml_java_python 2018-07-16 09:24:32 +00:00
Alexander Alekhin 10676f86d5 Merge pull request #11971 from csukuangfj:patch_1 2018-07-15 15:06:17 +00:00
Alexander Nesterov dee5f9a67b Update qrcode algorithm: fix seg. fault with kmeans 2018-07-14 21:51:21 +03:00
Kuang Fangjun 2b6aa50b81 avoid negative index. 2018-07-14 16:05:29 +08:00
Alexander Alekhin 3c74fde349 core: eliminate 'if' logic from Matx::inv()/solve()
- 'if' logic is moved into templates.
- removed unnecessary cv::Mat objects creation.
- fixed inv() test (invA * A == eye)
- added more Matx tests to cover all defined template specializations
2018-07-13 20:09:01 +03:00
Dmitry Kurtaev 6eb8faea85 Enable TensorFlow networks tests for different backends and targets 2018-07-13 19:58:56 +03:00
Alexander Alekhin 23fc96e98f Merge pull request #11955 from terfendail:matx_solve_fix2 2018-07-13 15:15:03 +00:00
Vadim Pisarevsky abceae1ac0 Merge pull request #11921 from allnes:detect_qr_code 2018-07-13 14:26:17 +00:00
Alexander Alekhin eed1130327 Merge pull request #11966 from alalek:core_solve_method_check 2018-07-13 14:25:42 +00:00
catree 41b95cae38 Add Java and Python code for ML tutorials. 2018-07-13 15:52:28 +02:00
Dmitry Kurtaev de6f0a537d Fix fully-connected layer in case of number of rows less than 4 2018-07-13 16:35:37 +03:00
catree 4dc7e617a4 Add overloaded cv::PCACompute() that returns also the eigenvalues. Useful for Java and Python OpenCV where PCA is not available. 2018-07-13 15:05:54 +02:00
Alexander Alekhin 0155851929 imgproc(getPerspectiveTransform): add configuration parameter 2018-07-13 15:31:33 +03:00
Alexander Alekhin 71c6cb9c22 imgproc(getPerspectiveTransform): solve(DECOMP_SVD -> LU) 2018-07-13 15:31:33 +03:00
Alexander Alekhin 2170811e48 imgproc(perf): update getPerspectiveTransform perf test
Function is very fast, so 0.000 ms results are useless.
1000 runs requires 25ms on i7-6700K.
2018-07-13 15:31:33 +03:00
Alexander Alekhin 9d8495f8b3 Merge pull request #11960 from dkurt:dnn_cl_clip_kernel 2018-07-13 12:29:47 +00:00
Alexander Alekhin 5385086fef core: solve(): add check for passed 'method' values 2018-07-13 15:15:48 +03:00
Dmitry Kurtaev dcc1beb1f8 Clip kernel for OpenCL PriorBox layer 2018-07-13 14:49:13 +03:00
Alexander Nesterov e38ea3a888 Update detect QRCode algorithm 2018-07-12 18:18:57 -03:00
Alexander Alekhin 33b7028be2 core: use "explicit" for Matx() ctor 2018-07-12 19:50:56 +00:00
Vitaly Tuzov 850a8577b2 Fixed unreachable code warnings for Matx::solve() 2018-07-12 19:19:51 +03:00
Alexander Alekhin e79c729b20 CUDA: allow to use external FindCUDA from modern CMake
CMake 3.9.0+ is required
2018-07-12 14:33:14 +03:00
Alexander Alekhin 625d20b9b4 Merge pull request #11949 from berak:dnn_object_detection_typo 2018-07-12 09:48:08 +00:00
berak 1c75f3d037 dnn: fix typo in object_detection.cpp sample 2018-07-12 11:06:53 +02:00
Alexander Alekhin 9c3ec05825 Merge pull request #11941 from alalek:dnn_ocl_fix_verify_umat_mapping 2018-07-12 07:37:55 +00:00
Alexander Alekhin 875f23881f Merge pull request #11942 from catree:add_tutorial_core_java_python 2018-07-11 20:27:17 +00:00
Vitaly Tuzov d0a3686812 Merge pull request #11904 from terfendail/matx_solve_fix
Fixed Matx::solve function for non-square matrixes (#11904)
2018-07-11 22:00:57 +03:00
catree c9fe6f1afe Add Java and Python code for the following tutorials:
- Changing the contrast and brightness of an image!
      - Operations with images
2018-07-11 20:14:58 +02:00
Alexander Alekhin 2508f7f971 dnn(ocl): fix wrong usage of stalled .getMat() pointers
Temporary object lifetime must be greater than pointer usage.
2018-07-11 19:11:36 +03:00
Dmitry Kurtaev 8b5f061dae Replace std::vector<char> to std::vector<uchar> for Java bindings of dnn importers 2018-07-11 18:58:56 +03:00
Alexander Alekhin 999aba3807 Merge pull request #11936 from berak:dnn_shufflelayer_name 2018-07-11 12:01:31 +00:00
Alexander Alekhin 82c7ab0231 Merge pull request #11927 from pengli:3.4 2018-07-11 09:33:24 +00:00
Li Peng 4c5a86828a Fix gemmlike convolution input reading
use vload3 for half3 or float3 input vector reading,
also check read position to see if it exceed input width

Signed-off-by: Li Peng <peng.li@intel.com>
2018-07-11 15:25:21 +08:00
berak a7b502f04a dnn: preserve name, type strings for ShuffleLayer 2018-07-11 08:19:23 +02:00
Alexander Alekhin e4b5e9b9c9 Merge pull request #11931 from catree:add_doc_eye_ones 2018-07-10 15:43:32 +00:00
Alexander Alekhin e9bb26267e Merge pull request #11929 from alalek:dnn_test_drop_enums 2018-07-10 15:31:52 +00:00
catree d7bd662c95 Add a note in the documentation about Mat::ones and mat::eye. With multi-channels type (e.g. CV_8UC3), only the first channel is treated. 2018-07-10 15:35:46 +02:00
Alexander Alekhin 452fa3011c dnn(test): drop CV_ENUM for DNNBackend / DNNTarget 2018-07-10 15:12:01 +03:00
Dmitry Kurtaev d57e5406f0 Add readNet* functions which parse models from byte arrays 2018-07-10 11:12:01 +03:00
Alexander Alekhin 7fe0727930 Merge pull request #11924 from alalek:dnn_ocl_fix_max_pool_forward 2018-07-09 16:25:34 +00:00
Alexander Alekhin 529d38613b Merge pull request #11923 from alalek:dnn_external_protobuf 2018-07-09 16:07:42 +00:00
Alexander Alekhin 88d56dc700 Merge pull request #11922 from alalek:dnn_test_myriad_check 2018-07-09 16:07:18 +00:00
Alexander Alekhin 7ba66a1682 Merge pull request #11703 from alalek:c_api_calib3d_chessboard_detector 2018-07-09 15:37:26 +00:00
Alexander Alekhin b6255ab9e7 dnn(ocl4dnn): fix args for 'max_pool_forward' kernel 2018-07-09 18:02:20 +03:00
Alexander Alekhin 924ff903ad Merge pull request #11903 from alalek:issue_9002 2018-07-09 14:49:37 +00:00
Alexander Alekhin e2b5d11290 dnn: allow to use external protobuf
"custom layers" feature will not work properly in these builds.
2018-07-09 17:28:45 +03:00
Alexander Alekhin e41f19d2f3 Merge pull request #11919 from dkurt:dnn_replace_convert_fp16 2018-07-09 14:07:37 +00:00
Alexander Alekhin 52b151dceb dnn(test): use checkMyriadTarget() in Test_Caffe_layers.Conv_Elu test 2018-07-09 16:20:46 +03:00
Dmitry Kurtaev 362d4f5395 Replace convertFp16 from dnn::Net::setInput() 2018-07-09 14:35:54 +03:00
Alexander Alekhin a29d11240e Merge pull request #11906 from berak:fix_qrcode 2018-07-09 09:36:41 +00:00
asciian 61d8719b8d Reading net from std::ifstream
Remove some assertions

Replace std::ifstream to std::istream

Add test for new importer

Remove constructor to load file

Rename cfgStream and darknetModelStream to ifile

Add error notification to inform pathname to user

Use FileStorage instead of std::istream

Use FileNode instead of FileStorage

Fix typo
2018-07-09 10:02:05 +03:00
Alexander Alekhin 0fd74fa177 Merge pull request #11911 from berak:core_fix_autobuffer_opengl 2018-07-08 13:50:35 +00:00
berak 45677819e8 core: fix autobuffer usage in opengl.cpp 2018-07-08 09:51:06 +02:00
berak e14b2ba43c objdetect: validate input in qrcode 2018-07-07 16:56:40 +02:00
Alexander Alekhin 81325a3fa0 highgui(gtk): use recursive cv::Mutex for 'window_mutex' variable 2018-07-06 17:35:47 +03:00
Alexander Alekhin aa0c6ddb4c highgui: fix GTK issues with external UI thread 2018-07-06 17:35:47 +03:00
Alexander Alekhin 5e6a3f1f6c Merge pull request #11901 from alalek:fix_cuda_build 2018-07-06 14:07:50 +00:00
Vadim Pisarevsky 523b6f32ba Merge pull request #11867 from dkurt:dnn_ie_layers 2018-07-06 13:13:20 +00:00
Alexander Alekhin fc59498b2b cuda: fix build
use cv::AutoBuffer::data() to get data pointer
2018-07-06 15:32:36 +03:00
Alexander Alekhin 3b01777c98 Merge pull request #11895 from alalek:fix_fn_types 2018-07-06 12:01:31 +00:00
Alexander Alekhin aa10cdbfa2 Merge pull request #11900 from alalek:build_warnings 2018-07-06 12:00:43 +00:00
Alexander Alekhin 06fc77610b core(hal): eliminate build warnings 2018-07-06 13:00:41 +03:00
Dmitry Kurtaev 019c2f2115 Enable more deep learning tests 2018-07-05 14:23:15 +03:00
Alexander Alekhin 4bc080dc50 fix function signatures, drop invalid casts 2018-07-05 13:55:26 +03:00
Alexander Alekhin c7fc563dc0 calib3d: chessboard detector - replace OpenCV C API 2018-07-05 13:09:10 +03:00
Alexander Alekhin 0bb2c115aa Merge pull request #11719 from alalek:update_autobuffer_api 2018-07-05 10:01:15 +00:00
Alexander Alekhin ccd2370bb7 Merge pull request #11890 from dkurt:keras_resize_nearest 2018-07-05 09:57:24 +00:00
Alexander Alekhin c0d0cf5e74 Merge pull request #11893 from dkurt:fix_11884 2018-07-05 09:56:50 +00:00
Alexander Alekhin b09a4a98d4 opencv: Use cv::AutoBuffer<>::data() 2018-07-04 19:11:29 +03:00
Alexander Alekhin 135ea264ef core: align cv::AutoBuffer API with std::vector/std::array
- added .data() methods
- added operator[] (int i)
- extend checks support to generic and debug-only cases
- deprecate existed operator* ()
2018-07-04 19:10:38 +03:00
Dmitry Kurtaev f25a01bb5a Disable fusion to output layers 2018-07-04 15:53:47 +03:00
Alexander Alekhin 6309e28dd0 Merge tag '3.4.2-openvino' 2018-07-04 14:08:21 +03:00
Alexander Alekhin bd8c8e720e Merge tag '3.4.2' 2018-07-04 14:08:11 +03:00
Dmitry Kurtaev 36288eebe7 Nearest neighbor resize from Keras 2018-07-04 11:53:24 +03:00
Alexander Alekhin 49886ebae3 OpenCV version '-openvino' 2018-06-10 10:20:38 +03:00
427 changed files with 17350 additions and 8384 deletions
+1 -1
View File
@@ -335,7 +335,7 @@ ITT_INLINE long __itt_interlocked_increment(volatile long* ptr)
#ifdef SDL_STRNCPY_S
#define __itt_fstrcpyn(s1, b, s2, l) SDL_STRNCPY_S(s1, b, s2, l)
#else
#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, l)
#define __itt_fstrcpyn(s1, b, s2, l) strncpy(s1, s2, b)
#endif /* SDL_STRNCPY_S */
#define __itt_fstrdup(s) strdup(s)
+4
View File
@@ -47,6 +47,10 @@ ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -W
-Wsuggest-override -Winconsistent-missing-override
-Wimplicit-fallthrough
)
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
+3
View File
@@ -29,6 +29,9 @@ if(CV_ICC)
-wd265 -wd858 -wd873 -wd2196
)
endif()
if(CV_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 8.0)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wclass-memaccess)
endif()
# Easier to support different versions of protobufs
function(append_if_exist OUTPUT_LIST)
+17 -3
View File
@@ -276,7 +276,7 @@ OCV_OPTION(WITH_VA "Include VA support" OFF
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) )
OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF IF ((UNIX AND NOT ANDROID) OR (WIN32 AND NOT WINRT AND NOT MINGW)) )
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" OFF IF (UNIX AND NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_LAPACK "Include Lapack library support" (NOT CV_DISABLE_OPTIMIZATION) IF (NOT ANDROID AND NOT IOS) )
OCV_OPTION(WITH_ITT "Include Intel ITT support" ON IF (NOT APPLE_FRAMEWORK) )
OCV_OPTION(WITH_PROTOBUF "Enable libprotobuf" ON )
@@ -1407,8 +1407,22 @@ if(WITH_HALIDE OR HAVE_HALIDE)
status(" Halide:" HAVE_HALIDE THEN "YES (${HALIDE_LIBRARIES} ${HALIDE_INCLUDE_DIRS})" ELSE NO)
endif()
if(WITH_INF_ENGINE OR HAVE_INF_ENGINE)
status(" Inference Engine:" HAVE_INF_ENGINE THEN "YES (${INF_ENGINE_LIBRARIES} ${INF_ENGINE_INCLUDE_DIRS})" ELSE NO)
if(WITH_INF_ENGINE OR INF_ENGINE_TARGET)
if(INF_ENGINE_TARGET)
set(__msg "YES (${INF_ENGINE_RELEASE} / ${INF_ENGINE_VERSION})")
get_target_property(_lib ${INF_ENGINE_TARGET} IMPORTED_LOCATION)
if(NOT _lib)
get_target_property(_lib_rel ${INF_ENGINE_TARGET} IMPORTED_IMPLIB_RELEASE)
get_target_property(_lib_dbg ${INF_ENGINE_TARGET} IMPORTED_IMPLIB_DEBUG)
set(_lib "${_lib_rel} / ${_lib_dbg}")
endif()
get_target_property(_inc ${INF_ENGINE_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
status(" Inference Engine:" "${__msg}")
status(" libs:" "${_lib}")
status(" includes:" "${_inc}")
else()
status(" Inference Engine:" "NO")
endif()
endif()
if(WITH_EIGEN OR HAVE_EIGEN)
+6 -4
View File
@@ -54,6 +54,10 @@
#include "opencv2/highgui.hpp"
#include "opencv2/calib3d.hpp"
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
using namespace cv;
#ifndef PATH_MAX
@@ -1040,12 +1044,10 @@ void cvCreateTrainingSamples( const char* filename,
output = fopen( filename, "wb" );
if( output != NULL )
{
int hasbg;
int i;
int inverse;
hasbg = 0;
hasbg = (bgfilename != NULL && icvInitBackgroundReaders( bgfilename,
const int hasbg = (bgfilename != NULL && icvInitBackgroundReaders( bgfilename,
Size( winwidth,winheight ) ) );
Mat sample( winheight, winwidth, CV_8UC1 );
@@ -1372,7 +1374,7 @@ int icvGetTraininDataFromVec( Mat& img, CvVecFile& userdata )
size_t elements_read = fread( &tmp, sizeof( tmp ), 1, userdata.input );
CV_Assert(elements_read == 1);
elements_read = fread( vector, sizeof( short ), userdata.vecsize, userdata.input );
elements_read = fread(vector.data(), sizeof(short), userdata.vecsize, userdata.input);
CV_Assert(elements_read == (size_t)userdata.vecsize);
if( feof( userdata.input ) || userdata.last++ >= userdata.count )
@@ -224,8 +224,10 @@ void calib::calibDataController::filterFrames()
cv::Mat newErrorsVec = cv::Mat((int)numberOfFrames - 1, 1, CV_64F);
std::copy(mCalibData->perViewErrors.ptr<double>(0),
mCalibData->perViewErrors.ptr<double>((int)worstElemIndex), newErrorsVec.ptr<double>(0));
std::copy(mCalibData->perViewErrors.ptr<double>((int)worstElemIndex + 1), mCalibData->perViewErrors.ptr<double>((int)numberOfFrames),
if((int)worstElemIndex < (int)numberOfFrames-1) {
std::copy(mCalibData->perViewErrors.ptr<double>((int)worstElemIndex + 1), mCalibData->perViewErrors.ptr<double>((int)numberOfFrames),
newErrorsVec.ptr<double>((int)worstElemIndex));
}
mCalibData->perViewErrors = newErrorsVec;
}
}
@@ -16,7 +16,7 @@ void calib::Euler(const cv::Mat& src, cv::Mat& dst, int argType)
{
if((src.rows == 3) && (src.cols == 3))
{
//convert rotaion matrix to 3 angles (pitch, yaw, roll)
//convert rotation matrix to 3 angles (pitch, yaw, roll)
dst = cv::Mat(3, 1, CV_64F);
double pitch, yaw, roll;
@@ -55,7 +55,7 @@ void calib::Euler(const cv::Mat& src, cv::Mat& dst, int argType)
else if( (src.cols == 1 && src.rows == 3) ||
(src.cols == 3 && src.rows == 1 ) )
{
//convert vector which contains 3 angles (pitch, yaw, roll) to rotaion matrix
//convert vector which contains 3 angles (pitch, yaw, roll) to rotation matrix
double pitch, yaw, roll;
if(src.cols == 1 && src.rows == 3)
{
+2 -2
View File
@@ -165,7 +165,7 @@ void CvHOGEvaluator::integralHistogram(const Mat &img, vector<Mat> &histogram, M
Mat qangle(gradSize, CV_8U);
AutoBuffer<int> mapbuf(gradSize.width + gradSize.height + 4);
int* xmap = (int*)mapbuf + 1;
int* xmap = mapbuf.data() + 1;
int* ymap = xmap + gradSize.width + 2;
const int borderType = (int)BORDER_REPLICATE;
@@ -177,7 +177,7 @@ void CvHOGEvaluator::integralHistogram(const Mat &img, vector<Mat> &histogram, M
int width = gradSize.width;
AutoBuffer<float> _dbuf(width*4);
float* dbuf = _dbuf;
float* dbuf = _dbuf.data();
Mat Dx(1, width, CV_32F, dbuf);
Mat Dy(1, width, CV_32F, dbuf + width);
Mat Mag(1, width, CV_32F, dbuf + width*2);
+6 -6
View File
@@ -383,7 +383,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
int ci = get_var_type(vi);
CV_Assert( ci < 0 );
int *src_idx_buf = (int*)(uchar*)inn_buf;
int *src_idx_buf = (int*)inn_buf.data();
float *src_val_buf = (float*)(src_idx_buf + sample_count);
int* sample_indices_buf = (int*)(src_val_buf + sample_count);
const int* src_idx = 0;
@@ -423,7 +423,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
}
// subsample cv_lables
const int* src_lbls = get_cv_labels(data_root, (int*)(uchar*)inn_buf);
const int* src_lbls = get_cv_labels(data_root, (int*)inn_buf.data());
if (is_buf_16u)
{
unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
@@ -440,7 +440,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
}
// subsample sample_indices
const int* sample_idx_src = get_sample_indices(data_root, (int*)(uchar*)inn_buf);
const int* sample_idx_src = get_sample_indices(data_root, (int*)inn_buf.data());
if (is_buf_16u)
{
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
@@ -815,7 +815,7 @@ struct FeatureIdxOnlyPrecalc : ParallelLoopBody
void operator()( const Range& range ) const
{
cv::AutoBuffer<float> valCache(sample_count);
float* valCachePtr = (float*)valCache;
float* valCachePtr = valCache.data();
for ( int fi = range.start; fi < range.end; fi++)
{
for( int si = 0; si < sample_count; si++ )
@@ -1084,7 +1084,7 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
CvMat* buf = data->buf;
size_t length_buf_row = data->get_length_subbuf();
cv::AutoBuffer<uchar> inn_buf(n*(3*sizeof(int)+sizeof(float)));
int* tempBuf = (int*)(uchar*)inn_buf;
int* tempBuf = (int*)inn_buf.data();
bool splitInputData;
complete_node_dir(node);
@@ -1398,7 +1398,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
int inn_buf_size = ((params.boost_type == LOGIT) || (params.boost_type == GENTLE) ? n*sizeof(int) : 0) +
( !tree ? n*sizeof(int) : 0 );
cv::AutoBuffer<uchar> inn_buf(inn_buf_size);
uchar* cur_inn_buf_pos = (uchar*)inn_buf;
uchar* cur_inn_buf_pos = inn_buf.data();
if ( (params.boost_type == LOGIT) || (params.boost_type == GENTLE) )
{
step = CV_IS_MAT_CONT(data->responses_copy->type) ?
+11 -11
View File
@@ -168,7 +168,7 @@ CvBoostTree::try_split_node( CvDTreeNode* node )
// store the responses for the corresponding training samples
double* weak_eval = ensemble->get_weak_response()->data.db;
cv::AutoBuffer<int> inn_buf(node->sample_count);
const int* labels = data->get_cv_labels( node, (int*)inn_buf );
const int* labels = data->get_cv_labels(node, inn_buf.data());
int i, count = node->sample_count;
double value = node->value;
@@ -191,7 +191,7 @@ CvBoostTree::calc_node_dir( CvDTreeNode* node )
if( data->get_var_type(vi) >= 0 ) // split on categorical var
{
cv::AutoBuffer<int> inn_buf(n);
const int* cat_labels = data->get_cat_var_data( node, vi, (int*)inn_buf );
const int* cat_labels = data->get_cat_var_data(node, vi, inn_buf.data());
const int* subset = node->split->subset;
double sum = 0, sum_abs = 0;
@@ -210,7 +210,7 @@ CvBoostTree::calc_node_dir( CvDTreeNode* node )
else // split on ordered var
{
cv::AutoBuffer<uchar> inn_buf(2*n*sizeof(int)+n*sizeof(float));
float* values_buf = (float*)(uchar*)inn_buf;
float* values_buf = (float*)inn_buf.data();
int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n;
const float* values = 0;
@@ -260,7 +260,7 @@ CvBoostTree::find_split_ord_class( CvDTreeNode* node, int vi, float init_quality
cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf )
inn_buf.allocate(n*(3*sizeof(int)+sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf;
uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n;
@@ -369,7 +369,7 @@ CvBoostTree::find_split_cat_class( CvDTreeNode* node, int vi, float init_quality
cv::AutoBuffer<uchar> inn_buf((2*mi+3)*sizeof(double) + mi*sizeof(double*));
if( !_ext_buf)
inn_buf.allocate( base_size + 2*n*sizeof(int) );
uchar* base_buf = (uchar*)inn_buf;
uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* cat_labels_buf = (int*)ext_buf;
@@ -490,7 +490,7 @@ CvBoostTree::find_split_ord_reg( CvDTreeNode* node, int vi, float init_quality,
cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf )
inn_buf.allocate(2*n*(sizeof(int)+sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf;
uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf;
int* indices_buf = (int*)(values_buf + n);
@@ -559,7 +559,7 @@ CvBoostTree::find_split_cat_reg( CvDTreeNode* node, int vi, float init_quality,
cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf )
inn_buf.allocate(base_size + n*(2*sizeof(int) + sizeof(float)));
uchar* base_buf = (uchar*)inn_buf;
uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* cat_labels_buf = (int*)ext_buf;
@@ -652,7 +652,7 @@ CvBoostTree::find_surrogate_split_ord( CvDTreeNode* node, int vi, uchar* _ext_bu
cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf )
inn_buf.allocate(n*(2*sizeof(int)+sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf;
uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf;
int* indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = indices_buf + n;
@@ -733,7 +733,7 @@ CvBoostTree::find_surrogate_split_cat( CvDTreeNode* node, int vi, uchar* _ext_bu
cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf )
inn_buf.allocate(base_size + n*sizeof(int));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf;
uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
int* cat_labels_buf = (int*)ext_buf;
const int* cat_labels = data->get_cat_var_data(node, vi, cat_labels_buf);
@@ -797,7 +797,7 @@ CvBoostTree::calc_node_value( CvDTreeNode* node )
int i, n = node->sample_count;
const double* weights = ensemble->get_weights()->data.db;
cv::AutoBuffer<uchar> inn_buf(n*(sizeof(int) + ( data->is_classifier ? sizeof(int) : sizeof(int) + sizeof(float))));
int* labels_buf = (int*)(uchar*)inn_buf;
int* labels_buf = (int*)inn_buf.data();
const int* labels = data->get_cv_labels(node, labels_buf);
double* subtree_weights = ensemble->get_subtree_weights()->data.db;
double rcw[2] = {0,0};
@@ -1147,7 +1147,7 @@ CvBoost::update_weights( CvBoostTree* tree )
_buf_size += data->get_length_subbuf()*(sizeof(float)+sizeof(uchar));
}
inn_buf.allocate(_buf_size);
uchar* cur_buf_pos = (uchar*)inn_buf;
uchar* cur_buf_pos = inn_buf.data();
if ( (params.boost_type == LOGIT) || (params.boost_type == GENTLE) )
{
+24 -24
View File
@@ -780,7 +780,7 @@ CvDTreeNode* CvDTreeTrainData::subsample_data( const CvMat* _subsample_idx )
if( ci >= 0 || vi >= var_count )
{
int num_valid = 0;
const int* src = CvDTreeTrainData::get_cat_var_data( data_root, vi, (int*)(uchar*)inn_buf );
const int* src = CvDTreeTrainData::get_cat_var_data(data_root, vi, (int*)inn_buf.data());
if (is_buf_16u)
{
@@ -810,7 +810,7 @@ CvDTreeNode* CvDTreeTrainData::subsample_data( const CvMat* _subsample_idx )
}
else
{
int *src_idx_buf = (int*)(uchar*)inn_buf;
int *src_idx_buf = (int*)inn_buf.data();
float *src_val_buf = (float*)(src_idx_buf + sample_count);
int* sample_indices_buf = (int*)(src_val_buf + sample_count);
const int* src_idx = 0;
@@ -870,7 +870,7 @@ CvDTreeNode* CvDTreeTrainData::subsample_data( const CvMat* _subsample_idx )
}
}
// sample indices subsampling
const int* sample_idx_src = get_sample_indices(data_root, (int*)(uchar*)inn_buf);
const int* sample_idx_src = get_sample_indices(data_root, (int*)inn_buf.data());
if (is_buf_16u)
{
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
@@ -943,7 +943,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
{
float* dst = values + vi;
uchar* m = missing ? missing + vi : 0;
const int* src = get_cat_var_data(data_root, vi, (int*)(uchar*)inn_buf);
const int* src = get_cat_var_data(data_root, vi, (int*)inn_buf.data());
for( i = 0; i < count; i++, dst += var_count )
{
@@ -962,7 +962,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
float* dst = values + vi;
uchar* m = missing ? missing + vi : 0;
int count1 = data_root->get_num_valid(vi);
float *src_val_buf = (float*)(uchar*)inn_buf;
float *src_val_buf = (float*)inn_buf.data();
int* src_idx_buf = (int*)(src_val_buf + sample_count);
int* sample_indices_buf = src_idx_buf + sample_count;
const float *src_val = 0;
@@ -999,7 +999,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
{
if( is_classifier )
{
const int* src = get_class_labels(data_root, (int*)(uchar*)inn_buf);
const int* src = get_class_labels(data_root, (int*)inn_buf.data());
for( i = 0; i < count; i++ )
{
int idx = sidx ? sidx[i] : i;
@@ -1010,7 +1010,7 @@ void CvDTreeTrainData::get_vectors( const CvMat* _subsample_idx,
}
else
{
float* val_buf = (float*)(uchar*)inn_buf;
float* val_buf = (float*)inn_buf.data();
int* sample_idx_buf = (int*)(val_buf + sample_count);
const float* _values = get_ord_responses(data_root, val_buf, sample_idx_buf);
for( i = 0; i < count; i++ )
@@ -1780,7 +1780,7 @@ double CvDTree::calc_node_dir( CvDTreeNode* node )
if( data->get_var_type(vi) >= 0 ) // split on categorical var
{
cv::AutoBuffer<int> inn_buf(n*(!data->have_priors ? 1 : 2));
int* labels_buf = (int*)inn_buf;
int* labels_buf = inn_buf.data();
const int* labels = data->get_cat_var_data( node, vi, labels_buf );
const int* subset = node->split->subset;
if( !data->have_priors )
@@ -1824,7 +1824,7 @@ double CvDTree::calc_node_dir( CvDTreeNode* node )
int split_point = node->split->ord.split_point;
int n1 = node->get_num_valid(vi);
cv::AutoBuffer<uchar> inn_buf(n*(sizeof(int)*(data->have_priors ? 3 : 2) + sizeof(float)));
float* val_buf = (float*)(uchar*)inn_buf;
float* val_buf = (float*)inn_buf.data();
int* sorted_buf = (int*)(val_buf + n);
int* sample_idx_buf = sorted_buf + n;
const float* val = 0;
@@ -1929,16 +1929,16 @@ void DTreeBestSplitFinder::operator()(const BlockedRange& range)
if( data->is_classifier )
{
if( ci >= 0 )
res = tree->find_split_cat_class( node, vi, bestSplit->quality, split, (uchar*)inn_buf );
res = tree->find_split_cat_class( node, vi, bestSplit->quality, split, inn_buf.data() );
else
res = tree->find_split_ord_class( node, vi, bestSplit->quality, split, (uchar*)inn_buf );
res = tree->find_split_ord_class( node, vi, bestSplit->quality, split, inn_buf.data() );
}
else
{
if( ci >= 0 )
res = tree->find_split_cat_reg( node, vi, bestSplit->quality, split, (uchar*)inn_buf );
res = tree->find_split_cat_reg( node, vi, bestSplit->quality, split, inn_buf.data() );
else
res = tree->find_split_ord_reg( node, vi, bestSplit->quality, split, (uchar*)inn_buf );
res = tree->find_split_ord_reg( node, vi, bestSplit->quality, split, inn_buf.data() );
}
if( res && bestSplit->quality < split->quality )
@@ -1982,7 +1982,7 @@ CvDTreeSplit* CvDTree::find_split_ord_class( CvDTreeNode* node, int vi,
cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf )
inn_buf.allocate(base_size + n*(3*sizeof(int)+sizeof(float)));
uchar* base_buf = (uchar*)inn_buf;
uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n);
@@ -2096,7 +2096,7 @@ void CvDTree::cluster_categories( const int* vectors, int n, int m,
int iters = 0, max_iters = 100;
int i, j, idx;
cv::AutoBuffer<double> buf(n + k);
double *v_weights = buf, *c_weights = buf + n;
double *v_weights = buf.data(), *c_weights = buf.data() + n;
bool modified = true;
RNG* r = data->rng;
@@ -2201,7 +2201,7 @@ CvDTreeSplit* CvDTree::find_split_cat_class( CvDTreeNode* node, int vi, float in
cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf )
inn_buf.allocate(base_size + 2*n*sizeof(int));
uchar* base_buf = (uchar*)inn_buf;
uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* lc = (int*)base_buf;
@@ -2383,7 +2383,7 @@ CvDTreeSplit* CvDTree::find_split_ord_reg( CvDTreeNode* node, int vi, float init
cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf )
inn_buf.allocate(2*n*(sizeof(int) + sizeof(float)));
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf;
uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n;
@@ -2443,7 +2443,7 @@ CvDTreeSplit* CvDTree::find_split_cat_reg( CvDTreeNode* node, int vi, float init
cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf )
inn_buf.allocate(base_size + n*(2*sizeof(int) + sizeof(float)));
uchar* base_buf = (uchar*)inn_buf;
uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* labels_buf = (int*)ext_buf;
const int* labels = data->get_cat_var_data(node, vi, labels_buf);
@@ -2534,7 +2534,7 @@ CvDTreeSplit* CvDTree::find_surrogate_split_ord( CvDTreeNode* node, int vi, ucha
cv::AutoBuffer<uchar> inn_buf;
if( !_ext_buf )
inn_buf.allocate( n*(sizeof(int)*(data->have_priors ? 3 : 2) + sizeof(float)) );
uchar* ext_buf = _ext_buf ? _ext_buf : (uchar*)inn_buf;
uchar* ext_buf = _ext_buf ? _ext_buf : inn_buf.data();
float* values_buf = (float*)ext_buf;
int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n;
@@ -2658,7 +2658,7 @@ CvDTreeSplit* CvDTree::find_surrogate_split_cat( CvDTreeNode* node, int vi, ucha
cv::AutoBuffer<uchar> inn_buf(base_size);
if( !_ext_buf )
inn_buf.allocate(base_size + n*(sizeof(int) + (data->have_priors ? sizeof(int) : 0)));
uchar* base_buf = (uchar*)inn_buf;
uchar* base_buf = inn_buf.data();
uchar* ext_buf = _ext_buf ? _ext_buf : base_buf + base_size;
int* labels_buf = (int*)ext_buf;
@@ -2758,7 +2758,7 @@ void CvDTree::calc_node_value( CvDTreeNode* node )
int base_size = data->is_classifier ? m*cv_n*sizeof(int) : 2*cv_n*sizeof(double)+cv_n*sizeof(int);
int ext_size = n*(sizeof(int) + (data->is_classifier ? sizeof(int) : sizeof(int)+sizeof(float)));
cv::AutoBuffer<uchar> inn_buf(base_size + ext_size);
uchar* base_buf = (uchar*)inn_buf;
uchar* base_buf = inn_buf.data();
uchar* ext_buf = base_buf + base_size;
int* cv_labels_buf = (int*)ext_buf;
@@ -2961,7 +2961,7 @@ void CvDTree::complete_node_dir( CvDTreeNode* node )
if( data->get_var_type(vi) >= 0 ) // split on categorical var
{
int* labels_buf = (int*)(uchar*)inn_buf;
int* labels_buf = (int*)inn_buf.data();
const int* labels = data->get_cat_var_data(node, vi, labels_buf);
const int* subset = split->subset;
@@ -2980,7 +2980,7 @@ void CvDTree::complete_node_dir( CvDTreeNode* node )
}
else // split on ordered var
{
float* values_buf = (float*)(uchar*)inn_buf;
float* values_buf = (float*)inn_buf.data();
int* sorted_indices_buf = (int*)(values_buf + n);
int* sample_indices_buf = sorted_indices_buf + n;
const float* values = 0;
@@ -3042,7 +3042,7 @@ void CvDTree::split_node_data( CvDTreeNode* node )
CvMat* buf = data->buf;
size_t length_buf_row = data->get_length_subbuf();
cv::AutoBuffer<uchar> inn_buf(n*(3*sizeof(int) + sizeof(float)));
int* temp_buf = (int*)(uchar*)inn_buf;
int* temp_buf = (int*)inn_buf.data();
complete_node_dir(node);
+2 -2
View File
@@ -141,7 +141,7 @@
# -- Same as CUDA_ADD_EXECUTABLE except that a library is created.
#
# CUDA_BUILD_CLEAN_TARGET()
# -- Creates a convience target that deletes all the dependency files
# -- Creates a convenience target that deletes all the dependency files
# generated. You should make clean after running this target to ensure the
# dependency files get regenerated.
#
@@ -473,7 +473,7 @@ else()
endif()
# Propagate the host flags to the host compiler via -Xcompiler
option(CUDA_PROPAGATE_HOST_FLAGS "Propage C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)
option(CUDA_PROPAGATE_HOST_FLAGS "Propagate C/CXX_FLAGS and friends to the host compiler via -Xcompile" ON)
# Enable CUDA_SEPARABLE_COMPILATION
option(CUDA_SEPARABLE_COMPILATION "Compile CUDA objects with separable compilation enabled. Requires CUDA 5.0+" OFF)
+36 -10
View File
@@ -700,12 +700,21 @@ macro(ocv_compiler_optimization_fill_cpu_config)
list(APPEND __dispatch_modes ${CPU_DISPATCH_${OPT}_FORCE} ${OPT})
endforeach()
list(REMOVE_DUPLICATES __dispatch_modes)
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "")
foreach(OPT ${__dispatch_modes})
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
#define CV_CPU_DISPATCH_COMPILE_${OPT} 1")
endforeach()
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
\n\n#define CV_CPU_DISPATCH_FEATURES 0 \\")
foreach(OPT ${__dispatch_modes})
if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}
, CV_CPU_${OPT} \\")
endif()
endforeach()
set(OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE "${OPENCV_CPU_DISPATCH_DEFINITIONS_CONFIGMAKE}\n")
set(OPENCV_CPU_CONTROL_DEFINITIONS_CONFIGMAKE "// AUTOGENERATED, DO NOT EDIT\n")
foreach(OPT ${CPU_ALL_OPTIMIZATIONS})
if(NOT DEFINED CPU_${OPT}_FEATURE_ALIAS OR NOT "x${CPU_${OPT}_FEATURE_ALIAS}" STREQUAL "x")
@@ -740,7 +749,7 @@ macro(ocv_compiler_optimization_fill_cpu_config)
")
set(__file "${CMAKE_SOURCE_DIR}/modules/core/include/opencv2/core/cv_cpu_helper.h")
set(__file "${OpenCV_SOURCE_DIR}/modules/core/include/opencv2/core/cv_cpu_helper.h")
if(EXISTS "${__file}")
file(READ "${__file}" __content)
endif()
@@ -752,24 +761,24 @@ macro(ocv_compiler_optimization_fill_cpu_config)
endif()
endmacro()
macro(ocv_add_dispatched_file filename)
macro(__ocv_add_dispatched_file filename target_src_var src_directory dst_directory precomp_hpp optimizations_var)
if(NOT OPENCV_INITIAL_PASS)
set(__codestr "
#include \"${CMAKE_CURRENT_LIST_DIR}/src/precomp.hpp\"
#include \"${CMAKE_CURRENT_LIST_DIR}/src/${filename}.simd.hpp\"
#include \"${src_directory}/${precomp_hpp}\"
#include \"${src_directory}/${filename}.simd.hpp\"
")
set(__declarations_str "#define CV_CPU_SIMD_FILENAME \"${CMAKE_CURRENT_LIST_DIR}/src/${filename}.simd.hpp\"")
set(__declarations_str "#define CV_CPU_SIMD_FILENAME \"${src_directory}/${filename}.simd.hpp\"")
set(__dispatch_modes "BASELINE")
set(__optimizations "${ARGN}")
set(__optimizations "${${optimizations_var}}")
if(CV_DISABLE_OPTIMIZATION OR NOT CV_ENABLE_INTRINSICS)
set(__optimizations "")
endif()
foreach(OPT ${__optimizations})
string(TOLOWER "${OPT}" OPT_LOWER)
set(__file "${CMAKE_CURRENT_BINARY_DIR}/${filename}.${OPT_LOWER}.cpp")
set(__file "${CMAKE_CURRENT_BINARY_DIR}/${dst_directory}${filename}.${OPT_LOWER}.cpp")
if(EXISTS "${__file}")
file(READ "${__file}" __content)
else()
@@ -782,7 +791,11 @@ macro(ocv_add_dispatched_file filename)
endif()
if(";${CPU_DISPATCH};" MATCHES "${OPT}" OR __CPU_DISPATCH_INCLUDE_ALL)
list(APPEND OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED "${__file}")
if(EXISTS "${src_directory}/${filename}.${OPT_LOWER}.cpp")
message(STATUS "Using overrided ${OPT} source: ${src_directory}/${filename}.${OPT_LOWER}.cpp")
else()
list(APPEND ${target_src_var} "${__file}")
endif()
endif()
set(__declarations_str "${__declarations_str}
@@ -794,9 +807,11 @@ macro(ocv_add_dispatched_file filename)
set(__declarations_str "${__declarations_str}
#define CV_CPU_DISPATCH_MODES_ALL ${__dispatch_modes}
#undef CV_CPU_SIMD_FILENAME
")
set(__file "${CMAKE_CURRENT_BINARY_DIR}/${filename}.simd_declarations.hpp")
set(__file "${CMAKE_CURRENT_BINARY_DIR}/${dst_directory}${filename}.simd_declarations.hpp")
if(EXISTS "${__file}")
file(READ "${__file}" __content)
endif()
@@ -808,6 +823,17 @@ macro(ocv_add_dispatched_file filename)
endif()
endmacro()
macro(ocv_add_dispatched_file filename)
set(__optimizations "${ARGN}")
if(" ${ARGV1}" STREQUAL " TEST")
list(REMOVE_AT __optimizations 0)
__ocv_add_dispatched_file("${filename}" "OPENCV_MODULE_${the_module}_TEST_SOURCES_DISPATCHED" "${CMAKE_CURRENT_LIST_DIR}/test" "test/" "test_precomp.hpp" __optimizations)
else()
__ocv_add_dispatched_file("${filename}" "OPENCV_MODULE_${the_module}_SOURCES_DISPATCHED" "${CMAKE_CURRENT_LIST_DIR}/src" "" "precomp.hpp" __optimizations)
endif()
endmacro()
# Workaround to support code which always require all code paths
macro(ocv_add_dispatched_file_force_all)
set(__CPU_DISPATCH_INCLUDE_ALL 1)
+23 -7
View File
@@ -3,19 +3,28 @@ if(WIN32 AND NOT MSVC)
return()
endif()
if(NOT APPLE AND CV_CLANG)
if(NOT UNIX AND CV_CLANG)
message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
return()
endif()
set(CMAKE_MODULE_PATH "${OpenCV_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
if(ANDROID)
set(CUDA_TARGET_OS_VARIANT "Android")
if(((NOT CMAKE_VERSION VERSION_LESS "3.9.0") # requires https://gitlab.kitware.com/cmake/cmake/merge_requests/663
OR OPENCV_CUDA_FORCE_EXTERNAL_CMAKE_MODULE)
AND NOT OPENCV_CUDA_FORCE_BUILTIN_CMAKE_MODULE)
ocv_update(CUDA_LINK_LIBRARIES_KEYWORD "LINK_PRIVATE")
find_host_package(CUDA "${MIN_VER_CUDA}" QUIET)
else()
# Use OpenCV's patched "FindCUDA" module
set(CMAKE_MODULE_PATH "${OpenCV_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH})
if(ANDROID)
set(CUDA_TARGET_OS_VARIANT "Android")
endif()
find_host_package(CUDA "${MIN_VER_CUDA}" QUIET)
list(REMOVE_AT CMAKE_MODULE_PATH 0)
endif()
find_host_package(CUDA "${MIN_VER_CUDA}" QUIET)
list(REMOVE_AT CMAKE_MODULE_PATH 0)
if(CUDA_FOUND)
set(HAVE_CUDA 1)
@@ -179,6 +188,13 @@ if(CUDA_FOUND)
foreach(var CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
set(${var}_backup_in_cuda_compile_ "${${var}}")
if (CV_CLANG)
# we remove -Winconsistent-missing-override and -Qunused-arguments
# just in case we are compiling CUDA with gcc but OpenCV with clang
string(REPLACE "-Winconsistent-missing-override" "" ${var} "${${var}}")
string(REPLACE "-Qunused-arguments" "" ${var} "${${var}}")
endif()
# we remove /EHa as it generates warnings under windows
string(REPLACE "/EHa" "" ${var} "${${var}}")
+70 -54
View File
@@ -1,71 +1,87 @@
# The script detects Intel(R) Inference Engine installation
#
# Parameters:
# INTEL_CVSDK_DIR - Path to Inference Engine root folder
# IE_PLUGINS_PATH - Path to folder with Inference Engine plugins
# Cache variables:
# INF_ENGINE_OMP_DIR - directory with OpenMP library to link with (needed by some versions of IE)
# INF_ENGINE_RELEASE - a number reflecting IE source interface (linked with OpenVINO release)
#
# On return this will define:
# Detect parameters:
# 1. Native cmake IE package:
# - enironment variable InferenceEngine_DIR is set to location of cmake module
# 2. Custom location:
# - INF_ENGINE_INCLUDE_DIRS - headers search location
# - INF_ENGINE_LIB_DIRS - library search location
# 3. OpenVINO location:
# - environment variable INTEL_CVSDK_DIR is set to location of OpenVINO installation dir
# - INF_ENGINE_PLATFORM - part of name of library directory representing its platform (default ubuntu_16.04)
#
# HAVE_INF_ENGINE - True if Intel Inference Engine was found
# INF_ENGINE_INCLUDE_DIRS - Inference Engine include folder
# INF_ENGINE_LIBRARIES - Inference Engine libraries and it's dependencies
# Result:
# INF_ENGINE_TARGET - set to name of imported library target representing InferenceEngine
#
macro(ie_fail)
set(HAVE_INF_ENGINE FALSE)
return()
endmacro()
if(NOT HAVE_CXX11)
ie_fail()
message(WARNING "DL Inference engine requires C++11. You can turn it on via ENABLE_CXX11=ON CMake flag.")
return()
endif()
if(NOT INF_ENGINE_ROOT_DIR OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}/include/inference_engine.hpp")
set(ie_root_paths "${INF_ENGINE_ROOT_DIR}")
if(DEFINED ENV{INTEL_CVSDK_DIR})
list(APPEND ie_root_paths "$ENV{INTEL_CVSDK_DIR}")
list(APPEND ie_root_paths "$ENV{INTEL_CVSDK_DIR}/inference_engine")
endif()
if(DEFINED INTEL_CVSDK_DIR)
list(APPEND ie_root_paths "${INTEL_CVSDK_DIR}")
list(APPEND ie_root_paths "${INTEL_CVSDK_DIR}/inference_engine")
endif()
# =======================
if(NOT ie_root_paths)
list(APPEND ie_root_paths "/opt/intel/deeplearning_deploymenttoolkit/deployment_tools/inference_engine")
endif()
function(add_custom_ie_build _inc _lib _lib_rel _lib_dbg _msg)
if(NOT _inc OR NOT (_lib OR _lib_rel OR _lib_dbg))
return()
endif()
add_library(inference_engine UNKNOWN IMPORTED)
set_target_properties(inference_engine PROPERTIES
IMPORTED_LOCATION "${_lib}"
IMPORTED_IMPLIB_RELEASE "${_lib_rel}"
IMPORTED_IMPLIB_DEBUG "${_lib_dbg}"
INTERFACE_INCLUDE_DIRECTORIES "${_inc}"
)
find_library(omp_lib iomp5 PATHS "${INF_ENGINE_OMP_DIR}" NO_DEFAULT_PATH)
if(NOT omp_lib)
message(WARNING "OpenMP for IE have not been found. Set INF_ENGINE_OMP_DIR variable if you experience build errors.")
else()
set_target_properties(inference_engine PROPERTIES IMPORTED_LINK_INTERFACE_LIBRARIES "${omp_lib}")
endif()
set(INF_ENGINE_VERSION "Unknown" CACHE STRING "")
set(INF_ENGINE_TARGET inference_engine PARENT_SCOPE)
message(STATUS "Detected InferenceEngine: ${_msg}")
endfunction()
find_path(INF_ENGINE_ROOT_DIR include/inference_engine.hpp PATHS ${ie_root_paths})
# ======================
find_package(InferenceEngine QUIET)
if(InferenceEngine_FOUND)
set(INF_ENGINE_TARGET IE::inference_engine)
set(INF_ENGINE_VERSION "${InferenceEngine_VERSION}" CACHE STRING "")
message(STATUS "Detected InferenceEngine: cmake package")
endif()
set(INF_ENGINE_INCLUDE_DIRS "${INF_ENGINE_ROOT_DIR}/include" CACHE PATH "Path to Inference Engine include directory")
if(NOT INF_ENGINE_ROOT_DIR
OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}"
OR NOT EXISTS "${INF_ENGINE_ROOT_DIR}/include/inference_engine.hpp"
)
ie_fail()
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)
find_library(ie_custom_lib "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}" NO_DEFAULT_PATH)
find_library(ie_custom_lib_rel "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Release" NO_DEFAULT_PATH)
find_library(ie_custom_lib_dbg "inference_engine" PATHS "${INF_ENGINE_LIB_DIRS}/Debug" NO_DEFAULT_PATH)
add_custom_ie_build("${ie_custom_inc}" "${ie_custom_lib}" "${ie_custom_lib_rel}" "${ie_custom_lib_dbg}" "INF_ENGINE_{INCLUDE,LIB}_DIRS")
endif()
set(INF_ENGINE_LIBRARIES "")
set(_loc "$ENV{INTEL_CVSDK_DIR}")
if(NOT INF_ENGINE_TARGET AND _loc)
set(INF_ENGINE_PLATFORM "ubuntu_16.04" CACHE STRING "InferenceEngine platform (library dir)")
find_path(ie_custom_env_inc "inference_engine.hpp" PATHS "${_loc}/deployment_tools/inference_engine/include" NO_DEFAULT_PATH)
find_library(ie_custom_env_lib "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/${INF_ENGINE_PLATFORM}/intel64" NO_DEFAULT_PATH)
find_library(ie_custom_env_lib_rel "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Release" NO_DEFAULT_PATH)
find_library(ie_custom_env_lib_dbg "inference_engine" PATHS "${_loc}/deployment_tools/inference_engine/lib/intel64/Debug" NO_DEFAULT_PATH)
add_custom_ie_build("${ie_custom_env_inc}" "${ie_custom_env_lib}" "${ie_custom_env_lib_rel}" "${ie_custom_env_lib_dbg}" "OpenVINO (${_loc})")
endif()
set(ie_lib_list inference_engine)
# Add more features to the target
link_directories(
${INTEL_CVSDK_DIR}/inference_engine/external/mkltiny_lnx/lib
${INTEL_CVSDK_DIR}/inference_engine/external/cldnn/lib
)
foreach(lib ${ie_lib_list})
find_library(${lib}
NAMES ${lib}
# For inference_engine
HINTS ${IE_PLUGINS_PATH}
HINTS "$ENV{IE_PLUGINS_PATH}"
)
if(NOT ${lib})
ie_fail()
endif()
list(APPEND INF_ENGINE_LIBRARIES ${${lib}})
endforeach()
set(HAVE_INF_ENGINE TRUE)
if(INF_ENGINE_TARGET)
if(NOT INF_ENGINE_RELEASE)
message(WARNING "InferenceEngine version have not been set, 2018R3 will be used by default. Set INF_ENGINE_RELEASE variable if you experience build errors.")
endif()
set(INF_ENGINE_RELEASE "2018030000" CACHE STRING "Force IE version, should be in form YYYYAABBCC (e.g. 2018R2.0.2 -> 2018020002)")
set_target_properties(${INF_ENGINE_TARGET} PROPERTIES
INTERFACE_COMPILE_DEFINITIONS "HAVE_INF_ENGINE=1;INF_ENGINE_RELEASE=${INF_ENGINE_RELEASE}"
)
endif()
+10 -4
View File
@@ -20,16 +20,19 @@ if(DEFINED ENV{OPENCV_DOWNLOAD_PATH})
endif()
set(OPENCV_DOWNLOAD_PATH "${OpenCV_SOURCE_DIR}/.cache" CACHE PATH "${HELP_OPENCV_DOWNLOAD_PATH}")
set(OPENCV_DOWNLOAD_LOG "${OpenCV_BINARY_DIR}/CMakeDownloadLog.txt")
set(OPENCV_DOWNLOAD_WITH_CURL "${OpenCV_BINARY_DIR}/download_with_curl.sh")
set(OPENCV_DOWNLOAD_WITH_WGET "${OpenCV_BINARY_DIR}/download_with_wget.sh")
# Init download cache directory and log file
# Init download cache directory and log file and helper scripts
if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}")
file(MAKE_DIRECTORY ${OPENCV_DOWNLOAD_PATH})
endif()
if(NOT EXISTS "${OPENCV_DOWNLOAD_PATH}/.gitignore")
file(WRITE "${OPENCV_DOWNLOAD_PATH}/.gitignore" "*\n")
endif()
file(WRITE "${OPENCV_DOWNLOAD_LOG}" "use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
file(WRITE "${OPENCV_DOWNLOAD_LOG}" "#use_cache \"${OPENCV_DOWNLOAD_PATH}\"\n")
file(REMOVE "${OPENCV_DOWNLOAD_WITH_CURL}")
file(REMOVE "${OPENCV_DOWNLOAD_WITH_WGET}")
function(ocv_download)
cmake_parse_arguments(DL "UNPACK;RELATIVE_URL" "FILENAME;HASH;DESTINATION_DIR;ID;STATUS" "URL" ${ARGN})
@@ -103,7 +106,7 @@ function(ocv_download)
endif()
# Log all calls to file
ocv_download_log("do_${mode} \"${DL_FILENAME}\" \"${DL_HASH}\" \"${DL_URL}\" \"${DL_DESTINATION_DIR}\"")
ocv_download_log("#do_${mode} \"${DL_FILENAME}\" \"${DL_HASH}\" \"${DL_URL}\" \"${DL_DESTINATION_DIR}\"")
# ... and to console
set(__msg_prefix "")
if(DL_ID)
@@ -191,6 +194,9 @@ function(ocv_download)
For details please refer to the download log file:
${OPENCV_DOWNLOAD_LOG}
")
# write helper scripts for failed downloads
file(APPEND "${OPENCV_DOWNLOAD_WITH_CURL}" "curl --output \"${CACHE_CANDIDATE}\" \"${DL_URL}\"\n")
file(APPEND "${OPENCV_DOWNLOAD_WITH_WGET}" "wget -O \"${CACHE_CANDIDATE}\" \"${DL_URL}\"\n")
return()
endif()
+3 -1
View File
@@ -12,7 +12,9 @@ endif()
if(VA_INCLUDE_DIR)
set(HAVE_VA TRUE)
set(VA_LIBRARIES "-lva" "-lva-drm")
if(NOT DEFINED VA_LIBRARIES)
set(VA_LIBRARIES "va" "va-drm")
endif()
else()
set(HAVE_VA FALSE)
message(WARNING "libva installation is not found.")
+9 -3
View File
@@ -1132,7 +1132,7 @@ function(ocv_add_perf_tests)
source_group("Src" FILES "${${the_target}_pch}")
ocv_add_executable(${the_target} ${OPENCV_PERF_${the_module}_SOURCES} ${${the_target}_pch})
ocv_target_include_modules(${the_target} ${perf_deps} "${perf_path}")
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${perf_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} ${OPENCV_PERF_${the_module}_DEPS})
add_dependencies(opencv_perf_tests ${the_target})
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};PerfTest")
@@ -1175,7 +1175,7 @@ function(ocv_add_perf_tests)
endfunction()
# this is a command for adding OpenCV accuracy/regression tests to the module
# ocv_add_accuracy_tests([FILES <source group name> <list of sources>] [DEPENDS_ON] <list of extra dependencies>)
# ocv_add_accuracy_tests(<list of extra dependencies>)
function(ocv_add_accuracy_tests)
ocv_debug_message("ocv_add_accuracy_tests(" ${ARGN} ")")
@@ -1202,6 +1202,9 @@ function(ocv_add_accuracy_tests)
set(OPENCV_TEST_${the_module}_SOURCES ${test_srcs} ${test_hdrs})
endif()
if(OPENCV_MODULE_${the_module}_TEST_SOURCES_DISPATCHED)
list(APPEND OPENCV_TEST_${the_module}_SOURCES ${OPENCV_MODULE_${the_module}_TEST_SOURCES_DISPATCHED})
endif()
ocv_compiler_optimization_process_sources(OPENCV_TEST_${the_module}_SOURCES OPENCV_TEST_${the_module}_DEPS ${the_target})
if(NOT BUILD_opencv_world)
@@ -1211,7 +1214,10 @@ function(ocv_add_accuracy_tests)
source_group("Src" FILES "${${the_target}_pch}")
ocv_add_executable(${the_target} ${OPENCV_TEST_${the_module}_SOURCES} ${${the_target}_pch})
ocv_target_include_modules(${the_target} ${test_deps} "${test_path}")
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${test_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS})
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/test")
ocv_target_include_directories(${the_target} "${CMAKE_CURRENT_BINARY_DIR}/test")
endif()
ocv_target_link_libraries(${the_target} LINK_PRIVATE ${test_deps} ${OPENCV_MODULE_${the_module}_DEPS} ${OPENCV_LINKER_LIBS} ${OPENCV_TEST_${the_module}_DEPS})
add_dependencies(opencv_tests ${the_target})
set_target_properties(${the_target} PROPERTIES LABELS "${OPENCV_MODULE_${the_module}_LABEL};AccuracyTest")
+1 -1
View File
@@ -362,7 +362,7 @@ MACRO(ADD_NATIVE_PRECOMPILED_HEADER _targetName _input)
endif()
endforeach()
#also inlude ${oldProps} to have the same compile options
#also include ${oldProps} to have the same compile options
GET_TARGET_PROPERTY(oldProps ${_targetName} COMPILE_FLAGS)
if (oldProps MATCHES NOTFOUND)
SET(oldProps "")
+1 -1
View File
@@ -260,7 +260,7 @@ endif()
set(OpenCV_LIBRARIES ${OpenCV_LIBS})
#
# Some macroses for samples
# Some macros for samples
#
macro(ocv_check_dependencies)
set(OCV_DEPENDENCIES_FOUND TRUE)
@@ -29,7 +29,7 @@ What happens in background ?
objects). Everything inside rectangle is unknown. Similarly any user input specifying
foreground and background are considered as hard-labelling which means they won't change in
the process.
- Computer does an initial labelling depeding on the data we gave. It labels the foreground and
- Computer does an initial labelling depending on the data we gave. It labels the foreground and
background pixels (or it hard-labels)
- Now a Gaussian Mixture Model(GMM) is used to model the foreground and background.
- Depending on the data we gave, GMM learns and create new pixel distribution. That is, the
@@ -129,7 +129,7 @@ function onOpenCvReady() {
</html>
@endcode
@note You have to call delete method of cv.Mat to free memory allocated in Emscripten's heap. Please refer to [Memeory management of Emscripten](https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html#memory-management) for details.
@note You have to call delete method of cv.Mat to free memory allocated in Emscripten's heap. Please refer to [Memory management of Emscripten](https://kripken.github.io/emscripten-site/docs/porting/connecting_cpp_and_javascript/embind.html#memory-management) for details.
Try it
------
+14
View File
@@ -1016,3 +1016,17 @@
year = {2017},
organization = {IEEE}
}
@ARTICLE{gonzalez,
title={Digital Image Fundamentals, Digital Imaging Processing},
author={Gonzalez, Rafael C and others},
year={1987},
publisher={Addison Wesley Publishing Company}
}
@ARTICLE{gruzman,
title={Цифровая обработка изображений в информационных системах},
author={Грузман, И.С. and Киричук, В.С. and Косых, В.П. and Перетягин, Г.И. and Спектор, А.А.},
year={2000},
publisher={Изд-во НГТУ Новосибирск}
}
@@ -37,7 +37,7 @@ So what happens in background ?
objects). Everything inside rectangle is unknown. Similarly any user input specifying
foreground and background are considered as hard-labelling which means they won't change in
the process.
- Computer does an initial labelling depeding on the data we gave. It labels the foreground and
- Computer does an initial labelling depending on the data we gave. It labels the foreground and
background pixels (or it hard-labels)
- Now a Gaussian Mixture Model(GMM) is used to model the foreground and background.
- Depending on the data we gave, GMM learns and create new pixel distribution. That is, the
@@ -16,7 +16,7 @@ In this tutorial is explained how to build a real time application to estimate t
order to track a textured object with six degrees of freedom given a 2D image and its 3D textured
model.
The application will have the followings parts:
The application will have the following parts:
- Read 3D textured object model and object mesh.
- Take input from Camera or Video.
@@ -426,16 +426,16 @@ Here is explained in detail the code for the real time application:
@endcode
OpenCV provides four PnP methods: ITERATIVE, EPNP, P3P and DLS. Depending on the application type,
the estimation method will be different. In the case that we want to make a real time application,
the more suitable methods are EPNP and P3P due to that are faster than ITERATIVE and DLS at
the more suitable methods are EPNP and P3P since they are faster than ITERATIVE and DLS at
finding an optimal solution. However, EPNP and P3P are not especially robust in front of planar
surfaces and sometimes the pose estimation seems to have a mirror effect. Therefore, in this this
tutorial is used ITERATIVE method due to the object to be detected has planar surfaces.
surfaces and sometimes the pose estimation seems to have a mirror effect. Therefore, in this
tutorial an ITERATIVE method is used due to the object to be detected has planar surfaces.
The OpenCV RANSAC implementation wants you to provide three parameters: the maximum number of
iterations until stop the algorithm, the maximum allowed distance between the observed and
computed point projections to consider it an inlier and the confidence to obtain a good result.
The OpenCV RANSAC implementation wants you to provide three parameters: 1) the maximum number of
iterations until the algorithm stops, 2) the maximum allowed distance between the observed and
computed point projections to consider it an inlier and 3) the confidence to obtain a good result.
You can tune these parameters in order to improve your algorithm performance. Increasing the
number of iterations you will have a more accurate solution, but will take more time to find a
number of iterations will have a more accurate solution, but will take more time to find a
solution. Increasing the reprojection error will reduce the computation time, but your solution
will be unaccurate. Decreasing the confidence your algorithm will be faster, but the obtained
solution will be unaccurate.
@@ -1,6 +1,9 @@
Changing the contrast and brightness of an image! {#tutorial_basic_linear_transform}
=================================================
@prev_tutorial{tutorial_adding_images}
@next_tutorial{tutorial_discrete_fourier_transform}
Goal
----
@@ -53,48 +56,143 @@ Theory
Code
----
@add_toggle_cpp
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp)
- The following code performs the operation \f$g(i,j) = \alpha \cdot f(i,j) + \beta\f$ :
@include BasicLinearTransforms.cpp
@include samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp
@end_toggle
@add_toggle_java
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java)
- The following code performs the operation \f$g(i,j) = \alpha \cdot f(i,j) + \beta\f$ :
@include samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java
@end_toggle
@add_toggle_python
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py)
- The following code performs the operation \f$g(i,j) = \alpha \cdot f(i,j) + \beta\f$ :
@include samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py
@end_toggle
Explanation
-----------
-# We begin by creating parameters to save \f$\alpha\f$ and \f$\beta\f$ to be entered by the user:
@snippet BasicLinearTransforms.cpp basic-linear-transform-parameters
- We load an image using @ref cv::imread and save it in a Mat object:
-# We load an image using @ref cv::imread and save it in a Mat object:
@snippet BasicLinearTransforms.cpp basic-linear-transform-load
-# Now, since we will make some transformations to this image, we need a new Mat object to store
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp basic-linear-transform-load
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java basic-linear-transform-load
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py basic-linear-transform-load
@end_toggle
- Now, since we will make some transformations to this image, we need a new Mat object to store
it. Also, we want this to have the following features:
- Initial pixel values equal to zero
- Same size and type as the original image
@snippet BasicLinearTransforms.cpp basic-linear-transform-output
We observe that @ref cv::Mat::zeros returns a Matlab-style zero initializer based on
*image.size()* and *image.type()*
-# Now, to perform the operation \f$g(i,j) = \alpha \cdot f(i,j) + \beta\f$ we will access to each
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp basic-linear-transform-output
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java basic-linear-transform-output
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py basic-linear-transform-output
@end_toggle
We observe that @ref cv::Mat::zeros returns a Matlab-style zero initializer based on
*image.size()* and *image.type()*
- We ask now the values of \f$\alpha\f$ and \f$\beta\f$ to be entered by the user:
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp basic-linear-transform-parameters
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java basic-linear-transform-parameters
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py basic-linear-transform-parameters
@end_toggle
- Now, to perform the operation \f$g(i,j) = \alpha \cdot f(i,j) + \beta\f$ we will access to each
pixel in image. Since we are operating with BGR images, we will have three values per pixel (B,
G and R), so we will also access them separately. Here is the piece of code:
@snippet BasicLinearTransforms.cpp basic-linear-transform-operation
Notice the following:
- To access each pixel in the images we are using this syntax: *image.at\<Vec3b\>(y,x)[c]*
where *y* is the row, *x* is the column and *c* is R, G or B (0, 1 or 2).
- Since the operation \f$\alpha \cdot p(i,j) + \beta\f$ can give values out of range or not
integers (if \f$\alpha\f$ is float), we use cv::saturate_cast to make sure the
values are valid.
-# Finally, we create windows and show the images, the usual way.
@snippet BasicLinearTransforms.cpp basic-linear-transform-display
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp basic-linear-transform-operation
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java basic-linear-transform-operation
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py basic-linear-transform-operation
@end_toggle
Notice the following (**C++ code only**):
- To access each pixel in the images we are using this syntax: *image.at\<Vec3b\>(y,x)[c]*
where *y* is the row, *x* is the column and *c* is R, G or B (0, 1 or 2).
- Since the operation \f$\alpha \cdot p(i,j) + \beta\f$ can give values out of range or not
integers (if \f$\alpha\f$ is float), we use cv::saturate_cast to make sure the
values are valid.
- Finally, we create windows and show the images, the usual way.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ImgProc/BasicLinearTransforms.cpp basic-linear-transform-display
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/BasicLinearTransformsDemo.java basic-linear-transform-display
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/BasicLinearTransforms.py basic-linear-transform-display
@end_toggle
@note
Instead of using the **for** loops to access each pixel, we could have simply used this command:
@code{.cpp}
image.convertTo(new_image, -1, alpha, beta);
@endcode
where @ref cv::Mat::convertTo would effectively perform *new_image = a*image + beta\*. However, we
wanted to show you how to access each pixel. In any case, both methods give the same result but
convertTo is more optimized and works a lot faster.
@add_toggle_cpp
@code{.cpp}
image.convertTo(new_image, -1, alpha, beta);
@endcode
@end_toggle
@add_toggle_java
@code{.java}
image.convertTo(newImage, -1, alpha, beta);
@endcode
@end_toggle
@add_toggle_python
@code{.py}
new_image = cv.convertScaleAbs(image, alpha=alpha, beta=beta)
@endcode
@end_toggle
where @ref cv::Mat::convertTo would effectively perform *new_image = a*image + beta\*. However, we
wanted to show you how to access each pixel. In any case, both methods give the same result but
convertTo is more optimized and works a lot faster.
Result
------
@@ -185,10 +283,31 @@ and are not intended to be used as a replacement of a raster graphics editor!**
### Code
@add_toggle_cpp
Code for the tutorial is [here](https://github.com/opencv/opencv/blob/3.4/samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp).
@end_toggle
@add_toggle_java
Code for the tutorial is [here](https://github.com/opencv/opencv/blob/3.4/samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/ChangingContrastBrightnessImageDemo.java).
@end_toggle
@add_toggle_python
Code for the tutorial is [here](https://github.com/opencv/opencv/blob/3.4/samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.py).
@end_toggle
Code for the gamma correction:
@snippet changing_contrast_brightness_image.cpp changing-contrast-brightness-gamma-correction
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ImgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.cpp changing-contrast-brightness-gamma-correction
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ImgProc/changing_contrast_brightness_image/ChangingContrastBrightnessImageDemo.java changing-contrast-brightness-gamma-correction
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/imgProc/changing_contrast_brightness_image/changing_contrast_brightness_image.py changing-contrast-brightness-gamma-correction
@end_toggle
A look-up table is used to improve the performance of the computation as only 256 values needs to be calculated once.
@@ -1,7 +1,7 @@
Discrete Fourier Transform {#tutorial_discrete_fourier_transform}
==========================
@prev_tutorial{tutorial_random_generator_and_text}
@prev_tutorial{tutorial_basic_linear_transform}
@next_tutorial{tutorial_file_input_output_with_xml_yml}
Goal
@@ -1,6 +1,9 @@
File Input and Output using XML and YAML files {#tutorial_file_input_output_with_xml_yml}
==============================================
@prev_tutorial{tutorial_discrete_fourier_transform}
@next_tutorial{tutorial_interoperability_with_OpenCV_1}
Goal
----
@@ -1,6 +1,9 @@
How to scan images, lookup tables and time measurement with OpenCV {#tutorial_how_to_scan_images}
==================================================================
@prev_tutorial{tutorial_mat_the_basic_image_container}
@next_tutorial{tutorial_mat_mask_operations}
Goal
----
@@ -1,6 +1,8 @@
How to use the OpenCV parallel_for_ to parallelize your code {#tutorial_how_to_use_OpenCV_parallel_for_}
==================================================================
@prev_tutorial{tutorial_how_to_use_ippa_conversion}
Goal
----
@@ -1,6 +1,9 @@
Intel® IPP Asynchronous C/C++ library in OpenCV {#tutorial_how_to_use_ippa_conversion}
===============================================
@prev_tutorial{tutorial_interoperability_with_OpenCV_1}
@next_tutorial{tutorial_how_to_use_OpenCV_parallel_for_}
Goal
----
@@ -1,6 +1,9 @@
Interoperability with OpenCV 1 {#tutorial_interoperability_with_OpenCV_1}
==============================
@prev_tutorial{tutorial_file_input_output_with_xml_yml}
@next_tutorial{tutorial_how_to_use_ippa_conversion}
Goal
----
+202 -108
View File
@@ -1,31 +1,59 @@
Operations with images {#tutorial_mat_operations}
======================
@prev_tutorial{tutorial_mat_mask_operations}
@next_tutorial{tutorial_adding_images}
Input/Output
------------
### Images
Load an image from a file:
@code{.cpp}
Mat img = imread(filename)
@endcode
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Load an image from a file
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Load an image from a file
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Load an image from a file
@end_toggle
If you read a jpg file, a 3 channel image is created by default. If you need a grayscale image, use:
@code{.cpp}
Mat img = imread(filename, IMREAD_GRAYSCALE);
@endcode
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Load an image from a file in grayscale
@end_toggle
@note format of the file is determined by its content (first few bytes) Save an image to a file:
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Load an image from a file in grayscale
@end_toggle
@code{.cpp}
imwrite(filename, img);
@endcode
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Load an image from a file in grayscale
@end_toggle
@note format of the file is determined by its extension.
@note Format of the file is determined by its content (first few bytes). To save an image to a file:
@note use imdecode and imencode to read and write image from/to memory rather than a file.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Save image
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Save image
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Save image
@end_toggle
@note Format of the file is determined by its extension.
@note Use cv::imdecode and cv::imencode to read and write an image from/to memory rather than a file.
Basic operations with images
----------------------------
@@ -35,49 +63,65 @@ Basic operations with images
In order to get pixel intensity value, you have to know the type of an image and the number of
channels. Here is an example for a single channel grey scale image (type 8UC1) and pixel coordinates
x and y:
@code{.cpp}
Scalar intensity = img.at<uchar>(y, x);
@endcode
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Pixel access 1
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Pixel access 1
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Pixel access 1
@end_toggle
C++ version only:
intensity.val[0] contains a value from 0 to 255. Note the ordering of x and y. Since in OpenCV
images are represented by the same structure as matrices, we use the same convention for both
cases - the 0-based row index (or y-coordinate) goes first and the 0-based column index (or
x-coordinate) follows it. Alternatively, you can use the following notation:
@code{.cpp}
Scalar intensity = img.at<uchar>(Point(x, y));
@endcode
x-coordinate) follows it. Alternatively, you can use the following notation (**C++ only**):
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Pixel access 2
Now let us consider a 3 channel image with BGR color ordering (the default format returned by
imread):
@code{.cpp}
Vec3b intensity = img.at<Vec3b>(y, x);
uchar blue = intensity.val[0];
uchar green = intensity.val[1];
uchar red = intensity.val[2];
@endcode
**C++ code**
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Pixel access 3
**Python Python**
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Pixel access 3
You can use the same method for floating-point images (for example, you can get such an image by
running Sobel on a 3 channel image):
@code{.cpp}
Vec3f intensity = img.at<Vec3f>(y, x);
float blue = intensity.val[0];
float green = intensity.val[1];
float red = intensity.val[2];
@endcode
running Sobel on a 3 channel image) (**C++ only**):
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Pixel access 4
The same method can be used to change pixel intensities:
@code{.cpp}
img.at<uchar>(y, x) = 128;
@endcode
There are functions in OpenCV, especially from calib3d module, such as projectPoints, that take an
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Pixel access 5
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Pixel access 5
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Pixel access 5
@end_toggle
There are functions in OpenCV, especially from calib3d module, such as cv::projectPoints, that take an
array of 2D or 3D points in the form of Mat. Matrix should contain exactly one column, each row
corresponds to a point, matrix type should be 32FC2 or 32FC3 correspondingly. Such a matrix can be
easily constructed from `std::vector`:
@code{.cpp}
vector<Point2f> points;
//... fill the array
Mat pointsMat = Mat(points);
@endcode
One can access a point in this matrix using the same method Mat::at :
@code{.cpp}
Point2f point = pointsMat.at<Point2f>(i, 0);
@endcode
easily constructed from `std::vector` (**C++ only**):
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Mat from points vector
One can access a point in this matrix using the same method `Mat::at` (**C++ only**):
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Point access
### Memory management and reference counting
@@ -85,91 +129,141 @@ Mat is a structure that keeps matrix/image characteristics (rows and columns num
and a pointer to data. So nothing prevents us from having several instances of Mat corresponding to
the same data. A Mat keeps a reference count that tells if data has to be deallocated when a
particular instance of Mat is destroyed. Here is an example of creating two matrices without copying
data:
@code{.cpp}
std::vector<Point3f> points;
// .. fill the array
Mat pointsMat = Mat(points).reshape(1);
@endcode
As a result we get a 32FC1 matrix with 3 columns instead of 32FC3 matrix with 1 column. pointsMat
data (**C++ only**):
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Reference counting 1
As a result, we get a 32FC1 matrix with 3 columns instead of 32FC3 matrix with 1 column. `pointsMat`
uses data from points and will not deallocate the memory when destroyed. In this particular
instance, however, developer has to make sure that lifetime of points is longer than of pointsMat.
instance, however, developer has to make sure that lifetime of `points` is longer than of `pointsMat`
If we need to copy the data, this is done using, for example, cv::Mat::copyTo or cv::Mat::clone:
@code{.cpp}
Mat img = imread("image.jpg");
Mat img1 = img.clone();
@endcode
To the contrary with C API where an output image had to be created by developer, an empty output Mat
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Reference counting 2
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Reference counting 2
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Reference counting 2
@end_toggle
To the contrary with C API where an output image had to be created by the developer, an empty output Mat
can be supplied to each function. Each implementation calls Mat::create for a destination matrix.
This method allocates data for a matrix if it is empty. If it is not empty and has the correct size
and type, the method does nothing. If, however, size or type are different from input arguments, the
and type, the method does nothing. If however, size or type are different from the input arguments, the
data is deallocated (and lost) and a new data is allocated. For example:
@code{.cpp}
Mat img = imread("image.jpg");
Mat sobelx;
Sobel(img, sobelx, CV_32F, 1, 0);
@endcode
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Reference counting 3
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Reference counting 3
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Reference counting 3
@end_toggle
### Primitive operations
There is a number of convenient operators defined on a matrix. For example, here is how we can make
a black image from an existing greyscale image \`img\`:
@code{.cpp}
img = Scalar(0);
@endcode
a black image from an existing greyscale image `img`
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Set image to black
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Set image to black
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Set image to black
@end_toggle
Selecting a region of interest:
@code{.cpp}
Rect r(10, 10, 100, 100);
Mat smallImg = img(r);
@endcode
A conversion from Mat to C API data structures:
@code{.cpp}
Mat img = imread("image.jpg");
IplImage img1 = img;
CvMat m = img;
@endcode
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Select ROI
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Select ROI
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Select ROI
@end_toggle
A conversion from Mat to C API data structures (**C++ only**):
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp C-API conversion
Note that there is no data copying here.
Conversion from color to grey scale:
@code{.cpp}
Mat img = imread("image.jpg"); // loading a 8UC3 image
Mat grey;
cvtColor(img, grey, COLOR_BGR2GRAY);
@endcode
Conversion from color to greyscale:
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp BGR to Gray
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java BGR to Gray
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py BGR to Gray
@end_toggle
Change image type from 8UC1 to 32FC1:
@code{.cpp}
src.convertTo(dst, CV_32F);
@endcode
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp Convert to CV_32F
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java Convert to CV_32F
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py Convert to CV_32F
@end_toggle
### Visualizing images
It is very useful to see intermediate results of your algorithm during development process. OpenCV
provides a convenient way of visualizing images. A 8U image can be shown using:
@code{.cpp}
Mat img = imread("image.jpg");
namedWindow("image", WINDOW_AUTOSIZE);
imshow("image", img);
waitKey();
@endcode
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp imshow 1
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java imshow 1
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py imshow 1
@end_toggle
A call to waitKey() starts a message passing cycle that waits for a key stroke in the "image"
window. A 32F image needs to be converted to 8U type. For example:
@code{.cpp}
Mat img = imread("image.jpg");
Mat grey;
cvtColor(img, grey, COLOR_BGR2GRAY);
Mat sobelx;
Sobel(grey, sobelx, CV_32F, 1, 0);
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/core/mat_operations/mat_operations.cpp imshow 2
@end_toggle
double minVal, maxVal;
minMaxLoc(sobelx, &minVal, &maxVal); //find minimum and maximum intensities
Mat draw;
sobelx.convertTo(draw, CV_8U, 255.0/(maxVal - minVal), -minVal * 255.0/(maxVal - minVal));
@add_toggle_java
@snippet samples/java/tutorial_code/core/mat_operations/MatOperations.java imshow 2
@end_toggle
namedWindow("image", WINDOW_AUTOSIZE);
imshow("image", draw);
waitKey();
@endcode
@add_toggle_python
@snippet samples/python/tutorial_code/core/mat_operations/mat_operations.py imshow 2
@end_toggle
@note Here cv::namedWindow is not necessary since it is immediately followed by cv::imshow.
Nevertheless, it can be used to change the window properties or when using cv::createTrackbar
@@ -1,6 +1,8 @@
Mat - The Basic Image Container {#tutorial_mat_the_basic_image_container}
===============================
@next_tutorial{tutorial_how_to_scan_images}
Goal
----
@@ -36,6 +36,10 @@ understanding how to manipulate the images on a pixel level.
- @subpage tutorial_mat_operations
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
Reading/writing images from file, accessing pixels, primitive operations, visualizing images.
- @subpage tutorial_adding_images
@@ -50,29 +54,13 @@ understanding how to manipulate the images on a pixel level.
- @subpage tutorial_basic_linear_transform
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will learn how to change our image appearance!
- @subpage tutorial_basic_geometric_drawing
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will learn how to draw simple geometry with OpenCV!
- @subpage tutorial_random_generator_and_text
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will draw some *fancy-looking* stuff using OpenCV!
We will learn how to change our image appearance!
- @subpage tutorial_discrete_fourier_transform
@@ -12,7 +12,7 @@ Tutorial was written for the following versions of corresponding software:
- Download and install Android Studio from https://developer.android.com/studio.
- Get the latest pre-built OpenCV for Android release from https://github.com/opencv/opencv/releases and unpack it (for example, `opencv-3.4.2-android-sdk.zip`).
- Get the latest pre-built OpenCV for Android release from https://github.com/opencv/opencv/releases and unpack it (for example, `opencv-3.4.3-android-sdk.zip`).
- Download MobileNet object detection model from https://github.com/chuanqi305/MobileNet-SSD. We need a configuration file `MobileNetSSD_deploy.prototxt` and weights `MobileNetSSD_deploy.caffemodel`.
@@ -1,7 +1,6 @@
Basic Drawing {#tutorial_basic_geometric_drawing}
=============
@prev_tutorial{tutorial_basic_linear_transform}
@next_tutorial{tutorial_random_generator_and_text}
Goals
@@ -82,20 +81,20 @@ Code
@add_toggle_cpp
- This code is in your OpenCV sample folder. Otherwise you can grab it from
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp)
@include samples/cpp/tutorial_code/core/Matrix/Drawing_1.cpp
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp)
@include samples/cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp
@end_toggle
@add_toggle_java
- This code is in your OpenCV sample folder. Otherwise you can grab it from
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java)
@include samples/java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java)
@include samples/java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java
@end_toggle
@add_toggle_python
- This code is in your OpenCV sample folder. Otherwise you can grab it from
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py)
@include samples/python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py
[here](https://raw.githubusercontent.com/opencv/opencv/3.4/samples/python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py)
@include samples/python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py
@end_toggle
Explanation
@@ -104,42 +103,42 @@ Explanation
Since we plan to draw two examples (an atom and a rook), we have to create two images and two
windows to display them.
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp create_images
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp create_images
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java create_images
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java create_images
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py create_images
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py create_images
@end_toggle
We created functions to draw different geometric shapes. For instance, to draw the atom we used
**MyEllipse** and **MyFilledCircle**:
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp draw_atom
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp draw_atom
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java draw_atom
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java draw_atom
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py draw_atom
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py draw_atom
@end_toggle
And to draw the rook we employed **MyLine**, **rectangle** and a **MyPolygon**:
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp draw_rook
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp draw_rook
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java draw_rook
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java draw_rook
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py draw_rook
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py draw_rook
@end_toggle
@@ -149,15 +148,15 @@ Let's check what is inside each of these functions:
<H4>MyLine</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_line
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_line
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_line
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_line
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_line
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_line
@end_toggle
- As we can see, **MyLine** just call the function **line()** , which does the following:
@@ -170,15 +169,15 @@ Let's check what is inside each of these functions:
<H4>MyEllipse</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_ellipse
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_ellipse
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_ellipse
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_ellipse
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_ellipse
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_ellipse
@end_toggle
- From the code above, we can observe that the function **ellipse()** draws an ellipse such
@@ -194,15 +193,15 @@ Let's check what is inside each of these functions:
<H4>MyFilledCircle</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_filled_circle
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_filled_circle
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_filled_circle
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_filled_circle
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_filled_circle
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_filled_circle
@end_toggle
- Similar to the ellipse function, we can observe that *circle* receives as arguments:
@@ -215,15 +214,15 @@ Let's check what is inside each of these functions:
<H4>MyPolygon</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp my_polygon
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp my_polygon
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java my_polygon
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java my_polygon
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py my_polygon
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py my_polygon
@end_toggle
- To draw a filled polygon we use the function **fillPoly()** . We note that:
@@ -235,15 +234,15 @@ Let's check what is inside each of these functions:
<H4>rectangle</H4>
@add_toggle_cpp
@snippet cpp/tutorial_code/core/Matrix/Drawing_1.cpp rectangle
@snippet cpp/tutorial_code/ImgProc/basic_drawing/Drawing_1.cpp rectangle
@end_toggle
@add_toggle_java
@snippet java/tutorial_code/core/BasicGeometricDrawing/BasicGeometricDrawing.java rectangle
@snippet java/tutorial_code/ImgProc/BasicGeometricDrawing/BasicGeometricDrawing.java rectangle
@end_toggle
@add_toggle_python
@snippet python/tutorial_code/core/BasicGeometricDrawing/basic_geometric_drawing.py rectangle
@snippet python/tutorial_code/imgProc/BasicGeometricDrawing/basic_geometric_drawing.py rectangle
@end_toggle
- Finally we have the @ref cv::rectangle function (we did not create a special function for
@@ -1,6 +1,9 @@
Eroding and Dilating {#tutorial_erosion_dilatation}
====================
@prev_tutorial{tutorial_gausian_median_blur_bilateral_filter}
@next_tutorial{tutorial_opening_closing_hats}
Goal
----
@@ -1,6 +1,7 @@
Smoothing Images {#tutorial_gausian_median_blur_bilateral_filter}
================
@prev_tutorial{tutorial_random_generator_and_text}
@next_tutorial{tutorial_erosion_dilatation}
Goal
@@ -1,6 +1,9 @@
Back Projection {#tutorial_back_projection}
===============
@prev_tutorial{tutorial_histogram_comparison}
@next_tutorial{tutorial_template_matching}
Goal
----
@@ -1,6 +1,9 @@
Histogram Calculation {#tutorial_histogram_calculation}
=====================
@prev_tutorial{tutorial_histogram_equalization}
@next_tutorial{tutorial_histogram_comparison}
Goal
----
@@ -1,6 +1,9 @@
Histogram Comparison {#tutorial_histogram_comparison}
====================
@prev_tutorial{tutorial_histogram_calculation}
@next_tutorial{tutorial_back_projection}
Goal
----
@@ -1,6 +1,9 @@
Histogram Equalization {#tutorial_histogram_equalization}
======================
@prev_tutorial{tutorial_warp_affine}
@next_tutorial{tutorial_histogram_calculation}
Goal
----
@@ -1,6 +1,9 @@
Canny Edge Detector {#tutorial_canny_detector}
===================
@prev_tutorial{tutorial_laplace_operator}
@next_tutorial{tutorial_hough_lines}
Goal
----
@@ -1,6 +1,9 @@
Image Segmentation with Distance Transform and Watershed Algorithm {#tutorial_distance_transform}
=============
@prev_tutorial{tutorial_point_polygon_test}
@next_tutorial{tutorial_out_of_focus_deblur_filter}
Goal
----
@@ -1,6 +1,9 @@
Remapping {#tutorial_remap}
=========
@prev_tutorial{tutorial_hough_circle}
@next_tutorial{tutorial_warp_affine}
Goal
----
@@ -1,6 +1,9 @@
Affine Transformations {#tutorial_warp_affine}
======================
@prev_tutorial{tutorial_remap}
@next_tutorial{tutorial_histogram_equalization}
Goal
----
@@ -1,6 +1,9 @@
More Morphology Transformations {#tutorial_opening_closing_hats}
===============================
@prev_tutorial{tutorial_erosion_dilatation}
@next_tutorial{tutorial_hitOrMiss}
Goal
----
Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

@@ -0,0 +1,114 @@
Out-of-focus Deblur Filter {#tutorial_out_of_focus_deblur_filter}
==========================
@prev_tutorial{tutorial_distance_transform}
Goal
----
In this tutorial you will learn:
- what is a degradation image model
- what is PSF of out-of-focus image
- how to restore a blurred image
- what is Wiener filter
Theory
------
@note The explanation is based on the books @cite gonzalez and @cite gruzman. Also, you can refer to Matlab's tutorial [Image Deblurring in Matlab] and an article [SmartDeblur].
@note An out-of-focus image on this page is a real world image. An out-of-focus was done manually by camera optics.
### What is a degradation image model?
A mathematical model of the image degradation in frequency domain representation is:
\f[S = H\cdot U + N\f]
where
\f$S\f$ is a spectrum of blurred (degraded) image,
\f$U\f$ is a spectrum of original true (undegraded) image,
\f$H\f$ is frequency response of point spread function (PSF),
\f$N\f$ is a spectrum of additive noise.
Circular PSF is a good approximation of out-of-focus distortion. Such PSF is specified by only one parameter - radius \f$R\f$. Circular PSF is used in this work.
![Circular point spread function](psf.png)
### How to restore an blurred image?
The objective of restoration (deblurring) is to obtain an estimate of the original image. Restoration formula in frequency domain is:
\f[U' = H_w\cdot S\f]
where
\f$U'\f$ is spectrum of estimation of original image \f$U\f$,
\f$H_w\f$ is restoration filter, for example, Wiener filter.
### What is Wiener filter?
Wiener filter is a way to restore a blurred image. Let's suppose that PSF is a real and symmetric signal, a power spectrum of the original true image and noise are not known,
then simplified Wiener formula is:
\f[H_w = \frac{H}{|H|^2+\frac{1}{SNR}} \f]
where
\f$SNR\f$ is signal-to-noise ratio.
So, in order to recover an out-of-focus image by Wiener filter, it needs to know \f$SNR\f$ and \f$R\f$ of circular PSF.
Source code
-----------
You can find source code in the `samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp` of the OpenCV source code library.
@include cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp
Explanation
-----------
An out-of-focus image recovering algorithm consists of PSF generation, Wiener filter generation and filtering an blurred image in frequency domain:
@snippet samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp main
A function calcPSF() forms an circular PSF according to input parameter radius \f$R\f$:
@snippet samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp calcPSF
A function calcWnrFilter() synthesizes simplified Wiener filter \f$H_w\f$ according to formula described above:
@snippet samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp calcWnrFilter
A function fftshift() rearranges PSF. This code was just copied from tutorial @ref tutorial_discrete_fourier_transform "Discrete Fourier Transform":
@snippet samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp fftshift
A function filter2DFreq() filters an blurred image in frequency domain:
@snippet samples/cpp/tutorial_code/ImgProc/out_of_focus_deblur_filter/out_of_focus_deblur_filter.cpp filter2DFreq
Result
------
Below you can see real out-of-focus image:
![Out-of-focus image](images/original.jpg)
Below result was done by \f$R\f$ = 53 and \f$SNR\f$ = 5200 parameters:
![The restored (deblurred) image](images/recovered.jpg)
The Wiener filter was used, values of \f$R\f$ and \f$SNR\f$ were selected manually to give the best possible visual result.
We can see that the result is not perfect, but it gives us a hint to the image content. With some difficulty, the text is readable.
@note The parameter \f$R\f$ is the most important. So you should adjust \f$R\f$ first, then \f$SNR\f$.
@note Sometimes you can observe the ringing effect in an restored image. This effect can be reduced by several methods. For example, you can taper input image edges.
You can also find a quick video demonstration of this on
[YouTube](https://youtu.be/0bEcE4B0XP4).
@youtube{0bEcE4B0XP4}
References
------
- [Image Deblurring in Matlab] - Image Deblurring in Matlab
- [SmartDeblur] - SmartDeblur site
<!-- invisible references list -->
[Digital Image Processing]: http://web.ipac.caltech.edu/staff/fmasci/home/astro_refs/Digital_Image_Processing_2ndEd.pdf
[Image Deblurring in Matlab]: https://www.mathworks.com/help/images/image-deblurring.html
[SmartDeblur]: http://yuzhikov.com/articles/BlurredImagesRestoration1.htm
@@ -1,6 +1,9 @@
Random generator and text with OpenCV {#tutorial_random_generator_and_text}
=====================================
@prev_tutorial{tutorial_basic_geometric_drawing}
@next_tutorial{tutorial_gausian_median_blur_bilateral_filter}
Goals
-----
@@ -1,6 +1,9 @@
Creating Bounding boxes and circles for contours {#tutorial_bounding_rects_circles}
================================================
@prev_tutorial{tutorial_hull}
@next_tutorial{tutorial_bounding_rotated_ellipses}
Goal
----
@@ -1,6 +1,9 @@
Creating Bounding rotated boxes and ellipses for contours {#tutorial_bounding_rotated_ellipses}
=========================================================
@prev_tutorial{tutorial_bounding_rects_circles}
@next_tutorial{tutorial_moments}
Goal
----
@@ -1,6 +1,9 @@
Finding contours in your image {#tutorial_find_contours}
==============================
@prev_tutorial{tutorial_template_matching}
@next_tutorial{tutorial_hull}
Goal
----
@@ -1,6 +1,9 @@
Convex Hull {#tutorial_hull}
===========
@prev_tutorial{tutorial_find_contours}
@next_tutorial{tutorial_bounding_rects_circles}
Goal
----
@@ -1,6 +1,9 @@
Image Moments {#tutorial_moments}
=============
@prev_tutorial{tutorial_bounding_rotated_ellipses}
@next_tutorial{tutorial_point_polygon_test}
Goal
----
@@ -1,6 +1,9 @@
Point Polygon Test {#tutorial_point_polygon_test}
==================
@prev_tutorial{tutorial_moments}
@next_tutorial{tutorial_distance_transform}
Goal
----
@@ -3,6 +3,24 @@ Image Processing (imgproc module) {#tutorial_table_of_content_imgproc}
In this section you will learn about the image processing (manipulation) functions inside OpenCV.
- @subpage tutorial_basic_geometric_drawing
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will learn how to draw simple geometry with OpenCV!
- @subpage tutorial_random_generator_and_text
*Compatibility:* \> OpenCV 2.0
*Author:* Ana Huamán
We will draw some *fancy-looking* stuff using OpenCV!
- @subpage tutorial_gausian_median_blur_bilateral_filter
*Languages:* C++, Java, Python
@@ -292,3 +310,13 @@ In this section you will learn about the image processing (manipulation) functio
*Author:* Theodore Tsesmelis
Where we learn to segment objects using Laplacian filtering, the Distance Transformation and the Watershed algorithm.
- @subpage tutorial_out_of_focus_deblur_filter
*Languages:* C++
*Compatibility:* \> OpenCV 2.0
*Author:* Karpushin Vladislav
You will learn how to recover an out-of-focus image by Wiener filter.
@@ -1,6 +1,9 @@
Basic Thresholding Operations {#tutorial_threshold}
=============================
@prev_tutorial{tutorial_pyramids}
@next_tutorial{tutorial_threshold_inRange}
Goal
----
@@ -1,6 +1,9 @@
Thresholding Operations using inRange {#tutorial_threshold_inRange}
=====================================
@prev_tutorial{tutorial_threshold}
@next_tutorial{tutorial_filter_2d}
Goal
----
@@ -36,14 +36,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.2
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.3
@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.2
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/3.4.3
@endcode
Doxygen can now use the information from the tag file to link to the OpenCV
@@ -46,7 +46,7 @@ cd /c/lib
myRepo=$(pwd)
CMAKE_CONFIG_GENERATOR="Visual Studio 14 2015 Win64"
if [ ! -d "$myRepo/opencv" ]; then
echo "clonning opencv"
echo "cloning opencv"
git clone https://github.com/opencv/opencv.git
mkdir Build
mkdir Build/opencv
@@ -58,7 +58,7 @@ else
cd ..
fi
if [ ! -d "$myRepo/opencv_contrib" ]; then
echo "clonning opencv_contrib"
echo "cloning opencv_contrib"
git clone https://github.com/opencv/opencv_contrib.git
mkdir Build
mkdir Build/opencv_contrib
@@ -91,37 +91,112 @@ __Find the eigenvectors and eigenvalues of the covariance matrix__
Source Code
-----------
This tutorial code's is shown lines below. You can also download it from
[here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp).
@include cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
@add_toggle_cpp
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp)
- **Code at glance:**
@include samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
@end_toggle
@add_toggle_java
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java)
- **Code at glance:**
@include samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java
@end_toggle
@add_toggle_python
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py)
- **Code at glance:**
@include samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py
@end_toggle
@note Another example using PCA for dimensionality reduction while maintaining an amount of variance can be found at [opencv_source_code/samples/cpp/pca.cpp](https://github.com/opencv/opencv/tree/3.4/samples/cpp/pca.cpp)
Explanation
-----------
-# __Read image and convert it to binary__
- __Read image and convert it to binary__
Here we apply the necessary pre-processing procedures in order to be able to detect the objects of interest.
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp pre-process
Here we apply the necessary pre-processing procedures in order to be able to detect the objects of interest.
-# __Extract objects of interest__
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp pre-process
@end_toggle
Then find and filter contours by size and obtain the orientation of the remaining ones.
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp contours
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java pre-process
@end_toggle
-# __Extract orientation__
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py pre-process
@end_toggle
Orientation is extracted by the call of getOrientation() function, which performs all the PCA procedure.
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp pca
- __Extract objects of interest__
First the data need to be arranged in a matrix with size n x 2, where n is the number of data points we have. Then we can perform that PCA analysis. The calculated mean (i.e. center of mass) is stored in the _cntr_ variable and the eigenvectors and eigenvalues are stored in the corresponding std::vectors.
Then find and filter contours by size and obtain the orientation of the remaining ones.
-# __Visualize result__
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp contours
@end_toggle
The final result is visualized through the drawAxis() function, where the principal components are drawn in lines, and each eigenvector is multiplied by its eigenvalue and translated to the mean position.
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp visualization
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp visualization1
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java contours
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py contours
@end_toggle
- __Extract orientation__
Orientation is extracted by the call of getOrientation() function, which performs all the PCA procedure.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp pca
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java pca
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py pca
@end_toggle
First the data need to be arranged in a matrix with size n x 2, where n is the number of data points we have. Then we can perform that PCA analysis. The calculated mean (i.e. center of mass) is stored in the _cntr_ variable and the eigenvectors and eigenvalues are stored in the corresponding std::vectors.
- __Visualize result__
The final result is visualized through the drawAxis() function, where the principal components are drawn in lines, and each eigenvector is multiplied by its eigenvalue and translated to the mean position.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp visualization
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java visualization
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py visualization
@end_toggle
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp visualization1
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_pca/IntroductionToPCADemo.java visualization1
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_pca/introduction_to_pca.py visualization1
@end_toggle
Results
-------
@@ -96,25 +96,67 @@ Source Code
@note The following code has been implemented with OpenCV 3.0 classes and functions. An equivalent version of the code using OpenCV 2.4 can be found in [this page.](http://docs.opencv.org/2.4/doc/tutorials/ml/introduction_to_svm/introduction_to_svm.html#introductiontosvms)
@include cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp
@add_toggle_cpp
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp)
- **Code at glance:**
@include samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp
@end_toggle
@add_toggle_java
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java)
- **Code at glance:**
@include samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java
@end_toggle
@add_toggle_python
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py)
- **Code at glance:**
@include samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py
@end_toggle
Explanation
-----------
-# **Set up the training data**
- **Set up the training data**
The training data of this exercise is formed by a set of labeled 2D-points that belong to one of
two different classes; one of the classes consists of one point and the other of three points.
The training data of this exercise is formed by a set of labeled 2D-points that belong to one of
two different classes; one of the classes consists of one point and the other of three points.
@snippet cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp setup1
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp setup1
@end_toggle
The function @ref cv::ml::SVM::train that will be used afterwards requires the training data to be
stored as @ref cv::Mat objects of floats. Therefore, we create these objects from the arrays
defined above:
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java setup1
@end_toggle
@snippet cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp setup2
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py setup1
@end_toggle
-# **Set up SVM's parameters**
The function @ref cv::ml::SVM::train that will be used afterwards requires the training data to be
stored as @ref cv::Mat objects of floats. Therefore, we create these objects from the arrays
defined above:
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp setup2
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java setup2
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py setup1
@end_toggle
- **Set up SVM's parameters**
In this tutorial we have introduced the theory of SVMs in the most simple case, when the
training examples are spread into two classes that are linearly separable. However, SVMs can be
@@ -123,35 +165,55 @@ Explanation
we have to define some parameters before training the SVM. These parameters are stored in an
object of the class @ref cv::ml::SVM.
@snippet cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp init
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp init
@end_toggle
Here:
- *Type of SVM*. We choose here the type @ref cv::ml::SVM::C_SVC "C_SVC" that can be used for
n-class classification (n \f$\geq\f$ 2). The important feature of this type is that it deals
with imperfect separation of classes (i.e. when the training data is non-linearly separable).
This feature is not important here since the data is linearly separable and we chose this SVM
type only for being the most commonly used.
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java init
@end_toggle
- *Type of SVM kernel*. We have not talked about kernel functions since they are not
interesting for the training data we are dealing with. Nevertheless, let's explain briefly now
the main idea behind a kernel function. It is a mapping done to the training data to improve
its resemblance to a linearly separable set of data. This mapping consists of increasing the
dimensionality of the data and is done efficiently using a kernel function. We choose here the
type @ref cv::ml::SVM::LINEAR "LINEAR" which means that no mapping is done. This parameter is
defined using cv::ml::SVM::setKernel.
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py init
@end_toggle
- *Termination criteria of the algorithm*. The SVM training procedure is implemented solving a
constrained quadratic optimization problem in an **iterative** fashion. Here we specify a
maximum number of iterations and a tolerance error so we allow the algorithm to finish in
less number of steps even if the optimal hyperplane has not been computed yet. This
parameter is defined in a structure @ref cv::TermCriteria .
Here:
- *Type of SVM*. We choose here the type @ref cv::ml::SVM::C_SVC "C_SVC" that can be used for
n-class classification (n \f$\geq\f$ 2). The important feature of this type is that it deals
with imperfect separation of classes (i.e. when the training data is non-linearly separable).
This feature is not important here since the data is linearly separable and we chose this SVM
type only for being the most commonly used.
-# **Train the SVM**
- *Type of SVM kernel*. We have not talked about kernel functions since they are not
interesting for the training data we are dealing with. Nevertheless, let's explain briefly now
the main idea behind a kernel function. It is a mapping done to the training data to improve
its resemblance to a linearly separable set of data. This mapping consists of increasing the
dimensionality of the data and is done efficiently using a kernel function. We choose here the
type @ref cv::ml::SVM::LINEAR "LINEAR" which means that no mapping is done. This parameter is
defined using cv::ml::SVM::setKernel.
- *Termination criteria of the algorithm*. The SVM training procedure is implemented solving a
constrained quadratic optimization problem in an **iterative** fashion. Here we specify a
maximum number of iterations and a tolerance error so we allow the algorithm to finish in
less number of steps even if the optimal hyperplane has not been computed yet. This
parameter is defined in a structure @ref cv::TermCriteria .
- **Train the SVM**
We call the method @ref cv::ml::SVM::train to build the SVM model.
@snippet cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp train
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp train
@end_toggle
-# **Regions classified by the SVM**
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java train
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py train
@end_toggle
- **Regions classified by the SVM**
The method @ref cv::ml::SVM::predict is used to classify an input sample using a trained SVM. In
this example we have used this method in order to color the space depending on the prediction done
@@ -159,16 +221,36 @@ Explanation
Cartesian plane. Each of the points is colored depending on the class predicted by the SVM; in
green if it is the class with label 1 and in blue if it is the class with label -1.
@snippet cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp show
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp show
@end_toggle
-# **Support vectors**
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java show
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py show
@end_toggle
- **Support vectors**
We use here a couple of methods to obtain information about the support vectors.
The method @ref cv::ml::SVM::getSupportVectors obtain all of the support
vectors. We have used this methods here to find the training examples that are
support vectors and highlight them.
@snippet cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp show_vectors
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/introduction_to_svm/introduction_to_svm.cpp show_vectors
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/introduction_to_svm/IntroductionToSVMDemo.java show_vectors
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/introduction_to_svm/introduction_to_svm.py show_vectors
@end_toggle
Results
-------
@@ -92,81 +92,175 @@ You may also find the source code in `samples/cpp/tutorial_code/ml/non_linear_sv
@note The following code has been implemented with OpenCV 3.0 classes and functions. An equivalent version of the code
using OpenCV 2.4 can be found in [this page.](http://docs.opencv.org/2.4/doc/tutorials/ml/non_linear_svms/non_linear_svms.html#nonlinearsvms)
@include cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp
@add_toggle_cpp
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp)
- **Code at glance:**
@include samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp
@end_toggle
@add_toggle_java
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java)
- **Code at glance:**
@include samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java
@end_toggle
@add_toggle_python
- **Downloadable code**: Click
[here](https://github.com/opencv/opencv/tree/3.4/samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py)
- **Code at glance:**
@include samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py
@end_toggle
Explanation
-----------
-# __Set up the training data__
- __Set up the training data__
The training data of this exercise is formed by a set of labeled 2D-points that belong to one of
two different classes. To make the exercise more appealing, the training data is generated
randomly using a uniform probability density functions (PDFs).
The training data of this exercise is formed by a set of labeled 2D-points that belong to one of
two different classes. To make the exercise more appealing, the training data is generated
randomly using a uniform probability density functions (PDFs).
We have divided the generation of the training data into two main parts.
We have divided the generation of the training data into two main parts.
In the first part we generate data for both classes that is linearly separable.
@snippet cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp setup1
In the first part we generate data for both classes that is linearly separable.
In the second part we create data for both classes that is non-linearly separable, data that
overlaps.
@snippet cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp setup2
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp setup1
@end_toggle
-# __Set up SVM's parameters__
@add_toggle_java
@snippet samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java setup1
@end_toggle
@note In the previous tutorial @ref tutorial_introduction_to_svm there is an explanation of the
attributes of the class @ref cv::ml::SVM that we configure here before training the SVM.
@add_toggle_python
@snippet samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py setup1
@end_toggle
@snippet cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp init
In the second part we create data for both classes that is non-linearly separable, data that
overlaps.
There are just two differences between the configuration we do here and the one that was done in
the previous tutorial (@ref tutorial_introduction_to_svm) that we use as reference.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp setup2
@end_toggle
- _C_. We chose here a small value of this parameter in order not to punish too much the
misclassification errors in the optimization. The idea of doing this stems from the will of
obtaining a solution close to the one intuitively expected. However, we recommend to get a
better insight of the problem by making adjustments to this parameter.
@add_toggle_java
@snippet samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java setup2
@end_toggle
@note In this case there are just very few points in the overlapping region between classes.
By giving a smaller value to __FRAC_LINEAR_SEP__ the density of points can be incremented and the
impact of the parameter _C_ explored deeply.
@add_toggle_python
@snippet samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py setup2
@end_toggle
- _Termination Criteria of the algorithm_. The maximum number of iterations has to be
increased considerably in order to solve correctly a problem with non-linearly separable
training data. In particular, we have increased in five orders of magnitude this value.
- __Set up SVM's parameters__
-# __Train the SVM__
@note In the previous tutorial @ref tutorial_introduction_to_svm there is an explanation of the
attributes of the class @ref cv::ml::SVM that we configure here before training the SVM.
We call the method @ref cv::ml::SVM::train to build the SVM model. Watch out that the training
process may take a quite long time. Have patiance when your run the program.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp init
@end_toggle
@snippet cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp train
@add_toggle_java
@snippet samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java init
@end_toggle
-# __Show the Decision Regions__
@add_toggle_python
@snippet samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py init
@end_toggle
The method @ref cv::ml::SVM::predict is used to classify an input sample using a trained SVM. In
this example we have used this method in order to color the space depending on the prediction done
by the SVM. In other words, an image is traversed interpreting its pixels as points of the
Cartesian plane. Each of the points is colored depending on the class predicted by the SVM; in
dark green if it is the class with label 1 and in dark blue if it is the class with label 2.
There are just two differences between the configuration we do here and the one that was done in
the previous tutorial (@ref tutorial_introduction_to_svm) that we use as reference.
@snippet cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp show
- _C_. We chose here a small value of this parameter in order not to punish too much the
misclassification errors in the optimization. The idea of doing this stems from the will of
obtaining a solution close to the one intuitively expected. However, we recommend to get a
better insight of the problem by making adjustments to this parameter.
-# __Show the training data__
@note In this case there are just very few points in the overlapping region between classes.
By giving a smaller value to __FRAC_LINEAR_SEP__ the density of points can be incremented and the
impact of the parameter _C_ explored deeply.
The method @ref cv::circle is used to show the samples that compose the training data. The samples
of the class labeled with 1 are shown in light green and in light blue the samples of the class
labeled with 2.
- _Termination Criteria of the algorithm_. The maximum number of iterations has to be
increased considerably in order to solve correctly a problem with non-linearly separable
training data. In particular, we have increased in five orders of magnitude this value.
@snippet cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp show_data
- __Train the SVM__
-# __Support vectors__
We call the method @ref cv::ml::SVM::train to build the SVM model. Watch out that the training
process may take a quite long time. Have patiance when your run the program.
We use here a couple of methods to obtain information about the support vectors. The method
@ref cv::ml::SVM::getSupportVectors obtain all support vectors. We have used this methods here
to find the training examples that are support vectors and highlight them.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp train
@end_toggle
@snippet cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp show_vectors
@add_toggle_java
@snippet samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java train
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py train
@end_toggle
- __Show the Decision Regions__
The method @ref cv::ml::SVM::predict is used to classify an input sample using a trained SVM. In
this example we have used this method in order to color the space depending on the prediction done
by the SVM. In other words, an image is traversed interpreting its pixels as points of the
Cartesian plane. Each of the points is colored depending on the class predicted by the SVM; in
dark green if it is the class with label 1 and in dark blue if it is the class with label 2.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp show
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java show
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py show
@end_toggle
- __Show the training data__
The method @ref cv::circle is used to show the samples that compose the training data. The samples
of the class labeled with 1 are shown in light green and in light blue the samples of the class
labeled with 2.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp show_data
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java show_data
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py show_data
@end_toggle
- __Support vectors__
We use here a couple of methods to obtain information about the support vectors. The method
@ref cv::ml::SVM::getSupportVectors obtain all support vectors. We have used this methods here
to find the training examples that are support vectors and highlight them.
@add_toggle_cpp
@snippet samples/cpp/tutorial_code/ml/non_linear_svms/non_linear_svms.cpp show_vectors
@end_toggle
@add_toggle_java
@snippet samples/java/tutorial_code/ml/non_linear_svms/NonLinearSVMsDemo.java show_vectors
@end_toggle
@add_toggle_python
@snippet samples/python/tutorial_code/ml/non_linear_svms/non_linear_svms.py show_vectors
@end_toggle
Results
-------
@@ -6,6 +6,8 @@ of data.
- @subpage tutorial_introduction_to_svm
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
*Author:* Fernando Iglesias García
@@ -14,6 +16,8 @@ of data.
- @subpage tutorial_non_linear_svms
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
*Author:* Fernando Iglesias García
@@ -23,6 +27,8 @@ of data.
- @subpage tutorial_introduction_to_pca
*Languages:* C++, Java, Python
*Compatibility:* \> OpenCV 2.0
*Author:* Theodore Tsesmelis
@@ -24,17 +24,7 @@ Explanation
The most important code part is:
@code{.cpp}
Mat pano;
Ptr<Stitcher> stitcher = Stitcher::create(mode, try_use_gpu);
Stitcher::Status status = stitcher->stitch(imgs, pano);
if (status != Stitcher::OK)
{
cout << "Can't stitch images, error code = " << int(status) << endl;
return -1;
}
@endcode
@snippet cpp/stitching.cpp stitching
A new instance of stitcher is created and the @ref cv::Stitcher::stitch will
do all the hard work.
+1 -1
View File
@@ -15,7 +15,7 @@ As always, we would be happy to hear your comments and receive your contribution
- @subpage tutorial_table_of_content_core
Here you will learn
the about the basic building blocks of this library. A must read for understanding how
about the basic building blocks of this library. A must read for understanding how
to manipulate the images on a pixel level.
- @subpage tutorial_table_of_content_imgproc
+13 -13
View File
@@ -118,7 +118,7 @@ v = f_y*y'' + c_y
tangential distortion coefficients. \f$s_1\f$, \f$s_2\f$, \f$s_3\f$, and \f$s_4\f$, are the thin prism distortion
coefficients. Higher-order coefficients are not considered in OpenCV.
The next figure shows two common types of radial distortion: barrel distortion (typically \f$ k_1 > 0 \f$ and pincushion distortion (typically \f$ k_1 < 0 \f$).
The next figure shows two common types of radial distortion: barrel distortion (typically \f$ k_1 > 0 \f$) and pincushion distortion (typically \f$ k_1 < 0 \f$).
![](pics/distortion_examples.png)
@@ -307,11 +307,11 @@ optimization procedures like calibrateCamera, stereoCalibrate, or solvePnP .
*/
CV_EXPORTS_W void Rodrigues( InputArray src, OutputArray dst, OutputArray jacobian = noArray() );
/** @example pose_from_homography.cpp
An example program about pose estimation from coplanar points
/** @example samples/cpp/tutorial_code/features2D/Homography/pose_from_homography.cpp
An example program about pose estimation from coplanar points
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
/** @brief Finds a perspective transformation between two planes.
@@ -526,11 +526,11 @@ CV_EXPORTS_W void projectPoints( InputArray objectPoints,
OutputArray jacobian = noArray(),
double aspectRatio = 0 );
/** @example homography_from_camera_displacement.cpp
An example program about homography from the camera displacement
/** @example samples/cpp/tutorial_code/features2D/Homography/homography_from_camera_displacement.cpp
An example program about homography from the camera displacement
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
Check @ref tutorial_homography "the corresponding tutorial" for more details
*/
/** @brief Finds an object pose from 3D-2D point correspondences.
@@ -1966,11 +1966,11 @@ CV_EXPORTS_W cv::Mat estimateAffinePartial2D(InputArray from, InputArray to, Out
size_t maxIters = 2000, double confidence = 0.99,
size_t refineIters = 10);
/** @example decompose_homography.cpp
An example program with homography decomposition.
/** @example samples/cpp/tutorial_code/features2D/Homography/decompose_homography.cpp
An example program with homography decomposition.
Check @ref tutorial_homography "the corresponding tutorial" for more details.
*/
Check @ref tutorial_homography "the corresponding tutorial" for more details.
*/
/** @brief Decompose a homography matrix to rotation(s), translation(s) and plane normal(s).
+3
View File
@@ -18,6 +18,9 @@
]
}
},
"namespaces_dict": {
"cv.fisheye": "fisheye"
},
"func_arg_fix" : {
"findFundamentalMat" : { "points1" : {"ctype" : "vector_Point2f"},
"points2" : {"ctype" : "vector_Point2f"} },
+47
View File
@@ -0,0 +1,47 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// This file contains wrappers for legacy OpenCV C API
#include "precomp.hpp"
#include "opencv2/calib3d/calib3d_c.h"
using namespace cv;
CV_IMPL void
cvDrawChessboardCorners(CvArr* _image, CvSize pattern_size,
CvPoint2D32f* corners, int count, int found)
{
CV_Assert(corners != NULL); //CV_CheckNULL(corners, "NULL is not allowed for 'corners' parameter");
Mat image = cvarrToMat(_image);
CV_StaticAssert(sizeof(CvPoint2D32f) == sizeof(Point2f), "");
drawChessboardCorners(image, pattern_size, Mat(1, count, traits::Type<Point2f>::value, corners), found != 0);
}
CV_IMPL int
cvFindChessboardCorners(const void* arr, CvSize pattern_size,
CvPoint2D32f* out_corners_, int* out_corner_count,
int flags)
{
if (!out_corners_)
CV_Error( CV_StsNullPtr, "Null pointer to corners" );
Mat image = cvarrToMat(arr);
std::vector<Point2f> out_corners;
if (out_corner_count)
*out_corner_count = 0;
bool res = cv::findChessboardCorners(image, pattern_size, out_corners, flags);
int corner_count = (int)out_corners.size();
if (out_corner_count)
*out_corner_count = corner_count;
CV_CheckLE(corner_count, Size(pattern_size).area(), "Unexpected number of corners");
for (int i = 0; i < corner_count; ++i)
{
out_corners_[i] = cvPoint2D32f(out_corners[i]);
}
return res ? 1 : 0;
}
File diff suppressed because it is too large Load Diff
+12
View File
@@ -2336,10 +2336,13 @@ void cvStereoRectify( const CvMat* _cameraMatrix1, const CvMat* _cameraMatrix2,
_uu[2] = 1;
cvCrossProduct(&uu, &t, &ww);
nt = cvNorm(&t, 0, CV_L2);
CV_Assert(fabs(nt) > 0);
nw = cvNorm(&ww, 0, CV_L2);
CV_Assert(fabs(nw) > 0);
cvConvertScale(&ww, &ww, 1 / nw);
cvCrossProduct(&t, &ww, &w3);
nw = cvNorm(&w3, 0, CV_L2);
CV_Assert(fabs(nw) > 0);
cvConvertScale(&w3, &w3, 1 / nw);
_uu[2] = 0;
@@ -3159,6 +3162,10 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints,
Point3f* objPtData = objPtMat.ptr<Point3f>();
Point2f* imgPtData1 = imgPtMat1.ptr<Point2f>();
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
for( i = 0; i < nimages; i++, j += ni )
{
Mat objpt = objectPoints.getMat(i);
@@ -3176,6 +3183,9 @@ static void collectCalibrationData( InputArrayOfArrays objectPoints,
memcpy( imgPtData2 + j, imgpt2.ptr(), ni*sizeof(imgPtData2[0]) );
}
}
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
}
static Mat prepareCameraMatrix(Mat& cameraMatrix0, int rtype)
@@ -3870,12 +3880,14 @@ float cv::rectify3Collinear( InputArray _cameraMatrix1, InputArray _distCoeffs1,
int idx = fabs(t12(0,0)) > fabs(t12(1,0)) ? 0 : 1;
double c = t12(idx,0), nt = norm(t12, CV_L2);
CV_Assert(fabs(nt) > 0);
Mat_<double> uu = Mat_<double>::zeros(3,1);
uu(idx, 0) = c > 0 ? 1 : -1;
// calculate global Z rotation
Mat_<double> ww = t12.cross(uu), wR;
double nw = norm(ww, CV_L2);
CV_Assert(fabs(nw) > 0);
ww *= acos(fabs(c)/nt)/nw;
Rodrigues(ww, wR);
+11 -11
View File
@@ -224,7 +224,7 @@ void CirclesGridClusterFinder::findOutsideCorners(const std::vector<cv::Point2f>
CV_Assert(!corners.empty());
outsideCorners.clear();
//find two pairs of the most nearest corners
int i, j, n = (int)corners.size();
const size_t n = corners.size();
#ifdef DEBUG_CIRCLES
Mat cornersImage(1024, 1248, CV_8UC1, Scalar(0));
@@ -232,22 +232,22 @@ void CirclesGridClusterFinder::findOutsideCorners(const std::vector<cv::Point2f>
imshow("corners", cornersImage);
#endif
std::vector<Point2f> tangentVectors(corners.size());
for(size_t k=0; k<corners.size(); k++)
std::vector<Point2f> tangentVectors(n);
for(size_t k=0; k < n; k++)
{
Point2f diff = corners[(k + 1) % corners.size()] - corners[k];
Point2f diff = corners[(k + 1) % n] - corners[k];
tangentVectors[k] = diff * (1.0f / norm(diff));
}
//compute angles between all sides
Mat cosAngles(n, n, CV_32FC1, 0.0f);
for(i = 0; i < n; i++)
Mat cosAngles((int)n, (int)n, CV_32FC1, 0.0f);
for(size_t i = 0; i < n; i++)
{
for(j = i + 1; j < n; j++)
for(size_t j = i + 1; j < n; j++)
{
float val = fabs(tangentVectors[i].dot(tangentVectors[j]));
cosAngles.at<float>(i, j) = val;
cosAngles.at<float>(j, i) = val;
cosAngles.at<float>((int)i, (int)j) = val;
cosAngles.at<float>((int)j, (int)i) = val;
}
}
@@ -276,10 +276,10 @@ void CirclesGridClusterFinder::findOutsideCorners(const std::vector<cv::Point2f>
const int bigDiff = 4;
if(maxIdx - minIdx == bigDiff)
{
minIdx += n;
minIdx += (int)n;
std::swap(maxIdx, minIdx);
}
if(maxIdx - minIdx != n - bigDiff)
if(maxIdx - minIdx != (int)n - bigDiff)
{
return;
}
+1
View File
@@ -206,6 +206,7 @@ void dls::run_kernel(const cv::Mat& pp)
void dls::build_coeff_matrix(const cv::Mat& pp, cv::Mat& Mtilde, cv::Mat& D)
{
CV_Assert(!pp.empty() && N > 0);
cv::Mat eye = cv::Mat::eye(3, 3, CV_64F);
// build coeff matrix
+9 -3
View File
@@ -126,7 +126,8 @@ void cv::fisheye::projectPoints(InputArray objectPoints, OutputArray imagePoints
{
Vec3d Xi = objectPoints.depth() == CV_32F ? (Vec3d)Xf[i] : Xd[i];
Vec3d Y = aff*Xi;
if (fabs(Y[2]) < DBL_MIN)
Y[2] = 1;
Vec2d x(Y[0]/Y[2], Y[1]/Y[2]);
double r2 = x.dot(x);
@@ -1186,6 +1187,7 @@ void cv::internal::ComputeExtrinsicRefine(const Mat& imagePoints, const Mat& obj
{
CV_Assert(!objectPoints.empty() && objectPoints.type() == CV_64FC3);
CV_Assert(!imagePoints.empty() && imagePoints.type() == CV_64FC2);
CV_Assert(rvec.total() > 2 && tvec.total() > 2);
Vec6d extrinsics(rvec.at<double>(0), rvec.at<double>(1), rvec.at<double>(2),
tvec.at<double>(0), tvec.at<double>(1), tvec.at<double>(2));
double change = 1;
@@ -1365,9 +1367,13 @@ void cv::internal::InitExtrinsics(const Mat& _imagePoints, const Mat& _objectPoi
double sc = .5 * (norm(H.col(0)) + norm(H.col(1)));
H = H / sc;
Mat u1 = H.col(0).clone();
u1 = u1 / norm(u1);
double norm_u1 = norm(u1);
CV_Assert(fabs(norm_u1) > 0);
u1 = u1 / norm_u1;
Mat u2 = H.col(1).clone() - u1.dot(H.col(1).clone()) * u1;
u2 = u2 / norm(u2);
double norm_u2 = norm(u2);
CV_Assert(fabs(norm_u2) > 0);
u2 = u2 / norm_u2;
Mat u3 = u1.cross(u2);
Mat RRR;
hconcat(u1, u2, RRR);
@@ -194,6 +194,7 @@ void HomographyDecompZhang::decompose(std::vector<CameraMotion>& camMotions)
{
Mat W, U, Vt;
SVD::compute(getHnorm(), W, U, Vt);
CV_Assert(W.total() > 2 && Vt.total() > 7);
double lambda1=W.at<double>(0);
double lambda3=W.at<double>(2);
double lambda1m3 = (lambda1-lambda3);
+5 -3
View File
@@ -42,13 +42,15 @@
#ifndef __OPENCV_PRECOMP_H__
#define __OPENCV_PRECOMP_H__
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/core/utility.hpp"
#include "opencv2/core/private.hpp"
#include "opencv2/calib3d.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/core/ocl.hpp"
#ifdef HAVE_TEGRA_OPTIMIZATION
+1 -1
View File
@@ -104,7 +104,7 @@ public:
int maxAttempts=1000 ) const
{
cv::AutoBuffer<int> _idx(modelPoints);
int* idx = _idx;
int* idx = _idx.data();
int i = 0, j, k, iters = 0;
int d1 = m1.channels() > 1 ? m1.channels() : m1.cols;
int d2 = m2.channels() > 1 ? m2.channels() : m2.cols;
+1 -1
View File
@@ -2451,7 +2451,7 @@ void cv::validateDisparity( InputOutputArray _disp, InputArray _cost, int minDis
int minD = minDisparity, maxD = minDisparity + numberOfDisparities;
int x, minX1 = std::max(maxD, 0), maxX1 = cols + std::min(minD, 0);
AutoBuffer<int> _disp2buf(cols*2);
int* disp2buf = _disp2buf;
int* disp2buf = _disp2buf.data();
int* disp2cost = disp2buf + cols;
const int DISP_SHIFT = 4, DISP_SCALE = 1 << DISP_SHIFT;
int INVALID_DISP = minD - 1, INVALID_DISP_SCALED = INVALID_DISP*DISP_SCALE;
@@ -1618,7 +1618,8 @@ void CV_StereoCalibrationTest::run( int )
bool found2 = findChessboardCorners(right, patternSize, imgpt2[i]);
if(!found1 || !found2)
{
ts->printf( cvtest::TS::LOG, "The function could not detect boards on the images %s and %s, testcase %d\n",
ts->printf( cvtest::TS::LOG, "The function could not detect boards (%d x %d) on the images %s and %s, testcase %d\n",
patternSize.width, patternSize.height,
imglist[i*2].c_str(), imglist[i*2+1].c_str(), testcase );
ts->set_failed_test_info( cvtest::TS::FAIL_INVALID_OUTPUT );
return;
@@ -489,7 +489,14 @@ protected:
void run(int /* start_from */ )
{
CvMat zeros;
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wclass-memaccess"
#endif
memset(&zeros, 0, sizeof(zeros));
#if defined __GNUC__ && __GNUC__ >= 8
#pragma GCC diagnostic pop
#endif
C_Caller caller, bad_caller;
CvMat objectPoints_c, r_vec_c, t_vec_c, A_c, distCoeffs_c, imagePoints_c,
+5 -5
View File
@@ -198,7 +198,7 @@ void CV_ChessboardDetectorTest::run_batch( const string& filename )
if( !fs.isOpened() || board_list.empty() || !board_list.isSeq() || board_list.size() % 2 != 0 )
{
ts->printf( cvtest::TS::LOG, "%s can not be readed or is not valid\n", (folder + filename).c_str() );
ts->printf( cvtest::TS::LOG, "%s can not be read or is not valid\n", (folder + filename).c_str() );
ts->printf( cvtest::TS::LOG, "fs.isOpened=%d, board_list.empty=%d, board_list.isSeq=%d,board_list.size()%2=%d\n",
fs.isOpened(), (int)board_list.empty(), board_list.isSeq(), board_list.size()%2);
ts->set_failed_test_info( cvtest::TS::FAIL_MISSING_TEST_DATA );
@@ -334,19 +334,19 @@ bool validateData(const ChessBoardGenerator& cbg, const Size& imgSz,
tmp = cv::norm(cur - mat(i + 1, j + 1)); // TODO cvtest
if (tmp < minNeibDist)
tmp = minNeibDist;
minNeibDist = tmp;
tmp = cv::norm(cur - mat(i - 1, j + 1)); // TODO cvtest
if (tmp < minNeibDist)
tmp = minNeibDist;
minNeibDist = tmp;
tmp = cv::norm(cur - mat(i + 1, j - 1)); // TODO cvtest
if (tmp < minNeibDist)
tmp = minNeibDist;
minNeibDist = tmp;
tmp = cv::norm(cur - mat(i - 1, j - 1)); // TODO cvtest
if (tmp < minNeibDist)
tmp = minNeibDist;
minNeibDist = tmp;
}
const double threshold = 0.25;
@@ -85,7 +85,7 @@ void CV_ChessboardDetectorTimingTest::run( int start_from )
if( !fs || !board_list || !CV_NODE_IS_SEQ(board_list->tag) ||
board_list->data.seq->total % 4 != 0 )
{
ts->printf( cvtest::TS::LOG, "chessboard_timing_list.dat can not be readed or is not valid" );
ts->printf( cvtest::TS::LOG, "chessboard_timing_list.dat can not be read or is not valid" );
code = cvtest::TS::FAIL_MISSING_TEST_DATA;
goto _exit_;
}
+12 -3
View File
@@ -3,6 +3,10 @@ set(the_description "The Core Functionality")
ocv_add_dispatched_file(mathfuncs_core SSE2 AVX AVX2)
ocv_add_dispatched_file(stat SSE4_2 AVX2)
# dispatching for accuracy tests
ocv_add_dispatched_file_force_all(test_intrin128 TEST SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX FP16 AVX2)
ocv_add_dispatched_file_force_all(test_intrin256 TEST AVX2)
ocv_add_module(core
OPTIONAL opencv_cudev
WRAP java python js)
@@ -29,9 +33,14 @@ if(CV_TRACE AND HAVE_ITT AND BUILD_ITT)
add_definitions(-DOPENCV_WITH_ITT=1)
endif()
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
file(GLOB lib_cuda_hdrs_detail "include/opencv2/${name}/cuda/detail/*.hpp" "include/opencv2/${name}/cuda/detail/*.h")
file(GLOB_RECURSE module_opencl_hdrs "include/opencv2/${name}/opencl/*")
file(GLOB lib_cuda_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/*.h")
file(GLOB lib_cuda_hdrs_detail
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/detail/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/cuda/detail/*.h")
file(GLOB_RECURSE module_opencl_hdrs
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/opencl/*")
source_group("Include\\Cuda Headers" FILES ${lib_cuda_hdrs})
source_group("Include\\Cuda Headers\\Detail" FILES ${lib_cuda_hdrs_detail})
+66 -55
View File
@@ -273,9 +273,11 @@ of p and len.
*/
CV_EXPORTS_W int borderInterpolate(int p, int len, int borderType);
/** @example copyMakeBorder_demo.cpp
An example using copyMakeBorder function
*/
/** @example samples/cpp/tutorial_code/ImgTrans/copyMakeBorder_demo.cpp
An example using copyMakeBorder function.
Check @ref tutorial_copyMakeBorder "the corresponding tutorial" for more details
*/
/** @brief Forms a border around an image.
The function copies the source image into the middle of the destination image. The areas to the
@@ -474,9 +476,10 @@ The function can also be emulated with a matrix expression, for example:
*/
CV_EXPORTS_W void scaleAdd(InputArray src1, double alpha, InputArray src2, OutputArray dst);
/** @example AddingImagesTrackbar.cpp
/** @example samples/cpp/tutorial_code/HighGUI/AddingImagesTrackbar.cpp
Check @ref tutorial_trackbar "the corresponding tutorial" for more details
*/
*/
/** @brief Calculates the weighted sum of two arrays.
The function addWeighted calculates the weighted sum of two arrays as follows:
@@ -1978,10 +1981,20 @@ CV_EXPORTS_W void calcCovarMatrix( InputArray samples, OutputArray covar,
CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, int maxComponents = 0);
/** wrap PCA::operator() and add eigenvalues output parameter */
CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, OutputArray eigenvalues,
int maxComponents = 0);
/** wrap PCA::operator() */
CV_EXPORTS_W void PCACompute(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, double retainedVariance);
/** wrap PCA::operator() and add eigenvalues output parameter */
CV_EXPORTS_AS(PCACompute2) void PCACompute(InputArray data, InputOutputArray mean,
OutputArray eigenvectors, OutputArray eigenvalues,
double retainedVariance);
/** wrap PCA::project */
CV_EXPORTS_W void PCAProject(InputArray data, InputArray mean,
InputArray eigenvectors, OutputArray result);
@@ -2517,14 +2530,18 @@ public:
Mat mean; //!< mean value subtracted before the projection and added after the back projection
};
/** @example pca.cpp
An example using %PCA for dimensionality reduction while maintaining an amount of variance
*/
/** @example samples/cpp/pca.cpp
An example using %PCA for dimensionality reduction while maintaining an amount of variance
*/
/** @example samples/cpp/tutorial_code/ml/introduction_to_pca/introduction_to_pca.cpp
Check @ref tutorial_introduction_to_pca "the corresponding tutorial" for more details
*/
/**
@brief Linear Discriminant Analysis
@todo document this class
*/
@brief Linear Discriminant Analysis
@todo document this class
*/
class CV_EXPORTS LDA
{
public:
@@ -2840,7 +2857,7 @@ public:
use explicit type cast operators, as in the a1 initialization above.
@param a lower inclusive boundary of the returned random number.
@param b upper non-inclusive boundary of the returned random number.
*/
*/
int uniform(int a, int b);
/** @overload */
float uniform(float a, float b);
@@ -2902,7 +2919,7 @@ public:
Inspired by http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/mt19937ar.c
@todo document
*/
*/
class CV_EXPORTS RNG_MT19937
{
public:
@@ -2920,17 +2937,11 @@ public:
unsigned operator ()(unsigned N);
unsigned operator ()();
/** @brief returns uniformly distributed integer random number from [a,b) range
*/
/** @brief returns uniformly distributed integer random number from [a,b) range*/
int uniform(int a, int b);
/** @brief returns uniformly distributed floating-point random number from [a,b) range
*/
/** @brief returns uniformly distributed floating-point random number from [a,b) range*/
float uniform(float a, float b);
/** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range
*/
/** @brief returns uniformly distributed double-precision floating-point random number from [a,b) range*/
double uniform(double a, double b);
private:
@@ -2944,8 +2955,8 @@ private:
//! @addtogroup core_cluster
//! @{
/** @example kmeans.cpp
An example on K-means clustering
/** @example samples/cpp/kmeans.cpp
An example on K-means clustering
*/
/** @brief Finds centers of clusters and groups input samples around the clusters.
@@ -3057,7 +3068,7 @@ etc.).
Here is example of SimpleBlobDetector use in your application via Algorithm interface:
@snippet snippets/core_various.cpp Algorithm
*/
*/
class CV_EXPORTS_W Algorithm
{
public:
@@ -3073,8 +3084,8 @@ public:
virtual void write(FileStorage& fs) const { (void)fs; }
/** @brief simplified API for language bindings
* @overload
*/
* @overload
*/
CV_WRAP void write(const Ptr<FileStorage>& fs, const String& name = String()) const;
/** @brief Reads algorithm parameters from a file storage
@@ -3082,20 +3093,20 @@ public:
CV_WRAP virtual void read(const FileNode& fn) { (void)fn; }
/** @brief Returns true if the Algorithm is empty (e.g. in the very beginning or after unsuccessful read
*/
*/
CV_WRAP virtual bool empty() const { return false; }
/** @brief Reads algorithm from the file node
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
cv::FileStorage fsRead("example.xml", FileStorage::READ);
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn) and also have static create() method without parameters
(or with all the optional parameters)
*/
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
cv::FileStorage fsRead("example.xml", FileStorage::READ);
Ptr<SVM> svm = Algorithm::read<SVM>(fsRead.root());
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn) and also have static create() method without parameters
(or with all the optional parameters)
*/
template<typename _Tp> static Ptr<_Tp> read(const FileNode& fn)
{
Ptr<_Tp> obj = _Tp::create();
@@ -3105,16 +3116,16 @@ public:
/** @brief Loads algorithm from the file
@param filename Name of the file to read.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
@param filename Name of the file to read.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn).
*/
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::load<SVM>("my_svm_model.xml");
@endcode
In order to make this method work, the derived class must overwrite Algorithm::read(const
FileNode& fn).
*/
template<typename _Tp> static Ptr<_Tp> load(const String& filename, const String& objname=String())
{
FileStorage fs(filename, FileStorage::READ);
@@ -3128,14 +3139,14 @@ public:
/** @brief Loads algorithm from a String
@param strModel The string variable containing the model you want to load.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
@param strModel The string variable containing the model you want to load.
@param objname The optional name of the node to read (if empty, the first top-level node will be used)
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
@endcode
*/
This is static template method of Algorithm. It's usage is following (in the case of SVM):
@code
Ptr<SVM> svm = Algorithm::loadFromString<SVM>(myStringModel);
@endcode
*/
template<typename _Tp> static Ptr<_Tp> loadFromString(const String& strModel, const String& objname=String())
{
FileStorage fs(strModel, FileStorage::READ + FileStorage::MEMORY);
@@ -3146,11 +3157,11 @@ public:
}
/** Saves the algorithm to a file.
In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs). */
CV_WRAP virtual void save(const String& filename) const;
/** Returns the algorithm string identifier.
This string is used as top level xml/yml node tag when the object is saved to a file or string. */
This string is used as top level xml/yml node tag when the object is saved to a file or string. */
CV_WRAP virtual String getDefaultName() const;
protected:
+30 -15
View File
@@ -414,7 +414,7 @@ CV_INLINE CV_NORETURN void errorNoReturn(int _code, const String& _err, const ch
// We need to use simplified definition for them.
#define CV_Error(...) do { abort(); } while (0)
#define CV_Error_( code, args ) do { cv::format args; abort(); } while (0)
#define CV_Assert_1( expr ) do { if (!(expr)) abort(); } while (0)
#define CV_Assert( expr ) do { if (!(expr)) abort(); } while (0)
#else // CV_STATIC_ANALYSIS
@@ -444,7 +444,13 @@ for example:
*/
#define CV_Error_( code, args ) cv::error( code, cv::format args, CV_Func, __FILE__, __LINE__ )
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
/** @brief Checks a condition at runtime and throws exception if it fails
The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros
raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release
configurations while CV_DbgAssert is only retained in the Debug configuration.
*/
#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
//! @cond IGNORED
#define CV__ErrorNoReturn( code, msg ) cv::errorNoReturn( code, msg, CV_Func, __FILE__, __LINE__ )
@@ -454,8 +460,8 @@ for example:
#define CV_Error CV__ErrorNoReturn
#undef CV_Error_
#define CV_Error_ CV__ErrorNoReturn_
#undef CV_Assert_1
#define CV_Assert_1( expr ) if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
#undef CV_Assert
#define CV_Assert( expr ) do { if(!!(expr)) ; else cv::errorNoReturn( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
#else
// backward compatibility
#define CV_ErrorNoReturn CV__ErrorNoReturn
@@ -465,6 +471,18 @@ for example:
#endif // CV_STATIC_ANALYSIS
//! @cond IGNORED
#if defined OPENCV_FORCE_MULTIARG_ASSERT_CHECK && defined CV_STATIC_ANALYSIS
#warning "OPENCV_FORCE_MULTIARG_ASSERT_CHECK can't be used with CV_STATIC_ANALYSIS"
#undef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
#endif
#ifdef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
#define CV_Assert_1( expr ) do { if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ ); } while(0)
#else
#define CV_Assert_1 CV_Assert
#endif
#define CV_Assert_2( expr1, expr2 ) CV_Assert_1(expr1); CV_Assert_1(expr2)
#define CV_Assert_3( expr1, expr2, expr3 ) CV_Assert_2(expr1, expr2); CV_Assert_1(expr3)
#define CV_Assert_4( expr1, expr2, expr3, expr4 ) CV_Assert_3(expr1, expr2, expr3); CV_Assert_1(expr4)
@@ -475,21 +493,18 @@ for example:
#define CV_Assert_9( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ) CV_Assert_8(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8 ); CV_Assert_1(expr9)
#define CV_Assert_10( expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9, expr10 ) CV_Assert_9(expr1, expr2, expr3, expr4, expr5, expr6, expr7, expr8, expr9 ); CV_Assert_1(expr10)
#define CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define CV_VA_NUM_ARGS(...) CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
#define CV_Assert_N(...) do { __CV_CAT(CV_Assert_, __CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__); } while(0)
/** @brief Checks a condition at runtime and throws exception if it fails
#ifdef OPENCV_FORCE_MULTIARG_ASSERT_CHECK
#undef CV_Assert
#define CV_Assert CV_Assert_N
#endif
//! @endcond
The macros CV_Assert (and CV_DbgAssert(expr)) evaluate the specified expression. If it is 0, the macros
raise an error (see cv::error). The macro CV_Assert checks the condition in both Debug and Release
configurations while CV_DbgAssert is only retained in the Debug configuration.
*/
#define CV_Assert(...) do { CVAUX_CONCAT(CV_Assert_, CV_VA_NUM_ARGS(__VA_ARGS__)) (__VA_ARGS__); } while(0)
/** replaced with CV_Assert(expr) in Debug configuration */
#ifdef _DEBUG
#if defined _DEBUG || defined CV_STATIC_ANALYSIS
# define CV_DbgAssert(expr) CV_Assert(expr)
#else
/** replaced with CV_Assert(expr) in Debug configuration */
# define CV_DbgAssert(expr)
#endif
+24 -2
View File
@@ -66,6 +66,7 @@ struct CheckContext {
{ CV__CHECK_FUNCTION, CV__CHECK_FILENAME, __LINE__, testOp, message, p1_str, p2_str }
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v1, const size_t v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v1, const float v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v1, const double v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v1, const int v2, const CheckContext& ctx);
@@ -73,6 +74,7 @@ CV_EXPORTS void CV_NORETURN check_failed_MatType(const int v1, const int v2, con
CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v1, const int v2, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const int v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const size_t v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const float v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_auto(const double v, const CheckContext& ctx);
CV_EXPORTS void CV_NORETURN check_failed_MatDepth(const int v, const CheckContext& ctx);
@@ -120,15 +122,35 @@ CV_EXPORTS void CV_NORETURN check_failed_MatChannels(const int v, const CheckCon
#define CV_CheckChannelsEQ(c1, c2, msg) CV__CHECK(_, EQ, MatChannels, c1, c2, #c1, #c2, msg)
/// Example: type == CV_8UC1 || type == CV_8UC3
#define CV_CheckType(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatType, t, (test_expr), #t, #test_expr, msg)
/// Example: depth == CV_32F || depth == CV_64F
#define CV_CheckDepth(t, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, MatDepth, t, (test_expr), #t, #test_expr, msg)
/// Example: v == A || v == B
#define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
/// Some complex conditions: CV_Check(src2, src2.empty() || (src2.type() == src1.type() && src2.size() == src1.size()), "src2 should have same size/type as src1")
// TODO define pretty-printers: #define CV_Check(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
// TODO define pretty-printers
#ifndef NDEBUG
#define CV_DbgCheck(v, test_expr, msg) CV__CHECK_CUSTOM_TEST(_, auto, v, (test_expr), #v, #test_expr, msg)
#define CV_DbgCheckEQ(v1, v2, msg) CV__CHECK(_, EQ, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckNE(v1, v2, msg) CV__CHECK(_, NE, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckLE(v1, v2, msg) CV__CHECK(_, LE, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckLT(v1, v2, msg) CV__CHECK(_, LT, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckGE(v1, v2, msg) CV__CHECK(_, GE, auto, v1, v2, #v1, #v2, msg)
#define CV_DbgCheckGT(v1, v2, msg) CV__CHECK(_, GT, auto, v1, v2, #v1, #v2, msg)
#else
#define CV_DbgCheck(v, test_expr, msg) do { } while (0)
#define CV_DbgCheckEQ(v1, v2, msg) do { } while (0)
#define CV_DbgCheckNE(v1, v2, msg) do { } while (0)
#define CV_DbgCheckLE(v1, v2, msg) do { } while (0)
#define CV_DbgCheckLT(v1, v2, msg) do { } while (0)
#define CV_DbgCheckGE(v1, v2, msg) do { } while (0)
#define CV_DbgCheckGT(v1, v2, msg) do { } while (0)
#endif
} // namespace
+28 -1
View File
@@ -79,6 +79,8 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
#define __CV_CAT(x, y) __CV_CAT_(x, y)
#endif
#define __CV_VA_NUM_ARGS_HELPER(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10, N, ...) N
#define __CV_VA_NUM_ARGS(...) __CV_VA_NUM_ARGS_HELPER(__VA_ARGS__, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0)
// undef problematic defines sometimes defined by system headers (windows.h in particular)
#undef small
@@ -255,6 +257,7 @@ Cv64suf;
#ifdef __OPENCV_BUILD
# define DISABLE_OPENCV_24_COMPATIBILITY
# define OPENCV_DISABLE_DEPRECATED_COMPATIBILITY
#endif
#ifdef CVAPI_EXPORTS
@@ -346,7 +349,13 @@ Cv64suf;
// We need to use simplified definition for them.
#ifndef CV_STATIC_ANALYSIS
# if defined(__KLOCWORK__) || defined(__clang_analyzer__) || defined(__COVERITY__)
# define CV_STATIC_ANALYSIS
# define CV_STATIC_ANALYSIS 1
# endif
#else
# if defined(CV_STATIC_ANALYSIS) && !(__CV_CAT(1, CV_STATIC_ANALYSIS) == 1) // defined and not empty
# if 0 == CV_STATIC_ANALYSIS
# undef CV_STATIC_ANALYSIS
# endif
# endif
#endif
@@ -405,6 +414,24 @@ Cv64suf;
#endif
/****************************************************************************************\
* CV_NODISCARD attribute *
* encourages the compiler to issue a warning if the return value is discarded (C++17) *
\****************************************************************************************/
#ifndef CV_NODISCARD
# if defined(__GNUC__)
# define CV_NODISCARD __attribute__((__warn_unused_result__)) // at least available with GCC 3.4
# elif defined(__clang__) && defined(__has_attribute)
# if __has_attribute(__warn_unused_result__)
# define CV_NODISCARD __attribute__((__warn_unused_result__))
# endif
# endif
#endif
#ifndef CV_NODISCARD
# define CV_NODISCARD /* nothing by default */
#endif
/****************************************************************************************\
* C++ 11 *
\****************************************************************************************/
@@ -269,6 +269,11 @@ static inline std::ostream& operator << (std::ostream& out, const MatSize& msize
return out;
}
static inline std::ostream &operator<< (std::ostream &s, cv::Range &r)
{
return s << "[" << r.start << " : " << r.end << ")";
}
} // cv
#ifdef _MSC_VER
+283 -324
View File
@@ -60,255 +60,83 @@
// access from within opencv code more accessible
namespace cv {
namespace hal {
enum StoreMode
{
STORE_UNALIGNED = 0,
STORE_ALIGNED = 1,
STORE_ALIGNED_NOCACHE = 2
};
}
template<typename _Tp> struct V_TypeTraits
{
};
#define CV_INTRIN_DEF_TYPE_TRAITS(type, int_type_, uint_type_, abs_type_, w_type_, q_type_, sum_type_, nlanes128_) \
template<> struct V_TypeTraits<type> \
{ \
typedef type value_type; \
typedef int_type_ int_type; \
typedef abs_type_ abs_type; \
typedef uint_type_ uint_type; \
typedef w_type_ w_type; \
typedef q_type_ q_type; \
typedef sum_type_ sum_type; \
enum { nlanes128 = nlanes128_ }; \
\
static inline int_type reinterpret_int(type x) \
{ \
union { type l; int_type i; } v; \
v.l = x; \
return v.i; \
} \
\
static inline type reinterpret_from_int(int_type x) \
{ \
union { type l; int_type i; } v; \
v.i = x; \
return v.l; \
} \
}
CV_INTRIN_DEF_TYPE_TRAITS(uchar, schar, uchar, uchar, ushort, unsigned, unsigned, 16);
CV_INTRIN_DEF_TYPE_TRAITS(schar, schar, uchar, uchar, short, int, int, 16);
CV_INTRIN_DEF_TYPE_TRAITS(ushort, short, ushort, ushort, unsigned, uint64, unsigned, 8);
CV_INTRIN_DEF_TYPE_TRAITS(short, short, ushort, ushort, int, int64, int, 8);
CV_INTRIN_DEF_TYPE_TRAITS(unsigned, int, unsigned, unsigned, uint64, void, unsigned, 4);
CV_INTRIN_DEF_TYPE_TRAITS(int, int, unsigned, unsigned, int64, void, int, 4);
CV_INTRIN_DEF_TYPE_TRAITS(float, int, unsigned, float, double, void, float, 4);
CV_INTRIN_DEF_TYPE_TRAITS(uint64, int64, uint64, uint64, void, void, uint64, 2);
CV_INTRIN_DEF_TYPE_TRAITS(int64, int64, uint64, uint64, void, void, int64, 2);
CV_INTRIN_DEF_TYPE_TRAITS(double, int64, uint64, double, void, void, double, 2);
#ifndef CV_DOXYGEN
#ifdef CV_CPU_DISPATCH_MODE
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE __CV_CAT(hal_, CV_CPU_DISPATCH_MODE)
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) {
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE __CV_CAT(hal_, CV_CPU_DISPATCH_MODE)
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace __CV_CAT(hal_, CV_CPU_DISPATCH_MODE) {
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
#else
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_baseline
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_baseline {
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE hal_baseline
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN namespace hal_baseline {
#define CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END }
#endif
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
using namespace CV_CPU_OPTIMIZATION_HAL_NAMESPACE;
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
#endif
//! @addtogroup core_hal_intrin
//! @{
//! @cond IGNORED
template<typename _Tp> struct V_TypeTraits
{
typedef _Tp int_type;
typedef _Tp uint_type;
typedef _Tp abs_type;
typedef _Tp sum_type;
enum { delta = 0, shift = 0 };
static int_type reinterpret_int(_Tp x) { return x; }
static uint_type reinterpet_uint(_Tp x) { return x; }
static _Tp reinterpret_from_int(int_type x) { return (_Tp)x; }
};
template<> struct V_TypeTraits<uchar>
{
typedef uchar value_type;
typedef schar int_type;
typedef uchar uint_type;
typedef uchar abs_type;
typedef int sum_type;
typedef ushort w_type;
typedef unsigned q_type;
enum { delta = 128, shift = 8 };
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<schar>
{
typedef schar value_type;
typedef schar int_type;
typedef uchar uint_type;
typedef uchar abs_type;
typedef int sum_type;
typedef short w_type;
typedef int q_type;
enum { delta = 128, shift = 8 };
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<ushort>
{
typedef ushort value_type;
typedef short int_type;
typedef ushort uint_type;
typedef ushort abs_type;
typedef int sum_type;
typedef unsigned w_type;
typedef uchar nu_type;
enum { delta = 32768, shift = 16 };
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<short>
{
typedef short value_type;
typedef short int_type;
typedef ushort uint_type;
typedef ushort abs_type;
typedef int sum_type;
typedef int w_type;
typedef uchar nu_type;
typedef schar n_type;
enum { delta = 128, shift = 8 };
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<unsigned>
{
typedef unsigned value_type;
typedef int int_type;
typedef unsigned uint_type;
typedef unsigned abs_type;
typedef unsigned sum_type;
typedef uint64 w_type;
typedef ushort nu_type;
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<int>
{
typedef int value_type;
typedef int int_type;
typedef unsigned uint_type;
typedef unsigned abs_type;
typedef int sum_type;
typedef int64 w_type;
typedef short n_type;
typedef ushort nu_type;
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<uint64>
{
typedef uint64 value_type;
typedef int64 int_type;
typedef uint64 uint_type;
typedef uint64 abs_type;
typedef uint64 sum_type;
typedef unsigned nu_type;
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<int64>
{
typedef int64 value_type;
typedef int64 int_type;
typedef uint64 uint_type;
typedef uint64 abs_type;
typedef int64 sum_type;
typedef int nu_type;
static int_type reinterpret_int(value_type x) { return (int_type)x; }
static uint_type reinterpret_uint(value_type x) { return (uint_type)x; }
static value_type reinterpret_from_int(int_type x) { return (value_type)x; }
};
template<> struct V_TypeTraits<float>
{
typedef float value_type;
typedef int int_type;
typedef unsigned uint_type;
typedef float abs_type;
typedef float sum_type;
typedef double w_type;
static int_type reinterpret_int(value_type x)
{
Cv32suf u;
u.f = x;
return u.i;
}
static uint_type reinterpet_uint(value_type x)
{
Cv32suf u;
u.f = x;
return u.u;
}
static value_type reinterpret_from_int(int_type x)
{
Cv32suf u;
u.i = x;
return u.f;
}
};
template<> struct V_TypeTraits<double>
{
typedef double value_type;
typedef int64 int_type;
typedef uint64 uint_type;
typedef double abs_type;
typedef double sum_type;
static int_type reinterpret_int(value_type x)
{
Cv64suf u;
u.f = x;
return u.i;
}
static uint_type reinterpet_uint(value_type x)
{
Cv64suf u;
u.f = x;
return u.u;
}
static value_type reinterpret_from_int(int_type x)
{
Cv64suf u;
u.i = x;
return u.f;
}
};
template <typename T> struct V_SIMD128Traits
{
enum { nlanes = 16 / sizeof(T) };
};
//! @endcond
//! @}
#ifndef CV_DOXYGEN
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
#endif
}
#ifdef CV_DOXYGEN
# undef CV_AVX2
# undef CV_SSE2
# undef CV_NEON
# undef CV_VSX
# undef CV_FP16
#endif
#if CV_SSE2
@@ -325,27 +153,25 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
#else
#define CV_SIMD128_CPP 1
#include "opencv2/core/hal/intrin_cpp.hpp"
#endif
//! @addtogroup core_hal_intrin
//! @{
// AVX2 can be used together with SSE2, so
// we define those two sets of intrinsics at once.
// Most of the intrinsics do not conflict (the proper overloaded variant is
// resolved by the argument types, e.g. v_float32x4 ~ SSE2, v_float32x8 ~ AVX2),
// but some of AVX2 intrinsics get v256_ prefix instead of v_, e.g. v256_load() vs v_load().
// Correspondingly, the wide intrinsics (which are mapped to the "widest"
// available instruction set) will get vx_ prefix
// (and will be mapped to v256_ counterparts) (e.g. vx_load() => v256_load())
#if CV_AVX2
#include "opencv2/core/hal/intrin_avx.hpp"
#ifndef CV_SIMD128
//! Set to 1 if current compiler supports vector extensions (NEON or SSE is enabled)
#define CV_SIMD128 0
#endif
#ifndef CV_SIMD128_64F
//! Set to 1 if current intrinsics implementation supports 64-bit float vectors
#define CV_SIMD128_64F 0
#endif
//! @}
//==================================================================================================
//! @cond IGNORED
namespace cv {
@@ -354,88 +180,208 @@ namespace cv {
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
#endif
template <typename R> struct V_RegTrait128;
#ifndef CV_SIMD128
#define CV_SIMD128 0
#endif
template <> struct V_RegTrait128<uchar> {
typedef v_uint8x16 reg;
typedef v_uint16x8 w_reg;
typedef v_uint32x4 q_reg;
typedef v_uint8x16 u_reg;
static v_uint8x16 zero() { return v_setzero_u8(); }
static v_uint8x16 all(uchar val) { return v_setall_u8(val); }
#ifndef CV_SIMD128_64F
#define CV_SIMD128_64F 0
#endif
#ifndef CV_SIMD256
#define CV_SIMD256 0
#endif
#ifndef CV_SIMD256_64F
#define CV_SIMD256_64F 0
#endif
#ifndef CV_SIMD512
#define CV_SIMD512 0
#endif
#ifndef CV_SIMD512_64F
#define CV_SIMD512_64F 0
#endif
#ifndef CV_SIMD128_FP16
#define CV_SIMD128_FP16 0
#endif
#ifndef CV_SIMD256_FP16
#define CV_SIMD256_FP16 0
#endif
#ifndef CV_SIMD512_FP16
#define CV_SIMD512_FP16 0
#endif
//==================================================================================================
#define CV_INTRIN_DEFINE_WIDE_INTRIN(typ, vtyp, short_typ, prefix, loadsfx) \
inline vtyp vx_setall_##short_typ(typ v) { return prefix##_setall_##short_typ(v); } \
inline vtyp vx_setzero_##short_typ() { return prefix##_setzero_##short_typ(); } \
inline vtyp vx_##loadsfx(const typ* ptr) { return prefix##_##loadsfx(ptr); } \
inline vtyp vx_##loadsfx##_aligned(const typ* ptr) { return prefix##_##loadsfx##_aligned(ptr); } \
inline vtyp vx_##loadsfx##_low(const typ* ptr) { return prefix##_##loadsfx##_low(ptr); } \
inline vtyp vx_##loadsfx##_halves(const typ* ptr0, const typ* ptr1) { return prefix##_##loadsfx##_halves(ptr0, ptr1); } \
inline void vx_store(typ* ptr, const vtyp& v) { return v_store(ptr, v); } \
inline void vx_store_aligned(typ* ptr, const vtyp& v) { return v_store_aligned(ptr, v); }
#define CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND(typ, wtyp, prefix) \
inline wtyp vx_load_expand(const typ* ptr) { return prefix##_load_expand(ptr); }
#define CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND_Q(typ, qtyp, prefix) \
inline qtyp vx_load_expand_q(const typ* ptr) { return prefix##_load_expand_q(ptr); }
#define CV_INTRIN_DEFINE_WIDE_INTRIN_WITH_EXPAND(typ, vtyp, short_typ, wtyp, qtyp, prefix, loadsfx) \
CV_INTRIN_DEFINE_WIDE_INTRIN(typ, vtyp, short_typ, prefix, loadsfx) \
CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND(typ, wtyp, prefix) \
CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND_Q(typ, qtyp, prefix)
#define CV_INTRIN_DEFINE_WIDE_INTRIN_ALL_TYPES(prefix) \
CV_INTRIN_DEFINE_WIDE_INTRIN_WITH_EXPAND(uchar, v_uint8, u8, v_uint16, v_uint32, prefix, load) \
CV_INTRIN_DEFINE_WIDE_INTRIN_WITH_EXPAND(schar, v_int8, s8, v_int16, v_int32, prefix, load) \
CV_INTRIN_DEFINE_WIDE_INTRIN(ushort, v_uint16, u16, prefix, load) \
CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND(ushort, v_uint32, prefix) \
CV_INTRIN_DEFINE_WIDE_INTRIN(short, v_int16, s16, prefix, load) \
CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND(short, v_int32, prefix) \
CV_INTRIN_DEFINE_WIDE_INTRIN(int, v_int32, s32, prefix, load) \
CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND(int, v_int64, prefix) \
CV_INTRIN_DEFINE_WIDE_INTRIN(unsigned, v_uint32, u32, prefix, load) \
CV_INTRIN_DEFINE_WIDE_LOAD_EXPAND(unsigned, v_uint64, prefix) \
CV_INTRIN_DEFINE_WIDE_INTRIN(float, v_float32, f32, prefix, load) \
CV_INTRIN_DEFINE_WIDE_INTRIN(int64, v_int64, s64, prefix, load) \
CV_INTRIN_DEFINE_WIDE_INTRIN(uint64, v_uint64, u64, prefix, load)
template<typename _Tp> struct V_RegTraits
{
};
template <> struct V_RegTrait128<schar> {
typedef v_int8x16 reg;
typedef v_int16x8 w_reg;
typedef v_int32x4 q_reg;
typedef v_uint8x16 u_reg;
static v_int8x16 zero() { return v_setzero_s8(); }
static v_int8x16 all(schar val) { return v_setall_s8(val); }
};
template <> struct V_RegTrait128<ushort> {
typedef v_uint16x8 reg;
typedef v_uint32x4 w_reg;
typedef v_int16x8 int_reg;
typedef v_uint16x8 u_reg;
static v_uint16x8 zero() { return v_setzero_u16(); }
static v_uint16x8 all(ushort val) { return v_setall_u16(val); }
};
template <> struct V_RegTrait128<short> {
typedef v_int16x8 reg;
typedef v_int32x4 w_reg;
typedef v_uint16x8 u_reg;
static v_int16x8 zero() { return v_setzero_s16(); }
static v_int16x8 all(short val) { return v_setall_s16(val); }
};
template <> struct V_RegTrait128<unsigned> {
typedef v_uint32x4 reg;
typedef v_uint64x2 w_reg;
typedef v_int32x4 int_reg;
typedef v_uint32x4 u_reg;
static v_uint32x4 zero() { return v_setzero_u32(); }
static v_uint32x4 all(unsigned val) { return v_setall_u32(val); }
};
template <> struct V_RegTrait128<int> {
typedef v_int32x4 reg;
typedef v_int64x2 w_reg;
typedef v_uint32x4 u_reg;
static v_int32x4 zero() { return v_setzero_s32(); }
static v_int32x4 all(int val) { return v_setall_s32(val); }
};
template <> struct V_RegTrait128<uint64> {
typedef v_uint64x2 reg;
static v_uint64x2 zero() { return v_setzero_u64(); }
static v_uint64x2 all(uint64 val) { return v_setall_u64(val); }
};
template <> struct V_RegTrait128<int64> {
typedef v_int64x2 reg;
static v_int64x2 zero() { return v_setzero_s64(); }
static v_int64x2 all(int64 val) { return v_setall_s64(val); }
};
template <> struct V_RegTrait128<float> {
typedef v_float32x4 reg;
typedef v_int32x4 int_reg;
typedef v_float32x4 u_reg;
static v_float32x4 zero() { return v_setzero_f32(); }
static v_float32x4 all(float val) { return v_setall_f32(val); }
};
#define CV_DEF_REG_TRAITS(prefix, _reg, lane_type, suffix, _u_reg, _w_reg, _q_reg, _int_reg, _round_reg) \
template<> struct V_RegTraits<_reg> \
{ \
typedef _reg reg; \
typedef _u_reg u_reg; \
typedef _w_reg w_reg; \
typedef _q_reg q_reg; \
typedef _int_reg int_reg; \
typedef _round_reg round_reg; \
}
#if CV_SIMD128 || CV_SIMD128_CPP
CV_DEF_REG_TRAITS(v, v_uint8x16, uchar, u8, v_uint8x16, v_uint16x8, v_uint32x4, v_int8x16, void);
CV_DEF_REG_TRAITS(v, v_int8x16, schar, s8, v_uint8x16, v_int16x8, v_int32x4, v_int8x16, void);
CV_DEF_REG_TRAITS(v, v_uint16x8, ushort, u16, v_uint16x8, v_uint32x4, v_uint64x2, v_int16x8, void);
CV_DEF_REG_TRAITS(v, v_int16x8, short, s16, v_uint16x8, v_int32x4, v_int64x2, v_int16x8, void);
CV_DEF_REG_TRAITS(v, v_uint32x4, unsigned, u32, v_uint32x4, v_uint64x2, void, v_int32x4, void);
CV_DEF_REG_TRAITS(v, v_int32x4, int, s32, v_uint32x4, v_int64x2, void, v_int32x4, void);
#if CV_SIMD128_64F
template <> struct V_RegTrait128<double> {
typedef v_float64x2 reg;
typedef v_int32x4 int_reg;
typedef v_float64x2 u_reg;
static v_float64x2 zero() { return v_setzero_f64(); }
static v_float64x2 all(double val) { return v_setall_f64(val); }
};
CV_DEF_REG_TRAITS(v, v_float32x4, float, f32, v_float32x4, v_float64x2, void, v_int32x4, v_int32x4);
#else
CV_DEF_REG_TRAITS(v, v_float32x4, float, f32, v_float32x4, void, void, v_int32x4, v_int32x4);
#endif
CV_DEF_REG_TRAITS(v, v_uint64x2, uint64, u64, v_uint64x2, void, void, v_int64x2, void);
CV_DEF_REG_TRAITS(v, v_int64x2, int64, s64, v_uint64x2, void, void, v_int64x2, void);
#if CV_SIMD128_64F
CV_DEF_REG_TRAITS(v, v_float64x2, double, f64, v_float64x2, void, void, v_int64x2, v_int32x4);
#endif
#if CV_SIMD128_FP16
CV_DEF_REG_TRAITS(v, v_float16x8, short, f16, v_float16x8, void, void, v_int16x8, v_int16x8);
#endif
#endif
#if CV_SIMD256
CV_DEF_REG_TRAITS(v256, v_uint8x32, uchar, u8, v_uint8x32, v_uint16x16, v_uint32x8, v_int8x32, void);
CV_DEF_REG_TRAITS(v256, v_int8x32, schar, s8, v_uint8x32, v_int16x16, v_int32x8, v_int8x32, void);
CV_DEF_REG_TRAITS(v256, v_uint16x16, ushort, u16, v_uint16x16, v_uint32x8, v_uint64x4, v_int16x16, void);
CV_DEF_REG_TRAITS(v256, v_int16x16, short, s16, v_uint16x16, v_int32x8, v_int64x4, v_int16x16, void);
CV_DEF_REG_TRAITS(v256, v_uint32x8, unsigned, u32, v_uint32x8, v_uint64x4, void, v_int32x8, void);
CV_DEF_REG_TRAITS(v256, v_int32x8, int, s32, v_uint32x8, v_int64x4, void, v_int32x8, void);
CV_DEF_REG_TRAITS(v256, v_float32x8, float, f32, v_float32x8, v_float64x4, void, v_int32x8, v_int32x8);
CV_DEF_REG_TRAITS(v256, v_uint64x4, uint64, u64, v_uint64x4, void, void, v_int64x4, void);
CV_DEF_REG_TRAITS(v256, v_int64x4, int64, s64, v_uint64x4, void, void, v_int64x4, void);
CV_DEF_REG_TRAITS(v256, v_float64x4, double, f64, v_float64x4, void, void, v_int64x4, v_int32x8);
#if CV_SIMD256_FP16
CV_DEF_REG_TRAITS(v256, v_float16x16, short, f16, v_float16x16, void, void, v_int16x16, void);
#endif
#endif
#if CV_SIMD512 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 512)
#define CV__SIMD_NAMESPACE simd512
namespace CV__SIMD_NAMESPACE {
#define CV_SIMD 1
#define CV_SIMD_64F CV_SIMD512_64F
#define CV_SIMD_WIDTH 64
// TODO typedef v_uint8 / v_int32 / etc types here
} // namespace
using namespace CV__SIMD_NAMESPACE;
#elif CV_SIMD256 && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 256)
#define CV__SIMD_NAMESPACE simd256
namespace CV__SIMD_NAMESPACE {
#define CV_SIMD 1
#define CV_SIMD_64F CV_SIMD256_64F
#define CV_SIMD_FP16 CV_SIMD256_FP16
#define CV_SIMD_WIDTH 32
typedef v_uint8x32 v_uint8;
typedef v_int8x32 v_int8;
typedef v_uint16x16 v_uint16;
typedef v_int16x16 v_int16;
typedef v_uint32x8 v_uint32;
typedef v_int32x8 v_int32;
typedef v_uint64x4 v_uint64;
typedef v_int64x4 v_int64;
typedef v_float32x8 v_float32;
#if CV_SIMD256_64F
typedef v_float64x4 v_float64;
#endif
#if CV_FP16
#define vx_load_fp16_f32 v256_load_fp16_f32
#define vx_store_fp16 v_store_fp16
#endif
#if CV_SIMD256_FP16
typedef v_float16x16 v_float16;
CV_INTRIN_DEFINE_WIDE_INTRIN(short, v_float16, f16, v256, load_f16)
#endif
CV_INTRIN_DEFINE_WIDE_INTRIN_ALL_TYPES(v256)
CV_INTRIN_DEFINE_WIDE_INTRIN(double, v_float64, f64, v256, load)
inline void vx_cleanup() { v256_cleanup(); }
} // namespace
using namespace CV__SIMD_NAMESPACE;
#elif (CV_SIMD128 || CV_SIMD128_CPP) && (!defined(CV__SIMD_FORCE_WIDTH) || CV__SIMD_FORCE_WIDTH == 128)
#define CV__SIMD_NAMESPACE simd128
namespace CV__SIMD_NAMESPACE {
#define CV_SIMD CV_SIMD128
#define CV_SIMD_64F CV_SIMD128_64F
#define CV_SIMD_FP16 CV_SIMD128_FP16
#define CV_SIMD_WIDTH 16
typedef v_uint8x16 v_uint8;
typedef v_int8x16 v_int8;
typedef v_uint16x8 v_uint16;
typedef v_int16x8 v_int16;
typedef v_uint32x4 v_uint32;
typedef v_int32x4 v_int32;
typedef v_uint64x2 v_uint64;
typedef v_int64x2 v_int64;
typedef v_float32x4 v_float32;
#if CV_SIMD128_64F
typedef v_float64x2 v_float64;
#endif
#if CV_FP16
#define vx_load_fp16_f32 v128_load_fp16_f32
#define vx_store_fp16 v_store_fp16
#endif
#if CV_SIMD128_FP16
typedef v_float16x8 v_float16;
CV_INTRIN_DEFINE_WIDE_INTRIN(short, v_float16, f16, v, load_f16)
#endif
CV_INTRIN_DEFINE_WIDE_INTRIN_ALL_TYPES(v)
#if CV_SIMD128_64F
CV_INTRIN_DEFINE_WIDE_INTRIN(double, v_float64, f64, v, load)
#endif
inline void vx_cleanup() { v_cleanup(); }
} // namespace
using namespace CV__SIMD_NAMESPACE;
#endif
inline unsigned int trailingZeros32(unsigned int value) {
@@ -465,6 +411,19 @@ inline unsigned int trailingZeros32(unsigned int value) {
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
#endif
#ifndef CV_SIMD_64F
#define CV_SIMD_64F 0
#endif
#ifndef CV_SIMD_FP16
#define CV_SIMD_FP16 0 //!< Defined to 1 on native support of operations with float16x8_t / float16x16_t (SIMD256) types
#endif
#ifndef CV_SIMD
#define CV_SIMD 0
#endif
} // cv::
//! @endcond
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More