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

Compare commits

...

227 Commits

Author SHA1 Message Date
Maksim Shabunin 81e7c7d8c8 OpenVINO version bump 2018-12-10 14:44:53 +03:00
Alexander Alekhin ea64e860de Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-12-09 13:21:58 +00:00
Rijubrata Bhaumik e70786e05e Merge pull request #13300 from riju:photoModule
* Enable Javascript bindings for photo module.

1. Enable the build flag in build_js.py.
2. Append js into WRAP list of photo’s CMakefiles.txt
3. Add photo module's API into JS API whitelist (embindgen.py)

Exposing the HDR imaging part of photo module.

[TODO]
Add tests
Fix opencv/doc/js_tutorials/

* [WIP] TODO: Add tests

* Remove TonemapDurand: algorithm patented in US, so moved to opencv_contrib

* Fix ningxin's comment: expose the base class.

* Add some more simple binding tests.

Also expose process function
2018-12-09 15:08:59 +03:00
LaurentBerger f1dc26d7ce Merge pull request #13382 from LaurentBerger:imreadsize
* try to solve #13381

* Add note
2018-12-09 15:05:27 +03:00
Alexander Alekhin 40a53e3d64 Merge pull request #13388 from alalek:ocl_fix_perf_stitching 2018-12-08 17:51:47 +00:00
Alexander Alekhin e5f298cca5 Merge pull request #13385 from alalek:cmake_cleanup_build_junk_dir 2018-12-08 17:51:09 +00:00
Alexander Alekhin 85b1750660 Merge pull request #13316 from alalek:cmake_fix_baseline_detect 2018-12-08 17:50:03 +00:00
Alexander Alekhin 92e86292dd Merge pull request #13389 from dkurt:dnn_tf_eltwise_sub 2018-12-07 13:54:09 +00:00
Maksim Shabunin 05131af8da Merge pull request #13367 from mshabunin:cmake-verify
* Added dependency verification mechanism for cmake
2018-12-07 15:57:25 +03:00
Dmitry Kurtaev 8422dda2c7 Element-wise subtraction from TensorFlow 2018-12-07 13:38:05 +03:00
Alexander Alekhin 606622ab36 stitching(perf): increase threshold of transform vector 2018-12-07 13:22:39 +03:00
Alexander Alekhin d77612fe70 cmake: hide 'junk' dir from the root of build directory
moved to CMakeFiles (no conflicts are expected)
2018-12-07 05:14:08 +00:00
Alexander Alekhin cab15f6c5e Merge pull request #13377 from dkurt:hotfix_dnn_ie_master 2018-12-06 15:11:09 +00:00
Alexander Alekhin 492a072ea8 Merge pull request #13376 from dkurt:hotfix_dnn_ie 2018-12-06 15:09:51 +00:00
Alexander Alekhin e82e672a93 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-12-06 07:06:58 +00:00
Dmitry Kurtaev 93971a53d9 Exclude Input layer from list of outputs for IE networks 2018-12-06 09:12:05 +03:00
Dmitry Kurtaev 3868cb44f1 Exclude Input layer from list of outputs for IE networks 2018-12-06 09:08:50 +03:00
Alexander Alekhin 6fbf6f8bea Merge pull request #13359 from dkurt:dnn_keras_pad_concat 2018-12-05 19:48:58 +00:00
Alexander Alekhin e090ea3efd Merge pull request #13370 from alalek:ocl_update_perf_stitching_matchers_threshold 2018-12-05 19:46:12 +00:00
Alexander Alekhin a618d8bc9e stitching(perf): update test threshold 2018-12-05 18:59:30 +00:00
Tsukasa Sugiura 09b3dcb6db Merge pull request #13341 from UnaNancyOwen:fix_librealsense
* videoio(librealsense): fix pipeline start with config

fix to apply pipeline settings by passing config to start.

* videoio(librealsense): add support get props

add support get some props.
2018-12-05 20:12:25 +03:00
Alexander Alekhin f26e86e4d8 Merge pull request #13369 from alalek:fixup_13332 2018-12-05 17:02:02 +00:00
Alexander Alekhin 9ff1c39daa dnn: fixup available backends/targets 2018-12-05 19:19:17 +03:00
okriof ef42baf9f0 Merge pull request #13361 from okriof:brisk_getset
* Get/Set functions for BRISK parameters, issue #11527.

Allows setting threshold and octaves parameters after creating a brisk object. These parameters do not affect the initial pattern initialization and can be changed later without re-initialization.

* Fix doc parameter name.

* Brisk get/set functions tests. Check for correct value and make tests independent of default parameter values.

* Add dummy implementations for BRISK get/set functions not to break API in case someone has overloaded the Feature2d::BRISK interface. This makes BRISK different from the other detectors/descriptors on the other hand, where get/set functions are pure virtual in the interface.
2018-12-05 18:44:23 +03:00
Maksim Shabunin fe459c82e5 Merge pull request #13332 from mshabunin:dnn-backends
DNN backends registry (#13332)

* Added dnn backends registry

* dnn: process DLIE/FPGA target
2018-12-05 18:11:45 +03:00
Alexander Alekhin cdf906b233 Merge pull request #12945 from terfendail:core_wintr_full 2018-12-05 12:52:03 +00:00
Alexander Alekhin ead7bc883d Merge pull request #13364 from nglee:dev_FixLineIteratorExample 2018-12-05 10:09:48 +00:00
Alexander Alekhin e55ad25355 Merge pull request #13363 from kartikmohta:patch-1 2018-12-05 09:50:09 +00:00
Alexander Alekhin 838624bf53 Merge pull request #13362 from alalek:photo_move_durand_contrib 2018-12-05 09:46:30 +00:00
Namgoo Lee 83c7dfb6a4 Fix error in LineIterator example code in doc 2018-12-05 11:31:19 +09:00
Kartik Mohta 80a3d7bffa Fix comment marker in OpenCVDetectCudaArch.cu 2018-12-04 11:47:28 -08:00
Dmitry Kurtaev c9e0c77d73 Concat layer from TensorFlow with constant inputs 2018-12-04 19:41:40 +03:00
Alexander Alekhin 742f22c09b photo: move TonemapDurand to opencv_contrib 2018-12-04 18:59:27 +03:00
Maksim Shabunin 6481397710 Merge pull request #13358 from terfendail:disflow_warn 2018-12-04 14:21:43 +00:00
Vitaly Tuzov 6ad8a9c09d Replaced core module calls to universal intrinsics with wide universal intrinsics 2018-12-04 16:24:20 +03:00
Vitaly Tuzov 388ccda85d Fixed static analyzer warnings in DISOpticalFlow 2018-12-04 12:57:14 +03:00
Alexander Alekhin 2e0150e601 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-12-03 18:38:27 +03:00
Alexander Alekhin aee865fec9 Merge pull request #13352 from alalek:issue_13324 2018-12-03 15:34:23 +00:00
Alexander Alekhin 2dc5e245d0 Merge pull request #13350 from alalek:fix_kw_gapi 2018-12-03 15:16:45 +00:00
Alexander Alekhin ea3a5950a3 Merge pull request #13346 from alalek:fix_kw_persistence 2018-12-03 15:16:31 +00:00
Alexander Alekhin 0d439a9879 Merge pull request #13351 from mshabunin:fix-va-compile 2018-12-03 15:15:55 +00:00
Alexander Alekhin 99f6f8ea9d Merge pull request #13348 from alalek:kw_videoio_v4l 2018-12-03 14:45:03 +00:00
Alexander Alekhin 39e448f7be Merge pull request #13347 from alalek:kw_resize_check 2018-12-03 14:44:41 +00:00
Alexander Alekhin 80c2adbda1 core: add getcwd() stub 2018-12-03 17:38:57 +03:00
Maksim Shabunin c26c43c69c Fixed compilation with VA-interop on 32-bit platforms 2018-12-03 17:16:09 +03:00
Alexander Alekhin 4e8311085f core(persistence): fix KW issues 2018-12-03 17:10:20 +03:00
Alexander Alekhin cf0be1a0af Merge pull request #13349 from mshabunin:fix-highgui-test 2018-12-03 13:06:09 +00:00
Alexander Alekhin 26d2095dd6 videoio(v4l): initialize members in ctor 2018-12-03 15:22:20 +03:00
Alexander Alekhin c577c2cc6a gapi: eliminate KW issues 2018-12-03 15:20:47 +03:00
Maksim Shabunin 905d96dd4a Restored 500ms delay in highgui test 2018-12-03 14:34:29 +03:00
Alexander Alekhin 2d5ccc7b3e imgproc(resize): update checks (static analyzers) 2018-12-03 13:13:48 +03:00
Alexander Alekhin a0fed8d9ea Merge pull request #13338 from alalek:fix_resize_bitexact_test 2018-11-30 15:46:33 +00:00
Alexander Alekhin 4e29e2fc7d imgproc(test): fix resize bitexact test
- use "random" area on input image
- avoid duplicate cases
2018-11-30 16:38:07 +03:00
Alexander Alekhin a811059bfb Merge pull request #13336 from sergiud:core_sse_immediates_gcc-5.4.0 2018-11-30 09:51:59 +00:00
Sergiu Deitsch e43a5ff9be fixed gcc 5.4.0 compilation errors 2018-11-30 08:48:19 +01:00
Vitaly Tuzov 00c9ab8c23 Merge pull request #13317 from terfendail:norm_wintr
* Added performance tests for hal::norm functions

* Added sum of absolute differences intrinsic

* norm implementation updated to use wide universal intrinsics

* improve and fix v_reduce_sad on VSX
2018-11-29 19:34:14 +03:00
Alexander Alekhin 197285d12a Merge pull request #13331 from dbudniko:dbudniko/gapi_gpu_to_ocl_renaming_patch 2018-11-29 15:39:14 +00:00
Evgeny Latkin ab430b8c87 Merge pull request #13329 from elatkin:el/gapi_perf_medblur
GAPI (fluid): Median blur optimization (#13329)

* GAPI (fluid): Median blur optimization: reference 3x3

* GAPI (fluid): Median blur optimization: CPU dispatcher

* GAPI (fluid): Median blur optimization: manual CV_SIMD
2018-11-29 18:02:29 +03:00
Dmitry Budnikov d1029faa90 patch removes gpu mention from ocl backend 2018-11-29 17:05:41 +03:00
Dmitry Budnikov 6374b99a1a Merge pull request #13240 from dbudniko:dbudniko/gapi_gpu_to_ocl_renaming
G-API rename GPU backend to OCL backend (#13240)

* renaming draft

* inline namespace instead non-safe define

* more back compatibility

* Updates after review from Dmitry
2018-11-29 16:29:11 +03:00
Alexander Alekhin ccf96b9e05 Merge pull request #13323 from alalek:issue_13297 2018-11-29 12:40:03 +00:00
Alexander Alekhin 3fe70d5cd5 Merge pull request #13327 from allnes:qrcode_modifications 2018-11-29 12:39:06 +00:00
Alexander Nesterov adb630ba3a Corrected parameters 2018-11-29 11:57:45 -01:00
Alexander Alekhin 5ed7d5a5d9 imgproc: local "CV_Assert(totalSampleCount > 0)" check 2018-11-28 20:16:37 +00:00
Alexander Alekhin 4fb9bce79f Merge pull request #13264 from mshabunin:fix-windows 2018-11-28 20:00:04 +00:00
Alexander Alekhin 487f631243 Merge pull request #13320 from alalek:api_checks_4.0.0 2018-11-28 19:51:29 +00:00
Alexander Alekhin 1f7728db35 Merge pull request #13322 from akashivskyy:pr/iossim-archs 2018-11-28 19:34:25 +00:00
Adrian Kashivskyy b7c134617d Add ability to specify iPhoneSimulator ARCHS 2018-11-28 19:27:20 +01:00
Evgeny Latkin c928c21fe7 Merge pull request #13319 from elatkin:el/gapi_perf_erdilate_2
GAPI (fluid): Erode/Dilate optimization, part 2 (#13319)

* GAPI (fluid): Erode/Dilate optimization: hard-code 3x3 case

* GAPI (fluid): Erode/Dilate optimization: CPU dispatcher

* GAPI (fluid): Erode/Dilate optimization: speed-up 10-15x times with CV_SIMD

* GAPI (fluid): Erode/Dilate optimization: 20-30% speed-up
2018-11-28 19:50:39 +03:00
Alexander Alekhin 59fa477edb opencv4: fix abi-checker (to enable API/source checks only) 2018-11-28 18:42:19 +03:00
Evgeny Latkin 992d5b8bcd Merge pull request #13315 from elatkin:el/gapi_perf_erdilate
GAPI (fluid): Erode/Dilate optimization (#13315)

* GAPI (fluid): Erode/Dilate optimization: hard-code 3x3 case

* GAPI (fluid): Erode/Dilate optimization: CPU dispatcher

* GAPI (fluid): Erode/Dilate optimization: speed-up 10-15x times with CV_SIMD
2018-11-28 18:20:31 +03:00
Alexander Alekhin fab0eb0d75 cmake: fix compiler flags (CPU_BASELINE_REQUIRED=xxx + CPU_BASELINE=DETECT) 2018-11-28 14:04:03 +03:00
Evgeny Latkin 6808d33b2f Merge pull request #13290 from elatkin:el/gapi_perf_filter2d
GAPI (fluid): Filter 2D optimization (#13290)

* GAPI (fluid): Filter 2D optimization: speedup 13x if float, 2x if integral

* GAPI (fluid): Filter 2D speedup 8x if output is short/ushort

* GAPI (fluid): Filter 2D speedup 7x if output is uchar

* GAPI (fluid): Filter 2D optimization: fixed compiler warnings

* GAPI (fluid): fix compiler warnings on Mac

* GAPI (fluid): fix compiler warnings on Mac

* GAPI (fluid): fix compiler errors on VS2015

* GAPI (fluid): fix compiler errors on VS2015

* GAPI (fluid): fix compiler errors on VS2015
2018-11-27 19:12:14 +03:00
Alexander Alekhin 65f22292ed Merge pull request #13298 from mshabunin:fix-intrin-indent 2018-11-27 13:58:02 +00:00
Alexander Alekhin b1064efb44 Merge pull request #13294 from terfendail:contours_wintr 2018-11-27 13:54:23 +00:00
Alexander Alekhin df96159eb6 Merge pull request #13301 from alalek:build_warnings 2018-11-27 13:53:02 +00:00
Maksim Shabunin 89f0e0a8d1 Fixed misleading indentation in intrin_cpp.hpp 2018-11-27 15:29:37 +03:00
Maksim Shabunin 966f27df34 Merge pull request #13293 from dkurt:dnn_add_extra_ie_net_method 2018-11-27 12:26:09 +00:00
Alexander Alekhin 83c8214b38 eliminate build warnings 2018-11-27 15:24:59 +03:00
Alexander Alekhin 21bb17e3ee Merge pull request #13292 from mshabunin:fix-filenode-compat 2018-11-27 10:56:23 +00:00
Dmitry Kurtaev 4ba4901ca9 Add serialize method for IE net wrapper 2018-11-27 12:02:00 +03:00
Maksim Shabunin 9de63c1edd Made FileNode::operator string inline 2018-11-27 11:47:23 +03:00
Vitaly Tuzov e991e05b9b Added anonymous namespace to perf_contours 2018-11-27 11:35:40 +03:00
Dmitry Budnikov 51cc78b2a2 Merge pull request #13251 from dbudniko:dbudniko/gapi_more_fixes_for_tests
More fixes for G-API tests (#13251)

* scalar comparator and more fixes for tests

* add weighted aligned

* white space

* more white space

* Add weighted test accuracy check enabled
2018-11-26 17:44:46 +03:00
Alexander Alekhin 8f4e5c2fb8 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-11-26 15:37:45 +03:00
Alexander Alekhin 223893ea5a Merge pull request #13242 from terfendail:contours_wintr 2018-11-26 12:29:31 +00:00
Maksim Shabunin db1c8b3f9e Restored function to rescale pixel values before imshow 2018-11-26 15:25:05 +03:00
Alexander Alekhin 5bd1cc44ec Merge pull request #13280 from dkurt:enable_dnn_ie_r4_tests 2018-11-26 12:24:17 +00:00
Evgeny Latkin f07856eab9 Merge pull request #13221 from elatkin:el/gapi_perf_sepfilter
GAPI (fluid): optimization of Separable filter (#13221)

* GAPI (fluid): Separable filter: performance test

* GAPI (fluid): enable all performance tests

* GAPI: separable filters: alternative code for Sobel

* GAPI (fluid): hide unused old code for Sobel filter

* GAPI (fluid): especial code for Sobel if U8 into S16

* GAPI (fluid): back to old code for Sobel

* GAPI (fluid): run_sepfilter3x3_impl() with CPU dispatcher

* GAPI (fluid): run_sepfilter3x3_impl(): fix compiler warnings

* GAPI (fluid): new engine for separable filters (but Sobel)

* GAPI (fluid): new performance engine for Sobel

* GAPI (fluid): Sepfilters performance: fixed compilation error
2018-11-26 15:05:35 +03:00
Matthias Winkelmann 24acd5fb83 Merge pull request #13228 from MatthiasWinkelmann:master
Add URLs, harmonise formatting, and fix parse error in bibliography (#13228)

* Fixed parse error in bibliography

* Removed extra curly braces

* harmonized whitespace

* changed organisation -> publisher where appropriate. Organisation is intended as the author's organisation, not the publishing.

* harmonized capitalisation and whitespace

* Add links to about 1/3 of references
2018-11-26 15:04:16 +03:00
Dmitry Kurtaev 84ce2cc211 Enable some dnn tests according to the new Intel's Inference Engine release (R4) 2018-11-26 13:02:24 +03:00
Alexander Alekhin 37d064f553 Merge pull request #13279 from mshabunin:fix-carotene-build-3.4 2018-11-26 09:30:32 +00:00
Alexander Alekhin dd952f6d68 Merge pull request #13278 from mshabunin:fix-carotene-build 2018-11-26 09:29:48 +00:00
Alexander Alekhin e63efe2978 Merge pull request #13275 from wzw-intel:thread_safe 2018-11-26 09:15:09 +00:00
Maksim Shabunin 26cb154f40 Fixed NEON detection in Carotene build 2018-11-26 11:33:18 +03:00
Maksim Shabunin fb6929ac3d Fixed NEON detection in Carotene build 2018-11-26 11:30:20 +03:00
Wu Zhiwen 4e65283081 dnn/Vulkan: make thread safe
Use a global dedicated mutex to make sure initialize once and
protect command buffer pool and queue.

Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>
2018-11-26 14:08:37 +08:00
Alexander Alekhin ca5455c592 Merge pull request #13270 from 1over:flann_dist_fix 2018-11-25 18:27:42 +00:00
Alexander Alekhin 82f4322d18 Merge pull request #13269 from alalek:ocl_fix_kernels_with_use_host_mem 2018-11-25 18:27:01 +00:00
Alexander Alekhin 36b6bcb674 Merge pull request #13268 from alalek:core_findfile_linux_use_dladdr 2018-11-25 18:26:28 +00:00
Alexander Alekhin 5a804e3c74 Merge pull request #13254 from alalek:update_python_install_path 2018-11-25 18:25:48 +00:00
1over 5ff76088b9 fixed memory issue in flann 2018-11-25 01:31:54 +01:00
Alexander Alekhin 9fd822f97e ocl: fix kernels launching with USE_HOST_PTR UMat
created from RAW memory buffers (without proper lifetime management)
2018-11-24 15:37:16 +00:00
Alexander Alekhin 3c49b1dbbe core: use dladdr() instead of parsing /proc/self/maps 2018-11-24 15:22:54 +00:00
Alexander Alekhin ad35b79e3f python: update install paths
- don't require "OPENCV_PYTHON{2,3}_INSTALL_PATH" if OPENCV_SKIP_PYTHON_LOADER=ON
- avoid unnecessary relative paths in generated config-X.Y.py
2018-11-24 13:55:46 +00:00
Alexander Alekhin 342366e314 Merge pull request #13263 from dkurt:dnn_refactor_tests 2018-11-23 17:12:01 +00:00
Alexander Alekhin c6daa4aa16 Merge pull request #13260 from alalek:cmake_ade_12856 2018-11-23 17:09:47 +00:00
Alexander Alekhin c0016d7fe9 Merge pull request #13253 from alalek:fix_13201
* cmake: install 'legacy/constants_c.h' files

* samples: add compatibility test code
2018-11-23 20:02:46 +03:00
Dmitry Kurtaev 2f6f52d644 Fix ONNX's emotion_ferplus model.
Reduce input size for OpenPose tests
2018-11-23 19:00:17 +03:00
Dmitry Budnikov a518e7063d Merge pull request #13120 from dbudniko:dbudniko/gapi_opencl_kernel_example
* custom OpenCL G-API kernel draft

* clean up and warnings fix

* more warnings

* white space

* new blank line at the EOF removed

* HAVE_OPENCL guard

* remove unnecessary ocl API call

* remove sum test workaround

* check if opencl activated

* fix std::str warning

* CPU fall back for symm7x7

* gpu test kernel draft

* adjust have opencl guard

* more guards

* one more attempt to adjust guards

* empty stub files and kernel source files creation in the test directory

* try to force auto generation

* one more attempt to force build

* remove symm7x7 custom from gapi module

* looks like that this version works properly on Win desktop

* clean up

* more clean up

* address some suggestions from Dmitry's review

* const kernel coefficients

* CV_Error in kernel + try to fix cpu fallback

* CV_Error_ instead CV_Error

* everything in one gapi_gpu_test.cpp

* fix warning

* remove kernel generation, add kernel string

* avoid generated code and ocl internal namespace

* fix misprint

* c_str
2018-11-23 17:51:15 +03:00
Alexander Alekhin de8696aa43 cmake: allow to disable ADE build too (BUILD_opencv_gapi=OFF is not enough)
CMake option: WITH_ADE=OFF
2018-11-23 12:52:41 +03:00
WuZhiwen 02cc1cd6e6 Merge pull request #13244 from wzw-intel:init_vulkan
* dnn/Vulkan: don't init Vulkan runtime if using other backend/target

Don't need to explictly call a init API but will automatically
init Vulkan environment the first time to use an VkCom object.

Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>

* dnn/Vulkan: depress compilier warning for "-Wsign-promo"

Signed-off-by: Wu Zhiwen <zhiwen.wu@intel.com>
2018-11-22 19:46:30 +03:00
Alexander Alekhin dc80f9d0fb Merge pull request #13243 from etienne02:3.4 2018-11-22 16:05:14 +00:00
Alexander Alekhin 0e6cf41923 Merge pull request #13241 from pasbi:master 2018-11-22 17:18:23 +03:00
Alexander Alekhin ad0d812aa0 Merge pull request #13239 from bramton:freebsd-build-fix 2018-11-22 14:17:35 +00:00
Bram 724620b476 Fixed build on FreeBSD 2018-11-22 09:23:09 +01:00
Etienne Brateau 736683ce2f Fix missing check part (defined(__cplusplus)) in header types_c.h 2018-11-22 01:39:09 +01:00
pascal 7579cd8068 updated documentation for imread and imwrite (added pfm image format) 2018-11-21 17:59:37 +01:00
Vitaly Tuzov e9e8bf4b81 Added performance tests for findContours 2018-11-21 19:57:02 +03:00
Vitaly Tuzov e1a2c034e8 Updated findContours to use wide universal intrinsics 2018-11-21 19:57:02 +03:00
Alexander Alekhin 6b346c92be Merge pull request #13236 from tomoaki0705:featureHighguiGetProp 2018-11-21 15:55:00 +00:00
Alexander Alekhin b6a447798a Merge pull request #13235 from berak:highgui_window_w32 2018-11-21 15:54:42 +00:00
Alexander Alekhin adf2013052 Merge pull request #13209 from alalek:issue_12865 2018-11-21 14:30:32 +00:00
Tomoaki Teshima a1c073d289 add missing API cvGetPropVisible_W32 2018-11-21 23:04:23 +09:00
berak 9344d0d0e3 highgui: restore convertscale semantics in window_w32.cpp 2018-11-21 11:05:24 +01:00
Alexander Alekhin 7fa7fa0226 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-11-21 08:33:39 +00:00
Alexander Alekhin 45d2e18808 Merge pull request #13232 from huangqinjin:openmp 2018-11-21 08:32:14 +00:00
huangqinjin e1ac8589f8 fix numThreadsMax for OpenMP
introduced by commit 4e62900009
2018-11-21 10:54:24 +08:00
Alexander Alekhin 6e67fd2752 Merge pull request #13224 from seiko2plus:core_ppc64le_infa 2018-11-20 21:26:05 +00:00
Sayed Adel 474a0dac49 core: several improves and fixes on ppc64le infrastructure
- add infrastructure support for Power9/VSX3
  - fix missing VSX flags on GCC4.9 and CLANG4(#13210, #13222)
  - fix disable VSX optimzation on GCC by using flag ENABLE_VSX
  - flag ENABLE_VSX is deprecated now, use CPU_BASELINE, CPU_DISPATCH instead
  - add VSX3 to arithmetic dispatchable flags
2018-11-20 15:28:46 +00:00
Alexander Alekhin 495cadddbd Merge pull request #13223 from dan-masek:fix_drawmatches_alpha 2018-11-20 14:59:35 +00:00
Alexander Alekhin 60b13d50c9 Merge pull request #13214 from 1over:fix_rect 2018-11-20 14:55:42 +00:00
Alexander Alekhin eaf39f6b6b Merge pull request #13213 from alalek:fix_format 2018-11-20 14:53:20 +00:00
Ruslan Garnov a3df05d93b Merge pull request #13215 from rgarnov:rg/overhead
* Added caching of agents execution sequence

* Merged linesRead() and nextWindow() methods on FluidAgent in one method

* Added caching of input lines for fluid::View

* Added caching of output lines for fluid::Buffer

* Fixed GAPI_Assert to work in standalone mode
2018-11-20 17:25:04 +03:00
Dan Mašek 2075fa9c15 Resolve #13219: Make randomly generated colours opaque. 2018-11-20 15:08:40 +01:00
Alexander Alekhin 798e2779f2 Merge pull request #13218 from dmatveev:fix_standalone 2018-11-20 13:25:13 +00:00
Dmitry Matveev 1b13df5368 G-API: Recent inclusion has broken STANDALONE build
This MR fixes this.
2018-11-20 14:00:08 +03:00
1over b6367f5821 fixed operator- for Rect 2018-11-20 00:48:17 +01:00
Alexander Alekhin d7272f76fb dnn: fix format 2018-11-19 19:33:56 +00:00
Alexander Alekhin 1317c3d178 cmake: don't generate dllmain for cudev module 2018-11-19 19:11:52 +03:00
Alexander Alekhin 36432cf4d9 Merge pull request #13181 from dkurt:ocv_dnn_fpga 2018-11-19 16:03:20 +00:00
Alexander Alekhin 605071e76f Merge pull request #13146 from terfendail:bilateral_nan 2018-11-19 15:59:12 +00:00
Alexander Alekhin 94d7c0f7f5 Merge pull request #13144 from dkurt:update_tf_mask_rcnn 2018-11-19 15:55:35 +00:00
Evgeny Latkin 083332f85f Merge pull request #13206 from elatkin:el/gapi_perf_rgb2lab
GAPI (fluid): RGB to Lab optimization (#13206)

* GAPI (fluid): BGR2LUV, RGB2Lab: performance test

* GAPI (fluid): BGR2LUV, RGB2Lab: using cv::hal::cvtBGRtoLab

* GAPI (fluid): BGR2LUV, RGB2Lab: hide reference code with #ifdef
2018-11-19 18:52:48 +03:00
Evgeny Latkin 6757c2c5a6 Merge pull request #13174 from elatkin:el/gapi_perf_rgb2yuv
GAPI (fluid): RGB to YUV optimization (#13174)

* GAPI (fluid): RGB to YUV: activate performance tests

* GAPI (fluid): speedup 4-8x RGB-to-YUV, 2.5x YUV to RGB with int16 arithmetic

* GAPI (fluid): RGB <--> YUV: fixed compiler warning

* GAPI (fluid): RGB <--> YUV: additional speedup 2-3x times (10-15x over original) via manual CV_SIMD

* GAPI (fluid): RGB <--> YUV: dynamic CV_SIMD dispatching
2018-11-19 17:30:14 +03:00
Dmitry Kurtaev 0d117312c9 DNN_TARGET_FPGA using Intel's Inference Engine 2018-11-19 11:41:43 +03:00
Alexander Alekhin 59e2ca16d9 Merge tag '4.0.0'
OpenCV 4.0.0
2018-11-18 09:22:00 +00:00
Alexander Alekhin 75ed282b20 release: OpenCV 4.0.0 (version++) 2018-11-18 09:19:28 +00:00
Alexander Alekhin 754956857c Merge tag '4.0.0-openvino'
OpenCV 4.0.0 for Intel(R) OpenVINO(TM) toolkit
2018-11-18 09:19:04 +00:00
Alexander Alekhin a4ab60920f Merge pull request #13195 from alalek:legacy_constants 2018-11-18 01:36:44 +00:00
Alexander Alekhin a574788e89 move legacy C-API constants into separate files 2018-11-17 23:47:51 +00:00
Alexander Alekhin 22dbcf98c5 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-11-17 14:17:35 +00:00
Alexander Alekhin 183bc5c281 Merge tag '3.4.4'
OpenCV 3.4.4
2018-11-17 13:00:28 +00:00
Alexander Alekhin a1fe8f754f OpenCV version++ (3.4.4)
OpenCV 3.4.4
2018-11-17 10:22:17 +00:00
Alexander Alekhin dd3398416b experimental version++ 2018-11-17 10:22:17 +00:00
Alexander Alekhin cf86af96ea Merge pull request #13194 from alalek:samples_fix_python_search_win32 2018-11-17 13:21:37 +03:00
Alexander Alekhin 780ae864a0 Merge pull request #13192 from alalek:fix_valgrind_3.4 2018-11-17 13:20:33 +03:00
berak 96c99c716a Merge pull request #13193 from berak:core_copyMakeBorder 2018-11-17 13:19:42 +03:00
Alexander Alekhin 73a17baeec samples(run_python): fix registry values querying 2018-11-17 09:42:51 +00:00
Alexander Alekhin c26dd5d7aa core: fix issues from valgrind builder 2018-11-17 07:32:06 +00:00
Alexander Alekhin 954969dd74 Merge pull request #13189 from alalek:cmake_options_warnings_update 2018-11-17 00:36:15 +03:00
Alexander Alekhin 43002c0c1d Merge pull request #13188 from alalek:samples_rename
* samples: rename starter_imagelist.cpp

* samples: rename intelperc_capture.cpp => videocapture_intelperc.cpp

* samples: rename openni_capture.cpp => videocapture_openni.cpp

* samples: rename image_sequence.cpp => videocapture_image_sequence.cpp

* samples: rename gstreamer_pipeline.cpp => videocapture_gstreamer_pipeline.cpp

* samples: rename autofocus.cpp => videocapture_gphoto2_autofocus.cpp

* samples: rename live_detect_qrcode.cpp => qrcode.cpp
2018-11-17 00:35:05 +03:00
Alexander Alekhin e580061b74 Merge pull request #12908 from alexevans:Issue11855 2018-11-16 20:42:54 +00:00
Dmitry Matveev d7540c9a3c Merge pull request #13176 from dmatveev:gapi_doxygen
G-API: Doxygen class reference

* G-API Doxygen documentation: covered cv::GComputation

* G-API Doxygen documentation: added sections on compile arguments

* G-API Doxygen documentation: restructuring & more text

* Added new sections (organized API reference into it);
* Documented GCompiled, compile args, backends, etc.

* G-API Doxygen documentation: documented GKernelPackage and added group for meta
2018-11-16 23:38:10 +03:00
Alexander Alekhin bea312bd65 Merge pull request #13183 from tomoaki0705:fixCaroteneColorConvert2Gray 2018-11-16 23:35:51 +03:00
Alexander Alekhin 3705648c9b Merge pull request #13184 from paroj:imshow_cvtscale 2018-11-16 20:34:22 +00:00
Alexander Alekhin 53af811530 cmake: emit warnings about unsupported options if turned ON only 2018-11-16 20:24:31 +00:00
Christopher Gundler b58a8729c2 Merge pull request #13131 from Christopher22:add_transposedConv_onnx
* Add support for ConvTranspose when parsing ONNX.

* Add support for ConvTranspose when parsing ONNX.

* Add test for Deconvolution
2018-11-16 22:50:40 +03:00
Alexander Alekhin ee417048e5 Merge pull request #13178 from alalek:fix_samples_python_video_params 2018-11-16 22:46:22 +03:00
Alexander Alekhin a4b21d9e2e Merge pull request #13177 from alalek:update_win32_scripts 2018-11-16 22:45:57 +03:00
Alexander Alekhin b321851e53 Merge pull request #12977 from alalek:python_package 2018-11-16 22:45:33 +03:00
Alexander Alekhin 1d5a528107 Merge pull request #12354 from alalek:samples_find_file 2018-11-16 22:40:49 +03:00
Alexander Alekhin a68835f7f1 features2d(test): add crossCheck=true test 2018-11-16 19:30:00 +00:00
Alexander Alekhin f2bec05e6d Merge pull request #12913 from dkurt:dnn_fix_ie_hyperparams 2018-11-16 18:36:12 +00:00
Alexander Alekhin c371df4aa2 samples: use findFile() in "python" 2018-11-16 18:08:22 +00:00
Alexander Alekhin 9ea8c775f8 samples: use findFile() in T-API samples 2018-11-16 18:08:22 +00:00
Alexander Alekhin e8e2197032 samples: use findFile() in dnn 2018-11-16 18:08:22 +00:00
Alexander Alekhin c4c31f5bba samples: use findFile() in "cpp" 2018-11-16 18:08:22 +00:00
Alexander Alekhin 940dc1f2b7 Merge pull request #13151 from paroj:nocapmodes 2018-11-16 17:20:48 +00:00
Pavel Rojtberg f54b230906 highgui: Qt - restore convertscale semantics
broken in 11eafca3e2
2018-11-16 16:13:05 +01:00
Tomoaki Teshima 3bbc4e44c3 fix test failure of ColorCvtRGB2Gray
- update parameter in carotene
2018-11-16 23:31:01 +09:00
Vitaly Tuzov 9ad1a84853 Unrolled bilateral filter neighbor processing loop 2018-11-16 13:51:46 +03:00
Vitaly Tuzov f5b6bea2d4 Raised bilateralFilter processing precision for CV_32F matrices containing NaNs 2018-11-16 12:07:04 +03:00
Alexander Alekhin ce6acd3ecd python: bindings loader package
Configures and loads OpenCV bindings extension including 3rdparty dependencies

Based on running Python specify:
- configure PYTHON_PATH (via "sys.path")
- configure LD_LIBRARY_PATH / PATH
2018-11-16 00:51:16 +00:00
Alexander Alekhin 1c04a5ec47 Merge pull request #12965 from terfendail:medianBlur_wintr 2018-11-16 00:47:11 +00:00
Alexander Alekhin 2fa9bd221d core: add utils::findDataFile() / samples::findFile() 2018-11-16 00:25:06 +00:00
Alexander Alekhin 9ca82caeb7 samples(python): fix drive handling in source path 2018-11-16 00:24:34 +00:00
Alexander Alekhin 5cf84c3765 samples: update Python launcher (winpack) 2018-11-15 23:36:26 +00:00
Alexander Alekhin 3d68b5baa1 samples: update build script (winpack)
- drop EnableDelayedExpansion
2018-11-15 23:36:26 +00:00
Alexander Alekhin 8792bddb0a win32: update setupvars.cmd
- drop EnableDelayedExpansion
- pause on failed commands (non-interactive mode)
2018-11-15 23:36:26 +00:00
Alexander Alekhin e5afa62c3d Merge pull request #13168 from alalek:cmake_dnn_warnings 2018-11-15 23:10:46 +00:00
Alexander Alekhin 33e824f5de Merge pull request #13175 from paddy74:patch-1 2018-11-16 02:10:18 +03:00
Patrick Cox 6820abd67f samples(python): Updated use of model.load instances
The load() function returns a new object, and as such does not use the one it is called on.
This commit updates the uses of model.load in this program so it will work as intended and not throw an error.
2018-11-15 22:14:40 +00:00
Dmitry Kurtaev b5c54e447c Extra hyperparameters for Intel's Inference Engine layers 2018-11-15 20:06:37 +03:00
Evgeny Latkin f81370232a Merge pull request #13162 from elatkin:el/gapi_perf_rgb2gray
GAPI (fluid): RGB/BGR to gray: optimization (#13162)

* GAPI (fluid): RGB/BGR to Gray: add performance tests

* GAPI (fluid): RGB/BGR to Gray: speedup 8-12x with manual CV_SIMD

* GAPI (fluid): RGB/BGR to Gray: fix compiler warning

* GAPI (fluid): RGB/BGR to Gray: dynamic dispatching to AVX2

* GAPI (fluid): RGB/BGR to Gray: check R/G/B coefficients

* GAPI (fluid): RGB/BGR to Gray: fixed compilation error (caused by change in master)
2018-11-15 18:14:27 +03:00
Dmitry Matveev 85fad1504a Merge pull request #13030 from dmatveev:tutorial
* G-API: First steps with tutorial

* G-API Tutorial: First iteration

* G-API port of anisotropic image segmentation tutorial;
* Currently works via OpenCV only;
* Some new kernels have been required.

* G-API Tutorial: added chapters on execution code, inspection, and profiling

* G-API Tutorial: make Fluid kernel headers public

For some reason, these headers were not moved to the public
headers subtree during the initial development. Somehow it even
worked for the existing workloads.

* G-API Tutorial: Fix a couple of issues found during the work

* Introduced Phase & Sqrt kernels, OCV & Fluid versions
* Extended GKernelPackage to allow kernel removal & policies on include()

All the above stuff needs to be tested, tests will be added later

* G-API Tutorial: added chapter on running Fluid backend

* G-API Tutorial: fix a number of issues in the text

* G-API Tutorial - some final updates

- Fixed post-merge issues after Sobel kernel renaming;
- Simplified G-API code a little bit;
- Put a conclusion note in text.

* G-API Tutorial - fix build issues in test/perf targets

Public headers were refactored but tests suites were not updated in time

* G-API Tutorial: Added tests & reference docs on new kernels

* Phase
* Sqrt

* G-API Tutorial: added link to the tutorial from the main module doc

* G-API Tutorial: Added tests on new GKernelPackage functionality

* G-API Tutorial: Extended InRange tests to cover 32F

* G-API Tutorial: Misc fixes

* Avoid building examples when gapi module is not there
* Added a volatile API disclaimer to G-API root documentation page

* G-API Tutorial: Fix perf tests build issue

This change came from master where Fluid kernels are still used
incorrectly.

* G-API Tutorial: Fixed channels support in Sqrt/Phase fluid kernels

Extended tests to cover this case

* G-API Tutorial: Fix text problems found on team review
2018-11-15 18:12:36 +03:00
Alexander Alekhin 1d10d56651 Merge pull request #13173 from dkurt:dnn_fix_vulkan_pool 2018-11-15 12:56:10 +00:00
Dmitry Kurtaev ef5d921eac Fix Vulkan's max pooling in case of no output indices 2018-11-15 14:10:54 +03:00
Alexander Alekhin 96c71dd3d2 dnn: reduce set of ignored warnings 2018-11-15 13:15:59 +03:00
Alexander Alekhin 8409aa9eba Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2018-11-14 19:41:09 +00:00
Alexander Alekhin 02d2cc58d7 Merge pull request #13164 from alalek:ocl_morph 2018-11-14 19:32:32 +00:00
Alexander Alekhin 452f0bb2ab Merge pull request #13166 from catree:fix_batch_norm_layer_missing_intrin 2018-11-14 19:02:17 +00:00
catree 10b482ff1e Fix code and missing intrin header. Remove useless header. 2018-11-14 19:00:59 +01:00
Alexander Alekhin 42742727d6 imgproc(ocl): fix morph generic filter checks
'ksize' is not updated with 'kernel'
2018-11-14 20:15:01 +03:00
Alexander Alekhin ca9aa180c1 Merge pull request #13096 from alalek:gapi_tests_checks 2018-11-14 15:59:01 +00:00
Alexander Alekhin ce46cc9852 Merge pull request #13153 from savuor:fix/filenodeit_member_ptr 2018-11-14 14:22:58 +00:00
Alexander Alekhin 47cb94e634 Merge pull request #13160 from dkurt:fix_13159 2018-11-14 14:18:21 +00:00
Alexander Alekhin 39f327acdb Merge pull request #13157 from elatkin:el/gapi_perf_sobel_3 2018-11-14 13:19:30 +00:00
Dmitry Kurtaev 80265a0815 Fix a bug with OpenVINO backend 2018-11-14 13:42:06 +03:00
Alexander Alekhin 6189b47648 gapi(test): more reliable checks
avoid `countNonZero()`, use `norm()`
2018-11-14 13:30:53 +03:00
Alexander Alekhin dd6f5949c2 gapi(test): use relative error check for Norm/Sum tests 2018-11-14 13:30:53 +03:00
Latkin, Yevgeny I a62539489d GAPI (fluid): Sobel 3x3 optimization: remove needless file 2018-11-14 10:17:40 +03:00
Alexander Alekhin 70ac734263 Merge pull request #13152 from ssnover95:docfix/fourier-transform-py-tutorial 2018-11-13 22:05:25 +03:00
ssnover95 b24a815ac1 doc(tutorial_py_fourier_transform): Correct errors in tutorial for integer division and filter symmetry 2018-11-13 12:45:23 -05:00
Rostislav Vasilikhin d6b2739525 removed FileNodeIterator::operator->() 2018-11-13 20:18:53 +03:00
Pavel Rojtberg 846a500fb4 videoio: drop VideoCaptureModes enum in favour of fourcc 2018-11-13 17:20:24 +01:00
Alexander Alekhin 8b7f805642 Merge pull request #13150 from dmatveev:update_ade011d 2018-11-13 16:18:32 +00:00
Evgeny Latkin cc5190eb91 Merge pull request #13133 from elatkin:el/gapi_perf_sobel_2
GAPI (fluid): Sobel 3x3 optimization: CV_SIMD dynamic dispatching (#13133)

* GAPI (fluid): Sobel 3x3: remove template for run_sobel_row()

* GAPI (fluid): Sobel 3x3: dynamic dispatching of CV_SIMD code

* GAPI (fluid): Sobel 3x3 optimization: fixed CV_SIMD dynamic dispatcher
2018-11-13 17:48:10 +03:00
Dmitry Matveev 4eff798270 Update ADE to version 0.1.1d 2018-11-13 16:44:29 +03:00
Evgeny Latkin 4e40e5bb88 Merge pull request #13070 from elatkin:el/gapi_perf_sobel
GAPI (fluid): optimization of Sobel 3x3 (#13070)

* GAPI: performance test for Sobel

* GAPI: performance test for Sobel w/FP32 input

* GAPI: Sobel speedup: 2.5x (U8) up to 10x (float)

* GAPI: Sobel 3x3 to support U8 into S16

* GAPI (fluid): Sobel 3x3 speedup: 10% (uchar), 1.5x (float)

* GAPI (fluid): Sobel 3x3 speedup: +10x (uchar), but -20% (float)

* GAPI (fluid): Sobel 3x3 speedup: +10% (float)

* GAPI (fluid): Sobel 3x3 speedup: +15% (float), +10% (uchar)

* GAPI (fluid): Sobel 3x3: address GCC warnings

* GAPI (fluid): Sobel 3x3: separate *.cpp file w/SIMD code

* GAPI (fluid): Sobel 3x3: fixed AVX2 code, AVX2 speedup 20-50% (uchar), 10-20% (float)

* GAPI (fluid): Sobel 3x3: fix CV_SIMD code for AVX2

* GAPI (fluid): Sobel 3x3: refactor
2018-11-13 15:04:37 +03:00
Dmitry Kurtaev 1a27ff4518 Update Mask-RCNN networks generator 2018-11-13 13:22:39 +03:00
Alexander Alekhin a456b968cf Merge tag '4.0.0-rc'
OpenCV 4.0.0-rc
2018-11-12 21:42:02 +00:00
Vitaly Tuzov 2dd98e7cc6 bilateralFilter implementation moved to separate file 2018-11-09 18:26:26 +03:00
Vitaly Tuzov 28fd967148 Updated bilateralFilter implementations to use wide universal intrinsics 2018-11-09 15:27:30 +03:00
root 1196eb33fc remove non-ideal pairs when using crosscheck in batchdistance 2018-10-26 20:25:24 +00:00
Maksim Shabunin e6d9486a6c Fixed several issues found by static analysis 2018-10-25 16:39:54 +03:00
Maksim Shabunin 9a8e47a766 Version update for OpenVINO 2018-10-25 16:38:30 +03:00
442 changed files with 12934 additions and 5249 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ endif()
set(CAROTENE_NS "carotene_o4t" CACHE STRING "" FORCE)
function(compile_carotene)
if(ENABLE_NEON)
if(";${CPU_BASELINE_FINAL};" MATCHES ";NEON;")
set(WITH_NEON ON)
endif()
+4 -4
View File
@@ -49,12 +49,12 @@ namespace {
enum
{
SHIFT = 14,
SHIFT = 15,
SHIFT_DELTA = 1 << (SHIFT - 1),
R2Y_BT601 = 4899,
G2Y_BT601 = 9617,
B2Y_BT601 = 1868,
R2Y_BT601 = 9798,
G2Y_BT601 = 19235,
B2Y_BT601 = 3735,
R2Y_BT709 = 3483,
G2Y_BT709 = 11718,
+204 -70
View File
@@ -219,71 +219,200 @@ OCV_OPTION(BUILD_ITT "Build Intel ITT from source" (NOT MI
# Optional 3rd party components
# ===================================================
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O (iOS/Mac)" ON IF APPLE)
OCV_OPTION(WITH_CAROTENE "Use NVidia carotene acceleration library for ARM platform" ON IF (ARM OR AARCH64) AND NOT IOS AND NOT (CMAKE_VERSION VERSION_LESS "2.8.11"))
OCV_OPTION(WITH_CPUFEATURES "Use cpufeatures Android library" ON IF ANDROID)
OCV_OPTION(WITH_VTK "Include VTK library support (and build opencv_viz module eiher)" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT AND NOT CMAKE_CROSSCOMPILING) )
OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" OFF IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" ON IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" ON IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" ON IF (NOT IOS AND NOT APPLE) )
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" (NOT CV_DISABLE_OPTIMIZATION) IF (NOT WINRT AND NOT CMAKE_CROSSCOMPILING) )
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)" OFF )
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_IPP "Include Intel IPP support" (NOT MINGW AND NOT CV_DISABLE_OPTIMIZATION) IF (X86_64 OR X86) AND NOT WINRT AND NOT IOS )
OCV_OPTION(WITH_HALIDE "Include Halide support" OFF)
OCV_OPTION(WITH_VULKAN "Include Vulkan support" OFF)
OCV_OPTION(WITH_INF_ENGINE "Include Intel Inference Engine support" OFF)
OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
OCV_OPTION(WITH_JPEG "Include JPEG support" ON)
OCV_OPTION(WITH_WEBP "Include WebP support" ON IF (NOT WINRT) )
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT WINRT) )
OCV_OPTION(WITH_OPENVX "Include OpenVX support" OFF)
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_PNG "Include PNG support" ON)
OCV_OPTION(WITH_GDCM "Include DICOM support" OFF)
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_ARAVIS "Include Aravis GigE support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT AND NOT WIN32) )
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON IF WIN32 AND NOT WINRT)
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_HPX "Include Ste||ar Group HPX support" OFF)
OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF)
OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON IF (NOT WIN32 OR MINGW) )
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID AND NOT APPLE) )
OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON IF (WIN32 AND NOT ARM AND NOT WINRT) )
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" ON IF WIN32 )
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT WINRT) )
OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF)
OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" (NOT ANDROID AND NOT CV_DISABLE_OPTIMIZATION) IF (NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_OPENCL_SVM "Include OpenCL Shared Virtual Memory support" OFF ) # experimental
OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON IF (WIN32 AND NOT WINRT) )
OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF IF (WIN32 AND NOT WINRT) )
OCV_OPTION(WITH_LIBREALSENSE "Include Intel librealsense support" OFF IF (NOT WITH_INTELPERC) )
OCV_OPTION(WITH_VA "Include VA support" OFF IF (UNIX AND NOT ANDROID) )
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" 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 )
OCV_OPTION(WITH_IMGCODEC_HDR "Include HDR support" ON)
OCV_OPTION(WITH_IMGCODEC_SUNRASTER "Include SUNRASTER support" ON)
OCV_OPTION(WITH_IMGCODEC_PXM "Include PNM (PBM,PGM,PPM) and PAM formats support" ON)
OCV_OPTION(WITH_IMGCODEC_PFM "Include PFM formats support" ON)
OCV_OPTION(WITH_QUIRC "Include library QR-code decoding" ON)
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_DC1394)
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O (iOS/Mac)" ON
VISIBLE_IF APPLE
VERIFY HAVE_AVFOUNDATION)
OCV_OPTION(WITH_CAROTENE "Use NVidia carotene acceleration library for ARM platform" ON
VISIBLE_IF (ARM OR AARCH64) AND NOT IOS AND NOT (CMAKE_VERSION VERSION_LESS "2.8.11"))
OCV_OPTION(WITH_CPUFEATURES "Use cpufeatures Android library" ON
VISIBLE_IF ANDROID
VERIFY HAVE_CPUFEATURES)
OCV_OPTION(WITH_VTK "Include VTK library support (and build opencv_viz module eiher)" ON
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT AND NOT CMAKE_CROSSCOMPILING
VERIFY HAVE_VTK)
OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" OFF
VISIBLE_IF NOT IOS AND NOT WINRT
VERIFY HAVE_CUDA)
OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" WITH_CUDA
VISIBLE_IF WITH_CUDA
VERIFY HAVE_CUFFT)
OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" WITH_CUDA
VISIBLE_IF WITH_CUDA
VERIFY HAVE_CUBLAS)
OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" WITH_CUDA
VISIBLE_IF WITH_CUDA
VERIFY HAVE_NVCUVID)
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" (NOT CV_DISABLE_OPTIMIZATION)
VISIBLE_IF NOT WINRT AND NOT CMAKE_CROSSCOMPILING
VERIFY HAVE_EIGEN)
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_FFMPEG)
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_GSTREAMER AND GSTREAMER_BASE_VERSION VERSION_GREATER "0.99")
OCV_OPTION(WITH_GSTREAMER_0_10 "Enable Gstreamer 0.10 support (instead of 1.x)" OFF
VISIBLE_IF TRUE
VERIFY HAVE_GSTREAMER AND GSTREAMER_BASE_VERSION VERSION_LESS "1.0")
OCV_OPTION(WITH_GTK "Include GTK support" ON
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
VERIFY HAVE_GTK)
OCV_OPTION(WITH_GTK_2_X "Use GTK version 2" OFF
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
VERIFY HAVE_GTK AND NOT HAVE_GTK3)
OCV_OPTION(WITH_IPP "Include Intel IPP support" (NOT MINGW AND NOT CV_DISABLE_OPTIMIZATION)
VISIBLE_IF (X86_64 OR X86) AND NOT WINRT AND NOT IOS
VERIFY HAVE_IPP)
OCV_OPTION(WITH_HALIDE "Include Halide support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_HALIDE)
OCV_OPTION(WITH_VULKAN "Include Vulkan support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_VULKAN)
OCV_OPTION(WITH_INF_ENGINE "Include Intel Inference Engine support" OFF
VISIBLE_IF TRUE
VERIFY INF_ENGINE_TARGET)
OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON
VISIBLE_IF NOT IOS
VERIFY HAVE_JASPER)
OCV_OPTION(WITH_JPEG "Include JPEG support" ON
VISIBLE_IF TRUE
VERIFY HAVE_JPEG)
OCV_OPTION(WITH_WEBP "Include WebP support" ON
VISIBLE_IF NOT WINRT
VERIFY HAVE_WEBP)
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON
VISIBLE_IF NOT IOS AND NOT WINRT
VERIFY HAVE_OPENEXR)
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF
VISIBLE_IF NOT ANDROID AND NOT WINRT
VERIFY HAVE_OPENGL)
OCV_OPTION(WITH_OPENVX "Include OpenVX support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_OPENVX)
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_OPENNI)
OCV_OPTION(WITH_OPENNI2 "Include OpenNI2 support" OFF
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_OPENNI2)
OCV_OPTION(WITH_PNG "Include PNG support" ON
VISIBLE_IF TRUE
VERIFY HAVE_PNG)
OCV_OPTION(WITH_GDCM "Include DICOM support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_GDCM)
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" OFF
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_PVAPI)
OCV_OPTION(WITH_GIGEAPI "Include Smartek GigE support" OFF
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_GIGE_API)
OCV_OPTION(WITH_ARAVIS "Include Aravis GigE support" OFF
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT AND NOT WIN32
VERIFY HAVE_ARAVIS_API)
OCV_OPTION(WITH_QT "Build with Qt Backend support" OFF
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_QT)
OCV_OPTION(WITH_WIN32UI "Build with Win32 UI Backend support" ON
VISIBLE_IF WIN32 AND NOT WINRT
VERIFY HAVE_WIN32UI)
OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF
VISIBLE_IF NOT IOS AND NOT WINRT
VERIFY HAVE_TBB)
OCV_OPTION(WITH_HPX "Include Ste||ar Group HPX support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_HPX)
OCV_OPTION(WITH_OPENMP "Include OpenMP support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_OPENMP)
OCV_OPTION(WITH_PTHREADS_PF "Use pthreads-based parallel_for" ON
VISIBLE_IF NOT WIN32 OR MINGW
VERIFY HAVE_PTHREADS_PF)
OCV_OPTION(WITH_TIFF "Include TIFF support" ON
VISIBLE_IF NOT IOS
VERIFY HAVE_TIFF)
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON
VISIBLE_IF UNIX AND NOT ANDROID AND NOT APPLE
VERIFY HAVE_CAMV4L OR HAVE_CAMV4L2 OR HAVE_VIDEOIO)
OCV_OPTION(WITH_DSHOW "Build VideoIO with DirectShow support" ON
VISIBLE_IF WIN32 AND NOT ARM AND NOT WINRT
VERIFY HAVE_DSHOW)
OCV_OPTION(WITH_MSMF "Build VideoIO with Media Foundation support" ON
VISIBLE_IF WIN32
VERIFY HAVE_MSMF)
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF
VISIBLE_IF NOT ANDROID AND NOT WINRT
VERIFY HAVE_XIMEA)
OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF
VISIBLE_IF UNIX AND NOT APPLE AND NOT ANDROID
VERIFY HAVE_XINE)
OCV_OPTION(WITH_CLP "Include Clp support (EPL)" OFF
VISIBLE_IF TRUE
VERIFY HAVE_CLP)
OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" (NOT ANDROID AND NOT CV_DISABLE_OPTIMIZATION)
VISIBLE_IF NOT IOS AND NOT WINRT
VERIFY HAVE_OPENCL)
OCV_OPTION(WITH_OPENCL_SVM "Include OpenCL Shared Virtual Memory support" OFF
VISIBLE_IF TRUE
VERIFY HAVE_OPENCL_SVM) # experimental
OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" ON
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_CLAMDFFT)
OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" ON
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_CLAMDBLAS)
OCV_OPTION(WITH_DIRECTX "Include DirectX support" ON
VISIBLE_IF WIN32 AND NOT WINRT
VERIFY HAVE_DIRECTX)
OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF
VISIBLE_IF WIN32 AND NOT WINRT
VERIFY HAVE_INTELPERC)
OCV_OPTION(WITH_LIBREALSENSE "Include Intel librealsense support" OFF
VISIBLE_IF NOT WITH_INTELPERC
VERIFY HAVE_LIBREALSENSE)
OCV_OPTION(WITH_VA "Include VA support" OFF
VISIBLE_IF UNIX AND NOT ANDROID
VERIFY HAVE_VA)
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF
VISIBLE_IF UNIX AND NOT ANDROID
VERIFY HAVE_VA_INTEL)
OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF
VISIBLE_IF (UNIX AND NOT ANDROID) OR (WIN32 AND NOT WINRT AND NOT MINGW)
VERIFY HAVE_MFX)
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF
VISIBLE_IF NOT ANDROID AND NOT IOS AND NOT WINRT
VERIFY HAVE_GDAL)
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" OFF
VISIBLE_IF UNIX AND NOT ANDROID AND NOT IOS
VERIFY HAVE_GPHOTO2)
OCV_OPTION(WITH_LAPACK "Include Lapack library support" (NOT CV_DISABLE_OPTIMIZATION)
VISIBLE_IF NOT ANDROID AND NOT IOS
VERIFY HAVE_LAPACK)
OCV_OPTION(WITH_ITT "Include Intel ITT support" ON
VISIBLE_IF NOT APPLE_FRAMEWORK
VERIFY HAVE_ITT)
OCV_OPTION(WITH_PROTOBUF "Enable libprotobuf" ON
VISIBLE_IF TRUE
VERIFY HAVE_PROTOBUF)
OCV_OPTION(WITH_IMGCODEC_HDR "Include HDR support" ON
VISIBLE_IF TRUE
VERIFY HAVE_IMGCODEC_HDR)
OCV_OPTION(WITH_IMGCODEC_SUNRASTER "Include SUNRASTER support" ON
VISIBLE_IF TRUE
VERIFY HAVE_IMGCODEC_SUNRASTER)
OCV_OPTION(WITH_IMGCODEC_PXM "Include PNM (PBM,PGM,PPM) and PAM formats support" ON
VISIBLE_IF TRUE
VERIFY HAVE_IMGCODEC_PXM)
OCV_OPTION(WITH_IMGCODEC_PFM "Include PFM formats support" ON
VISIBLE_IF TRUE
VERIFY HAVE_IMGCODEC_PFM)
OCV_OPTION(WITH_QUIRC "Include library QR-code decoding" ON
VISIBLE_IF TRUE
VERIFY HAVE_QUIRC)
# OpenCV build components
# ===================================================
@@ -295,8 +424,8 @@ OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform"
OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" OFF IF (NOT WINRT AND NOT APPLE_FRAMEWORK))
OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
OCV_OPTION(BUILD_PACKAGE "Enables 'make package_source' command" ON IF NOT WINRT)
OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" ON IF (NOT APPLE_FRAMEWORK) )
OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT APPLE_FRAMEWORK) )
OCV_OPTION(BUILD_PERF_TESTS "Build performance tests" NOT INSTALL_CREATE_DISTRIB IF (NOT APPLE_FRAMEWORK) )
OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" NOT INSTALL_CREATE_DISTRIB IF (NOT APPLE_FRAMEWORK) )
OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into release binaries ('OFF' means default settings)" OFF )
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of statically linked CRT for statically linked OpenCV" ON IF MSVC )
OCV_OPTION(BUILD_WITH_DYNAMIC_IPP "Enables dynamic linking of IPP (only for standalone IPP)" OFF )
@@ -323,7 +452,6 @@ OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CV_GCC )
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CV_GCC )
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CV_GCC AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
OCV_OPTION(ENABLE_VSX "Enable POWER8 and above VSX (64-bit little-endian)" ON IF ((CV_GCC OR CV_CLANG) AND PPC64LE) )
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CV_GCC AND (X86 OR X86_64)) )
if(NOT IOS AND (NOT ANDROID OR OPENCV_ANDROID_USE_LEGACY_FLAGS)) # Use CPU_BASELINE instead
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" (NEON OR ANDROID_ARM_NEON OR AARCH64) IF (CV_GCC OR CV_CLANG) AND (ARM OR AARCH64 OR IOS) )
@@ -344,6 +472,7 @@ OCV_OPTION(CV_ENABLE_INTRINSICS "Use intrinsic-based optimized code" ON )
OCV_OPTION(CV_DISABLE_OPTIMIZATION "Disable explicit optimized code (dispatched code/intrinsics/loop unrolling/etc)" OFF )
OCV_OPTION(CV_TRACE "Enable OpenCV code trace" ON)
OCV_OPTION(OPENCV_GENERATE_SETUPVARS "Generate setup_vars* scripts" ON IF (NOT ANDROID AND NOT APPLE_FRAMEWORK) )
OCV_OPTION(ENABLE_CONFIG_VERIFICATION "Fail build if actual configuration doesn't match requested (WITH_XXX != HAVE_XXX)" OFF)
OCV_OPTION(ENABLE_PYLINT "Add target with Pylint checks" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
OCV_OPTION(ENABLE_FLAKE8 "Add target with Python flake8 checker" (BUILD_DOCS OR BUILD_EXAMPLES) IF (NOT CMAKE_CROSSCOMPILING AND NOT APPLE_FRAMEWORK) )
@@ -461,6 +590,7 @@ else()
ocv_update(OPENCV_OTHER_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/opencv4")
ocv_update(OPENCV_LICENSES_INSTALL_PATH "${CMAKE_INSTALL_DATAROOTDIR}/licenses/opencv4")
endif()
ocv_update(OPENCV_PYTHON_INSTALL_PATH "python")
endif()
ocv_update(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
@@ -1478,7 +1608,7 @@ if(BUILD_opencv_python2)
status(" Libraries:" HAVE_opencv_python2 THEN "${PYTHON2_LIBRARIES}" ELSE NO)
endif()
status(" numpy:" PYTHON2_NUMPY_INCLUDE_DIRS THEN "${PYTHON2_NUMPY_INCLUDE_DIRS} (ver ${PYTHON2_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)")
status(" packages path:" PYTHON2_EXECUTABLE THEN "${PYTHON2_PACKAGES_PATH}" ELSE "-")
status(" install path:" HAVE_opencv_python2 THEN "${__INSTALL_PATH_PYTHON2}" ELSE "-")
endif()
if(BUILD_opencv_python3)
@@ -1491,7 +1621,7 @@ if(BUILD_opencv_python3)
status(" Libraries:" HAVE_opencv_python3 THEN "${PYTHON3_LIBRARIES}" ELSE NO)
endif()
status(" numpy:" PYTHON3_NUMPY_INCLUDE_DIRS THEN "${PYTHON3_NUMPY_INCLUDE_DIRS} (ver ${PYTHON3_NUMPY_VERSION})" ELSE "NO (Python3 wrappers can not be generated)")
status(" packages path:" PYTHON3_EXECUTABLE THEN "${PYTHON3_PACKAGES_PATH}" ELSE "-")
status(" install path:" HAVE_opencv_python3 THEN "${__INSTALL_PATH_PYTHON3}" ELSE "-")
endif()
status("")
@@ -1526,6 +1656,10 @@ status("")
ocv_finalize_status()
if(ENABLE_CONFIG_VERIFICATION)
ocv_verify_config()
endif()
ocv_cmake_hook(POST_FINALIZE)
# ----------------------------------------------------------------------------
+21 -4
View File
@@ -5,6 +5,10 @@
# AVX / AVX2 / AVX_512F
# FMA3
# ppc64le arch:
# VSX (always available on Power8)
# VSX3 (always available on Power9)
# CPU_{opt}_SUPPORTED=ON/OFF - compiler support (possibly with additional flag)
# CPU_{opt}_IMPLIES=<list>
# CPU_{opt}_FORCE=<list> - subset of "implies" list
@@ -26,10 +30,12 @@
# CPU_DISPATCH_FINAL=<list> - final list of dispatched optimizations
#
# CPU_DISPATCH_FLAGS_${opt} - flags for source files compiled separately (<name>.avx2.cpp)
#
# CPU_{opt}_ENABLED_DEFAULT=ON/OFF - has compiler support without additional flag (CPU_BASELINE_DETECT=ON only)
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3;AVX_512F;AVX512_SKX")
list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16)
list(APPEND CPU_ALL_OPTIMIZATIONS VSX)
list(APPEND CPU_ALL_OPTIMIZATIONS VSX VSX3)
list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS)
ocv_update(CPU_VFPV3_FEATURE_ALIAS "")
@@ -81,7 +87,7 @@ ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX OFF)
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX ON)
macro(ocv_is_optimization_in_list resultvar check_opt)
set(__checked "")
@@ -289,14 +295,24 @@ elseif(ARM OR AARCH64)
set(CPU_BASELINE "NEON;FP16" CACHE STRING "${HELP_CPU_BASELINE}")
endif()
elseif(PPC64LE)
ocv_update(CPU_KNOWN_OPTIMIZATIONS "VSX")
ocv_update(CPU_KNOWN_OPTIMIZATIONS "VSX;VSX3")
ocv_update(CPU_VSX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx.cpp")
ocv_update(CPU_VSX3_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx3.cpp")
if(NOT OPENCV_CPU_OPT_IMPLIES_IGNORE)
ocv_update(CPU_VSX3_IMPLIES "VSX")
endif()
if(CV_CLANG AND (NOT ${CMAKE_CXX_COMPILER} MATCHES "xlc"))
ocv_update(CPU_VSX_FLAGS_ON "-mvsx -maltivec")
ocv_update(CPU_VSX3_FLAGS_ON "-mpower9-vector")
else()
ocv_update(CPU_VSX_FLAGS_ON "-mcpu=power8")
ocv_update(CPU_VSX3_FLAGS_ON "-mcpu=power9 -mtune=power9")
endif()
set(CPU_DISPATCH "VSX3" CACHE STRING "${HELP_CPU_DISPATCH}")
set(CPU_BASELINE "VSX" CACHE STRING "${HELP_CPU_BASELINE}")
endif()
# Helper values for cmake-gui
@@ -331,6 +347,7 @@ macro(ocv_check_compiler_optimization OPT)
ocv_check_compiler_flag(CXX "${CPU_BASELINE_FLAGS}" "${_varname}" "${CPU_${OPT}_TEST_FILE}")
if(${_varname})
list(APPEND CPU_BASELINE_FINAL ${OPT})
set(CPU_${OPT}_ENABLED_DEFAULT ON)
set(__available 1)
endif()
endif()
@@ -448,7 +465,7 @@ foreach(OPT ${CPU_KNOWN_OPTIMIZATIONS})
if(NOT ";${CPU_BASELINE_FINAL};" MATCHES ";${OPT};")
list(APPEND CPU_BASELINE_FINAL ${OPT})
endif()
if(NOT CPU_BASELINE_DETECT) # Don't change compiler flags in 'detection' mode
if(NOT CPU_${OPT}_ENABLED_DEFAULT) # Don't change compiler flags in 'detection' mode
ocv_append_optimization_flag(CPU_BASELINE_FLAGS ${OPT})
endif()
endif()
+2 -2
View File
@@ -78,9 +78,9 @@ endif()
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.")
message(WARNING "InferenceEngine version have not been set, 2018R4 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(INF_ENGINE_RELEASE "2018040000" 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}"
)
+1 -3
View File
@@ -22,8 +22,6 @@ set(OPENCV_ABI_HEADERS "{RELPATH}/${OPENCV_INCLUDE_INSTALL_PATH}")
# Libraries
set(OPENCV_ABI_LIBRARIES "{RELPATH}/${OPENCV_LIB_INSTALL_PATH}")
set(OPENCV_ABI_SKIP_HEADERS "")
set(OPENCV_ABI_SKIP_LIBRARIES "")
foreach(mod ${OPENCV_MODULES_BUILD})
string(REGEX REPLACE "^opencv_" "" mod "${mod}")
if(NOT OPENCV_MODULE_opencv_${mod}_CLASS STREQUAL "PUBLIC"
@@ -44,7 +42,7 @@ string(REPLACE ";" "\n " OPENCV_ABI_SKIP_HEADERS "${OPENCV_ABI_SKIP_HEADERS}"
string(REPLACE ";" "\n " OPENCV_ABI_SKIP_LIBRARIES "${OPENCV_ABI_SKIP_LIBRARIES}")
# Options
set(OPENCV_ABI_GCC_OPTIONS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -DOPENCV_ABI_CHECK=1")
set(OPENCV_ABI_GCC_OPTIONS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -DOPENCV_ABI_CHECK=1 -DCV_DNN_DONT_ADD_INLINE_NS=1")
string(REGEX REPLACE "([^ ]) +([^ ])" "\\1\\n \\2" OPENCV_ABI_GCC_OPTIONS "${OPENCV_ABI_GCC_OPTIONS}")
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_abi.xml.in" "${path1}.base")
+6 -1
View File
@@ -43,7 +43,12 @@ else()
endif()
file(RELATIVE_PATH OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG
"${CMAKE_INSTALL_PREFIX}/${OPENCV_SETUPVARS_INSTALL_PATH}/" "${CMAKE_INSTALL_PREFIX}/")
ocv_path_join(OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG "${OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG}" "python_loader") # https://github.com/opencv/opencv/pull/12977
if(IS_ABSOLUTE "${OPENCV_PYTHON_INSTALL_PATH}")
set(OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG "${OPENCV_PYTHON_INSTALL_PATH}")
message(WARNING "CONFIGURATION IS NOT SUPPORTED: validate setupvars script in install directory")
else()
ocv_path_join(OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG "${OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG}" "${OPENCV_PYTHON_INSTALL_PATH}")
endif()
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/${OPENCV_SETUPVARS_TEMPLATE}" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/install/${OPENCV_SETUPVARS_FILENAME}" @ONLY)
install(FILES "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/install/${OPENCV_SETUPVARS_FILENAME}"
DESTINATION "${OPENCV_SETUPVARS_INSTALL_PATH}"
+8 -1
View File
@@ -779,6 +779,7 @@ macro(ocv_glob_module_sources)
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/hal/*.h"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.hpp"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/utils/*.h"
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/legacy/*.h"
)
file(GLOB lib_hdrs_detail
"${CMAKE_CURRENT_LIST_DIR}/include/opencv2/${name}/detail/*.hpp"
@@ -909,7 +910,11 @@ macro(_ocv_create_module)
source_group("Src" FILES "${_VS_VERSION_FILE}")
endif()
endif()
if(WIN32 AND NOT ("${the_module}" STREQUAL "opencv_core" OR "${the_module}" STREQUAL "opencv_world")
if(WIN32 AND NOT (
"${the_module}" STREQUAL "opencv_core" OR
"${the_module}" STREQUAL "opencv_world" OR
"${the_module}" STREQUAL "opencv_cudev"
)
AND (BUILD_SHARED_LIBS AND NOT "x${OPENCV_MODULE_TYPE}" STREQUAL "xSTATIC")
AND NOT OPENCV_SKIP_DLLMAIN_GENERATION
)
@@ -1011,6 +1016,8 @@ macro(_ocv_create_module)
string(REGEX REPLACE "^.*opencv2/" "opencv2/" hdr2 "${hdr}")
if(NOT hdr2 MATCHES "private" AND hdr2 MATCHES "^(opencv2/?.*)/[^/]+.h(..)?$" )
install(FILES ${hdr} OPTIONAL DESTINATION "${OPENCV_INCLUDE_INSTALL_PATH}/${CMAKE_MATCH_1}" COMPONENT dev)
else()
#message("Header file will be NOT installed: ${hdr}")
endif()
endforeach()
endif()
+48 -3
View File
@@ -571,14 +571,21 @@ endmacro()
# Provides an option that the user can optionally select.
# Can accept condition to control when option is available for user.
# Usage:
# option(<option_variable> "help string describing the option" <initial value or boolean expression> [IF <condition>])
# option(<option_variable>
# "help string describing the option"
# <initial value or boolean expression>
# [VISIBLE_IF <condition>]
# [VERIFY <condition>])
macro(OCV_OPTION variable description value)
set(__value ${value})
set(__condition "")
set(__verification)
set(__varname "__value")
foreach(arg ${ARGN})
if(arg STREQUAL "IF" OR arg STREQUAL "if")
if(arg STREQUAL "IF" OR arg STREQUAL "if" OR arg STREQUAL "VISIBLE_IF")
set(__varname "__condition")
elseif(arg STREQUAL "VERIFY")
set(__varname "__verification")
else()
list(APPEND ${__varname} ${arg})
endif()
@@ -605,17 +612,55 @@ macro(OCV_OPTION variable description value)
option(${variable} "${description}" ${__value})
endif()
else()
if(DEFINED ${variable} AND NOT OPENCV_HIDE_WARNING_UNSUPPORTED_OPTION)
if(DEFINED ${variable} AND "${${variable}}" # emit warnings about turned ON options only.
AND NOT (OPENCV_HIDE_WARNING_UNSUPPORTED_OPTION OR "$ENV{OPENCV_HIDE_WARNING_UNSUPPORTED_OPTION}")
)
message(WARNING "Unexpected option: ${variable} (=${${variable}})\nCondition: IF (${__condition})")
endif()
if(OPENCV_UNSET_UNSUPPORTED_OPTION)
unset(${variable} CACHE)
endif()
endif()
if(__verification)
set(OPENCV_VERIFY_${variable} "${__verification}") # variable containing condition to verify
list(APPEND OPENCV_VERIFICATIONS "${variable}") # list of variable names (WITH_XXX;WITH_YYY;...)
endif()
unset(__condition)
unset(__value)
endmacro()
# Check that each variable stored in OPENCV_VERIFICATIONS list
# is consistent with actual detection result (stored as condition in OPENCV_VERIFY_...) variables
function(ocv_verify_config)
set(broken_options)
foreach(var ${OPENCV_VERIFICATIONS})
set(evaluated FALSE)
if(${OPENCV_VERIFY_${var}})
set(evaluated TRUE)
endif()
status("Verifying ${var}=${${var}} => '${OPENCV_VERIFY_${var}}'=${evaluated}")
if (${var} AND NOT evaluated)
list(APPEND broken_options ${var})
message(WARNING
"Option ${var} is enabled but corresponding dependency "
"have not been found: \"${OPENCV_VERIFY_${var}}\" is FALSE")
elseif(NOT ${var} AND evaluated)
list(APPEND broken_options ${var})
message(WARNING
"Option ${var} is disabled or unset but corresponding dependency "
"have been explicitly turned on: \"${OPENCV_VERIFY_${var}}\" is TRUE")
endif()
endforeach()
if(broken_options)
string(REPLACE ";" "\n" broken_options "${broken_options}")
message(FATAL_ERROR
"Some dependencies have not been found or have been forced, "
"unset ENABLE_CONFIG_VERIFICATION option to ignore these failures "
"or change following options:\n${broken_options}")
endif()
endfunction()
# Usage: ocv_append_build_options(HIGHGUI FFMPEG)
macro(ocv_append_build_options var_prefix pkg_prefix)
foreach(suffix INCLUDE_DIRS LIBRARIES LIBRARY_DIRS)
+1 -1
View File
@@ -15,7 +15,7 @@ set(OPENCV_LIBVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_
# create a dependency on the version file
# we never use the output of the following command but cmake will rerun automatically if the version file changes
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}/junk/version.junk" COPYONLY)
configure_file("${OPENCV_VERSION_FILE}" "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/opencv_junk/version.junk" COPYONLY)
ocv_update(OPENCV_VS_VER_FILEVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
ocv_update(OPENCV_VS_VER_PRODUCTVERSION_QUAD "${OPENCV_VERSION_MAJOR},${OPENCV_VERSION_MINOR},${OPENCV_VERSION_PATCH},0")
+1 -1
View File
@@ -18,7 +18,7 @@ int main()
archs.push_back(arch.str());
arch.str("");
}
archs.unique(); #Some devices might have the same arch
archs.unique(); // Some devices might have the same arch
for (std::list<std::string>::iterator it=archs.begin(); it!=archs.end(); ++it)
std::cout << *it << " ";
return 0;
+9 -5
View File
@@ -1,8 +1,12 @@
# if defined(__VSX__)
# include <altivec.h>
# else
# error "VSX is not supported"
# endif
#if defined(__VSX__)
#if defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
#include <altivec.h>
#else
#error "OpenCV only supports little-endian mode"
#endif
#else
#error "VSX is not supported"
#endif
int main()
{
+17
View File
@@ -0,0 +1,17 @@
#if defined(__VSX__)
#if defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
#include <altivec.h>
#else
#error "OpenCV only supports little-endian mode"
#endif
#else
#error "VSX3 is not supported"
#endif
int main()
{
__vector unsigned char a = vec_splats((unsigned char)1);
__vector unsigned char b = vec_splats((unsigned char)2);
__vector unsigned char r = vec_absd(a, b);
return 0;
}
+3
View File
@@ -28,7 +28,9 @@
opencv/cxeigen.hpp
opencv2/core/eigen.hpp
opencv2/flann/hdf5.h
opencv2/imgcodecs/imgcodecs_c.h
opencv2/imgcodecs/ios.h
opencv2/videoio/videoio_c.h
opencv2/videoio/cap_ios.h
opencv2/xobjdetect/private.hpp
@OPENCV_ABI_SKIP_HEADERS@
@@ -39,6 +41,7 @@
</skip_libs>
<gcc_options>
-std=c++11
@OPENCV_ABI_GCC_OPTIONS@
</gcc_options>
+28 -10
View File
@@ -1,18 +1,36 @@
@ECHO OFF
SETLOCAL EnableDelayedExpansion
SET "SCRIPT_DIR=%~dp0"
IF NOT DEFINED OPENCV_QUIET ( ECHO Setting vars for OpenCV @OPENCV_VERSION@ )
SET "PATH=!SCRIPT_DIR!\@OPENCV_LIB_RUNTIME_DIR_RELATIVE_CMAKECONFIG@;%PATH%"
SET "PATH=%SCRIPT_DIR%\@OPENCV_LIB_RUNTIME_DIR_RELATIVE_CMAKECONFIG@;%PATH%"
IF NOT DEFINED OPENCV_SKIP_PYTHON (
SET "PYTHONPATH_OPENCV=!SCRIPT_DIR!\@OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG@"
IF NOT DEFINED OPENCV_QUIET ( ECHO Append PYTHONPATH: !PYTHONPATH_OPENCV! )
SET "PYTHONPATH=!PYTHONPATH_OPENCV!;%PYTHONPATH%"
)
IF NOT DEFINED OPENCV_SKIP_PYTHON CALL :SET_PYTHON
IF NOT [%1] == [] (
%*
EXIT /B !errorlevel!
SET SCRIPT_DIR=
IF NOT [%1] == [] GOTO :RUN_COMMAND
GOTO :EOF
:RUN_COMMAND
SET RUN_INTERACTIVE=1
echo %CMDCMDLINE% | find /i "%~0" >nul
IF NOT errorlevel 1 set RUN_INTERACTIVE=0
%*
SET RESULT=%ERRORLEVEL%
IF %RESULT% NEQ 0 (
IF _%RUN_INTERACTIVE%_==_0_ ( IF NOT DEFINED OPENCV_BATCH_MODE ( pause ) )
)
EXIT /B %RESULT%
:SET_PYTHON
SET "PYTHONPATH_OPENCV=%SCRIPT_DIR%\@OPENCV_PYTHON_DIR_RELATIVE_CMAKECONFIG@"
IF NOT DEFINED OPENCV_QUIET ( ECHO Append PYTHONPATH: %PYTHONPATH_OPENCV% )
SET "PYTHONPATH=%PYTHONPATH_OPENCV%;%PYTHONPATH%"
SET PYTHONPATH_OPENCV=
EXIT /B
:EOF
+2 -1
View File
@@ -106,7 +106,7 @@ FILE_PATTERNS =
RECURSIVE = YES
EXCLUDE = @CMAKE_DOXYGEN_EXCLUDE_LIST@
EXCLUDE_SYMLINKS = NO
EXCLUDE_PATTERNS = *.inl.hpp *.impl.hpp *_detail.hpp */cudev/**/detail/*.hpp *.m */opencl/runtime/*
EXCLUDE_PATTERNS = *.inl.hpp *.impl.hpp *_detail.hpp */cudev/**/detail/*.hpp *.m */opencl/runtime/* */legacy/* *_c.h @DOXYGEN_EXCLUDE_PATTERNS@
EXCLUDE_SYMBOLS = cv::DataType<*> cv::traits::* int void CV__* T __CV*
EXAMPLE_PATH = @CMAKE_DOXYGEN_EXAMPLE_PATH@
EXAMPLE_PATTERNS = *
@@ -257,6 +257,7 @@ PREDEFINED = __cplusplus=1 \
CV_SSE2=1 \
CV__DEBUG_NS_BEGIN= \
CV__DEBUG_NS_END= \
CV_DEPRECATED_EXTERNAL= \
CV_DEPRECATED=
EXPAND_AS_DEFINED =
SKIP_FUNCTION_MACROS = YES
+334 -344
View File
File diff suppressed because it is too large Load Diff
@@ -79,11 +79,11 @@ using **np.ifft2()** function. The result, again, will be a complex number. You
absolute value.
@code{.py}
rows, cols = img.shape
crow,ccol = rows/2 , cols/2
fshift[crow-30:crow+30, ccol-30:ccol+30] = 0
crow,ccol = rows//2 , cols//2
fshift[crow-30:crow+31, ccol-30:ccol+31] = 0
f_ishift = np.fft.ifftshift(fshift)
img_back = np.fft.ifft2(f_ishift)
img_back = np.abs(img_back)
img_back = np.real(img_back)
plt.subplot(131),plt.imshow(img, cmap = 'gray')
plt.title('Input Image'), plt.xticks([]), plt.yticks([])
@@ -85,10 +85,8 @@ we will later have to clip the data in order to avoid overflow.
@code{.py}
# Tonemap HDR image
tonemap1 = cv.createTonemapDurand(gamma=2.2)
tonemap1 = cv.createTonemap(gamma=2.2)
res_debevec = tonemap1.process(hdr_debevec.copy())
tonemap2 = cv.createTonemapDurand(gamma=1.3)
res_robertson = tonemap2.process(hdr_robertson.copy())
@endcode
### 4. Merge exposures using Mertens fusion
@@ -173,5 +171,5 @@ Additional Resources
Exercises
---------
1. Try all tonemap algorithms: cv::TonemapDrago, cv::TonemapDurand, cv::TonemapMantiuk and cv::TonemapReinhard
1. Try all tonemap algorithms: cv::TonemapDrago, cv::TonemapMantiuk and cv::TonemapReinhard
2. Try changing the parameters in the HDR calibration and tonemap methods.
@@ -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.3-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.4-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`.
Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 KiB

@@ -0,0 +1,411 @@
# Porting anisotropic image segmentation on G-API {#tutorial_gapi_anisotropic_segmentation}
[TOC]
# Introduction {#gapi_anisotropic_intro}
In this tutorial you will learn:
* How an existing algorithm can be transformed into a G-API
computation (graph);
* How to inspect and profile G-API graphs;
* How to customize graph execution without changing its code.
This tutorial is based on @ref
tutorial_anisotropic_image_segmentation_by_a_gst.
# Quick start: using OpenCV backend {#gapi_anisotropic_start}
Before we start, let's review the original algorithm implementation:
@include cpp/tutorial_code/ImgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.cpp
## Examining calcGST() {#gapi_anisotropic_calcgst}
The function calcGST() is clearly an image processing pipeline:
* It is just a sequence of operations over a number of cv::Mat;
* No logic (conditionals) and loops involved in the code;
* All functions operate on 2D images (like cv::Sobel, cv::multiply,
cv::boxFilter, cv::sqrt, etc).
Considering the above, calcGST() is a great candidate to start
with. In the original code, its prototype is defined like this:
@snippet cpp/tutorial_code/ImgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.cpp calcGST_proto
With G-API, we can define it as follows:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi.cpp calcGST_proto
It is important to understand that the new G-API based version of
calcGST() will just produce a compute graph, in contrast to its
original version, which actually calculates the values. This is a
principial difference -- G-API based functions like this are used to
construct graphs, not to process the actual data.
Let's start implementing calcGST() with calculation of \f$J\f$
matrix. This is how the original code looks like:
@snippet cpp/tutorial_code/ImgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.cpp calcJ_header
Here we need to declare output objects for every new operation (see
img as a result for cv::Mat::convertTo, imgDiffX and others as results for
cv::Sobel and cv::multiply).
The G-API analogue is listed below:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi.cpp calcGST_header
This snippet demonstrates the following syntactic difference between
G-API and traditional OpenCV:
* All standard G-API functions are by default placed in "cv::gapi"
namespace;
* G-API operations _return_ its results -- there's no need to pass
extra "output" parameters to the functions.
Note -- this code is also using `auto` -- types of intermediate objects
like `img`, `imgDiffX`, and so on are inferred automatically by the
C++ compiler. In this example, the types are determined by G-API
operation return values which all are cv::GMat.
G-API standard kernels are trying to follow OpenCV API conventions
whenever possible -- so cv::gapi::sobel takes the same arguments as
cv::Sobel, cv::gapi::mul follows cv::multiply, and so on (except
having a return value).
The rest of calcGST() function can be implemented the same
way trivially. Below is its full source code:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi.cpp calcGST
## Running G-API graph {#gapi_anisotropic_running}
After calcGST() is defined in G-API language, we can construct a graph
based on it and finally run it -- pass input image and obtain
result. Before we do it, let's have a look how original code looked
like:
@snippet cpp/tutorial_code/ImgProc/anisotropic_image_segmentation/anisotropic_image_segmentation.cpp main_extra
G-API-based functions like calcGST() can't be applied to input data
directly, since it is a _construction_ code, not the _processing_ code.
In order to _run_ computations, a special object of class
cv::GComputation needs to be created. This object wraps our G-API code
(which is a composition of G-API data and operations) into a callable
object, similar to C++11
[std::function<>](https://en.cppreference.com/w/cpp/utility/functional/function).
cv::GComputation class has a number of constructors which can be used
to define a graph. Generally, user needs to pass graph boundaries
-- _input_ and _output_ objects, on which a GComputation is
defined. Then G-API analyzes the call flow from _outputs_ to _inputs_
and reconstructs the graph with operations in-between the specified
boundaries. This may sound complex, however in fact the code looks
like this:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi.cpp main
Note that this code slightly changes from the original one: forming up
the resulting image is also a part of the pipeline (done with
cv::gapi::addWeighted). Normalization of orientation and coherency
images is still done by traditional OpenCV (using cv::normalize) as
G-API doesn't provide such kernel at the moment.
Result of this G-API pipeline bit-exact matches the original one
(given the same input image):
![Segmentation result with G-API](pics/result.jpg)
## G-API initial version: full listing {#gapi_anisotropic_ocv}
Below is the full listing of the initial anisotropic image
segmentation port on G-API:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi.cpp full_sample
# Inspecting the initial version {#gapi_anisotropic_inspect}
After we have got the initial working version of our algorithm working
with G-API, we can use it to inspect and learn how G-API works. This
chapter covers two aspects: understanding the graph structure, and
memory profiling.
## Understanding the graph structure {#gapi_anisotropic_inspect_graph}
G-API stands for "Graph API", but did you mention any graphs in the
above example? It was one of the initial design goals -- G-API was
designed with expressions in mind to make adoption and porting process
more straightforward. People _usually_ don't think in terms of
_Nodes_ and _Edges_ when writing ordinary code, and so G-API, while
being a Graph API, doesn't force its users to do that.
However, a graph is still built implicitly when a cv::GComputation
object is defined. It may be useful to inspect how the resulting graph
looks like to check if it is generated correctly and if it really
represents our alrogithm. It is also useful to learn the structure of
the graph to see if it has any redundancies.
G-API allows to dump generated graphs to `.dot` files which then
could be visualized with [Graphviz](https://www.graphviz.org/), a
popular open graph visualization software.
<!-- TODO THIS VARIABLE NEEDS TO BE FIXED TO DUMP DIR ASAP! -->
In order to dump our graph to a `.dot` file, set `GRAPH_DUMP_PATH` to a
file name before running the application, e.g.:
$ GRAPH_DUMP_PATH=segm.dot ./bin/example_tutorial_porting_anisotropic_image_segmentation_gapi
Now this file can be visalized with a `dot` command like this:
$ dot segm.dot -Tpng -o segm.png
or viewed instantly with `xdot` command (please refer to your
distribution/operating system documentation on how to install these
packages).
![Anisotropic image segmentation graph](pics/segm.gif)
The above diagram demonstrates a number of interesting aspects of
G-API's internal algorithm representation:
1. G-API underlying graph is a bipartite graph: it consists of
_Operation_ and _Data_ nodes such that a _Data_ node can only be
connected to an _Operation_ node, _Operation_ node can only be
connected to a _Data_ node, and nodes of a single kind are never
connected directly.
2. Graph is directed - every edge in the graph has a direction.
3. Graph "begins" and "ends" with a _Data_ kind of nodes.
4. A _Data_ node can have only a single writer and multiple readers.
5. An _Operation_ node may have multiple inputs, though every input
must have an unique _port number_ (among inputs).
6. An _Operation_ node may have multiple outputs, and every output
must have an unique _port number_ (among outputs).
## Measuring memory footprint {#gapi_anisotropic_memory_ocv}
Let's measure and compare memory footprint of the algorithm in its two
versions: G-API-based and OpenCV-based. At the moment, G-API version
is also OpenCV-based since it fallbacks to OpenCV functions inside.
On GNU/Linux, application memory footprint can be profiled with
[Valgrind](http://valgrind.org/). On Debian/Ubuntu systems it can be
installed like this (assuming you have administrator priveleges):
$ sudo apt-get install valgrind massif-visualizer
Once installed, we can collect memory profiles easily for our two
algorithm versions:
$ valgrind --tool=massif --massif-out-file=ocv.out ./bin/example_tutorial_anisotropic_image_segmentation
==6101== Massif, a heap profiler
==6101== Copyright (C) 2003-2015, and GNU GPL'd, by Nicholas Nethercote
==6101== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==6101== Command: ./bin/example_tutorial_anisotropic_image_segmentation
==6101==
==6101==
$ valgrind --tool=massif --massif-out-file=gapi.out ./bin/example_tutorial_porting_anisotropic_image_segmentation_gapi
==6117== Massif, a heap profiler
==6117== Copyright (C) 2003-2015, and GNU GPL'd, by Nicholas Nethercote
==6117== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==6117== Command: ./bin/example_tutorial_porting_anisotropic_image_segmentation_gapi
==6117==
==6117==
Once done, we can inspect the collected profiles with
[Massif Visualizer](@https://github.com/KDE/massif-visualizer)
(installed in the above step).
Below is the visualized memory profile of the original OpenCV version
of the algorithm:
![Memory profile: original Anisotropic Image Segmentation sample](pics/massif_export_ocv.png)
We see that memory is allocated as the application
executes, reaching its peak in the calcGST() function; then the
footprint drops as calcGST() completes its execution and all temporary
buffers are freed. Massif reports us peak memory consumption of 7.6 MiB.
Now let's have a look on the profile of G-API version:
![Memory profile: G-API port of Anisotropic Image Segmentation sample](pics/massif_export_gapi.png)
Once G-API computation is created and its execution starts, G-API
allocates all required memory at once and then the memory profile
remains flat until the termination of the program. Massif reports us
peak memory consumption of 10.6 MiB.
A reader may ask a right question at this point -- is G-API that bad?
What is the reason in using it than?
Hopefully, it is not. The reason why we see here an increased memory
consumption is because the default naive OpenCV-based backend is used to
execute this graph. This backend serves mostly for quick prototyping
and debugging algorithms before offload/further optimization.
This backend doesn't utilize any complex memory mamagement strategies yet
since it is not its point at the moment. In the following chapter,
we'll learn about Fluid backend and see how the same G-API code can
run in a completely different model (and the footprint shrinked to a
number of kilobytes).
# Backends and kernels {#gapi_anisotropic_backends}
This chapter covers how a G-API computation can be executed in a
special way -- e.g. offloaded to another device, or scheduled with a
special intelligence. G-API is designed to make its graphs portable --
it means that once a graph is defined in G-API terms, no changes
should be required in it if we want to run it on CPU or on GPU or on
both devices at once. [G-API High-level overview](@ref gapi_hld) and
[G-API Kernel API](@ref gapi_kernel_api) shed more light on technical
details which make it possible. In this chapter, we will utilize G-API
Fluid backend to make our graph cache-efficient on CPU.
G-API defines _backend_ as the lower-level entity which knows how to
run kernels. Backends may have (and, in fact, do have) different
_Kernel APIs_ which are used to program and integrate kernels for that
backends. In this context, _kernel_ is an implementaion of an
_operation_, which is defined on the top API level (see
G_TYPED_KERNEL() macro).
Backend is a thing which is aware of device & platform specifics, and
which executes its kernels with keeping that specifics in mind. For
example, there may be [Halide](http://halide-lang.org/) backend which
allows to write (implement) G-API operations in Halide language and
then generate functional Halide code for portions of G-API graph which
map well there.
## Running a graph with a Fluid backend {#gapi_anisotropic_fluid}
OpenCV 4.0 is bundled with two G-API backends -- the default "OpenCV"
which we just used, and a special "Fluid" backend.
Fluid backend reorganizes the execution to save memory and to achieve
near-perfect cache locality, implementing so-called "streaming" model
of execution.
In order to start using Fluid kernels, we need first to include
appropriate header files (which are not included by default):
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi_fluid.cpp fluid_includes
Once these headers are included, we can form up a new _kernel package_
and specify it to G-API:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi_fluid.cpp kernel_pkg
In G-API, kernels (or operation implementations) are objects. Kernels are
organized into collections, or _kernel packages_, represented by class
cv::gapi::GKernelPackage. The main purpose of a kernel package is to
capture which kernels we would like to use in our graph, and pass it
as a _graph compilation option_:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi_fluid.cpp kernel_pkg_use
Traditional OpenCV is logically divided into modules, whith every
module providing a set of functions. In G-API, there are also
"modules" which are represented as kernel packages provided by a
particular backend. In this example, we pass Fluid kernel packages to
G-API to utilize appropriate Fluid functions in our graph.
Kernel packages are combinable -- in the above example, we take "Core"
and "ImgProc" Fluid kernel packages and combine it into a single
one. See documentation reference on cv::gapi::combine and
cv::unite_policy on package combination options.
If no kernel packages are specified in options, G-API is using
_default_ package which consists of default OpenCV implementations and
thus G-API graphs are executed via OpenCV functions by default. OpenCV
backend provides broader functional coverage than any other
backend. If a kernel package is specified, like in this example, then
it is being combined with the _default_ one with
cv::unite_policy::REPLACE. It means that user-specified
implementations will replace default implementations in case of
conflict.
Kernel packages may contain a mix of kernels, in particular, multiple
implementations of the same kernel. For example, a single kernel
package may contain both OpenCV and Fluid implementations of kernel
"Filter2D". In this case, the implementation selection preference can
be specified with a special compilation parameter cv::gapi::lookup_order.
<!-- FIXME Document this process better as a part of regular -->
<!-- documentation, not a tutorial kind of thing -->
## Troubleshooting and customization {#gapi_anisotropic_trouble}
After the above modifications, (in OpenCV 4.0) the app should crash
with a message like this:
```
$ ./bin/example_tutorial_porting_anisotropic_image_segmentation_gapi_fluid
terminate called after throwing an instance of 'std::logic_error'
what(): .../modules/gapi/src/backends/fluid/gfluidimgproc.cpp:436: Assertion kernelSize.width == 3 && kernelSize.height == 3 in function run failed
Aborted (core dumped)
```
Fluid backend has a number of limitations in OpenCV 4.0 (see this
[wiki page](https://github.com/opencv/opencv/wiki/Graph-API) for a
more up-to-date status). In particular, the Box filter used in this
sample supports only static 3x3 kernel size.
We can overcome this problem easily by avoiding G-API using Fluid
version of Box filter kernel in this sample. It can be done by
removing the appropriate kernel from the kernel package we've just
created:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi_fluid.cpp kernel_hotfix
Now this kernel package doesn't have _any_ implementation of Box
filter kernel interface (specified as a template parameter). As
described above, G-API will fall-back to OpenCV to run this kernel
now. The resulting code with this change now looks like:
@snippet cpp/tutorial_code/gapi/porting_anisotropic_image_segmentation/porting_anisotropic_image_segmentation_gapi_fluid.cpp kernel_pkg_proper
Let's examine the memory profile for this sample after we switched to
Fluid backend. Now it looks like this:
![Memory profile: G-API/Fluid port of Anisotropic Image Segmentation sample](pics/massif_export_gapi_fluid.png)
Now the tool reports 3.8MiB -- and we just changed a few lines in our
code, without modifying the graph itself! It is a ~2.8X improvement of
the previous G-API result, and 2X improvement of the original OpenCV
version.
Let's also examine how the internal representation of the graph now
looks like. Dumping the graph into `.dot` would result into a
visualization like this:
![Anisotropic image segmentation graph with OpenCV & Fluid kernels](pics/segm_fluid.gif)
This graph doesn't differ structually from its previous version (in
terms of operations and data objects), though a changed layout (on the
left side of the dump) is easily noticeable.
The visualization reflects how G-API deals with mixed graphs, also
called _heterogeneous_ graphs. The majority of operations in this
graph are implemented with Fluid backend, but Box filters are executed
by the OpenCV backend. One can easily see that the graph is partioned
(with rectangles). G-API groups connected operations based on their
affinity, forming _subgraphs_ (or _islands_ in G-API terminology), and
our top-level graph becomes a composition of multiple smaller
subgraphs. Every backend determines how its subgraph (island) is
executed, so Fluid backend optimizes out memory where possible, and
six intermediate buffers accessed by OpenCV Box filters are allocated
fully and can't be optimized out.
<!-- TODO: add a chapter on custom kernels -->
<!-- TODO: make a full-fluid pipeline -->
<!-- TODO: talk about parallelism when it is available -->
# Conclusion {#gapi_tutor_conclusion}
This tutorial demonstrates what G-API is and what its key design
concepts are, how an algorithm can be ported to G-API, and
how to utilize graph model benefits after that.
In OpenCV 4.0, G-API is still in its inception stage -- it is more a
foundation for all future work, though ready for use even now.
Further, this tutorial will be extended with new chapters on custom
kernels programming, parallelism, and more.
@@ -0,0 +1,17 @@
# Graph API (gapi module) {#tutorial_table_of_content_gapi}
In this section you will learn about graph-based image processing and
how G-API module can be used for that.
- @subpage tutorial_gapi_anisotropic_segmentation
*Languages:* C++
*Compatibility:* \> OpenCV 4.0
*Author:* Dmitry Matveev
This is an end-to-end tutorial where an existing sample algorithm
is ported on G-API, covering the basic intuition behind this
transition process, and examining benefits which a graph model
brings there.
@@ -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/4.0.0-rc
TAGFILES = ./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/4.0.0
@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/4.0.0-rc
./docs/doxygen-tags/opencv.tag=http://docs.opencv.org/4.0.0
@endcode
Doxygen can now use the information from the tag file to link to the OpenCV
@@ -171,7 +171,7 @@ Now it's time to look at the results. Note that HDR image can't be stored in one
formats, so we save it to Radiance image (.hdr). Also all HDR imaging functions return results in
[0, 1] range so we should multiply result by 255.
You can try other tonemap algorithms: cv::TonemapDrago, cv::TonemapDurand, cv::TonemapMantiuk and cv::TonemapReinhard
You can try other tonemap algorithms: cv::TonemapDrago, cv::TonemapMantiuk and cv::TonemapReinhard
You can also adjust the parameters in the HDR calibration and tonemap methods for your own photos.
Results
+4
View File
@@ -67,6 +67,10 @@ As always, we would be happy to hear your comments and receive your contribution
Use the powerful
machine learning classes for statistical classification, regression and clustering of data.
- @subpage tutorial_table_of_content_gapi
Learn how to use Graph API (G-API) and port algorithms from "traditional" OpenCV to a graph model.
- @subpage tutorial_table_of_content_photo
Use OpenCV for
+1 -1
View File
@@ -78,5 +78,5 @@ there are two flags that should be used to set/get property of the needed genera
flag value is assumed by default if neither of the two possible values of the property is set.
For more information please refer to the example of usage
[intelperc_capture.cpp](https://github.com/opencv/opencv/tree/master/samples/cpp/intelperc_capture.cpp)
[videocapture_intelperc.cpp](https://github.com/opencv/opencv/tree/master/samples/cpp/videocapture_intelperc.cpp)
in opencv/samples/cpp folder.
+1 -1
View File
@@ -134,5 +134,5 @@ property. The following properties of cameras available through OpenNI interface
- CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION = CAP_OPENNI_DEPTH_GENERATOR + CAP_PROP_OPENNI_REGISTRATION
For more information please refer to the example of usage
[openni_capture.cpp](https://github.com/opencv/opencv/tree/master/samples/cpp/openni_capture.cpp) in
[videocapture_openni.cpp](https://github.com/opencv/opencv/tree/master/samples/cpp/videocapture_openni.cpp) in
opencv/samples/cpp folder.
+45 -1
View File
@@ -2,7 +2,7 @@ set(the_description "The Core Functionality")
ocv_add_dispatched_file(mathfuncs_core SSE2 AVX AVX2)
ocv_add_dispatched_file(stat SSE4_2 AVX2)
ocv_add_dispatched_file(arithm SSE2 SSE4_1 AVX2)
ocv_add_dispatched_file(arithm SSE2 SSE4_1 AVX2 VSX3)
# dispatching for accuracy tests
ocv_add_dispatched_file_force_all(test_intrin128 TEST SSE2 SSE3 SSSE3 SSE4_1 SSE4_2 AVX FP16 AVX2)
@@ -86,3 +86,47 @@ ocv_add_accuracy_tests()
ocv_add_perf_tests()
ocv_install_3rdparty_licenses(SoftFloat "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/SoftFloat/COPYING.txt")
# generate data (samples data) config file
set(OPENCV_DATA_CONFIG_FILE "${CMAKE_BINARY_DIR}/opencv_data_config.hpp")
set(OPENCV_DATA_CONFIG_STR "")
if(CMAKE_INSTALL_PREFIX)
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
#define OPENCV_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\"
")
endif()
if(OPENCV_OTHER_INSTALL_PATH)
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
#define OPENCV_DATA_INSTALL_PATH \"${OPENCV_OTHER_INSTALL_PATH}\"
")
endif()
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
#define OPENCV_BUILD_DIR \"${CMAKE_BINARY_DIR}\"
")
file(RELATIVE_PATH SOURCE_DIR_RELATIVE ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR})
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
#define OPENCV_DATA_BUILD_DIR_SEARCH_PATHS \\
\"${SOURCE_DIR_RELATIVE}/\"
")
if(WIN32)
file(RELATIVE_PATH INSTALL_DATA_DIR_RELATIVE "${CMAKE_INSTALL_PREFIX}/${OPENCV_BIN_INSTALL_PATH}" "${CMAKE_INSTALL_PREFIX}/${OPENCV_OTHER_INSTALL_PATH}")
else()
file(RELATIVE_PATH INSTALL_DATA_DIR_RELATIVE "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}" "${CMAKE_INSTALL_PREFIX}/${OPENCV_OTHER_INSTALL_PATH}")
endif()
list(APPEND OPENCV_INSTALL_DATA_DIR_RELATIVE "${INSTALL_DATA_DIR_RELATIVE}")
string(REPLACE ";" "\",\\\n \"" OPENCV_INSTALL_DATA_DIR_RELATIVE_STR "\"${OPENCV_INSTALL_DATA_DIR_RELATIVE}\"")
set(OPENCV_DATA_CONFIG_STR "${OPENCV_DATA_CONFIG_STR}
#define OPENCV_INSTALL_DATA_DIR_RELATIVE ${OPENCV_INSTALL_DATA_DIR_RELATIVE_STR}
")
if(EXISTS "${OPENCV_DATA_CONFIG_FILE}")
file(READ "${OPENCV_DATA_CONFIG_FILE}" __content)
endif()
if(NOT OPENCV_DATA_CONFIG_STR STREQUAL "${__content}")
file(WRITE "${OPENCV_DATA_CONFIG_FILE}" "${OPENCV_DATA_CONFIG_STR}")
endif()
+1
View File
@@ -75,6 +75,7 @@
@defgroup core_utils_sse SSE utilities
@defgroup core_utils_neon NEON utilities
@defgroup core_utils_softfloat Softfloat support
@defgroup core_utils_samples Utility functions for OpenCV samples
@}
@defgroup core_opengl OpenGL interoperability
@defgroup core_ipp Intel IPP Asynchronous C/C++ Converters
@@ -107,7 +107,7 @@
# include <arm_neon.h>
#endif
#if defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
#ifdef CV_CPU_COMPILE_VSX
# include <altivec.h>
# undef vector
# undef pixel
@@ -115,6 +115,10 @@
# define CV_VSX 1
#endif
#ifdef CV_CPU_COMPILE_VSX3
# define CV_VSX3 1
#endif
#endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__
#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX
@@ -237,3 +241,7 @@ struct VZeroUpperGuard {
#ifndef CV_VSX
# define CV_VSX 0
#endif
#ifndef CV_VSX3
# define CV_VSX3 0
#endif
@@ -315,5 +315,26 @@
#endif
#define __CV_CPU_DISPATCH_CHAIN_VSX(fn, args, mode, ...) CV_CPU_CALL_VSX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX3
# define CV_TRY_VSX3 1
# define CV_CPU_FORCE_VSX3 1
# define CV_CPU_HAS_SUPPORT_VSX3 1
# define CV_CPU_CALL_VSX3(fn, args) return (cpu_baseline::fn args)
# define CV_CPU_CALL_VSX3_(fn, args) return (opt_VSX3::fn args)
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX3
# define CV_TRY_VSX3 1
# define CV_CPU_FORCE_VSX3 0
# define CV_CPU_HAS_SUPPORT_VSX3 (cv::checkHardwareSupport(CV_CPU_VSX3))
# define CV_CPU_CALL_VSX3(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args)
# define CV_CPU_CALL_VSX3_(fn, args) if (CV_CPU_HAS_SUPPORT_VSX3) return (opt_VSX3::fn args)
#else
# define CV_TRY_VSX3 0
# define CV_CPU_FORCE_VSX3 0
# define CV_CPU_HAS_SUPPORT_VSX3 0
# define CV_CPU_CALL_VSX3(fn, args)
# define CV_CPU_CALL_VSX3_(fn, args)
#endif
#define __CV_CPU_DISPATCH_CHAIN_VSX3(fn, args, mode, ...) CV_CPU_CALL_VSX3(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
+13 -2
View File
@@ -226,9 +226,10 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
#define CV_CPU_AVX_512VBMI 20
#define CV_CPU_AVX_512VL 21
#define CV_CPU_NEON 100
#define CV_CPU_NEON 100
#define CV_CPU_VSX 200
#define CV_CPU_VSX 200
#define CV_CPU_VSX3 201
// CPU features groups
#define CV_CPU_AVX512_SKX 256
@@ -266,6 +267,7 @@ enum CpuFeatures {
CPU_NEON = 100,
CPU_VSX = 200,
CPU_VSX3 = 201,
CPU_AVX512_SKX = 256, //!< Skylake-X with AVX-512F/CD/BW/DQ/VL
@@ -349,6 +351,15 @@ Cv64suf;
# endif
#endif
#ifndef CV_DEPRECATED_EXTERNAL
# if defined(__OPENCV_BUILD)
# define CV_DEPRECATED_EXTERNAL /* nothing */
# else
# define CV_DEPRECATED_EXTERNAL CV_DEPRECATED
# endif
#endif
#ifndef CV_EXTERN_C
# ifdef __cplusplus
# define CV_EXTERN_C extern "C"
@@ -905,6 +905,11 @@ OPENCV_HAL_IMPL_AVX_CMP_OP_64BIT(v_int64x4)
OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(v_float32x8, ps)
OPENCV_HAL_IMPL_AVX_CMP_OP_FLT(v_float64x4, pd)
inline v_float32x8 v_not_nan(const v_float32x8& a)
{ return v_float32x8(_mm256_cmp_ps(a.val, a.val, _CMP_ORD_Q)); }
inline v_float64x4 v_not_nan(const v_float64x4& a)
{ return v_float64x4(_mm256_cmp_pd(a.val, a.val, _CMP_ORD_Q)); }
/** min/max **/
OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_min, v_uint8x32, _mm256_min_epu8)
OPENCV_HAL_IMPL_AVX_BIN_FUNC(v_max, v_uint8x32, _mm256_max_epu8)
@@ -1128,6 +1133,41 @@ inline v_float32x8 v_reduce_sum4(const v_float32x8& a, const v_float32x8& b,
return v_float32x8(_mm256_hadd_ps(ab, cd));
}
inline unsigned v_reduce_sad(const v_uint8x32& a, const v_uint8x32& b)
{
return (unsigned)_v_cvtsi256_si32(_mm256_sad_epu8(a.val, b.val));
}
inline unsigned v_reduce_sad(const v_int8x32& a, const v_int8x32& b)
{
__m256i half = _mm256_set1_epi8(0x7f);
return (unsigned)_v_cvtsi256_si32(_mm256_sad_epu8(_mm256_add_epi8(a.val, half), _mm256_add_epi8(b.val, half)));
}
inline unsigned v_reduce_sad(const v_uint16x16& a, const v_uint16x16& b)
{
v_uint32x8 l, h;
v_expand(v_add_wrap(a - b, b - a), l, h);
return v_reduce_sum(l + h);
}
inline unsigned v_reduce_sad(const v_int16x16& a, const v_int16x16& b)
{
v_uint32x8 l, h;
v_expand(v_reinterpret_as_u16(v_sub_wrap(v_max(a, b), v_min(a, b))), l, h);
return v_reduce_sum(l + h);
}
inline unsigned v_reduce_sad(const v_uint32x8& a, const v_uint32x8& b)
{
return v_reduce_sum(v_max(a, b) - v_min(a, b));
}
inline unsigned v_reduce_sad(const v_int32x8& a, const v_int32x8& b)
{
v_int32x8 m = a < b;
return v_reduce_sum(v_reinterpret_as_u32(((a - b) ^ m) - m));
}
inline float v_reduce_sad(const v_float32x8& a, const v_float32x8& b)
{
return v_reduce_sum((a - b) & v_float32x8(_mm256_castsi256_ps(_mm256_set1_epi32(0x7fffffff))));
}
/** Popcount **/
#define OPENCV_HAL_IMPL_AVX_POPCOUNT(_Tpvec) \
inline v_uint32x8 v_popcount(const _Tpvec& a) \
@@ -1363,25 +1403,22 @@ inline v_float64x4 v_cvt_f64_high(const v_float32x8& a)
inline v_int32x8 v_lut(const int* tab, const v_int32x8& idxvec)
{
int CV_DECL_ALIGNED(32) idx[8];
v_store_aligned(idx, idxvec);
return v_int32x8(_mm256_setr_epi32(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]],
tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]));
return v_int32x8(_mm256_i32gather_epi32(tab, idxvec.val, 4));
}
inline v_uint32x8 v_lut(const unsigned* tab, const v_int32x8& idxvec)
{
return v_reinterpret_as_u32(v_lut((const int *)tab, idxvec));
}
inline v_float32x8 v_lut(const float* tab, const v_int32x8& idxvec)
{
int CV_DECL_ALIGNED(32) idx[8];
v_store_aligned(idx, idxvec);
return v_float32x8(_mm256_setr_ps(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]],
tab[idx[4]], tab[idx[5]], tab[idx[6]], tab[idx[7]]));
return v_float32x8(_mm256_i32gather_ps(tab, idxvec.val, 4));
}
inline v_float64x4 v_lut(const double* tab, const v_int32x8& idxvec)
{
int CV_DECL_ALIGNED(32) idx[8];
v_store_aligned(idx, idxvec);
return v_float64x4(_mm256_setr_pd(tab[idx[0]], tab[idx[1]], tab[idx[2]], tab[idx[3]]));
return v_float64x4(_mm256_i32gather_pd(tab, _mm256_castsi256_si128(idxvec.val), 8));
}
inline void v_lut_deinterleave(const float* tab, const v_int32x8& idxvec, v_float32x8& x, v_float32x8& y)
@@ -683,6 +683,25 @@ OPENCV_HAL_IMPL_CMP_OP(==)
For all types except 64-bit integer values. */
OPENCV_HAL_IMPL_CMP_OP(!=)
template<int n>
inline v_reg<float, n> v_not_nan(const v_reg<float, n>& a)
{
typedef typename V_TypeTraits<float>::int_type itype;
v_reg<float, n> c;
for (int i = 0; i < n; i++)
c.s[i] = V_TypeTraits<float>::reinterpret_from_int((itype)-(int)(a.s[i] == a.s[i]));
return c;
}
template<int n>
inline v_reg<double, n> v_not_nan(const v_reg<double, n>& a)
{
typedef typename V_TypeTraits<double>::int_type itype;
v_reg<double, n> c;
for (int i = 0; i < n; i++)
c.s[i] = V_TypeTraits<double>::reinterpret_from_int((itype)-(int)(a.s[i] == a.s[i]));
return c;
}
//! @brief Helper macro
//! @ingroup core_hal_intrin_impl
#define OPENCV_HAL_IMPL_ARITHM_OP(func, bin_op, cast_op, _Tp2) \
@@ -1044,6 +1063,21 @@ inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
return r;
}
/** @brief Sum absolute differences of values
Scheme:
@code
{A1 A2 A3 ...} {B1 B2 B3 ...} => sum{ABS(A1-B1),abs(A2-B2),abs(A3-B3),...}
@endcode
For all types except 64-bit types.*/
template<typename _Tp, int n> inline typename V_TypeTraits< typename V_TypeTraits<_Tp>::abs_type >::sum_type v_reduce_sad(const v_reg<_Tp, n>& a, const v_reg<_Tp, n>& b)
{
typename V_TypeTraits< typename V_TypeTraits<_Tp>::abs_type >::sum_type c = _absdiff(a.s[0], b.s[0]);
for (int i = 1; i < n; i++)
c += _absdiff(a.s[i], b.s[i]);
return c;
}
/** @brief Get negative values mask
Returned value is a bit mask with bits set to 1 on places corresponding to negative packed values indexes.
@@ -764,6 +764,13 @@ OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_int64x2, vreinterpretq_s64_u64, s64, u64)
OPENCV_HAL_IMPL_NEON_INT_CMP_OP(v_float64x2, vreinterpretq_f64_u64, f64, u64)
#endif
inline v_float32x4 v_not_nan(const v_float32x4& a)
{ return v_float32x4(vreinterpretq_f32_u32(vceqq_f32(a.val, a.val))); }
#if CV_SIMD128_64F
inline v_float64x2 v_not_nan(const v_float64x2& a)
{ return v_float64x2(vreinterpretq_f64_u64(vceqq_f64(a.val, a.val))); }
#endif
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint8x16, v_add_wrap, vaddq_u8)
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_int8x16, v_add_wrap, vaddq_s8)
OPENCV_HAL_IMPL_NEON_BIN_FUNC(v_uint16x8, v_add_wrap, vaddq_u16)
@@ -992,6 +999,49 @@ inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
return v_float32x4(vaddq_f32(v0, v1));
}
inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b)
{
uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vabdq_u8(a.val, b.val)));
uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0));
return vget_lane_u32(vpadd_u32(t1, t1), 0);
}
inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b)
{
uint32x4_t t0 = vpaddlq_u16(vpaddlq_u8(vreinterpretq_u8_s8(vabdq_s8(a.val, b.val))));
uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0));
return vget_lane_u32(vpadd_u32(t1, t1), 0);
}
inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b)
{
uint32x4_t t0 = vpaddlq_u16(vabdq_u16(a.val, b.val));
uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0));
return vget_lane_u32(vpadd_u32(t1, t1), 0);
}
inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b)
{
uint32x4_t t0 = vpaddlq_u16(vreinterpretq_u16_s16(vabdq_s16(a.val, b.val)));
uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0));
return vget_lane_u32(vpadd_u32(t1, t1), 0);
}
inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b)
{
uint32x4_t t0 = vabdq_u32(a.val, b.val);
uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0));
return vget_lane_u32(vpadd_u32(t1, t1), 0);
}
inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b)
{
uint32x4_t t0 = vreinterpretq_u32_s32(vabdq_s32(a.val, b.val));
uint32x2_t t1 = vpadd_u32(vget_low_u32(t0), vget_high_u32(t0));
return vget_lane_u32(vpadd_u32(t1, t1), 0);
}
inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b)
{
float32x4_t t0 = vabdq_f32(a.val, b.val);
float32x2_t t1 = vpadd_f32(vget_low_f32(t0), vget_high_f32(t0));
return vget_lane_f32(vpadd_f32(t1, t1), 0);
}
#define OPENCV_HAL_IMPL_NEON_POPCOUNT(_Tpvec, cast) \
inline v_uint32x4 v_popcount(const _Tpvec& a) \
{ \
@@ -1041,6 +1041,11 @@ inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \
OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_uint64x2, v_reinterpret_as_u64)
OPENCV_HAL_IMPL_SSE_64BIT_CMP_OP(v_int64x2, v_reinterpret_as_s64)
inline v_float32x4 v_not_nan(const v_float32x4& a)
{ return v_float32x4(_mm_cmpord_ps(a.val, a.val)); }
inline v_float64x2 v_not_nan(const v_float64x2& a)
{ return v_float64x2(_mm_cmpord_pd(a.val, a.val)); }
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint8x16, v_add_wrap, _mm_add_epi8)
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_int8x16, v_add_wrap, _mm_add_epi8)
OPENCV_HAL_IMPL_SSE_BIN_FUNC(v_uint16x8, v_add_wrap, _mm_add_epi16)
@@ -1472,6 +1477,41 @@ OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_int32x4, int, min, std::min)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, max, std::max)
OPENCV_HAL_IMPL_SSE_REDUCE_OP_4(v_float32x4, float, min, std::min)
inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b)
{
return (unsigned)_mm_cvtsi128_si32(_mm_sad_epu8(a.val, b.val));
}
inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b)
{
__m128i half = _mm_set1_epi8(0x7f);
return (unsigned)_mm_cvtsi128_si32(_mm_sad_epu8(_mm_add_epi8(a.val, half),
_mm_add_epi8(b.val, half)));
}
inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b)
{
v_uint32x4 l, h;
v_expand(v_absdiff(a, b), l, h);
return v_reduce_sum(l + h);
}
inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b)
{
v_uint32x4 l, h;
v_expand(v_absdiff(a, b), l, h);
return v_reduce_sum(l + h);
}
inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b)
{
return v_reduce_sum(v_absdiff(a, b));
}
inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b)
{
return v_reduce_sum(v_absdiff(a, b));
}
inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b)
{
return v_reduce_sum(v_absdiff(a, b));
}
#define OPENCV_HAL_IMPL_SSE_POPCOUNT(_Tpvec) \
inline v_uint32x4 v_popcount(const _Tpvec& a) \
{ \
@@ -1925,13 +1965,11 @@ inline void v_load_deinterleave(const unsigned* ptr, v_uint32x4& a, v_uint32x4&
inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b)
{
const int mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1);
__m128 u0 = _mm_loadu_ps(ptr); // a0 b0 a1 b1
__m128 u1 = _mm_loadu_ps((ptr + 4)); // a2 b2 a3 b3
a.val = _mm_shuffle_ps(u0, u1, mask_lo); // a0 a1 a2 a3
b.val = _mm_shuffle_ps(u0, u1, mask_hi); // b0 b1 ab b3
a.val = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(2, 0, 2, 0)); // a0 a1 a2 a3
b.val = _mm_shuffle_ps(u0, u1, _MM_SHUFFLE(3, 1, 3, 1)); // b0 b1 ab b3
}
inline void v_load_deinterleave(const float* ptr, v_float32x4& a, v_float32x4& b, v_float32x4& c)
@@ -607,6 +607,11 @@ OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float64x2)
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint64x2)
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int64x2)
inline v_float32x4 v_not_nan(const v_float32x4& a)
{ return v_float32x4(vec_cmpeq(a.val, a.val)); }
inline v_float64x2 v_not_nan(const v_float64x2& a)
{ return v_float64x2(vec_cmpeq(a.val, a.val)); }
/** min/max **/
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_min, vec_min)
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_max, vec_max)
@@ -734,6 +739,50 @@ inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
return v_float32x4(vec_mergeh(ac, bd));
}
inline unsigned v_reduce_sad(const v_uint8x16& a, const v_uint8x16& b)
{
const vec_uint4 zero4 = vec_uint4_z;
vec_uint4 sum4 = vec_sum4s(vec_absd(a.val, b.val), zero4);
return (unsigned)vec_extract(vec_sums(vec_int4_c(sum4), vec_int4_c(zero4)), 3);
}
inline unsigned v_reduce_sad(const v_int8x16& a, const v_int8x16& b)
{
const vec_int4 zero4 = vec_int4_z;
vec_char16 ad = vec_abss(vec_subs(a.val, b.val));
vec_int4 sum4 = vec_sum4s(ad, zero4);
return (unsigned)vec_extract(vec_sums(sum4, zero4), 3);
}
inline unsigned v_reduce_sad(const v_uint16x8& a, const v_uint16x8& b)
{
vec_ushort8 ad = vec_absd(a.val, b.val);
VSX_UNUSED(vec_int4) sum = vec_sums(vec_int4_c(vec_unpackhu(ad)), vec_int4_c(vec_unpacklu(ad)));
return (unsigned)vec_extract(sum, 3);
}
inline unsigned v_reduce_sad(const v_int16x8& a, const v_int16x8& b)
{
const vec_int4 zero4 = vec_int4_z;
vec_short8 ad = vec_abss(vec_subs(a.val, b.val));
vec_int4 sum4 = vec_sum4s(ad, zero4);
return (unsigned)vec_extract(vec_sums(sum4, zero4), 3);
}
inline unsigned v_reduce_sad(const v_uint32x4& a, const v_uint32x4& b)
{
const vec_uint4 ad = vec_absd(a.val, b.val);
const vec_uint4 rd = vec_add(ad, vec_sld(ad, ad, 8));
return vec_extract(vec_add(rd, vec_sld(rd, rd, 4)), 0);
}
inline unsigned v_reduce_sad(const v_int32x4& a, const v_int32x4& b)
{
vec_int4 ad = vec_abss(vec_sub(a.val, b.val));
return (unsigned)vec_extract(vec_sums(ad, vec_int4_z), 3);
}
inline float v_reduce_sad(const v_float32x4& a, const v_float32x4& b)
{
const vec_float4 ad = vec_abs(vec_sub(a.val, b.val));
const vec_float4 rd = vec_add(ad, vec_sld(ad, ad, 8));
return vec_extract(vec_add(rd, vec_sld(rd, rd, 4)), 0);
}
/** Popcount **/
template<typename _Tpvec>
inline v_uint32x4 v_popcount(const _Tpvec& a)
@@ -565,7 +565,7 @@ public:
//! returns the node content as double
operator double() const;
//! returns the node content as text string
operator std::string() const;
inline operator std::string() const { return this->string(); }
static bool isMap(int flags);
static bool isSeq(int flags);
@@ -599,7 +599,7 @@ public:
//! Simplified reading API to use with bindings.
CV_WRAP double real() const;
//! Simplified reading API to use with bindings.
CV_WRAP String string() const;
CV_WRAP std::string string() const;
//! Simplified reading API to use with bindings.
CV_WRAP Mat mat() const;
@@ -642,8 +642,6 @@ public:
//! returns the currently observed element
FileNode operator *() const;
//! accesses the currently observed element methods
FileNode operator ->() const;
//! moves iterator to the next node
FileNodeIterator& operator ++ ();
@@ -794,6 +794,82 @@ CV_EXPORTS InstrNode* getCurrentNode();
#define CV_INSTRUMENT_REGION(); CV_INSTRUMENT_REGION_();
#endif
namespace cv {
namespace utils {
//! @addtogroup core_utils
//! @{
/** @brief Try to find requested data file
Search directories:
1. Directories passed via `addDataSearchPath()`
2. Check path specified by configuration parameter with "_HINT" suffix (name of environment variable).
3. Check path specified by configuration parameter (name of environment variable).
If parameter value is not empty and nothing is found then stop searching.
4. Detects build/install path based on:
a. current working directory (CWD)
b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
5. Scan `<source>/{,data}` directories if build directory is detected or the current directory is in source tree.
6. Scan `<install>/share/OpenCV` directory if install directory is detected.
@param relative_path Relative path to data file
@param required Specify "file not found" handling.
If true, function prints information message and raises cv::Exception.
If false, function returns empty result
@param configuration_parameter specify configuration parameter name. Default NULL value means "OPENCV_DATA_PATH".
@return Returns path (absolute or relative to the current directory) or empty string if file is not found
@note Implementation is not thread-safe.
*/
CV_EXPORTS
cv::String findDataFile(const cv::String& relative_path, bool required = true,
const char* configuration_parameter = NULL);
/** @overload
@param relative_path Relative path to data file
@param configuration_parameter specify configuration parameter name. Default NULL value means "OPENCV_DATA_PATH".
@param search_paths override addDataSearchPath() settings.
@param subdir_paths override addDataSearchSubDirectory() settings.
@return Returns path (absolute or relative to the current directory) or empty string if file is not found
@note Implementation is not thread-safe.
*/
CV_EXPORTS
cv::String findDataFile(const cv::String& relative_path,
const char* configuration_parameter,
const std::vector<String>* search_paths,
const std::vector<String>* subdir_paths);
/** @brief Override default search data path by adding new search location
Use this only to override default behavior
Passed paths are used in LIFO order.
@param path Path to used samples data
@note Implementation is not thread-safe.
*/
CV_EXPORTS void addDataSearchPath(const cv::String& path);
/** @brief Append default search data sub directory
General usage is to add OpenCV modules name (`<opencv_contrib>/modules/<name>/data` -> `modules/<name>/data` + `<name>/data`).
Passed subdirectories are used in LIFO order.
@param subdir samples data sub directory
@note Implementation is not thread-safe.
*/
CV_EXPORTS void addDataSearchSubDirectory(const cv::String& subdir);
//! @}
} // namespace utils
} // namespace cv
//! @endcond
#endif // OPENCV_CORE_PRIVATE_HPP
@@ -567,7 +567,7 @@ inline void _mm_deinterleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m
inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1)
{
const int mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1);
enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) };
__m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo);
__m128 layer2_chunk2 = _mm_shuffle_ps(v_r0, v_r1, mask_hi);
@@ -588,7 +588,7 @@ inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m12
inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0,
__m128 & v_g1, __m128 & v_b0, __m128 & v_b1)
{
const int mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1);
enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) };
__m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo);
__m128 layer2_chunk3 = _mm_shuffle_ps(v_r0, v_r1, mask_hi);
@@ -615,7 +615,7 @@ inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0,
inline void _mm_interleave_ps(__m128 & v_r0, __m128 & v_r1, __m128 & v_g0, __m128 & v_g1,
__m128 & v_b0, __m128 & v_b1, __m128 & v_a0, __m128 & v_a1)
{
const int mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1);
enum { mask_lo = _MM_SHUFFLE(2, 0, 2, 0), mask_hi = _MM_SHUFFLE(3, 1, 3, 1) };
__m128 layer2_chunk0 = _mm_shuffle_ps(v_r0, v_r1, mask_lo);
__m128 layer2_chunk4 = _mm_shuffle_ps(v_r0, v_r1, mask_hi);
+14 -2
View File
@@ -1941,8 +1941,11 @@ Rect_<_Tp>& operator += ( Rect_<_Tp>& a, const Size_<_Tp>& b )
template<typename _Tp> static inline
Rect_<_Tp>& operator -= ( Rect_<_Tp>& a, const Size_<_Tp>& b )
{
a.width -= b.width;
a.height -= b.height;
const _Tp width = a.width - b.width;
const _Tp height = a.height - b.height;
CV_DbgAssert(width >= 0 && height >= 0);
a.width = width;
a.height = height;
return a;
}
@@ -2007,6 +2010,15 @@ Rect_<_Tp> operator + (const Rect_<_Tp>& a, const Size_<_Tp>& b)
return Rect_<_Tp>( a.x, a.y, a.width + b.width, a.height + b.height );
}
template<typename _Tp> static inline
Rect_<_Tp> operator - (const Rect_<_Tp>& a, const Size_<_Tp>& b)
{
const _Tp width = a.width - b.width;
const _Tp height = a.height - b.height;
CV_DbgAssert(width >= 0 && height >= 0);
return Rect_<_Tp>( a.x, a.y, width, height );
}
template<typename _Tp> static inline
Rect_<_Tp> operator & (const Rect_<_Tp>& a, const Rect_<_Tp>& b)
{
+1 -1
View File
@@ -364,7 +364,7 @@ IplImage;
CV_INLINE IplImage cvIplImage()
{
#if !defined(CV__ENABLE_C_API_CTORS)
#if !(defined(CV__ENABLE_C_API_CTORS) && defined(__cplusplus))
IplImage self = CV_STRUCT_INITIALIZER; self.nSize = sizeof(IplImage); return self;
#else
return _IplImage();
@@ -1234,8 +1234,75 @@ enum FLAGS
CV_EXPORTS void setFlags(FLAGS modeFlags);
static inline void setFlags(int modeFlags) { setFlags((FLAGS)modeFlags); }
CV_EXPORTS FLAGS getFlags();
} // namespace instr
namespace samples {
//! @addtogroup core_utils_samples
// This section describes utility functions for OpenCV samples.
//
// @note Implementation of these utilities is not thread-safe.
//
//! @{
/** @brief Try to find requested data file
Search directories:
1. Directories passed via `addSamplesDataSearchPath()`
2. OPENCV_SAMPLES_DATA_PATH_HINT environment variable
3. OPENCV_SAMPLES_DATA_PATH environment variable
If parameter value is not empty and nothing is found then stop searching.
4. Detects build/install path based on:
a. current working directory (CWD)
b. and/or binary module location (opencv_core/opencv_world, doesn't work with static linkage)
5. Scan `<source>/{,data,samples/data}` directories if build directory is detected or the current directory is in source tree.
6. Scan `<install>/share/OpenCV` directory if install directory is detected.
@see cv::utils::findDataFile
@param relative_path Relative path to data file
@param required Specify "file not found" handling.
If true, function prints information message and raises cv::Exception.
If false, function returns empty result
@param silentMode Disables messages
@return Returns path (absolute or relative to the current directory) or empty string if file is not found
*/
CV_EXPORTS_W cv::String findFile(const cv::String& relative_path, bool required = true, bool silentMode = false);
CV_EXPORTS_W cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode = false);
inline cv::String findFileOrKeep(const cv::String& relative_path, bool silentMode)
{
cv::String res = findFile(relative_path, false, silentMode);
if (res.empty())
return relative_path;
return res;
}
/** @brief Override search data path by adding new search location
Use this only to override default behavior
Passed paths are used in LIFO order.
@param path Path to used samples data
*/
CV_EXPORTS_W void addSamplesDataSearchPath(const cv::String& path);
/** @brief Append samples search data sub directory
General usage is to add OpenCV modules name (`<opencv_contrib>/modules/<name>/samples/data` -> `<name>/samples/data` + `modules/<name>/samples/data`).
Passed subdirectories are used in LIFO order.
@param subdir samples data sub directory
*/
CV_EXPORTS_W void addSamplesDataSearchSubDirectory(const cv::String& subdir);
//! @}
} // namespace samples
namespace utils {
CV_EXPORTS int getThreadID();
@@ -16,6 +16,13 @@ CV_EXPORTS void remove_all(const cv::String& path);
CV_EXPORTS cv::String getcwd();
/** @brief Converts path p to a canonical absolute path
* Symlinks are processed if there is support for them on running platform.
*
* @param path input path. Target file/directory should exist.
*/
CV_EXPORTS cv::String canonical(const cv::String& path);
/** Join path components */
CV_EXPORTS cv::String join(const cv::String& base, const cv::String& path);
@@ -7,8 +7,8 @@
#define CV_VERSION_MAJOR 4
#define CV_VERSION_MINOR 0
#define CV_VERSION_REVISION 0
#define CV_VERSION_STATUS "-rc"
#define CV_VERSION_REVISION 1
#define CV_VERSION_STATUS "-openvino"
#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
+49
View File
@@ -253,4 +253,53 @@ PERF_TEST_P( Size_MatType, normalize_minmax, TYPICAL_MATS )
SANITY_CHECK(dst, 1e-6, ERROR_RELATIVE);
}
typedef TestBaseWithParam< int > test_len;
PERF_TEST_P(test_len, hal_normL1_u8,
testing::Values(300000, 2000000)
)
{
int len = GetParam();
Mat src1(1, len, CV_8UC1);
Mat src2(1, len, CV_8UC1);
declare.in(src1, src2, WARMUP_RNG);
double n;
TEST_CYCLE() n = hal::normL1_(src1.ptr<uchar>(0), src2.ptr<uchar>(0), len);
CV_UNUSED(n);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(test_len, hal_normL1_f32,
testing::Values(300000, 2000000)
)
{
int len = GetParam();
Mat src1(1, len, CV_32FC1);
Mat src2(1, len, CV_32FC1);
declare.in(src1, src2, WARMUP_RNG);
double n;
TEST_CYCLE() n = hal::normL1_(src1.ptr<float>(0), src2.ptr<float>(0), len);
CV_UNUSED(n);
SANITY_CHECK_NOTHING();
}
PERF_TEST_P(test_len, hal_normL2Sqr,
testing::Values(300000, 2000000)
)
{
int len = GetParam();
Mat src1(1, len, CV_32FC1);
Mat src2(1, len, CV_32FC1);
declare.in(src1, src2, WARMUP_RNG);
double n;
TEST_CYCLE() n = hal::normL2Sqr_(src1.ptr<float>(0), src2.ptr<float>(0), len);
CV_UNUSED(n);
SANITY_CHECK_NOTHING();
}
} // namespace
+43 -37
View File
@@ -1333,7 +1333,7 @@ struct InRange_SIMD
}
};
#if CV_SIMD128
#if CV_SIMD
template <>
struct InRange_SIMD<uchar>
@@ -1342,16 +1342,17 @@ struct InRange_SIMD<uchar>
uchar * dst, int len) const
{
int x = 0;
const int width = v_uint8x16::nlanes;
const int width = v_uint8::nlanes;
for (; x <= len - width; x += width)
{
v_uint8x16 values = v_load(src1 + x);
v_uint8x16 low = v_load(src2 + x);
v_uint8x16 high = v_load(src3 + x);
v_uint8 values = vx_load(src1 + x);
v_uint8 low = vx_load(src2 + x);
v_uint8 high = vx_load(src3 + x);
v_store(dst + x, (values >= low) & (high >= values));
}
vx_cleanup();
return x;
}
};
@@ -1363,16 +1364,17 @@ struct InRange_SIMD<schar>
uchar * dst, int len) const
{
int x = 0;
const int width = v_int8x16::nlanes;
const int width = v_int8::nlanes;
for (; x <= len - width; x += width)
{
v_int8x16 values = v_load(src1 + x);
v_int8x16 low = v_load(src2 + x);
v_int8x16 high = v_load(src3 + x);
v_int8 values = vx_load(src1 + x);
v_int8 low = vx_load(src2 + x);
v_int8 high = vx_load(src3 + x);
v_store((schar*)(dst + x), (values >= low) & (high >= values));
}
vx_cleanup();
return x;
}
};
@@ -1384,20 +1386,21 @@ struct InRange_SIMD<ushort>
uchar * dst, int len) const
{
int x = 0;
const int width = v_uint16x8::nlanes * 2;
const int width = v_uint16::nlanes * 2;
for (; x <= len - width; x += width)
{
v_uint16x8 values1 = v_load(src1 + x);
v_uint16x8 low1 = v_load(src2 + x);
v_uint16x8 high1 = v_load(src3 + x);
v_uint16 values1 = vx_load(src1 + x);
v_uint16 low1 = vx_load(src2 + x);
v_uint16 high1 = vx_load(src3 + x);
v_uint16x8 values2 = v_load(src1 + x + v_uint16x8::nlanes);
v_uint16x8 low2 = v_load(src2 + x + v_uint16x8::nlanes);
v_uint16x8 high2 = v_load(src3 + x + v_uint16x8::nlanes);
v_uint16 values2 = vx_load(src1 + x + v_uint16::nlanes);
v_uint16 low2 = vx_load(src2 + x + v_uint16::nlanes);
v_uint16 high2 = vx_load(src3 + x + v_uint16::nlanes);
v_store(dst + x, v_pack((values1 >= low1) & (high1 >= values1), (values2 >= low2) & (high2 >= values2)));
}
vx_cleanup();
return x;
}
};
@@ -1409,20 +1412,21 @@ struct InRange_SIMD<short>
uchar * dst, int len) const
{
int x = 0;
const int width = (int)v_int16x8::nlanes * 2;
const int width = (int)v_int16::nlanes * 2;
for (; x <= len - width; x += width)
{
v_int16x8 values1 = v_load(src1 + x);
v_int16x8 low1 = v_load(src2 + x);
v_int16x8 high1 = v_load(src3 + x);
v_int16 values1 = vx_load(src1 + x);
v_int16 low1 = vx_load(src2 + x);
v_int16 high1 = vx_load(src3 + x);
v_int16x8 values2 = v_load(src1 + x + v_int16x8::nlanes);
v_int16x8 low2 = v_load(src2 + x + v_int16x8::nlanes);
v_int16x8 high2 = v_load(src3 + x + v_int16x8::nlanes);
v_int16 values2 = vx_load(src1 + x + v_int16::nlanes);
v_int16 low2 = vx_load(src2 + x + v_int16::nlanes);
v_int16 high2 = vx_load(src3 + x + v_int16::nlanes);
v_store((schar*)(dst + x), v_pack((values1 >= low1) & (high1 >= values1), (values2 >= low2) & (high2 >= values2)));
}
vx_cleanup();
return x;
}
};
@@ -1434,20 +1438,21 @@ struct InRange_SIMD<int>
uchar * dst, int len) const
{
int x = 0;
const int width = (int)v_int32x4::nlanes * 2;
const int width = (int)v_int32::nlanes * 2;
for (; x <= len - width; x += width)
{
v_int32x4 values1 = v_load(src1 + x);
v_int32x4 low1 = v_load(src2 + x);
v_int32x4 high1 = v_load(src3 + x);
v_int32 values1 = vx_load(src1 + x);
v_int32 low1 = vx_load(src2 + x);
v_int32 high1 = vx_load(src3 + x);
v_int32x4 values2 = v_load(src1 + x + v_int32x4::nlanes);
v_int32x4 low2 = v_load(src2 + x + v_int32x4::nlanes);
v_int32x4 high2 = v_load(src3 + x + v_int32x4::nlanes);
v_int32 values2 = vx_load(src1 + x + v_int32::nlanes);
v_int32 low2 = vx_load(src2 + x + v_int32::nlanes);
v_int32 high2 = vx_load(src3 + x + v_int32::nlanes);
v_pack_store(dst + x, v_reinterpret_as_u16(v_pack((values1 >= low1) & (high1 >= values1), (values2 >= low2) & (high2 >= values2))));
}
vx_cleanup();
return x;
}
};
@@ -1459,20 +1464,21 @@ struct InRange_SIMD<float>
uchar * dst, int len) const
{
int x = 0;
const int width = (int)v_float32x4::nlanes * 2;
const int width = (int)v_float32::nlanes * 2;
for (; x <= len - width; x += width)
{
v_float32x4 values1 = v_load(src1 + x);
v_float32x4 low1 = v_load(src2 + x);
v_float32x4 high1 = v_load(src3 + x);
v_float32 values1 = vx_load(src1 + x);
v_float32 low1 = vx_load(src2 + x);
v_float32 high1 = vx_load(src3 + x);
v_float32x4 values2 = v_load(src1 + x + v_float32x4::nlanes);
v_float32x4 low2 = v_load(src2 + x + v_float32x4::nlanes);
v_float32x4 high2 = v_load(src3 + x + v_float32x4::nlanes);
v_float32 values2 = vx_load(src1 + x + v_float32::nlanes);
v_float32 low2 = vx_load(src2 + x + v_float32::nlanes);
v_float32 high2 = vx_load(src3 + x + v_float32::nlanes);
v_pack_store(dst + x, v_pack(v_reinterpret_as_u32((values1 >= low1) & (high1 >= values1)), v_reinterpret_as_u32((values2 >= low2) & (high2 >= values2))));
}
vx_cleanup();
return x;
}
};
+11 -2
View File
@@ -297,19 +297,21 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
nidx = Scalar::all(-1);
}
if( crosscheck )
{
CV_Assert( K == 1 && update == 0 && mask.empty() );
CV_Assert(!nidx.empty());
Mat tdist, tidx;
Mat tdist, tidx, sdist, sidx;
batchDistance(src2, src1, tdist, dtype, tidx, normType, K, mask, 0, false);
batchDistance(src1, src2, sdist, dtype, sidx, normType, K, mask, 0, false);
// if an idx-th element from src1 appeared to be the nearest to i-th element of src2,
// we update the minimum mutual distance between idx-th element of src1 and the whole src2 set.
// As a result, if nidx[idx] = i*, it means that idx-th element of src1 is the nearest
// to i*-th element of src2 and i*-th element of src2 is the closest to idx-th element of src1.
// If nidx[idx] = -1, it means that there is no such ideal couple for it in src2.
// This O(N) procedure is called cross-check and it helps to eliminate some false matches.
// This O(2N) procedure is called cross-check and it helps to eliminate some false matches.
if( dtype == CV_32S )
{
for( int i = 0; i < tdist.rows; i++ )
@@ -336,6 +338,13 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
}
}
}
for( int i = 0; i < sdist.rows; i++ )
{
if( tidx.at<int>(sidx.at<int>(i)) != i )
{
nidx.at<int>(i) = -1;
}
}
return;
}
+2 -2
View File
@@ -1183,9 +1183,9 @@ void cv::copyMakeBorder( InputArray _src, OutputArray _dst, int top, int bottom,
{
CV_INSTRUMENT_REGION();
CV_Assert( top >= 0 && bottom >= 0 && left >= 0 && right >= 0 );
CV_Assert( top >= 0 && bottom >= 0 && left >= 0 && right >= 0 && _src.dims() <= 2);
CV_OCL_RUN(_dst.isUMat() && _src.dims() <= 2,
CV_OCL_RUN(_dst.isUMat(),
ocl_copyMakeBorder(_src, _dst, top, bottom, left, right, borderType, value))
Mat src = _src.getMat();
+3 -1
View File
@@ -1699,7 +1699,7 @@ transform_( const T* src, T* dst, const WT* m, int len, int scn, int dcn )
}
}
#if CV_SIMD128
#if CV_SIMD128 && !defined(__aarch64__)
static inline void
load3x3Matrix(const float* m, v_float32x4& m0, v_float32x4& m1, v_float32x4& m2, v_float32x4& m3)
{
@@ -1708,7 +1708,9 @@ load3x3Matrix(const float* m, v_float32x4& m0, v_float32x4& m1, v_float32x4& m2,
m2 = v_float32x4(m[2], m[6], m[10], 0);
m3 = v_float32x4(m[3], m[7], m[11], 0);
}
#endif
#if CV_SIMD128
static inline v_int16x8
v_matmulvec(const v_int16x8 &v0, const v_int16x8 &m0, const v_int16x8 &m1, const v_int16x8 &m2, const v_int32x4 &m3, const int BITS)
{
+15 -105
View File
@@ -98,43 +98,15 @@ int normHamming(const uchar* a, const uchar* b, int n, int cellSize)
float normL2Sqr_(const float* a, const float* b, int n)
{
int j = 0; float d = 0.f;
#if CV_AVX2
float CV_DECL_ALIGNED(32) buf[8];
__m256 d0 = _mm256_setzero_ps();
for( ; j <= n - 8; j += 8 )
#if CV_SIMD
v_float32 v_d = vx_setzero_f32();
for (; j <= n - v_float32::nlanes; j += v_float32::nlanes)
{
__m256 t0 = _mm256_sub_ps(_mm256_loadu_ps(a + j), _mm256_loadu_ps(b + j));
#if CV_FMA3
d0 = _mm256_fmadd_ps(t0, t0, d0);
#else
d0 = _mm256_add_ps(d0, _mm256_mul_ps(t0, t0));
v_float32 t = vx_load(a + j) - vx_load(b + j);
v_d = v_muladd(t, t, v_d);
}
d = v_reduce_sum(v_d);
#endif
}
_mm256_store_ps(buf, d0);
d = buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + buf[5] + buf[6] + buf[7];
#elif CV_SSE
float CV_DECL_ALIGNED(16) buf[4];
__m128 d0 = _mm_setzero_ps(), d1 = _mm_setzero_ps();
for( ; j <= n - 8; j += 8 )
{
__m128 t0 = _mm_sub_ps(_mm_loadu_ps(a + j), _mm_loadu_ps(b + j));
__m128 t1 = _mm_sub_ps(_mm_loadu_ps(a + j + 4), _mm_loadu_ps(b + j + 4));
d0 = _mm_add_ps(d0, _mm_mul_ps(t0, t0));
d1 = _mm_add_ps(d1, _mm_mul_ps(t1, t1));
}
_mm_store_ps(buf, _mm_add_ps(d0, d1));
d = buf[0] + buf[1] + buf[2] + buf[3];
#endif
{
for( ; j <= n - 4; j += 4 )
{
float t0 = a[j] - b[j], t1 = a[j+1] - b[j+1], t2 = a[j+2] - b[j+2], t3 = a[j+3] - b[j+3];
d += t0*t0 + t1*t1 + t2*t2 + t3*t3;
}
}
for( ; j < n; j++ )
{
float t = a[j] - b[j];
@@ -147,38 +119,12 @@ float normL2Sqr_(const float* a, const float* b, int n)
float normL1_(const float* a, const float* b, int n)
{
int j = 0; float d = 0.f;
#if CV_SSE
float CV_DECL_ALIGNED(16) buf[4];
static const int CV_DECL_ALIGNED(16) absbuf[4] = {0x7fffffff, 0x7fffffff, 0x7fffffff, 0x7fffffff};
__m128 d0 = _mm_setzero_ps(), d1 = _mm_setzero_ps();
__m128 absmask = _mm_load_ps((const float*)absbuf);
for( ; j <= n - 8; j += 8 )
{
__m128 t0 = _mm_sub_ps(_mm_loadu_ps(a + j), _mm_loadu_ps(b + j));
__m128 t1 = _mm_sub_ps(_mm_loadu_ps(a + j + 4), _mm_loadu_ps(b + j + 4));
d0 = _mm_add_ps(d0, _mm_and_ps(t0, absmask));
d1 = _mm_add_ps(d1, _mm_and_ps(t1, absmask));
}
_mm_store_ps(buf, _mm_add_ps(d0, d1));
d = buf[0] + buf[1] + buf[2] + buf[3];
#elif CV_NEON
float32x4_t v_sum = vdupq_n_f32(0.0f);
for ( ; j <= n - 4; j += 4)
v_sum = vaddq_f32(v_sum, vabdq_f32(vld1q_f32(a + j), vld1q_f32(b + j)));
float CV_DECL_ALIGNED(16) buf[4];
vst1q_f32(buf, v_sum);
d = buf[0] + buf[1] + buf[2] + buf[3];
#if CV_SIMD
v_float32 v_d = vx_setzero_f32();
for (; j <= n - v_float32::nlanes; j += v_float32::nlanes)
v_d += v_absdiff(vx_load(a + j), vx_load(b + j));
d = v_reduce_sum(v_d);
#endif
{
for( ; j <= n - 4; j += 4 )
{
d += std::abs(a[j] - b[j]) + std::abs(a[j+1] - b[j+1]) +
std::abs(a[j+2] - b[j+2]) + std::abs(a[j+3] - b[j+3]);
}
}
for( ; j < n; j++ )
d += std::abs(a[j] - b[j]);
return d;
@@ -187,46 +133,10 @@ float normL1_(const float* a, const float* b, int n)
int normL1_(const uchar* a, const uchar* b, int n)
{
int j = 0, d = 0;
#if CV_SSE
__m128i d0 = _mm_setzero_si128();
for( ; j <= n - 16; j += 16 )
{
__m128i t0 = _mm_loadu_si128((const __m128i*)(a + j));
__m128i t1 = _mm_loadu_si128((const __m128i*)(b + j));
d0 = _mm_add_epi32(d0, _mm_sad_epu8(t0, t1));
}
for( ; j <= n - 4; j += 4 )
{
__m128i t0 = _mm_cvtsi32_si128(*(const int*)(a + j));
__m128i t1 = _mm_cvtsi32_si128(*(const int*)(b + j));
d0 = _mm_add_epi32(d0, _mm_sad_epu8(t0, t1));
}
d = _mm_cvtsi128_si32(_mm_add_epi32(d0, _mm_unpackhi_epi64(d0, d0)));
#elif CV_NEON
uint32x4_t v_sum = vdupq_n_u32(0.0f);
for ( ; j <= n - 16; j += 16)
{
uint8x16_t v_dst = vabdq_u8(vld1q_u8(a + j), vld1q_u8(b + j));
uint16x8_t v_low = vmovl_u8(vget_low_u8(v_dst)), v_high = vmovl_u8(vget_high_u8(v_dst));
v_sum = vaddq_u32(v_sum, vaddl_u16(vget_low_u16(v_low), vget_low_u16(v_high)));
v_sum = vaddq_u32(v_sum, vaddl_u16(vget_high_u16(v_low), vget_high_u16(v_high)));
}
uint CV_DECL_ALIGNED(16) buf[4];
vst1q_u32(buf, v_sum);
d = buf[0] + buf[1] + buf[2] + buf[3];
#if CV_SIMD
for (; j <= n - v_uint8::nlanes; j += v_uint8::nlanes)
d += v_reduce_sad(vx_load(a + j), vx_load(b + j));
#endif
{
for( ; j <= n - 4; j += 4 )
{
d += std::abs(a[j] - b[j]) + std::abs(a[j+1] - b[j+1]) +
std::abs(a[j+2] - b[j+2]) + std::abs(a[j+3] - b[j+3]);
}
}
for( ; j < n; j++ )
d += std::abs(a[j] - b[j]);
return d;
+7
View File
@@ -2772,6 +2772,7 @@ struct Kernel::Impl
for( int i = 0; i < MAX_ARRS; i++ )
u[i] = 0;
haveTempDstUMats = false;
haveTempSrcUMats = false;
}
void cleanupUMats()
@@ -2788,6 +2789,7 @@ struct Kernel::Impl
}
nu = 0;
haveTempDstUMats = false;
haveTempSrcUMats = false;
}
void addUMat(const UMat& m, bool dst)
@@ -2798,6 +2800,8 @@ struct Kernel::Impl
nu++;
if(dst && m.u->tempUMat())
haveTempDstUMats = true;
if(m.u->originalUMatData == NULL && m.u->tempUMat())
haveTempSrcUMats = true; // UMat is created on RAW memory (without proper lifetime management, even from Mat)
}
void addImage(const Image2D& image)
@@ -2835,6 +2839,7 @@ struct Kernel::Impl
int nu;
std::list<Image2D> images;
bool haveTempDstUMats;
bool haveTempSrcUMats;
};
}} // namespace cv::ocl
@@ -3108,6 +3113,8 @@ bool Kernel::Impl::run(int dims, size_t globalsize[], size_t localsize[],
cl_command_queue qq = getQueue(q);
if (haveTempDstUMats)
sync = true;
if (haveTempSrcUMats)
sync = true;
if (timeNS)
sync = true;
cl_event asyncEvent = 0;
+1 -1
View File
@@ -454,7 +454,7 @@ static inline int _initMaxThreads()
{
omp_set_dynamic(maxThreads);
}
return numThreads;
return maxThreads;
}
static int numThreadsMax = _initMaxThreads();
#elif defined HAVE_GCD
+14 -14
View File
@@ -114,9 +114,11 @@ char* floatToString( char* buf, float value, bool halfprecision, bool explicitZe
}
else
{
static const char* fmt = halfprecision ? "%.4e" : "%.8e";
char* ptr = buf;
sprintf( buf, fmt, value );
if (halfprecision)
sprintf(buf, "%.4e", value);
else
sprintf(buf, "%.8e", value);
if( *ptr == '+' || *ptr == '-' )
ptr++;
for( ; cv_isdigit(*ptr); ptr++ )
@@ -350,6 +352,7 @@ public:
void init()
{
flags = 0;
buffer.clear();
bufofs = 0;
state = UNDEFINED;
@@ -358,6 +361,7 @@ public:
write_mode = false;
mem_mode = false;
space = 0;
wrap_margin = 71;
fmt = 0;
file = 0;
gzfile = 0;
@@ -615,7 +619,8 @@ public:
for(;;)
{
int line_offset = (int)ftell( file );
char* ptr0 = gets( &xml_buf_[0], xml_buf_size ), *ptr;
const char* ptr0 = this->gets(&xml_buf_[0], xml_buf_size );
const char* ptr = NULL;
if( !ptr0 )
break;
ptr = ptr0;
@@ -708,7 +713,7 @@ public:
const char* json_signature = "{";
const char* xml_signature = "<?xml";
char buf[16];
gets( buf, sizeof(buf)-2 );
this->gets( buf, sizeof(buf)-2 );
char* bufPtr = cv_skip_BOM(buf);
size_t bufOffset = bufPtr - buf;
@@ -861,7 +866,7 @@ public:
char* gets()
{
char* ptr = gets(bufferStart(), (int)(bufferEnd() - bufferStart()));
char* ptr = this->gets(bufferStart(), (int)(bufferEnd() - bufferStart()));
if( !ptr )
{
ptr = bufferStart(); // FIXIT Why do we need this hack? What is about other parsers JSON/YAML?
@@ -1766,11 +1771,13 @@ public:
};
FileStorage::FileStorage()
: state(0)
{
p = makePtr<FileStorage::Impl>(this);
}
FileStorage::FileStorage(const String& filename, int flags, const String& encoding)
: state(0)
{
p = makePtr<FileStorage::Impl>(this);
bool ok = p->open(filename.c_str(), flags, encoding.c_str());
@@ -2197,7 +2204,8 @@ FileNode::operator double() const
return DBL_MAX;
}
FileNode::operator std::string() const
double FileNode::real() const { return double(*this); }
std::string FileNode::string() const
{
const uchar* p = ptr();
if( !p || (*p & TYPE_MASK) != STRING )
@@ -2206,9 +2214,6 @@ FileNode::operator std::string() const
size_t sz = (size_t)(unsigned)readInt(p);
return std::string((const char*)(p + 4), sz - 1);
}
double FileNode::real() const { return double(*this); }
std::string FileNode::string() const { return std::string(*this); }
Mat FileNode::mat() const { Mat value; read(*this, value, Mat()); return value; }
FileNodeIterator FileNode::begin() const { return FileNodeIterator(*this, false); }
@@ -2388,11 +2393,6 @@ FileNode FileNodeIterator::operator *() const
return FileNode(idx < nodeNElems ? fs : 0, blockIdx, ofs);
}
FileNode FileNodeIterator::operator ->() const
{
return FileNode(idx < nodeNElems ? fs : 0, blockIdx, ofs);
}
FileNodeIterator& FileNodeIterator::operator ++ ()
{
if( idx == nodeNElems || !fs )
+12 -2
View File
@@ -96,11 +96,20 @@ int decodeFormat( const char* dt, int* fmt_pairs, int max_len );
int decodeSimpleFormat( const char* dt );
}
#ifdef CV_STATIC_ANALYSIS
#define CV_PARSE_ERROR_CPP(errmsg) do { (void)fs; abort(); } while (0)
#else
#define CV_PARSE_ERROR_CPP( errmsg ) \
fs->parseError( CV_Func, (errmsg), __FILE__, __LINE__ )
#endif
#define CV_PERSISTENCE_CHECK_END_OF_BUFFER_BUG_CPP() do { \
CV_DbgAssert(ptr); \
if((ptr)[0] == 0 && (ptr) == fs->bufferEnd() - 1) CV_PARSE_ERROR_CPP("OpenCV persistence doesn't support very long lines"); \
} while (0)
#define CV_PERSISTENCE_CHECK_END_OF_BUFFER_BUG_CPP() \
if((ptr)[0] == 0 && (ptr) == fs->bufferEnd() - 1) CV_PARSE_ERROR_CPP("OpenCV persistence doesn't support very long lines")
class FileStorageParser;
class FileStorageEmitter;
@@ -151,6 +160,7 @@ public:
virtual double strtod(char* ptr, char** endptr) = 0;
virtual char* parseBase64(char* ptr, int indent, FileNode& collection) = 0;
CV_NORETURN
virtual void parseError(const char* funcname, const std::string& msg,
const char* filename, int lineno) = 0;
};
+15 -15
View File
@@ -107,15 +107,14 @@ void* allocSingletonBuffer(size_t size) { return fastMalloc(size); }
# include <cpu-features.h>
#endif
#ifndef __VSX__
# if defined __PPC64__ && defined __linux__
# include "sys/auxv.h"
# ifndef AT_HWCAP2
# define AT_HWCAP2 26
# endif
# ifndef PPC_FEATURE2_ARCH_2_07
# define PPC_FEATURE2_ARCH_2_07 0x80000000
# endif
#if CV_VSX && defined __linux__
# include "sys/auxv.h"
# ifndef AT_HWCAP2
# define AT_HWCAP2 26
# endif
# ifndef PPC_FEATURE2_ARCH_3_00
# define PPC_FEATURE2_ARCH_3_00 0x00800000
# endif
#endif
@@ -359,6 +358,7 @@ struct HWFeatures
g_hwFeatureNames[CPU_NEON] = "NEON";
g_hwFeatureNames[CPU_VSX] = "VSX";
g_hwFeatureNames[CPU_VSX3] = "VSX3";
g_hwFeatureNames[CPU_AVX512_SKX] = "AVX512-SKX";
}
@@ -513,14 +513,14 @@ struct HWFeatures
#endif
#endif
#ifdef __VSX__
have[CV_CPU_VSX] = true;
#elif (defined __PPC64__ && defined __linux__)
uint64 hwcaps = getauxval(AT_HWCAP);
// there's no need to check VSX availability in runtime since it's always available on ppc64le CPUs
have[CV_CPU_VSX] = (CV_VSX);
// TODO: Check VSX3 availability in runtime for other platforms
#if CV_VSX && defined __linux__
uint64 hwcap2 = getauxval(AT_HWCAP2);
have[CV_CPU_VSX] = (hwcaps & PPC_FEATURE_PPC_LE && hwcaps & PPC_FEATURE_HAS_VSX && hwcap2 & PPC_FEATURE2_ARCH_2_07);
have[CV_CPU_VSX3] = (hwcap2 & PPC_FEATURE2_ARCH_3_00);
#else
have[CV_CPU_VSX] = false;
have[CV_CPU_VSX3] = (CV_VSX3);
#endif
int baseline_features[] = { CV_CPU_BASELINE_FEATURES };
+383
View File
@@ -0,0 +1,383 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "../precomp.hpp"
#include "opencv_data_config.hpp"
#include <vector>
#include <fstream>
#include <opencv2/core/utils/logger.defines.hpp>
#undef CV_LOG_STRIP_LEVEL
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
#include "opencv2/core/utils/logger.hpp"
#include "opencv2/core/utils/filesystem.hpp"
#include <opencv2/core/utils/configuration.private.hpp>
#ifdef _WIN32
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#undef small
#undef min
#undef max
#undef abs
#elif defined(__linux__)
#include <dlfcn.h> // requires -ldl
#elif defined(__APPLE__)
#include <TargetConditionals.h>
#if TARGET_OS_MAC
#include <dlfcn.h>
#endif
#endif
namespace cv { namespace utils {
static cv::Ptr< std::vector<cv::String> > g_data_search_path;
static cv::Ptr< std::vector<cv::String> > g_data_search_subdir;
static std::vector<cv::String>& _getDataSearchPath()
{
if (g_data_search_path.empty())
g_data_search_path.reset(new std::vector<cv::String>());
return *(g_data_search_path.get());
}
static std::vector<cv::String>& _getDataSearchSubDirectory()
{
if (g_data_search_subdir.empty())
{
g_data_search_subdir.reset(new std::vector<cv::String>());
g_data_search_subdir->push_back("data");
g_data_search_subdir->push_back("");
}
return *(g_data_search_subdir.get());
}
CV_EXPORTS void addDataSearchPath(const cv::String& path)
{
if (utils::fs::isDirectory(path))
_getDataSearchPath().push_back(path);
}
CV_EXPORTS void addDataSearchSubDirectory(const cv::String& subdir)
{
_getDataSearchSubDirectory().push_back(subdir);
}
static bool isPathSep(char c)
{
return c == '/' || c == '\\';
}
static bool isSubDirectory_(const cv::String& base_path, const cv::String& path)
{
size_t N = base_path.size();
if (N == 0)
return false;
if (isPathSep(base_path[N - 1]))
N--;
if (path.size() < N)
return false;
for (size_t i = 0; i < N; i++)
{
if (path[i] == base_path[i])
continue;
if (isPathSep(path[i]) && isPathSep(base_path[i]))
continue;
return false;
}
size_t M = path.size();
if (M > N)
{
if (!isPathSep(path[N]))
return false;
}
return true;
}
static bool isSubDirectory(const cv::String& base_path, const cv::String& path)
{
bool res = isSubDirectory_(base_path, path);
CV_LOG_VERBOSE(NULL, 0, "isSubDirectory(): base: " << base_path << " path: " << path << " => result: " << (res ? "TRUE" : "FALSE"));
return res;
}
static cv::String getModuleLocation(const void* addr)
{
CV_UNUSED(addr);
#ifdef _WIN32
HMODULE m = 0;
#if _WIN32_WINNT >= 0x0501
::GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
reinterpret_cast<LPCTSTR>(addr),
&m);
#endif
if (m)
{
char path[MAX_PATH];
const size_t path_size = sizeof(path)/sizeof(*path);
size_t sz = GetModuleFileNameA(m, path, path_size); // no unicode support
if (sz > 0 && sz < path_size)
{
path[sz] = '\0';
return cv::String(path);
}
}
#elif defined(__linux__)
Dl_info info;
if (0 != dladdr(addr, &info))
{
return cv::String(info.dli_fname);
}
#elif defined(__APPLE__)
# if TARGET_OS_MAC
Dl_info info;
if (0 != dladdr(addr, &info))
{
return cv::String(info.dli_fname);
}
# endif
#else
// not supported, skip
#endif
return cv::String();
}
cv::String findDataFile(const cv::String& relative_path,
const char* configuration_parameter,
const std::vector<String>* search_paths,
const std::vector<String>* subdir_paths)
{
configuration_parameter = configuration_parameter ? configuration_parameter : "OPENCV_DATA_PATH";
CV_LOG_DEBUG(NULL, cv::format("utils::findDataFile('%s', %s)", relative_path.c_str(), configuration_parameter));
#define TRY_FILE_WITH_PREFIX(prefix) \
{ \
cv::String path = utils::fs::join(prefix, relative_path); \
CV_LOG_DEBUG(NULL, cv::format("... Line %d: trying open '%s'", __LINE__, path.c_str())); \
FILE* f = fopen(path.c_str(), "rb"); \
if(f) { \
fclose(f); \
return path; \
} \
}
// Step 0: check current directory or absolute path at first
TRY_FILE_WITH_PREFIX("");
// Step 1
const std::vector<cv::String>& search_path = search_paths ? *search_paths : _getDataSearchPath();
for(size_t i = search_path.size(); i > 0; i--)
{
const cv::String& prefix = search_path[i - 1];
TRY_FILE_WITH_PREFIX(prefix);
}
const std::vector<cv::String>& search_subdir = subdir_paths ? *subdir_paths : _getDataSearchSubDirectory();
// Step 2
const cv::String configuration_parameter_s(configuration_parameter ? configuration_parameter : "");
const cv::utils::Paths& search_hint = configuration_parameter_s.empty() ? cv::utils::Paths()
: getConfigurationParameterPaths((configuration_parameter_s + "_HINT").c_str());
for (size_t k = 0; k < search_hint.size(); k++)
{
cv::String datapath = search_hint[k];
if (datapath.empty())
continue;
if (utils::fs::isDirectory(datapath))
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): trying " << configuration_parameter << "_HINT=" << datapath);
for(size_t i = search_subdir.size(); i > 0; i--)
{
const cv::String& subdir = search_subdir[i - 1];
cv::String prefix = utils::fs::join(datapath, subdir);
TRY_FILE_WITH_PREFIX(prefix);
}
}
else
{
CV_LOG_WARNING(NULL, configuration_parameter << "_HINT is specified but it is not a directory: " << datapath);
}
}
// Step 3
const cv::utils::Paths& override_paths = configuration_parameter_s.empty() ? cv::utils::Paths()
: getConfigurationParameterPaths(configuration_parameter);
for (size_t k = 0; k < override_paths.size(); k++)
{
cv::String datapath = override_paths[k];
if (datapath.empty())
continue;
if (utils::fs::isDirectory(datapath))
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): trying " << configuration_parameter << "=" << datapath);
for(size_t i = search_subdir.size(); i > 0; i--)
{
const cv::String& subdir = search_subdir[i - 1];
cv::String prefix = utils::fs::join(datapath, subdir);
TRY_FILE_WITH_PREFIX(prefix);
}
}
else
{
CV_LOG_WARNING(NULL, configuration_parameter << " is specified but it is not a directory: " << datapath);
}
}
if (!override_paths.empty())
{
CV_LOG_INFO(NULL, "utils::findDataFile(): can't find data file via " << configuration_parameter << " configuration override: " << relative_path);
return cv::String();
}
// Steps: 4, 5, 6
cv::String cwd = utils::fs::getcwd();
cv::String build_dir(OPENCV_BUILD_DIR);
bool has_tested_build_directory = false;
if (isSubDirectory(build_dir, cwd) || isSubDirectory(utils::fs::canonical(build_dir), utils::fs::canonical(cwd)))
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): the current directory is build sub-directory: " << cwd);
const char* build_subdirs[] = { OPENCV_DATA_BUILD_DIR_SEARCH_PATHS };
for (size_t k = 0; k < sizeof(build_subdirs)/sizeof(build_subdirs[0]); k++)
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): <build>/" << build_subdirs[k]);
cv::String datapath = utils::fs::join(build_dir, build_subdirs[k]);
if (utils::fs::isDirectory(datapath))
{
for(size_t i = search_subdir.size(); i > 0; i--)
{
const cv::String& subdir = search_subdir[i - 1];
cv::String prefix = utils::fs::join(datapath, subdir);
TRY_FILE_WITH_PREFIX(prefix);
}
}
}
has_tested_build_directory = true;
}
cv::String source_dir;
cv::String try_source_dir = cwd;
for (int levels = 0; levels < 3; ++levels)
{
if (utils::fs::exists(utils::fs::join(try_source_dir, "modules/core/include/opencv2/core/version.hpp")))
{
source_dir = try_source_dir;
break;
}
try_source_dir = utils::fs::join(try_source_dir, "/..");
}
if (!source_dir.empty())
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): the current directory is source sub-directory: " << source_dir);
CV_LOG_DEBUG(NULL, "utils::findDataFile(): <source>" << source_dir);
cv::String datapath = source_dir;
if (utils::fs::isDirectory(datapath))
{
for(size_t i = search_subdir.size(); i > 0; i--)
{
const cv::String& subdir = search_subdir[i - 1];
cv::String prefix = utils::fs::join(datapath, subdir);
TRY_FILE_WITH_PREFIX(prefix);
}
}
}
cv::String module_path = getModuleLocation((void*)getModuleLocation); // use code addr, doesn't work with static linkage!
CV_LOG_DEBUG(NULL, "Detected module path: '" << module_path << '\'');
if (!has_tested_build_directory &&
(isSubDirectory(build_dir, module_path) || isSubDirectory(utils::fs::canonical(build_dir), utils::fs::canonical(module_path)))
)
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): the binary module directory is build sub-directory: " << module_path);
const char* build_subdirs[] = { OPENCV_DATA_BUILD_DIR_SEARCH_PATHS };
for (size_t k = 0; k < sizeof(build_subdirs)/sizeof(build_subdirs[0]); k++)
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): <build>/" << build_subdirs[k]);
cv::String datapath = utils::fs::join(build_dir, build_subdirs[k]);
if (utils::fs::isDirectory(datapath))
{
for(size_t i = search_subdir.size(); i > 0; i--)
{
const cv::String& subdir = search_subdir[i - 1];
cv::String prefix = utils::fs::join(datapath, subdir);
TRY_FILE_WITH_PREFIX(prefix);
}
}
}
}
#if defined OPENCV_INSTALL_DATA_DIR_RELATIVE
if (!module_path.empty()) // require module path
{
size_t pos = module_path.rfind('/');
if (pos == cv::String::npos)
pos = module_path.rfind('\\');
cv::String module_dir = (pos == cv::String::npos) ? module_path : module_path.substr(0, pos);
const char* install_subdirs[] = { OPENCV_INSTALL_DATA_DIR_RELATIVE };
for (size_t k = 0; k < sizeof(install_subdirs)/sizeof(install_subdirs[0]); k++)
{
cv::String datapath = utils::fs::join(module_dir, install_subdirs[k]);
CV_LOG_DEBUG(NULL, "utils::findDataFile(): trying install path (from binary path): " << datapath);
if (utils::fs::isDirectory(datapath))
{
for(size_t i = search_subdir.size(); i > 0; i--)
{
const cv::String& subdir = search_subdir[i - 1];
cv::String prefix = utils::fs::join(datapath, subdir);
TRY_FILE_WITH_PREFIX(prefix);
}
}
else
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): ... skip, not a valid directory: " << datapath);
}
}
}
#endif
#if defined OPENCV_INSTALL_PREFIX && defined OPENCV_DATA_INSTALL_PATH
cv::String install_dir(OPENCV_INSTALL_PREFIX);
// use core/world module path and verify that library is running from installation directory
// It is neccessary to avoid touching of unrelated common /usr/local path
if (module_path.empty()) // can't determine
module_path = install_dir;
if (isSubDirectory(install_dir, module_path) || isSubDirectory(utils::fs::canonical(install_dir), utils::fs::canonical(module_path)))
{
cv::String datapath = utils::fs::join(install_dir, OPENCV_DATA_INSTALL_PATH);
if (utils::fs::isDirectory(datapath))
{
CV_LOG_DEBUG(NULL, "utils::findDataFile(): trying install path: " << datapath);
for(size_t i = search_subdir.size(); i > 0; i--)
{
const cv::String& subdir = search_subdir[i - 1];
cv::String prefix = utils::fs::join(datapath, subdir);
TRY_FILE_WITH_PREFIX(prefix);
}
}
}
#endif
return cv::String(); // not found
}
cv::String findDataFile(const cv::String& relative_path, bool required, const char* configuration_parameter)
{
CV_LOG_DEBUG(NULL, cv::format("cv::utils::findDataFile('%s', %s, %s)",
relative_path.c_str(), required ? "true" : "false",
configuration_parameter ? configuration_parameter : "NULL"));
cv::String result = cv::utils::findDataFile(relative_path,
configuration_parameter,
NULL,
NULL);
if (result.empty() && required)
CV_Error(cv::Error::StsError, cv::format("OpenCV: Can't find required data file: %s", relative_path.c_str()));
return result;
}
}} // namespace
+29 -10
View File
@@ -34,7 +34,7 @@
#include <errno.h>
#include <io.h>
#include <stdio.h>
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
@@ -85,6 +85,23 @@ cv::String join(const cv::String& base, const cv::String& path)
#if OPENCV_HAVE_FILESYSTEM_SUPPORT
cv::String canonical(const cv::String& path)
{
cv::String result;
#ifdef _WIN32
const char* result_str = _fullpath(NULL, path.c_str(), 0);
#else
const char* result_str = realpath(path.c_str(), NULL);
#endif
if (result_str)
{
result = cv::String(result_str);
free((void*)result_str);
}
return result.empty() ? path : result;
}
bool exists(const cv::String& path)
{
CV_INSTRUMENT_REGION();
@@ -161,7 +178,7 @@ cv::String getcwd()
sz = GetCurrentDirectoryA((DWORD)buf.size(), buf.data());
return cv::String(buf.data(), (size_t)sz);
#endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__
for(;;)
{
char* p = ::getcwd(buf.data(), buf.size());
@@ -195,7 +212,7 @@ bool createDirectory(const cv::String& path)
#else
int result = _mkdir(path.c_str());
#endif
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__
int result = mkdir(path.c_str(), 0777);
#else
int result = -1;
@@ -310,7 +327,7 @@ private:
Impl& operator=(const Impl&); // disabled
};
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__
#elif defined __linux__ || defined __APPLE__ || defined __HAIKU__ || defined __FreeBSD__
struct FileLock::Impl
{
@@ -424,7 +441,7 @@ cv::String getCacheDirectory(const char* sub_directory_name, const char* configu
default_cache_path = "/tmp/";
CV_LOG_WARNING(NULL, "Using world accessible cache directory. This may be not secure: " << default_cache_path);
}
#elif defined __linux__ || defined __HAIKU__
#elif defined __linux__ || defined __HAIKU__ || defined __FreeBSD__
// https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html
if (default_cache_path.empty())
{
@@ -543,11 +560,13 @@ cv::String getCacheDirectory(const char* sub_directory_name, const char* configu
#else
#define NOT_IMPLEMENTED CV_Error(Error::StsNotImplemented, "");
CV_EXPORTS bool exists(const cv::String& /*path*/) { NOT_IMPLEMENTED }
CV_EXPORTS void remove_all(const cv::String& /*path*/) { NOT_IMPLEMENTED }
CV_EXPORTS bool createDirectory(const cv::String& /*path*/) { NOT_IMPLEMENTED }
CV_EXPORTS bool createDirectories(const cv::String& /*path*/) { NOT_IMPLEMENTED }
CV_EXPORTS cv::String getCacheDirectory(const char* /*sub_directory_name*/, const char* /*configuration_name = NULL*/) { NOT_IMPLEMENTED }
cv::String canonical(const cv::String& /*path*/) { NOT_IMPLEMENTED }
bool exists(const cv::String& /*path*/) { NOT_IMPLEMENTED }
void remove_all(const cv::String& /*path*/) { NOT_IMPLEMENTED }
cv::String getcwd() { NOT_IMPLEMENTED }
bool createDirectory(const cv::String& /*path*/) { NOT_IMPLEMENTED }
bool createDirectories(const cv::String& /*path*/) { NOT_IMPLEMENTED }
cv::String getCacheDirectory(const char* /*sub_directory_name*/, const char* /*configuration_name = NULL*/) { NOT_IMPLEMENTED }
#undef NOT_IMPLEMENTED
#endif // OPENCV_HAVE_FILESYSTEM_SUPPORT
+67
View File
@@ -0,0 +1,67 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "../precomp.hpp"
#include <vector>
#include <opencv2/core/utils/logger.defines.hpp>
#undef CV_LOG_STRIP_LEVEL
#define CV_LOG_STRIP_LEVEL CV_LOG_LEVEL_VERBOSE + 1
#include "opencv2/core/utils/logger.hpp"
#include "opencv2/core/utils/filesystem.hpp"
namespace cv { namespace samples {
static cv::Ptr< std::vector<cv::String> > g_data_search_path;
static cv::Ptr< std::vector<cv::String> > g_data_search_subdir;
static std::vector<cv::String>& _getDataSearchPath()
{
if (g_data_search_path.empty())
g_data_search_path.reset(new std::vector<cv::String>());
return *(g_data_search_path.get());
}
static std::vector<cv::String>& _getDataSearchSubDirectory()
{
if (g_data_search_subdir.empty())
{
g_data_search_subdir.reset(new std::vector<cv::String>());
g_data_search_subdir->push_back("samples/data");
g_data_search_subdir->push_back("data");
g_data_search_subdir->push_back("");
}
return *(g_data_search_subdir.get());
}
CV_EXPORTS void addSamplesDataSearchPath(const cv::String& path)
{
if (utils::fs::isDirectory(path))
_getDataSearchPath().push_back(path);
}
CV_EXPORTS void addSamplesDataSearchSubDirectory(const cv::String& subdir)
{
_getDataSearchSubDirectory().push_back(subdir);
}
cv::String findFile(const cv::String& relative_path, bool required, bool silentMode)
{
CV_LOG_DEBUG(NULL, cv::format("cv::samples::findFile('%s', %s)", relative_path.c_str(), required ? "true" : "false"));
cv::String result = cv::utils::findDataFile(relative_path,
"OPENCV_SAMPLES_DATA_PATH",
&_getDataSearchPath(),
&_getDataSearchSubDirectory());
if (result != relative_path && !silentMode)
{
CV_LOG_WARNING(NULL, "cv::samples::findFile('" << relative_path << "') => '" << result << "'");
}
if (result.empty() && required)
CV_Error(cv::Error::StsError, cv::format("OpenCV samples: Can't find required data file: %s", relative_path.c_str()));
return result;
}
}} // namespace
+4 -4
View File
@@ -340,8 +340,8 @@ static void copy_convert_yv12_to_bgr(const VAImage& image, const unsigned char*
1.5959997177f
};
CV_CheckEQ(image.format.fourcc, VA_FOURCC_YV12, "Unexpected image format");
CV_CheckEQ(image.num_planes, 3, "");
CV_CheckEQ((size_t)image.format.fourcc, (size_t)VA_FOURCC_YV12, "Unexpected image format");
CV_CheckEQ((size_t)image.num_planes, (size_t)3, "");
const size_t srcOffsetY = image.offsets[0];
const size_t srcOffsetV = image.offsets[1];
@@ -417,8 +417,8 @@ static void copy_convert_bgr_to_yv12(const VAImage& image, const Mat& bgr, unsig
-0.2909994125f, 0.438999176f, -0.3679990768f, -0.0709991455f
};
CV_CheckEQ(image.format.fourcc, VA_FOURCC_YV12, "Unexpected image format");
CV_CheckEQ(image.num_planes, 3, "");
CV_CheckEQ((size_t)image.format.fourcc, (size_t)VA_FOURCC_YV12, "Unexpected image format");
CV_CheckEQ((size_t)image.num_planes, (size_t)3, "");
const size_t dstOffsetY = image.offsets[0];
const size_t dstOffsetV = image.offsets[1];
+7
View File
@@ -972,6 +972,13 @@ bool CV_OperationsTest::operations1()
if (sz.width != 10 || sz.height != 20) throw test_excep();
if (cvSize(sz).width != 10 || cvSize(sz).height != 20) throw test_excep();
Rect r1(0, 0, 10, 20);
Size sz1(5, 10);
r1 -= sz1;
if (r1.size().width != 5 || r1.size().height != 10) throw test_excep();
Rect r2 = r1 - sz1;
if (r2.size().width != 0 || r2.size().height != 0) throw test_excep();
Vec<double, 5> v5d(1, 1, 1, 1, 1);
Vec<double, 6> v6d(1, 1, 1, 1, 1, 1);
Vec<double, 7> v7d(1, 1, 1, 1, 1, 1, 1);
+18
View File
@@ -2,6 +2,7 @@
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "test_precomp.hpp"
#include "opencv2/core/utils/logger.hpp"
namespace opencv_test { namespace {
@@ -283,4 +284,21 @@ TEST(CommandLineParser, testScalar)
EXPECT_EQ(parser.get<Scalar>("s5"), Scalar(5, -4, 3, 2));
}
TEST(Samples, findFile)
{
cv::utils::logging::LogLevel prev = cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_VERBOSE);
cv::String path;
ASSERT_NO_THROW(path = samples::findFile("lena.jpg", false));
EXPECT_NE(std::string(), path.c_str());
cv::utils::logging::setLogLevel(prev);
}
TEST(Samples, findFile_missing)
{
cv::utils::logging::LogLevel prev = cv::utils::logging::setLogLevel(cv::utils::logging::LOG_LEVEL_VERBOSE);
cv::String path;
ASSERT_ANY_THROW(path = samples::findFile("non-existed.file", true));
cv::utils::logging::setLogLevel(prev);
}
}} // namespace
+5 -10
View File
@@ -20,11 +20,6 @@ else()
ocv_cmake_hook_append(INIT_MODULE_SOURCES_opencv_dnn "${CMAKE_CURRENT_LIST_DIR}/cmake/hooks/INIT_MODULE_SOURCES_opencv_dnn.cmake")
endif()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-shadow -Wno-parentheses -Wmaybe-uninitialized -Wsign-promo
-Wmissing-declarations -Wmissing-prototypes
)
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4701 /wd4100)
if(MSVC)
add_definitions( -D_CRT_SECURE_NO_WARNINGS=1 )
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244 /wd4267 /wd4018 /wd4355 /wd4800 /wd4251 /wd4996 /wd4146
@@ -33,12 +28,14 @@ if(MSVC)
)
else()
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-deprecated -Wmissing-prototypes -Wmissing-declarations -Wshadow
-Wunused-parameter -Wunused-local-typedefs -Wsign-compare -Wsign-promo
-Wundef -Wtautological-undefined-compare -Wignored-qualifiers -Wextra
-Wunused-function -Wunused-const-variable -Wdeprecated-declarations
-Wunused-parameter -Wsign-compare
)
endif()
if(NOT HAVE_CXX11)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wno-undef) # LANG_CXX11 from protobuf files
endif()
if(APPLE_FRAMEWORK)
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshorten-64-to-32)
endif()
@@ -55,8 +52,6 @@ add_definitions(-DHAVE_PROTOBUF=1)
#suppress warnings in autogenerated caffe.pb.* files
ocv_warnings_disable(CMAKE_CXX_FLAGS
-Wunused-parameter -Wundef -Wignored-qualifiers -Wno-enum-compare
-Wdeprecated-declarations
/wd4125 /wd4267 /wd4127 /wd4244 /wd4512 /wd4702
/wd4456 /wd4510 /wd4610 /wd4800
/wd4701 /wd4703 # potentially uninitialized local/pointer variable 'value' used
+11 -2
View File
@@ -77,6 +77,15 @@ CV__DNN_INLINE_NS_BEGIN
static Ptr<Layer> create(const LayerParams &params);
};
/**
* Constant layer produces the same data blob at an every forward pass.
*/
class CV_EXPORTS ConstLayer : public Layer
{
public:
static Ptr<Layer> create(const LayerParams &params);
};
//! LSTM recurrent layer
class CV_EXPORTS LSTMLayer : public Layer
{
@@ -236,7 +245,7 @@ CV__DNN_INLINE_NS_BEGIN
int type;
Size kernel, stride;
int pad_l, pad_t, pad_r, pad_b;
CV_DEPRECATED Size pad;
CV_DEPRECATED_EXTERNAL Size pad;
bool globalPooling;
bool computeMaxIdx;
String padMode;
@@ -578,7 +587,7 @@ CV__DNN_INLINE_NS_BEGIN
{
public:
float pnorm, epsilon;
CV_DEPRECATED bool acrossSpatial;
CV_DEPRECATED_EXTERNAL bool acrossSpatial;
static Ptr<NormalizeBBoxLayer> create(const LayerParams& params);
};
+3 -2
View File
@@ -60,12 +60,13 @@ CV__DNN_INLINE_NS_BEGIN
struct CV_EXPORTS_W DictValue
{
DictValue(const DictValue &r);
DictValue(bool i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i ? 1 : 0; } //!< Constructs integer scalar
DictValue(int64 i = 0) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
CV_WRAP DictValue(int i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
CV_WRAP DictValue(int i) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = i; } //!< Constructs integer scalar
DictValue(unsigned p) : type(Param::INT), pi(new AutoBuffer<int64,1>) { (*pi)[0] = p; } //!< Constructs integer scalar
CV_WRAP DictValue(double p) : type(Param::REAL), pd(new AutoBuffer<double,1>) { (*pd)[0] = p; } //!< Constructs floating point scalar
CV_WRAP DictValue(const String &s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< Constructs string scalar
DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< @overload
DictValue(const char *s) : type(Param::STRING), ps(new AutoBuffer<String,1>) { (*ps)[0] = s; } //!< @overload
template<typename TypeIter>
static DictValue arrayInt(TypeIter begin, int size); //!< Constructs integer array
+13 -4
View File
@@ -83,9 +83,14 @@ CV__DNN_INLINE_NS_BEGIN
DNN_TARGET_OPENCL,
DNN_TARGET_OPENCL_FP16,
DNN_TARGET_MYRIAD,
DNN_TARGET_VULKAN
DNN_TARGET_VULKAN,
//! FPGA device with CPU fallbacks using Inference Engine's Heterogeneous plugin.
DNN_TARGET_FPGA
};
CV_EXPORTS std::vector< std::pair<Backend, Target> > getAvailableBackends();
CV_EXPORTS std::vector<Target> getAvailableTargets(Backend be);
/** @brief This class provides all data needed to initialize layer.
*
* It includes dictionary with scalar params (which can be read by using Dict interface),
@@ -181,7 +186,8 @@ CV__DNN_INLINE_NS_BEGIN
* If this method is called after network has allocated all memory for input and output blobs
* and before inferencing.
*/
CV_DEPRECATED virtual void finalize(const std::vector<Mat*> &input, std::vector<Mat> &output);
CV_DEPRECATED_EXTERNAL
virtual void finalize(const std::vector<Mat*> &input, std::vector<Mat> &output);
/** @brief Computes and sets internal parameters according to inputs, outputs and blobs.
* @param[in] inputs vector of already allocated input blobs
@@ -198,7 +204,8 @@ CV__DNN_INLINE_NS_BEGIN
* @param[out] output allocated output blobs, which will store results of the computation.
* @param[out] internals allocated internal blobs
*/
CV_DEPRECATED virtual void forward(std::vector<Mat*> &input, std::vector<Mat> &output, std::vector<Mat> &internals);
CV_DEPRECATED_EXTERNAL
virtual void forward(std::vector<Mat*> &input, std::vector<Mat> &output, std::vector<Mat> &internals);
/** @brief Given the @p input blobs, computes the output @p blobs.
* @param[in] inputs the input blobs.
@@ -218,7 +225,8 @@ CV__DNN_INLINE_NS_BEGIN
* @overload
* @deprecated Use Layer::finalize(InputArrayOfArrays, OutputArrayOfArrays) instead
*/
CV_DEPRECATED void finalize(const std::vector<Mat> &inputs, CV_OUT std::vector<Mat> &outputs);
CV_DEPRECATED_EXTERNAL
void finalize(const std::vector<Mat> &inputs, CV_OUT std::vector<Mat> &outputs);
/** @brief
* @overload
@@ -494,6 +502,7 @@ CV__DNN_INLINE_NS_BEGIN
* | DNN_TARGET_OPENCL | + | + | + |
* | DNN_TARGET_OPENCL_FP16 | + | + | |
* | DNN_TARGET_MYRIAD | | + | |
* | DNN_TARGET_FPGA | | + | |
*/
CV_WRAP void setPreferableTarget(int targetId);
+1 -1
View File
@@ -6,7 +6,7 @@
#define OPENCV_DNN_VERSION_HPP
/// Use with major OpenCV version only.
#define OPENCV_DNN_API_VERSION 20180917
#define OPENCV_DNN_API_VERSION 20181205
#if !defined CV_DOXYGEN && !defined CV_DNN_DONT_ADD_INLINE_NS
#define CV__DNN_INLINE_NS __CV_CAT(dnn4_v, OPENCV_DNN_API_VERSION)
+6 -24
View File
@@ -31,23 +31,6 @@ public:
void processNet(std::string weights, std::string proto, std::string halide_scheduler,
const Mat& input, const std::string& outputLayer = "")
{
if (backend == DNN_BACKEND_OPENCV && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
{
#if defined(HAVE_OPENCL)
if (!cv::ocl::useOpenCL())
#endif
{
throw cvtest::SkipTestException("OpenCL is not available/disabled in OpenCV");
}
}
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
{
if (!checkMyriadTarget())
{
throw SkipTestException("Myriad is not available/disabled in OpenCV");
}
}
randu(input, 0.0f, 1.0f);
weights = findDataFile(weights, false);
@@ -175,8 +158,7 @@ PERF_TEST_P_(DNNTestNetwork, MobileNet_SSD_v2_TensorFlow)
PERF_TEST_P_(DNNTestNetwork, DenseNet_121)
{
if (backend == DNN_BACKEND_HALIDE ||
backend == DNN_BACKEND_INFERENCE_ENGINE && (target == DNN_TARGET_OPENCL_FP16 ||
target == DNN_TARGET_MYRIAD))
(backend == DNN_BACKEND_INFERENCE_ENGINE && (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD)))
throw SkipTestException("");
processNet("dnn/DenseNet_121.caffemodel", "dnn/DenseNet_121.prototxt", "",
Mat(cv::Size(224, 224), CV_32FC3));
@@ -185,7 +167,7 @@ PERF_TEST_P_(DNNTestNetwork, DenseNet_121)
PERF_TEST_P_(DNNTestNetwork, OpenPose_pose_coco)
{
if (backend == DNN_BACKEND_HALIDE ||
backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
processNet("dnn/openpose_pose_coco.caffemodel", "dnn/openpose_pose_coco.prototxt", "",
Mat(cv::Size(368, 368), CV_32FC3));
@@ -194,7 +176,7 @@ PERF_TEST_P_(DNNTestNetwork, OpenPose_pose_coco)
PERF_TEST_P_(DNNTestNetwork, OpenPose_pose_mpi)
{
if (backend == DNN_BACKEND_HALIDE ||
backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
processNet("dnn/openpose_pose_mpi.caffemodel", "dnn/openpose_pose_mpi.prototxt", "",
Mat(cv::Size(368, 368), CV_32FC3));
@@ -203,7 +185,7 @@ PERF_TEST_P_(DNNTestNetwork, OpenPose_pose_mpi)
PERF_TEST_P_(DNNTestNetwork, OpenPose_pose_mpi_faster_4_stages)
{
if (backend == DNN_BACKEND_HALIDE ||
backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
// The same .caffemodel but modified .prototxt
// See https://github.com/CMU-Perceptual-Computing-Lab/openpose/blob/master/src/openpose/pose/poseParameters.cpp
@@ -230,7 +212,7 @@ PERF_TEST_P_(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
PERF_TEST_P_(DNNTestNetwork, YOLOv3)
{
if (backend == DNN_BACKEND_HALIDE ||
backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
Mat sample = imread(findDataFile("dnn/dog416.png", false));
Mat inp;
@@ -241,7 +223,7 @@ PERF_TEST_P_(DNNTestNetwork, YOLOv3)
PERF_TEST_P_(DNNTestNetwork, EAST_text_detection)
{
if (backend == DNN_BACKEND_HALIDE ||
backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))
throw SkipTestException("");
processNet("dnn/frozen_east_text_detection.pb", "", "", Mat(cv::Size(320, 320), CV_32FC3));
}
+6 -6
View File
@@ -404,7 +404,7 @@ bool UpgradeV0LayerParameter(V1LayerParameter* v0_layer_connection_,
PoolingParameter_PoolMethod_STOCHASTIC);
break;
default:
LOG(ERROR) << "Unknown pool method " << pool;
LOG(ERROR) << "Unknown pool method " << (int)pool;
is_fully_compatible = false;
}
} else {
@@ -863,7 +863,7 @@ bool UpgradeV1LayerParameter(V1LayerParameter* v1_layer_param_,
while (layer_param->param_size() <= i) { layer_param->add_param(); }
layer_param->mutable_param(i)->set_name(v1_layer_param.param(i));
}
ParamSpec_DimCheckMode mode;
ParamSpec_DimCheckMode mode = ParamSpec_DimCheckMode_STRICT;
for (int i = 0; i < v1_layer_param.blob_share_mode_size(); ++i) {
while (layer_param->param_size() <= i) { layer_param->add_param(); }
switch (v1_layer_param.blob_share_mode(i)) {
@@ -875,8 +875,8 @@ bool UpgradeV1LayerParameter(V1LayerParameter* v1_layer_param_,
break;
default:
LOG(FATAL) << "Unknown blob_share_mode: "
<< v1_layer_param.blob_share_mode(i);
break;
<< (int)v1_layer_param.blob_share_mode(i);
CV_Error_(Error::StsError, ("Unknown blob_share_mode: %d", (int)v1_layer_param.blob_share_mode(i)));
}
layer_param->mutable_param(i)->set_share_mode(mode);
}
@@ -1102,12 +1102,12 @@ const char* UpgradeV1LayerType(const V1LayerParameter_LayerType type) {
case V1LayerParameter_LayerType_THRESHOLD:
return "Threshold";
default:
LOG(FATAL) << "Unknown V1LayerParameter layer type: " << type;
LOG(FATAL) << "Unknown V1LayerParameter layer type: " << (int)type;
return "";
}
}
const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte.
static const int kProtoReadBytesLimit = INT_MAX; // Max size of 2 GB minus 1 byte.
bool ReadProtoFromBinary(ZeroCopyInputStream* input, Message *proto) {
CodedInputStream coded_input(input);
+134 -19
View File
@@ -85,6 +85,111 @@ using std::map;
using std::make_pair;
using std::set;
//==================================================================================================
class BackendRegistry
{
public:
typedef std::vector< std::pair<Backend, Target> > BackendsList;
const BackendsList & getBackends() const { return backends; }
static BackendRegistry & getRegistry()
{
static BackendRegistry impl;
return impl;
}
private:
BackendRegistry()
{
#ifdef HAVE_HALIDE
backends.push_back(std::make_pair(DNN_BACKEND_HALIDE, DNN_TARGET_CPU));
# ifdef HAVE_OPENCL
if (cv::ocl::useOpenCL())
backends.push_back(std::make_pair(DNN_BACKEND_HALIDE, DNN_TARGET_OPENCL));
# endif
#endif // HAVE_HALIDE
#ifdef HAVE_INF_ENGINE
if (checkIETarget(DNN_TARGET_CPU))
backends.push_back(std::make_pair(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_CPU));
if (checkIETarget(DNN_TARGET_MYRIAD))
backends.push_back(std::make_pair(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_MYRIAD));
if (checkIETarget(DNN_TARGET_FPGA))
backends.push_back(std::make_pair(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_FPGA));
# ifdef HAVE_OPENCL
if (cv::ocl::useOpenCL() && ocl::Device::getDefault().isIntel())
{
if (checkIETarget(DNN_TARGET_OPENCL))
backends.push_back(std::make_pair(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL));
if (checkIETarget(DNN_TARGET_OPENCL_FP16))
backends.push_back(std::make_pair(DNN_BACKEND_INFERENCE_ENGINE, DNN_TARGET_OPENCL_FP16));
}
# endif
#endif // HAVE_INF_ENGINE
#ifdef HAVE_OPENCL
if (cv::ocl::useOpenCL())
{
backends.push_back(std::make_pair(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL));
backends.push_back(std::make_pair(DNN_BACKEND_OPENCV, DNN_TARGET_OPENCL_FP16));
}
#endif
backends.push_back(std::make_pair(DNN_BACKEND_OPENCV, DNN_TARGET_CPU));
#ifdef HAVE_VULKAN
backends.push_back(std::make_pair(DNN_BACKEND_VKCOM, DNN_TARGET_VULKAN)); // TODO Add device check
#endif
}
static inline bool checkIETarget(int target)
{
#ifndef HAVE_INF_ENGINE
return false;
#else
cv::dnn::Net net;
cv::dnn::LayerParams lp;
net.addLayerToPrev("testLayer", "Identity", lp);
net.setPreferableBackend(cv::dnn::DNN_BACKEND_INFERENCE_ENGINE);
net.setPreferableTarget(target);
static int inpDims[] = {1, 2, 3, 4};
net.setInput(cv::Mat(4, &inpDims[0], CV_32FC1, cv::Scalar(0)));
try
{
net.forward();
}
catch(...)
{
return false;
}
return true;
#endif
}
BackendsList backends;
};
std::vector< std::pair<Backend, Target> > getAvailableBackends()
{
return BackendRegistry::getRegistry().getBackends();
}
std::vector<Target> getAvailableTargets(Backend be)
{
if (be == DNN_BACKEND_DEFAULT)
be = (Backend)PARAM_DNN_BACKEND_DEFAULT;
std::vector<Target> result;
const BackendRegistry::BackendsList all_backends = getAvailableBackends();
for(BackendRegistry::BackendsList::const_iterator i = all_backends.begin(); i != all_backends.end(); ++i )
{
if (i->first == be)
result.push_back(i->second);
}
return result;
}
//==================================================================================================
namespace
{
typedef std::vector<MatShape> ShapesVec;
@@ -353,7 +458,7 @@ struct LayerPin
bool operator<(const LayerPin &r) const
{
return lid < r.lid || lid == r.lid && oid < r.oid;
return lid < r.lid || (lid == r.lid && oid < r.oid);
}
bool operator ==(const LayerPin &r) const
@@ -428,7 +533,7 @@ struct DataLayer : public Layer
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && inputsData.size() == 1;
(backendId == DNN_BACKEND_INFERENCE_ENGINE && inputsData.size() == 1);
}
void forward(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
@@ -911,21 +1016,8 @@ struct Net::Impl
typedef std::map<int, LayerShapes> LayersShapesMap;
typedef std::map<int, LayerData> MapIdToLayerData;
~Impl()
{
#ifdef HAVE_VULKAN
// Vulkan requires explicit releasing the child objects of
// VkDevice object prior to releasing VkDevice object itself.
layers.clear();
backendWrappers.clear();
vkcom::deinitPerThread();
#endif
}
Impl()
{
#ifdef HAVE_VULKAN
vkcom::initPerThread();
#endif
//allocate fake net input layer
netInputLayer = Ptr<DataLayer>(new DataLayer());
LayerData &inpl = layers.insert( make_pair(0, LayerData()) ).first->second;
@@ -1104,7 +1196,8 @@ struct Net::Impl
preferableTarget == DNN_TARGET_CPU ||
preferableTarget == DNN_TARGET_OPENCL ||
preferableTarget == DNN_TARGET_OPENCL_FP16 ||
preferableTarget == DNN_TARGET_MYRIAD);
preferableTarget == DNN_TARGET_MYRIAD ||
preferableTarget == DNN_TARGET_FPGA);
CV_Assert(preferableBackend != DNN_BACKEND_VKCOM ||
preferableTarget == DNN_TARGET_VULKAN);
if (!netWasAllocated || this->blobsToKeep != blobsToKeep_)
@@ -1609,7 +1702,9 @@ struct Net::Impl
ieNode->net = net;
auto weightableLayer = std::dynamic_pointer_cast<InferenceEngine::WeightableLayer>(ieNode->layer);
if ((preferableTarget == DNN_TARGET_OPENCL_FP16 || preferableTarget == DNN_TARGET_MYRIAD) && !fused)
if ((preferableTarget == DNN_TARGET_OPENCL_FP16 ||
preferableTarget == DNN_TARGET_MYRIAD ||
preferableTarget == DNN_TARGET_FPGA) && !fused)
{
ieNode->layer->precision = InferenceEngine::Precision::FP16;
if (weightableLayer)
@@ -1665,6 +1760,23 @@ struct Net::Impl
if (!ieNode->net->isInitialized())
{
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R3)
// For networks which is built in runtime we need to specify a
// version of it's hyperparameters.
std::string versionTrigger = "<net name=\"TestInput\" version=\"3\" batch=\"1\">"
"<layers>"
"<layer name=\"data\" type=\"Input\" precision=\"FP32\" id=\"0\">"
"<output>"
"<port id=\"0\">"
"<dim>1</dim>"
"</port>"
"</output>"
"</layer>"
"</layers>"
"</net>";
InferenceEngine::CNNNetReader reader;
reader.ReadNetwork(versionTrigger.data(), versionTrigger.size());
#endif
ieNode->net->init(preferableTarget);
ld.skip = false;
}
@@ -1787,8 +1899,8 @@ struct Net::Impl
void fuseLayers(const std::vector<LayerPin>& blobsToKeep_)
{
if( !fusion || preferableBackend != DNN_BACKEND_OPENCV &&
preferableBackend != DNN_BACKEND_INFERENCE_ENGINE)
if( !fusion || (preferableBackend != DNN_BACKEND_OPENCV &&
preferableBackend != DNN_BACKEND_INFERENCE_ENGINE))
return;
CV_TRACE_FUNCTION();
@@ -1996,6 +2108,9 @@ struct Net::Impl
}
}
if (preferableBackend != DNN_BACKEND_OPENCV)
continue; // Go to the next layer.
// the optimization #2. if there is no layer that takes max pooling layer's computed
// max indices (and only some semantical segmentation networks might need this;
// many others only take the maximum values), then we switch the max pooling
+1
View File
@@ -112,6 +112,7 @@ void initializeLayerFactory()
CV_DNN_REGISTER_LAYER_CLASS(Dropout, BlankLayer);
CV_DNN_REGISTER_LAYER_CLASS(Identity, BlankLayer);
CV_DNN_REGISTER_LAYER_CLASS(Silence, BlankLayer);
CV_DNN_REGISTER_LAYER_CLASS(Const, ConstLayer);
CV_DNN_REGISTER_LAYER_CLASS(Crop, CropLayer);
CV_DNN_REGISTER_LAYER_CLASS(Eltwise, EltwiseLayer);
+7 -6
View File
@@ -10,6 +10,7 @@ Implementation of Batch Normalization layer.
*/
#include "../precomp.hpp"
#include "layers_common.hpp"
#include "../op_halide.hpp"
#include "../op_inf_engine.hpp"
#include <opencv2/dnn/shape_utils.hpp>
@@ -150,8 +151,8 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE && haveHalide() ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine();
(backendId == DNN_BACKEND_HALIDE && haveHalide()) ||
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine());
}
#ifdef HAVE_OPENCL
@@ -284,10 +285,10 @@ public:
v_float32x4 x1 = v_load(srcptr + i + 4);
v_float32x4 x2 = v_load(srcptr + i + 8);
v_float32x4 x3 = v_load(srcptr + i + 12);
x0 = v_muladd(x0, w, b);
x1 = v_muladd(x1, w, b);
x2 = v_muladd(x2, w, b);
x3 = v_muladd(x3, w, b);
x0 = v_muladd(x0, wV, bV);
x1 = v_muladd(x1, wV, bV);
x2 = v_muladd(x2, wV, bV);
x3 = v_muladd(x3, wV, bV);
v_store(dstptr + i, x0);
v_store(dstptr + i + 4, x1);
v_store(dstptr + i + 8, x2);
+9 -2
View File
@@ -57,7 +57,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine();
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine());
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
@@ -107,14 +107,21 @@ public:
inputs[i].copyTo(outputs[i]);
}
virtual Ptr<BackendNode> initInfEngine(const std::vector<Ptr<BackendWrapper> >&) CV_OVERRIDE
virtual Ptr<BackendNode> initInfEngine(const std::vector<Ptr<BackendWrapper> >& inputs) CV_OVERRIDE
{
#ifdef HAVE_INF_ENGINE
InferenceEngine::DataPtr input = infEngineDataNode(inputs[0]);
CV_Assert(!input->dims.empty());
InferenceEngine::LayerParams lp;
lp.name = name;
lp.type = "Split";
lp.precision = InferenceEngine::Precision::FP32;
std::shared_ptr<InferenceEngine::SplitLayer> ieLayer(new InferenceEngine::SplitLayer(lp));
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R3)
ieLayer->params["axis"] = format("%d", (int)input->dims.size() - 1);
ieLayer->params["out_sizes"] = format("%d", (int)input->dims[0]);
#endif
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
#endif // HAVE_INF_ENGINE
return Ptr<BackendNode>();
+3 -3
View File
@@ -105,9 +105,9 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE && haveHalide() && axis == 1 && !padding || // By channels
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine() && !padding ||
backendId == DNN_BACKEND_VKCOM && haveVulkan() && !padding;
(backendId == DNN_BACKEND_HALIDE && haveHalide() && axis == 1 && !padding) || // By channels
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine() && !padding) ||
(backendId == DNN_BACKEND_VKCOM && haveVulkan() && !padding);
}
class ChannelConcatInvoker : public ParallelLoopBody
+68
View File
@@ -0,0 +1,68 @@
// 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.
// Copyright (C) 2018, Intel Corporation, all rights reserved.
// Third party copyrights are property of their respective owners.
#include "../precomp.hpp"
#include "layers_common.hpp"
#ifdef HAVE_OPENCL
#include "opencl_kernels_dnn.hpp"
#endif
namespace cv { namespace dnn {
class ConstLayerImpl CV_FINAL : public ConstLayer
{
public:
ConstLayerImpl(const LayerParams& params)
{
setParamsFrom(params);
CV_Assert(blobs.size() == 1);
}
virtual bool getMemoryShapes(const std::vector<MatShape> &inputs,
const int requiredOutputs,
std::vector<MatShape> &outputs,
std::vector<MatShape> &internals) const CV_OVERRIDE
{
CV_Assert(inputs.empty());
outputs.assign(1, shape(blobs[0]));
return false;
}
#ifdef HAVE_OPENCL
bool forward_ocl(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
{
std::vector<UMat> outputs;
outs.getUMatVector(outputs);
if (outs.depth() == CV_16S)
convertFp16(blobs[0], outputs[0]);
else
blobs[0].copyTo(outputs[0]);
return true;
}
#endif
void forward(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
{
CV_TRACE_FUNCTION();
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
CV_OCL_RUN(IS_DNN_OPENCL_TARGET(preferableTarget),
forward_ocl(inputs_arr, outputs_arr, internals_arr))
std::vector<Mat> outputs;
outputs_arr.getMatVector(outputs);
blobs[0].copyTo(outputs[0]);
}
};
Ptr<Layer> ConstLayer::create(const LayerParams& params)
{
return Ptr<Layer>(new ConstLayerImpl(params));
}
}} // namespace cv::dnn
+13 -2
View File
@@ -220,12 +220,17 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
#ifdef HAVE_INF_ENGINE
if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
return preferableTarget != DNN_TARGET_MYRIAD || dilation.width == dilation.height;
{
return INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R4) ||
(preferableTarget != DNN_TARGET_MYRIAD || dilation.width == dilation.height);
}
else
#endif
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE ||
backendId == DNN_BACKEND_VKCOM && haveVulkan();
(backendId == DNN_BACKEND_VKCOM && haveVulkan());
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
@@ -530,6 +535,12 @@ public:
ieLayer->_pads_end.insert(InferenceEngine::Y_AXIS, pad.height);
ieLayer->_dilation.insert(InferenceEngine::X_AXIS, dilation.width);
ieLayer->_dilation.insert(InferenceEngine::Y_AXIS, dilation.height);
ieLayer->params["output"] = format("%d", outCn);
ieLayer->params["kernel"] = format("%d,%d,%d,%d", outCn, inpGroupCn, kernel.height, kernel.width);
ieLayer->params["pads_begin"] = format("%d,%d", pad.height, pad.width);
ieLayer->params["pads_end"] = format("%d,%d", pad.height, pad.width);
ieLayer->params["strides"] = format("%d,%d", stride.height, stride.width);
ieLayer->params["dilations"] = format("%d,%d", dilation.height, dilation.width);
#else
ieLayer->_kernel_x = kernel.width;
ieLayer->_kernel_y = kernel.height;
+10 -2
View File
@@ -68,7 +68,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && crop_ranges.size() == 4;
(backendId == DNN_BACKEND_INFERENCE_ENGINE && crop_ranges.size() == 4);
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
@@ -156,6 +156,14 @@ public:
CV_Assert(crop_ranges.size() == 4);
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R3)
for (int i = 0; i < 4; ++i)
{
ieLayer->axis.push_back(i);
ieLayer->offset.push_back(crop_ranges[i].start);
ieLayer->dim.push_back(crop_ranges[i].end - crop_ranges[i].start);
}
#else
ieLayer->axis.push_back(0); // batch
ieLayer->offset.push_back(crop_ranges[0].start);
ieLayer->dim.push_back(crop_ranges[0].end - crop_ranges[0].start);
@@ -171,7 +179,7 @@ public:
ieLayer->axis.push_back(2); // width
ieLayer->offset.push_back(crop_ranges[3].start);
ieLayer->dim.push_back(crop_ranges[3].end - crop_ranges[3].start);
#endif
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
#endif // HAVE_INF_ENGINE
return Ptr<BackendNode>();
@@ -198,7 +198,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && !_locPredTransposed && _bboxesNormalized && !_clip;
(backendId == DNN_BACKEND_INFERENCE_ENGINE && !_locPredTransposed && _bboxesNormalized && !_clip);
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
+15 -8
View File
@@ -45,7 +45,6 @@
#include "../op_halide.hpp"
#include "../op_inf_engine.hpp"
#include "../op_vkcom.hpp"
#include "opencv2/imgproc.hpp"
#include <opencv2/dnn/shape_utils.hpp>
#include <iostream>
@@ -753,7 +752,8 @@ struct AbsValFunctor
bool supportBackend(int backendId, int)
{
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE ||
backendId == DNN_BACKEND_INFERENCE_ENGINE;
}
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
@@ -807,8 +807,11 @@ struct AbsValFunctor
#ifdef HAVE_INF_ENGINE
InferenceEngine::CNNLayerPtr initInfEngine(InferenceEngine::LayerParams& lp)
{
CV_Error(Error::StsNotImplemented, "Abs");
return InferenceEngine::CNNLayerPtr();
lp.type = "ReLU";
std::shared_ptr<InferenceEngine::ReLULayer> ieLayer(new InferenceEngine::ReLULayer(lp));
ieLayer->negative_slope = -1;
ieLayer->params["negative_slope"] = "-1.0";
return ieLayer;
}
#endif // HAVE_INF_ENGINE
@@ -901,7 +904,7 @@ struct PowerFunctor
bool supportBackend(int backendId, int targetId)
{
if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
return (targetId != DNN_TARGET_OPENCL && targetId != DNN_TARGET_OPENCL_FP16) || power == 1.0;
return (targetId != DNN_TARGET_OPENCL && targetId != DNN_TARGET_OPENCL_FP16) || power == 1.0 || power == 0.5;
else
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
}
@@ -1055,7 +1058,8 @@ struct ChannelsPReLUFunctor
bool supportBackend(int backendId, int)
{
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE;
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE ||
backendId == DNN_BACKEND_INFERENCE_ENGINE;
}
void apply(const float* srcptr, float* dstptr, int len, size_t planeSize, int cn0, int cn1) const
@@ -1141,8 +1145,11 @@ struct ChannelsPReLUFunctor
#ifdef HAVE_INF_ENGINE
InferenceEngine::CNNLayerPtr initInfEngine(InferenceEngine::LayerParams& lp)
{
CV_Error(Error::StsNotImplemented, "PReLU");
return InferenceEngine::CNNLayerPtr();
lp.type = "PReLU";
std::shared_ptr<InferenceEngine::PReLULayer> ieLayer(new InferenceEngine::PReLULayer(lp));
const size_t numChannels = scale.total();
ieLayer->_weights = wrapToInfEngineBlob(scale, {numChannels}, InferenceEngine::Layout::C);
return ieLayer;
}
#endif // HAVE_INF_ENGINE
+3 -1
View File
@@ -98,7 +98,8 @@ public:
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && (op != SUM || coeffs.empty());
(backendId == DNN_BACKEND_INFERENCE_ENGINE &&
(preferableTarget != DNN_TARGET_MYRIAD || coeffs.empty()));
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
@@ -427,6 +428,7 @@ public:
lp.type = "Eltwise";
lp.precision = InferenceEngine::Precision::FP32;
std::shared_ptr<InferenceEngine::EltwiseLayer> ieLayer(new InferenceEngine::EltwiseLayer(lp));
ieLayer->coeff = coeffs;
if (op == SUM)
ieLayer->_operation = InferenceEngine::EltwiseLayer::Sum;
else if (op == PROD)
+1 -1
View File
@@ -65,7 +65,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine();
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine());
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
@@ -123,8 +123,8 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE && haveHalide() && axis == 1 ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine() && axis == 1;
(backendId == DNN_BACKEND_HALIDE && haveHalide() && axis == 1) ||
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine() && axis == 1);
}
virtual bool setActivation(const Ptr<ActivationLayer>& layer) CV_OVERRIDE
@@ -449,6 +449,9 @@ public:
std::shared_ptr<InferenceEngine::FullyConnectedLayer> ieLayer(new InferenceEngine::FullyConnectedLayer(lp));
ieLayer->_out_num = blobs[0].size[0];
#if INF_ENGINE_VER_MAJOR_GT(INF_ENGINE_RELEASE_2018R3)
ieLayer->params["out-size"] = format("%d", blobs[0].size[0]);
#endif
ieLayer->_weights = wrapToInfEngineBlob(blobs[0], {(size_t)blobs[0].size[0], (size_t)blobs[0].size[1], 1, 1}, InferenceEngine::Layout::OIHW);
if (blobs.size() > 1)
ieLayer->_biases = wrapToInfEngineBlob(blobs[1], {(size_t)ieLayer->_out_num}, InferenceEngine::Layout::C);
+2 -2
View File
@@ -93,8 +93,8 @@ public:
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && (preferableTarget != DNN_TARGET_MYRIAD || type == CHANNEL_NRM) ||
backendId == DNN_BACKEND_VKCOM && haveVulkan() && (size % 2 == 1) && (type == CHANNEL_NRM);
(backendId == DNN_BACKEND_INFERENCE_ENGINE && (preferableTarget != DNN_TARGET_MYRIAD || type == CHANNEL_NRM)) ||
(backendId == DNN_BACKEND_VKCOM && haveVulkan() && (size % 2 == 1) && (type == CHANNEL_NRM));
}
#ifdef HAVE_OPENCL
@@ -35,8 +35,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE && haveHalide() &&
!poolPad.width && !poolPad.height;
(backendId == DNN_BACKEND_HALIDE && haveHalide() && !poolPad.width && !poolPad.height);
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
+1 -1
View File
@@ -91,7 +91,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE && haveHalide() && dstRanges.size() == 4;
(backendId == DNN_BACKEND_HALIDE && haveHalide() && dstRanges.size() == 4);
}
void forward(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
+2 -2
View File
@@ -106,8 +106,8 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine() ||
backendId == DNN_BACKEND_VKCOM && haveVulkan();
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine()) ||
(backendId == DNN_BACKEND_VKCOM && haveVulkan());
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
+10 -6
View File
@@ -155,10 +155,10 @@ public:
}
else
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE && haveHalide() &&
(type == MAX || type == AVE && !pad_t && !pad_l && !pad_b && !pad_r) ||
backendId == DNN_BACKEND_VKCOM && haveVulkan() &&
(type == MAX || type == AVE);
(backendId == DNN_BACKEND_HALIDE && haveHalide() &&
(type == MAX || (type == AVE && !pad_t && !pad_l && !pad_b && !pad_r))) ||
(backendId == DNN_BACKEND_VKCOM && haveVulkan() &&
(type == MAX || type == AVE));
}
#ifdef HAVE_OPENCL
@@ -313,6 +313,10 @@ public:
poolLayer->_padding.insert(InferenceEngine::Y_AXIS, pad_t);
poolLayer->_pads_end.insert(InferenceEngine::X_AXIS, pad_r);
poolLayer->_pads_end.insert(InferenceEngine::Y_AXIS, pad_b);
poolLayer->params["kernel"] = format("%d,%d", kernel.height, kernel.width);
poolLayer->params["pads_begin"] = format("%d,%d", pad_t, pad_l);
poolLayer->params["pads_end"] = format("%d,%d", pad_b, pad_r);
poolLayer->params["strides"] = format("%d,%d", stride.height, stride.width);
#else
poolLayer->_kernel_x = kernel.width;
poolLayer->_kernel_y = kernel.height;
@@ -380,8 +384,8 @@ public:
src.isContinuous(), dst.isContinuous(),
src.type() == CV_32F, src.type() == dst.type(),
src.dims == 4, dst.dims == 4,
((poolingType == ROI || poolingType == PSROI) && dst.size[0] ==rois.size[0] || src.size[0] == dst.size[0]),
poolingType == PSROI || src.size[1] == dst.size[1],
(((poolingType == ROI || poolingType == PSROI) && dst.size[0] == rois.size[0]) || src.size[0] == dst.size[0]),
poolingType == PSROI || src.size[1] == dst.size[1],
(mask.empty() || (mask.type() == src.type() && mask.size == dst.size)));
PoolingInvoker p;
+2 -2
View File
@@ -272,8 +272,8 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine() ||
backendId == DNN_BACKEND_VKCOM && haveVulkan();
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine()) ||
(backendId == DNN_BACKEND_VKCOM && haveVulkan());
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
+1 -1
View File
@@ -87,7 +87,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && preferableTarget != DNN_TARGET_MYRIAD;
(backendId == DNN_BACKEND_INFERENCE_ENGINE && preferableTarget != DNN_TARGET_MYRIAD);
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
+2 -2
View File
@@ -175,7 +175,7 @@ public:
std::vector<MatShape> &outputs,
std::vector<MatShape> &internals) const CV_OVERRIDE
{
CV_Assert(!usePeephole && blobs.size() == 3 || usePeephole && blobs.size() == 6);
CV_Assert((!usePeephole && blobs.size() == 3) || (usePeephole && blobs.size() == 6));
CV_Assert(inputs.size() == 1);
const MatShape& inp0 = inputs[0];
@@ -221,7 +221,7 @@ public:
std::vector<Mat> input;
inputs_arr.getMatVector(input);
CV_Assert(!usePeephole && blobs.size() == 3 || usePeephole && blobs.size() == 6);
CV_Assert((!usePeephole && blobs.size() == 3) || (usePeephole && blobs.size() == 6));
CV_Assert(input.size() == 1);
const Mat& inp0 = input[0];
+1 -1
View File
@@ -178,7 +178,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine();
(backendId == DNN_BACKEND_INFERENCE_ENGINE && haveInfEngine());
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,
+24 -7
View File
@@ -51,9 +51,14 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
#ifdef HAVE_INF_ENGINE
if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
return interpolation == "nearest" && preferableTarget != DNN_TARGET_MYRIAD;
{
return (interpolation == "nearest" && preferableTarget != DNN_TARGET_MYRIAD) ||
(interpolation == "bilinear" && INF_ENGINE_VER_MAJOR_GE(INF_ENGINE_RELEASE_2018R4));
}
else
#endif
return backendId == DNN_BACKEND_OPENCV;
}
@@ -160,15 +165,27 @@ public:
#ifdef HAVE_INF_ENGINE
InferenceEngine::LayerParams lp;
lp.name = name;
lp.type = "Resample";
lp.precision = InferenceEngine::Precision::FP32;
std::shared_ptr<InferenceEngine::CNNLayer> ieLayer(new InferenceEngine::CNNLayer(lp));
ieLayer->params["type"] = "caffe.ResampleParameter.NEAREST";
ieLayer->params["antialias"] = "0";
std::shared_ptr<InferenceEngine::CNNLayer> ieLayer;
if (interpolation == "nearest")
{
lp.type = "Resample";
ieLayer = std::shared_ptr<InferenceEngine::CNNLayer>(new InferenceEngine::CNNLayer(lp));
ieLayer->params["type"] = "caffe.ResampleParameter.NEAREST";
ieLayer->params["antialias"] = "0";
}
else if (interpolation == "bilinear")
{
lp.type = "Interp";
ieLayer = std::shared_ptr<InferenceEngine::CNNLayer>(new InferenceEngine::CNNLayer(lp));
ieLayer->params["pad_beg"] = "0";
ieLayer->params["pad_end"] = "0";
ieLayer->params["align_corners"] = "0";
}
else
CV_Error(Error::StsNotImplemented, "Unsupported interpolation: " + interpolation);
ieLayer->params["width"] = cv::format("%d", outWidth);
ieLayer->params["height"] = cv::format("%d", outHeight);
return Ptr<BackendNode>(new InfEngineBackendNode(ieLayer));
#endif // HAVE_INF_ENGINE
return Ptr<BackendNode>();
+2 -2
View File
@@ -45,13 +45,13 @@ public:
std::vector<Mat> inputs;
inputs_arr.getMatVector(inputs);
hasWeights = blobs.size() == 2 || (blobs.size() == 1 && !hasBias);
CV_Assert(inputs.size() == 2 && blobs.empty() || blobs.size() == (int)hasWeights + (int)hasBias);
CV_Assert((inputs.size() == 2 && blobs.empty()) || blobs.size() == (int)hasWeights + (int)hasBias);
}
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV || backendId == DNN_BACKEND_HALIDE ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && axis == 1;
(backendId == DNN_BACKEND_INFERENCE_ENGINE && axis == 1);
}
void forward(InputArrayOfArrays inputs_arr, OutputArrayOfArrays outputs_arr, OutputArrayOfArrays internals_arr) CV_OVERRIDE
+1 -1
View File
@@ -111,7 +111,7 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_INFERENCE_ENGINE && sliceRanges.size() == 1 && sliceRanges[0].size() == 4;
(backendId == DNN_BACKEND_INFERENCE_ENGINE && sliceRanges.size() == 1 && sliceRanges[0].size() == 4);
}
bool getMemoryShapes(const std::vector<MatShape> &inputs,

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