1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 07:13:02 +04:00

Compare commits

..

95 Commits

Author SHA1 Message Date
Alexander Alekhin ddbd10c001 release: OpenCV 4.1.1
OpenCV 4.1.1
2019-07-26 03:24:45 +00:00
Alexander Alekhin 7c0a43d425 Merge tag '4.1.1-openvino' 2019-07-26 03:23:42 +00:00
Alexander Alekhin 0cf479dd5c Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2019-07-25 19:21:47 +00:00
Alexander Alekhin 2693ed9b22 Merge tag '3.4.7' 2019-07-25 19:19:49 +00:00
Alexander Alekhin 4a7ca5a291 OpenCV version++ (3.4.7)
OpenCV 3.4.7
2019-07-25 19:01:19 +00:00
Alexander Alekhin 7295983964 Merge pull request #15139 from alalek:openvino_2019R2 2019-07-25 18:59:56 +00:00
Alexander Alekhin 39a6889767 Merge pull request #15118 from dkurt:fix_15106 2019-07-25 18:56:32 +00:00
Chip Kerchner 0db4fb1835 Merge pull request #15136 from ChipKerchner:dotProd_unroll
* Unroll multiply and add instructions in dotProd_32f - 35% faster.

* Eliminate unnecessary v_reduce_sum instructions.
2019-07-25 21:21:32 +03:00
Alexander Alekhin ac425f67e4 Merge pull request #15150 from alalek:fix_15124_15125 2019-07-25 18:19:04 +00:00
Dmitry Kurtaev a2125594ea Fix false positives of face detection network for large faces 2019-07-25 20:09:59 +03:00
Alexander Alekhin 1f736a95a7 Merge pull request #15131 from paroj:web 2019-07-25 16:25:57 +00:00
Alexander Alekhin 79859ebca3 Merge pull request #15145 from alalek:fix_15127 2019-07-25 16:14:25 +00:00
Alexander Alekhin 416c693b3f dnn(test): OpenVINO 2019R2 2019-07-25 19:01:16 +03:00
Alexander Alekhin 321c74ccd6 objdetect: validate feature rectangle on reading 2019-07-25 18:58:53 +03:00
Alexander Alekhin 5691d998ea core(persistence): added null ptr checks 2019-07-25 15:14:22 +03:00
Alexander Alekhin 6158bd2afa Merge pull request #15103 from alalek:simd_intrinsics_in_user_code 2019-07-25 11:36:36 +00:00
Alexander Alekhin d2911a8d41 dnn: use OpenVINO 2019R2 defines 2019-07-24 21:37:03 +00:00
Andrey Golubev b10ec8ef8b Merge pull request #14985 from andrey-golubev:gapi_fix_ocl_umat
* G-API: fix GOCLExecutable issue with UMat lifetime

Add tests on initialized/uninitialized outputs for all
backends

* Use proper clean-up procedure for magazine

* Rename InitOut test and reduce tested sizes

* Enable output allocation test
2019-07-24 23:36:18 +03:00
Alexey Smirnov 8313209704 Merge pull request #14952 from smirnov-alexey:gapi_transform_macro_rework
G-API: GAPI_TRANSFORM internal functionality rework (#14952)

* Change internal pattern and substitute signatures and refactor tests

* Enhance GArrayU with type-checker function

Add a couple of new tests on GAPI_TRANSFORM
2019-07-24 23:29:52 +03:00
Alexander Alekhin 89f23a35c5 Merge pull request #15091 from anton-potapov:fluid_internal_parallellism_custom_pfor 2019-07-24 20:28:48 +00:00
Hugo Lindström 2ee00e7f7d Merge pull request #15059 from hugolm84:improved-support-for-wince
* Improve support for Windows Embedded Compact

* Remove redundant set(WINCE true) and format CMake
2019-07-24 23:12:09 +03:00
Pavel Rojtberg 293729f48a js: whitelist some more functions (calib3d , aruco) 2019-07-23 11:57:59 +02:00
Alexander Alekhin 79310a0051 Merge pull request #15105 from komakai:camera_permissions 2019-07-22 17:47:54 +00:00
Alexander Alekhin b69bf8a897 Merge pull request #15097 from komakai:no_samples_build-option 2019-07-22 17:38:37 +00:00
Alexander Alekhin 426482e05b Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2019-07-21 18:06:04 +00:00
Alexander Alekhin ad092bf1ce Merge pull request #15107 from dkurt:js_features2d_drawings 2019-07-21 17:57:19 +00:00
Alexander Alekhin 557990fdcf Merge pull request #15104 from alalek:videoio_fix_debug_message 2019-07-21 17:56:41 +00:00
Dmitry Kurtaev a66a1a24d7 Fix drawKeypoints and drawMatches for JS 2019-07-20 23:47:26 +03:00
Alexander Alekhin 099f4f9e7c Merge pull request #15093 from tomoaki0705:fixCudaLegacyRansac 2019-07-20 08:07:14 +00:00
Giles Payne 2734291b35 Add CameraActivity utility class to automate Camera permission request handling 2019-07-20 13:40:10 +09:00
Alexander Alekhin 8bac8b513c core: support SIMD intrinsics in user code 2019-07-19 20:33:32 +00:00
Lubov Batanina 781f4d439e Merge pull request #15032 from l-bat:reduce_mean
* Added support for the ONNX "ReduceMean" Layer. (as this is the same as the GlobalAveragePool)

* Add ReduceMean test

* Fix ONNX importer

* Fix ReduceMean

* Add assert

* Split test

* Fix split test
2019-07-19 19:18:34 +03:00
Alexander Alekhin a8a71eb200 Merge pull request #15092 from alalek:videoio_gstreamer_more_get_checks 2019-07-19 15:50:54 +00:00
Alexander Alekhin 61f589ddd0 videoio(gstreamer): more .get() checks 2019-07-19 13:16:58 +03:00
Alexander Alekhin 3361c59576 Merge pull request #15084 from lpea:calib3d_doc_fix 2019-07-19 10:11:35 +00:00
Anton Potapov 8936d55675 Fluid Internal Parallelism
- added ability to use custom implementation of "parallel for" function
2019-07-19 11:56:57 +03:00
Tomoaki Teshima c6de84d868 cudalegacy: fix test failure of SolvePnPRansac
* use SOLVE_EPNP for the initial guess
2019-07-19 17:50:00 +09:00
Alexander Alekhin 228af2d617 videoio: fix debug message 2019-07-18 21:45:07 +00:00
Alexander Alekhin 199ddff13b Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2019-07-18 20:25:25 +00:00
Alexander Alekhin 985e5014bc Merge pull request #15058 from alalek:core_fix_base64_packed_struct_master 2019-07-18 19:09:08 +00:00
Alexander Alekhin 002904e445 Merge pull request #15050 from alalek:core_fix_base64_packed_struct 2019-07-18 19:07:06 +00:00
Vitaly Tuzov e0f8bb83a6 Merge pull request #14994 from terfendail:wintr_undistort
WUI based implementation to initUndistortRectifyMap (#14994)

* Add initUndistortRectifyMap performance test

* Move cv namespace boundaries

* Add wide universal intrinsics based implementation to initUndistortRectifyMap

* Dispatch undistort
2019-07-18 19:32:51 +03:00
Lubov Batanina 12fdaf895e Merge pull request #15057 from l-bat:fix_vizualizer
* Fix dumpToFile

* Add test

* Fix test
2019-07-18 18:41:08 +03:00
Alexander Alekhin 8b341884d2 Merge pull request #15080 from alalek:gapi_fix_build 2019-07-18 15:15:25 +00:00
Giles Payne a897fc91ec Add no_samples_build option to Android SDK build 2019-07-18 21:31:02 +09:00
Alexander Alekhin e7bb0ecee0 gapi: fix build with unique_ptr
avoid generation of copy ctors with unique_ptr members
2019-07-18 14:08:42 +03:00
Alexander Alekhin c12e26ff28 Merge pull request #15071 from l-bat:tf_split 2019-07-18 08:12:42 +00:00
Guillaume Jacob 4a28ef8034 calib3d: fix format in findChessboardCornersSB doxygen 2019-07-18 10:04:47 +02:00
Liubov Batanina 0d2bc7b5fd Fix TF Split layer 2019-07-17 15:50:50 +03:00
Alexander Alekhin f6ec0cd827 Merge pull request #15061 from AsyaPronina:dev/fix_merge_issue 2019-07-16 21:00:50 +03:00
AsyaPronina add1df4bcb Fixed issue happened during merge 2019-07-16 20:47:34 +03:00
Alexander Alekhin 65d148d9a8 Merge pull request #15024 from alalek:android_stl_cxx_shared 2019-07-16 17:10:04 +00:00
Andrey Golubev c9bd43c0f6 Merge pull request #14945 from andrey-golubev:delete_bool
G-API: clean up accuracy tests (#14945)

* Delete createOutputMatrices flag

Update the way compile args function is created

Fix instantiation suffix print function

* Update comment (NB)

* Make printable comparison functions

* Use defines instead of objects for compile args

* Remove custom printers, use operator<< overload

* Remove SAME_TYPE and use -1 instead

* Delete createOutputMatrices flag in new tests

* Fix GetParam() printed values

* Update Resize tests: use CompareF object

* Address code review feedback

* Add default cases for operator<< overloads

* change throw to GAPI_Assert
2019-07-16 19:04:18 +03:00
Andrey Golubev c11423df1e Merge pull request #15012 from andrey-golubev:test_output
G-API: Add output allocation tests for backends (#15012)

* Add output tests for backends

* Fix large size test: output is in fact reallocated

* Use cv::Mat copies for reallocation tracking

* Separate LargeSizeWithCorrectSubmatrix test

* Rename backed output allocation tests

* Address code review feedback

Update test names

Add illustrative "expect (non-)empty" checks

Rename mat "copy" to mat reference

Add more pointer checks

* Add illustrative checks
2019-07-16 19:01:45 +03:00
Alexander Alekhin e4e0bb533d Merge pull request #15052 from alalek:dnn_fix_required_data 2019-07-16 16:00:33 +00:00
Andrey Golubev e629785a97 Merge pull request #15021 from andrey-golubev:gapi_fix_standalone_exports
* Fix G-API export specifier in standalone build

* Make dummy GAPI_EXPORTS in case of non-OpenCV builds

* Add old version under #if 0
2019-07-16 18:53:51 +03:00
Alexander Alekhin 3a2a74b655 Merge pull request #14968 from anton-potapov:fluid_internal_parallellism 2019-07-16 14:22:06 +00:00
Alexander Alekhin f5e01f7b49 Merge pull request #15037 from hugolm84:noop-noexcept-for-vs13 2019-07-16 13:28:15 +00:00
Chip Kerchner c9fcc12e3b Merge pull request #15048 from ChipKerchner:reduceStoreGatheringThreshold
* Reduce store gathering pressures - speeds thresholds by up to 20%

* Rename temporary histogram array and initialize so that MACOSX builder is happy
2019-07-16 16:10:49 +03:00
Anton Potapov 97e88bd769 Fluid Internal Parallelism
- Added new graph compile time argument to specify multiple independent
ROIs (Tiles)
 - Added new "executable" with serial loop other user specified
ROIs(Tiles)
 - refactored graph traversal code into separate function to be called
once
 - added saturate cast to Fluid AddCsimple test kernel
2019-07-16 16:09:14 +03:00
Alexander Alekhin d4501f08b8 core(persistence): disable base64 tests due missing encoders 2019-07-16 15:37:58 +03:00
Alexander Alekhin 2df7736562 Merge branch 'core_fix_base64_packed_struct' 2019-07-16 15:35:43 +03:00
Alexander Alekhin 4ea8526e9f core(persistence): fix writeRaw() / readRaw() struct support
- writeRaw(): support structs
- readRaw(): 'len' is buffer limit in bytes (documentation is fixed)
2019-07-16 14:03:39 +03:00
Alexander Alekhin ee1de8f30d Merge pull request #15053 from SciMad:fix-error-message 2019-07-16 09:55:06 +00:00
Alexander Alekhin 5ccb2a4cbd dnn(test): fix required data 2019-07-16 07:53:50 +00:00
Madhav bee510dbce Fix error message on invalid seam finder parameter 2019-07-16 13:27:04 +05:45
Alexander Alekhin c3b838b738 core(persistence): struct storage layout without alignment gaps 2019-07-15 21:37:20 +00:00
Alexander Alekhin 571b69bdb6 Merge pull request #15049 from alalek:disable_14850 2019-07-15 16:27:45 +00:00
Alexander Alekhin 095f44f4b2 cmake: disable WITH_NVCUVID by default due build failures 2019-07-15 17:09:07 +03:00
Alexander Alekhin 95415ac3a5 android: change ANDROID_STL='c++_shared'
- fixes crashes in face-detector application
- libc++_shared.so is bundled automatically via CMake helper project
2019-07-12 18:58:02 +00:00
Alexander Alekhin f6c573880e Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2019-07-12 18:45:06 +00:00
Alexander Alekhin 054c796213 Merge pull request #15026 from terfendail:gaussian_fix 2019-07-12 18:31:09 +00:00
Hugo Lindström 245c256b1c Support compiliation for <=VS13 2019-07-12 19:02:36 +02:00
Alexander Alekhin 6aa07cdc7e Merge pull request #15025 from alalek:issue_14281 2019-07-12 15:28:44 +00:00
Vitaly Tuzov 894ad33bf4 Fix pixel value evaluation overflow in bit-exact GaussianBlur implementation 2019-07-12 18:11:51 +03:00
Lubov Batanina 34f6b05467 Merge pull request #14996 from l-bat:ocv_deconv3d
* Support Deconvolution3D on IE backend

* Add test tag

* Fix tests
2019-07-12 15:51:44 +03:00
Alexander Alekhin 32c6e58bdb imgproc: fix unaligned memory access
may cause crashes on ARM platform
2019-07-11 20:49:47 +00:00
Lubov Batanina 8bcd7e122a Merge pull request #14842 from l-bat:ocv_conv3d
* Support Conv3D on OCV backend

* Add header

* Add perf tests

* Support pool3d

* Enable Resnet34_kinetics on OCV backend

* Add test

* Fix conv

* Optimize Conv2D
2019-07-11 20:13:52 +03:00
Alexander Alekhin f663e8f903 Merge remote-tracking branch 'upstream/3.4' into merge-3.4 2019-07-09 19:57:57 +00:00
Alexander Alekhin 3c086fb2fe Merge pull request #15001 from antmicro:v4l2-y10-support 2019-07-09 14:34:11 +00:00
Alexander Alekhin 32b6ebb670 Merge pull request #14989 from alalek:issue_14978 2019-07-09 14:14:06 +00:00
Alexander Alekhin de4d304d90 Merge pull request #15000 from mshabunin:fix-videoio-writer 2019-07-09 12:59:10 +00:00
Tomasz Gorochowik 4997a6bf06 V4L2: Add V4L2_PIX_FMT_Y10 (10 bit grey) support 2019-07-09 14:36:00 +02:00
Maksim Shabunin 2a9521661e Fixed video writer filename check for plugins 2019-07-09 14:16:49 +03:00
Alexander Alekhin 1e9e2aa95c Merge pull request #14811 from jxu:ubuntu-doc-fix 2019-07-08 16:47:19 +00:00
jxu b9399a5df8 Fix python setup in ubuntu dependencies 2019-07-07 15:15:31 -04:00
Alexander Alekhin 8408587341 Merge pull request #14888 from vchiluka5:NVIDIA_Optical_Flow 2019-07-07 17:20:53 +03:00
Alexander Alekhin 0fc584961c cmake: workaround to fix link issues with stubs/libcuda.so.1 2019-07-06 16:29:59 +00:00
Alexander Alekhin eedbd1ad59 imgcodecs: force reshaping of imdecode() input into a single row
OpenCV upstream stuff may reinterpret vector as column.
2019-07-06 10:11:29 +00:00
Alexander Alekhin 7589225fc0 Merge pull request #14981 from alalek:android_camera_use_calc_frame_size_method 2019-07-06 08:20:20 +00:00
Alexander Alekhin 39a975cb29 Merge pull request #14983 from tomoaki0705:fixOclCvtColorMRGBA 2019-07-05 09:31:08 +00:00
Tomoaki Teshima 594a95839c fix test failure of OCL_ImgProc/CvtColor8u.mRGBA2RGBA 2019-07-05 11:22:22 +09:00
Alexander Alekhin 3998b41d68 android: JavaCamera2View use calculateCameraFrameSize() method
from CameraBridgeViewBase (common base with JavaCameraView)
2019-07-04 21:43:09 +00:00
Diego 57fae4a6a1 Merge pull request #14858 from dvd42:instancenorm_onnx
Instancenorm onnx (#14858)

* Onnx unsupported operation handling

* instance norm implementation

* Revert "Onnx unsupported operation handling"

* instance norm layer test

* onnx instancenorm layer
2019-07-04 21:15:04 +03:00
Vishal Chiluka 0e9a865bbf Moved NVIDIA_Optical_Flow sample app to opencv_contrib
Description:
Moved NVIDIA_Optical_flow sample app and comparison app to
opencv_contrib branch. Added CUDA_CUDA_LIBRARY in CMakeLists.txt for
resolving linker errors.
2019-06-28 09:19:26 +05:30
114 changed files with 5481 additions and 1824 deletions
+1 -1
View File
@@ -136,7 +136,7 @@ const char * ZEXPORT zError(err)
return ERR_MSG(err);
}
#if defined(_WIN32_WCE)
#if defined(_WIN32_WCE) && _WIN32_WCE < 0x800
/* The Microsoft C Run-Time Library for Windows CE doesn't have
* errno. We define it as a global variable to simplify porting.
* Its value is always 0 and should not be used.
+7 -5
View File
@@ -169,11 +169,13 @@ extern z_const char * const z_errmsg[10]; /* indexed by 2-zlib_error */
#if (defined(_MSC_VER) && (_MSC_VER > 600)) && !defined __INTERIX
# if defined(_WIN32_WCE)
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# if _WIN32_WCE < 0x800
# define fdopen(fd,mode) NULL /* No fdopen() */
# ifndef _PTRDIFF_T_DEFINED
typedef int ptrdiff_t;
# define _PTRDIFF_T_DEFINED
# endif
# endif
# else
# define fdopen(fd,type) _fdopen(fd,type)
# endif
+36 -56
View File
@@ -53,35 +53,6 @@ if(NOT DEFINED CMAKE_INSTALL_PREFIX)
endif()
endif()
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT TRUE)
endif()
if(WINRT)
add_definitions(-DWINRT -DNO_GETENV)
# Making definitions available to other configurations and
# to filter dependency restrictions at compile time.
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone)
set(WINRT_PHONE TRUE)
add_definitions(-DWINRT_PHONE)
elseif(CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT_STORE TRUE)
add_definitions(-DWINRT_STORE)
endif()
if(CMAKE_SYSTEM_VERSION MATCHES 10)
set(WINRT_10 TRUE)
add_definitions(-DWINRT_10)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
set(WINRT_8_1 TRUE)
add_definitions(-DWINRT_8_1)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.0)
set(WINRT_8_0 TRUE)
add_definitions(-DWINRT_8_0)
endif()
endif()
if(POLICY CMP0026)
cmake_policy(SET CMP0026 NEW)
endif()
@@ -136,6 +107,39 @@ enable_testing()
project(OpenCV CXX C)
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone OR CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT TRUE)
endif()
if(WINRT OR WINCE)
add_definitions(-DNO_GETENV)
endif()
if(WINRT)
add_definitions(-DWINRT)
# Making definitions available to other configurations and
# to filter dependency restrictions at compile time.
if(CMAKE_SYSTEM_NAME MATCHES WindowsPhone)
set(WINRT_PHONE TRUE)
add_definitions(-DWINRT_PHONE)
elseif(CMAKE_SYSTEM_NAME MATCHES WindowsStore)
set(WINRT_STORE TRUE)
add_definitions(-DWINRT_STORE)
endif()
if(CMAKE_SYSTEM_VERSION MATCHES 10)
set(WINRT_10 TRUE)
add_definitions(-DWINRT_10)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.1)
set(WINRT_8_1 TRUE)
add_definitions(-DWINRT_8_1)
elseif(CMAKE_SYSTEM_VERSION MATCHES 8.0)
set(WINRT_8_0 TRUE)
add_definitions(-DWINRT_8_0)
endif()
endif()
if(MSVC)
set(CMAKE_USE_RELATIVE_PATHS ON CACHE INTERNAL "" FORCE)
endif()
@@ -257,7 +261,7 @@ OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BL
OCV_OPTION(WITH_CUDNN "Include NVIDIA CUDA Deep Neural Network (cuDNN) library support" WITH_CUDA
VISIBLE_IF WITH_CUDA
VERIFY HAVE_CUDNN)
OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" WITH_CUDA
OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" OFF # disabled, details: https://github.com/opencv/opencv/issues/14850
VISIBLE_IF WITH_CUDA
VERIFY HAVE_NVCUVID)
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" (NOT CV_DISABLE_OPTIMIZATION AND NOT CMAKE_CROSSCOMPILING)
@@ -918,30 +922,6 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/custom_hal.hpp.in" "${CMAKE
unset(_hal_includes)
# ----------------------------------------------------------------------------
# Add CUDA libraries (needed for apps/tools, samples)
# ----------------------------------------------------------------------------
if(HAVE_CUDA)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
if(HAVE_CUBLAS)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUDNN)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDNN_LIBRARIES})
endif()
if(HAVE_CUFFT)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
endif()
foreach(p ${CUDA_LIBS_PATH})
if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja|JOM")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}"${p}")
else()
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}${p})
endif()
endforeach()
endif()
# ----------------------------------------------------------------------------
# Code trace support
# ----------------------------------------------------------------------------
@@ -988,7 +968,7 @@ if(BUILD_opencv_apps)
endif()
# examples
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES OR INSTALL_C_EXAMPLES)
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES OR INSTALL_C_EXAMPLES)
add_subdirectory(samples)
endif()
@@ -1223,7 +1203,7 @@ ocv_build_features_string(apps_status
IF BUILD_EXAMPLES THEN "examples"
IF BUILD_opencv_apps THEN "apps"
IF BUILD_ANDROID_SERVICE THEN "android_service"
IF BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN "android_examples"
IF (BUILD_ANDROID_EXAMPLES OR INSTALL_ANDROID_EXAMPLES) AND CAN_BUILD_ANDROID_PROJECTS THEN "android_examples"
ELSE "-")
status(" Applications:" "${apps_status}")
ocv_build_features_string(docs_status
+49
View File
@@ -337,3 +337,52 @@ if(HAVE_CUDA)
ocv_convert_to_lib_name(CUDA_cufft_LIBRARY ${CUDA_cufft_LIBRARY})
endif()
endif()
# ----------------------------------------------------------------------------
# Add CUDA libraries (needed for apps/tools, samples)
# ----------------------------------------------------------------------------
if(HAVE_CUDA)
# details: https://github.com/NVIDIA/nvidia-docker/issues/775
if(" ${CUDA_CUDA_LIBRARY}" MATCHES "/stubs/libcuda.so" AND NOT OPENCV_SKIP_CUDA_STUB_WORKAROUND)
set(CUDA_STUB_ENABLED_LINK_WORKAROUND 1)
if(EXISTS "${CUDA_CUDA_LIBRARY}" AND NOT OPENCV_SKIP_CUDA_STUB_WORKAROUND_RPATH_LINK)
set(CUDA_STUB_TARGET_PATH "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/")
execute_process(COMMAND ${CMAKE_COMMAND} -E create_symlink "${CUDA_CUDA_LIBRARY}" "${CUDA_STUB_TARGET_PATH}/libcuda.so.1"
RESULT_VARIABLE CUDA_STUB_SYMLINK_RESULT)
if(NOT CUDA_STUB_SYMLINK_RESULT EQUAL 0)
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CUDA_CUDA_LIBRARY}" "${CUDA_STUB_TARGET_PATH}/libcuda.so.1"
RESULT_VARIABLE CUDA_STUB_COPY_RESULT)
if(NOT CUDA_STUB_COPY_RESULT EQUAL 0)
set(CUDA_STUB_ENABLED_LINK_WORKAROUND 0)
endif()
endif()
if(CUDA_STUB_ENABLED_LINK_WORKAROUND)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,\"${CUDA_STUB_TARGET_PATH}\"")
endif()
else()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--allow-shlib-undefined")
endif()
if(NOT CUDA_STUB_ENABLED_LINK_WORKAROUND)
message(WARNING "CUDA: workaround for stubs/libcuda.so.1 is not applied")
endif()
endif()
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_LIBRARIES} ${CUDA_CUDA_LIBRARY} ${CUDA_npp_LIBRARY})
if(HAVE_CUBLAS)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cublas_LIBRARY})
endif()
if(HAVE_CUDNN)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDNN_LIBRARIES})
endif()
if(HAVE_CUFFT)
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CUDA_cufft_LIBRARY})
endif()
foreach(p ${CUDA_LIBS_PATH})
if(MSVC AND CMAKE_GENERATOR MATCHES "Ninja|JOM")
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}"${p}")
else()
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} ${CMAKE_LIBRARY_PATH_FLAG}${p})
endif()
endforeach()
endif()
+23 -11
View File
@@ -105,17 +105,29 @@ macro(add_android_project target path)
include ':${__dir}'
")
# build apk
set(APK_FILE "${ANDROID_BUILD_BASE_DIR}/${__dir}/build/outputs/apk/release/${__dir}-${ANDROID_ABI}-release-unsigned.apk")
ocv_update(OPENCV_GRADLE_VERBOSE_OPTIONS "-i")
add_custom_command(
OUTPUT "${APK_FILE}" "${OPENCV_DEPHELPER}/android_sample_${__dir}"
COMMAND ./gradlew ${OPENCV_GRADLE_VERBOSE_OPTIONS} "${__dir}:assemble"
COMMAND ${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/android_sample_${__dir}"
WORKING_DIRECTORY "${ANDROID_BUILD_BASE_DIR}"
DEPENDS ${depends} opencv_java_android
COMMENT "Building OpenCV Android sample project: ${__dir}"
)
if (BUILD_ANDROID_EXAMPLES)
# build apk
set(APK_FILE "${ANDROID_BUILD_BASE_DIR}/${__dir}/build/outputs/apk/release/${__dir}-${ANDROID_ABI}-release-unsigned.apk")
ocv_update(OPENCV_GRADLE_VERBOSE_OPTIONS "-i")
add_custom_command(
OUTPUT "${APK_FILE}" "${OPENCV_DEPHELPER}/android_sample_${__dir}"
COMMAND ./gradlew ${OPENCV_GRADLE_VERBOSE_OPTIONS} "${__dir}:assemble"
COMMAND ${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/android_sample_${__dir}"
WORKING_DIRECTORY "${ANDROID_BUILD_BASE_DIR}"
DEPENDS ${depends} opencv_java_android
COMMENT "Building OpenCV Android sample project: ${__dir}"
)
else() # install only
# copy samples
add_custom_command(
OUTPUT "${OPENCV_DEPHELPER}/android_sample_${__dir}"
COMMAND ${CMAKE_COMMAND} -E touch "${OPENCV_DEPHELPER}/android_sample_${__dir}"
WORKING_DIRECTORY "${ANDROID_BUILD_BASE_DIR}"
DEPENDS ${depends} opencv_java_android
COMMENT "Copying OpenCV Android sample project: ${__dir}"
)
endif()
file(REMOVE "${OPENCV_DEPHELPER}/android_sample_${__dir}") # force rebuild after CMake run
add_custom_target(android_sample_${__dir} ALL DEPENDS "${OPENCV_DEPHELPER}/android_sample_${__dir}" SOURCES "${ANDROID_SAMPLE_MANIFEST_PATH}")
@@ -62,8 +62,8 @@ We need **CMake** to configure the installation, **GCC** for compilation, **Pyth
```
sudo apt-get install cmake
sudo apt-get install python-devel numpy
sudo apt-get install gcc gcc-c++
sudo apt-get install python-dev python-numpy
sudo apt-get install gcc g++
```
Next we need **GTK** support for GUI features, Camera support (v4l), Media Support
+3
View File
@@ -1,4 +1,7 @@
set(the_description "Camera Calibration and 3D Reconstruction")
ocv_add_dispatched_file(undistort SSE2 AVX2)
set(debug_modules "")
if(DEBUG_opencv_calib3d)
list(APPEND debug_modules opencv_highgui)
+2 -2
View File
@@ -1226,8 +1226,8 @@ CV_EXPORTS_W bool checkChessboard(InputArray img, Size size);
@param corners Output array of detected corners.
@param flags Various operation flags that can be zero or a combination of the following values:
- **CALIB_CB_NORMALIZE_IMAGE** Normalize the image gamma with equalizeHist before detection.
- **CALIB_CB_EXHAUSTIVE ** Run an exhaustive search to improve detection rate.
- **CALIB_CB_ACCURACY ** Up sample input image to improve sub-pixel accuracy due to aliasing effects.
- **CALIB_CB_EXHAUSTIVE** Run an exhaustive search to improve detection rate.
- **CALIB_CB_ACCURACY** Up sample input image to improve sub-pixel accuracy due to aliasing effects.
This should be used if an accurate camera calibration is required.
The function is analog to findchessboardCorners but uses a localized radon
+19
View File
@@ -0,0 +1,19 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html
#include "perf_precomp.hpp"
namespace opencv_test {
PERF_TEST(Undistort, InitUndistortMap)
{
Size size_w_h(512 + 3, 512);
Mat k(3, 3, CV_32FC1);
Mat d(1, 14, CV_64FC1);
Mat dst(size_w_h, CV_32FC2);
declare.in(k, d, WARMUP_RNG).out(dst);
TEST_CYCLE() initUndistortRectifyMap(k, d, noArray(), k, size_w_h, CV_32FC2, dst, noArray());
SANITY_CHECK_NOTHING();
}
}
-194
View File
@@ -1,194 +0,0 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include "undistort.hpp"
namespace cv
{
int initUndistortRectifyMapLine_AVX(float* m1f, float* m2f, short* m1, ushort* m2, double* matTilt, const double* ir,
double& _x, double& _y, double& _w, int width, int m1type,
double k1, double k2, double k3, double k4, double k5, double k6,
double p1, double p2, double s1, double s2, double s3, double s4,
double u0, double v0, double fx, double fy)
{
int j = 0;
static const __m256d __one = _mm256_set1_pd(1.0);
static const __m256d __two = _mm256_set1_pd(2.0);
const __m256d __matTilt_00 = _mm256_set1_pd(matTilt[0]);
const __m256d __matTilt_10 = _mm256_set1_pd(matTilt[3]);
const __m256d __matTilt_20 = _mm256_set1_pd(matTilt[6]);
const __m256d __matTilt_01 = _mm256_set1_pd(matTilt[1]);
const __m256d __matTilt_11 = _mm256_set1_pd(matTilt[4]);
const __m256d __matTilt_21 = _mm256_set1_pd(matTilt[7]);
const __m256d __matTilt_02 = _mm256_set1_pd(matTilt[2]);
const __m256d __matTilt_12 = _mm256_set1_pd(matTilt[5]);
const __m256d __matTilt_22 = _mm256_set1_pd(matTilt[8]);
for (; j <= width - 4; j += 4, _x += 4 * ir[0], _y += 4 * ir[3], _w += 4 * ir[6])
{
// Question: Should we load the constants first?
__m256d __w = _mm256_div_pd(__one, _mm256_set_pd(_w + 3 * ir[6], _w + 2 * ir[6], _w + ir[6], _w));
__m256d __x = _mm256_mul_pd(_mm256_set_pd(_x + 3 * ir[0], _x + 2 * ir[0], _x + ir[0], _x), __w);
__m256d __y = _mm256_mul_pd(_mm256_set_pd(_y + 3 * ir[3], _y + 2 * ir[3], _y + ir[3], _y), __w);
__m256d __x2 = _mm256_mul_pd(__x, __x);
__m256d __y2 = _mm256_mul_pd(__y, __y);
__m256d __r2 = _mm256_add_pd(__x2, __y2);
__m256d __2xy = _mm256_mul_pd(__two, _mm256_mul_pd(__x, __y));
__m256d __kr = _mm256_div_pd(
#if CV_FMA3
_mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_set1_pd(k3), __r2, _mm256_set1_pd(k2)), __r2, _mm256_set1_pd(k1)), __r2, __one),
_mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_fmadd_pd(_mm256_set1_pd(k6), __r2, _mm256_set1_pd(k5)), __r2, _mm256_set1_pd(k4)), __r2, __one)
#else
_mm256_add_pd(__one, _mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(k3), __r2), _mm256_set1_pd(k2)), __r2), _mm256_set1_pd(k1)), __r2)),
_mm256_add_pd(__one, _mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_add_pd(_mm256_mul_pd(_mm256_set1_pd(k6), __r2), _mm256_set1_pd(k5)), __r2), _mm256_set1_pd(k4)), __r2))
#endif
);
__m256d __r22 = _mm256_mul_pd(__r2, __r2);
#if CV_FMA3
__m256d __xd = _mm256_fmadd_pd(__x, __kr,
_mm256_add_pd(
_mm256_fmadd_pd(_mm256_set1_pd(p1), __2xy, _mm256_mul_pd(_mm256_set1_pd(p2), _mm256_fmadd_pd(__two, __x2, __r2))),
_mm256_fmadd_pd(_mm256_set1_pd(s1), __r2, _mm256_mul_pd(_mm256_set1_pd(s2), __r22))));
__m256d __yd = _mm256_fmadd_pd(__y, __kr,
_mm256_add_pd(
_mm256_fmadd_pd(_mm256_set1_pd(p1), _mm256_fmadd_pd(__two, __y2, __r2), _mm256_mul_pd(_mm256_set1_pd(p2), __2xy)),
_mm256_fmadd_pd(_mm256_set1_pd(s3), __r2, _mm256_mul_pd(_mm256_set1_pd(s4), __r22))));
__m256d __vecTilt2 = _mm256_fmadd_pd(__matTilt_20, __xd, _mm256_fmadd_pd(__matTilt_21, __yd, __matTilt_22));
#else
__m256d __xd = _mm256_add_pd(
_mm256_mul_pd(__x, __kr),
_mm256_add_pd(
_mm256_add_pd(
_mm256_mul_pd(_mm256_set1_pd(p1), __2xy),
_mm256_mul_pd(_mm256_set1_pd(p2), _mm256_add_pd(__r2, _mm256_mul_pd(__two, __x2)))),
_mm256_add_pd(
_mm256_mul_pd(_mm256_set1_pd(s1), __r2),
_mm256_mul_pd(_mm256_set1_pd(s2), __r22))));
__m256d __yd = _mm256_add_pd(
_mm256_mul_pd(__y, __kr),
_mm256_add_pd(
_mm256_add_pd(
_mm256_mul_pd(_mm256_set1_pd(p1), _mm256_add_pd(__r2, _mm256_mul_pd(__two, __y2))),
_mm256_mul_pd(_mm256_set1_pd(p2), __2xy)),
_mm256_add_pd(
_mm256_mul_pd(_mm256_set1_pd(s3), __r2),
_mm256_mul_pd(_mm256_set1_pd(s4), __r22))));
__m256d __vecTilt2 = _mm256_add_pd(_mm256_add_pd(
_mm256_mul_pd(__matTilt_20, __xd), _mm256_mul_pd(__matTilt_21, __yd)), __matTilt_22);
#endif
__m256d __invProj = _mm256_blendv_pd(
_mm256_div_pd(__one, __vecTilt2), __one,
_mm256_cmp_pd(__vecTilt2, _mm256_setzero_pd(), _CMP_EQ_OQ));
#if CV_FMA3
__m256d __u = _mm256_fmadd_pd(__matTilt_00, __xd, _mm256_fmadd_pd(__matTilt_01, __yd, __matTilt_02));
__u = _mm256_fmadd_pd(_mm256_mul_pd(_mm256_set1_pd(fx), __invProj), __u, _mm256_set1_pd(u0));
__m256d __v = _mm256_fmadd_pd(__matTilt_10, __xd, _mm256_fmadd_pd(__matTilt_11, __yd, __matTilt_12));
__v = _mm256_fmadd_pd(_mm256_mul_pd(_mm256_set1_pd(fy), __invProj), __v, _mm256_set1_pd(v0));
#else
__m256d __u = _mm256_add_pd(_mm256_add_pd(
_mm256_mul_pd(__matTilt_00, __xd), _mm256_mul_pd(__matTilt_01, __yd)), __matTilt_02);
__u = _mm256_add_pd(_mm256_mul_pd(_mm256_mul_pd(_mm256_set1_pd(fx), __invProj), __u), _mm256_set1_pd(u0));
__m256d __v = _mm256_add_pd(_mm256_add_pd(
_mm256_mul_pd(__matTilt_10, __xd), _mm256_mul_pd(__matTilt_11, __yd)), __matTilt_12);
__v = _mm256_add_pd(_mm256_mul_pd(_mm256_mul_pd(_mm256_set1_pd(fy), __invProj), __v), _mm256_set1_pd(v0));
#endif
if (m1type == CV_32FC1)
{
_mm_storeu_ps(&m1f[j], _mm256_cvtpd_ps(__u));
_mm_storeu_ps(&m2f[j], _mm256_cvtpd_ps(__v));
}
else if (m1type == CV_32FC2)
{
__m128 __u_float = _mm256_cvtpd_ps(__u);
__m128 __v_float = _mm256_cvtpd_ps(__v);
_mm_storeu_ps(&m1f[j * 2], _mm_unpacklo_ps(__u_float, __v_float));
_mm_storeu_ps(&m1f[j * 2 + 4], _mm_unpackhi_ps(__u_float, __v_float));
}
else // m1type == CV_16SC2
{
__u = _mm256_mul_pd(__u, _mm256_set1_pd(INTER_TAB_SIZE));
__v = _mm256_mul_pd(__v, _mm256_set1_pd(INTER_TAB_SIZE));
__m128i __iu = _mm256_cvtpd_epi32(__u);
__m128i __iv = _mm256_cvtpd_epi32(__v);
static const __m128i __INTER_TAB_SIZE_m1 = _mm_set1_epi32(INTER_TAB_SIZE - 1);
__m128i __m2 = _mm_add_epi32(
_mm_mullo_epi32(_mm_and_si128(__iv, __INTER_TAB_SIZE_m1), _mm_set1_epi32(INTER_TAB_SIZE)),
_mm_and_si128(__iu, __INTER_TAB_SIZE_m1));
__m2 = _mm_packus_epi32(__m2, __m2);
_mm_maskstore_epi64((long long int*) &m2[j], _mm_set_epi32(0, 0, 0xFFFFFFFF, 0xFFFFFFFF), __m2);
// gcc4.9 does not support _mm256_set_m128
// __m256i __m1 = _mm256_set_m128i(__iv, __iu);
__m256i __m1 = _mm256_setzero_si256();
__m1 = _mm256_inserti128_si256(__m1, __iu, 0);
__m1 = _mm256_inserti128_si256(__m1, __iv, 1);
__m1 = _mm256_srai_epi32(__m1, INTER_BITS); // v3 v2 v1 v0 u3 u2 u1 u0 (int32_t)
static const __m256i __permute_mask = _mm256_set_epi32(7, 3, 6, 2, 5, 1, 4, 0);
__m1 = _mm256_permutevar8x32_epi32(__m1, __permute_mask); // v3 u3 v2 u2 v1 u1 v0 u0 (int32_t)
__m1 = _mm256_packs_epi32(__m1, __m1); // x x x x v3 u3 v2 u2 x x x x v1 u1 v0 u0 (int16_t)
_mm_storeu_si128((__m128i*) &m1[j * 2], _mm256_extracti128_si256(_mm256_permute4x64_epi64(__m1, (2 << 2) + 0), 0));
}
}
_mm256_zeroupper();
return j;
}
}
/* End of file */
@@ -42,11 +42,16 @@
#include "precomp.hpp"
#include "distortion_model.hpp"
#include "undistort.hpp"
#include "calib3d_c_api.h"
cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
#include "undistort.simd.hpp"
#include "undistort.simd_declarations.hpp" // defines CV_CPU_DISPATCH_MODES_ALL=AVX2,...,BASELINE based on CMakeLists.txt content
namespace cv
{
Mat getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
bool centerPrincipalPoint )
{
Mat cameraMatrix = _cameraMatrix.getMat();
@@ -63,134 +68,22 @@ cv::Mat cv::getDefaultNewCameraMatrix( InputArray _cameraMatrix, Size imgsize,
return newCameraMatrix;
}
class initUndistortRectifyMapComputer : public cv::ParallelLoopBody
namespace {
Ptr<ParallelLoopBody> getInitUndistortRectifyMapComputer(Size _size, Mat &_map1, Mat &_map2, int _m1type,
const double* _ir, Matx33d &_matTilt,
double _u0, double _v0, double _fx, double _fy,
double _k1, double _k2, double _p1, double _p2,
double _k3, double _k4, double _k5, double _k6,
double _s1, double _s2, double _s3, double _s4)
{
public:
initUndistortRectifyMapComputer(
cv::Size _size, cv::Mat &_map1, cv::Mat &_map2, int _m1type,
const double* _ir, cv::Matx33d &_matTilt,
double _u0, double _v0, double _fx, double _fy,
double _k1, double _k2, double _p1, double _p2,
double _k3, double _k4, double _k5, double _k6,
double _s1, double _s2, double _s3, double _s4)
: size(_size),
map1(_map1),
map2(_map2),
m1type(_m1type),
ir(_ir),
matTilt(_matTilt),
u0(_u0),
v0(_v0),
fx(_fx),
fy(_fy),
k1(_k1),
k2(_k2),
p1(_p1),
p2(_p2),
k3(_k3),
k4(_k4),
k5(_k5),
k6(_k6),
s1(_s1),
s2(_s2),
s3(_s3),
s4(_s4) {
#if CV_TRY_AVX2
useAVX2 = cv::checkHardwareSupport(CV_CPU_AVX2);
#endif
}
CV_INSTRUMENT_REGION();
void operator()( const cv::Range& range ) const CV_OVERRIDE
{
const int begin = range.start;
const int end = range.end;
CV_CPU_DISPATCH(getInitUndistortRectifyMapComputer, (_size, _map1, _map2, _m1type, _ir, _matTilt, _u0, _v0, _fx, _fy, _k1, _k2, _p1, _p2, _k3, _k4, _k5, _k6, _s1, _s2, _s3, _s4),
CV_CPU_DISPATCH_MODES_ALL);
}
}
for( int i = begin; i < end; i++ )
{
float* m1f = map1.ptr<float>(i);
float* m2f = map2.empty() ? 0 : map2.ptr<float>(i);
short* m1 = (short*)m1f;
ushort* m2 = (ushort*)m2f;
double _x = i*ir[1] + ir[2], _y = i*ir[4] + ir[5], _w = i*ir[7] + ir[8];
int j = 0;
if (m1type == CV_16SC2)
CV_Assert(m1 != NULL && m2 != NULL);
else if (m1type == CV_32FC1)
CV_Assert(m1f != NULL && m2f != NULL);
else
CV_Assert(m1 != NULL);
#if CV_TRY_AVX2
if( useAVX2 )
j = cv::initUndistortRectifyMapLine_AVX(m1f, m2f, m1, m2,
matTilt.val, ir, _x, _y, _w, size.width, m1type,
k1, k2, k3, k4, k5, k6, p1, p2, s1, s2, s3, s4, u0, v0, fx, fy);
#endif
for( ; j < size.width; j++, _x += ir[0], _y += ir[3], _w += ir[6] )
{
double w = 1./_w, x = _x*w, y = _y*w;
double x2 = x*x, y2 = y*y;
double r2 = x2 + y2, _2xy = 2*x*y;
double kr = (1 + ((k3*r2 + k2)*r2 + k1)*r2)/(1 + ((k6*r2 + k5)*r2 + k4)*r2);
double xd = (x*kr + p1*_2xy + p2*(r2 + 2*x2) + s1*r2+s2*r2*r2);
double yd = (y*kr + p1*(r2 + 2*y2) + p2*_2xy + s3*r2+s4*r2*r2);
cv::Vec3d vecTilt = matTilt*cv::Vec3d(xd, yd, 1);
double invProj = vecTilt(2) ? 1./vecTilt(2) : 1;
double u = fx*invProj*vecTilt(0) + u0;
double v = fy*invProj*vecTilt(1) + v0;
if( m1type == CV_16SC2 )
{
int iu = cv::saturate_cast<int>(u*cv::INTER_TAB_SIZE);
int iv = cv::saturate_cast<int>(v*cv::INTER_TAB_SIZE);
m1[j*2] = (short)(iu >> cv::INTER_BITS);
m1[j*2+1] = (short)(iv >> cv::INTER_BITS);
m2[j] = (ushort)((iv & (cv::INTER_TAB_SIZE-1))*cv::INTER_TAB_SIZE + (iu & (cv::INTER_TAB_SIZE-1)));
}
else if( m1type == CV_32FC1 )
{
m1f[j] = (float)u;
m2f[j] = (float)v;
}
else
{
m1f[j*2] = (float)u;
m1f[j*2+1] = (float)v;
}
}
}
}
private:
cv::Size size;
cv::Mat &map1;
cv::Mat &map2;
int m1type;
const double* ir;
cv::Matx33d &matTilt;
double u0;
double v0;
double fx;
double fy;
double k1;
double k2;
double p1;
double p2;
double k3;
double k4;
double k5;
double k6;
double s1;
double s2;
double s3;
double s4;
#if CV_TRY_AVX2
bool useAVX2;
#endif
};
void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoeffs,
void initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoeffs,
InputArray _matR, InputArray _newCameraMatrix,
Size size, int m1type, OutputArray _map1, OutputArray _map2 )
{
@@ -263,17 +156,17 @@ void cv::initUndistortRectifyMap( InputArray _cameraMatrix, InputArray _distCoef
double tauY = distCoeffs.cols + distCoeffs.rows - 1 >= 14 ? distPtr[13] : 0.;
// Matrix for trapezoidal distortion of tilted image sensor
cv::Matx33d matTilt = cv::Matx33d::eye();
cv::detail::computeTiltProjectionMatrix(tauX, tauY, &matTilt);
Matx33d matTilt = Matx33d::eye();
detail::computeTiltProjectionMatrix(tauX, tauY, &matTilt);
parallel_for_(Range(0, size.height), initUndistortRectifyMapComputer(
parallel_for_(Range(0, size.height), *getInitUndistortRectifyMapComputer(
size, map1, map2, m1type, ir, matTilt, u0, v0,
fx, fy, k1, k2, p1, p2, k3, k4, k5, k6, s1, s2, s3, s4));
}
void cv::undistort( InputArray _src, OutputArray _dst, InputArray _cameraMatrix,
InputArray _distCoeffs, InputArray _newCameraMatrix )
void undistort( InputArray _src, OutputArray _dst, InputArray _cameraMatrix,
InputArray _distCoeffs, InputArray _newCameraMatrix )
{
CV_INSTRUMENT_REGION();
@@ -319,6 +212,7 @@ void cv::undistort( InputArray _src, OutputArray _dst, InputArray _cameraMatrix,
}
}
}
CV_IMPL void
cvUndistort2( const CvArr* srcarr, CvArr* dstarr, const CvMat* Aarr, const CvMat* dist_coeffs, const CvMat* newAarr )
-59
View File
@@ -1,59 +0,0 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#ifndef OPENCV_CALIB3D_UNDISTORT_HPP
#define OPENCV_CALIB3D_UNDISTORT_HPP
namespace cv
{
#if CV_TRY_AVX2
int initUndistortRectifyMapLine_AVX(float* m1f, float* m2f, short* m1, ushort* m2, double* matTilt, const double* ir,
double& _x, double& _y, double& _w, int width, int m1type,
double k1, double k2, double k3, double k4, double k5, double k6,
double p1, double p2, double s1, double s2, double s3, double s4,
double u0, double v0, double fx, double fy);
#endif
}
#endif // OPENCV_CALIB3D_UNDISTORT_HPP
/* End of file */
+324
View File
@@ -0,0 +1,324 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistribution's of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistribution's in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//
//M*/
#include "precomp.hpp"
#include "opencv2/core/hal/intrin.hpp"
namespace cv {
CV_CPU_OPTIMIZATION_NAMESPACE_BEGIN
// forward declarations
Ptr<ParallelLoopBody> getInitUndistortRectifyMapComputer(Size _size, Mat &_map1, Mat &_map2, int _m1type,
const double* _ir, Matx33d &_matTilt,
double _u0, double _v0, double _fx, double _fy,
double _k1, double _k2, double _p1, double _p2,
double _k3, double _k4, double _k5, double _k6,
double _s1, double _s2, double _s3, double _s4);
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
namespace
{
class initUndistortRectifyMapComputer : public ParallelLoopBody
{
public:
initUndistortRectifyMapComputer(
Size _size, Mat &_map1, Mat &_map2, int _m1type,
const double* _ir, Matx33d &_matTilt,
double _u0, double _v0, double _fx, double _fy,
double _k1, double _k2, double _p1, double _p2,
double _k3, double _k4, double _k5, double _k6,
double _s1, double _s2, double _s3, double _s4)
: size(_size),
map1(_map1),
map2(_map2),
m1type(_m1type),
ir(_ir),
matTilt(_matTilt),
u0(_u0),
v0(_v0),
fx(_fx),
fy(_fy),
k1(_k1),
k2(_k2),
p1(_p1),
p2(_p2),
k3(_k3),
k4(_k4),
k5(_k5),
k6(_k6),
s1(_s1),
s2(_s2),
s3(_s3),
s4(_s4) {
#if CV_SIMD_64F
for (int i = 0; i < 2 * v_float64::nlanes; ++i)
{
s_x[i] = ir[0] * i;
s_y[i] = ir[3] * i;
s_w[i] = ir[6] * i;
}
#endif
}
void operator()( const cv::Range& range ) const CV_OVERRIDE
{
CV_INSTRUMENT_REGION();
const int begin = range.start;
const int end = range.end;
for( int i = begin; i < end; i++ )
{
float* m1f = map1.ptr<float>(i);
float* m2f = map2.empty() ? 0 : map2.ptr<float>(i);
short* m1 = (short*)m1f;
ushort* m2 = (ushort*)m2f;
double _x = i*ir[1] + ir[2], _y = i*ir[4] + ir[5], _w = i*ir[7] + ir[8];
int j = 0;
if (m1type == CV_16SC2)
CV_Assert(m1 != NULL && m2 != NULL);
else if (m1type == CV_32FC1)
CV_Assert(m1f != NULL && m2f != NULL);
else
CV_Assert(m1 != NULL);
#if CV_SIMD_64F
const v_float64 v_one = vx_setall_f64(1.0);
for (; j <= size.width - 2*v_float64::nlanes; j += 2*v_float64::nlanes, _x += 2*v_float64::nlanes * ir[0], _y += 2*v_float64::nlanes * ir[3], _w += 2*v_float64::nlanes * ir[6])
{
v_float64 m_0, m_1, m_2, m_3;
m_2 = v_one / (vx_setall_f64(_w) + vx_load(s_w));
m_3 = v_one / (vx_setall_f64(_w) + vx_load(s_w + v_float64::nlanes));
m_0 = vx_setall_f64(_x); m_1 = vx_setall_f64(_y);
v_float64 x_0 = (m_0 + vx_load(s_x)) * m_2;
v_float64 x_1 = (m_0 + vx_load(s_x + v_float64::nlanes)) * m_3;
v_float64 y_0 = (m_1 + vx_load(s_y)) * m_2;
v_float64 y_1 = (m_1 + vx_load(s_y + v_float64::nlanes)) * m_3;
v_float64 xd_0 = x_0 * x_0;
v_float64 yd_0 = y_0 * y_0;
v_float64 xd_1 = x_1 * x_1;
v_float64 yd_1 = y_1 * y_1;
v_float64 r2_0 = xd_0 + yd_0;
v_float64 r2_1 = xd_1 + yd_1;
m_1 = vx_setall_f64(k3);
m_2 = vx_setall_f64(k2);
m_3 = vx_setall_f64(k1);
m_0 = v_muladd(v_muladd(v_muladd(m_1, r2_0, m_2), r2_0, m_3), r2_0, v_one);
m_1 = v_muladd(v_muladd(v_muladd(m_1, r2_1, m_2), r2_1, m_3), r2_1, v_one);
m_3 = vx_setall_f64(k6);
m_2 = vx_setall_f64(k5);
m_0 /= v_muladd(v_muladd(v_muladd(m_3, r2_0, m_2), r2_0, vx_setall_f64(k4)), r2_0, v_one);
m_1 /= v_muladd(v_muladd(v_muladd(m_3, r2_1, m_2), r2_1, vx_setall_f64(k4)), r2_1, v_one);
x_0 *= m_0; y_0 *= m_0; x_1 *= m_1; y_1 *= m_1;
m_0 = vx_setall_f64(p1);
m_1 = vx_setall_f64(p2);
m_2 = vx_setall_f64(2.0);
xd_0 = v_muladd(v_muladd(m_2, xd_0, r2_0), m_1, x_0);
yd_0 = v_muladd(v_muladd(m_2, yd_0, r2_0), m_0, y_0);
xd_1 = v_muladd(v_muladd(m_2, xd_1, r2_1), m_1, x_1);
yd_1 = v_muladd(v_muladd(m_2, yd_1, r2_1), m_0, y_1);
m_0 *= m_2; m_1 *= m_2;
m_2 = x_0 * y_0;
m_3 = x_1 * y_1;
xd_0 = v_muladd(m_0, m_2, xd_0);
yd_0 = v_muladd(m_1, m_2, yd_0);
xd_1 = v_muladd(m_0, m_3, xd_1);
yd_1 = v_muladd(m_1, m_3, yd_1);
m_0 = r2_0 * r2_0;
m_1 = r2_1 * r2_1;
m_2 = vx_setall_f64(s2);
m_3 = vx_setall_f64(s1);
xd_0 = v_muladd(m_3, r2_0, v_muladd(m_2, m_0, xd_0));
xd_1 = v_muladd(m_3, r2_1, v_muladd(m_2, m_1, xd_1));
m_2 = vx_setall_f64(s4);
m_3 = vx_setall_f64(s3);
yd_0 = v_muladd(m_3, r2_0, v_muladd(m_2, m_0, yd_0));
yd_1 = v_muladd(m_3, r2_1, v_muladd(m_2, m_1, yd_1));
m_0 = vx_setall_f64(matTilt.val[0]);
m_1 = vx_setall_f64(matTilt.val[1]);
m_2 = vx_setall_f64(matTilt.val[2]);
x_0 = v_muladd(m_0, xd_0, v_muladd(m_1, yd_0, m_2));
x_1 = v_muladd(m_0, xd_1, v_muladd(m_1, yd_1, m_2));
m_0 = vx_setall_f64(matTilt.val[3]);
m_1 = vx_setall_f64(matTilt.val[4]);
m_2 = vx_setall_f64(matTilt.val[5]);
y_0 = v_muladd(m_0, xd_0, v_muladd(m_1, yd_0, m_2));
y_1 = v_muladd(m_0, xd_1, v_muladd(m_1, yd_1, m_2));
m_0 = vx_setall_f64(matTilt.val[6]);
m_1 = vx_setall_f64(matTilt.val[7]);
m_2 = vx_setall_f64(matTilt.val[8]);
r2_0 = v_muladd(m_0, xd_0, v_muladd(m_1, yd_0, m_2));
r2_1 = v_muladd(m_0, xd_1, v_muladd(m_1, yd_1, m_2));
m_0 = vx_setzero_f64();
r2_0 = v_select(r2_0 == m_0, v_one, v_one / r2_0);
r2_1 = v_select(r2_1 == m_0, v_one, v_one / r2_1);
m_0 = vx_setall_f64(fx);
m_1 = vx_setall_f64(u0);
m_2 = vx_setall_f64(fy);
m_3 = vx_setall_f64(v0);
x_0 = v_muladd(m_0 * r2_0, x_0, m_1);
y_0 = v_muladd(m_2 * r2_0, y_0, m_3);
x_1 = v_muladd(m_0 * r2_1, x_1, m_1);
y_1 = v_muladd(m_2 * r2_1, y_1, m_3);
if (m1type == CV_32FC1)
{
v_store(&m1f[j], v_cvt_f32(x_0, x_1));
v_store(&m2f[j], v_cvt_f32(y_0, y_1));
}
else if (m1type == CV_32FC2)
{
v_float32 mf0, mf1;
v_zip(v_cvt_f32(x_0, x_1), v_cvt_f32(y_0, y_1), mf0, mf1);
v_store(&m1f[j * 2], mf0);
v_store(&m1f[j * 2 + v_float32::nlanes], mf1);
}
else // m1type == CV_16SC2
{
m_0 = vx_setall_f64(INTER_TAB_SIZE);
x_0 *= m_0; x_1 *= m_0; y_0 *= m_0; y_1 *= m_0;
v_int32 mask = vx_setall_s32(INTER_TAB_SIZE - 1);
v_int32 iu = v_round(x_0, x_1);
v_int32 iv = v_round(y_0, y_1);
v_pack_u_store(&m2[j], (iu & mask) + (iv & mask) * vx_setall_s32(INTER_TAB_SIZE));
v_int32 out0, out1;
v_zip(iu >> INTER_BITS, iv >> INTER_BITS, out0, out1);
v_store(&m1[j * 2], v_pack(out0, out1));
}
}
vx_cleanup();
#endif
for( ; j < size.width; j++, _x += ir[0], _y += ir[3], _w += ir[6] )
{
double w = 1./_w, x = _x*w, y = _y*w;
double x2 = x*x, y2 = y*y;
double r2 = x2 + y2, _2xy = 2*x*y;
double kr = (1 + ((k3*r2 + k2)*r2 + k1)*r2)/(1 + ((k6*r2 + k5)*r2 + k4)*r2);
double xd = (x*kr + p1*_2xy + p2*(r2 + 2*x2) + s1*r2+s2*r2*r2);
double yd = (y*kr + p1*(r2 + 2*y2) + p2*_2xy + s3*r2+s4*r2*r2);
Vec3d vecTilt = matTilt*cv::Vec3d(xd, yd, 1);
double invProj = vecTilt(2) ? 1./vecTilt(2) : 1;
double u = fx*invProj*vecTilt(0) + u0;
double v = fy*invProj*vecTilt(1) + v0;
if( m1type == CV_16SC2 )
{
int iu = saturate_cast<int>(u*INTER_TAB_SIZE);
int iv = saturate_cast<int>(v*INTER_TAB_SIZE);
m1[j*2] = (short)(iu >> INTER_BITS);
m1[j*2+1] = (short)(iv >> INTER_BITS);
m2[j] = (ushort)((iv & (INTER_TAB_SIZE-1))*INTER_TAB_SIZE + (iu & (INTER_TAB_SIZE-1)));
}
else if( m1type == CV_32FC1 )
{
m1f[j] = (float)u;
m2f[j] = (float)v;
}
else
{
m1f[j*2] = (float)u;
m1f[j*2+1] = (float)v;
}
}
}
}
private:
Size size;
Mat &map1;
Mat &map2;
int m1type;
const double* ir;
Matx33d &matTilt;
double u0;
double v0;
double fx;
double fy;
double k1;
double k2;
double p1;
double p2;
double k3;
double k4;
double k5;
double k6;
double s1;
double s2;
double s3;
double s4;
#if CV_SIMD_64F
double s_x[2*v_float64::nlanes];
double s_y[2*v_float64::nlanes];
double s_w[2*v_float64::nlanes];
#endif
};
}
Ptr<ParallelLoopBody> getInitUndistortRectifyMapComputer(Size _size, Mat &_map1, Mat &_map2, int _m1type,
const double* _ir, Matx33d &_matTilt,
double _u0, double _v0, double _fx, double _fy,
double _k1, double _k2, double _p1, double _p2,
double _k3, double _k4, double _k5, double _k6,
double _s1, double _s2, double _s3, double _s4)
{
CV_INSTRUMENT_REGION();
return Ptr<initUndistortRectifyMapComputer>(new initUndistortRectifyMapComputer(_size, _map1, _map2, _m1type, _ir, _matTilt, _u0, _v0, _fx, _fy,
_k1, _k2, _p1, _p2, _k3, _k4, _k5, _k6, _s1, _s2, _s3, _s4));
}
#endif
CV_CPU_OPTIMIZATION_NAMESPACE_END
}
/* End of file */
@@ -583,11 +583,11 @@ public:
/** @brief Reads node elements to the buffer with the specified format.
Usually it is more convenient to use operator `>>` instead of this method.
@param fmt Specification of each array element. See @ref format_spec "format specification"
@param vec Pointer to the destination array.
@param len Number of elements to read. If it is greater than number of remaining elements then all
of them will be read.
Usually it is more convenient to use operator `>>` instead of this method.
@param fmt Specification of each array element. See @ref format_spec "format specification"
@param vec Pointer to the destination array.
@param len Number of bytes to read (buffer size limit). If it is greater than number of
remaining elements then all of them will be read.
*/
void readRaw( const String& fmt, void* vec, size_t len ) const;
@@ -652,14 +652,14 @@ public:
/** @brief Reads node elements to the buffer with the specified format.
Usually it is more convenient to use operator `>>` instead of this method.
@param fmt Specification of each array element. See @ref format_spec "format specification"
@param vec Pointer to the destination array.
@param maxCount Number of elements to read. If it is greater than number of remaining elements then
all of them will be read.
Usually it is more convenient to use operator `>>` instead of this method.
@param fmt Specification of each array element. See @ref format_spec "format specification"
@param vec Pointer to the destination array.
@param len Number of bytes to read (buffer size limit). If it is greater than number of
remaining elements then all of them will be read.
*/
FileNodeIterator& readRaw( const String& fmt, void* vec,
size_t maxCount=(size_t)INT_MAX );
size_t len=(size_t)INT_MAX );
//! returns the number of remaining (not read yet) elements
size_t remaining() const;
@@ -0,0 +1,88 @@
// 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.
#ifndef OPENCV_CORE_SIMD_INTRINSICS_HPP
#define OPENCV_CORE_SIMD_INTRINSICS_HPP
/**
Helper header to support SIMD intrinsics (universal intrinsics) in user code.
Intrinsics documentation: https://docs.opencv.org/3.4/df/d91/group__core__hal__intrin.html
Checks of target CPU instruction set based on compiler definitions don't work well enough.
More reliable solutions require utilization of configuration systems (like CMake).
So, probably you need to specify your own configuration.
You can do that via CMake in this way:
add_definitions(/DOPENCV_SIMD_CONFIG_HEADER=opencv_simd_config_custom.hpp)
or
add_definitions(/DOPENCV_SIMD_CONFIG_INCLUDE_DIR=1)
Additionally you may need to add include directory to your files:
include_directories("${CMAKE_CURRENT_LIST_DIR}/opencv_config_${MYTARGET}")
These files can be pre-generated for target configurations of your application
or generated by CMake on the fly (use CMAKE_BINARY_DIR for that).
Notes:
- H/W capability checks are still responsibility of your applcation
- runtime dispatching is not covered by this helper header
*/
#ifdef __OPENCV_BUILD
#error "Use core/hal/intrin.hpp during OpenCV build"
#endif
#ifdef OPENCV_HAL_INTRIN_HPP
#error "core/simd_intrinsics.hpp must be included before core/hal/intrin.hpp"
#endif
#include "opencv2/core/cvdef.h"
#include "opencv2/core/version.hpp"
#ifdef OPENCV_SIMD_CONFIG_HEADER
#include CVAUX_STR(OPENCV_SIMD_CONFIG_HEADER)
#elif defined(OPENCV_SIMD_CONFIG_INCLUDE_DIR)
#include "opencv_simd_config.hpp" // corresponding directory should be added via -I compiler parameter
#else // custom config headers
#if (!defined(CV_AVX_512F) || !CV_AVX_512F) && (defined(__AVX512__) || defined(__AVX512F__))
# include <immintrin.h>
# undef CV_AVX_512F
# define CV_AVX_512F 1
# ifndef OPENCV_SIMD_DONT_ASSUME_SKX // Skylake-X with AVX-512F/CD/BW/DQ/VL
# undef CV_AVX512_SKX
# define CV_AVX512_SKX 1
# undef CV_AVX_512CD
# define CV_AVX_512CD 1
# undef CV_AVX_512BW
# define CV_AVX_512BW 1
# undef CV_AVX_512DQ
# define CV_AVX_512DQ 1
# undef CV_AVX_512VL
# define CV_AVX_512VL 1
# endif
#endif // AVX512
// GCC/Clang: -mavx2
// MSVC: /arch:AVX2
#if defined __AVX2__
# include <immintrin.h>
# undef CV_AVX2
# define CV_AVX2 1
# if defined __F16C__
# undef CV_FP16
# define CV_FP16 1
# endif
#endif
#endif
// SSE / NEON / VSX is handled by cv_cpu_dispatch.h compatibility block
#include "cv_cpu_dispatch.h"
#include "hal/intrin.hpp"
#endif // OPENCV_CORE_SIMD_INTRINSICS_HPP
@@ -9,7 +9,7 @@
#ifndef OPENCV_HAVE_FILESYSTEM_SUPPORT
# if defined(__EMSCRIPTEN__) || defined(__native_client__)
/* no support */
# elif defined WINRT
# elif defined WINRT || defined _WIN32_WCE
/* not supported */
# elif defined __ANDROID__ || defined __linux__ || defined _WIN32 || \
defined __FreeBSD__ || defined __bsdi__ || defined __HAIKU__
@@ -8,7 +8,7 @@
#define CV_VERSION_MAJOR 4
#define CV_VERSION_MINOR 1
#define CV_VERSION_REVISION 1
#define CV_VERSION_STATUS "-openvino"
#define CV_VERSION_STATUS ""
#define CVAUX_STR_EXP(__A) #__A
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
+3 -3
View File
@@ -57,7 +57,7 @@ namespace
struct DIR
{
#ifdef WINRT
#if defined(WINRT) || defined(_WIN32_WCE)
WIN32_FIND_DATAW data;
#else
WIN32_FIND_DATAA data;
@@ -78,7 +78,7 @@ namespace
{
DIR* dir = new DIR;
dir->ent.d_name = 0;
#ifdef WINRT
#if defined(WINRT) || defined(_WIN32_WCE)
cv::String full_path = cv::String(path) + "\\*";
wchar_t wfull_path[MAX_PATH];
size_t copied = mbstowcs(wfull_path, full_path.c_str(), MAX_PATH);
@@ -100,7 +100,7 @@ namespace
dirent* readdir(DIR* dir)
{
#ifdef WINRT
#if defined(WINRT) || defined(_WIN32_WCE)
if (dir->ent.d_name != 0)
{
if (::FindNextFileW(dir->handle, &dir->data) != TRUE)
+22 -1
View File
@@ -2511,6 +2511,27 @@ double dotProd_32f(const float* src1, const float* src2, int len)
int j = 0;
int cWidth = v_float32::nlanes;
#if CV_ENABLE_UNROLLED
v_float32 v_sum1 = vx_setzero_f32();
v_float32 v_sum2 = vx_setzero_f32();
v_float32 v_sum3 = vx_setzero_f32();
for (; j <= blockSize - (cWidth * 4); j += (cWidth * 4))
{
v_sum = v_muladd(vx_load(src1 + j),
vx_load(src2 + j), v_sum);
v_sum1 = v_muladd(vx_load(src1 + j + cWidth),
vx_load(src2 + j + cWidth), v_sum1);
v_sum2 = v_muladd(vx_load(src1 + j + (cWidth * 2)),
vx_load(src2 + j + (cWidth * 2)), v_sum2);
v_sum3 = v_muladd(vx_load(src1 + j + (cWidth * 3)),
vx_load(src2 + j + (cWidth * 3)), v_sum3);
}
v_sum += v_sum1 + v_sum2 + v_sum3;
#endif
for (; j <= blockSize - cWidth; j += cWidth)
v_sum = v_muladd(vx_load(src1 + j), vx_load(src2 + j), v_sum);
@@ -2532,4 +2553,4 @@ double dotProd_64f(const double* src1, const double* src2, int len)
#endif
CV_CPU_OPTIMIZATION_NAMESPACE_END
} // namespace
} // namespace
+1 -1
View File
@@ -1722,7 +1722,7 @@ static bool parseOpenCLDeviceConfiguration(const std::string& configurationStr,
return true;
}
#ifdef WINRT
#if defined WINRT || defined _WIN32_WCE
static cl_device_id selectOpenCLDevice()
{
return NULL;
+12
View File
@@ -296,6 +296,8 @@ public:
while ( is_eof == false && is_completed == false )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
switch ( *ptr )
{
/* comment */
@@ -381,6 +383,7 @@ public:
if ( is_eof || !is_completed )
{
ptr = fs->bufferStart();
CV_Assert(ptr);
*ptr = '\0';
fs->setEof();
if( !is_completed )
@@ -392,6 +395,9 @@ public:
char* parseKey( char* ptr, FileNode& collection, FileNode& value_placeholder )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
if( *ptr != '"' )
CV_PARSE_ERROR_CPP( "Key must start with \'\"\'" );
@@ -430,6 +436,9 @@ public:
char* parseValue( char* ptr, FileNode& node )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid value input");
ptr = skipSpaces( ptr );
if( !ptr || !*ptr )
CV_PARSE_ERROR_CPP( "Unexpected End-Of-File" );
@@ -817,6 +826,9 @@ public:
bool parse( char* ptr )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
ptr = skipSpaces( ptr );
if ( !ptr || !*ptr )
return false;
+21
View File
@@ -360,6 +360,9 @@ public:
char* skipSpaces( char* ptr, int mode )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
int level = 0;
for(;;)
@@ -441,6 +444,9 @@ public:
char* parseValue( char* ptr, FileNode& node )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
FileNode new_elem;
bool have_space = true;
int value_type = node.type();
@@ -456,6 +462,8 @@ public:
(c == '<' && ptr[1] == '!' && ptr[2] == '-') )
{
ptr = skipSpaces( ptr, 0 );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
have_space = true;
c = *ptr;
}
@@ -502,6 +510,8 @@ public:
{
ptr = fs->parseBase64( ptr, 0, new_elem);
ptr = skipSpaces( ptr, 0 );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
}
ptr = parseTag( ptr, key2, type_name, tag_type );
@@ -645,6 +655,9 @@ public:
char* parseTag( char* ptr, std::string& tag_name,
std::string& type_name, int& tag_type )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid tag input");
if( *ptr == '\0' )
CV_PARSE_ERROR_CPP( "Unexpected end of the stream" );
@@ -702,6 +715,8 @@ public:
if( *ptr != '=' )
{
ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid attribute");
if( *ptr != '=' )
CV_PARSE_ERROR_CPP( "Attribute name should be followed by \'=\'" );
}
@@ -740,6 +755,8 @@ public:
if( c != '>' )
{
ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
c = *ptr;
}
@@ -781,6 +798,8 @@ public:
// CV_XML_INSIDE_TAG is used to prohibit leading comments
ptr = skipSpaces( ptr, CV_XML_INSIDE_TAG );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
if( memcmp( ptr, "<?xml", 5 ) != 0 ) // FIXIT ptr[1..] - out of bounds read without check
CV_PARSE_ERROR_CPP( "Valid XML should start with \'<?xml ...?>\'" );
@@ -791,6 +810,8 @@ public:
while( ptr && *ptr != '\0' )
{
ptr = skipSpaces( ptr, 0 );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
if( *ptr != '\0' )
{
+21
View File
@@ -330,6 +330,9 @@ public:
char* skipSpaces( char* ptr, int min_indent, int max_comment_indent )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
for(;;)
{
while( *ptr == ' ' )
@@ -374,6 +377,9 @@ public:
bool getBase64Row(char* ptr, int indent, char* &beg, char* &end)
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
beg = end = ptr = skipSpaces(ptr, 0, INT_MAX);
if (!ptr || !*ptr)
return false; // end of file
@@ -394,6 +400,9 @@ public:
char* parseKey( char* ptr, FileNode& map_node, FileNode& value_placeholder )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
char c;
char *endptr = ptr - 1, *saveptr;
@@ -422,6 +431,9 @@ public:
char* parseValue( char* ptr, FileNode& node, int min_indent, bool is_parent_flow )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
char* endptr = 0;
char c = ptr[0], d = ptr[1];
int value_type = FileNode::NONE;
@@ -508,6 +520,8 @@ public:
*endptr = d;
ptr = skipSpaces( endptr, min_indent, INT_MAX );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
c = *ptr;
@@ -634,6 +648,8 @@ public:
FileNode elem;
ptr = skipSpaces( ptr, new_min_indent, INT_MAX );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
if( *ptr == '}' || *ptr == ']' )
{
if( *ptr != d )
@@ -647,6 +663,8 @@ public:
if( *ptr != ',' )
CV_PARSE_ERROR_CPP( "Missing , between the elements" );
ptr = skipSpaces( ptr + 1, new_min_indent, INT_MAX );
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
}
if( struct_type == FileNode::MAP )
@@ -746,6 +764,9 @@ public:
bool parse( char* ptr )
{
if (!ptr)
CV_PARSE_ERROR_CPP("Invalid input");
bool first = true;
bool ok = true;
FileNode root_collection(fs->getFS(), 0, 0);
+19 -5
View File
@@ -378,7 +378,7 @@ struct HWFeatures
void initialize(void)
{
#ifndef WINRT
#ifndef NO_GETENV
if (getenv("OPENCV_DUMP_CONFIG"))
{
fprintf(stderr, "\nOpenCV build configuration is:\n%s\n",
@@ -614,10 +614,10 @@ struct HWFeatures
{
bool dump = true;
const char* disabled_features =
#ifndef WINRT
getenv("OPENCV_CPU_DISABLE");
#else
#ifdef NO_GETENV
NULL;
#else
getenv("OPENCV_CPU_DISABLE");
#endif
if (disabled_features && disabled_features[0] != 0)
{
@@ -889,7 +889,7 @@ String format( const char* fmt, ... )
String tempfile( const char* suffix )
{
String fname;
#ifndef WINRT
#ifndef NO_GETENV
const char *temp_dir = getenv("OPENCV_TEMP_PATH");
#endif
@@ -910,6 +910,20 @@ String tempfile( const char* suffix )
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
fname = String(aname);
RoUninitialize();
#elif defined(_WIN32_WCE)
const auto kMaxPathSize = MAX_PATH+1;
wchar_t temp_dir[kMaxPathSize] = {0};
wchar_t temp_file[kMaxPathSize] = {0};
::GetTempPathW(kMaxPathSize, temp_dir);
if(0 != ::GetTempFileNameW(temp_dir, L"ocv", 0, temp_file)) {
DeleteFileW(temp_file);
char aname[MAX_PATH];
size_t copied = wcstombs(aname, temp_file, MAX_PATH);
CV_Assert((copied != MAX_PATH) && (copied != (size_t)-1));
fname = String(aname);
}
#else
char temp_dir2[MAX_PATH] = { 0 };
char temp_file[MAX_PATH] = { 0 };
+95 -51
View File
@@ -581,36 +581,27 @@ struct data_t
}
};
TEST(Core_InputOutput, filestorage_base64_basic)
static void test_filestorage_basic(int write_flags, const char* suffix_name, bool testReadWrite, bool useMemory = false)
{
const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info();
std::string basename = (test_info == 0)
? "filestorage_base64_valid_call"
: (std::string(test_info->test_case_name()) + "--" + test_info->name());
CV_Assert(test_info);
std::string name = (std::string(test_info->test_case_name()) + "--" + test_info->name() + suffix_name);
if (!testReadWrite)
name = string(cvtest::TS::ptr()->get_data_path()) + "io/" + name;
char const * filenames[] = {
"core_io_base64_basic_test.yml",
"core_io_base64_basic_test.xml",
"core_io_base64_basic_test.json",
0
};
for (char const ** ptr = filenames; *ptr; ptr++)
{
char const * suffix_name = *ptr;
std::string name = basename + '_' + suffix_name;
const size_t rawdata_N = 40;
std::vector<data_t> rawdata;
cv::Mat _em_out, _em_in;
cv::Mat _2d_out, _2d_in;
cv::Mat _nd_out, _nd_in;
cv::Mat _rd_out(64, 64, CV_64FC1), _rd_in;
cv::Mat _rd_out(8, 16, CV_64FC1), _rd_in;
{ /* init */
/* a normal mat */
_2d_out = cv::Mat(100, 100, CV_8UC3, cvScalar(1U, 2U, 127U));
_2d_out = cv::Mat(10, 20, CV_8UC3, cvScalar(1U, 2U, 127U));
for (int i = 0; i < _2d_out.rows; ++i)
for (int j = 0; j < _2d_out.cols; ++j)
_2d_out.at<cv::Vec3b>(i, j)[1] = (i + j) % 256;
@@ -629,7 +620,7 @@ TEST(Core_InputOutput, filestorage_base64_basic)
cv::randu(_rd_out, cv::Scalar(0.0), cv::Scalar(1.0));
/* raw data */
for (int i = 0; i < 1000; i++) {
for (int i = 0; i < (int)rawdata_N; i++) {
data_t tmp;
tmp.u1 = 1;
tmp.u2 = 2;
@@ -642,25 +633,41 @@ TEST(Core_InputOutput, filestorage_base64_basic)
rawdata.push_back(tmp);
}
}
{ /* write */
cv::FileStorage fs(name, cv::FileStorage::WRITE_BASE64);
#ifdef GENERATE_TEST_DATA
#else
if (testReadWrite || useMemory)
#endif
{
cv::FileStorage fs(name, write_flags + (useMemory ? cv::FileStorage::MEMORY : 0));
fs << "normal_2d_mat" << _2d_out;
fs << "normal_nd_mat" << _nd_out;
fs << "empty_2d_mat" << _em_out;
fs << "random_mat" << _rd_out;
fs << "rawdata" << "[:";
size_t esz = sizeof(data_t);
for (int i = 0; i < 10; i++)
fs.writeRaw(data_t::signature(), rawdata.data() + i * 100, 100*esz );
fs << "rawdata" << "[:";
for (int i = 0; i < (int)rawdata_N/10; i++)
fs.writeRaw(data_t::signature(), (const uchar*)&rawdata[i * 10], sizeof(data_t) * 10);
fs << "]";
fs.release();
size_t sz = 0;
if (useMemory)
{
name = fs.releaseAndGetString();
sz = name.size();
}
else
{
fs.release();
std::ifstream f(name.c_str(), std::ios::in|std::ios::binary);
f.seekg(0, std::fstream::end);
sz = (size_t)f.tellg();
f.close();
}
std::cout << "Storage size: " << sz << std::endl;
EXPECT_LE(sz, (size_t)6000);
}
{ /* read */
cv::FileStorage fs(name, cv::FileStorage::READ);
cv::FileStorage fs(name, cv::FileStorage::READ + (useMemory ? cv::FileStorage::MEMORY : 0));
/* mat */
fs["empty_2d_mat"] >> _em_in;
@@ -669,24 +676,23 @@ TEST(Core_InputOutput, filestorage_base64_basic)
fs["random_mat"] >> _rd_in;
/* raw data */
std::vector<data_t>(1000).swap(rawdata);
fs["rawdata"].readRaw(data_t::signature(), &rawdata[0], 1000*sizeof(rawdata[0]));
std::vector<data_t>(rawdata_N).swap(rawdata);
fs["rawdata"].readRaw(data_t::signature(), (uchar*)&rawdata[0], rawdata.size() * sizeof(data_t));
fs.release();
}
int errors = 0;
const data_t* rawdata_ptr = &rawdata[0];
for (int i = 0; i < 1000; i++)
for (int i = 0; i < (int)rawdata_N; i++)
{
EXPECT_EQ((int)rawdata_ptr[i].u1, 1);
EXPECT_EQ((int)rawdata_ptr[i].u2, 2);
EXPECT_EQ((int)rawdata_ptr[i].i1, 1);
EXPECT_EQ((int)rawdata_ptr[i].i2, 2);
EXPECT_EQ((int)rawdata_ptr[i].i3, 3);
EXPECT_EQ(rawdata_ptr[i].d1, 0.1);
EXPECT_EQ(rawdata_ptr[i].d2, 0.2);
EXPECT_EQ((int)rawdata_ptr[i].i4, i);
EXPECT_EQ((int)rawdata[i].u1, 1);
EXPECT_EQ((int)rawdata[i].u2, 2);
EXPECT_EQ((int)rawdata[i].i1, 1);
EXPECT_EQ((int)rawdata[i].i2, 2);
EXPECT_EQ((int)rawdata[i].i3, 3);
EXPECT_EQ(rawdata[i].d1, 0.1);
EXPECT_EQ(rawdata[i].d2, 0.2);
EXPECT_EQ((int)rawdata[i].i4, i);
if (::testing::Test::HasNonfatalFailure())
{
printf("i = %d\n", i);
@@ -729,18 +735,54 @@ TEST(Core_InputOutput, filestorage_base64_basic)
EXPECT_EQ(_nd_in.cols , _nd_out.cols);
EXPECT_EQ(_nd_in.dims , _nd_out.dims);
EXPECT_EQ(_nd_in.depth(), _nd_out.depth());
EXPECT_EQ(cv::countNonZero(cv::mean(_nd_in != _nd_out)), 0);
EXPECT_EQ(0, cv::norm(_nd_in, _nd_out, NORM_INF));
EXPECT_EQ(_rd_in.rows , _rd_out.rows);
EXPECT_EQ(_rd_in.cols , _rd_out.cols);
EXPECT_EQ(_rd_in.dims , _rd_out.dims);
EXPECT_EQ(_rd_in.depth(), _rd_out.depth());
EXPECT_EQ(cv::countNonZero(cv::mean(_rd_in != _rd_out)), 0);
remove(name.c_str());
EXPECT_EQ(0, cv::norm(_rd_in, _rd_out, NORM_INF));
}
}
TEST(Core_InputOutput, filestorage_base64_basic_read_XML)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".xml", false);
}
TEST(Core_InputOutput, filestorage_base64_basic_read_YAML)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".yml", false);
}
TEST(Core_InputOutput, DISABLED_filestorage_base64_basic_read_JSON)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".json", false);
}
TEST(Core_InputOutput, DISABLED_filestorage_base64_basic_rw_XML)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".xml", true);
}
TEST(Core_InputOutput, DISABLED_filestorage_base64_basic_rw_YAML)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".yml", true);
}
TEST(Core_InputOutput, DISABLED_filestorage_base64_basic_rw_JSON)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".json", true);
}
TEST(Core_InputOutput, DISABLED_filestorage_base64_basic_memory_XML)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".xml", true, true);
}
TEST(Core_InputOutput, DISABLED_filestorage_base64_basic_memory_YAML)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".yml", true, true);
}
TEST(Core_InputOutput, DISABLED_filestorage_base64_basic_memory_JSON)
{
test_filestorage_basic(cv::FileStorage::WRITE_BASE64, ".json", true, true);
}
TEST(Core_InputOutput, filestorage_base64_valid_call)
{
const ::testing::TestInfo* const test_info = ::testing::UnitTest::GetInstance()->current_test_info();
@@ -770,10 +812,12 @@ TEST(Core_InputOutput, filestorage_base64_valid_call)
std::vector<int> rawdata(10, static_cast<int>(0x00010203));
cv::String str_out = "test_string";
for (char const ** ptr = filenames; *ptr; ptr++)
for (int n = 0; n < 6; n++)
{
char const * suffix_name = *ptr;
char const* suffix_name = filenames[n];
SCOPED_TRACE(suffix_name);
std::string name = basename + '_' + suffix_name;
std::string file_name = basename + '_' + real_name[n];
EXPECT_NO_THROW(
{
@@ -791,9 +835,9 @@ TEST(Core_InputOutput, filestorage_base64_valid_call)
});
{
cv::FileStorage fs(name, cv::FileStorage::READ);
cv::FileStorage fs(file_name, cv::FileStorage::READ);
std::vector<int> data_in(rawdata.size());
fs["manydata"][0].readRaw("i", data_in.data(), data_in.size()*sizeof(data_in[0]));
fs["manydata"][0].readRaw("i", (uchar *)data_in.data(), data_in.size() * sizeof(data_in[0]));
EXPECT_TRUE(fs["manydata"][0].isSeq());
EXPECT_TRUE(std::equal(rawdata.begin(), rawdata.end(), data_in.begin()));
cv::String str_in;
@@ -819,19 +863,19 @@ TEST(Core_InputOutput, filestorage_base64_valid_call)
});
{
cv::FileStorage fs(name, cv::FileStorage::READ);
cv::FileStorage fs(file_name, cv::FileStorage::READ);
cv::String str_in;
fs["manydata"][0] >> str_in;
EXPECT_TRUE(fs["manydata"][0].isString());
EXPECT_EQ(str_in, str_out);
std::vector<int> data_in(rawdata.size());
fs["manydata"][1].readRaw("i", (uchar *)data_in.data(), data_in.size()*sizeof(data_in[0]));
fs["manydata"][1].readRaw("i", (uchar *)data_in.data(), data_in.size() * sizeof(data_in[0]));
EXPECT_TRUE(fs["manydata"][1].isSeq());
EXPECT_TRUE(std::equal(rawdata.begin(), rawdata.end(), data_in.begin()));
fs.release();
}
remove((basename + '_' + real_name[ptr - filenames]).c_str());
EXPECT_EQ(0, remove(file_name.c_str()));
}
}
@@ -366,6 +366,7 @@ CV__DNN_INLINE_NS_BEGIN
*/
std::vector<std::vector<Range> > sliceRanges;
int axis;
int num_split;
static Ptr<SliceLayer> create(const LayerParams &params);
};
+1 -1
View File
@@ -383,7 +383,7 @@ CV__DNN_INLINE_NS_BEGIN
/** @brief Dump net to String
* @returns String with structure, hyperparameters, backend, target and fusion
* To see correct backend, target and fusion run after forward().
* Call method after setInput(). To see correct backend, target and fusion run after forward().
*/
CV_WRAP String dump();
/** @brief Dump net structure, hyperparameters, backend, target and fusion to dot file
+182
View File
@@ -0,0 +1,182 @@
// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
#include <opencv2/dnn/shape_utils.hpp>
namespace opencv_test {
struct Conv3DParam_t {
int kernel[3];
struct BlobShape { int dims[5]; } shapeIn;
int outCN;
int groups;
int stride[3];
int dilation[3];
int pad[6];
const char* padMode;
bool hasBias;
double declared_flops;
};
// Details: #12142
static const Conv3DParam_t testConvolution3DConfigs[] = {
{{3, 3, 3}, {{1, 6, 10, 38, 50}}, 6, 1, {1, 1, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "VALID", true, 26956800.},
{{3, 3, 3}, {{1, 2, 19, 19, 19}}, 2, 2, {2, 2, 2}, {1, 1, 1}, {1, 1, 1, 1, 1, 1}, "", true, 218000.},
{{3, 3, 3}, {{1, 2, 25, 19, 19}}, 2, 2, {1, 2, 2}, {1, 1, 1}, {2, 2, 2, 2, 2, 2}, "SAME", false, 545000.},
{{3, 3, 3}, {{1, 11, 9, 150, 200}}, 11, 1, {1, 1, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "VALID", true, 1342562760.},
{{3, 3, 3}, {{1, 10, 98, 10, 10}}, 10, 1, {1, 1, 1}, {1, 1, 1}, {1, 0, 1, 1, 0,1}, "SAME", false, 53018000.},
{{5, 5, 5}, {{1, 6, 19, 19, 19}}, 6, 2, {1, 1, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "", false, 30395250.},
{{5, 5, 5}, {{1, 4, 50, 19, 19}}, 4, 1, {2, 2, 2}, {1, 1, 1}, {1, 1, 1, 1, 1, 1}, "VALID", false, 5893888.},
{{5, 5, 5}, {{1, 3, 75, 75, 100}}, 3, 1, {1, 1, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "SAME", true, 1267312500.},
{{5, 5, 5}, {{1, 2, 21, 75, 100}}, 2, 1, {1, 1, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "", true, 116103744.},
{{5, 5, 5}, {{1, 4, 40, 75, 75}}, 4, 1, {2, 2, 2}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "", false, 93405312.},
{{7, 7, 7}, {{1, 6, 15, 19, 19}}, 6, 1, {2, 1, 1}, {1, 1, 1}, {3, 3, 3, 3, 3, 3}, "SAME", true, 71339376.},
{{7, 7, 7}, {{1, 2, 38, 38, 38}}, 2, 1, {1, 2, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "", false, 44990464.},
{{1, 1, 1}, {{1, 4, 9, 10, 10}}, 4, 1, {1, 1, 2}, {1, 1, 1}, {1, 1, 1, 1, 1, 1}, "VALID", false, 16200.},
{{3, 1, 4}, {{1, 14, 5, 10, 10}}, 14, 1, {1, 1, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "SAME", false, 2359000.},
{{1, 1, 1}, {{1, 8, 1, 10, 10}}, 8, 8, {1, 1, 1}, {1, 1, 1}, {1, 1, 1, 1, 1, 1}, "", true, 58752.},
{{3, 4, 2}, {{1, 4, 8, 10, 10}}, 4, 4, {1, 2, 1}, {1, 1, 1}, {0, 0, 0, 0, 0, 0}, "", true, 166752.}
};
struct Conv3DParamID
{
enum {
CONV_0 = 0,
CONV_100 = 16,
CONV_LAST = sizeof(testConvolution3DConfigs) / sizeof(testConvolution3DConfigs[0])
};
int val_; \
Conv3DParamID(int val = 0) : val_(val) {}
operator int() const { return val_; }
static ::testing::internal::ParamGenerator<Conv3DParamID> all()
{
#if 0
enum { NUM = (int)CONV_LAST };
#else
enum { NUM = (int)CONV_100 };
#endif
Conv3DParamID v_[NUM]; for (int i = 0; i < NUM; ++i) { v_[i] = Conv3DParamID(i); } // reduce generated code size
return ::testing::ValuesIn(v_, v_ + NUM);
}
}; \
static inline void PrintTo(const Conv3DParamID& v, std::ostream* os)
{
CV_Assert((int)v >= 0); CV_Assert((int)v < Conv3DParamID::CONV_LAST);
const Conv3DParam_t& p = testConvolution3DConfigs[(int)v];
*os << "GFLOPS=" << cv::format("%.3f", p.declared_flops * 1e-9)
<< ", K=[" << p.kernel[0] << " x " << p.kernel[1] << " x " << p.kernel[2] << "]"
<< ", IN={" << p.shapeIn.dims[0] << ", " << p.shapeIn.dims[1] << ", " << p.shapeIn.dims[2] << ", " << p.shapeIn.dims[3] << ", " << p.shapeIn.dims[4] << "}"
<< ", OCN=" << p.outCN;
if (p.groups > 1)
*os << ", G=" << p.groups;
if (p.stride[0] * p.stride[1] * p.stride[2] != 1)
*os << ", S=[" << p.stride[0] << " x " << p.stride[1] << " x " << p.stride[2] << "]";
if (p.dilation[0] * p.dilation[1] * p.dilation[2] != 1)
*os << ", D=[" << p.dilation[0] << " x " << p.dilation[1] << " x " << p.dilation[2] << "]";
if (p.pad[0] != 0 && p.pad[1] != 0 && p.pad[2] != 0 &&
p.pad[3] != 0 && p.pad[4] != 0 && p.pad[5] != 0)
*os << ", P=(" << p.pad[0] << ", " << p.pad[3] << ") x ("
<< p.pad[1] << ", " << p.pad[4] << ") x ("
<< p.pad[2] << ", " << p.pad[5] << ")";
if (!((std::string)p.padMode).empty())
*os << ", PM=" << ((std::string)p.padMode);
if (p.hasBias)
*os << ", BIAS";
}
typedef tuple<Conv3DParamID, tuple<Backend, Target> > Conv3DTestParam_t;
typedef TestBaseWithParam<Conv3DTestParam_t> Conv3D;
PERF_TEST_P_(Conv3D, conv3d)
{
int test_id = (int)get<0>(GetParam());
ASSERT_GE(test_id, 0); ASSERT_LT(test_id, Conv3DParamID::CONV_LAST);
const Conv3DParam_t& params = testConvolution3DConfigs[test_id];
double declared_flops = params.declared_flops;
DictValue kernel = DictValue::arrayInt(&params.kernel[0], 3);
DictValue stride = DictValue::arrayInt(&params.stride[0], 3);
DictValue pad = DictValue::arrayInt(&params.pad[0], 6);
DictValue dilation = DictValue::arrayInt(&params.dilation[0], 3);
MatShape inputShape = MatShape(params.shapeIn.dims, params.shapeIn.dims + 5);
int outChannels = params.outCN;
int groups = params.groups;
std::string padMode(params.padMode);
bool hasBias = params.hasBias;
Backend backendId = get<0>(get<1>(GetParam()));
Target targetId = get<1>(get<1>(GetParam()));
if (targetId != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
int inChannels = inputShape[1];
int sz[] = {outChannels, inChannels / groups, params.kernel[0], params.kernel[1], params.kernel[2]};
Mat weights(5, &sz[0], CV_32F);
randu(weights, -1.0f, 1.0f);
LayerParams lp;
lp.set("kernel_size", kernel);
lp.set("pad", pad);
if (!padMode.empty())
lp.set("pad_mode", padMode);
lp.set("stride", stride);
lp.set("dilation", dilation);
lp.set("num_output", outChannels);
lp.set("group", groups);
lp.set("bias_term", hasBias);
lp.type = "Convolution";
lp.name = "testLayer";
lp.blobs.push_back(weights);
if (hasBias)
{
Mat bias(1, outChannels, CV_32F);
randu(bias, -1.0f, 1.0f);
lp.blobs.push_back(bias);
}
int inpSz[] = {1, inChannels, inputShape[2], inputShape[3], inputShape[4]};
Mat input(5, &inpSz[0], CV_32F);
randu(input, -1.0f, 1.0f);
Net net;
net.addLayerToPrev(lp.name, lp.type, lp);
net.setInput(input);
net.setPreferableBackend(backendId);
net.setPreferableTarget(targetId);
Mat output = net.forward();
MatShape netInputShape = shape(input);
size_t weightsMemory = 0, blobsMemory = 0;
net.getMemoryConsumption(netInputShape, weightsMemory, blobsMemory);
int64 flops = net.getFLOPS(netInputShape);
CV_Assert(flops > 0);
std::cout
<< "IN=" << divUp(input.total() * input.elemSize(), 1u<<10) << " Kb " << netInputShape
<< " OUT=" << divUp(output.total() * output.elemSize(), 1u<<10) << " Kb " << shape(output)
<< " Weights(parameters): " << divUp(weightsMemory, 1u<<10) << " Kb"
<< " MFLOPS=" << flops * 1e-6 << std::endl;
TEST_CYCLE()
{
Mat res = net.forward();
}
EXPECT_NEAR(flops, declared_flops, declared_flops * 1e-6);
SANITY_CHECK_NOTHING();
}
INSTANTIATE_TEST_CASE_P(/**/, Conv3D, Combine(
Conv3DParamID::all(),
dnnBackendsAndTargets(false, false) // defined in ../test/test_common.hpp
));
} // namespace
+13
View File
@@ -142,6 +142,8 @@ PERF_TEST_P_(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow)
{
if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException("");
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
throw SkipTestException("");
processNet("dnn/ssd_mobilenet_v1_coco_2017_11_17.pb", "ssd_mobilenet_v1_coco_2017_11_17.pbtxt", "",
Mat(cv::Size(300, 300), CV_32FC3));
}
@@ -150,6 +152,8 @@ PERF_TEST_P_(DNNTestNetwork, MobileNet_SSD_v2_TensorFlow)
{
if (backend == DNN_BACKEND_HALIDE)
throw SkipTestException("");
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
throw SkipTestException("");
processNet("dnn/ssd_mobilenet_v2_coco_2018_03_29.pb", "ssd_mobilenet_v2_coco_2018_03_29.pbtxt", "",
Mat(cv::Size(300, 300), CV_32FC3));
}
@@ -190,6 +194,11 @@ PERF_TEST_P_(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
throw SkipTestException("Test is disabled for MyriadX");
#endif
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
throw SkipTestException("Test is disabled for Myriad in OpenVINO 2019R2");
#endif
processNet("dnn/ssd_inception_v2_coco_2017_11_17.pb", "ssd_inception_v2_coco_2017_11_17.pbtxt", "",
Mat(cv::Size(300, 300), CV_32FC3));
}
@@ -223,6 +232,10 @@ PERF_TEST_P_(DNNTestNetwork, Inception_v2_Faster_RCNN)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019010000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE)
throw SkipTestException("Test is disabled in OpenVINO 2019R1");
#endif
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE)
throw SkipTestException("Test is disabled in OpenVINO 2019R2");
#endif
if (backend == DNN_BACKEND_HALIDE ||
(backend == DNN_BACKEND_INFERENCE_ENGINE && target != DNN_TARGET_CPU) ||
+11 -1
View File
@@ -2233,7 +2233,10 @@ struct Net::Impl
if (isAsync)
CV_Error(Error::StsNotImplemented, "Default implementation fallbacks in asynchronous mode");
CV_Assert(layer->supportBackend(DNN_BACKEND_OPENCV));
if (!layer->supportBackend(DNN_BACKEND_OPENCV))
CV_Error(Error::StsNotImplemented, format("Layer \"%s\" of type \"%s\" unsupported on OpenCV backend",
ld.name.c_str(), ld.type.c_str()));
if (preferableBackend == DNN_BACKEND_OPENCV && IS_DNN_OPENCL_TARGET(preferableTarget))
{
std::vector<UMat> umat_inputBlobs = OpenCLBackendWrapper::getUMatVector(ld.inputBlobsWrappers);
@@ -2979,6 +2982,13 @@ String parseLayerParams(const String& name, const LayerParams& lp) {
String Net::dump()
{
CV_Assert(!empty());
if (impl->netInputLayer->inputsData.empty())
CV_Error(Error::StsError, "Requested set input");
if (!impl->netWasAllocated)
impl->setUpNet();
std::ostringstream out;
std::map<int, LayerData>& map = impl->layers;
int prefBackend = impl->preferableBackend;
+239 -105
View File
@@ -48,6 +48,7 @@
#include "opencv2/core/hal/hal.hpp"
#include "opencv2/core/hal/intrin.hpp"
#include <iostream>
#include <numeric>
#ifdef HAVE_OPENCL
#include "opencl_kernels_dnn.hpp"
@@ -67,7 +68,7 @@ public:
BaseConvolutionLayerImpl(const LayerParams &params)
{
setParamsFrom(params);
getConvolutionKernelParams(params, kernel_size, pads_begin, pads_end, strides, dilations, padMode);
getConvolutionKernelParams(params, kernel_size, pads_begin, pads_end, strides, dilations, padMode, adjust_pads);
numOutput = params.get<int>("num_output");
int ngroups = params.get<int>("group", 1);
@@ -83,14 +84,14 @@ public:
pad = Size(pads_begin[1], pads_begin[0]);
dilation = Size(dilations[1], dilations[0]);
adjust_pads.push_back(params.get<int>("adj_h", 0));
adjust_pads.push_back(params.get<int>("adj_w", 0));
adjustPad.height = adjust_pads[0];
adjustPad.width = adjust_pads[1];
CV_Assert(adjustPad.width < stride.width &&
adjustPad.height < stride.height);
}
for (int i = 0; i < adjust_pads.size(); i++) {
CV_Assert(adjust_pads[i] < strides[i]);
}
fusedWeights = false;
fusedBias = false;
}
@@ -258,11 +259,14 @@ public:
else
#endif
{
if (kernel_size.size() != 2)
if (kernel_size.size() == 3)
return (preferableTarget == DNN_TARGET_CPU && backendId == DNN_BACKEND_OPENCV);
else if (kernel_size.size() == 2)
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE ||
(backendId == DNN_BACKEND_VKCOM && haveVulkan());
else
return false;
return backendId == DNN_BACKEND_OPENCV ||
backendId == DNN_BACKEND_HALIDE ||
(backendId == DNN_BACKEND_VKCOM && haveVulkan());
}
}
@@ -604,8 +608,8 @@ public:
const Mat* input_;
const Mat* weights_;
Mat* output_;
int outShape[4];
Size kernel_, pad_, stride_, dilation_;
int outShape[4]; // used only for conv2d
std::vector<size_t> kernel_size, pads_begin, pads_end, strides, dilations;
int ngroups_, nstripes_;
std::vector<int> ofstab_;
const std::vector<float>* biasvec_;
@@ -624,14 +628,18 @@ public:
static void run( const Mat& input, Mat& output, const Mat& weights,
const std::vector<float>& biasvec,
const std::vector<float>& reluslope,
Size kernel, Size pad, Size stride, Size dilation,
const std::vector<size_t>& kernel_size, const std::vector<size_t>& strides,
const std::vector<size_t>& pads_begin, const std::vector<size_t>& pads_end,
const std::vector<size_t>& dilations,
const ActivationLayer* activ, int ngroups, int nstripes )
{
size_t karea = std::accumulate(kernel_size.begin(), kernel_size.end(),
1, std::multiplies<size_t>());
CV_Assert_N(
input.dims == 4 && output.dims == 4,
(input.dims == 4 || input.dims == 5) && (input.dims == output.dims),
input.size[0] == output.size[0],
weights.rows == output.size[1],
weights.cols == (input.size[1]/ngroups)*kernel.width*kernel.height,
weights.cols == (input.size[1]/ngroups)*karea,
input.type() == output.type(),
input.type() == weights.type(),
input.type() == CV_32FC1,
@@ -645,26 +653,58 @@ public:
p.output_ = &output;
for( int i = 0; i < 4; i++ ) p.outShape[i] = output.size[i];
p.outShape[1] /= ngroups;
p.kernel_ = kernel; p.pad_ = pad; p.stride_ = stride; p.dilation_ = dilation;
p.kernel_size = kernel_size; p.strides = strides; p.dilations = dilations;
p.pads_begin = pads_begin; p.pads_end = pads_end;
p.ngroups_ = ngroups;
p.nstripes_ = nstripes;
int inpCnAll = input.size[1], width = input.size[3], height = input.size[2];
int inpCnAll = input.size[1];
int depth = (input.dims == 5) ? input.size[2] : 1;
int width = input.size[input.dims - 1];
int height = input.size[input.dims - 2];
int inpCn = inpCnAll / ngroups;
p.is1x1_ = kernel == Size(1,1) && pad == Size(0, 0);
p.useAVX = checkHardwareSupport(CPU_AVX);
p.useAVX2 = checkHardwareSupport(CPU_AVX2);
p.useAVX512 = CV_CPU_HAS_SUPPORT_AVX512_SKX;
bool isConv2D = kernel_size.size() == 2;
p.is1x1_ = isConv2D && kernel_size[0] == 1 && kernel_size[1] == 1 &&
pads_begin[0] == 0 && pads_begin[1] == 0;
p.useAVX = checkHardwareSupport(CPU_AVX) && isConv2D;
p.useAVX2 = checkHardwareSupport(CPU_AVX2) && isConv2D;
p.useAVX512 = CV_CPU_HAS_SUPPORT_AVX512_SKX && isConv2D;
int ncn = std::min(inpCn, (int)BLK_SIZE_CN);
p.ofstab_.resize(kernel.width*kernel.height*ncn);
int kernel_d = !isConv2D? kernel_size[0] : 1;
int kernel_h = kernel_size[kernel_size.size() - 2];
int kernel_w = kernel_size.back();
int dil_d = !isConv2D? dilations[0] : 1;
int dil_h = dilations[dilations.size() - 2];
int dil_w = dilations.back();
p.ofstab_.resize(karea * ncn);
int* ofstab = &p.ofstab_[0];
for( int k = 0; k < ncn; k++ )
for( int k_r = 0; k_r < kernel.height; k_r++ )
for( int k_c = 0; k_c < kernel.width; k_c++ )
ofstab[(k*kernel.height + k_r)*kernel.width + k_c] =
(k*height + k_r*dilation.height)*width + k_c*dilation.width;
if (isConv2D)
{
for( int k = 0; k < ncn; k++ )
for( int k_r = 0; k_r < kernel_h; k_r++ )
for( int k_c = 0; k_c < kernel_w; k_c++ )
ofstab[(k*kernel_h + k_r)*kernel_w + k_c] =
(k*height + k_r*dil_h)*width + k_c*dil_w;
}
else
{
for( int k = 0; k < ncn; k++ )
for (int k_d = 0; k_d < kernel_d; k_d++)
for( int k_r = 0; k_r < kernel_h; k_r++ )
for( int k_c = 0; k_c < kernel_w; k_c++ )
ofstab[(k*kernel_d*kernel_h + k_d*kernel_h + k_r)*kernel_w + k_c] =
(k*depth*height + k_d*dil_d*height + k_r*dil_h)*width + k_c*dil_w;
}
p.biasvec_ = &biasvec;
p.reluslope_ = &reluslope;
@@ -677,17 +717,39 @@ public:
{
const int valign = ConvolutionLayerImpl::VEC_ALIGN;
int ngroups = ngroups_, batchSize = input_->size[0]*ngroups;
int outW = output_->size[3], outH = output_->size[2], outCn = output_->size[1]/ngroups;
int width = input_->size[3], height = input_->size[2], inpCn = input_->size[1]/ngroups;
bool isConv2D = input_->dims == 4;
int outW = output_->size[output_->dims - 1];
int outH = output_->size[output_->dims - 2];
int outCn = output_->size[1]/ngroups;
int depth = !isConv2D? input_->size[2] : 1;
int height = input_->size[input_->dims - 2];
int width = input_->size[input_->dims - 1];
int inpCn = input_->size[1]/ngroups;
const int nstripes = nstripes_;
int kernel_w = kernel_.width, kernel_h = kernel_.height;
int pad_w = pad_.width, pad_h = pad_.height;
int stride_w = stride_.width, stride_h = stride_.height;
int dilation_w = dilation_.width, dilation_h = dilation_.height;
int karea = kernel_w*kernel_h;
int i, j, k;
size_t inpPlaneSize = width*height;
size_t outPlaneSize = outW*outH;
int kernel_d = !isConv2D? kernel_size[0] : 1;
int kernel_h = kernel_size[kernel_size.size() - 2];
int kernel_w = kernel_size.back();
int karea = kernel_w*kernel_h*kernel_d;
int pad_d = !isConv2D? pads_begin[0] : 0;
int pad_t = pads_begin[pads_begin.size() - 2];
int pad_l = pads_begin.back();
int stride_d = !isConv2D? strides[0] : 0;
int stride_h = strides[strides.size() - 2];
int stride_w = strides.back();
int dilation_d = !isConv2D? dilations[0] : 1;
int dilation_h = dilations[dilations.size() - 2];
int dilation_w = dilations.back();
int i, j, k, d;
size_t inpPlaneSize = input_->total(2);
size_t outPlaneSize = output_->total(2);
bool is1x1 = is1x1_;
int stripesPerSample;
@@ -756,72 +818,125 @@ public:
for( int ofs0 = stripeStart; ofs0 < stripeEnd; ofs0 += BLK_SIZE )
{
int ofs, ofs1 = std::min(ofs0 + BLK_SIZE, stripeEnd);
int out_i = ofs0 / outW;
int out_j = ofs0 - out_i * outW;
int out_d = ofs0 / (outH * outW);
int out_i = (ofs0 - out_d * outH * outW) / outW;
int out_j = ofs0 % outW;
// do im2row for a part of input tensor
float* rowbuf = rowbuf0;
for( ofs = ofs0; ofs < ofs1; out_j = 0, ++out_i )
{
int delta = std::min(ofs1 - ofs, outW - out_j);
int out_j1 = out_j + delta;
int in_i = out_i * stride_h - pad_h;
int in_j = out_j * stride_w - pad_w;
const float* imgptr = data_inp0 + (cn0*height + in_i)*width + in_j;
ofs += delta;
// do im2row for a part of input tensor
if( is1x1 )
if (isConv2D)
{
for( ofs = ofs0; ofs < ofs1; out_j = 0, ++out_i )
{
for( ; out_j < out_j1; out_j++, rowbuf += vsz_a, imgptr += stride_w )
int delta = std::min(ofs1 - ofs, outW - out_j);
int out_j1 = out_j + delta;
int in_i = out_i * stride_h - pad_t;
int in_j = out_j * stride_w - pad_l;
const float* imgptr = data_inp0 + (cn0*height + in_i)*width + in_j;
ofs += delta;
// do im2row for a part of input tensor
if( is1x1 )
{
for( k = 0; k < vsz; k++ )
rowbuf[k] = imgptr[k*inpPlaneSize];
for( ; out_j < out_j1; out_j++, rowbuf += vsz_a, imgptr += stride_w )
{
for( k = 0; k < vsz; k++ )
rowbuf[k] = imgptr[k*inpPlaneSize];
}
}
else
{
bool ok_i = 0 <= in_i && in_i < height - (kernel_h-1)*dilation_h;
int i0 = std::max(0, (-in_i + dilation_h-1)/dilation_h);
int i1 = std::min(kernel_h, (height - in_i + dilation_h-1)/dilation_h);
for( ; out_j < out_j1; out_j++, rowbuf += vsz_a, imgptr += stride_w, in_j += stride_w )
{
// this condition should be true for most of the tensor elements, i.e.
// most of the time the kernel aperture is inside the tensor X-Y plane.
if( ok_i && out_j + 2 <= out_j1 && 0 <= in_j && in_j + stride_w*2 <= width - (kernel_w-1)*dilation_w )
{
for( k = 0; k < vsz; k++ )
{
int k1 = ofstab[k];
float v0 = imgptr[k1];
float v1 = imgptr[k1 + stride_w];
rowbuf[k] = v0;
rowbuf[k+vsz_a] = v1;
}
out_j++;
rowbuf += vsz_a;
imgptr += stride_w;
in_j += stride_w;
}
else
{
int j0 = std::max(0, (-in_j + dilation_w-1)/dilation_w);
int j1 = std::min(kernel_w, (width - in_j + dilation_w-1)/dilation_w);
// here some non-continuous sub-row of the row will not be
// filled from the tensor; we need to make sure that the uncovered
// elements are explicitly set to 0's. the easiest way is to
// set all the elements to 0's before the loop.
memset(rowbuf, 0, vsz*sizeof(rowbuf[0]));
for( k = 0; k < ncn; k++ )
{
for( i = i0; i < i1; i++ )
{
for( j = j0; j < j1; j++ )
{
int imgofs = k*(width*height) + i*(dilation_h*width) + j*dilation_w;
rowbuf[(k*kernel_h + i)*kernel_w + j] = imgptr[imgofs];
}
}
}
}
}
}
}
else
}
else
{
for( ofs = ofs0; ofs < ofs1; out_d += (out_i + 1) / outH, out_i = (out_i + 1) % outH, out_j = 0 )
{
bool ok_i = 0 <= in_i && in_i < height - (kernel_h-1)*dilation_h;
int delta = std::min(ofs1 - ofs, outW - out_j);
int out_j1 = out_j + delta;
int in_d = out_d * stride_d - pad_d;
int in_i = out_i * stride_h - pad_t;
int in_j = out_j * stride_w - pad_l;
const float* imgptr = data_inp0 + (cn0*depth*height + in_d*height + in_i)*width + in_j;
ofs += delta;
int d0 = std::max(0, (-in_d + dilation_d - 1) / dilation_d);
int d1 = std::min(kernel_d, (depth - in_d + dilation_d - 1) / dilation_d);
int i0 = std::max(0, (-in_i + dilation_h-1)/dilation_h);
int i1 = std::min(kernel_h, (height - in_i + dilation_h-1)/dilation_h);
for( ; out_j < out_j1; out_j++, rowbuf += vsz_a, imgptr += stride_w, in_j += stride_w )
{
// this condition should be true for most of the tensor elements, i.e.
// most of the time the kernel aperture is inside the tensor X-Y plane.
if( ok_i && out_j + 2 <= out_j1 && 0 <= in_j && in_j + stride_w*2 <= width - (kernel_w-1)*dilation_w )
{
for( k = 0; k < vsz; k++ )
{
int k1 = ofstab[k];
float v0 = imgptr[k1];
float v1 = imgptr[k1 + stride_w];
rowbuf[k] = v0;
rowbuf[k+vsz_a] = v1;
}
out_j++;
rowbuf += vsz_a;
imgptr += stride_w;
in_j += stride_w;
}
else
{
int j0 = std::max(0, (-in_j + dilation_w-1)/dilation_w);
int j1 = std::min(kernel_w, (width - in_j + dilation_w-1)/dilation_w);
int j0 = std::max(0, (-in_j + dilation_w-1)/dilation_w);
int j1 = std::min(kernel_w, (width - in_j + dilation_w-1)/dilation_w);
// here some non-continuous sub-row of the row will not be
// filled from the tensor; we need to make sure that the uncovered
// elements are explicitly set to 0's. the easiest way is to
// set all the elements to 0's before the loop.
memset(rowbuf, 0, vsz*sizeof(rowbuf[0]));
for( k = 0; k < ncn; k++ )
// here some non-continuous sub-row of the row will not be
// filled from the tensor; we need to make sure that the uncovered
// elements are explicitly set to 0's. the easiest way is to
// set all the elements to 0's before the loop.
memset(rowbuf, 0, vsz*sizeof(rowbuf[0]));
for( k = 0; k < ncn; k++ )
{
for ( d = d0; d < d1; d++)
{
for( i = i0; i < i1; i++ )
{
for( j = j0; j < j1; j++ )
{
int imgofs = k*(width*height) + i*(dilation_h*width) + j*dilation_w;
rowbuf[(k*kernel_h + i)*kernel_w + j] = imgptr[imgofs];
int imgofs = k*(depth*width*height) + d*dilation_d*width*height + i*(dilation_h*width) + j*dilation_w;
rowbuf[(k*kernel_d*kernel_h + d*kernel_h + i)*kernel_w + j] = imgptr[imgofs];
}
}
}
@@ -1131,10 +1246,6 @@ public:
CV_Assert_N(inputs.size() == (size_t)1, inputs[0].size[1] % blobs[0].size[1] == 0,
outputs.size() == 1, inputs[0].data != outputs[0].data);
if (inputs[0].dims == 5) {
CV_Error(Error::StsNotImplemented, "Convolution3D layer is not supported on OCV backend");
}
int ngroups = inputs[0].size[1]/blobs[0].size[1];
CV_Assert(outputs[0].size[1] % ngroups == 0);
int outCn = blobs[0].size[0];
@@ -1163,7 +1274,7 @@ public:
int nstripes = std::max(getNumThreads(), 1);
ParallelConv::run(inputs[0], outputs[0], weightsMat, biasvec, reluslope,
kernel, pad, stride, dilation, activ.get(), ngroups, nstripes);
kernel_size, strides, pads_begin, pads_end, dilations, activ.get(), ngroups, nstripes);
}
virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
@@ -1172,9 +1283,10 @@ public:
CV_Assert(inputs.size() == outputs.size());
int64 flops = 0;
int karea = std::accumulate(kernel_size.begin(), kernel_size.end(), 1, std::multiplies<size_t>());
for (int i = 0; i < inputs.size(); i++)
{
flops += total(outputs[i])*(CV_BIG_INT(2)*kernel.area()*inputs[i][1] + 1);
flops += total(outputs[i])*(CV_BIG_INT(2)*karea*inputs[i][1] + 1);
}
return flops;
@@ -1205,29 +1317,39 @@ public:
virtual bool supportBackend(int backendId) CV_OVERRIDE
{
#ifdef HAVE_INF_ENGINE
const int outGroupCn = blobs[0].size[1]; // Weights are in IOHW layout
const int outGroupCn = blobs[0].size[1]; // Weights are in IOHW or IODHW layout
const int group = numOutput / outGroupCn;
if (backendId == DNN_BACKEND_INFERENCE_ENGINE)
{
if (kernel_size.size() == 3)
CV_Error(Error::StsNotImplemented, "Unsupported deconvolution3D layer");
if (kernel_size.size() == 3 && preferableTarget != DNN_TARGET_CPU) {
return false;
}
if (adjustPad.height || adjustPad.width)
if (std::accumulate(adjust_pads.begin(), adjust_pads.end(), 0, std::plus<size_t>()) > 0)
{
if (padMode.empty())
{
if (preferableTarget != DNN_TARGET_CPU && group != 1)
{
if ((adjustPad.height && pad.height) || (adjustPad.width && pad.width))
for (int i = 0; i < adjust_pads.size(); i++) {
if (adjust_pads[i] && pads_begin[i])
return false;
}
}
for (int i = 0; i < adjust_pads.size(); i++) {
if (pads_end[i] < adjust_pads[i])
return false;
}
return pad.width >= adjustPad.width && pad.height >= adjustPad.height;
return true;
}
else if (padMode == "SAME")
{
return kernel.width >= pad.width + 1 + adjustPad.width &&
kernel.height >= pad.height + 1 + adjustPad.height;
for (int i = 0; i < adjust_pads.size(); i++) {
if (kernel_size[i] < pads_begin[i] + 1 + adjust_pads[i])
return false;
}
return true;
}
else if (padMode == "VALID")
return false;
@@ -1238,7 +1360,7 @@ public:
return preferableTarget == DNN_TARGET_CPU;
}
if (preferableTarget == DNN_TARGET_OPENCL || preferableTarget == DNN_TARGET_OPENCL_FP16)
return dilation.width == 1 && dilation.height == 1;
return std::accumulate(dilations.begin(), dilations.end(), 1, std::multiplies<size_t>()) == 1;
return true;
}
else
@@ -1825,11 +1947,14 @@ public:
#ifdef HAVE_INF_ENGINE
virtual Ptr<BackendNode> initInfEngine(const std::vector<Ptr<BackendWrapper> > &) CV_OVERRIDE
{
auto ieWeights = wrapToInfEngineBlob(blobs[0], InferenceEngine::Layout::OIHW);
InferenceEngine::Layout layout = blobs[0].dims == 5? InferenceEngine::Layout::NCDHW :
InferenceEngine::Layout::OIHW;
auto ieWeights = wrapToInfEngineBlob(blobs[0], layout);
if (fusedWeights)
{
ieWeights = InferenceEngine::make_shared_blob<float>(
InferenceEngine::Precision::FP32, InferenceEngine::Layout::OIHW,
InferenceEngine::Precision::FP32, layout,
ieWeights->dims());
ieWeights->allocate();
@@ -1838,7 +1963,7 @@ public:
transpose(weightsMat, newWeights);
}
const int outGroupCn = blobs[0].size[1]; // Weights are in IOHW layout
const int outGroupCn = blobs[0].size[1]; // Weights are in IOHW or OIDHW layout
const int group = numOutput / outGroupCn;
InferenceEngine::Builder::DeconvolutionLayer ieLayer(name);
@@ -1850,12 +1975,19 @@ public:
if (padMode.empty())
{
ieLayer.setPaddingsEnd({pads_end[0] - adjust_pads[0], pads_end[1] - adjust_pads[1]});
std::vector<size_t> paddings_end;
for (int i = 0; i < pads_end.size(); i++) {
paddings_end.push_back(pads_end[i] - adjust_pads[i]);
}
ieLayer.setPaddingsEnd(paddings_end);
}
else if (padMode == "SAME")
{
ieLayer.setPaddingsEnd({kernel_size[0] - pads_begin[0] - 1 - adjust_pads[0],
kernel_size[1] - pads_begin[1] - 1 - adjust_pads[1]});
std::vector<size_t> paddings_end;
for (int i = 0; i < pads_begin.size(); i++) {
paddings_end.push_back(kernel_size[i] - pads_begin[i] - 1 - adjust_pads[i]);
}
ieLayer.setPaddingsEnd(paddings_end);
}
ieLayer.setGroup((size_t)group);
ieLayer.setOutDepth((size_t)numOutput);
@@ -1875,10 +2007,12 @@ public:
float flops = 0;
int outChannels = blobs[0].size[0];
size_t karea = std::accumulate(kernel_size.begin(), kernel_size.end(),
1, std::multiplies<size_t>());
for (int i = 0; i < inputs.size(); i++)
{
flops += CV_BIG_INT(2)*outChannels*kernel.area()*total(inputs[i]);
flops += CV_BIG_INT(2)*outChannels*karea*total(inputs[i]);
}
return flops;
+5 -3
View File
@@ -148,13 +148,12 @@ void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kern
std::vector<size_t>& pads_begin, std::vector<size_t>& pads_end,
std::vector<size_t>& strides, cv::String &padMode)
{
util::getStrideAndPadding(params, pads_begin, pads_end, strides, padMode);
globalPooling = params.has("global_pooling") &&
params.get<bool>("global_pooling");
if (globalPooling)
{
util::getStrideAndPadding(params, pads_begin, pads_end, strides, padMode);
if(params.has("kernel_h") || params.has("kernel_w") || params.has("kernel_size"))
{
CV_Error(cv::Error::StsBadArg, "In global_pooling mode, kernel_size (or kernel_h and kernel_w) cannot be specified");
@@ -171,15 +170,18 @@ void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kern
else
{
util::getKernelSize(params, kernel);
util::getStrideAndPadding(params, pads_begin, pads_end, strides, padMode, kernel.size());
}
}
void getConvolutionKernelParams(const LayerParams &params, std::vector<size_t>& kernel, std::vector<size_t>& pads_begin,
std::vector<size_t>& pads_end, std::vector<size_t>& strides, std::vector<size_t>& dilations, cv::String &padMode)
std::vector<size_t>& pads_end, std::vector<size_t>& strides,
std::vector<size_t>& dilations, cv::String &padMode, std::vector<size_t>& adjust_pads)
{
util::getKernelSize(params, kernel);
util::getStrideAndPadding(params, pads_begin, pads_end, strides, padMode, kernel.size());
util::getParameter(params, "dilation", "dilation", dilations, true, std::vector<size_t>(kernel.size(), 1));
util::getParameter(params, "adj", "adj", adjust_pads, true, std::vector<size_t>(kernel.size(), 0));
for (int i = 0; i < dilations.size(); i++)
CV_Assert(dilations[i] > 0);
+2 -1
View File
@@ -60,7 +60,8 @@ namespace cv
namespace dnn
{
void getConvolutionKernelParams(const LayerParams &params, std::vector<size_t>& kernel, std::vector<size_t>& pads_begin,
std::vector<size_t>& pads_end, std::vector<size_t>& strides, std::vector<size_t>& dilations, cv::String &padMode);
std::vector<size_t>& pads_end, std::vector<size_t>& strides, std::vector<size_t>& dilations,
cv::String &padMode, std::vector<size_t>& adjust_pads);
void getPoolingKernelParams(const LayerParams &params, std::vector<size_t>& kernel, bool &globalPooling,
std::vector<size_t>& pads_begin, std::vector<size_t>& pads_end, std::vector<size_t>& strides, cv::String &padMode);
+124 -60
View File
@@ -48,6 +48,7 @@
#include "../op_vkcom.hpp"
#include <float.h>
#include <algorithm>
#include <numeric>
using std::max;
using std::min;
@@ -179,13 +180,16 @@ public:
}
else
{
if (!kernel_size.empty() && kernel_size.size() != 2) // TODO Support Pooling3D
if (kernel_size.size() == 3)
return (backendId == DNN_BACKEND_OPENCV && preferableTarget == DNN_TARGET_CPU);
if (kernel_size.empty() || kernel_size.size() == 2)
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));
else
return false;
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));
}
}
@@ -383,19 +387,26 @@ public:
int poolingType;
float spatialScale;
std::vector<size_t> pads_begin, pads_end;
std::vector<size_t> kernel_size;
std::vector<size_t> strides;
PoolingInvoker() : src(0), rois(0), dst(0), mask(0), pad_l(0), pad_t(0), pad_r(0), pad_b(0),
avePoolPaddedArea(false), nstripes(0),
computeMaxIdx(0), poolingType(MAX), spatialScale(0) {}
static void run(const Mat& src, const Mat& rois, Mat& dst, Mat& mask, Size kernel,
Size stride, int pad_l, int pad_t, int pad_r, int pad_b, bool avePoolPaddedArea, int poolingType, float spatialScale,
static void run(const Mat& src, const Mat& rois, Mat& dst, Mat& mask,
std::vector<size_t> kernel_size, std::vector<size_t> strides,
std::vector<size_t> pads_begin, std::vector<size_t> pads_end,
bool avePoolPaddedArea, int poolingType, float spatialScale,
bool computeMaxIdx, int nstripes)
{
CV_Assert_N(
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]),
src.dims == 4 || src.dims == 5, dst.dims == 4 || dst.dims == 5,
(((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)));
@@ -404,13 +415,20 @@ public:
p.src = &src;
p.rois = &rois;
p.dst = &dst;
p.kernel_size = kernel_size;
p.strides = strides;
p.pads_begin = pads_begin;
p.pads_end = pads_end;
p.mask = &mask;
p.kernel = kernel;
p.stride = stride;
p.pad_l = pad_l;
p.pad_t = pad_t;
p.pad_r = pad_r;
p.pad_b = pad_b;
p.kernel = Size(kernel_size[1], kernel_size[0]);
p.stride = Size(strides[1], strides[0]);
p.pad_l = pads_begin.back();
p.pad_t = pads_begin[pads_begin.size() - 2];
p.pad_r = pads_end.back();
p.pad_b = pads_end[pads_end.size() - 2];
p.avePoolPaddedArea = avePoolPaddedArea;
p.nstripes = nstripes;
p.computeMaxIdx = computeMaxIdx;
@@ -419,10 +437,21 @@ public:
if( !computeMaxIdx )
{
p.ofsbuf.resize(kernel.width*kernel.height);
for( int i = 0; i < kernel.height; i++ )
for( int j = 0; j < kernel.width; j++ )
p.ofsbuf[i*kernel.width + j] = src.size[3]*i + j;
int height = src.size[src.dims - 2];
int width = src.size[src.dims - 1];
int kernel_d = (kernel_size.size() == 3) ? kernel_size[0] : 1;
int kernel_h = kernel_size[kernel_size.size() - 2];
int kernel_w = kernel_size.back();
p.ofsbuf.resize(kernel_d * kernel_h * kernel_w);
for (int i = 0; i < kernel_d; ++i) {
for (int j = 0; j < kernel_h; ++j) {
for (int k = 0; k < kernel_w; ++k) {
p.ofsbuf[i * kernel_h * kernel_w + j * kernel_w + k] = width * height * i + width * j + k;
}
}
}
}
parallel_for_(Range(0, nstripes), p, nstripes);
@@ -430,14 +459,29 @@ public:
void operator()(const Range& r) const CV_OVERRIDE
{
int channels = dst->size[1], width = dst->size[3], height = dst->size[2];
int inp_width = src->size[3], inp_height = src->size[2];
int channels = dst->size[1];
bool isPool2D = src->dims == 4;
int depth = !isPool2D? dst->size[2] : 1;
int height = dst->size[dst->dims - 2];
int width = dst->size[dst->dims - 1];
int inp_depth = !isPool2D? src->size[2] : 1;
int inp_height = src->size[src->dims - 2];
int inp_width = src->size[src->dims - 1];
size_t total = dst->total();
size_t stripeSize = (total + nstripes - 1)/nstripes;
size_t stripeStart = r.start*stripeSize;
size_t stripeEnd = std::min(r.end*stripeSize, total);
int kernel_w = kernel.width, kernel_h = kernel.height;
int stride_w = stride.width, stride_h = stride.height;
int kernel_d = !isPool2D? kernel_size[0] : 1;
int kernel_h = kernel_size[kernel_size.size() - 2];
int kernel_w = kernel_size.back();
int stride_d = !isPool2D? strides[0] : 0;
int stride_h = strides[strides.size() - 2];
int stride_w = strides.back();
bool compMaxIdx = computeMaxIdx;
#if CV_SIMD128
@@ -456,9 +500,14 @@ public:
ofs /= width;
int y0 = (int)(ofs % height);
ofs /= height;
int d0 = (int)(ofs % depth);
ofs /= depth;
int c = (int)(ofs % channels);
int n = (int)(ofs / channels);
int ystart, yend;
int dstart = 0, dend = 1;
const float *srcData = 0;
if (poolingType == ROI)
@@ -488,15 +537,22 @@ public:
}
else
{
int pad_d_begin = (pads_begin.size() == 3) ? pads_begin[0] : 0;
dstart = d0 * stride_d - pad_d_begin;
dend = min(dstart + kernel_d, (int)(inp_depth + pads_end[0]));
ystart = y0 * stride_h - pad_t;
yend = min(ystart + kernel_h, inp_height + pad_b);
srcData = src->ptr<float>(n, c);
}
int ddelta = dend - dstart;
dstart = max(dstart, 0);
dend = min(dend, inp_depth);
int ydelta = yend - ystart;
ystart = max(ystart, 0);
yend = min(yend, inp_height);
float *dstData = dst->ptr<float>(n, c, y0);
float *dstMaskData = mask->data ? mask->ptr<float>(n, c, y0) : 0;
float *dstData = &dst->ptr<float>(n, c, d0)[y0 * width];
float *dstMaskData = mask->data ? &mask->ptr<float>(n, c, d0)[y0 * width] : 0;
int delta = std::min((int)(stripeEnd - ofs0), width - x0);
ofs0 += delta;
@@ -516,7 +572,7 @@ public:
continue;
}
#if CV_SIMD128
if( xstart > 0 && x0 + 7 < x1 && (x0 + 7) * stride_w - pad_l + kernel_w < inp_width )
if( isPool2D && xstart > 0 && x0 + 7 < x1 && (x0 + 7) * stride_w - pad_l + kernel_w < inp_width )
{
if( compMaxIdx )
{
@@ -621,49 +677,51 @@ public:
if( compMaxIdx )
{
int max_index = -1;
for (int y = ystart; y < yend; ++y)
for (int x = xstart; x < xend; ++x)
{
const int index = y * inp_width + x;
float val = srcData[index];
if (val > max_val)
for (int d = dstart; d < dend; ++d)
for (int y = ystart; y < yend; ++y)
for (int x = xstart; x < xend; ++x)
{
max_val = val;
max_index = index;
const int index = d * inp_width * inp_height + y * inp_width + x;
float val = srcData[index];
if (val > max_val)
{
max_val = val;
max_index = index;
}
}
}
dstData[x0] = max_val;
if (dstMaskData)
dstMaskData[x0] = max_index;
}
else
{
for (int y = ystart; y < yend; ++y)
for (int x = xstart; x < xend; ++x)
{
const int index = y * inp_width + x;
float val = srcData[index];
max_val = std::max(max_val, val);
for (int d = dstart; d < dend; ++d) {
for (int y = ystart; y < yend; ++y) {
for (int x = xstart; x < xend; ++x) {
const int index = d * inp_width * inp_height + y * inp_width + x;
float val = srcData[index];
max_val = std::max(max_val, val);
}
}
}
dstData[x0] = max_val;
}
}
}
else if (poolingType == AVE)
{
for( ; x0 < x1; x0++ )
for( ; x0 < x1; ++x0)
{
int xstart = x0 * stride_w - pad_l;
int xend = min(xstart + kernel_w, inp_width + pad_r);
int xdelta = xend - xstart;
xstart = max(xstart, 0);
xend = min(xend, inp_width);
float inv_kernel_area = avePoolPaddedArea ? xdelta * ydelta : ((yend - ystart) * (xend - xstart));
float inv_kernel_area = avePoolPaddedArea ? xdelta * ydelta * ddelta :
((dend - dstart) * (yend - ystart) * (xend - xstart));
inv_kernel_area = 1.0 / inv_kernel_area;
#if CV_SIMD128
if( xstart > 0 && x0 + 7 < x1 && (x0 + 7) * stride_w - pad_l + kernel_w < inp_width )
if( isPool2D && xstart > 0 && x0 + 7 < x1 && (x0 + 7) * stride_w - pad_l + kernel_w < inp_width )
{
v_float32x4 sum_val0 = v_setzero_f32(), sum_val1 = v_setzero_f32();
v_float32x4 ikarea = v_setall_f32(inv_kernel_area);
@@ -689,14 +747,15 @@ public:
#endif
{
float sum_val = 0.f;
for (int y = ystart; y < yend; ++y)
for (int x = xstart; x < xend; ++x)
{
const int index = y * inp_width + x;
float val = srcData[index];
sum_val += val;
for (int d = dstart; d < dend; ++d) {
for (int y = ystart; y < yend; ++y) {
for (int x = xstart; x < xend; ++x) {
const int index = d * inp_width * inp_height + y * inp_width + x;
float val = srcData[index];
sum_val += val;
}
}
}
dstData[x0] = sum_val*inv_kernel_area;
}
}
@@ -772,21 +831,25 @@ public:
{
const int nstripes = getNumThreads();
Mat rois;
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad_l, pad_t, pad_r, pad_b, avePoolPaddedArea, type, spatialScale, computeMaxIdx, nstripes);
PoolingInvoker::run(src, rois, dst, mask, kernel_size, strides, pads_begin, pads_end, avePoolPaddedArea, type, spatialScale, computeMaxIdx, nstripes);
}
void avePooling(Mat &src, Mat &dst)
{
const int nstripes = getNumThreads();
Mat rois, mask;
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad_l, pad_t, pad_r, pad_b, avePoolPaddedArea, type, spatialScale, computeMaxIdx, nstripes);
PoolingInvoker::run(src, rois, dst, mask, kernel_size, strides, pads_begin, pads_end, avePoolPaddedArea, type, spatialScale, computeMaxIdx, nstripes);
}
void roiPooling(const Mat &src, const Mat &rois, Mat &dst)
{
const int nstripes = getNumThreads();
Mat mask;
PoolingInvoker::run(src, rois, dst, mask, kernel, stride, pad_l, pad_t, pad_r, pad_b, avePoolPaddedArea, type, spatialScale, computeMaxIdx, nstripes);
kernel_size.resize(2);
strides.resize(2);
pads_begin.resize(2);
pads_end.resize(2);
PoolingInvoker::run(src, rois, dst, mask, kernel_size, strides, pads_begin, pads_end, avePoolPaddedArea, type, spatialScale, computeMaxIdx, nstripes);
}
virtual Ptr<BackendNode> initMaxPoolingHalide(const std::vector<Ptr<BackendWrapper> > &inputs)
@@ -974,17 +1037,18 @@ public:
{
CV_UNUSED(inputs); // suppress unused variable warning
long flops = 0;
size_t karea = std::accumulate(kernel_size.begin(), kernel_size.end(),
1, std::multiplies<size_t>());
for(int i = 0; i < outputs.size(); i++)
{
if (type == MAX)
{
if (i%2 == 0)
flops += total(outputs[i])*kernel.area();
flops += total(outputs[i])*karea;
}
else
{
flops += total(outputs[i])*(kernel.area() + 1);
flops += total(outputs[i])*(karea + 1);
}
}
return flops;
+5 -3
View File
@@ -61,6 +61,7 @@ public:
{
setParamsFrom(params);
axis = params.get<int>("axis", 1);
num_split = params.get<int>("num_split", 0);
if (params.has("slice_point"))
{
CV_Assert(!params.has("begin") && !params.has("size") && !params.has("end"));
@@ -141,9 +142,10 @@ public:
else // Divide input blob on equal parts by axis.
{
CV_Assert(0 <= axis && axis < inpShape.size());
CV_Assert(requiredOutputs > 0 && inpShape[axis] % requiredOutputs == 0);
inpShape[axis] /= requiredOutputs;
outputs.resize(requiredOutputs, inpShape);
int splits = num_split ? num_split : requiredOutputs;
CV_Assert(splits > 0 && inpShape[axis] % splits == 0);
inpShape[axis] /= splits;
outputs.resize(splits, inpShape);
}
return false;
}
+89 -33
View File
@@ -397,11 +397,33 @@ void ONNXImporter::populateNet(Net dstNet)
layerParams.set("ceil_mode", layerParams.has("pad_mode"));
layerParams.set("ave_pool_padded_area", framework_name == "pytorch");
}
else if (layer_type == "GlobalAveragePool" || layer_type == "GlobalMaxPool")
else if (layer_type == "GlobalAveragePool" || layer_type == "GlobalMaxPool" || layer_type == "ReduceMean")
{
CV_Assert(node_proto.input_size() == 1);
layerParams.type = "Pooling";
layerParams.set("pool", layer_type == "GlobalAveragePool" ? "AVE" : "MAX");
layerParams.set("global_pooling", true);
layerParams.set("pool", layer_type == "GlobalMaxPool"? "MAX" : "AVE");
layerParams.set("global_pooling", layer_type == "GlobalAveragePool" || layer_type == "GlobalMaxPool");
if (layer_type == "ReduceMean")
{
if (layerParams.get<int>("keepdims") == 0 || !layerParams.has("axes"))
CV_Error(Error::StsNotImplemented, "Unsupported mode of ReduceMean operation.");
MatShape inpShape = outShapes[node_proto.input(0)];
if (inpShape.size() != 4 && inpShape.size() != 5)
CV_Error(Error::StsNotImplemented, "Unsupported input shape of reduce_mean operation.");
DictValue axes = layerParams.get("axes");
CV_Assert(axes.size() <= inpShape.size() - 2);
std::vector<int> kernel_size(inpShape.size() - 2, 1);
for (int i = 0; i < axes.size(); i++) {
int axis = axes.get<int>(i);
CV_Assert_N(axis >= 2 + i, axis < inpShape.size());
kernel_size[axis - 2] = inpShape[axis];
}
layerParams.set("kernel_size", DictValue::arrayInt(&kernel_size[0], kernel_size.size()));
}
}
else if (layer_type == "Slice")
{
@@ -546,6 +568,43 @@ void ONNXImporter::populateNet(Net dstNet)
{
replaceLayerParam(layerParams, "size", "local_size");
}
else if (layer_type == "InstanceNormalization")
{
if (node_proto.input_size() != 3)
CV_Error(Error::StsNotImplemented,
"Expected input, scale, bias");
layerParams.blobs.resize(4);
layerParams.blobs[2] = getBlob(node_proto, constBlobs, 1); // weightData
layerParams.blobs[3] = getBlob(node_proto, constBlobs, 2); // biasData
layerParams.set("has_bias", true);
layerParams.set("has_weight", true);
// Get number of channels in input
int size = layerParams.blobs[2].total();
layerParams.blobs[0] = Mat::zeros(size, 1, CV_32F); // mean
layerParams.blobs[1] = Mat::ones(size, 1, CV_32F); // std
LayerParams mvnParams;
mvnParams.name = layerParams.name + "/MVN";
mvnParams.type = "MVN";
mvnParams.set("eps", layerParams.get<float>("epsilon"));
layerParams.erase("epsilon");
//Create MVN layer
int id = dstNet.addLayer(mvnParams.name, mvnParams.type, mvnParams);
//Connect to input
layerId = layer_id.find(node_proto.input(0));
CV_Assert(layerId != layer_id.end());
dstNet.connect(layerId->second.layerId, layerId->second.outputId, id, 0);
//Add shape
layer_id.insert(std::make_pair(mvnParams.name, LayerInfo(id, 0)));
outShapes[mvnParams.name] = outShapes[node_proto.input(0)];
//Replace Batch Norm's input to MVN
node_proto.set_input(0, mvnParams.name);
layerParams.type = "BatchNorm";
}
else if (layer_type == "BatchNormalization")
{
if (node_proto.input_size() != 5)
@@ -645,42 +704,37 @@ void ONNXImporter::populateNet(Net dstNet)
layerParams.set("num_output", layerParams.blobs[0].size[1] * layerParams.get<int>("group", 1));
layerParams.set("bias_term", node_proto.input_size() == 3);
if (!layerParams.has("kernel_size"))
CV_Error(Error::StsNotImplemented,
"Required attribute 'kernel_size' is not present.");
if (layerParams.has("output_shape"))
{
const DictValue& outShape = layerParams.get("output_shape");
DictValue strides = layerParams.get("stride");
DictValue kernel = layerParams.get("kernel_size");
if (outShape.size() != 4)
CV_Error(Error::StsNotImplemented, "Output shape must have 4 elements.");
DictValue stride = layerParams.get("stride");
const int strideY = stride.getIntValue(0);
const int strideX = stride.getIntValue(1);
const int outH = outShape.getIntValue(2);
const int outW = outShape.getIntValue(3);
if (layerParams.get<String>("pad_mode") == "SAME")
String padMode;
std::vector<int> adjust_pads;
if (layerParams.has("pad_mode"))
{
layerParams.set("adj_w", (outW - 1) % strideX);
layerParams.set("adj_h", (outH - 1) % strideY);
}
else if (layerParams.get<String>("pad_mode") == "VALID")
{
if (!layerParams.has("kernel_size"))
CV_Error(Error::StsNotImplemented,
"Required attribute 'kernel_size' is not present.");
padMode = toUpperCase(layerParams.get<String>("pad_mode"));
if (padMode != "SAME" && padMode != "VALID")
CV_Error(Error::StsError, "Unsupported padding mode " + padMode);
DictValue kernel = layerParams.get("kernel_size");
layerParams.set("adj_h", (outH - kernel.getIntValue(0)) % strideY);
layerParams.set("adj_w", (outW - kernel.getIntValue(1)) % strideX);
for (int i = 0; i < strides.size(); i++)
{
int sz = outShape.get<int>(2 + i);
int stride = strides.get<int>(i);
adjust_pads.push_back(padMode == "SAME"? (sz - 1) % stride :
(sz - kernel.get<int>(i)) % stride);
}
layerParams.set("adj", DictValue::arrayInt(&adjust_pads[0], adjust_pads.size()));
}
}
else if (layerParams.has("output_padding"))
{
const DictValue& adj_pad = layerParams.get("output_padding");
if (adj_pad.size() != 2)
CV_Error(Error::StsNotImplemented, "Deconvolution3D layer is not supported");
layerParams.set("adj_w", adj_pad.get<int>(1));
layerParams.set("adj_h", adj_pad.get<int>(0));
replaceLayerParam(layerParams, "output_padding", "adj");
}
}
else if (layer_type == "Transpose")
@@ -715,11 +769,13 @@ void ONNXImporter::populateNet(Net dstNet)
if (axes.size() != 1)
CV_Error(Error::StsNotImplemented, "Multidimensional unsqueeze");
int dims[] = {1, -1};
MatShape inpShape = outShapes[node_proto.input(0)];
int axis = axes.getIntValue(0);
CV_Assert(0 <= axis && axis <= inpShape.size());
std::vector<int> outShape = inpShape;
outShape.insert(outShape.begin() + axis, 1);
layerParams.type = "Reshape";
layerParams.set("axis", axes.getIntValue(0));
layerParams.set("num_axes", 1);
layerParams.set("dim", DictValue::arrayInt(&dims[0], 2));
layerParams.set("dim", DictValue::arrayInt(&outShape[0], outShape.size()));
}
else if (layer_type == "Reshape")
{
@@ -1410,6 +1410,9 @@ void TFImporter::populateNet(Net dstNet)
axis = toNCHW(axis);
layerParams.set("axis", axis);
if (hasLayerAttr(layer, "num_split"))
layerParams.set("num_split", getLayerAttr(layer, "num_split").i());
int id = dstNet.addLayer(name, "Slice", layerParams);
layer_id[name] = id;
+19
View File
@@ -205,6 +205,11 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow)
applyTestTag(target == DNN_TARGET_CPU ? "" : CV_TEST_TAG_MEMORY_512MB);
if (backend == DNN_BACKEND_HALIDE)
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE);
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
#endif
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.095 : 0.0;
@@ -224,6 +229,11 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v1_TensorFlow_Different_Width_Height)
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X);
#endif
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
#endif
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 560), Scalar(), false);
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.012 : 0.0;
@@ -238,6 +248,11 @@ TEST_P(DNNTestNetwork, MobileNet_SSD_v2_TensorFlow)
applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
if (backend == DNN_BACKEND_HALIDE)
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE);
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
#endif
Mat sample = imread(findDataFile("dnn/street.png"));
Mat inp = blobFromImage(sample, 1.0f, Size(300, 300), Scalar(), false);
float l1 = (target == DNN_TARGET_OPENCL_FP16 || target == DNN_TARGET_MYRIAD) ? 0.013 : 2e-5;
@@ -355,6 +370,10 @@ TEST_P(DNNTestNetwork, Inception_v2_SSD_TensorFlow)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X);
#endif
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
#endif
if (backend == DNN_BACKEND_HALIDE)
applyTestTag(CV_TEST_TAG_DNN_SKIP_HALIDE);
+24 -1
View File
@@ -561,7 +561,7 @@ TEST(Test_Caffe, shared_weights)
typedef testing::TestWithParam<tuple<std::string, Target> > opencv_face_detector;
TEST_P(opencv_face_detector, Accuracy)
{
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt", false);
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt");
std::string model = findDataFile(get<0>(GetParam()), false);
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
@@ -584,6 +584,29 @@ TEST_P(opencv_face_detector, Accuracy)
0, 1, 0.95097077, 0.51901293, 0.45863652, 0.5777427, 0.5347801);
normAssertDetections(ref, out, "", 0.5, 1e-5, 2e-4);
}
// False positives bug for large faces: https://github.com/opencv/opencv/issues/15106
TEST_P(opencv_face_detector, issue_15106)
{
std::string proto = findDataFile("dnn/opencv_face_detector.prototxt");
std::string model = findDataFile(get<0>(GetParam()), false);
dnn::Target targetId = (dnn::Target)(int)get<1>(GetParam());
Net net = readNetFromCaffe(proto, model);
Mat img = imread(findDataFile("cv/shared/lena.png"));
img = img.rowRange(img.rows / 4, 3 * img.rows / 4).colRange(img.cols / 4, 3 * img.cols / 4);
Mat blob = blobFromImage(img, 1.0, Size(300, 300), Scalar(104.0, 177.0, 123.0), false, false);
net.setPreferableBackend(DNN_BACKEND_OPENCV);
net.setPreferableTarget(targetId);
net.setInput(blob);
// Output has shape 1x1xNx7 where N - number of detections.
// An every detection is a vector of values [id, classId, confidence, left, top, right, bottom]
Mat out = net.forward();
Mat ref = (Mat_<float>(1, 7) << 0, 1, 0.9149431, 0.30424616, 0.26964942, 0.88733053, 0.99815309);
normAssertDetections(ref, out, "", 0.2, 6e-5, 1e-4);
}
INSTANTIATE_TEST_CASE_P(Test_Caffe, opencv_face_detector,
Combine(
Values("dnn/opencv_face_detector.caffemodel",
+1
View File
@@ -18,6 +18,7 @@
#define CV_TEST_TAG_DNN_SKIP_IE_2018R5 "dnn_skip_ie_2018r5"
#define CV_TEST_TAG_DNN_SKIP_IE_2019R1 "dnn_skip_ie_2019r1"
#define CV_TEST_TAG_DNN_SKIP_IE_2019R1_1 "dnn_skip_ie_2019r1_1"
#define CV_TEST_TAG_DNN_SKIP_IE_2019R2 "dnn_skip_ie_2019r2"
#define CV_TEST_TAG_DNN_SKIP_IE_OPENCL "dnn_skip_ie_ocl"
#define CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16 "dnn_skip_ie_ocl_fp16"
#define CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_2 "dnn_skip_ie_myriad2"
+5 -2
View File
@@ -319,8 +319,11 @@ void initDNNTests()
CV_TEST_TAG_DNN_SKIP_IE_2018R5,
#elif INF_ENGINE_VER_MAJOR_EQ(2019010000)
CV_TEST_TAG_DNN_SKIP_IE_2019R1,
#elif INF_ENGINE_VER_MAJOR_EQ(2019010100)
CV_TEST_TAG_DNN_SKIP_IE_2019R1_1
# if INF_ENGINE_RELEASE == 2019010100
CV_TEST_TAG_DNN_SKIP_IE_2019R1_1,
# endif
#elif INF_ENGINE_VER_MAJOR_EQ(2019020000)
CV_TEST_TAG_DNN_SKIP_IE_2019R2,
#endif
CV_TEST_TAG_DNN_SKIP_IE
);
+22
View File
@@ -9,10 +9,32 @@
#ifdef HAVE_INF_ENGINE
#include <opencv2/core/utils/filesystem.hpp>
//
// Synchronize headers include statements with src/op_inf_engine.hpp
//
//#define INFERENCE_ENGINE_DEPRECATED // turn off deprecation warnings from IE
//there is no way to suppress warnigns from IE only at this moment, so we are forced to suppress warnings globally
#if defined(__GNUC__)
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
#endif
#ifdef _MSC_VER
#pragma warning(disable: 4996) // was declared deprecated
#endif
#if defined(__GNUC__)
#pragma GCC visibility push(default)
#endif
#include <inference_engine.hpp>
#include <ie_icnn_network.hpp>
#include <ie_extension.h>
#if defined(__GNUC__)
#pragma GCC visibility pop
#endif
namespace opencv_test { namespace {
static void initDLDTDataPath()
+20
View File
@@ -78,6 +78,26 @@ TEST(readNet, Regression)
EXPECT_FALSE(net.empty());
}
typedef testing::TestWithParam<tuple<Backend, Target> > dump;
TEST_P(dump, Regression)
{
const int backend = get<0>(GetParam());
const int target = get<1>(GetParam());
Net net = readNet(findDataFile("dnn/squeezenet_v1.1.prototxt"),
findDataFile("dnn/squeezenet_v1.1.caffemodel", false));
int size[] = {1, 3, 227, 227};
Mat input = cv::Mat::ones(4, size, CV_32F);
net.setInput(input);
net.setPreferableBackend(backend);
net.setPreferableTarget(target);
EXPECT_FALSE(net.dump().empty());
net.forward();
EXPECT_FALSE(net.dump().empty());
}
INSTANTIATE_TEST_CASE_P(/**/, dump, dnnBackendsAndTargets());
class FirstCustomLayer CV_FINAL : public Layer
{
public:
+51 -8
View File
@@ -76,6 +76,14 @@ public:
}
};
TEST_P(Test_ONNX_layers, InstanceNorm)
{
if (target == DNN_TARGET_MYRIAD)
testONNXModels("instancenorm", npy, 0, 0, false, false);
else
testONNXModels("instancenorm", npy);
}
TEST_P(Test_ONNX_layers, MaxPooling)
{
testONNXModels("maxpooling");
@@ -92,8 +100,8 @@ TEST_P(Test_ONNX_layers, Convolution3D)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
testONNXModels("conv3d");
testONNXModels("conv3d_bias");
}
@@ -119,6 +127,19 @@ TEST_P(Test_ONNX_layers, Deconvolution)
testONNXModels("deconv_adjpad_2d", npy, 0, 0, false, false);
}
TEST_P(Test_ONNX_layers, Deconvolution3D)
{
#if defined(INF_ENGINE_RELEASE)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_2018R5);
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
testONNXModels("deconv3d");
testONNXModels("deconv3d_bias");
testONNXModels("deconv3d_pad");
testONNXModels("deconv3d_adjpad");
}
TEST_P(Test_ONNX_layers, Dropout)
{
testONNXModels("dropout");
@@ -141,6 +162,18 @@ TEST_P(Test_ONNX_layers, Clip)
testONNXModels("clip", npy);
}
TEST_P(Test_ONNX_layers, ReduceMean)
{
testONNXModels("reduce_mean");
}
TEST_P(Test_ONNX_layers, ReduceMean3D)
{
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
testONNXModels("reduce_mean3d");
}
TEST_P(Test_ONNX_layers, MaxPooling_Sigmoid)
{
testONNXModels("maxpooling_sigmoid");
@@ -177,8 +210,8 @@ TEST_P(Test_ONNX_layers, MaxPooling3D)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
testONNXModels("max_pool3d");
}
@@ -187,11 +220,21 @@ TEST_P(Test_ONNX_layers, AvePooling3D)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
testONNXModels("ave_pool3d");
}
TEST_P(Test_ONNX_layers, PoolConv3D)
{
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
testONNXModels("pool_conv_3d");
}
TEST_P(Test_ONNX_layers, BatchNormalization)
{
testONNXModels("batch_norm");
@@ -571,8 +614,8 @@ TEST_P(Test_ONNX_nets, Resnet34_kinetics)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
String onnxmodel = findDataFile("dnn/resnet-34_kinetics.onnx", false);
Mat image0 = imread(findDataFile("dnn/dog416.png"));
+29 -13
View File
@@ -136,8 +136,8 @@ TEST_P(Test_TensorFlow_layers, Convolution3D)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
runTensorFlowNet("conv3d");
}
@@ -243,8 +243,8 @@ TEST_P(Test_TensorFlow_layers, MaxPooling3D)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
runTensorFlowNet("max_pool3d");
}
@@ -253,8 +253,8 @@ TEST_P(Test_TensorFlow_layers, AvePooling3D)
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_LT(2019010000)
throw SkipTestException("Test is enabled starts from 2019R1");
#endif
if (backend != DNN_BACKEND_INFERENCE_ENGINE || target != DNN_TARGET_CPU)
throw SkipTestException("Only DLIE backend on CPU is supported");
if (target != DNN_TARGET_CPU)
throw SkipTestException("Only CPU is supported");
runTensorFlowNet("ave_pool3d");
}
@@ -357,11 +357,11 @@ TEST_P(Test_TensorFlow_nets, MobileNet_SSD)
#if defined(INF_ENGINE_RELEASE)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
{
#if INF_ENGINE_VER_MAJOR_GE(2019010000)
#if INF_ENGINE_VER_MAJOR_EQ(2019010000)
if (getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X);
#else
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
#endif
}
#endif
@@ -395,12 +395,16 @@ TEST_P(Test_TensorFlow_nets, MobileNet_SSD)
TEST_P(Test_TensorFlow_nets, Inception_v2_SSD)
{
applyTestTag(target == DNN_TARGET_CPU ? CV_TEST_TAG_MEMORY_512MB : CV_TEST_TAG_MEMORY_1GB);
#if defined(INF_ENGINE_RELEASE)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD
&& getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X
)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X);
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
{
#if INF_ENGINE_VER_MAJOR_LE(2019010000)
if (getInferenceEngineVPUType() == CV_DNN_INFERENCE_ENGINE_VPU_TYPE_MYRIAD_X)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_X);
#else
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD);
#endif
}
#endif
checkBackend();
@@ -432,6 +436,11 @@ TEST_P(Test_TensorFlow_nets, Inception_v2_SSD)
TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD)
{
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
#endif
checkBackend();
std::string proto = findDataFile("dnn/ssd_mobilenet_v1_coco_2017_11_17.pbtxt");
std::string model = findDataFile("dnn/ssd_mobilenet_v1_coco_2017_11_17.pb", false);
@@ -506,6 +515,10 @@ TEST_P(Test_TensorFlow_nets, MobileNet_v1_SSD_PPN)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && (target == DNN_TARGET_OPENCL || target == DNN_TARGET_OPENCL_FP16))
applyTestTag(target == DNN_TARGET_OPENCL ? CV_TEST_TAG_DNN_SKIP_IE_OPENCL : CV_TEST_TAG_DNN_SKIP_IE_OPENCL_FP16);
#endif
#if defined(INF_ENGINE_RELEASE) && INF_ENGINE_VER_MAJOR_EQ(2019020000)
if (backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD, CV_TEST_TAG_DNN_SKIP_IE, CV_TEST_TAG_DNN_SKIP_IE_2019R2);
#endif
checkBackend();
std::string proto = findDataFile("dnn/ssd_mobilenet_v1_ppn_coco.pbtxt");
@@ -677,6 +690,9 @@ TEST_P(Test_TensorFlow_layers, lstm)
TEST_P(Test_TensorFlow_layers, split)
{
if (backend == DNN_BACKEND_INFERENCE_ENGINE)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE_MYRIAD_2);
runTensorFlowNet("split");
if (backend == DNN_BACKEND_INFERENCE_ENGINE)
applyTestTag(CV_TEST_TAG_DNN_SKIP_IE);
runTensorFlowNet("split_equals");
@@ -99,12 +99,33 @@ struct GFluidOutputRois
std::vector<cv::gapi::own::Rect> rois;
};
struct GFluidParallelOutputRois
{
std::vector<GFluidOutputRois> parallel_rois;
};
struct GFluidParallelFor
{
std::function<void(std::size_t, std::function<void(std::size_t)>)> parallel_for;
};
namespace detail
{
template<> struct CompileArgTag<GFluidOutputRois>
{
static const char* tag() { return "gapi.fluid.outputRois"; }
};
template<> struct CompileArgTag<GFluidParallelFor>
{
static const char* tag() { return "gapi.fluid.parallelFor"; }
};
template<> struct CompileArgTag<GFluidParallelOutputRois>
{
static const char* tag() { return "gapi.fluid.parallelOutputRois"; }
};
} // namespace detail
namespace detail
+29 -1
View File
@@ -55,6 +55,12 @@ namespace detail
class VectorRef;
using ConstructVec = std::function<void(VectorRef&)>;
// This is the base struct for GArrayU type holder
struct TypeHintBase{virtual ~TypeHintBase() = default;};
// This class holds type of initial GArray to be checked from GArrayU
template <typename T>
struct TypeHint final : public TypeHintBase{};
// This class strips type information from GArray<T> and makes it usable
// in the G-API graph compiler (expression unrolling, graph generation, etc).
@@ -64,6 +70,9 @@ namespace detail
public:
GArrayU(const GNode &n, std::size_t out); // Operation result constructor
template <typename T>
bool holds() const; // Check if was created from GArray<T>
GOrigin& priv(); // Internal use only
const GOrigin& priv() const; // Internal use only
@@ -73,7 +82,23 @@ namespace detail
void setConstructFcn(ConstructVec &&cv); // Store T-aware constructor
template <typename T>
void specifyType(); // Store type of initial GArray<T>
std::shared_ptr<GOrigin> m_priv;
std::shared_ptr<TypeHintBase> m_hint;
};
template <typename T>
bool GArrayU::holds() const{
GAPI_Assert(m_hint != nullptr);
using U = typename std::decay<T>::type;
return dynamic_cast<TypeHint<U>*>(m_hint.get()) != nullptr;
};
template <typename T>
void GArrayU::specifyType(){
m_hint.reset(new TypeHint<typename std::decay<T>::type>);
};
// This class represents a typed STL vector reference.
@@ -239,7 +264,10 @@ public:
private:
static void VCTor(detail::VectorRef& vref) { vref.reset<T>(); }
void putDetails() {m_ref.setConstructFcn(&VCTor); }
void putDetails() {
m_ref.setConstructFcn(&VCTor);
m_ref.specifyType<T>();
}
detail::GArrayU m_ref;
};
@@ -16,13 +16,16 @@
#include <opencv2/gapi/garg.hpp>
#include <opencv2/gapi/gtype_traits.hpp>
#include <opencv2/gapi/util/compiler_hints.hpp>
#include <opencv2/gapi/gcomputation.hpp>
namespace cv
{
struct GAPI_EXPORTS GTransform
{
using F = std::function<GArgs(const GArgs &)>;
// FIXME: consider another simplified
// class instead of GComputation
using F = std::function<GComputation()>;
std::string description;
F pattern;
@@ -41,20 +44,22 @@ template <typename K, typename... Ins, typename Out>
struct TransHelper<K, std::tuple<Ins...>, Out>
{
template <typename Callable, int... IIs, int... OIs>
static GArgs invoke(Callable f, const GArgs &in_args, Seq<IIs...>, Seq<OIs...>)
static GComputation invoke(Callable f, Seq<IIs...>, Seq<OIs...>)
{
const auto r = tuple_wrap_helper<Out>::get(f(in_args.at(IIs).template get<Ins>()...));
return GArgs{GArg(std::get<OIs>(r))...};
const std::tuple<Ins...> ins;
const auto r = tuple_wrap_helper<Out>::get(f(std::get<IIs>(ins)...));
return GComputation(cv::GIn(std::get<IIs>(ins)...),
cv::GOut(std::get<OIs>(r)...));
}
static GArgs get_pattern(const GArgs &in_args)
static GComputation get_pattern()
{
return invoke(K::pattern, in_args, typename MkSeq<sizeof...(Ins)>::type(),
return invoke(K::pattern, typename MkSeq<sizeof...(Ins)>::type(),
typename MkSeq<std::tuple_size<typename tuple_wrap_helper<Out>::type>::value>::type());
}
static GArgs get_substitute(const GArgs &in_args)
static GComputation get_substitute()
{
return invoke(K::substitute, in_args, typename MkSeq<sizeof...(Ins)>::type(),
return invoke(K::substitute, typename MkSeq<sizeof...(Ins)>::type(),
typename MkSeq<std::tuple_size<typename tuple_wrap_helper<Out>::type>::value>::type());
}
};
@@ -11,8 +11,10 @@
# if defined(__OPENCV_BUILD)
# include <opencv2/core/base.hpp>
# define GAPI_EXPORTS CV_EXPORTS
# else
# define GAPI_EXPORTS
#if 0 // Note: the following version currently is not needed for non-OpenCV build
# if defined _WIN32
# define GAPI_EXPORTS __declspec(dllexport)
# elif defined __GNUC__ && __GNUC__ >= 4
@@ -22,6 +24,7 @@
# ifndef GAPI_EXPORTS
# define GAPI_EXPORTS
# endif
#endif
# endif
+1 -1
View File
@@ -103,7 +103,7 @@ void bindInArg(Mag& mag, const RcDesc &rc, const GRunArg &arg, bool is_umat)
auto& mag_umat = mag.template slot<cv::UMat>()[rc.id];
mag_umat = to_ocv(util::get<cv::gapi::own::Mat>(arg)).getUMat(ACCESS_READ);
#else
util::throw_error(std::logic_error("UMat is not supported in stadnalone build"));
util::throw_error(std::logic_error("UMat is not supported in standalone build"));
#endif // !defined(GAPI_STANDALONE)
}
else
+119 -29
View File
@@ -91,7 +91,21 @@ namespace
cv::util::throw_error(std::logic_error("GFluidOutputRois feature supports only one-island graphs"));
auto rois = out_rois.value_or(cv::GFluidOutputRois());
return EPtr{new cv::gimpl::GFluidExecutable(graph, nodes, std::move(rois.rois))};
auto graph_data = fluidExtractInputDataFromGraph(graph, nodes);
const auto parallel_out_rois = cv::gimpl::getCompileArg<cv::GFluidParallelOutputRois>(args);
const auto gpfor = cv::gimpl::getCompileArg<cv::GFluidParallelFor>(args);
auto serial_for = [](std::size_t count, std::function<void(std::size_t)> f){
for (std::size_t i = 0; i < count; ++i){
f(i);
}
};
auto pfor = gpfor.has_value() ? gpfor.value().parallel_for : serial_for;
return parallel_out_rois.has_value() ?
EPtr{new cv::gimpl::GParallelFluidExecutable (graph, graph_data, std::move(parallel_out_rois.value().parallel_rois), pfor)}
: EPtr{new cv::gimpl::GFluidExecutable (graph, graph_data, std::move(rois.rois))}
;
}
virtual void addBackendPasses(ade::ExecutionEngineSetupContext &ectx) override;
@@ -700,27 +714,31 @@ void cv::gimpl::GFluidExecutable::initBufferRois(std::vector<int>& readStarts,
} // while (!nodesToVisit.empty())
}
cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
const std::vector<ade::NodeHandle> &nodes,
const std::vector<cv::gapi::own::Rect> &outputRois)
: m_g(g), m_gm(m_g)
cv::gimpl::FluidGraphInputData cv::gimpl::fluidExtractInputDataFromGraph(const ade::Graph &g, const std::vector<ade::NodeHandle> &nodes)
{
GConstFluidModel fg(m_g);
decltype(FluidGraphInputData::m_agents_data) agents_data;
decltype(FluidGraphInputData::m_scratch_users) scratch_users;
decltype(FluidGraphInputData::m_id_map) id_map;
decltype(FluidGraphInputData::m_all_gmat_ids) all_gmat_ids;
std::size_t mat_count = 0;
GConstFluidModel fg(g);
GModel::ConstGraph m_gm(g);
// Initialize vector of data buffers, build list of operations
// FIXME: There _must_ be a better way to [query] count number of DATA nodes
std::size_t mat_count = 0;
std::size_t last_agent = 0;
auto grab_mat_nh = [&](ade::NodeHandle nh) {
auto rc = m_gm.metadata(nh).get<Data>().rc;
if (m_id_map.count(rc) == 0)
if (id_map.count(rc) == 0)
{
m_all_gmat_ids[mat_count] = nh;
m_id_map[rc] = mat_count++;
all_gmat_ids[mat_count] = nh;
id_map[rc] = mat_count++;
}
};
std::size_t last_agent = 0;
for (const auto &nh : nodes)
{
switch (m_gm.metadata(nh).get<NodeType>().t)
@@ -733,15 +751,10 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
case NodeType::OP:
{
const auto& fu = fg.metadata(nh).get<FluidUnit>();
switch (fu.k.m_kind)
{
case GFluidKernel::Kind::Filter: m_agents.emplace_back(new FluidFilterAgent(m_g, nh)); break;
case GFluidKernel::Kind::Resize: m_agents.emplace_back(new FluidResizeAgent(m_g, nh)); break;
case GFluidKernel::Kind::NV12toRGB: m_agents.emplace_back(new FluidNV12toRGBAgent(m_g, nh)); break;
default: GAPI_Assert(false);
}
agents_data.push_back({fu.k.m_kind, nh, {}, {}});
// NB.: in_buffer_ids size is equal to Arguments size, not Edges size!!!
m_agents.back()->in_buffer_ids.resize(m_gm.metadata(nh).get<Op>().args.size(), -1);
agents_data.back().in_buffer_ids.resize(m_gm.metadata(nh).get<Op>().args.size(), -1);
for (auto eh : nh->inEdges())
{
// FIXME Only GMats are currently supported (which can be represented
@@ -751,23 +764,23 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
const auto in_port = m_gm.metadata(eh).get<Input>().port;
const int in_buf = m_gm.metadata(eh->srcNode()).get<Data>().rc;
m_agents.back()->in_buffer_ids[in_port] = in_buf;
agents_data.back().in_buffer_ids[in_port] = in_buf;
grab_mat_nh(eh->srcNode());
}
}
// FIXME: Assumption that all operation outputs MUST be connected
m_agents.back()->out_buffer_ids.resize(nh->outEdges().size(), -1);
agents_data.back().out_buffer_ids.resize(nh->outEdges().size(), -1);
for (auto eh : nh->outEdges())
{
const auto& data = m_gm.metadata(eh->dstNode()).get<Data>();
const auto out_port = m_gm.metadata(eh).get<Output>().port;
const int out_buf = data.rc;
m_agents.back()->out_buffer_ids[out_port] = out_buf;
agents_data.back().out_buffer_ids[out_port] = out_buf;
if (data.shape == GShape::GMAT) grab_mat_nh(eh->dstNode());
}
if (fu.k.m_scratch)
m_scratch_users.push_back(last_agent);
scratch_users.push_back(last_agent);
last_agent++;
break;
}
@@ -776,12 +789,50 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
}
// Check that IDs form a continiuos set (important for further indexing)
GAPI_Assert(m_id_map.size() > 0);
GAPI_Assert(m_id_map.size() == static_cast<size_t>(mat_count));
GAPI_Assert(id_map.size() > 0);
GAPI_Assert(id_map.size() == static_cast<size_t>(mat_count));
return FluidGraphInputData {std::move(agents_data), std::move(scratch_users), std::move(id_map), std::move(all_gmat_ids), mat_count};
}
cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
const cv::gimpl::FluidGraphInputData &traverse_res,
const std::vector<cv::gapi::own::Rect> &outputRois)
: m_g(g), m_gm(m_g)
{
GConstFluidModel fg(m_g);
auto tie_traverse_res = [&traverse_res](){
auto& r = traverse_res;
return std::tie(r.m_scratch_users, r.m_id_map, r.m_all_gmat_ids, r.m_mat_count);
};
auto tie_this = [this](){
return std::tie(m_scratch_users, m_id_map, m_all_gmat_ids, m_num_int_buffers);
};
tie_this() = tie_traverse_res();
auto create_fluid_agent = [&g](agent_data_t const& agent_data) -> std::unique_ptr<FluidAgent> {
std::unique_ptr<FluidAgent> agent_ptr;
switch (agent_data.kind)
{
case GFluidKernel::Kind::Filter: agent_ptr.reset(new FluidFilterAgent(g, agent_data.nh)); break;
case GFluidKernel::Kind::Resize: agent_ptr.reset(new FluidResizeAgent(g, agent_data.nh)); break;
case GFluidKernel::Kind::NV12toRGB: agent_ptr.reset(new FluidNV12toRGBAgent(g, agent_data.nh)); break;
default: GAPI_Assert(false);
}
std::tie(agent_ptr->in_buffer_ids, agent_ptr->out_buffer_ids) = std::tie(agent_data.in_buffer_ids, agent_data.out_buffer_ids);
return agent_ptr;
};
for (auto const& agent_data : traverse_res.m_agents_data){
m_agents.push_back(create_fluid_agent(agent_data));
}
// Actually initialize Fluid buffers
GAPI_LOG_INFO(NULL, "Initializing " << mat_count << " fluid buffer(s)" << std::endl);
m_num_int_buffers = mat_count;
GAPI_LOG_INFO(NULL, "Initializing " << m_num_int_buffers << " fluid buffer(s)" << std::endl);
const std::size_t num_scratch = m_scratch_users.size();
m_buffers.resize(m_num_int_buffers + num_scratch);
@@ -847,6 +898,12 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
makeReshape(outputRois);
GAPI_LOG_INFO(NULL, "Internal buffers: " << std::fixed << std::setprecision(2) << static_cast<float>(total_buffers_size())/1024 << " KB\n");
}
std::size_t cv::gimpl::GFluidExecutable::total_buffers_size() const
{
GConstFluidModel fg(m_g);
std::size_t total_size = 0;
for (const auto &i : ade::util::indexed(m_buffers))
{
@@ -854,7 +911,7 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
const auto idx = ade::util::index(i);
const auto b = ade::util::value(i);
if (idx >= m_num_int_buffers ||
fg.metadata(m_all_gmat_ids[idx]).get<FluidData>().internal == true)
fg.metadata(m_all_gmat_ids.at(idx)).get<FluidData>().internal == true)
{
GAPI_Assert(b.priv().size() > 0);
}
@@ -863,7 +920,7 @@ cv::gimpl::GFluidExecutable::GFluidExecutable(const ade::Graph &g,
// (There can be non-zero sized const border buffer allocated in such buffers)
total_size += b.priv().size();
}
GAPI_LOG_INFO(NULL, "Internal buffers: " << std::fixed << std::setprecision(2) << static_cast<float>(total_size)/1024 << " KB\n");
return total_size;
}
namespace
@@ -1196,6 +1253,11 @@ void cv::gimpl::GFluidExecutable::packArg(cv::GArg &in_arg, const cv::GArg &op_a
void cv::gimpl::GFluidExecutable::run(std::vector<InObj> &&input_objs,
std::vector<OutObj> &&output_objs)
{
run(input_objs, output_objs);
}
void cv::gimpl::GFluidExecutable::run(std::vector<InObj> &input_objs,
std::vector<OutObj> &output_objs)
{
// Bind input buffers from parameters
for (auto& it : input_objs) bindInArg(it.first, it.second);
@@ -1269,6 +1331,34 @@ void cv::gimpl::GFluidExecutable::run(std::vector<InObj> &&input_objs,
}
}
cv::gimpl::GParallelFluidExecutable::GParallelFluidExecutable(const ade::Graph &g,
const FluidGraphInputData &graph_data,
const std::vector<GFluidOutputRois> &parallelOutputRois,
const decltype(parallel_for) &pfor)
: parallel_for(pfor)
{
for (auto&& rois : parallelOutputRois){
tiles.emplace_back(new GFluidExecutable(g, graph_data, rois.rois));
}
}
void cv::gimpl::GParallelFluidExecutable::reshape(ade::Graph&, const GCompileArgs& )
{
//TODO: implement ?
GAPI_Assert(false && "Not Implemented;");
}
void cv::gimpl::GParallelFluidExecutable::run(std::vector<InObj> &&input_objs,
std::vector<OutObj> &&output_objs)
{
parallel_for(tiles.size(), [&, this](std::size_t index){
GAPI_Assert((bool)tiles[index]);
tiles[index]->run(input_objs, output_objs);
});
}
// FIXME: these passes operate on graph global level!!!
// Need to fix this for heterogeneous (island-based) processing
void GFluidBackendImpl::addBackendPasses(ade::ExecutionEngineSetupContext &ectx)
@@ -51,6 +51,13 @@ struct FluidData
gapi::fluid::BorderOpt border;
};
struct agent_data_t {
GFluidKernel::Kind kind;
ade::NodeHandle nh;
std::vector<int> in_buffer_ids;
std::vector<int> out_buffer_ids;
};
struct FluidAgent
{
public:
@@ -96,8 +103,23 @@ private:
virtual std::pair<int,int> linesReadAndnextWindow(std::size_t inPort) const = 0;
};
//helper data structure for accumulating graph traversal/analysis data
struct FluidGraphInputData {
std::vector<agent_data_t> m_agents_data;
std::vector<std::size_t> m_scratch_users;
std::unordered_map<int, std::size_t> m_id_map; // GMat id -> buffer idx map
std::map<std::size_t, ade::NodeHandle> m_all_gmat_ids;
std::size_t m_mat_count;
};
//local helper function to traverse the graph once and pass the results to multiple instances of GFluidExecutable
FluidGraphInputData fluidExtractInputDataFromGraph(const ade::Graph &m_g, const std::vector<ade::NodeHandle> &nodes);
class GFluidExecutable final: public GIslandExecutable
{
GFluidExecutable(const GFluidExecutable&) = delete; // due std::unique_ptr in members list
const ade::Graph &m_g;
GModel::ConstGraph m_gm;
@@ -121,15 +143,40 @@ class GFluidExecutable final: public GIslandExecutable
void initBufferRois(std::vector<int>& readStarts, std::vector<cv::gapi::own::Rect>& rois, const std::vector<gapi::own::Rect> &out_rois);
void makeReshape(const std::vector<cv::gapi::own::Rect>& out_rois);
std::size_t total_buffers_size() const;
public:
GFluidExecutable(const ade::Graph &g,
const std::vector<ade::NodeHandle> &nodes,
const std::vector<cv::gapi::own::Rect> &outputRois);
virtual inline bool canReshape() const override { return true; }
virtual void reshape(ade::Graph& g, const GCompileArgs& args) override;
virtual void run(std::vector<InObj> &&input_objs,
std::vector<OutObj> &&output_objs) override;
void run(std::vector<InObj> &input_objs,
std::vector<OutObj> &output_objs);
GFluidExecutable(const ade::Graph &g,
const FluidGraphInputData &graph_data,
const std::vector<cv::gapi::own::Rect> &outputRois);
};
class GParallelFluidExecutable final: public GIslandExecutable {
GParallelFluidExecutable(const GParallelFluidExecutable&) = delete; // due std::unique_ptr in members list
std::vector<std::unique_ptr<GFluidExecutable>> tiles;
decltype(GFluidParallelFor::parallel_for) parallel_for;
public:
GParallelFluidExecutable(const ade::Graph &g,
const FluidGraphInputData &graph_data,
const std::vector<GFluidOutputRois> &parallelOutputRois,
const decltype(parallel_for) &pfor);
virtual inline bool canReshape() const override { return false; }
virtual void reshape(ade::Graph& g, const GCompileArgs& args) override;
virtual void run(std::vector<InObj> &&input_objs,
std::vector<OutObj> &&output_objs) override;
};
@@ -150,6 +150,26 @@ void cv::gimpl::GOCLExecutable::run(std::vector<InObj> &&input_objs,
// has received from user (or from another Island, or mix...)
// FIXME: Check input/output objects against GIsland protocol
// NB: We must clean-up m_res before this function returns because internally (bindInArg,
// bindOutArg) we work with cv::UMats, not cv::Mats that were originally placed into the
// input/output objects. If this is not done and cv::UMat "leaves" the local function scope,
// certain problems may occur.
//
// For example, if the original output (cv::Mat) is re-initialized by the user but we still
// hold cv::UMat -> we get cv::UMat that has a parent that was already destroyed. Also,
// since we don't own the data (the user does), there's no point holding it after we're done
const auto clean_up = [&input_objs, &output_objs] (cv::gimpl::Mag* p)
{
// Only clean-up UMat entries from current scope, we know that inputs and outputs are stored
// as UMats from the context below, so the following procedure is safe
auto& umats = p->slot<cv::UMat>();
// NB: avoid clearing the whole magazine, there's also pre-allocated internal data
for (auto& it : input_objs) umats.erase(it.first.id);
for (auto& it : output_objs) umats.erase(it.first.id);
};
// RAII wrapper to clean-up m_res
std::unique_ptr<cv::gimpl::Mag, decltype(clean_up)> cleaner(&m_res, clean_up);
for (auto& it : input_objs) magazine::bindInArg (m_res, it.first, it.second, true);
for (auto& it : output_objs) magazine::bindOutArg(m_res, it.first, it.second, true);
+47 -88
View File
@@ -30,91 +30,37 @@ enum bitwiseOp
NOT = 3
};
namespace
// Note: namespace must match the namespace of the type of the printed object
inline std::ostream& operator<<(std::ostream& os, mathOp op)
{
const char *MathOperations[] = {"ADD", "SUB", "MUL", "DIV"};
const char *BitwiseOperations[] = {"And", "Or", "Xor"};
const char *CompareOperations[] = {"CMP_EQ", "CMP_GT", "CMP_GE", "CMP_LT", "CMP_LE", "CMP_NE"};
//corresponds to OpenCV
const char *NormOperations[] = {"", "NORM_INF", "NORM_L1", "","NORM_L2"};
#define CASE(v) case mathOp::v: os << #v; break
switch (op)
{
CASE(ADD);
CASE(SUB);
CASE(MUL);
CASE(DIV);
default: GAPI_Assert(false && "unknown mathOp value");
}
#undef CASE
return os;
}
struct PrintMathOpCoreParams
// Note: namespace must match the namespace of the type of the printed object
inline std::ostream& operator<<(std::ostream& os, bitwiseOp op)
{
template <class TestParams>
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
#define CASE(v) case bitwiseOp::v: os << #v; break
switch (op)
{
std::stringstream ss;
using AllParams = Params<mathOp,bool,double,bool>;
const AllParams::params_t& params = info.param;
cv::Size sz = AllParams::getCommon<1>(params); // size
ss<<MathOperations[AllParams::getSpecific<0>(params)] // mathOp
<<"_"<<AllParams::getSpecific<1>(params) // testWithScalar
<<"_"<<AllParams::getCommon<0>(params) // type
<<"_"<<(int)AllParams::getSpecific<2>(params) // scale
<<"_"<<sz.width
<<"x"<<sz.height
<<"_"<<(AllParams::getCommon<2>(params)+1) // dtype
<<"_"<<AllParams::getCommon<3>(params) // createOutputMatrices
<<"_"<<AllParams::getSpecific<3>(params); // doReverseOp
return ss.str();
}
};
struct PrintCmpCoreParams
{
template <class TestParams>
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
{
std::stringstream ss;
using AllParams = Params<CmpTypes,bool>;
const AllParams::params_t& params = info.param;
cv::Size sz = AllParams::getCommon<1>(params); // size
ss<<CompareOperations[AllParams::getSpecific<0>(params)] // CmpType
<<"_"<<AllParams::getSpecific<1>(params) // testWithScalar
<<"_"<<AllParams::getCommon<0>(params) // type
<<"_"<<sz.width
<<"x"<<sz.height
<<"_"<<AllParams::getCommon<3>(params); // createOutputMatrices
return ss.str();
}
};
struct PrintBWCoreParams
{
template <class TestParams>
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
{
std::stringstream ss;
using AllParams = Params<bitwiseOp>;
const AllParams::params_t& params = info.param;
cv::Size sz = AllParams::getCommon<1>(params); // size
ss<<BitwiseOperations[AllParams::getSpecific<0>(params)] // bitwiseOp
<<"_"<<AllParams::getCommon<0>(params) // type
<<"_"<<sz.width
<<"x"<<sz.height
<<"_"<<AllParams::getCommon<3>(params); // createOutputMatrices
return ss.str();
}
};
struct PrintNormCoreParams
{
template <class TestParams>
std::string operator()(const ::testing::TestParamInfo<TestParams>& info) const
{
std::stringstream ss;
using AllParams = Params<compare_scalar_f,NormTypes>;
const AllParams::params_t& params = info.param;
cv::Size sz = AllParams::getCommon<1>(params); // size
ss<<NormOperations[AllParams::getSpecific<1>(params)] // NormTypes
<<"_"<<AllParams::getCommon<0>(params) // type
<<"_"<<sz.width
<<"x"<<sz.height;
return ss.str();
}
};
CASE(AND);
CASE(OR);
CASE(XOR);
CASE(NOT);
default: GAPI_Assert(false && "unknown bitwiseOp value");
}
#undef CASE
return os;
}
GAPI_TEST_FIXTURE(MathOpTest, initMatsRandU, FIXTURE_API(mathOp,bool,double,bool), 4,
opType, testWithScalar, scale, doReverseOp)
@@ -133,9 +79,9 @@ GAPI_TEST_FIXTURE(MinTest, initMatsRandU, <>, 0)
GAPI_TEST_FIXTURE(MaxTest, initMatsRandU, <>, 0)
GAPI_TEST_FIXTURE(AbsDiffTest, initMatsRandU, <>, 0)
GAPI_TEST_FIXTURE(AbsDiffCTest, initMatsRandU, <>, 0)
GAPI_TEST_FIXTURE(SumTest, initMatrixRandU, FIXTURE_API(compare_scalar_f), 1, cmpF)
GAPI_TEST_FIXTURE(AddWeightedTest, initMatsRandU, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(NormTest, initMatrixRandU, FIXTURE_API(compare_scalar_f,NormTypes), 2,
GAPI_TEST_FIXTURE(SumTest, initMatrixRandU, FIXTURE_API(CompareScalars), 1, cmpF)
GAPI_TEST_FIXTURE(AddWeightedTest, initMatsRandU, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(NormTest, initMatrixRandU, FIXTURE_API(CompareScalars,NormTypes), 2,
cmpF, opType)
GAPI_TEST_FIXTURE(IntegralTest, initNothing, <>, 0)
GAPI_TEST_FIXTURE(ThresholdTest, initMatrixRandU, FIXTURE_API(int), 1, tt)
@@ -143,11 +89,11 @@ GAPI_TEST_FIXTURE(ThresholdOTTest, initMatrixRandU, FIXTURE_API(int), 1, tt)
GAPI_TEST_FIXTURE(InRangeTest, initMatrixRandU, <>, 0)
GAPI_TEST_FIXTURE(Split3Test, initMatrixRandU, <>, 0)
GAPI_TEST_FIXTURE(Split4Test, initMatrixRandU, <>, 0)
GAPI_TEST_FIXTURE(ResizeTest, initNothing, FIXTURE_API(compare_f,int,cv::Size), 3,
GAPI_TEST_FIXTURE(ResizeTest, initNothing, FIXTURE_API(CompareMats,int,cv::Size), 3,
cmpF, interp, sz_out)
GAPI_TEST_FIXTURE(ResizePTest, initNothing, FIXTURE_API(compare_f,int,cv::Size), 3,
GAPI_TEST_FIXTURE(ResizePTest, initNothing, FIXTURE_API(CompareMats,int,cv::Size), 3,
cmpF, interp, sz_out)
GAPI_TEST_FIXTURE(ResizeTestFxFy, initNothing, FIXTURE_API(compare_f,int,double,double), 4,
GAPI_TEST_FIXTURE(ResizeTestFxFy, initNothing, FIXTURE_API(CompareMats,int,double,double), 4,
cmpF, interp, fx, fy)
GAPI_TEST_FIXTURE(Merge3Test, initMatsRandU, <>, 0)
GAPI_TEST_FIXTURE(Merge4Test, initMatsRandU, <>, 0)
@@ -159,12 +105,25 @@ GAPI_TEST_FIXTURE(ConcatVertTest, initNothing, <>, 0)
GAPI_TEST_FIXTURE(ConcatVertVecTest, initNothing, <>, 0)
GAPI_TEST_FIXTURE(ConcatHorVecTest, initNothing, <>, 0)
GAPI_TEST_FIXTURE(LUTTest, initNothing, <>, 0)
GAPI_TEST_FIXTURE(ConvertToTest, initNothing, FIXTURE_API(compare_f, double, double), 3,
GAPI_TEST_FIXTURE(ConvertToTest, initNothing, FIXTURE_API(CompareMats, double, double), 3,
cmpF, alpha, beta)
GAPI_TEST_FIXTURE(PhaseTest, initMatsRandU, FIXTURE_API(bool), 1, angle_in_degrees)
GAPI_TEST_FIXTURE(SqrtTest, initMatrixRandU, <>, 0)
GAPI_TEST_FIXTURE(NormalizeTest, initNothing, FIXTURE_API(compare_f,double,double,int,MatType), 5,
GAPI_TEST_FIXTURE(NormalizeTest, initNothing, FIXTURE_API(CompareMats,double,double,int,MatType2), 5,
cmpF, a, b, norm_type, ddepth)
struct BackendOutputAllocationTest : TestWithParamBase<>
{
BackendOutputAllocationTest()
{
in_mat1 = cv::Mat(sz, type);
in_mat2 = cv::Mat(sz, type);
cv::randu(in_mat1, cv::Scalar::all(1), cv::Scalar::all(15));
cv::randu(in_mat2, cv::Scalar::all(1), cv::Scalar::all(15));
}
};
// FIXME: move all tests from this fixture to the base class once all issues are resolved
struct BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest : BackendOutputAllocationTest {};
GAPI_TEST_FIXTURE(ReInitOutTest, initNothing, <cv::Size>, 1, out_sz)
} // opencv_test
#endif //OPENCV_GAPI_CORE_TESTS_HPP
@@ -269,7 +269,7 @@ TEST_P(Polar2CartTest, AccuracyTest)
{
cv::Mat out_mat2;
cv::Mat out_mat_ocv2;
if(createOutputMatrices)
if (dtype != -1)
{
out_mat2 = cv::Mat(sz, dtype);
out_mat_ocv2 = cv::Mat(sz, dtype);
@@ -808,7 +808,8 @@ TEST_P(Split4Test, AccuracyTest)
}
}
static void ResizeAccuracyTest(compare_f cmpF, int type, int interp, cv::Size sz_in, cv::Size sz_out, double fx, double fy, cv::GCompileArgs&& compile_args)
static void ResizeAccuracyTest(const CompareMats& cmpF, int type, int interp, cv::Size sz_in,
cv::Size sz_out, double fx, double fy, cv::GCompileArgs&& compile_args)
{
cv::Mat in_mat1 (sz_in, type );
cv::Scalar mean = cv::Scalar::all(127);
@@ -978,7 +979,7 @@ TEST_P(FlipTest, AccuracyTest)
TEST_P(CropTest, AccuracyTest)
{
cv::Size sz_out = cv::Size(rect_to.width, rect_to.height);
if(createOutputMatrices)
if (dtype != -1)
{
out_mat_gapi = cv::Mat(sz_out, dtype);
out_mat_ocv = cv::Mat(sz_out, dtype);
@@ -1247,7 +1248,7 @@ TEST_P(SqrtTest, AccuracyTest)
TEST_P(NormalizeTest, Test)
{
initMatrixRandN(type, sz, CV_MAKETYPE(ddepth, CV_MAT_CN(type)), createOutputMatrices);
initMatrixRandN(type, sz, CV_MAKETYPE(ddepth, CV_MAT_CN(type)));
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in;
@@ -1267,6 +1268,249 @@ TEST_P(NormalizeTest, Test)
}
}
TEST_P(BackendOutputAllocationTest, EmptyOutput)
{
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::mul(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
EXPECT_TRUE(out_mat_gapi.empty());
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), getCompileArgs());
EXPECT_FALSE(out_mat_gapi.empty());
// OpenCV code /////////////////////////////////////////////////////////////
cv::multiply(in_mat1, in_mat2, out_mat_ocv);
// Comparison //////////////////////////////////////////////////////////////
// Expected: output is allocated to the needed size
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi.size());
}
TEST_P(BackendOutputAllocationTest, CorrectlyPreallocatedOutput)
{
out_mat_gapi = cv::Mat(sz, type);
auto out_mat_gapi_ref = out_mat_gapi; // shallow copy to ensure previous data is not deleted
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::add(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::add(in_mat1, in_mat2, out_mat_ocv);
// Comparison //////////////////////////////////////////////////////////////
// Expected: output is not reallocated
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi.size());
EXPECT_EQ(out_mat_gapi_ref.data, out_mat_gapi.data);
}
TEST_P(BackendOutputAllocationTest, IncorrectOutputMeta)
{
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::add(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
const auto run_and_compare = [&c, this] ()
{
auto out_mat_gapi_ref = out_mat_gapi; // shallow copy to ensure previous data is not deleted
// G-API code //////////////////////////////////////////////////////////////
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::add(in_mat1, in_mat2, out_mat_ocv, cv::noArray());
// Comparison //////////////////////////////////////////////////////////////
// Expected: size is changed, type is changed, output is reallocated
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi.size());
EXPECT_EQ(type, out_mat_gapi.type());
EXPECT_NE(out_mat_gapi_ref.data, out_mat_gapi.data);
};
const auto chan = CV_MAT_CN(type);
out_mat_gapi = cv::Mat(sz, CV_MAKE_TYPE(CV_64F, chan));
run_and_compare();
out_mat_gapi = cv::Mat(sz, CV_MAKE_TYPE(CV_MAT_DEPTH(type), chan + 1));
run_and_compare();
}
TEST_P(BackendOutputAllocationTest, SmallerPreallocatedSize)
{
out_mat_gapi = cv::Mat(sz / 2, type);
auto out_mat_gapi_ref = out_mat_gapi; // shallow copy to ensure previous data is not deleted
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::mul(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::multiply(in_mat1, in_mat2, out_mat_ocv);
// Comparison //////////////////////////////////////////////////////////////
// Expected: size is changed, output is reallocated due to original size < curr size
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi.size());
EXPECT_NE(out_mat_gapi_ref.data, out_mat_gapi.data);
}
TEST_P(BackendOutputAllocationTest, SmallerPreallocatedSizeWithSubmatrix)
{
out_mat_gapi = cv::Mat(sz / 2, type);
cv::Mat out_mat_gapi_submat = out_mat_gapi(cv::Rect({10, 0}, sz / 5));
EXPECT_EQ(out_mat_gapi.data, out_mat_gapi_submat.datastart);
auto out_mat_gapi_submat_ref = out_mat_gapi_submat; // shallow copy to ensure previous data is not deleted
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::mul(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi_submat), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::multiply(in_mat1, in_mat2, out_mat_ocv);
// Comparison //////////////////////////////////////////////////////////////
// Expected: submatrix is reallocated and is "detached", original matrix is unchanged
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi_submat != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi_submat.size());
EXPECT_EQ(sz / 2, out_mat_gapi.size());
EXPECT_NE(out_mat_gapi_submat_ref.data, out_mat_gapi_submat.data);
EXPECT_NE(out_mat_gapi.data, out_mat_gapi_submat.datastart);
}
TEST_P(BackendOutputAllocationTest, LargerPreallocatedSize)
{
out_mat_gapi = cv::Mat(sz * 2, type);
auto out_mat_gapi_ref = out_mat_gapi; // shallow copy to ensure previous data is not deleted
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::mul(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::multiply(in_mat1, in_mat2, out_mat_ocv);
// Comparison //////////////////////////////////////////////////////////////
// Expected: size is changed, output is reallocated
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi.size());
EXPECT_NE(out_mat_gapi_ref.data, out_mat_gapi.data);
}
TEST_P(BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest,
LargerPreallocatedSizeWithCorrectSubmatrix)
{
out_mat_gapi = cv::Mat(sz * 2, type);
auto out_mat_gapi_ref = out_mat_gapi; // shallow copy to ensure previous data is not deleted
cv::Mat out_mat_gapi_submat = out_mat_gapi(cv::Rect({5, 8}, sz));
EXPECT_EQ(out_mat_gapi.data, out_mat_gapi_submat.datastart);
auto out_mat_gapi_submat_ref = out_mat_gapi_submat;
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::mul(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi_submat), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::multiply(in_mat1, in_mat2, out_mat_ocv);
// Comparison //////////////////////////////////////////////////////////////
// Expected: submatrix is not reallocated, original matrix is not reallocated
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi_submat != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi_submat.size());
EXPECT_EQ(sz * 2, out_mat_gapi.size());
EXPECT_EQ(out_mat_gapi_ref.data, out_mat_gapi.data);
EXPECT_EQ(out_mat_gapi_submat_ref.data, out_mat_gapi_submat.data);
EXPECT_EQ(out_mat_gapi.data, out_mat_gapi_submat.datastart);
}
TEST_P(BackendOutputAllocationTest, LargerPreallocatedSizeWithSmallSubmatrix)
{
out_mat_gapi = cv::Mat(sz * 2, type);
auto out_mat_gapi_ref = out_mat_gapi; // shallow copy to ensure previous data is not deleted
cv::Mat out_mat_gapi_submat = out_mat_gapi(cv::Rect({5, 8}, sz / 2));
EXPECT_EQ(out_mat_gapi.data, out_mat_gapi_submat.datastart);
auto out_mat_gapi_submat_ref = out_mat_gapi_submat;
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::mul(in1, in2);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi_submat), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::multiply(in_mat1, in_mat2, out_mat_ocv);
// Comparison //////////////////////////////////////////////////////////////
// Expected: submatrix is reallocated and is "detached", original matrix is unchanged
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi_submat != out_mat_ocv));
EXPECT_EQ(sz, out_mat_gapi_submat.size());
EXPECT_EQ(sz * 2, out_mat_gapi.size());
EXPECT_EQ(out_mat_gapi_ref.data, out_mat_gapi.data);
EXPECT_NE(out_mat_gapi_submat_ref.data, out_mat_gapi_submat.data);
EXPECT_NE(out_mat_gapi.data, out_mat_gapi_submat.datastart);
}
TEST_P(ReInitOutTest, TestWithAdd)
{
in_mat1 = cv::Mat(sz, type);
in_mat2 = cv::Mat(sz, type);
cv::randu(in_mat1, cv::Scalar::all(0), cv::Scalar::all(100));
cv::randu(in_mat2, cv::Scalar::all(0), cv::Scalar::all(100));
// G-API code //////////////////////////////////////////////////////////////
cv::GMat in1, in2, out;
out = cv::gapi::add(in1, in2, dtype);
cv::GComputation c(cv::GIn(in1, in2), cv::GOut(out));
const auto run_and_compare = [&c, this] ()
{
// G-API code //////////////////////////////////////////////////////////////
c.apply(cv::gin(in_mat1, in_mat2), cv::gout(out_mat_gapi), getCompileArgs());
// OpenCV code /////////////////////////////////////////////////////////////
cv::add(in_mat1, in_mat2, out_mat_ocv, cv::noArray());
// Comparison //////////////////////////////////////////////////////////////
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv));
EXPECT_EQ(out_mat_gapi.size(), sz);
};
// run for uninitialized output
run_and_compare();
// run for initialized output (can be initialized with a different size)
initOutMats(out_sz, type);
run_and_compare();
}
} // opencv_test
#endif //OPENCV_GAPI_CORE_TESTS_INL_HPP
+30 -30
View File
@@ -14,45 +14,45 @@
namespace opencv_test
{
GAPI_TEST_FIXTURE(Filter2DTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
GAPI_TEST_FIXTURE(Filter2DTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
cmpF, kernSize, borderType)
GAPI_TEST_FIXTURE(BoxFilterTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
GAPI_TEST_FIXTURE(BoxFilterTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
cmpF, filterSize, borderType)
GAPI_TEST_FIXTURE(SepFilterTest, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, kernSize)
GAPI_TEST_FIXTURE(BlurTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
GAPI_TEST_FIXTURE(SepFilterTest, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, kernSize)
GAPI_TEST_FIXTURE(BlurTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
cmpF, filterSize, borderType)
GAPI_TEST_FIXTURE(GaussianBlurTest, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, kernSize)
GAPI_TEST_FIXTURE(MedianBlurTest, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, kernSize)
GAPI_TEST_FIXTURE(ErodeTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
GAPI_TEST_FIXTURE(GaussianBlurTest, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, kernSize)
GAPI_TEST_FIXTURE(MedianBlurTest, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, kernSize)
GAPI_TEST_FIXTURE(ErodeTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
cmpF, kernSize, kernType)
GAPI_TEST_FIXTURE(Erode3x3Test, initMatrixRandN, FIXTURE_API(compare_f,int), 2,
GAPI_TEST_FIXTURE(Erode3x3Test, initMatrixRandN, FIXTURE_API(CompareMats,int), 2,
cmpF, numIters)
GAPI_TEST_FIXTURE(DilateTest, initMatrixRandN, FIXTURE_API(compare_f,int,int), 3,
GAPI_TEST_FIXTURE(DilateTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int), 3,
cmpF, kernSize, kernType)
GAPI_TEST_FIXTURE(Dilate3x3Test, initMatrixRandN, FIXTURE_API(compare_f,int), 2, cmpF, numIters)
GAPI_TEST_FIXTURE(SobelTest, initMatrixRandN, FIXTURE_API(compare_f,int,int,int), 4,
GAPI_TEST_FIXTURE(Dilate3x3Test, initMatrixRandN, FIXTURE_API(CompareMats,int), 2, cmpF, numIters)
GAPI_TEST_FIXTURE(SobelTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int,int), 4,
cmpF, kernSize, dx, dy)
GAPI_TEST_FIXTURE(SobelXYTest, initMatrixRandN, FIXTURE_API(compare_f,int,int,int,int), 5,
GAPI_TEST_FIXTURE(SobelXYTest, initMatrixRandN, FIXTURE_API(CompareMats,int,int,int,int), 5,
cmpF, kernSize, order, border_type, border_val)
GAPI_TEST_FIXTURE(EqHistTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(CannyTest, initMatrixRandN, FIXTURE_API(compare_f,double,double,int,bool), 5,
GAPI_TEST_FIXTURE(EqHistTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(CannyTest, initMatrixRandN, FIXTURE_API(CompareMats,double,double,int,bool), 5,
cmpF, thrLow, thrUp, apSize, l2gr)
GAPI_TEST_FIXTURE(RGB2GrayTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(BGR2GrayTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2YUVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(YUV2RGBTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toRGBTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toBGRpTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toRGBpTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toBGRTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2LabTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(BGR2LUVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(LUV2BGRTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(BGR2YUVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(YUV2BGRTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2HSVTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(BayerGR2RGBTest, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2YUV422Test, initMatrixRandN, FIXTURE_API(compare_f), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(BGR2GrayTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2YUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(YUV2RGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toRGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toBGRpTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toRGBpTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(NV12toBGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2LabTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(BGR2LUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(LUV2BGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(BGR2YUVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(YUV2BGRTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2HSVTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(BayerGR2RGBTest, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
GAPI_TEST_FIXTURE(RGB2YUV422Test, initMatrixRandN, FIXTURE_API(CompareMats), 1, cmpF)
} // opencv_test
#endif //OPENCV_GAPI_IMGPROC_TESTS_HPP
@@ -185,9 +185,9 @@ g_api_ocv_pair_mat_mat opXor = {std::string{"operator^"},
} // anonymous namespace
GAPI_TEST_FIXTURE(MathOperatorMatScalarTest, initMatsRandU,
FIXTURE_API(compare_f, g_api_ocv_pair_mat_scalar), 2, cmpF, op)
FIXTURE_API(CompareMats, g_api_ocv_pair_mat_scalar), 2, cmpF, op)
GAPI_TEST_FIXTURE(MathOperatorMatMatTest, initMatsRandU,
FIXTURE_API(compare_f, g_api_ocv_pair_mat_mat), 2, cmpF, op)
FIXTURE_API(CompareMats, g_api_ocv_pair_mat_mat), 2, cmpF, op)
GAPI_TEST_FIXTURE(NotOperatorTest, initMatrixRandU, <>, 0)
} // opencv_test
+138 -24
View File
@@ -132,15 +132,33 @@ using compare_f = std::function<bool(const cv::Mat &a, const cv::Mat &b)>;
using compare_scalar_f = std::function<bool(const cv::Scalar &a, const cv::Scalar &b)>;
// FIXME: re-use MatType. current problem: "special values" interpreted incorrectly (-1 is printed
// as 16FC512)
struct MatType2
{
public:
MatType2(int val = 0) : _value(val) {}
operator int() const { return _value; }
friend std::ostream& operator<<(std::ostream& os, const MatType2& t)
{
switch (t)
{
case -1: return os << "SAME_TYPE";
default: PrintTo(MatType(t), &os); return os;
}
}
private:
int _value;
};
// Universal parameter wrapper for common (pre-defined) and specific (user-defined) parameters
template<typename ...SpecificParams>
struct Params
{
using gcomp_args_function_t = cv::GCompileArgs(*)();
// TODO: delete bool (createOutputMatrices) from common parameters
using common_params_t = std::tuple<int, cv::Size, int, bool, gcomp_args_function_t>;
using common_params_t = std::tuple<MatType2, cv::Size, MatType2, gcomp_args_function_t>;
using specific_params_t = std::tuple<SpecificParams...>;
using params_t = std::tuple<int, cv::Size, int, bool, gcomp_args_function_t, SpecificParams...>;
using params_t = std::tuple<MatType2, cv::Size, MatType2, gcomp_args_function_t, SpecificParams...>;
static constexpr const size_t common_params_size = std::tuple_size<common_params_t>::value;
static constexpr const size_t specific_params_size = std::tuple_size<specific_params_t>::value;
@@ -170,15 +188,9 @@ struct TestWithParamBase : TestFunctional,
{
using AllParams = Params<SpecificParams...>;
MatType type = getCommonParam<0>();
MatType2 type = getCommonParam<0>();
cv::Size sz = getCommonParam<1>();
MatType dtype = getCommonParam<2>();
bool createOutputMatrices = getCommonParam<3>();
TestWithParamBase()
{
if (dtype == SAME_TYPE) { dtype = type; }
}
MatType2 dtype = getCommonParam<2>();
// Get common (pre-defined) parameter value by index
template<size_t I>
@@ -199,7 +211,7 @@ struct TestWithParamBase : TestFunctional,
// Return G-API compile arguments specified for test fixture
inline cv::GCompileArgs getCompileArgs() const
{
return getCommonParam<4>()();
return getCommonParam<3>()();
}
};
@@ -220,13 +232,35 @@ struct TestWithParamBase : TestFunctional,
static_assert(Number == AllParams::specific_params_size, \
"Number of user-defined parameters doesn't match size of __VA_ARGS__"); \
__WRAP_VAARGS(DEFINE_SPECIFIC_PARAMS_##Number(__VA_ARGS__)) \
Fixture() { InitF(type, sz, dtype, createOutputMatrices); } \
Fixture() { InitF(type, sz, dtype); } \
};
// Wrapper for test fixture API. Use to specify multiple types.
// Example: FIXTURE_API(int, bool) expands to <int, bool>
#define FIXTURE_API(...) <__VA_ARGS__>
template<typename T1, typename T2>
struct CompareF
{
using callable_t = std::function<bool(const T1& a, const T2& b)>;
CompareF(callable_t&& cmp, std::string&& cmp_name) :
_comparator(std::move(cmp)), _name(std::move(cmp_name)) {}
bool operator()(const T1& a, const T2& b) const
{
return _comparator(a, b);
}
friend std::ostream& operator<<(std::ostream& os, const CompareF<T1, T2>& obj)
{
return os << obj._name;
}
private:
callable_t _comparator;
std::string _name;
};
using CompareMats = CompareF<cv::Mat, cv::Mat>;
using CompareScalars = CompareF<cv::Scalar, cv::Scalar>;
template<typename T>
struct Wrappable
{
@@ -238,6 +272,14 @@ struct Wrappable
return t(a, b);
};
}
CompareMats to_compare_obj()
{
T t = *static_cast<T*const>(this);
std::stringstream ss;
ss << t;
return CompareMats(to_compare_f(), ss.str());
}
};
template<typename T>
@@ -251,6 +293,14 @@ struct WrappableScalar
return t(a, b);
};
}
CompareScalars to_compare_obj()
{
T t = *static_cast<T*const>(this);
std::stringstream ss;
ss << t;
return CompareScalars(to_compare_f(), ss.str());
}
};
@@ -270,7 +320,10 @@ public:
return true;
}
}
private:
friend std::ostream& operator<<(std::ostream& os, const AbsExact&)
{
return os << "AbsExact()";
}
};
class AbsTolerance : public Wrappable<AbsTolerance>
@@ -290,6 +343,10 @@ public:
return true;
}
}
friend std::ostream& operator<<(std::ostream& os, const AbsTolerance& obj)
{
return os << "AbsTolerance(" << std::to_string(obj._tol) << ")";
}
private:
double _tol;
};
@@ -318,6 +375,10 @@ public:
}
}
}
friend std::ostream& operator<<(std::ostream& os, const Tolerance_FloatRel_IntAbs& obj)
{
return os << "Tolerance_FloatRel_IntAbs(" << obj._tol << ", " << obj._tol8u << ")";
}
private:
double _tol;
double _tol8u;
@@ -347,6 +408,10 @@ public:
return true;
}
}
friend std::ostream& operator<<(std::ostream& os, const AbsSimilarPoints& obj)
{
return os << "AbsSimilarPoints(" << obj._tol << ", " << obj._percent << ")";
}
private:
double _tol;
double _percent;
@@ -379,6 +444,11 @@ public:
}
return true;
}
friend std::ostream& operator<<(std::ostream& os, const ToleranceFilter& obj)
{
return os << "ToleranceFilter(" << obj._tol << ", " << obj._tol8u << ", "
<< obj._inf_tol << ")";
}
private:
double _tol;
double _tol8u;
@@ -407,6 +477,10 @@ public:
}
return true;
}
friend std::ostream& operator<<(std::ostream& os, const ToleranceColor& obj)
{
return os << "ToleranceColor(" << obj._tol << ", " << obj._inf_tol << ")";
}
private:
double _tol;
double _inf_tol;
@@ -429,26 +503,66 @@ public:
return true;
}
}
friend std::ostream& operator<<(std::ostream& os, const AbsToleranceScalar& obj)
{
return os << "AbsToleranceScalar(" << std::to_string(obj._tol) << ")";
}
private:
double _tol;
};
} // namespace opencv_test
namespace
{
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_f&)
{
return os << "compare_f";
}
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_f&)
{
return os << "compare_f";
}
namespace
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_scalar_f&)
{
inline std::ostream& operator<<(std::ostream& os, const opencv_test::compare_scalar_f&)
{
return os << "compare_scalar_f";
}
return os << "compare_scalar_f";
}
} // anonymous namespace
// Note: namespace must match the namespace of the type of the printed object
namespace cv
{
inline std::ostream& operator<<(std::ostream& os, CmpTypes op)
{
#define CASE(v) case CmpTypes::v: os << #v; break
switch (op)
{
CASE(CMP_EQ);
CASE(CMP_GT);
CASE(CMP_GE);
CASE(CMP_LT);
CASE(CMP_LE);
CASE(CMP_NE);
default: GAPI_Assert(false && "unknown CmpTypes value");
}
#undef CASE
return os;
}
inline std::ostream& operator<<(std::ostream& os, NormTypes op)
{
#define CASE(v) case NormTypes::v: os << #v; break
switch (op)
{
CASE(NORM_INF);
CASE(NORM_L1);
CASE(NORM_L2);
CASE(NORM_L2SQR);
CASE(NORM_HAMMING);
CASE(NORM_HAMMING2);
CASE(NORM_RELATIVE);
CASE(NORM_MINMAX);
default: GAPI_Assert(false && "unknown NormTypes value");
}
#undef CASE
return os;
}
} // namespace cv
#endif //OPENCV_GAPI_TESTS_COMMON_HPP
@@ -13,12 +13,6 @@
namespace opencv_test
{
// out_type == in_type in matrices initialization if out_type is marked as SAME_TYPE
enum {
// TODO: why is it different from -1?
SAME_TYPE = std::numeric_limits<int>::max()
};
// Ensure correct __VA_ARGS__ expansion on Windows
#define __WRAP_VAARGS(x) x
+61 -94
View File
@@ -11,7 +11,7 @@
namespace
{
#define CORE_CPU [] () { return cv::compile_args(cv::gapi::core::cpu::kernels()); }
#define CORE_CPU [] () { return cv::compile_args(cv::gapi::core::cpu::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -24,13 +24,11 @@ INSTANTIATE_TEST_CASE_P(AddTestCPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(ADD, MUL),
testing::Bool(),
Values(1.0),
Values(false)),
opencv_test::PrintMathOpCoreParams());
Values(false)));
INSTANTIATE_TEST_CASE_P(MulTestCPU, MathOpTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -38,13 +36,11 @@ INSTANTIATE_TEST_CASE_P(MulTestCPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(MUL),
testing::Bool(),
Values(1.0, 0.5, 2.0),
Values(false)),
opencv_test::PrintMathOpCoreParams());
Values(false)));
INSTANTIATE_TEST_CASE_P(SubTestCPU, MathOpTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -52,13 +48,11 @@ INSTANTIATE_TEST_CASE_P(SubTestCPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(SUB),
testing::Bool(),
Values (1.0),
testing::Bool()),
opencv_test::PrintMathOpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(DivTestCPU, MathOpTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -66,13 +60,11 @@ INSTANTIATE_TEST_CASE_P(DivTestCPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(DIV),
testing::Bool(),
Values (1.0, 0.5, 2.0),
testing::Bool()),
opencv_test::PrintMathOpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(MulTestCPU, MulDoubleTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -80,7 +72,6 @@ INSTANTIATE_TEST_CASE_P(MulTestCPU, MulDoubleTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(DivTestCPU, DivTest,
@@ -89,7 +80,6 @@ INSTANTIATE_TEST_CASE_P(DivTestCPU, DivTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(DivCTestCPU, DivCTest,
@@ -98,7 +88,6 @@ INSTANTIATE_TEST_CASE_P(DivCTestCPU, DivCTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(MeanTestCPU, MeanTest,
@@ -106,8 +95,7 @@ INSTANTIATE_TEST_CASE_P(MeanTestCPU, MeanTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(MaskTestCPU, MaskTest,
@@ -115,8 +103,7 @@ INSTANTIATE_TEST_CASE_P(MaskTestCPU, MaskTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(SelectTestCPU, SelectTest,
@@ -124,8 +111,7 @@ INSTANTIATE_TEST_CASE_P(SelectTestCPU, SelectTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(Polar2CartCPU, Polar2CartTest,
@@ -134,7 +120,6 @@ INSTANTIATE_TEST_CASE_P(Polar2CartCPU, Polar2CartTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_32FC1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(Cart2PolarCPU, Cart2PolarTest,
@@ -143,7 +128,6 @@ INSTANTIATE_TEST_CASE_P(Cart2PolarCPU, Cart2PolarTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_32FC1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(PhaseCPU, PhaseTest,
@@ -151,18 +135,16 @@ INSTANTIATE_TEST_CASE_P(PhaseCPU, PhaseTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(true),
Values(-1),
Values(CORE_CPU),
testing::Bool()));
/* angle_in_degrees */ testing::Bool()));
INSTANTIATE_TEST_CASE_P(SqrtCPU, SqrtTest,
Combine(Values(CV_32F, CV_32FC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(true),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(CompareTestCPU, CmpTest,
@@ -171,30 +153,25 @@ INSTANTIATE_TEST_CASE_P(CompareTestCPU, CmpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8U),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
testing::Bool()),
opencv_test::PrintCmpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(BitwiseTestCPU, BitwiseTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU),
Values(AND, OR, XOR)),
opencv_test::PrintBWCoreParams());
Values(AND, OR, XOR)));
INSTANTIATE_TEST_CASE_P(BitwiseNotTestCPU, NotTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(MinTestCPU, MinTest,
@@ -202,8 +179,7 @@ INSTANTIATE_TEST_CASE_P(MinTestCPU, MinTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(MaxTestCPU, MaxTest,
@@ -211,8 +187,7 @@ INSTANTIATE_TEST_CASE_P(MaxTestCPU, MaxTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(SumTestCPU, SumTest,
@@ -220,19 +195,17 @@ INSTANTIATE_TEST_CASE_P(SumTestCPU, SumTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
//Values(1e-5),
Values(CORE_CPU),
Values(AbsToleranceScalar(1e-5).to_compare_f())));
Values(AbsToleranceScalar(1e-5).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(AbsDiffTestCPU, AbsDiffTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(AbsDiffCTestCPU, AbsDiffCTest,
@@ -240,8 +213,7 @@ INSTANTIATE_TEST_CASE_P(AbsDiffCTestCPU, AbsDiffCTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(AddWeightedTestCPU, AddWeightedTest,
@@ -250,22 +222,18 @@ INSTANTIATE_TEST_CASE_P(AddWeightedTestCPU, AddWeightedTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f())));
Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(NormTestCPU, NormTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
//Values(1e-5),
Values(-1),
Values(CORE_CPU),
Values(AbsToleranceScalar(1e-5).to_compare_f()),
Values(NORM_INF, NORM_L1, NORM_L2)),
opencv_test::PrintNormCoreParams());
Values(AbsToleranceScalar(1e-5).to_compare_obj()),
Values(NORM_INF, NORM_L1, NORM_L2)));
INSTANTIATE_TEST_CASE_P(IntegralTestCPU, IntegralTest,
Combine(Values( CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -273,7 +241,6 @@ INSTANTIATE_TEST_CASE_P(IntegralTestCPU, IntegralTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(false),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(ThresholdTestCPU, ThresholdTest,
@@ -281,8 +248,7 @@ INSTANTIATE_TEST_CASE_P(ThresholdTestCPU, ThresholdTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC,
cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)));
@@ -292,8 +258,7 @@ INSTANTIATE_TEST_CASE_P(ThresholdTestCPU, ThresholdOTTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU),
Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE)));
@@ -303,8 +268,7 @@ INSTANTIATE_TEST_CASE_P(InRangeTestCPU, InRangeTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(Split3TestCPU, Split3Test,
@@ -313,7 +277,6 @@ INSTANTIATE_TEST_CASE_P(Split3TestCPU, Split3Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
Values(true),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(Split4TestCPU, Split4Test,
@@ -322,7 +285,6 @@ INSTANTIATE_TEST_CASE_P(Split4TestCPU, Split4Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
Values(true),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(ResizeTestCPU, ResizeTest,
@@ -331,9 +293,8 @@ INSTANTIATE_TEST_CASE_P(ResizeTestCPU, ResizeTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(false),
Values(CORE_CPU),
Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(AbsSimilarPoints(2, 0.05).to_compare_obj()),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(cv::Size(64,64),
cv::Size(30,30))));
@@ -344,9 +305,8 @@ INSTANTIATE_TEST_CASE_P(ResizePTestCPU, ResizePTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(false),
Values(CORE_CPU),
Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(AbsSimilarPoints(2, 0.05).to_compare_obj()),
Values(cv::INTER_LINEAR),
Values(cv::Size(64,64),
cv::Size(30,30))));
@@ -357,9 +317,8 @@ INSTANTIATE_TEST_CASE_P(ResizeTestCPU, ResizeTestFxFy,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(false),
Values(CORE_CPU),
Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(AbsSimilarPoints(2, 0.05).to_compare_obj()),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(0.5, 0.1),
Values(0.5, 0.1)));
@@ -370,7 +329,6 @@ INSTANTIATE_TEST_CASE_P(Merge3TestCPU, Merge3Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC3),
Values(true),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(Merge4TestCPU, Merge4Test,
@@ -379,7 +337,6 @@ INSTANTIATE_TEST_CASE_P(Merge4TestCPU, Merge4Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC4),
Values(true),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(RemapTestCPU, RemapTest,
@@ -387,8 +344,7 @@ INSTANTIATE_TEST_CASE_P(RemapTestCPU, RemapTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(FlipTestCPU, FlipTest,
@@ -396,8 +352,7 @@ INSTANTIATE_TEST_CASE_P(FlipTestCPU, FlipTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ Values(false),
Values(-1),
Values(CORE_CPU),
Values(0,1,-1)));
@@ -406,8 +361,7 @@ INSTANTIATE_TEST_CASE_P(CropTestCPU, CropTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ Values(false),
Values(-1),
Values(CORE_CPU),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50))));
@@ -417,7 +371,6 @@ INSTANTIATE_TEST_CASE_P(LUTTestCPU, LUTTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
/*init output matrices or not*/ Values(true),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(LUTTestCustomCPU, LUTTest,
@@ -426,7 +379,6 @@ INSTANTIATE_TEST_CASE_P(LUTTestCustomCPU, LUTTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC3),
/*init output matrices or not*/ Values(true),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(ConvertToCPU, ConvertToTest,
@@ -435,9 +387,8 @@ INSTANTIATE_TEST_CASE_P(ConvertToCPU, ConvertToTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(false),
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(2.5, 1.0, -1.0),
Values(250.0, 0.0, -128.0)));
@@ -446,8 +397,7 @@ INSTANTIATE_TEST_CASE_P(ConcatHorTestCPU, ConcatHorTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(ConcatVertTestCPU, ConcatVertTest,
@@ -455,8 +405,7 @@ INSTANTIATE_TEST_CASE_P(ConcatVertTestCPU, ConcatVertTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(ConcatVertVecTestCPU, ConcatVertVecTest,
@@ -464,8 +413,7 @@ INSTANTIATE_TEST_CASE_P(ConcatVertVecTestCPU, ConcatVertVecTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(ConcatHorVecTestCPU, ConcatHorVecTest,
@@ -473,8 +421,7 @@ INSTANTIATE_TEST_CASE_P(ConcatHorVecTestCPU, ConcatHorVecTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(NormalizeTestCPU, NormalizeTest,
@@ -482,11 +429,31 @@ INSTANTIATE_TEST_CASE_P(NormalizeTestCPU, NormalizeTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(0.0, 15.0),
Values(1.0, 120.0, 255.0),
Values(NORM_MINMAX, NORM_INF, NORM_L1, NORM_L2),
Values(-1, CV_8U, CV_16U, CV_16S, CV_32F)));
INSTANTIATE_TEST_CASE_P(BackendOutputAllocationTestCPU, BackendOutputAllocationTest,
Combine(Values(CV_8UC3, CV_16SC2, CV_32FC1),
Values(cv::Size(50, 50)),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(BackendOutputAllocationLargeSizeWithCorrectSubmatrixTestCPU,
BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest,
Combine(Values(CV_8UC3, CV_16SC2, CV_32FC1),
Values(cv::Size(50, 50)),
Values(-1),
Values(CORE_CPU)));
INSTANTIATE_TEST_CASE_P(ReInitOutTestCPU, ReInitOutTest,
Combine(Values(CV_8UC3, CV_16SC4, CV_32FC1),
Values(cv::Size(640, 480)),
Values(-1),
Values(CORE_CPU),
Values(cv::Size(640, 400),
cv::Size(10, 480))));
}
+45 -58
View File
@@ -10,7 +10,7 @@
namespace
{
#define CORE_FLUID [] () { return cv::compile_args(cv::gapi::core::fluid::kernels()); }
#define CORE_FLUID [] () { return cv::compile_args(cv::gapi::core::fluid::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -24,13 +24,11 @@ INSTANTIATE_TEST_CASE_P(MathOpTestFluid, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
testing::Bool(),
Values(CORE_FLUID),
Values(ADD, SUB, DIV, MUL),
testing::Bool(),
Values(1.0),
testing::Bool()),
opencv_test::PrintMathOpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(MulSTestFluid, MulDoubleTest,
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
@@ -38,7 +36,6 @@ INSTANTIATE_TEST_CASE_P(MulSTestFluid, MulDoubleTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1), // FIXME: extend with more types
testing::Bool(),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(DivCTestFluid, DivCTest,
@@ -47,7 +44,6 @@ INSTANTIATE_TEST_CASE_P(DivCTestFluid, DivCTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8U, CV_32F),
testing::Bool(),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(AbsDiffTestFluid, AbsDiffTest,
@@ -55,8 +51,7 @@ INSTANTIATE_TEST_CASE_P(AbsDiffTestFluid, AbsDiffTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(AbsDiffCTestFluid, AbsDiffCTest,
@@ -64,8 +59,7 @@ INSTANTIATE_TEST_CASE_P(AbsDiffCTestFluid, AbsDiffCTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(BitwiseTestFluid, BitwiseTest,
@@ -74,11 +68,9 @@ INSTANTIATE_TEST_CASE_P(BitwiseTestFluid, BitwiseTest,
cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID),
Values(AND, OR, XOR)),
opencv_test::PrintBWCoreParams());
Values(AND, OR, XOR)));
INSTANTIATE_TEST_CASE_P(BitwiseNotTestFluid, NotTest,
Combine(Values(CV_8UC3, CV_8UC1, CV_16UC1, CV_16SC1),
@@ -86,8 +78,7 @@ INSTANTIATE_TEST_CASE_P(BitwiseNotTestFluid, NotTest,
cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(MinTestFluid, MinTest,
@@ -96,8 +87,7 @@ INSTANTIATE_TEST_CASE_P(MinTestFluid, MinTest,
cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(MaxTestFluid, MaxTest,
@@ -106,8 +96,7 @@ INSTANTIATE_TEST_CASE_P(MaxTestFluid, MaxTest,
cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(CompareTestFluid, CmpTest,
@@ -117,11 +106,9 @@ INSTANTIATE_TEST_CASE_P(CompareTestFluid, CmpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8U),
testing::Bool(),
Values(CORE_FLUID),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
testing::Bool()),
opencv_test::PrintCmpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(AddWeightedTestFluid, AddWeightedTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
@@ -129,10 +116,8 @@ INSTANTIATE_TEST_CASE_P(AddWeightedTestFluid, AddWeightedTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
testing::Bool(),
//Values(0.5000005),
Values(CORE_FLUID),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f())));
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(LUTTestFluid, LUTTest,
Combine(Values(CV_8UC1, CV_8UC3),
@@ -141,7 +126,6 @@ INSTANTIATE_TEST_CASE_P(LUTTestFluid, LUTTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
/*init output matrices or not*/ Values(true),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(ConvertToFluid, ConvertToTest,
@@ -151,9 +135,8 @@ INSTANTIATE_TEST_CASE_P(ConvertToFluid, ConvertToTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8U, CV_16U, CV_32F),
Values(true),
Values(CORE_FLUID),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_obj()),
Values(2.5, 1.0, -1.0),
Values(250.0, 0.0, -128.0)));
@@ -163,7 +146,6 @@ INSTANTIATE_TEST_CASE_P(Split3TestFluid, Split3Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
Values(true),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(Split4TestFluid, Split4Test,
@@ -172,7 +154,6 @@ INSTANTIATE_TEST_CASE_P(Split4TestFluid, Split4Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
Values(true),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(Merge3TestFluid, Merge3Test,
@@ -182,7 +163,6 @@ INSTANTIATE_TEST_CASE_P(Merge3TestFluid, Merge3Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC3),
Values(true),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(Merge4TestFluid, Merge4Test,
@@ -192,7 +172,6 @@ INSTANTIATE_TEST_CASE_P(Merge4TestFluid, Merge4Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC4),
Values(true),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(SelectTestFluid, SelectTest,
@@ -201,8 +180,7 @@ INSTANTIATE_TEST_CASE_P(SelectTestFluid, SelectTest,
cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(Polar2CartFluid, Polar2CartTest,
@@ -211,7 +189,6 @@ INSTANTIATE_TEST_CASE_P(Polar2CartFluid, Polar2CartTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_32FC1),
testing::Bool(),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(Cart2PolarFluid, Cart2PolarTest,
@@ -220,7 +197,6 @@ INSTANTIATE_TEST_CASE_P(Cart2PolarFluid, Cart2PolarTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_32FC1),
testing::Bool(),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(PhaseFluid, PhaseTest,
@@ -228,18 +204,16 @@ INSTANTIATE_TEST_CASE_P(PhaseFluid, PhaseTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(true),
Values(-1),
Values(CORE_FLUID),
testing::Bool()));
/* angle_in_degrees */ testing::Bool()));
INSTANTIATE_TEST_CASE_P(SqrtFluid, SqrtTest,
Combine(Values(CV_32F, CV_32FC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(true),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(ThresholdTestFluid, ThresholdTest,
@@ -248,8 +222,7 @@ INSTANTIATE_TEST_CASE_P(ThresholdTestFluid, ThresholdTest,
cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV,
cv::THRESH_TRUNC,
@@ -261,8 +234,7 @@ INSTANTIATE_TEST_CASE_P(InRangeTestFluid, InRangeTest,
cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(ResizeTestFluid, ResizeTest,
@@ -273,9 +245,8 @@ INSTANTIATE_TEST_CASE_P(ResizeTestFluid, ResizeTest,
cv::Size(64, 64),
cv::Size(30, 30)),
Values(-1),
Values(false),
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(/*cv::INTER_NEAREST,*/ cv::INTER_LINEAR/*, cv::INTER_AREA*/),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
@@ -283,6 +254,27 @@ INSTANTIATE_TEST_CASE_P(ResizeTestFluid, ResizeTest,
cv::Size(64, 64),
cv::Size(30, 30))));
INSTANTIATE_TEST_CASE_P(BackendOutputAllocationTestFluid, BackendOutputAllocationTest,
Combine(Values(CV_8UC3, CV_16SC2, CV_32FC1),
Values(cv::Size(50, 50)),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(BackendOutputAllocationLargeSizeWithCorrectSubmatrixTestFluid,
BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest,
Combine(Values(CV_8UC3, CV_16SC2, CV_32FC1),
Values(cv::Size(50, 50)),
Values(-1),
Values(CORE_FLUID)));
INSTANTIATE_TEST_CASE_P(ReInitOutTestFluid, ReInitOutTest,
Combine(Values(CV_8UC3, CV_16SC4, CV_32FC1),
Values(cv::Size(640, 480)),
Values(-1),
Values(CORE_FLUID),
Values(cv::Size(640, 400),
cv::Size(10, 480))));
//----------------------------------------------------------------------
// FIXME: Clean-up test configurations which are enabled already
#if 0
@@ -295,8 +287,7 @@ INSTANTIATE_TEST_CASE_P(MathOpTestCPU, MathOpTest,
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(false)),
opencv_test::PrintMathOpCoreParams());
Values(false)));
INSTANTIATE_TEST_CASE_P(SubTestCPU, MathOpTest,
Combine(Values(SUB),
@@ -307,8 +298,7 @@ INSTANTIATE_TEST_CASE_P(SubTestCPU, MathOpTest,
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
testing::Bool()),
opencv_test::PrintMathOpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(MulSTestCPU, MulSTest,
Combine(Values(CV_8UC1, CV_16SC1, CV_32FC1),
@@ -358,8 +348,7 @@ INSTANTIATE_TEST_CASE_P(CompareTestCPU, CmpTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
/*init output matrices or not*/ testing::Bool()),
opencv_test::PrintCmpCoreParams());
/*init output matrices or not*/ testing::Bool()));
INSTANTIATE_TEST_CASE_P(BitwiseTestCPU, BitwiseTest,
Combine(Values(AND, OR, XOR),
@@ -367,8 +356,7 @@ INSTANTIATE_TEST_CASE_P(BitwiseTestCPU, BitwiseTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
/*init output matrices or not*/ testing::Bool()),
opencv_test::PrintBWCoreParams());
/*init output matrices or not*/ testing::Bool()));
INSTANTIATE_TEST_CASE_P(BitwiseNotTestCPU, NotTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
@@ -428,8 +416,7 @@ INSTANTIATE_TEST_CASE_P(NormTestCPU, NormTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128))),
Values(0.0),
opencv_test::PrintNormCoreParams());
Values(0.0));
INSTANTIATE_TEST_CASE_P(IntegralTestCPU, IntegralTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
@@ -12,7 +12,7 @@
namespace
{
#define IMGPROC_CPU [] () { return cv::compile_args(cv::gapi::imgproc::cpu::kernels()); }
#define IMGPROC_CPU [] () { return cv::compile_args(cv::gapi::imgproc::cpu::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -24,9 +24,8 @@ INSTANTIATE_TEST_CASE_P(Filter2DTestCPU, Filter2DTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 4, 5, 7),
Values(cv::BORDER_DEFAULT)));
@@ -35,9 +34,8 @@ INSTANTIATE_TEST_CASE_P(BoxFilterTestCPU, BoxFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsTolerance(0).to_compare_f()),
Values(AbsTolerance(0).to_compare_obj()),
Values(3,5),
Values(cv::BORDER_DEFAULT)));
@@ -46,9 +44,8 @@ INSTANTIATE_TEST_CASE_P(SepFilterTestCPU_8U, SepFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_16S, CV_32F),
testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3)));
INSTANTIATE_TEST_CASE_P(SepFilterTestCPU_other, SepFilterTest,
@@ -56,19 +53,17 @@ INSTANTIATE_TEST_CASE_P(SepFilterTestCPU_other, SepFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3)));
INSTANTIATE_TEST_CASE_P(BlurTestCPU, BlurTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_CPU),
Values(AbsTolerance(0.0).to_compare_f()),
Values(AbsTolerance(0.0).to_compare_obj()),
Values(3,5),
Values(cv::BORDER_DEFAULT)));
@@ -76,30 +71,27 @@ INSTANTIATE_TEST_CASE_P(gaussBlurTestCPU, GaussianBlurTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5)));
INSTANTIATE_TEST_CASE_P(MedianBlurTestCPU, MedianBlurTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5)));
INSTANTIATE_TEST_CASE_P(ErodeTestCPU, ErodeTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(cv::MorphShapes::MORPH_RECT,
cv::MorphShapes::MORPH_CROSS,
@@ -109,20 +101,18 @@ INSTANTIATE_TEST_CASE_P(Erode3x3TestCPU, Erode3x3Test,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(1,2,4)));
INSTANTIATE_TEST_CASE_P(DilateTestCPU, DilateTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(cv::MorphShapes::MORPH_RECT,
cv::MorphShapes::MORPH_CROSS,
@@ -132,10 +122,9 @@ INSTANTIATE_TEST_CASE_P(Dilate3x3TestCPU, Dilate3x3Test,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(1,2,4)));
INSTANTIATE_TEST_CASE_P(SobelTestCPU, SobelTest,
@@ -143,9 +132,8 @@ INSTANTIATE_TEST_CASE_P(SobelTestCPU, SobelTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_16S, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(0, 1),
Values(1, 2)));
@@ -155,9 +143,8 @@ INSTANTIATE_TEST_CASE_P(SobelTestCPU32F, SobelTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(0, 1),
Values(1, 2)));
@@ -167,9 +154,8 @@ INSTANTIATE_TEST_CASE_P(SobelXYTestCPU, SobelXYTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_16S, CV_32F),
Values(true),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(1, 2),
Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT),
@@ -180,9 +166,8 @@ INSTANTIATE_TEST_CASE_P(SobelXYTestCPU32F, SobelXYTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_32F),
Values(true),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(1, 2),
Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT),
@@ -193,18 +178,16 @@ INSTANTIATE_TEST_CASE_P(EqHistTestCPU, EqHistTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(CannyTestCPU, CannyTest,
Combine(Values(CV_8UC1, CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsSimilarPoints(0, 0.05).to_compare_f()),
Values(AbsSimilarPoints(0, 0.05).to_compare_obj()),
Values(3.0, 120.0),
Values(125.0, 240.0),
Values(3, 5),
@@ -215,142 +198,126 @@ INSTANTIATE_TEST_CASE_P(RGB2GrayTestCPU, RGB2GrayTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BGR2GrayTestCPU, BGR2GrayTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2YUVTestCPU, RGB2YUVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(YUV2RGBTestCPU, YUV2RGBTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(NV12toRGBTestCPU, NV12toRGBTest,
Combine(Values(CV_8UC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(NV12toBGRTestCPU, NV12toBGRTest,
Combine(Values(CV_8UC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(NV12toRGBpTestCPU, NV12toRGBpTest,
Combine(Values(CV_8UC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(NV12toBGRpTestCPU, NV12toBGRpTest,
Combine(Values(CV_8UC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2LabTestCPU, RGB2LabTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BGR2LUVTestCPU, BGR2LUVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(LUV2BGRTestCPU, LUV2BGRTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BGR2YUVTestCPU, BGR2YUVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(YUV2BGRTestCPU, YUV2BGRTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2HSVTestCPU, RGB2HSVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BayerGR2RGBTestCPU, BayerGR2RGBTest,
Combine(Values(CV_8UC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsExact().to_compare_f())));
Values(AbsExact().to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2YUV422TestCPU, RGB2YUV422Test,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC2),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_CPU),
Values(AbsTolerance(1).to_compare_f())));
Values(AbsTolerance(1).to_compare_obj())));
} // opencv_test
@@ -10,7 +10,7 @@
namespace
{
#define IMGPROC_FLUID [] () { return cv::compile_args(cv::gapi::imgproc::fluid::kernels()); }
#define IMGPROC_FLUID [] () { return cv::compile_args(cv::gapi::imgproc::fluid::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -21,45 +21,40 @@ INSTANTIATE_TEST_CASE_P(RGB2GrayTestFluid, RGB2GrayTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BGR2GrayTestFluid, BGR2GrayTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2YUVTestFluid, RGB2YUVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(YUV2RGBTestFluid, YUV2RGBTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2LabTestFluid, RGB2LabTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true, false),
Values(IMGPROC_FLUID),
Values(AbsSimilarPoints(1, 0.05).to_compare_f())));
Values(AbsSimilarPoints(1, 0.05).to_compare_obj())));
// FIXME: Not supported by Fluid yet (no kernel implemented)
INSTANTIATE_TEST_CASE_P(BGR2LUVTestFluid, BGR2LUVTest,
@@ -67,45 +62,40 @@ INSTANTIATE_TEST_CASE_P(BGR2LUVTestFluid, BGR2LUVTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceColor(5e-3, 6).to_compare_f())));
Values(ToleranceColor(5e-3, 6).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2HSVTestFluid, RGB2HSVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BayerGR2RGBTestFluid, BayerGR2RGBTest,
Combine(Values(CV_8UC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2YUV422TestFluid, RGB2YUV422Test,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC2),
Values(true, false),
Values(IMGPROC_FLUID),
Values(AbsTolerance(1).to_compare_f())));
Values(AbsTolerance(1).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(blurTestFluid, BlurTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
Values(true, false),
Values(-1),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3), // add kernel size=5 when implementation is ready
Values(cv::BORDER_DEFAULT)));
@@ -113,30 +103,27 @@ INSTANTIATE_TEST_CASE_P(gaussBlurTestFluid, GaussianBlurTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
Values(true, false),
Values(-1),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-3f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-3f, 0.01).to_compare_obj()),
Values(3))); // add kernel size=5 when implementation is ready
INSTANTIATE_TEST_CASE_P(medianBlurTestFluid, MedianBlurTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
Values(true, false),
Values(-1),
Values(IMGPROC_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3))); // add kernel size=5 when implementation is ready
INSTANTIATE_TEST_CASE_P(erodeTestFluid, ErodeTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
Values(true, false),
Values(-1),
Values(IMGPROC_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3), // add kernel size=5 when implementation is ready
Values(cv::MorphShapes::MORPH_RECT,
cv::MorphShapes::MORPH_CROSS,
@@ -146,10 +133,9 @@ INSTANTIATE_TEST_CASE_P(dilateTestFluid, DilateTest,
Combine(Values(CV_8UC1, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
Values(true, false),
Values(-1),
Values(IMGPROC_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3), // add kernel size=5 when implementation is ready
Values(cv::MorphShapes::MORPH_RECT,
cv::MorphShapes::MORPH_CROSS,
@@ -160,9 +146,8 @@ INSTANTIATE_TEST_CASE_P(SobelTestFluid, SobelTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_16S, CV_32F),
Values(true, false),
Values(IMGPROC_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3), // add kernel size=5 when implementation is ready
Values(0, 1),
Values(1, 2)));
@@ -172,9 +157,8 @@ INSTANTIATE_TEST_CASE_P(SobelTestFluid32F, SobelTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_32F),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3), // add kernel size=5 when implementation is ready
Values(0, 1),
Values(1, 2)));
@@ -184,9 +168,8 @@ INSTANTIATE_TEST_CASE_P(SobelXYTestFluid, SobelXYTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_16S, CV_32F),
Values(true),
Values(IMGPROC_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3),
Values(1, 2),
Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101),
@@ -197,9 +180,8 @@ INSTANTIATE_TEST_CASE_P(SobelXYTestFluid32F, SobelXYTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_32F),
Values(true),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3),
Values(1, 2),
Values(BORDER_CONSTANT, BORDER_REPLICATE, BORDER_REFLECT_101),
@@ -210,9 +192,8 @@ INSTANTIATE_TEST_CASE_P(boxFilterTestFluid32, BoxFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_32F),
Values(true, false),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3), // add kernel size=5 when implementation is ready
Values(cv::BORDER_DEFAULT)));
@@ -221,9 +202,8 @@ INSTANTIATE_TEST_CASE_P(sepFilterTestFluid, SepFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3))); // add kernel size=5 when implementation is ready
INSTANTIATE_TEST_CASE_P(filter2DTestFluid, Filter2DTest,
@@ -232,9 +212,8 @@ INSTANTIATE_TEST_CASE_P(filter2DTestFluid, Filter2DTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_FLUID),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3), // add kernel size=4,5,7 when implementation ready
Values(cv::BORDER_DEFAULT)));
@@ -11,7 +11,7 @@
namespace
{
#define CORE_CPU [] () { return cv::compile_args(cv::gapi::core::cpu::kernels()); }
#define CORE_CPU [] () { return cv::compile_args(cv::gapi::core::cpu::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -24,9 +24,8 @@ INSTANTIATE_TEST_CASE_P(MathOperatorTestCPU, MathOperatorMatMatTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
testing::Bool(),
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq)));
@@ -36,9 +35,8 @@ INSTANTIATE_TEST_CASE_P(MathOperatorTestCPU, MathOperatorMatScalarTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER)));
@@ -49,9 +47,8 @@ INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestCPU, MathOperatorMatMatTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opAnd, opOr, opXor )));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestCPU, MathOperatorMatScalarTest,
@@ -60,9 +57,8 @@ INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestCPU, MathOperatorMatScalarTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_CPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR )));
INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestCPU, NotOperatorTest,
@@ -70,7 +66,6 @@ INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestCPU, NotOperatorTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_CPU)));
}
@@ -10,7 +10,7 @@
namespace
{
#define CORE_FLUID [] () { return cv::compile_args(cv::gapi::core::fluid::kernels()); }
#define CORE_FLUID [] () { return cv::compile_args(cv::gapi::core::fluid::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -22,9 +22,8 @@ INSTANTIATE_TEST_CASE_P(MathOperatorTestFluid, MathOperatorMatMatTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq)));
@@ -35,9 +34,8 @@ INSTANTIATE_TEST_CASE_P(DISABLED_MathOperatorTestFluid, MathOperatorMatScalarTes
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER)));
@@ -48,9 +46,8 @@ INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestFluid, MathOperatorMatMatTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opAnd, opOr, opXor )));
//FIXME: Some Mat/Scalar Fluid kernels are not there yet!
@@ -60,9 +57,8 @@ INSTANTIATE_TEST_CASE_P(DISABLED_BitwiseOperatorTestFluid, MathOperatorMatScalar
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_FLUID),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR )));
INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestFluid, NotOperatorTest,
@@ -70,7 +66,6 @@ INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestFluid, NotOperatorTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_FLUID)));
}
@@ -0,0 +1,315 @@
// 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) 2019 Intel Corporation
#include "test_precomp.hpp"
#include "gapi_fluid_test_kernels.hpp"
namespace opencv_test
{
namespace {
cv::Mat randomMat(cv::Size img_sz, int type = CV_8UC1, cv::Scalar mean = cv::Scalar(127.0f), cv::Scalar stddev = cv::Scalar(40.f)){
cv::Mat mat(img_sz, type);
cv::randn(mat, mean, stddev);
return mat;
}
cv::GFluidParallelOutputRois asGFluidParallelOutputRois(const std::vector<cv::Rect>& rois){
cv::GFluidParallelOutputRois parallel_rois;
for (auto const& roi : rois) {
parallel_rois.parallel_rois.emplace_back(GFluidOutputRois{{to_own(roi)}});
}
return parallel_rois;
}
void adjust_empty_roi(cv::Rect& roi, cv::Size size){
if (roi.empty()) roi = cv::Rect{{0,0}, size};
}
cv::GCompileArgs combine(cv::GCompileArgs&& lhs, cv::GCompileArgs const& rhs){
lhs.insert(lhs.end(), rhs.begin(), rhs.end());
return std::move(lhs);
}
}
using namespace cv::gapi_test_kernels;
//As GTest can not simultaneously parameterize test with both types and values - lets use type-erasure and virtual interfaces
//to use different computation pipelines
struct ComputationPair {
void run_with_gapi(const cv::Mat& in_mat, cv::GCompileArgs const& compile_args, cv::Mat& out_mat){
run_with_gapi_impl(in_mat, combine(cv::compile_args(fluidTestPackage), compile_args), out_mat);
}
void run_with_gapi(const cv::Mat& in_mat, cv::GFluidParallelOutputRois const& parallel_rois, cv::Mat& out_mat){
run_with_gapi_impl(in_mat, cv::compile_args(fluidTestPackage, parallel_rois), out_mat);
}
virtual void run_with_ocv (const cv::Mat& in_mat, const std::vector<cv::Rect>& rois, cv::Mat& out_mat) = 0;
virtual std::string name() const { return {}; }
virtual ~ComputationPair () = default;
friend std::ostream& operator<<(std::ostream& o, ComputationPair const* cp){
std::string custom_name = cp->name();
return o << (custom_name.empty() ? typeid(cp).name() : custom_name );
}
private:
virtual void run_with_gapi_impl(const cv::Mat& in_mat, cv::GCompileArgs const& comp_args, cv::Mat& out_mat) = 0;
};
struct Blur3x3CP : ComputationPair{
static constexpr int borderType = BORDER_REPLICATE;
static constexpr int kernelSize = 3;
std::string name() const override { return "Blur3x3"; }
void run_with_gapi_impl(const cv::Mat& in_mat, cv::GCompileArgs const& comp_args, cv::Mat& out_mat_gapi) override {
cv::GMat in;
cv::GMat out = TBlur3x3::on(in, borderType, {});
cv::GComputation c(cv::GIn(in), cv::GOut(out));
// Run G-API
auto cc = c.compile(cv::descr_of(in_mat), comp_args);
cc(cv::gin(in_mat), cv::gout(out_mat_gapi));
}
void run_with_ocv(const cv::Mat& in_mat, const std::vector<cv::Rect>& rois, cv::Mat& out_mat_ocv) override {
cv::Point anchor = {-1, -1};
// Check with OpenCV
for (auto roi : rois) {
adjust_empty_roi(roi, in_mat.size());
cv::blur(in_mat(roi), out_mat_ocv(roi), {kernelSize, kernelSize}, anchor, borderType);
}
}
};
struct AddCCP : ComputationPair{
std::string name() const override { return "AddC"; }
void run_with_gapi_impl(const cv::Mat& in_mat, cv::GCompileArgs const& comp_args, cv::Mat& out_mat_gapi) override {
cv::GMat in;
cv::GMat out = TAddCSimple::on(in, 1);
cv::GComputation c(cv::GIn(in), cv::GOut(out));
// Run G-API
auto cc = c.compile(cv::descr_of(in_mat), comp_args);
cc(cv::gin(in_mat), cv::gout(out_mat_gapi));
}
void run_with_ocv(const cv::Mat& in_mat, const std::vector<cv::Rect>& rois, cv::Mat& out_mat_ocv) override {
// Check with OpenCV
for (auto roi : rois) {
adjust_empty_roi(roi, in_mat.size());
out_mat_ocv(roi) = in_mat(roi) + 1u;
}
}
};
template<BorderTypes _borderType>
struct SequenceOfBlursCP : ComputationPair{
BorderTypes borderType = _borderType;
std::string name() const override { return "SequenceOfBlurs, border type: " + std::to_string(static_cast<int>(borderType)); }
void run_with_gapi_impl(const cv::Mat& in_mat, cv::GCompileArgs const& comp_args, cv::Mat& out_mat) override {
cv::Scalar borderValue(0);
GMat in;
auto mid = TBlur3x3::on(in, borderType, borderValue);
auto out = TBlur5x5::on(mid, borderType, borderValue);
GComputation c(GIn(in), GOut(out));
auto cc = c.compile(descr_of(in_mat), comp_args);
cc(cv::gin(in_mat), cv::gout(out_mat));
}
void run_with_ocv(const cv::Mat& in_mat, const std::vector<cv::Rect>& rois, cv::Mat& out_mat) override {
cv::Mat mid_mat_ocv = Mat::zeros(in_mat.size(), in_mat.type());
cv::Point anchor = {-1, -1};
for (auto roi : rois) {
adjust_empty_roi(roi, in_mat.size());
cv::blur(in_mat, mid_mat_ocv, {3,3}, anchor, borderType);
cv::blur(mid_mat_ocv(roi), out_mat(roi), {5,5}, anchor, borderType);
}
}
};
struct TiledComputation : public TestWithParam <std::tuple<ComputationPair*, cv::Size, std::vector<cv::Rect>, decltype(cv::GFluidParallelFor::parallel_for)>> {};
TEST_P(TiledComputation, Test)
{
ComputationPair* cp;
cv::Size img_sz;
std::vector<cv::Rect> rois ;
decltype(cv::GFluidParallelFor::parallel_for) pfor;
auto mat_type = CV_8UC1;
std::tie(cp, img_sz, rois, pfor) = GetParam();
cv::Mat in_mat = randomMat(img_sz, mat_type);
cv::Mat out_mat_gapi = cv::Mat::zeros(img_sz, mat_type);
cv::Mat out_mat_ocv = cv::Mat::zeros(img_sz, mat_type);
auto comp_args = combine(cv::compile_args(asGFluidParallelOutputRois(rois)), pfor ? cv::compile_args(cv::GFluidParallelFor{pfor}) : cv::GCompileArgs{});
cp->run_with_gapi(in_mat, comp_args, out_mat_gapi);
cp->run_with_ocv (in_mat, rois, out_mat_ocv);
EXPECT_EQ(0, cv::countNonZero(out_mat_gapi != out_mat_ocv))
<< "in_mat : \n" << in_mat << std::endl
<< "diff matrix :\n " << (out_mat_gapi != out_mat_ocv) << std::endl
<< "out_mat_gapi: \n" << out_mat_gapi << std::endl
<< "out_mat_ocv: \n" << out_mat_ocv << std::endl;;
}
namespace {
//this is ugly but other variants (like using shared_ptr) are IMHO even more ugly :)
template<typename T, typename... Arg>
T* addr_of_static(Arg... arg) {
static T obj(std::forward<Arg>(arg)...);
return &obj;
}
}
auto single_arg_computations = [](){
return Values( addr_of_static<Blur3x3CP>(),
addr_of_static<AddCCP>(),
addr_of_static<SequenceOfBlursCP<BORDER_CONSTANT>>(),
addr_of_static<SequenceOfBlursCP<BORDER_REPLICATE>>(),
addr_of_static<SequenceOfBlursCP<BORDER_REFLECT_101>>()
);
};
auto tilesets_8x10 = [](){
return Values(std::vector<cv::Rect>{cv::Rect{}},
std::vector<cv::Rect>{cv::Rect{0,0,8,5}, cv::Rect{0,5,8,5}},
std::vector<cv::Rect>{cv::Rect{0,1,8,3}, cv::Rect{0,4,8,3}},
std::vector<cv::Rect>{cv::Rect{0,2,8,3}, cv::Rect{0,5,8,2}},
std::vector<cv::Rect>{cv::Rect{0,3,8,4}, cv::Rect{0,9,8,1}});
};
auto tilesets_20x15 = [](){
return Values(std::vector<cv::Rect>{cv::Rect{}},
std::vector<cv::Rect>{cv::Rect{{0,0},cv::Size{20,7}},
cv::Rect{{0,7},cv::Size{20,8}}});
};
auto tilesets_320x240 = [](){
return Values(std::vector<cv::Rect>{cv::Rect{{0,0}, cv::Size{320,120}},
cv::Rect{{0,120}, cv::Size{320,120}}},
std::vector<cv::Rect>{cv::Rect{{0,0}, cv::Size{320,120}},
cv::Rect{{0,120}, cv::Size{320,120}}},
std::vector<cv::Rect>{cv::Rect{{0,0}, cv::Size{320,60}},
cv::Rect{{0,60}, cv::Size{320,60}},
cv::Rect{{0,120},cv::Size{320,120}}});
};
namespace{
auto no_custom_pfor = decltype(cv::GFluidParallelFor::parallel_for){};
}
INSTANTIATE_TEST_CASE_P(FluidTiledSerial8x10, TiledComputation,
Combine(
single_arg_computations(),
Values(cv::Size(8, 10)),
tilesets_8x10(),
Values(no_custom_pfor))
);
INSTANTIATE_TEST_CASE_P(FluidTiledSerial20x15, TiledComputation,
Combine(
single_arg_computations(),
Values(cv::Size(20, 15)),
tilesets_20x15(),
Values(no_custom_pfor))
);
INSTANTIATE_TEST_CASE_P(FluidTiledSerial320x240, TiledComputation,
Combine(
single_arg_computations(),
Values(cv::Size(320, 240)),
tilesets_320x240(),
Values(no_custom_pfor))
);
//FIXME: add multiple outputs tests
TEST(FluidTiledParallelFor, basic)
{
cv::Size img_sz{8,20};
auto mat_type = CV_8UC1;
cv::GMat in;
cv::GMat out = TAddCSimple::on(in, 1);
cv::GComputation c(cv::GIn(in), cv::GOut(out));
cv::Mat in_mat = randomMat(img_sz, mat_type);
cv::Mat out_mat_gapi = cv::Mat::zeros(img_sz, mat_type);
auto parallel_rois = asGFluidParallelOutputRois( std::vector<cv::Rect>{cv::Rect{0,0,8,5}, cv::Rect{0,5,8,5}});
std::size_t items_count = 0;
auto pfor = [&items_count](std::size_t count, std::function<void(std::size_t)> ){
items_count = count;
};
// Run G-API
auto cc = c.compile(cv::descr_of(in_mat), cv::compile_args(fluidTestPackage, parallel_rois, GFluidParallelFor{pfor}));
cc(cv::gin(in_mat), cv::gout(out_mat_gapi));
ASSERT_EQ(parallel_rois.parallel_rois.size(), items_count);
}
namespace {
auto serial_for = [](std::size_t count, std::function<void(std::size_t)> f){
for (std::size_t i = 0; i < count; ++i){
f(i);
}
};
auto cv_parallel_for = [](std::size_t count, std::function<void(std::size_t)> f){
cv::parallel_for_(cv::Range(0, static_cast<int>(count)), [f](const cv::Range& r){
for (auto i = r.start; i < r.end; ++i){
f(i);
} });
};
}
INSTANTIATE_TEST_CASE_P(FluidTiledParallel8x10, TiledComputation,
Combine(
single_arg_computations(),
Values(cv::Size(8, 10)),
tilesets_8x10(),
Values(serial_for, cv_parallel_for))
);
} // namespace opencv_test
//define custom printer for "parallel_for" test parameter
namespace std {
void PrintTo(decltype(cv::GFluidParallelFor::parallel_for) const& f, std::ostream* o);
}
//separate declaration and definition are needed to please the compiler
void std::PrintTo(decltype(cv::GFluidParallelFor::parallel_for) const& f, std::ostream* o){
if (f) {
using namespace opencv_test;
if (f.target<decltype(serial_for)>()){
*o <<"serial_for";
}
else if (f.target<decltype(cv_parallel_for)>()){
*o <<"cv_parallel_for";
}
else {
*o <<"parallel_for of type: " << f.target_type().name();
}
}
else
{
*o << "default parallel_for";
}
}
@@ -9,6 +9,7 @@
#include <iomanip>
#include "gapi_fluid_test_kernels.hpp"
#include <opencv2/gapi/core.hpp>
#include <opencv2/gapi/own/saturate.hpp>
namespace cv
{
@@ -72,7 +73,8 @@ GAPI_FLUID_KERNEL(FAddCSimple, TAddCSimple, false)
for (int i = 0, w = in.length(); i < w; i++)
{
//std::cout << std::setw(4) << int(in_row[i]);
out_row[i] = static_cast<uint8_t>(in_row[i] + cval);
//FIXME: it seems that over kernels might need it as well
out_row[i] = cv::gapi::own::saturate<uint8_t>(in_row[i] + cval);
}
//std::cout << std::endl;
}
+64 -58
View File
@@ -8,6 +8,9 @@
#include "test_precomp.hpp"
#include "opencv2/gapi/gtransform.hpp"
#include "opencv2/gapi/gtype_traits.hpp"
// explicit include to use GComputation::Priv
#include "api/gcomputation_priv.hpp"
namespace opencv_test
{
@@ -68,6 +71,12 @@ GAPI_TRANSFORM(gmat_in_garr_out, <GArray<int>(GMat)>, "gmat_in_garr_out")
static GArray<int> substitute(GMat) { return {}; }
};
GAPI_TRANSFORM(gmat_gsc_garray_in_gmat2_out, <GMat2(GMat, GScalar, GArray<int>)>, "gmat_gsc_garray_in_gmat2_out")
{
static GMat2 pattern(GMat, GScalar, GArray<int>) { return {}; }
static GMat2 substitute(GMat, GScalar, GArray<int>) { return {}; }
};
} // anonymous namespace
TEST(KernelPackageTransform, CreatePackage)
@@ -76,12 +85,16 @@ TEST(KernelPackageTransform, CreatePackage)
< gmat_in_gmat_out
, gmat2_in_gmat_out
, gmat2_in_gmat3_out
, gmatp_in_gmatp_out
, gsc_in_gmat_out
, gmat_in_gsc_out
, garr_in_gmat_out
, gmat_in_garr_out
, gmat_gsc_garray_in_gmat2_out
>();
auto tr = pkg.get_transformations();
EXPECT_EQ(5u, tr.size());
EXPECT_EQ(9u, tr.size());
}
TEST(KernelPackageTransform, Include)
@@ -103,81 +116,74 @@ TEST(KernelPackageTransform, Combine)
EXPECT_EQ(2u, tr.size());
}
TEST(KernelPackageTransform, Pattern)
{
auto tr = gmat2_in_gmat3_out::transformation();
GMat a, b;
auto pattern = tr.pattern({cv::GArg(a), cv::GArg(b)});
// return type of '2gmat_in_gmat3_out' is GMat3
EXPECT_EQ(3u, pattern.size());
for (const auto& p : pattern)
{
EXPECT_NO_THROW(p.get<GMat>());
namespace {
template <typename T>
inline bool ProtoContainsT(const cv::GProtoArg &arg) {
return cv::GProtoArg::index_of<T>() == arg.index();
}
}
} // anonymous namespace
TEST(KernelPackageTransform, Substitute)
TEST(KernelPackageTransform, gmat_gsc_in_gmat_out)
{
auto tr = gmat2_in_gmat3_out::transformation();
GMat a, b;
auto subst = tr.substitute({cv::GArg(a), cv::GArg(b)});
auto tr = gmat_gsc_garray_in_gmat2_out::transformation();
EXPECT_EQ(3u, subst.size());
for (const auto& s : subst)
{
EXPECT_NO_THROW(s.get<GMat>());
}
}
auto check = [](const cv::GComputation &comp){
const auto &p = comp.priv();
EXPECT_EQ(3u, p.m_ins.size());
EXPECT_EQ(2u, p.m_outs.size());
template <typename Transformation, typename InType, typename OutType>
static void transformTest()
{
auto tr = Transformation::transformation();
InType in;
auto pattern = tr.pattern({cv::GArg(in)});
auto subst = tr.substitute({cv::GArg(in)});
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_ins[0]));
EXPECT_TRUE(ProtoContainsT<GScalar>(p.m_ins[1]));
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_ins[2]));
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_ins[2]).holds<int>());
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_ins[2]).holds<char>());
EXPECT_EQ(1u, pattern.size());
EXPECT_EQ(1u, subst.size());
auto checkOut = [](GArg& garg) {
EXPECT_TRUE(garg.kind == cv::detail::GTypeTraits<OutType>::kind);
EXPECT_NO_THROW(garg.get<OutType>());
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[0]));
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[1]));
};
checkOut(pattern[0]);
checkOut(subst[0]);
check(tr.pattern());
check(tr.substitute());
}
TEST(KernelPackageTransform, GMat)
TEST(KernelPackageTransform, gmat_in_garr_out)
{
transformTest<gmat_in_gmat_out, GMat, GMat>();
auto tr = gmat_in_garr_out::transformation();
auto check = [](const cv::GComputation &comp){
const auto &p = comp.priv();
EXPECT_EQ(1u, p.m_ins.size());
EXPECT_EQ(1u, p.m_outs.size());
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_ins[0]));
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_outs[0]));
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_outs[0]).holds<int>());
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_outs[0]).holds<float>());
};
check(tr.pattern());
check(tr.substitute());
}
TEST(KernelPackageTransform, GMatP)
TEST(KernelPackageTransform, garr_in_gmat_out)
{
transformTest<gmatp_in_gmatp_out, GMatP, GMatP>();
}
auto tr = garr_in_gmat_out::transformation();
TEST(KernelPackageTransform, GScalarIn)
{
transformTest<gsc_in_gmat_out, GScalar, GMat>();
}
auto check = [](const cv::GComputation &comp){
const auto &p = comp.priv();
EXPECT_EQ(1u, p.m_ins.size());
EXPECT_EQ(1u, p.m_outs.size());
TEST(KernelPackageTransform, GScalarOut)
{
transformTest<gmat_in_gsc_out, GMat, GScalar>();
}
EXPECT_TRUE(ProtoContainsT<cv::detail::GArrayU>(p.m_ins[0]));
EXPECT_TRUE(cv::util::get<cv::detail::GArrayU>(p.m_ins[0]).holds<int>());
EXPECT_FALSE(cv::util::get<cv::detail::GArrayU>(p.m_ins[0]).holds<bool>());
TEST(KernelPackageTransform, DISABLED_GArrayIn)
{
transformTest<garr_in_gmat_out, GArray<int>, GMat>();
}
EXPECT_TRUE(ProtoContainsT<GMat>(p.m_outs[0]));
};
TEST(KernelPackageTransform, DISABLED_GArrayOut)
{
transformTest<gmat_in_garr_out, GMat, GArray<int>>();
check(tr.pattern());
check(tr.substitute());
}
} // namespace opencv_test
+54 -79
View File
@@ -10,7 +10,7 @@
namespace
{
#define CORE_GPU [] () { return cv::compile_args(cv::gapi::core::gpu::kernels()); }
#define CORE_GPU [] () { return cv::compile_args(cv::gapi::core::gpu::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -23,13 +23,11 @@ INSTANTIATE_TEST_CASE_P(AddTestGPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(ADD, MUL),
testing::Bool(),
Values(1.0),
Values(false)),
opencv_test::PrintMathOpCoreParams());
Values(false)));
INSTANTIATE_TEST_CASE_P(MulTestGPU, MathOpTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -37,13 +35,11 @@ INSTANTIATE_TEST_CASE_P(MulTestGPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(MUL),
testing::Bool(),
Values(1.0, 0.5, 2.0),
Values(false)),
opencv_test::PrintMathOpCoreParams());
Values(false)));
INSTANTIATE_TEST_CASE_P(SubTestGPU, MathOpTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -51,13 +47,11 @@ INSTANTIATE_TEST_CASE_P(SubTestGPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(SUB),
testing::Bool(),
Values (1.0),
testing::Bool()),
opencv_test::PrintMathOpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(DivTestGPU, MathOpTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -65,13 +59,11 @@ INSTANTIATE_TEST_CASE_P(DivTestGPU, MathOpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(DIV),
testing::Bool(),
Values (1.0, 0.5, 2.0),
testing::Bool()),
opencv_test::PrintMathOpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(MulTestGPU, MulDoubleTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -79,7 +71,6 @@ INSTANTIATE_TEST_CASE_P(MulTestGPU, MulDoubleTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(DivTestGPU, DivTest,
@@ -88,7 +79,6 @@ INSTANTIATE_TEST_CASE_P(DivTestGPU, DivTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(DivCTestGPU, DivCTest,
@@ -97,7 +87,6 @@ INSTANTIATE_TEST_CASE_P(DivCTestGPU, DivCTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(MeanTestGPU, MeanTest,
@@ -105,8 +94,7 @@ INSTANTIATE_TEST_CASE_P(MeanTestGPU, MeanTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
//TODO: mask test doesn't work
@@ -116,7 +104,6 @@ INSTANTIATE_TEST_CASE_P(MaskTestGPU, MaskTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU)));
#endif
@@ -125,8 +112,7 @@ INSTANTIATE_TEST_CASE_P(SelectTestGPU, SelectTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(Polar2CartGPU, Polar2CartTest,
@@ -135,7 +121,6 @@ INSTANTIATE_TEST_CASE_P(Polar2CartGPU, Polar2CartTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_32FC1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(Cart2PolarGPU, Cart2PolarTest,
@@ -144,7 +129,6 @@ INSTANTIATE_TEST_CASE_P(Cart2PolarGPU, Cart2PolarTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_32FC1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(CompareTestGPU, CmpTest,
@@ -153,30 +137,25 @@ INSTANTIATE_TEST_CASE_P(CompareTestGPU, CmpTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8U),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(CMP_EQ, CMP_GE, CMP_NE, CMP_GT, CMP_LT, CMP_LE),
testing::Bool()),
opencv_test::PrintCmpCoreParams());
testing::Bool()));
INSTANTIATE_TEST_CASE_P(BitwiseTestGPU, BitwiseTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU),
Values(AND, OR, XOR)),
opencv_test::PrintBWCoreParams());
Values(AND, OR, XOR)));
INSTANTIATE_TEST_CASE_P(BitwiseNotTestGPU, NotTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(MinTestGPU, MinTest,
@@ -184,8 +163,7 @@ INSTANTIATE_TEST_CASE_P(MinTestGPU, MinTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(MaxTestGPU, MaxTest,
@@ -193,8 +171,7 @@ INSTANTIATE_TEST_CASE_P(MaxTestGPU, MaxTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(SumTestGPU, SumTest,
@@ -202,18 +179,16 @@ INSTANTIATE_TEST_CASE_P(SumTestGPU, SumTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU),
Values(AbsToleranceScalar(1e-3).to_compare_f())));//TODO: too relaxed?
Values(AbsToleranceScalar(1e-3).to_compare_obj())));//TODO: too relaxed?
INSTANTIATE_TEST_CASE_P(AbsDiffTestGPU, AbsDiffTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(AbsDiffCTestGPU, AbsDiffCTest,
@@ -221,8 +196,7 @@ INSTANTIATE_TEST_CASE_P(AbsDiffCTestGPU, AbsDiffCTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(AddWeightedTestGPU, AddWeightedTest,
@@ -231,21 +205,18 @@ INSTANTIATE_TEST_CASE_P(AddWeightedTestGPU, AddWeightedTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values( -1, CV_8U, CV_16U, CV_32F ),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_f())));
Values(Tolerance_FloatRel_IntAbs(1e-6, 1).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(NormTestGPU, NormTest,
Combine(Values( CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1 ),
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
Values(-1),
Values(CORE_GPU),
Values(AbsToleranceScalar(1e-3).to_compare_f()), //TODO: too relaxed?
Values(NORM_INF, NORM_L1, NORM_L2)),
opencv_test::PrintNormCoreParams());
Values(AbsToleranceScalar(1e-3).to_compare_obj()), //TODO: too relaxed?
Values(NORM_INF, NORM_L1, NORM_L2)));
INSTANTIATE_TEST_CASE_P(IntegralTestGPU, IntegralTest,
Combine(Values( CV_8UC1, CV_16UC1, CV_16SC1, CV_32FC1 ),
@@ -253,7 +224,6 @@ INSTANTIATE_TEST_CASE_P(IntegralTestGPU, IntegralTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(false),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(ThresholdTestGPU, ThresholdTest,
@@ -261,8 +231,7 @@ INSTANTIATE_TEST_CASE_P(ThresholdTestGPU, ThresholdTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU),
Values(cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC,
cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)));
@@ -272,8 +241,7 @@ INSTANTIATE_TEST_CASE_P(ThresholdTestGPU, ThresholdOTTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU),
Values(cv::THRESH_OTSU, cv::THRESH_TRIANGLE)));
@@ -283,8 +251,7 @@ INSTANTIATE_TEST_CASE_P(InRangeTestGPU, InRangeTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(Split3TestGPU, Split3Test,
@@ -293,7 +260,6 @@ INSTANTIATE_TEST_CASE_P(Split3TestGPU, Split3Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
Values(true),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(Split4TestGPU, Split4Test,
@@ -302,7 +268,6 @@ INSTANTIATE_TEST_CASE_P(Split4TestGPU, Split4Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
Values(true),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(ResizeTestGPU, ResizeTest,
@@ -311,9 +276,8 @@ INSTANTIATE_TEST_CASE_P(ResizeTestGPU, ResizeTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(false),
Values(CORE_GPU),
Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(AbsSimilarPoints(2, 0.05).to_compare_obj()),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(cv::Size(64,64),
cv::Size(30,30))));
@@ -324,9 +288,8 @@ INSTANTIATE_TEST_CASE_P(ResizeTestGPU, ResizeTestFxFy,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
Values(false),
Values(CORE_GPU),
Values(AbsSimilarPoints(2, 0.05).to_compare_f()),
Values(AbsSimilarPoints(2, 0.05).to_compare_obj()),
Values(cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_AREA),
Values(0.5, 0.1),
Values(0.5, 0.1)));
@@ -337,7 +300,6 @@ INSTANTIATE_TEST_CASE_P(Merge3TestGPU, Merge3Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC3),
Values(true),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(Merge4TestGPU, Merge4Test,
@@ -346,7 +308,6 @@ INSTANTIATE_TEST_CASE_P(Merge4TestGPU, Merge4Test,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC4),
Values(true),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(RemapTestGPU, RemapTest,
@@ -354,8 +315,7 @@ INSTANTIATE_TEST_CASE_P(RemapTestGPU, RemapTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(FlipTestGPU, FlipTest,
@@ -363,8 +323,7 @@ INSTANTIATE_TEST_CASE_P(FlipTestGPU, FlipTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ Values(false),
Values(-1),
Values(CORE_GPU),
Values(0,1,-1)));
@@ -373,8 +332,7 @@ INSTANTIATE_TEST_CASE_P(CropTestGPU, CropTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ Values(false),
Values(-1),
Values(CORE_GPU),
Values(cv::Rect(10, 8, 20, 35), cv::Rect(4, 10, 37, 50))));
@@ -384,7 +342,6 @@ INSTANTIATE_TEST_CASE_P(LUTTestGPU, LUTTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC1),
/*init output matrices or not*/ Values(true),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(LUTTestCustomGPU, LUTTest,
@@ -393,7 +350,6 @@ INSTANTIATE_TEST_CASE_P(LUTTestCustomGPU, LUTTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8UC3),
/*init output matrices or not*/ Values(true),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(ConvertToGPU, ConvertToTest,
@@ -402,9 +358,8 @@ INSTANTIATE_TEST_CASE_P(ConvertToGPU, ConvertToTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(CV_8U, CV_16U, CV_16S, CV_32F),
Values(false),
Values(CORE_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(2.5, 1.0, -1.0),
Values(250.0, 0.0, -128.0)));
@@ -413,8 +368,7 @@ INSTANTIATE_TEST_CASE_P(ConcatHorTestGPU, ConcatHorTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(ConcatVertTestGPU, ConcatVertTest,
@@ -422,10 +376,31 @@ INSTANTIATE_TEST_CASE_P(ConcatVertTestGPU, ConcatVertTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
Values(false),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(BackendOutputAllocationTestGPU, BackendOutputAllocationTest,
Combine(Values(CV_8UC3, CV_16SC2, CV_32FC1),
Values(cv::Size(50, 50)),
Values(-1),
Values(CORE_GPU)));
// FIXME: there's an issue in OCL backend with matrix reallocation that shouldn't happen
INSTANTIATE_TEST_CASE_P(DISABLED_BackendOutputAllocationLargeSizeWithCorrectSubmatrixTestGPU,
BackendOutputAllocationLargeSizeWithCorrectSubmatrixTest,
Combine(Values(CV_8UC3, CV_16SC2, CV_32FC1),
Values(cv::Size(50, 50)),
Values(-1),
Values(CORE_GPU)));
INSTANTIATE_TEST_CASE_P(ReInitOutTestGPU, ReInitOutTest,
Combine(Values(CV_8UC3, CV_16SC4, CV_32FC1),
Values(cv::Size(640, 480)),
Values(-1),
Values(CORE_GPU),
Values(cv::Size(640, 400),
cv::Size(10, 480))));
//TODO: fix this backend to allow ConcatVertVec ConcatHorVec
#if 0
INSTANTIATE_TEST_CASE_P(ConcatVertVecTestGPU, ConcatVertVecTest,
@@ -11,7 +11,7 @@
namespace
{
#define IMGPROC_GPU [] () { return cv::compile_args(cv::gapi::imgproc::gpu::kernels()); }
#define IMGPROC_GPU [] () { return cv::compile_args(cv::gapi::imgproc::gpu::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -23,9 +23,8 @@ INSTANTIATE_TEST_CASE_P(Filter2DTestGPU, Filter2DTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_obj()),
Values(3, 4, 5, 7),
Values(cv::BORDER_DEFAULT)));
@@ -34,9 +33,8 @@ INSTANTIATE_TEST_CASE_P(BoxFilterTestCPU, BoxFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_obj()),
Values(3,5),
Values(cv::BORDER_DEFAULT))); //TODO: 8UC1 doesn't work
@@ -46,9 +44,8 @@ INSTANTIATE_TEST_CASE_P(SepFilterTestGPU_8U, SepFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_16S, CV_32F),
testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3)));
INSTANTIATE_TEST_CASE_P(SepFilterTestGPU_other, SepFilterTest,
@@ -56,19 +53,17 @@ INSTANTIATE_TEST_CASE_P(SepFilterTestGPU_other, SepFilterTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_32F),
testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-4f, 0.01).to_compare_obj()),
Values(3)));
INSTANTIATE_TEST_CASE_P(BlurTestGPU, BlurTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_obj()),
Values(3,5),
Values(cv::BORDER_DEFAULT)));
@@ -76,30 +71,27 @@ INSTANTIATE_TEST_CASE_P(gaussBlurTestGPU, GaussianBlurTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(ToleranceFilter(1e-5f, 0.01).to_compare_f()),
Values(ToleranceFilter(1e-5f, 0.01).to_compare_obj()),
Values(3))); // FIXIT 5
INSTANTIATE_TEST_CASE_P(MedianBlurTestGPU, MedianBlurTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5)));
INSTANTIATE_TEST_CASE_P(ErodeTestGPU, ErodeTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(cv::MorphShapes::MORPH_RECT,
cv::MorphShapes::MORPH_CROSS,
@@ -109,20 +101,18 @@ INSTANTIATE_TEST_CASE_P(Erode3x3TestGPU, Erode3x3Test,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(1,2,4)));
INSTANTIATE_TEST_CASE_P(DilateTestGPU, DilateTest,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(3, 5),
Values(cv::MorphShapes::MORPH_RECT,
cv::MorphShapes::MORPH_CROSS,
@@ -132,10 +122,9 @@ INSTANTIATE_TEST_CASE_P(Dilate3x3TestGPU, Dilate3x3Test,
Combine(Values(CV_8UC1, CV_8UC3, CV_16UC1, CV_16SC1, CV_32FC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values(1,2,4)));
INSTANTIATE_TEST_CASE_P(SobelTestGPU, SobelTest,
@@ -143,9 +132,8 @@ INSTANTIATE_TEST_CASE_P(SobelTestGPU, SobelTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(-1, CV_16S, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_obj()),
Values(3, 5),
Values(0, 1),
Values(1, 2)));
@@ -155,9 +143,8 @@ INSTANTIATE_TEST_CASE_P(SobelTestGPU32F, SobelTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_obj()),
Values(3, 5),
Values(0, 1),
Values(1, 2)));
@@ -166,19 +153,17 @@ INSTANTIATE_TEST_CASE_P(EqHistTestGPU, EqHistTest,
Combine(Values(CV_8UC1),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(IMGPROC_GPU),
Values(AbsExact().to_compare_f()))); // FIXIT Non reliable check
Values(AbsExact().to_compare_obj()))); // FIXIT Non reliable check
INSTANTIATE_TEST_CASE_P(CannyTestGPU, CannyTest,
Combine(Values(CV_8UC1, CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(AbsSimilarPoints(0, 0.05).to_compare_f()),
Values(AbsSimilarPoints(0, 0.05).to_compare_obj()),
Values(3.0, 120.0),
Values(125.0, 240.0),
Values(3, 5),
@@ -189,80 +174,71 @@ INSTANTIATE_TEST_CASE_P(RGB2GrayTestGPU, RGB2GrayTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BGR2GrayTestGPU, BGR2GrayTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC1),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2YUVTestGPU, RGB2YUVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(YUV2RGBTestGPU, YUV2RGBTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(RGB2LabTestGPU, RGB2LabTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(AbsSimilarPoints(1, 0.05).to_compare_f())));
Values(AbsSimilarPoints(1, 0.05).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BGR2LUVTestGPU, BGR2LUVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(5e-3, 6).to_compare_f())));
Values(ToleranceColor(5e-3, 6).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(LUV2BGRTestGPU, LUV2BGRTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(BGR2YUVTestGPU, BGR2YUVTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
INSTANTIATE_TEST_CASE_P(YUV2BGRTestGPU, YUV2BGRTest,
Combine(Values(CV_8UC3),
Values(cv::Size(1280, 720),
cv::Size(640, 480)),
Values(CV_8UC3),
/*init output matrices or not*/ testing::Bool(),
Values(IMGPROC_GPU),
Values(ToleranceColor(1e-3).to_compare_f())));
Values(ToleranceColor(1e-3).to_compare_obj())));
} // opencv_test
@@ -10,7 +10,7 @@
namespace
{
#define CORE_GPU [] () { return cv::compile_args(cv::gapi::core::gpu::kernels()); }
#define CORE_GPU [] () { return cv::compile_args(cv::gapi::core::gpu::kernels()); }
} // anonymous namespace
namespace opencv_test
@@ -22,9 +22,8 @@ INSTANTIATE_TEST_CASE_P(MathOperatorTestGPU, MathOperatorMatMatTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
testing::Bool(),
Values(CORE_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-5, 2).to_compare_obj()),
Values( opPlusM, opMinusM, opDivM,
opGreater, opLess, opGreaterEq, opLessEq, opEq, opNotEq)));
@@ -34,9 +33,8 @@ INSTANTIATE_TEST_CASE_P(MathOperatorTestGPU, MathOperatorMatScalarTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1, CV_8U, CV_32F),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_f()),
Values(Tolerance_FloatRel_IntAbs(1e-4, 2).to_compare_obj()),
Values( opPlus, opPlusR, opMinus, opMinusR, opMul, opMulR, // FIXIT avoid division by values near zero: opDiv, opDivR,
opGT, opLT, opGE, opLE, opEQ, opNE,
opGTR, opLTR, opGER, opLER, opEQR, opNER)));
@@ -47,9 +45,8 @@ INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestGPU, MathOperatorMatMatTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opAnd, opOr, opXor )));
INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestGPU, MathOperatorMatScalarTest,
@@ -58,9 +55,8 @@ INSTANTIATE_TEST_CASE_P(BitwiseOperatorTestGPU, MathOperatorMatScalarTest,
cv::Size(640, 480),
cv::Size(128, 128)),
Values(-1),
/*init output matrices or not*/ testing::Bool(),
Values(CORE_GPU),
Values(AbsExact().to_compare_f()),
Values(AbsExact().to_compare_obj()),
Values( opAND, opOR, opXOR, opANDR, opORR, opXORR )));
INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestGPU, NotOperatorTest,
@@ -68,7 +64,6 @@ INSTANTIATE_TEST_CASE_P(BitwiseNotOperatorTestGPU, NotOperatorTest,
Values(cv::Size(1280, 720),
cv::Size(640, 480),
cv::Size(128, 128)),
Values(SAME_TYPE),
/*init output matrices or not*/ testing::Bool(),
Values(-1),
Values(CORE_GPU)));
}
+9 -5
View File
@@ -723,21 +723,25 @@ bool imwrite( const String& filename, InputArray _img,
static bool
imdecode_( const Mat& buf, int flags, Mat& mat )
{
CV_Assert(!buf.empty() && buf.isContinuous());
CV_Assert(!buf.empty());
CV_Assert(buf.isContinuous());
CV_Assert(buf.checkVector(1, CV_8U) > 0);
Mat buf_row = buf.reshape(1, 1); // decoders expects single row, avoid issues with vector columns
String filename;
ImageDecoder decoder = findDecoder(buf);
ImageDecoder decoder = findDecoder(buf_row);
if( !decoder )
return 0;
if( !decoder->setSource(buf) )
if( !decoder->setSource(buf_row) )
{
filename = tempfile();
FILE* f = fopen( filename.c_str(), "wb" );
if( !f )
return 0;
size_t bufSize = buf.cols*buf.rows*buf.elemSize();
if( fwrite( buf.ptr(), 1, bufSize, f ) != bufSize )
size_t bufSize = buf_row.total()*buf.elemSize();
if (fwrite(buf_row.ptr(), 1, bufSize, f) != bufSize)
{
fclose( f );
CV_Error( Error::StsError, "failed to write image data to temporary file" );
+4 -3
View File
@@ -84,6 +84,7 @@ Ptr<BaseFilter> getLinearFilter(
#ifndef CV_CPU_OPTIMIZATION_DECLARATIONS_ONLY
typedef int CV_DECL_ALIGNED(1) unaligned_int;
#define VEC_ALIGN CV_MALLOC_ALIGN
int FilterEngine__start(FilterEngine& this_, const Size &_wholeSize, const Size &sz, const Point &ofs)
@@ -1049,7 +1050,7 @@ struct SymmColumnVec_32s8u
s0 = v_muladd(v_cvt_f32(v_load(src[k] + i) + v_load(src[-k] + i)), v_setall_f32(ky[k]), s0);
v_int32x4 s32 = v_round(s0);
v_int16x8 s16 = v_pack(s32, s32);
*(int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();
*(unaligned_int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();
i += v_int32x4::nlanes;
}
}
@@ -1104,7 +1105,7 @@ struct SymmColumnVec_32s8u
s0 = v_muladd(v_cvt_f32(v_load(src[k] + i) - v_load(src[-k] + i)), v_setall_f32(ky[k]), s0);
v_int32x4 s32 = v_round(s0);
v_int16x8 s16 = v_pack(s32, s32);
*(int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();
*(unaligned_int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();
i += v_int32x4::nlanes;
}
}
@@ -2129,7 +2130,7 @@ struct FilterVec_8u
s0 = v_muladd(v_cvt_f32(v_reinterpret_as_s32(v_load_expand_q(src[k] + i))), v_setall_f32(kf[k]), s0);
v_int32x4 s32 = v_round(s0);
v_int16x8 s16 = v_pack(s32, s32);
*(int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();
*(unaligned_int*)(dst + i) = v_reinterpret_as_s32(v_pack_u(s16, s16)).get0();
i += v_int32x4::nlanes;
}
return i;
+16 -16
View File
@@ -334,7 +334,7 @@ void hlineSmooth3Naba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const
{
int src_idx = borderInterpolate(-1, len, borderType);
for (int k = 0; k < cn; k++)
((uint16_t*)dst)[k] = ((uint16_t*)m)[1] * src[k] + ((uint16_t*)m)[0] * ((uint16_t)(src[cn + k]) + (uint16_t)(src[src_idx*cn + k]));
((uint16_t*)dst)[k] = saturate_cast<uint16_t>(((uint16_t*)m)[1] * (uint32_t)(src[k]) + ((uint16_t*)m)[0] * ((uint32_t)(src[cn + k]) + (uint32_t)(src[src_idx*cn + k])));
}
else
{
@@ -354,14 +354,14 @@ void hlineSmooth3Naba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, const
v_mul_wrap(vx_load_expand(src), v_mul1));
#endif
for (; i < lencn; i++, src++, dst++)
*((uint16_t*)dst) = ((uint16_t*)m)[1] * src[0] + ((uint16_t*)m)[0] * ((uint16_t)(src[-cn]) + (uint16_t)(src[cn]));
*((uint16_t*)dst) = saturate_cast<uint16_t>(((uint16_t*)m)[1] * (uint32_t)(src[0]) + ((uint16_t*)m)[0] * ((uint32_t)(src[-cn]) + (uint32_t)(src[cn])));
// Point that fall right from border
if (borderType != BORDER_CONSTANT)// If BORDER_CONSTANT out of border values are equal to zero and could be skipped
{
int src_idx = (borderInterpolate(len, len, borderType) - (len - 1))*cn;
for (int k = 0; k < cn; k++)
((uint16_t*)dst)[k] = ((uint16_t*)m)[1] * src[k] + ((uint16_t*)m)[0] * ((uint16_t)(src[k - cn]) + (uint16_t)(src[src_idx + k]));
((uint16_t*)dst)[k] = saturate_cast<uint16_t>(((uint16_t*)m)[1] * (uint32_t)(src[k]) + ((uint16_t*)m)[0] * ((uint32_t)(src[k - cn]) + (uint32_t)(src[src_idx + k])));
}
else
{
@@ -896,8 +896,8 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
int idxp2 = borderInterpolate(3, len, borderType)*cn;
for (int k = 0; k < cn; k++)
{
((uint16_t*)dst)[k] = ((uint16_t*)m)[1] * ((uint16_t)(src[k + idxm1]) + (uint16_t)(src[k + cn])) + ((uint16_t*)m)[2] * src[k] + ((uint16_t*)m)[0] * ((uint16_t)(src[k + idxp1]) + (uint16_t)(src[k + idxm2]));
((uint16_t*)dst)[k + cn] = ((uint16_t*)m)[0] * ((uint16_t)(src[k + idxm1]) + (uint16_t)(src[k + idxp2])) + ((uint16_t*)m)[1] * ((uint16_t)(src[k]) + (uint16_t)(src[k + idxp1])) + ((uint16_t*)m)[2] * src[k + cn];
((uint16_t*)dst)[k] = saturate_cast<uint16_t>(((uint16_t*)m)[1] * ((uint32_t)(src[k + idxm1]) + (uint32_t)(src[k + cn])) + ((uint16_t*)m)[2] * (uint32_t)(src[k]) + ((uint16_t*)m)[0] * ((uint32_t)(src[k + idxp1]) + (uint32_t)(src[k + idxm2])));
((uint16_t*)dst)[k + cn] = saturate_cast<uint16_t>(((uint16_t*)m)[0] * ((uint32_t)(src[k + idxm1]) + (uint32_t)(src[k + idxp2])) + ((uint16_t*)m)[1] * ((uint32_t)(src[k]) + (uint32_t)(src[k + idxp1])) + ((uint16_t*)m)[2] * (uint32_t)(src[k + cn]));
}
}
}
@@ -907,7 +907,7 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
for (int k = 0; k < cn; k++)
{
dst[k] = m[2] * src[k] + m[1] * src[k + cn] + m[0] * src[k + 2 * cn];
((uint16_t*)dst)[k + cn] = ((uint16_t*)m)[1] * ((uint16_t)(src[k]) + (uint16_t)(src[k + 2 * cn])) + ((uint16_t*)m)[2] * src[k + cn];
((uint16_t*)dst)[k + cn] = saturate_cast<uint16_t>(((uint16_t*)m)[1] * ((uint32_t)(src[k]) + (uint32_t)(src[k + 2 * cn])) + ((uint16_t*)m)[2] * (uint32_t)(src[k + cn]));
dst[k + 2 * cn] = m[0] * src[k] + m[1] * src[k + cn] + m[2] * src[k + 2 * cn];
}
else
@@ -918,9 +918,9 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
int idxp2 = borderInterpolate(4, len, borderType)*cn;
for (int k = 0; k < cn; k++)
{
((uint16_t*)dst)[k] = ((uint16_t*)m)[2] * src[k] + ((uint16_t*)m)[1] * ((uint16_t)(src[k + cn]) + (uint16_t)(src[k + idxm1])) + ((uint16_t*)m)[0] * ((uint16_t)(src[k + 2 * cn]) + (uint16_t)(src[k + idxm2]));
((uint16_t*)dst)[k + cn] = ((uint16_t*)m)[2] * src[k + cn] + ((uint16_t*)m)[1] * ((uint16_t)(src[k]) + (uint16_t)(src[k + 2 * cn])) + ((uint16_t*)m)[0] * ((uint16_t)(src[k + idxm1]) + (uint16_t)(src[k + idxp1]));
((uint16_t*)dst)[k + 2 * cn] = ((uint16_t*)m)[0] * ((uint16_t)(src[k]) + (uint16_t)(src[k + idxp2])) + ((uint16_t*)m)[1] * ((uint16_t)(src[k + cn]) + (uint16_t)(src[k + idxp1])) + ((uint16_t*)m)[2] * src[k + 2 * cn];
((uint16_t*)dst)[k] = saturate_cast<uint16_t>(((uint16_t*)m)[2] * (uint32_t)(src[k]) + ((uint16_t*)m)[1] * ((uint32_t)(src[k + cn]) + (uint32_t)(src[k + idxm1])) + ((uint16_t*)m)[0] * ((uint32_t)(src[k + 2 * cn]) + (uint32_t)(src[k + idxm2])));
((uint16_t*)dst)[k + cn] = saturate_cast<uint16_t>(((uint16_t*)m)[2] * (uint32_t)(src[k + cn]) + ((uint16_t*)m)[1] * ((uint32_t)(src[k]) + (uint32_t)(src[k + 2 * cn])) + ((uint16_t*)m)[0] * ((uint32_t)(src[k + idxm1]) + (uint32_t)(src[k + idxp1])));
((uint16_t*)dst)[k + 2 * cn] = saturate_cast<uint16_t>(((uint16_t*)m)[0] * ((uint32_t)(src[k]) + (uint32_t)(src[k + idxp2])) + ((uint16_t*)m)[1] * ((uint32_t)(src[k + cn]) + (uint32_t)(src[k + idxp1])) + ((uint16_t*)m)[2] * (uint32_t)(src[k + 2 * cn]));
}
}
}
@@ -933,8 +933,8 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
int idxm1 = borderInterpolate(-1, len, borderType)*cn;
for (int k = 0; k < cn; k++)
{
((uint16_t*)dst)[k] = ((uint16_t*)m)[2] * src[k] + ((uint16_t*)m)[1] * ((uint16_t)(src[cn + k]) + (uint16_t)(src[idxm1 + k])) + ((uint16_t*)m)[0] * ((uint16_t)(src[2 * cn + k]) + (uint16_t)(src[idxm2 + k]));
((uint16_t*)dst)[k + cn] = ((uint16_t*)m)[1] * ((uint16_t)(src[k]) + (uint16_t)(src[2 * cn + k])) + ((uint16_t*)m)[2] * src[cn + k] + ((uint16_t*)m)[0] * ((uint16_t)(src[3 * cn + k]) + (uint16_t)(src[idxm1 + k]));
((uint16_t*)dst)[k] = saturate_cast<uint16_t>(((uint16_t*)m)[2] * (uint32_t)(src[k]) + ((uint16_t*)m)[1] * ((uint32_t)(src[cn + k]) + (uint32_t)(src[idxm1 + k])) + ((uint16_t*)m)[0] * ((uint32_t)(src[2 * cn + k]) + (uint32_t)(src[idxm2 + k])));
((uint16_t*)dst)[k + cn] = saturate_cast<uint16_t>(((uint16_t*)m)[1] * ((uint32_t)(src[k]) + (uint32_t)(src[2 * cn + k])) + ((uint16_t*)m)[2] * (uint32_t)(src[cn + k]) + ((uint16_t*)m)[0] * ((uint32_t)(src[3 * cn + k]) + (uint32_t)(src[idxm1 + k])));
}
}
else
@@ -942,7 +942,7 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
for (int k = 0; k < cn; k++)
{
dst[k] = m[2] * src[k] + m[1] * src[cn + k] + m[0] * src[2 * cn + k];
((uint16_t*)dst)[k + cn] = ((uint16_t*)m)[1] * ((uint16_t)(src[k]) + (uint16_t)(src[2 * cn + k])) + ((uint16_t*)m)[2] * src[cn + k] + ((uint16_t*)m)[0] * src[3 * cn + k];
((uint16_t*)dst)[k + cn] = saturate_cast<uint16_t>(((uint16_t*)m)[1] * ((uint32_t)(src[k]) + (uint32_t)(src[2 * cn + k])) + ((uint16_t*)m)[2] * (uint32_t)(src[cn + k]) + ((uint16_t*)m)[0] * (uint32_t)(src[3 * cn + k]));
}
}
@@ -960,7 +960,7 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
v_mul_wrap(vx_load_expand(src), v_mul2));
#endif
for (; i < lencn; i++, src++, dst++)
*((uint16_t*)dst) = ((uint16_t*)m)[0] * ((uint16_t)(src[-2 * cn]) + (uint16_t)(src[2 * cn])) + ((uint16_t*)m)[1] * ((uint16_t)(src[-cn]) + (uint16_t)(src[cn])) + ((uint16_t*)m)[2] * src[0];
*((uint16_t*)dst) = saturate_cast<uint16_t>(((uint16_t*)m)[0] * ((uint32_t)(src[-2 * cn]) + (uint32_t)(src[2 * cn])) + ((uint16_t*)m)[1] * ((uint32_t)(src[-cn]) + (uint32_t)(src[cn])) + ((uint16_t*)m)[2] * (uint32_t)(src[0]));
// Points that fall right from border
if (borderType != BORDER_CONSTANT)// If BORDER_CONSTANT out of border values are equal to zero and could be skipped
@@ -969,15 +969,15 @@ void hlineSmooth5Nabcba<uint8_t, ufixedpoint16>(const uint8_t* src, int cn, cons
int idxp2 = (borderInterpolate(len + 1, len, borderType) - (len - 2))*cn;
for (int k = 0; k < cn; k++)
{
((uint16_t*)dst)[k] = ((uint16_t*)m)[0] * ((uint16_t)(src[k - 2 * cn]) + (uint16_t)(src[idxp1 + k])) + ((uint16_t*)m)[1] * ((uint16_t)(src[k - cn]) + (uint16_t)(src[k + cn])) + ((uint16_t*)m)[2] * src[k];
((uint16_t*)dst)[k + cn] = ((uint16_t*)m)[0] * ((uint16_t)(src[k - cn]) + (uint16_t)(src[idxp2 + k])) + ((uint16_t*)m)[1] * ((uint16_t)(src[k]) + (uint16_t)(src[idxp1 + k])) + ((uint16_t*)m)[2] * src[k + cn];
((uint16_t*)dst)[k] = saturate_cast<uint16_t>(((uint16_t*)m)[0] * ((uint32_t)(src[k - 2 * cn]) + (uint32_t)(src[idxp1 + k])) + ((uint16_t*)m)[1] * ((uint32_t)(src[k - cn]) + (uint32_t)(src[k + cn])) + ((uint16_t*)m)[2] * (uint32_t)(src[k]));
((uint16_t*)dst)[k + cn] = saturate_cast<uint16_t>(((uint16_t*)m)[0] * ((uint32_t)(src[k - cn]) + (uint32_t)(src[idxp2 + k])) + ((uint16_t*)m)[1] * ((uint32_t)(src[k]) + (uint32_t)(src[idxp1 + k])) + ((uint16_t*)m)[2] * (uint32_t)(src[k + cn]));
}
}
else
{
for (int k = 0; k < cn; k++)
{
((uint16_t*)dst)[k] = ((uint16_t*)m)[0] * src[k - 2 * cn] + ((uint16_t*)m)[1] * ((uint16_t)(src[k - cn]) + (uint16_t)(src[k + cn])) + ((uint16_t*)m)[2] * src[k];
((uint16_t*)dst)[k] = saturate_cast<uint16_t>(((uint16_t*)m)[0] * (uint32_t)(src[k - 2 * cn]) + ((uint16_t*)m)[1] * ((uint32_t)(src[k - cn]) + (uint32_t)(src[k + cn])) + ((uint16_t*)m)[2] * (uint32_t)(src[k]));
dst[k + cn] = m[0] * src[k - cn] + m[1] * src[k] + m[2] * src[k + cn];
}
}
+22 -4
View File
@@ -1142,6 +1142,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
const int N = 256;
int i, j, h[N] = {0};
#if CV_ENABLE_UNROLLED
int h_unrolled[3][N] = {};
#endif
for( i = 0; i < size.height; i++ )
{
const uchar* src = _src.ptr() + step*i;
@@ -1150,9 +1153,9 @@ getThreshVal_Otsu_8u( const Mat& _src )
for( ; j <= size.width - 4; j += 4 )
{
int v0 = src[j], v1 = src[j+1];
h[v0]++; h[v1]++;
h[v0]++; h_unrolled[0][v1]++;
v0 = src[j+2]; v1 = src[j+3];
h[v0]++; h[v1]++;
h_unrolled[1][v0]++; h_unrolled[2][v1]++;
}
#endif
for( ; j < size.width; j++ )
@@ -1161,7 +1164,12 @@ getThreshVal_Otsu_8u( const Mat& _src )
double mu = 0, scale = 1./(size.width*size.height);
for( i = 0; i < N; i++ )
{
#if CV_ENABLE_UNROLLED
h[i] += h_unrolled[0][i] + h_unrolled[1][i] + h_unrolled[2][i];
#endif
mu += i*(double)h[i];
}
mu *= scale;
double mu1 = 0, q1 = 0;
@@ -1206,6 +1214,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
const int N = 256;
int i, j, h[N] = {0};
#if CV_ENABLE_UNROLLED
int h_unrolled[3][N] = {};
#endif
for( i = 0; i < size.height; i++ )
{
const uchar* src = _src.ptr() + step*i;
@@ -1214,9 +1225,9 @@ getThreshVal_Triangle_8u( const Mat& _src )
for( ; j <= size.width - 4; j += 4 )
{
int v0 = src[j], v1 = src[j+1];
h[v0]++; h[v1]++;
h[v0]++; h_unrolled[0][v1]++;
v0 = src[j+2]; v1 = src[j+3];
h[v0]++; h[v1]++;
h_unrolled[1][v0]++; h_unrolled[2][v1]++;
}
#endif
for( ; j < size.width; j++ )
@@ -1227,6 +1238,13 @@ getThreshVal_Triangle_8u( const Mat& _src )
int temp;
bool isflipped = false;
#if CV_ENABLE_UNROLLED
for( i = 0; i < N; i++ )
{
h[i] += h_unrolled[0][i] + h_unrolled[1][i] + h_unrolled[2][i];
}
#endif
for( i = 0; i < N; i++ )
{
if( h[i] > 0 )
+2 -2
View File
@@ -294,14 +294,14 @@ OCL_TEST_P(CvtColor8u, GRAY2BGR555) { performTest(1, 2, CVTCODE(GRAY2BGR555)); }
// RGBA <-> mRGBA
#ifdef HAVE_IPP
#if defined(HAVE_IPP) || defined(__arm__)
#define IPP_EPS depth <= CV_32S ? 1 : 1e-3
#else
#define IPP_EPS 1e-3
#endif
OCL_TEST_P(CvtColor8u, RGBA2mRGBA) { performTest(4, 4, CVTCODE(RGBA2mRGBA), IPP_EPS); }
OCL_TEST_P(CvtColor8u, mRGBA2RGBA) { performTest(4, 4, CVTCODE(mRGBA2RGBA)); }
OCL_TEST_P(CvtColor8u, mRGBA2RGBA) { performTest(4, 4, CVTCODE(mRGBA2RGBA), IPP_EPS); }
// RGB <-> Lab
@@ -158,4 +158,12 @@ TEST(GaussianBlur_Bitexact, Linear8U)
}
}
TEST(GaussianBlur_Bitexact, regression_15015)
{
Mat src(100,100,CV_8UC3,Scalar(255,255,255));
Mat dst;
GaussianBlur(src, dst, Size(5, 5), 9);
ASSERT_EQ(0.0, cvtest::norm(dst, src, NORM_INF));
}
}} // namespace
+10
View File
@@ -123,6 +123,16 @@ foreach(file ${seed_project_files_rel})
endif()
endforeach()
# copy libcxx_helper
set(__base_dir "${CMAKE_CURRENT_SOURCE_DIR}/")
file(GLOB_RECURSE __files_rel RELATIVE "${__base_dir}/" "${__base_dir}/libcxx_helper/*")
foreach(file ${__files_rel})
configure_file("${__base_dir}/${file}" "${OPENCV_JAVA_DIR}/${file}" @ONLY)
list(APPEND depends "${__base_dir}/${file}")
get_filename_component(install_subdir "${file}" PATH)
install(FILES "${OPENCV_JAVA_DIR}/${file}" DESTINATION "${JAVA_INSTALL_ROOT}/../${install_subdir}" COMPONENT java)
endforeach()
list(APPEND depends gen_opencv_java_source "${OPENCV_DEPHELPER}/gen_opencv_java_source")
ocv_copyfiles_add_target(${the_module}_android_source_copy JAVA_SRC_COPY "Copy Java(Andoid SDK) source files" ${depends})
file(REMOVE "${OPENCV_DEPHELPER}/${the_module}_android_source_copy") # force rebuild after CMake run
@@ -7,6 +7,13 @@ android {
defaultConfig {
minSdkVersion @ANDROID_MIN_SDK_VERSION@
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=@ANDROID_STL@"
targets "opencv_jni_shared"
}
}
}
buildTypes {
@@ -37,6 +44,12 @@ android {
manifest.srcFile 'AndroidManifest.xml'
}
}
externalNativeBuild {
cmake {
path (project.projectDir.toString() + '/libcxx_helper/CMakeLists.txt')
}
}
}
dependencies {
+13
View File
@@ -99,6 +99,13 @@ android {
defaultConfig {
minSdkVersion @ANDROID_MIN_SDK_VERSION@
targetSdkVersion @ANDROID_TARGET_SDK_VERSION@
externalNativeBuild {
cmake {
arguments "-DANDROID_STL=@ANDROID_STL@"
targets "opencv_jni_shared"
}
}
}
buildTypes {
@@ -129,6 +136,12 @@ android {
manifest.srcFile 'java/AndroidManifest.xml'
}
}
externalNativeBuild {
cmake {
path (project.projectDir.toString() + '/libcxx_helper/CMakeLists.txt')
}
}
}
dependencies {
@@ -0,0 +1,4 @@
cmake_minimum_required(VERSION 3.6)
# dummy target to bring libc++_shared.so into packages
add_library(opencv_jni_shared STATIC dummy.cpp)
@@ -0,0 +1 @@
// empty
@@ -2,6 +2,7 @@ package org.opencv.android;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.List;
import android.annotation.TargetApi;
import android.content.Context;
@@ -24,6 +25,7 @@ import android.view.ViewGroup.LayoutParams;
import org.opencv.core.CvType;
import org.opencv.core.Mat;
import org.opencv.core.Size;
import org.opencv.imgproc.Imgproc;
/**
@@ -248,6 +250,20 @@ public class JavaCamera2View extends CameraBridgeViewBase {
}
}
public static class JavaCameraSizeAccessor implements ListItemAccessor {
@Override
public int getWidth(Object obj) {
android.util.Size size = (android.util.Size)obj;
return size.getWidth();
}
@Override
public int getHeight(Object obj) {
android.util.Size size = (android.util.Size)obj;
return size.getHeight();
}
}
boolean calcPreviewSize(final int width, final int height) {
Log.i(LOGTAG, "calcPreviewSize: " + width + "x" + height);
if (mCameraID == null) {
@@ -258,26 +274,15 @@ public class JavaCamera2View extends CameraBridgeViewBase {
try {
CameraCharacteristics characteristics = manager.getCameraCharacteristics(mCameraID);
StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
int bestWidth = 0, bestHeight = 0;
float aspect = (float) width / height;
android.util.Size[] sizes = map.getOutputSizes(ImageReader.class);
bestWidth = sizes[0].getWidth();
bestHeight = sizes[0].getHeight();
for (android.util.Size sz : sizes) {
int w = sz.getWidth(), h = sz.getHeight();
Log.d(LOGTAG, "trying size: " + w + "x" + h);
if (width >= w && height >= h && bestWidth <= w && bestHeight <= h
&& Math.abs(aspect - (float) w / h) < 0.2) {
bestWidth = w;
bestHeight = h;
}
}
Log.i(LOGTAG, "best size: " + bestWidth + "x" + bestHeight);
assert(!(bestWidth == 0 || bestHeight == 0));
if (mPreviewSize.getWidth() == bestWidth && mPreviewSize.getHeight() == bestHeight)
List<android.util.Size> sizes_list = Arrays.asList(sizes);
Size frameSize = calculateCameraFrameSize(sizes_list, new JavaCameraSizeAccessor(), width, height);
Log.i(LOGTAG, "Selected preview size to " + Integer.valueOf((int)frameSize.width) + "x" + Integer.valueOf((int)frameSize.height));
assert(!(frameSize.width == 0 || frameSize.height == 0));
if (mPreviewSize.getWidth() == frameSize.width && mPreviewSize.getHeight() == frameSize.height)
return false;
else {
mPreviewSize = new android.util.Size(bestWidth, bestHeight);
mPreviewSize = new android.util.Size((int)frameSize.width, (int)frameSize.height);
return true;
}
} catch (CameraAccessException e) {
@@ -0,0 +1,60 @@
package org.opencv.android;
import android.annotation.TargetApi;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
import java.util.ArrayList;
import java.util.List;
import static android.Manifest.permission.CAMERA;
public class CameraActivity extends Activity {
private static final int CAMERA_PERMISSION_REQUEST_CODE = 200;
protected List<? extends CameraBridgeViewBase> getCameraViewList() {
return new ArrayList<CameraBridgeViewBase>();
}
protected void onCameraPermissionGranted() {
List<? extends CameraBridgeViewBase> cameraViews = getCameraViewList();
if (cameraViews == null) {
return;
}
for (CameraBridgeViewBase cameraBridgeViewBase: cameraViews) {
if (cameraBridgeViewBase != null) {
cameraBridgeViewBase.setCameraPermissionGranted();
}
}
}
@Override
protected void onStart() {
super.onStart();
boolean havePermission = true;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
if (checkSelfPermission(CAMERA) != PackageManager.PERMISSION_GRANTED) {
requestPermissions(new String[]{CAMERA}, CAMERA_PERMISSION_REQUEST_CODE);
havePermission = false;
}
}
if (havePermission) {
onCameraPermissionGranted();
}
}
@Override
@TargetApi(Build.VERSION_CODES.M)
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
if (requestCode == CAMERA_PERMISSION_REQUEST_CODE && grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
onCameraPermissionGranted();
}
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
}
}
@@ -30,7 +30,7 @@ import android.view.SurfaceView;
public abstract class CameraBridgeViewBase extends SurfaceView implements SurfaceHolder.Callback {
private static final String TAG = "CameraBridge";
private static final int MAX_UNSPECIFIED = -1;
protected static final int MAX_UNSPECIFIED = -1;
private static final int STOPPED = 0;
private static final int STARTED = 1;
@@ -48,6 +48,7 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
protected int mPreviewFormat = RGBA;
protected int mCameraIndex = CAMERA_ID_ANY;
protected boolean mEnabled;
protected boolean mCameraPermissionGranted = false;
protected FpsMeter mFpsMeter = null;
public static final int CAMERA_ID_ANY = -1;
@@ -219,9 +220,24 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
}
}
/**
* This method is provided for clients, so they can signal camera permission has been granted.
* The actual onCameraViewStarted callback will be delivered only after setCameraPermissionGranted
* and enableView have been called and surface is available
*/
public void setCameraPermissionGranted() {
synchronized(mSyncObject) {
mCameraPermissionGranted = true;
checkCurrentState();
}
}
/**
* This method is provided for clients, so they can enable the camera connection.
* The actual onCameraViewStarted callback will be delivered only after both this method is called and surface is available
* The actual onCameraViewStarted callback will be delivered only after setCameraPermissionGranted
* and enableView have been called and surface is available
*/
public void enableView() {
synchronized(mSyncObject) {
@@ -300,7 +316,7 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
Log.d(TAG, "call checkCurrentState");
int targetState;
if (mEnabled && mSurfaceExist && getVisibility() == VISIBLE) {
if (mEnabled && mCameraPermissionGranted && mSurfaceExist && getVisibility() == VISIBLE) {
targetState = STARTED;
} else {
targetState = STOPPED;
@@ -481,6 +497,7 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
for (Object size : supportedSizes) {
int width = accessor.getWidth(size);
int height = accessor.getHeight(size);
Log.d(TAG, "trying size: " + width + "x" + height);
if (width <= maxAllowedWidth && height <= maxAllowedHeight) {
if (width >= calcWidth && height >= calcHeight) {
@@ -489,6 +506,13 @@ public abstract class CameraBridgeViewBase extends SurfaceView implements Surfac
}
}
}
if ((calcWidth == 0 || calcHeight == 0) && supportedSizes.size() > 0)
{
Log.i(TAG, "fallback to the first frame size");
Object size = supportedSizes.get(0);
calcWidth = accessor.getWidth(size);
calcHeight = accessor.getHeight(size);
}
return new Size(calcWidth, calcHeight);
}
+4 -4
View File
@@ -141,7 +141,7 @@ features2d = {'Feature2D': ['detect', 'compute', 'detectAndCompute', 'descriptor
'AKAZE': ['create', 'setDescriptorType', 'getDescriptorType', 'setDescriptorSize', 'getDescriptorSize', 'setDescriptorChannels', 'getDescriptorChannels', 'setThreshold', 'getThreshold', 'setNOctaves', 'getNOctaves', 'setNOctaveLayers', 'getNOctaveLayers', 'setDiffusivity', 'getDiffusivity', 'getDefaultName'],
'DescriptorMatcher': ['add', 'clear', 'empty', 'isMaskSupported', 'train', 'match', 'knnMatch', 'radiusMatch', 'clone', 'create'],
'BFMatcher': ['isMaskSupported', 'create'],
'': ['drawKeypoints', 'drawMatches']}
'': ['drawKeypoints', 'drawMatches', 'drawMatchesKnn']}
photo = {'': ['createAlignMTB', 'createCalibrateDebevec', 'createCalibrateRobertson', \
'createMergeDebevec', 'createMergeMertens', 'createMergeRobertson', \
@@ -164,14 +164,14 @@ photo = {'': ['createAlignMTB', 'createCalibrateDebevec', 'createCalibrateRobert
'getColorAdaptation', 'setColorAdaptation']
}
aruco = {'': ['detectMarkers', 'drawDetectedMarkers', 'drawAxis', 'estimatePoseSingleMarkers', 'estimatePoseBoard', 'interpolateCornersCharuco', 'drawDetectedCornersCharuco'],
aruco = {'': ['detectMarkers', 'drawDetectedMarkers', 'drawAxis', 'estimatePoseSingleMarkers', 'estimatePoseBoard', 'estimatePoseCharucoBoard', 'interpolateCornersCharuco', 'drawDetectedCornersCharuco'],
'aruco_Dictionary': ['get', 'drawMarker'],
'aruco_Board': ['create'],
'aruco_GridBoard': ['create', 'draw'],
'aruco_CharucoBoard': ['create', 'draw'],
}
calib3d = {'': ['findHomography']}
calib3d = {'': ['findHomography','calibrateCameraExtended', 'drawFrameAxes', 'getDefaultNewCameraMatrix', 'initUndistortRectifyMap']}
def makeWhiteList(module_list):
wl = {}
@@ -590,7 +590,7 @@ class JSWrapperGenerator(object):
match = re.search(r'const std::vector<(.*)>&', arg_type)
if match:
type_in_vect = match.group(1)
if type_in_vect != 'cv::Mat':
if type_in_vect in ['int', 'float', 'double', 'char', 'uchar', 'String', 'std::string']:
casted_arg_name = 'emscripten::vecFromJSArray<' + type_in_vect + '>(' + arg_name + ')'
arg_type = re.sub(r'std::vector<(.*)>', 'emscripten::val', arg_type)
w_signature.append(arg_type + ' ' + arg_name)
+33
View File
@@ -80,3 +80,36 @@ QUnit.test('BFMatcher', function(assert) {
assert.equal(dm.size(), 67);
});
QUnit.test('Drawing', function(assert) {
// Generate key points.
let image = generateTestFrame();
let kp = new cv.KeyPointVector();
let descriptors = new cv.Mat();
let orb = new cv.ORB();
orb.detectAndCompute(image, new cv.Mat(), kp, descriptors);
assert.equal(kp.size(), 67);
let dst = new cv.Mat();
cv.drawKeypoints(image, kp, dst);
assert.equal(dst.rows, image.rows);
assert.equal(dst.cols, image.cols);
// Run a matcher.
let dm = new cv.DMatchVector();
let matcher = new cv.BFMatcher();
matcher.match(descriptors, descriptors, dm);
assert.equal(dm.size(), 67);
cv.drawMatches(image, kp, image, kp, dm, dst);
assert.equal(dst.rows, image.rows);
assert.equal(dst.cols, 2 * image.cols);
dm = new cv.DMatchVectorVector();
matcher.knnMatch(descriptors, descriptors, dm, 2);
assert.equal(dm.size(), 67);
cv.drawMatchesKnn(image, kp, image, kp, dm, dst);
assert.equal(dst.rows, image.rows);
assert.equal(dst.cols, 2 * image.cols);
});
+37 -6
View File
@@ -46,6 +46,10 @@
#include "cascadedetect.hpp"
#include "opencl_kernels_objdetect.hpp"
#if defined(_MSC_VER)
# pragma warning(disable:4458) // declaration of 'origWinSize' hides class member
#endif
namespace cv
{
@@ -536,7 +540,7 @@ bool FeatureEvaluator::setImage( InputArray _image, const std::vector<float>& _s
//---------------------------------------------- HaarEvaluator ---------------------------------------
bool HaarEvaluator::Feature :: read( const FileNode& node )
bool HaarEvaluator::Feature::read(const FileNode& node, const Size& origWinSize)
{
FileNode rnode = node[CC_RECTS];
FileNodeIterator it = rnode.begin(), it_end = rnode.end();
@@ -548,11 +552,23 @@ bool HaarEvaluator::Feature :: read( const FileNode& node )
rect[ri].weight = 0.f;
}
const int W = origWinSize.width;
const int H = origWinSize.height;
for(ri = 0; it != it_end; ++it, ri++)
{
FileNodeIterator it2 = (*it).begin();
it2 >> rect[ri].r.x >> rect[ri].r.y >>
rect[ri].r.width >> rect[ri].r.height >> rect[ri].weight;
Feature::RectWeigth& rw = rect[ri];
it2 >> rw.r.x >> rw.r.y >> rw.r.width >> rw.r.height >> rw.weight;
// input validation
{
CV_CheckGE(rw.r.x, 0, "Invalid HAAR feature");
CV_CheckGE(rw.r.y, 0, "Invalid HAAR feature");
CV_CheckLT(rw.r.x, W, "Invalid HAAR feature"); // necessary for overflow checks
CV_CheckLT(rw.r.y, H, "Invalid HAAR feature"); // necessary for overflow checks
CV_CheckLE(rw.r.x + rw.r.width, W, "Invalid HAAR feature");
CV_CheckLE(rw.r.y + rw.r.height, H, "Invalid HAAR feature");
}
}
tilted = (int)node[CC_TILTED] != 0;
@@ -597,7 +613,7 @@ bool HaarEvaluator::read(const FileNode& node, Size _origWinSize)
for(i = 0; i < n; i++, ++it)
{
if(!ff[i].read(*it))
if(!ff[i].read(*it, _origWinSize))
return false;
if( ff[i].tilted )
hasTiltedFeatures = true;
@@ -758,11 +774,24 @@ int HaarEvaluator::getSquaresOffset() const
}
//---------------------------------------------- LBPEvaluator -------------------------------------
bool LBPEvaluator::Feature :: read(const FileNode& node )
bool LBPEvaluator::Feature::read(const FileNode& node, const Size& origWinSize)
{
FileNode rnode = node[CC_RECT];
FileNodeIterator it = rnode.begin();
it >> rect.x >> rect.y >> rect.width >> rect.height;
const int W = origWinSize.width;
const int H = origWinSize.height;
// input validation
{
CV_CheckGE(rect.x, 0, "Invalid LBP feature");
CV_CheckGE(rect.y, 0, "Invalid LBP feature");
CV_CheckLT(rect.x, W, "Invalid LBP feature");
CV_CheckLT(rect.y, H, "Invalid LBP feature");
CV_CheckLE(rect.x + rect.width, W, "Invalid LBP feature");
CV_CheckLE(rect.y + rect.height, H, "Invalid LBP feature");
}
return true;
}
@@ -796,7 +825,7 @@ bool LBPEvaluator::read( const FileNode& node, Size _origWinSize )
std::vector<Feature>& ff = *features;
for(int i = 0; it != it_end; ++it, i++)
{
if(!ff[i].read(*it))
if(!ff[i].read(*it, _origWinSize))
return false;
}
nchannels = 1;
@@ -1441,6 +1470,8 @@ bool CascadeClassifierImpl::Data::read(const FileNode &root)
origWinSize.width = (int)root[CC_WIDTH];
origWinSize.height = (int)root[CC_HEIGHT];
CV_Assert( origWinSize.height > 0 && origWinSize.width > 0 );
CV_CheckLE(origWinSize.width, 1000000, "Invalid window size (too large)");
CV_CheckLE(origWinSize.height, 1000000, "Invalid window size (too large)");
// load feature params
FileNode fn = root[CC_FEATURE_PARAMS];
+3 -3
View File
@@ -317,12 +317,12 @@ public:
struct Feature
{
Feature();
bool read( const FileNode& node );
bool read(const FileNode& node, const Size& origWinSize);
bool tilted;
enum { RECT_NUM = 3 };
struct
struct RectWeigth
{
Rect r;
float weight;
@@ -412,7 +412,7 @@ public:
Feature( int x, int y, int _block_w, int _block_h ) :
rect(x, y, _block_w, _block_h) {}
bool read(const FileNode& node );
bool read(const FileNode& node, const Size& origWinSize);
Rect rect; // weight and height for block
};
+1 -1
View File
@@ -55,7 +55,7 @@ Ptr<SeamFinder> SeamFinder::createDefault(int type)
return makePtr<VoronoiSeamFinder>();
if (type == DP_SEAM)
return makePtr<DpSeamFinder>();
CV_Error(Error::StsBadArg, "unsupported exposure compensation method");
CV_Error(Error::StsBadArg, "unsupported seam finder method");
}
+24 -6
View File
@@ -141,14 +141,14 @@ public:
inline operator T* () CV_NOEXCEPT { return ptr; }
inline operator /*const*/ T* () const CV_NOEXCEPT { return (T*)ptr; } // there is no const correctness in Gst C API
inline T* get() CV_NOEXCEPT { return ptr; }
inline /*const*/ T* get() const CV_NOEXCEPT { CV_Assert(ptr); return (T*)ptr; } // there is no const correctness in Gst C API
T* get() { CV_Assert(ptr); return ptr; }
/*const*/ T* get() const { CV_Assert(ptr); return (T*)ptr; } // there is no const correctness in Gst C API
inline const T* operator -> () const { CV_Assert(ptr); return ptr; }
const T* operator -> () const { CV_Assert(ptr); return ptr; }
inline operator bool () const CV_NOEXCEPT { return ptr != NULL; }
inline bool operator ! () const CV_NOEXCEPT { return ptr == NULL; }
inline T** getRef() { CV_Assert(ptr == NULL); return &ptr; }
T** getRef() { CV_Assert(ptr == NULL); return &ptr; }
inline GSafePtr& reset(T* p) CV_NOEXCEPT // pass result of functions with "transfer floating" ownership
{
@@ -1221,7 +1221,21 @@ public:
num_frames(0), framerate(0)
{
}
virtual ~CvVideoWriter_GStreamer() CV_OVERRIDE { close(); }
virtual ~CvVideoWriter_GStreamer() CV_OVERRIDE
{
try
{
close();
}
catch (const std::exception& e)
{
CV_WARN("C++ exception in writer destructor: " << e.what());
}
catch (...)
{
CV_WARN("Unknown exception in writer destructor. Ignore");
}
}
int getCaptureDomain() const CV_OVERRIDE { return cv::CAP_GSTREAMER; }
@@ -1253,7 +1267,11 @@ void CvVideoWriter_GStreamer::close_()
{
handleMessage(pipeline);
if (gst_app_src_end_of_stream(GST_APP_SRC(source.get())) != GST_FLOW_OK)
if (!(bool)source)
{
CV_WARN("No source in GStreamer pipeline. Ignore");
}
else if (gst_app_src_end_of_stream(GST_APP_SRC(source.get())) != GST_FLOW_OK)
{
CV_WARN("Cannot send EOS to GStreamer pipeline");
}
+11 -1
View File
@@ -500,7 +500,8 @@ bool CvCaptureCAM_V4L::autosetup_capture_mode_v4l2()
V4L2_PIX_FMT_JPEG,
#endif
V4L2_PIX_FMT_Y16,
V4L2_PIX_FMT_GREY
V4L2_PIX_FMT_Y10,
V4L2_PIX_FMT_GREY,
};
for (size_t i = 0; i < sizeof(try_order) / sizeof(__u32); i++) {
@@ -547,6 +548,7 @@ bool CvCaptureCAM_V4L::convertableToRgb() const
case V4L2_PIX_FMT_SGBRG8:
case V4L2_PIX_FMT_RGB24:
case V4L2_PIX_FMT_Y16:
case V4L2_PIX_FMT_Y10:
case V4L2_PIX_FMT_GREY:
case V4L2_PIX_FMT_BGR24:
return true;
@@ -581,6 +583,7 @@ void CvCaptureCAM_V4L::v4l2_create_frame()
size.height = size.height * 3 / 2; // "1.5" channels
break;
case V4L2_PIX_FMT_Y16:
case V4L2_PIX_FMT_Y10:
depth = IPL_DEPTH_16U;
/* fallthru */
case V4L2_PIX_FMT_GREY:
@@ -1455,6 +1458,13 @@ void CvCaptureCAM_V4L::convertToRgb(const Buffer &currentBuffer)
cv::cvtColor(temp, destination, COLOR_GRAY2BGR);
return;
}
case V4L2_PIX_FMT_Y10:
{
cv::Mat temp(imageSize, CV_8UC1, buffers[MAX_V4L_BUFFERS].start);
cv::Mat(imageSize, CV_16UC1, currentBuffer.start).convertTo(temp, CV_8U, 1.0 / 4);
cv::cvtColor(temp, destination, COLOR_GRAY2BGR);
return;
}
case V4L2_PIX_FMT_GREY:
cv::cvtColor(cv::Mat(imageSize, CV_8UC1, currentBuffer.start), destination, COLOR_GRAY2BGR);
break;
+59
View File
@@ -506,4 +506,63 @@ TEST(Videoio, exceptions)
EXPECT_THROW(cap.open("this_does_not_exist.avi", CAP_OPENCV_MJPEG), Exception);
}
typedef Videoio_Writer Videoio_Writer_bad_fourcc;
TEST_P(Videoio_Writer_bad_fourcc, nocrash)
{
if (!isBackendAvailable(apiPref, cv::videoio_registry::getStreamBackends()))
throw SkipTestException(cv::String("Backend is not available/disabled: ") + cv::videoio_registry::getBackendName(apiPref));
VideoWriter writer;
EXPECT_NO_THROW(writer.open(video_file, apiPref, fourcc, fps, frame_size, true));
ASSERT_FALSE(writer.isOpened());
EXPECT_NO_THROW(writer.release());
}
static vector<Ext_Fourcc_API> generate_Ext_Fourcc_API_nocrash()
{
static const Ext_Fourcc_API params[] = {
#ifdef HAVE_MSMF_DISABLED // MSMF opens writer stream
{"wmv", "aaaa", CAP_MSMF},
{"mov", "aaaa", CAP_MSMF},
#endif
#ifdef HAVE_QUICKTIME
{"mov", "aaaa", CAP_QT},
{"avi", "aaaa", CAP_QT},
{"mkv", "aaaa", CAP_QT},
#endif
#ifdef HAVE_AVFOUNDATION
{"mov", "aaaa", CAP_AVFOUNDATION},
{"mp4", "aaaa", CAP_AVFOUNDATION},
{"m4v", "aaaa", CAP_AVFOUNDATION},
#endif
#ifdef HAVE_FFMPEG
{"avi", "aaaa", CAP_FFMPEG},
{"mkv", "aaaa", CAP_FFMPEG},
#endif
#ifdef HAVE_GSTREAMER
{"avi", "aaaa", CAP_GSTREAMER},
{"mkv", "aaaa", CAP_GSTREAMER},
#endif
{"avi", "aaaa", CAP_OPENCV_MJPEG},
};
const size_t N = sizeof(params)/sizeof(params[0]);
vector<Ext_Fourcc_API> result; result.reserve(N);
for (size_t i = 0; i < N; i++)
{
const Ext_Fourcc_API& src = params[i];
Ext_Fourcc_API e = { src.ext, src.fourcc, src.api };
result.push_back(e);
}
return result;
}
INSTANTIATE_TEST_CASE_P(videoio, Videoio_Writer_bad_fourcc, testing::ValuesIn(generate_Ext_Fourcc_API_nocrash()));
} // namespace
@@ -112,10 +112,10 @@ class TestCmakeBuild(unittest.TestCase):
def suite(workdir, opencv_cmake_path):
abis = {
"armeabi-v7a": { "ANDROID_ABI": "armeabi-v7a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"arm64-v8a": { "ANDROID_ABI": "arm64-v8a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86": { "ANDROID_ABI": "x86", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86_64": { "ANDROID_ABI": "x86_64", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_static", 'ANDROID_NATIVE_API_LEVEL': "21" },
"armeabi-v7a": { "ANDROID_ABI": "armeabi-v7a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
"arm64-v8a": { "ANDROID_ABI": "arm64-v8a", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86": { "ANDROID_ABI": "x86", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
"x86_64": { "ANDROID_ABI": "x86_64", "ANDROID_TOOLCHAIN": "clang", "ANDROID_STL": "c++_shared", 'ANDROID_NATIVE_API_LEVEL': "21" },
}
suite = unittest.TestSuite()
+9 -4
View File
@@ -125,7 +125,7 @@ class ABI:
self.cmake_vars['ANDROID_TOOLCHAIN_NAME'] = toolchain
else:
self.cmake_vars['ANDROID_TOOLCHAIN'] = 'clang'
self.cmake_vars['ANDROID_STL'] = 'c++_static'
self.cmake_vars['ANDROID_STL'] = 'c++_shared'
if ndk_api_level:
self.cmake_vars['ANDROID_NATIVE_API_LEVEL'] = ndk_api_level
self.cmake_vars.update(cmake_vars)
@@ -151,6 +151,7 @@ class Builder:
self.ninja_path = self.get_ninja()
self.debug = True if config.debug else False
self.debug_info = True if config.debug_info else False
self.no_samples_build = True if config.no_samples_build else False
def get_cmake(self):
if not self.config.use_android_buildtools and check_executable(['cmake', '--version']):
@@ -217,7 +218,7 @@ class Builder:
BUILD_TESTS="OFF",
BUILD_PERF_TESTS="OFF",
BUILD_DOCS="OFF",
BUILD_ANDROID_EXAMPLES="ON",
BUILD_ANDROID_EXAMPLES=("OFF" if self.no_samples_build else "ON"),
INSTALL_ANDROID_EXAMPLES="ON",
)
if self.ninja_path != 'ninja':
@@ -243,8 +244,11 @@ class Builder:
execute(cmd)
# full parallelism for C++ compilation tasks
execute([self.ninja_path, "opencv_modules"])
# limit parallelism for Gradle steps (avoid huge memory consumption)
execute([self.ninja_path, '-j3', "install" if (self.debug_info or self.debug) else "install/strip"])
# limit parallelism for building samples (avoid huge memory consumption)
if self.no_samples_build:
execute([self.ninja_path, "install" if (self.debug_info or self.debug) else "install/strip"])
else:
execute([self.ninja_path, "-j1" if (self.debug_info or self.debug) else "-j3", "install" if (self.debug_info or self.debug) else "install/strip"])
def build_javadoc(self):
classpaths = []
@@ -323,6 +327,7 @@ if __name__ == "__main__":
parser.add_argument('--force_opencv_toolchain', action="store_true", help="Do not use toolchain from Android NDK")
parser.add_argument('--debug', action="store_true", help="Build 'Debug' binaries (CMAKE_BUILD_TYPE=Debug)")
parser.add_argument('--debug_info', action="store_true", help="Build with debug information (useful for Release mode: BUILD_WITH_DEBUG_INFO=ON)")
parser.add_argument('--no_samples_build', action="store_true", help="Do not build samples (speeds up build)")
args = parser.parse_args()
log.basicConfig(format='%(message)s', level=log.DEBUG)
@@ -9,7 +9,7 @@
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
org.gradle.jvmargs=-Xmx1536m
org.gradle.jvmargs=-Xmx2g
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
@@ -0,0 +1,12 @@
if(WINCE)
# CommCtrl.lib does not exist in headless WINCE Adding this will make CMake
# Try_Compile succeed and therefore also C/C++ ABI Detetection work
# https://gitlab.kitware.com/cmake/cmake/blob/master/Modules/Platform/Windows-
# MSVC.cmake
set(CMAKE_C_STANDARD_LIBRARIES_INIT "coredll.lib")
set(CMAKE_CXX_STANDARD_LIBRARIES_INIT ${CMAKE_C_STANDARD_LIBRARIES_INIT})
foreach(ID EXE SHARED MODULE)
string(APPEND CMAKE_${ID}_LINKER_FLAGS_INIT
" /NODEFAULTLIB:libc.lib /NODEFAULTLIB:oldnames.lib")
endforeach()
endif()
+35
View File
@@ -0,0 +1,35 @@
set(CMAKE_SYSTEM_NAME WindowsCE)
if(NOT CMAKE_SYSTEM_VERSION)
set(CMAKE_SYSTEM_VERSION 8.0)
endif()
if(NOT CMAKE_SYSTEM_PROCESSOR)
set(CMAKE_SYSTEM_PROCESSOR armv7-a)
endif()
if(NOT CMAKE_GENERATOR_TOOLSET)
set(CMAKE_GENERATOR_TOOLSET CE800)
endif()
# Needed to make try_compile to succeed
if(BUILD_HEADLESS)
set(CMAKE_USER_MAKE_RULES_OVERRIDE
${CMAKE_CURRENT_LIST_DIR}/arm-wince-headless-overrides.cmake)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PROGRAM)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_LIBRARY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_INCLUDE)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
endif()
if(NOT CMAKE_FIND_ROOT_PATH_MODE_PACKAGE)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
endif()
+62
View File
@@ -0,0 +1,62 @@
# Building OpenCV from Source for Windows Embedded Compact (WINCE/WEC)
## Requirements
CMake 3.1.0 or higher
Windows Embedded Compact SDK
## Configuring
To configure CMake for Windows Embedded, specify Visual Studio 2013 as generator and the name of your installed SDK:
`cmake -G "Visual Studio 12 2013" -A "MySDK WEC2013" -DCMAKE_TOOLCHAIN_FILE:FILEPATH=../platforms/wince/arm-wince.toolchain.cmake`
If you are building for a headless WINCE, specify `-DBUILD_HEADLESS=ON` when configuring. This will remove the `commctrl.lib` dependency.
If you are building for anything else than WINCE800, you need to specify that in the configuration step. Example:
```
-DCMAKE_SYSTEM_VERSION=7.0 -DCMAKE_GENERATOR_TOOLSET=CE700 -DCMAKE_SYSTEM_PROCESSOR=arm-v4
```
For headless WEC2013, this configuration may not be limited to but is known to work:
```
-DBUILD_EXAMPLES=OFF `
-DBUILD_opencv_apps=OFF `
-DBUILD_opencv_calib3d=OFF `
-DBUILD_opencv_highgui=OFF `
-DBUILD_opencv_features2d=OFF `
-DBUILD_opencv_flann=OFF `
-DBUILD_opencv_ml=OFF `
-DBUILD_opencv_objdetect=OFF `
-DBUILD_opencv_photo=OFF `
-DBUILD_opencv_shape=OFF `
-DBUILD_opencv_stitching=OFF `
-DBUILD_opencv_superres=OFF `
-DBUILD_opencv_ts=OFF `
-DBUILD_opencv_video=OFF `
-DBUILD_opencv_videoio=OFF `
-DBUILD_opencv_videostab=OFF `
-DBUILD_opencv_dnn=OFF `
-DBUILD_opencv_java=OFF `
-DBUILD_opencv_python2=OFF `
-DBUILD_opencv_python3=OFF `
-DBUILD_opencv_java_bindings_generator=OFF `
-DBUILD_opencv_python_bindings_generator=OFF `
-DBUILD_TIFF=OFF `
-DCV_TRACE=OFF `
-DWITH_OPENCL=OFF `
-DHAVE_OPENCL=OFF `
-DWITH_QT=OFF `
-DWITH_GTK=OFF `
-DWITH_QUIRC=OFF `
-DWITH_JASPER=OFF `
-DWITH_WEBP=OFF `
-DWITH_PROTOBUF=OFF `
-DBUILD_SHARED_LIBS=OFF `
-DWITH_OPENEXR=OFF `
-DWITH_TIFF=OFF `
```
## Building
You are required to build using Unicode:
`cmake --build . -- /p:CharacterSet=Unicode`
+1 -1
View File
@@ -38,7 +38,7 @@ endif()
if(UNIX AND NOT ANDROID AND (HAVE_VA OR HAVE_VA_INTEL))
add_subdirectory(va_intel)
endif()
if(ANDROID AND BUILD_ANDROID_EXAMPLES)
if(ANDROID AND (BUILD_ANDROID_EXAMPLES OR INSTALL_ANDROID_EXAMPLES))
add_subdirectory(android)
endif()
if(INSTALL_PYTHON_EXAMPLES)

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