mirror of
https://github.com/opencv/opencv.git
synced 2026-07-26 05:43:05 +04:00
Compare commits
98 Commits
3.3.1-cvsdk
..
3.3.1
| Author | SHA1 | Date | |
|---|---|---|---|
| a871f9e4f7 | |||
| bf418ba342 | |||
| be9767e014 | |||
| ab5e09e428 | |||
| 607231641f | |||
| 91323549f4 | |||
| 734ea77c9a | |||
| d96cac1341 | |||
| 0622146a93 | |||
| db980b0eca | |||
| d1c5e79ec3 | |||
| cca99bf824 | |||
| 08a5fe3661 | |||
| 9ae86a922c | |||
| 276459e57e | |||
| 223830a5ee | |||
| 410d44d67d | |||
| a6c02af099 | |||
| c97c1a2454 | |||
| 9b1b281c7b | |||
| 185faf99bd | |||
| face2ea612 | |||
| 3fd03964a3 | |||
| ccea108806 | |||
| c63b4433f4 | |||
| 505c90e104 | |||
| 97b8a089c7 | |||
| 69e5ac6f02 | |||
| 110af09bf9 | |||
| 73af899b7c | |||
| b066dd36ff | |||
| 1563300197 | |||
| 2914443685 | |||
| fef1f9b0a7 | |||
| 2808bea7fa | |||
| d30a0c6f03 | |||
| 0246cffc34 | |||
| 22dece8146 | |||
| fee2049642 | |||
| e2499e5b2f | |||
| 60bcb16ca8 | |||
| 2a781bb616 | |||
| 5ed354221c | |||
| 827c7515c9 | |||
| 23f26fb4a8 | |||
| 26fe8bd4f2 | |||
| 4857cae6ed | |||
| 1ba29cc95d | |||
| df5b2224d7 | |||
| f1fe873375 | |||
| b0c6bd0a5b | |||
| 4ae30ecdd9 | |||
| 937b8e4277 | |||
| e356ca2369 | |||
| e955bcb872 | |||
| 88225eb65e | |||
| ec24091578 | |||
| 024be9b8c9 | |||
| af9c8377eb | |||
| 29c186a022 | |||
| baf9e32af3 | |||
| 8b168175ec | |||
| 83655ba9be | |||
| 0873ebb9b0 | |||
| 5e82c98a9f | |||
| babd21c764 | |||
| 47e1133e71 | |||
| a972f0d4ea | |||
| f7175f5050 | |||
| 1ea1ff197d | |||
| 5ea8ea440b | |||
| 050916fd6b | |||
| ada753a54c | |||
| a96c5b5d90 | |||
| b2d8e8c508 | |||
| b2673a19cf | |||
| 905a9dada2 | |||
| 3935e13603 | |||
| af8ed9d09f | |||
| 638a91f92f | |||
| 3562a05d90 | |||
| 6c1247b38c | |||
| b7ff9ddcdd | |||
| 25161fc56f | |||
| 0739f28e56 | |||
| 046045239c | |||
| 7d55c09a9f | |||
| 0be1f4a573 | |||
| 2cfe29276e | |||
| 752f232335 | |||
| ecc34dc521 | |||
| eabf728682 | |||
| 0a19b07055 | |||
| 4b968d1fe2 | |||
| d077778074 | |||
| e4aa39f9e5 | |||
| 421c5dee12 | |||
| d0ab595f52 |
Vendored
+1
-1
@@ -43,7 +43,7 @@ source_group("Include" FILES ${lib_hdrs} )
|
||||
source_group("Src" FILES ${lib_srcs})
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses -Warray-bounds -Wextra
|
||||
-Wdeprecated-declarations -Wmisleading-indentation
|
||||
-Wdeprecated-declarations -Wmisleading-indentation -Wdeprecated
|
||||
)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
|
||||
|
||||
Vendored
+5
-4
@@ -5,13 +5,14 @@ if (WIN32 AND NOT ARM)
|
||||
message(FATAL_ERROR "BUILD_TBB option supports Windows on ARM only!\nUse regular official TBB build instead of the BUILD_TBB option!")
|
||||
endif()
|
||||
|
||||
set(tbb_ver "tbb44_20160128oss")
|
||||
set(tbb_filename "4.4.3.tar.gz")
|
||||
set(tbb_subdir "tbb-4.4.3")
|
||||
set(tbb_md5 "8e7200af3ac16e91a0d1535c606a485c")
|
||||
set(tbb_filename "2018_U1.tar.gz")
|
||||
set(tbb_subdir "tbb-2018_U1")
|
||||
set(tbb_md5 "b2f2fa09adf44a22f4024049907f774b")
|
||||
|
||||
set(tbb_version_file "version_string.ver")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4702)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wunused-parameter)
|
||||
|
||||
set(tbb_src_dir "${OpenCV_BINARY_DIR}/3rdparty/tbb")
|
||||
ocv_download(FILENAME ${tbb_filename}
|
||||
|
||||
+4
-2
@@ -245,7 +245,7 @@ OCV_OPTION(WITH_INTELPERC "Include Intel Perceptual Computing support" OFF
|
||||
OCV_OPTION(WITH_MATLAB "Include Matlab support" ON IF (NOT ANDROID AND NOT IOS AND NOT WINRT))
|
||||
OCV_OPTION(WITH_VA "Include VA support" OFF IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_VA_INTEL "Include Intel VA-API/OpenCL support" OFF IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_MFX "Include Intel Media SDK support" OFF IF ((UNIX AND NOT ANDROID) OR (WIN32 AND NOT WINRT AND NOT MINGW)) )
|
||||
OCV_OPTION(WITH_GDAL "Include GDAL Support" OFF IF (NOT ANDROID AND NOT IOS AND NOT WINRT) )
|
||||
OCV_OPTION(WITH_GPHOTO2 "Include gPhoto2 library support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_LAPACK "Include Lapack library support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
@@ -298,6 +298,7 @@ OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add
|
||||
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) )
|
||||
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
OCV_OPTION(ENABLE_VSX "Enable POWER8 and above VSX (64-bit little-endian)" ON IF (CMAKE_COMPILER_IS_GNUCXX AND PPC64LE) )
|
||||
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NEON "Enable NEON instructions" (NEON OR ANDROID_ARM_NEON OR AARCH64) IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
OCV_OPTION(ENABLE_VFPV3 "Enable VFPv3-D32 instructions" OFF IF CMAKE_COMPILER_IS_GNUCXX AND (ARM OR AARCH64 OR IOS) )
|
||||
@@ -792,7 +793,8 @@ endif()
|
||||
include(cmake/OpenCVGenHeaders.cmake)
|
||||
|
||||
# Generate opencv.pc for pkg-config command
|
||||
if(NOT OPENCV_SKIP_PKGCONFIG_GENERATION)
|
||||
if(NOT OPENCV_SKIP_PKGCONFIG_GENERATION
|
||||
AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
||||
include(cmake/OpenCVGenPkgconfig.cmake)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
set(CPU_ALL_OPTIMIZATIONS "SSE;SSE2;SSE3;SSSE3;SSE4_1;SSE4_2;POPCNT;AVX;FP16;AVX2;FMA3") # without AVX512
|
||||
list(APPEND CPU_ALL_OPTIMIZATIONS NEON VFPV3 FP16)
|
||||
list(APPEND CPU_ALL_OPTIMIZATIONS VSX)
|
||||
list(REMOVE_DUPLICATES CPU_ALL_OPTIMIZATIONS)
|
||||
|
||||
ocv_update(CPU_VFPV3_FEATURE_ALIAS "")
|
||||
@@ -79,6 +80,7 @@ ocv_optimization_process_obsolete_option(ENABLE_FMA3 FMA3 ON)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_VFPV3 VFPV3 OFF)
|
||||
ocv_optimization_process_obsolete_option(ENABLE_NEON NEON OFF)
|
||||
|
||||
ocv_optimization_process_obsolete_option(ENABLE_VSX VSX OFF)
|
||||
|
||||
macro(ocv_is_optimization_in_list resultvar check_opt)
|
||||
set(__checked "")
|
||||
@@ -254,18 +256,29 @@ elseif(ARM OR AARCH64)
|
||||
ocv_update(CPU_FP16_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_fp16.cpp")
|
||||
if(NOT AARCH64)
|
||||
ocv_update(CPU_KNOWN_OPTIMIZATIONS "VFPV3;NEON;FP16")
|
||||
ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
|
||||
ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
|
||||
ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
|
||||
ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
|
||||
if(NOT MSVC)
|
||||
ocv_update(CPU_VFPV3_FLAGS_ON "-mfpu=vfpv3")
|
||||
ocv_update(CPU_NEON_FLAGS_ON "-mfpu=neon")
|
||||
ocv_update(CPU_NEON_FLAGS_CONFLICT "-mfpu=[^ ]*")
|
||||
ocv_update(CPU_FP16_FLAGS_ON "-mfpu=neon-fp16")
|
||||
ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
|
||||
endif()
|
||||
ocv_update(CPU_FP16_IMPLIES "NEON")
|
||||
ocv_update(CPU_FP16_FLAGS_CONFLICT "-mfpu=[^ ]*")
|
||||
else()
|
||||
ocv_update(CPU_KNOWN_OPTIMIZATIONS "NEON;FP16")
|
||||
ocv_update(CPU_NEON_FLAGS_ON "")
|
||||
ocv_update(CPU_FP16_IMPLIES "NEON")
|
||||
set(CPU_BASELINE "NEON;FP16" CACHE STRING "${HELP_CPU_BASELINE}")
|
||||
endif()
|
||||
elseif(PPC64LE)
|
||||
ocv_update(CPU_KNOWN_OPTIMIZATIONS "VSX")
|
||||
ocv_update(CPU_VSX_TEST_FILE "${OpenCV_SOURCE_DIR}/cmake/checks/cpu_vsx.cpp")
|
||||
|
||||
if(CMAKE_COMPILER_IS_CLANGCXX AND (NOT ${CMAKE_CXX_COMPILER} MATCHES "xlc"))
|
||||
ocv_update(CPU_VSX_FLAGS_ON "-mvsx -maltivec")
|
||||
else()
|
||||
ocv_update(CPU_VSX_FLAGS_ON "-mcpu=power8")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Helper values for cmake-gui
|
||||
|
||||
@@ -280,7 +280,7 @@ set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEA
|
||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build")
|
||||
|
||||
# set default visibility to hidden
|
||||
if((CMAKE_COMPILER_ID STREQUAL "GNU" OR CMAKE_COMPILER_ID STREQUAL "Clang")
|
||||
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
AND NOT OPENCV_SKIP_VISIBILITY_HIDDEN
|
||||
AND NOT CMAKE_CXX_FLAGS MATCHES "-fvisibility")
|
||||
add_extra_compiler_option(-fvisibility=hidden)
|
||||
|
||||
@@ -72,6 +72,8 @@ elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(arm.*|ARM.*)")
|
||||
set(ARM 1)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^(aarch64.*|AARCH64.*)")
|
||||
set(AARCH64 1)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^ppc64le.*|PPC64LE.*")
|
||||
set(PPC64LE 1)
|
||||
endif()
|
||||
|
||||
# Workaround for 32-bit operating systems on 64-bit x86_64 processor
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
set(root "$ENV{MFX_HOME}")
|
||||
set(HAVE_MFX 0)
|
||||
|
||||
find_path(MFX_INCLUDE mfxdefs.h PATHS "${root}/include" NO_DEFAULT_PATH)
|
||||
if (UNIX)
|
||||
set(root "$ENV{MFX_HOME}")
|
||||
elseif(WIN32)
|
||||
set(root "$ENV{INTELMEDIASDKROOT}")
|
||||
endif()
|
||||
|
||||
# TODO: ICC? MINGW? ARM? IOS?
|
||||
if(WIN32)
|
||||
@@ -15,24 +19,41 @@ else()
|
||||
# ???
|
||||
endif()
|
||||
|
||||
find_library(MFX_LIBRARY mfx PATHS "${root}/lib/${arch}" NO_DEFAULT_PATH)
|
||||
find_library(MFX_VA_LIBRARY va)
|
||||
find_library(MFX_VA_DRM_LIBRARY va-drm)
|
||||
find_path(MFX_INCLUDE mfxdefs.h PATHS "${root}/include" NO_DEFAULT_PATH)
|
||||
message(STATUS "MFX_INCLUDE: ${MFX_INCLUDE} (${root}/include)")
|
||||
find_library(MFX_LIBRARY NAMES mfx PATHS "${root}/lib/${arch}" NO_DEFAULT_PATH)
|
||||
if(MSVC)
|
||||
if(MSVC14)
|
||||
find_library(MFX_LIBRARY NAMES libmfx_vs2015.lib PATHS "${root}/lib/${arch}" NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library(MFX_LIBRARY NAMES libmfx.lib PATHS "${root}/lib/${arch}" NO_DEFAULT_PATH)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(MFX_INCLUDE AND MFX_LIBRARY AND MFX_VA_LIBRARY AND MFX_VA_DRM_LIBRARY)
|
||||
if(NOT MFX_INCLUDE OR NOT MFX_LIBRARY)
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(deps)
|
||||
|
||||
if (UNIX)
|
||||
find_library(MFX_VA_LIBRARY va)
|
||||
find_library(MFX_VA_DRM_LIBRARY va-drm)
|
||||
if (NOT MFX_VA_LIBRARY OR NOT MFX_VA_DRM_LIBRARY)
|
||||
return()
|
||||
endif()
|
||||
add_library(mfx-va UNKNOWN IMPORTED)
|
||||
set_target_properties(mfx-va PROPERTIES IMPORTED_LOCATION "${MFX_VA_LIBRARY}")
|
||||
|
||||
add_library(mfx-va-drm UNKNOWN IMPORTED)
|
||||
set_target_properties(mfx-va-drm PROPERTIES IMPORTED_LOCATION "${MFX_VA_DRM_LIBRARY}")
|
||||
|
||||
add_library(mfx UNKNOWN IMPORTED)
|
||||
set_target_properties(mfx PROPERTIES
|
||||
IMPORTED_LOCATION "${MFX_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${MFX_INCLUDE}"
|
||||
INTERFACE_LINK_LIBRARIES "mfx-va;mfx-va-drm;-Wl,--exclude-libs=libmfx"
|
||||
)
|
||||
set(HAVE_MFX 1)
|
||||
else()
|
||||
set(HAVE_MFX 0)
|
||||
list(APPEND deps mfx-va mfx-va-drm "-Wl,--exclude-libs=libmfx")
|
||||
endif()
|
||||
|
||||
add_library(mfx UNKNOWN IMPORTED)
|
||||
set_target_properties(mfx PROPERTIES
|
||||
IMPORTED_LOCATION "${MFX_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${MFX_INCLUDE}"
|
||||
INTERFACE_LINK_LIBRARIES "${deps}"
|
||||
)
|
||||
|
||||
set(HAVE_MFX 1)
|
||||
|
||||
@@ -41,9 +41,9 @@ endfunction()
|
||||
function(ocv_tbb_env_guess _found)
|
||||
find_path(TBB_ENV_INCLUDE NAMES "tbb/tbb.h" PATHS ENV CPATH NO_DEFAULT_PATH)
|
||||
find_path(TBB_ENV_INCLUDE NAMES "tbb/tbb.h")
|
||||
find_library(TBB_ENV_LIB NAMES "tbb" PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
|
||||
find_library(TBB_ENV_LIB NAMES "tbb" PATHS ENV LIBRARY_PATH NO_DEFAULT_PATH)
|
||||
find_library(TBB_ENV_LIB NAMES "tbb")
|
||||
find_library(TBB_ENV_LIB_DEBUG NAMES "tbb_debug" PATHS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH NO_DEFAULT_PATH)
|
||||
find_library(TBB_ENV_LIB_DEBUG NAMES "tbb_debug" PATHS ENV LIBRARY_PATH NO_DEFAULT_PATH)
|
||||
find_library(TBB_ENV_LIB_DEBUG NAMES "tbb_debug")
|
||||
if (TBB_ENV_INCLUDE AND (TBB_ENV_LIB OR TBB_ENV_LIB_DEBUG))
|
||||
ocv_tbb_verify()
|
||||
|
||||
@@ -31,9 +31,10 @@ file(TO_CMAKE_PATH "${IPPROOT}" IPPROOT)
|
||||
|
||||
# This function detects Intel IPP IW version by analyzing .h file
|
||||
macro(ippiw_setup PATH BUILD)
|
||||
set(FILE "${PATH}/include/iw/iw_version.h")
|
||||
set(FILE "${PATH}/include/iw/iw_ll.h") # check if Intel IPP IW is OpenCV specific
|
||||
ippiw_debugmsg("Checking path: ${PATH}")
|
||||
if(EXISTS "${FILE}")
|
||||
set(FILE "${PATH}/include/iw/iw_version.h")
|
||||
ippiw_debugmsg("vfile\tok")
|
||||
file(STRINGS "${FILE}" IW_VERSION_MAJOR REGEX "IW_VERSION_MAJOR")
|
||||
file(STRINGS "${FILE}" IW_VERSION_MINOR REGEX "IW_VERSION_MINOR")
|
||||
|
||||
@@ -121,23 +121,22 @@ if(WITH_LAPACK)
|
||||
set(LAPACK_IMPL "LAPACK/MKL")
|
||||
ocv_lapack_check()
|
||||
endif()
|
||||
if(LAPACKE_INCLUDE_DIR AND NOT HAVE_LAPACK)
|
||||
set(LAPACK_INCLUDE_DIR ${LAPACKE_INCLUDE_DIR})
|
||||
set(LAPACK_CBLAS_H "cblas.h")
|
||||
set(LAPACK_LAPACKE_H "lapacke.h")
|
||||
set(LAPACK_IMPL "LAPACK/Generic")
|
||||
ocv_lapack_check()
|
||||
elseif(APPLE)
|
||||
set(LAPACK_CBLAS_H "Accelerate/Accelerate.h")
|
||||
set(LAPACK_LAPACKE_H "Accelerate/Accelerate.h")
|
||||
set(LAPACK_IMPL "LAPACK/Apple")
|
||||
ocv_lapack_check()
|
||||
else()
|
||||
unset(LAPACK_LIBRARIES)
|
||||
unset(LAPACK_LIBRARIES CACHE)
|
||||
if(NOT HAVE_LAPACK)
|
||||
if(LAPACKE_INCLUDE_DIR)
|
||||
set(LAPACK_INCLUDE_DIR ${LAPACKE_INCLUDE_DIR})
|
||||
set(LAPACK_CBLAS_H "cblas.h")
|
||||
set(LAPACK_LAPACKE_H "lapacke.h")
|
||||
set(LAPACK_IMPL "LAPACK/Generic")
|
||||
ocv_lapack_check()
|
||||
elseif(APPLE)
|
||||
set(LAPACK_CBLAS_H "Accelerate/Accelerate.h")
|
||||
set(LAPACK_LAPACKE_H "Accelerate/Accelerate.h")
|
||||
set(LAPACK_IMPL "LAPACK/Apple")
|
||||
ocv_lapack_check()
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
# LAPACK not found
|
||||
endif()
|
||||
if(NOT HAVE_LAPACK)
|
||||
unset(LAPACK_LIBRARIES)
|
||||
unset(LAPACK_LIBRARIES CACHE)
|
||||
endif()
|
||||
|
||||
@@ -31,6 +31,9 @@ elseif(ARM)
|
||||
elseif(AARCH64)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "arm64")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "aarch64")
|
||||
elseif(PPC64LE)
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "ppc64el")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "ppc64le")
|
||||
else()
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
|
||||
@@ -164,4 +167,4 @@ endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
include(CPack)
|
||||
|
||||
ENDif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
ENDif(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# if defined(__VSX__)
|
||||
# include <altivec.h>
|
||||
# else
|
||||
# error "VSX is not supported"
|
||||
# endif
|
||||
|
||||
int main()
|
||||
{
|
||||
__vector float testF = vec_splats(0.f);
|
||||
testF = vec_madd(testF, testF, testF);
|
||||
return 0;
|
||||
}
|
||||
@@ -37,6 +37,8 @@ if(BUILD_DOCS AND DOXYGEN_FOUND)
|
||||
unset(CMAKE_DOXYGEN_TUTORIAL_CONTRIB_ROOT)
|
||||
unset(CMAKE_DOXYGEN_TUTORIAL_JS_ROOT)
|
||||
|
||||
set(OPENCV_MATHJAX_RELPATH "https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0" CACHE STRING "URI to a MathJax installation")
|
||||
|
||||
# gathering headers
|
||||
set(paths_include)
|
||||
set(paths_doc)
|
||||
|
||||
+3
-3
@@ -38,7 +38,7 @@ ALIASES += add_toggle_python="@htmlonly[block] <div class='newInne
|
||||
ALIASES += end_toggle="@htmlonly[block] </div> @endhtmlonly"
|
||||
ALIASES += prev_tutorial{1}="**Prev Tutorial:** \ref \1 \n"
|
||||
ALIASES += next_tutorial{1}="**Next Tutorial:** \ref \1 \n"
|
||||
ALIASES += youtube{1}="@htmlonly[block]<div align='center'><iframe title='my title' width='560' height='349' src='http://www.youtube.com/embed/\1?rel=0' frameborder='0' align='middle' allowfullscreen></iframe></div>@endhtmlonly"
|
||||
ALIASES += youtube{1}="@htmlonly[block]<div align='center'><iframe title='Video' width='560' height='349' src='https://www.youtube.com/embed/\1?rel=0' frameborder='0' align='middle' allowfullscreen></iframe></div>@endhtmlonly"
|
||||
TCL_SUBST =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
@@ -106,7 +106,7 @@ FILE_PATTERNS =
|
||||
RECURSIVE = YES
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS = *.inl.hpp *.impl.hpp *_detail.hpp */cudev/**/detail/*.hpp *.m
|
||||
EXCLUDE_PATTERNS = *.inl.hpp *.impl.hpp *_detail.hpp */cudev/**/detail/*.hpp *.m */opencl/runtime/*
|
||||
EXCLUDE_SYMBOLS = cv::DataType<*> cv::traits::* int void CV__*
|
||||
EXAMPLE_PATH = @CMAKE_DOXYGEN_EXAMPLE_PATH@
|
||||
EXAMPLE_PATTERNS = *
|
||||
@@ -174,7 +174,7 @@ FORMULA_FONTSIZE = 14
|
||||
FORMULA_TRANSPARENT = YES
|
||||
USE_MATHJAX = YES
|
||||
MATHJAX_FORMAT = HTML-CSS
|
||||
MATHJAX_RELPATH = https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.0
|
||||
MATHJAX_RELPATH = @OPENCV_MATHJAX_RELPATH@
|
||||
MATHJAX_EXTENSIONS = TeX/AMSmath TeX/AMSsymbols
|
||||
MATHJAX_CODEFILE = @CMAKE_CURRENT_SOURCE_DIR@/mymath.js
|
||||
SEARCHENGINE = YES
|
||||
|
||||
@@ -5,14 +5,14 @@ Goal
|
||||
----
|
||||
|
||||
In this session,
|
||||
- We will learn to create depth map from stereo images.
|
||||
- We will learn to create a depth map from stereo images.
|
||||
|
||||
Basics
|
||||
------
|
||||
|
||||
In last session, we saw basic concepts like epipolar constraints and other related terms. We also
|
||||
In the last session, we saw basic concepts like epipolar constraints and other related terms. We also
|
||||
saw that if we have two images of same scene, we can get depth information from that in an intuitive
|
||||
way. Below is an image and some simple mathematical formulas which proves that intuition. (Image
|
||||
way. Below is an image and some simple mathematical formulas which prove that intuition. (Image
|
||||
Courtesy :
|
||||
|
||||

|
||||
@@ -24,7 +24,7 @@ following result:
|
||||
|
||||
\f$x\f$ and \f$x'\f$ are the distance between points in image plane corresponding to the scene point 3D and
|
||||
their camera center. \f$B\f$ is the distance between two cameras (which we know) and \f$f\f$ is the focal
|
||||
length of camera (already known). So in short, above equation says that the depth of a point in a
|
||||
length of camera (already known). So in short, the above equation says that the depth of a point in a
|
||||
scene is inversely proportional to the difference in distance of corresponding image points and
|
||||
their camera centers. So with this information, we can derive the depth of all pixels in an image.
|
||||
|
||||
@@ -35,7 +35,7 @@ how we can do it with OpenCV.
|
||||
Code
|
||||
----
|
||||
|
||||
Below code snippet shows a simple procedure to create disparity map.
|
||||
Below code snippet shows a simple procedure to create a disparity map.
|
||||
@code{.py}
|
||||
import numpy as np
|
||||
import cv2
|
||||
@@ -49,7 +49,7 @@ disparity = stereo.compute(imgL,imgR)
|
||||
plt.imshow(disparity,'gray')
|
||||
plt.show()
|
||||
@endcode
|
||||
Below image contains the original image (left) and its disparity map (right). As you can see, result
|
||||
Below image contains the original image (left) and its disparity map (right). As you can see, the result
|
||||
is contaminated with high degree of noise. By adjusting the values of numDisparities and blockSize,
|
||||
you can get a better result.
|
||||
|
||||
|
||||
@@ -50,9 +50,9 @@ You can modify the pixel values the same way.
|
||||
Numpy is a optimized library for fast array calculations. So simply accessing each and every pixel
|
||||
values and modifying it will be very slow and it is discouraged.
|
||||
|
||||
@note Above mentioned method is normally used for selecting a region of array, say first 5 rows and
|
||||
last 3 columns like that. For individual pixel access, Numpy array methods, array.item() and
|
||||
array.itemset() is considered to be better. But it always returns a scalar. So if you want to access
|
||||
@note The above method is normally used for selecting a region of an array, say the first 5 rows
|
||||
and last 3 columns. For individual pixel access, the Numpy array methods, array.item() and
|
||||
array.itemset() are considered better, however they always return a scalar. If you want to access
|
||||
all B,G,R values, you need to call array.item() separately for all.
|
||||
|
||||
Better pixel accessing and editing method :
|
||||
@@ -73,15 +73,15 @@ Accessing Image Properties
|
||||
Image properties include number of rows, columns and channels, type of image data, number of pixels
|
||||
etc.
|
||||
|
||||
Shape of image is accessed by img.shape. It returns a tuple of number of rows, columns and channels
|
||||
The shape of an image is accessed by img.shape. It returns a tuple of number of rows, columns, and channels
|
||||
(if image is color):
|
||||
@code{.py}
|
||||
>>> print( img.shape )
|
||||
(342, 548, 3)
|
||||
@endcode
|
||||
|
||||
@note If image is grayscale, tuple returned contains only number of rows and columns. So it is a
|
||||
good method to check if loaded image is grayscale or color image.
|
||||
@note If an image is grayscale, the tuple returned contains only the number of rows
|
||||
and columns, so it is a good method to check whether the loaded image is grayscale or color.
|
||||
|
||||
Total number of pixels is accessed by `img.size`:
|
||||
@code{.py}
|
||||
@@ -101,9 +101,9 @@ Image ROI
|
||||
---------
|
||||
|
||||
Sometimes, you will have to play with certain region of images. For eye detection in images, first
|
||||
face detection is done all over the image and when face is obtained, we select the face region alone
|
||||
and search for eyes inside it instead of searching whole image. It improves accuracy (because eyes
|
||||
are always on faces :D ) and performance (because we search for a small area)
|
||||
face detection is done all over the image. When a face is obtained, we select the face region alone
|
||||
and search for eyes inside it instead of searching the whole image. It improves accuracy (because eyes
|
||||
are always on faces :D ) and performance (because we search in a small area).
|
||||
|
||||
ROI is again obtained using Numpy indexing. Here I am selecting the ball and copying it to another
|
||||
region in the image:
|
||||
@@ -118,9 +118,9 @@ Check the results below:
|
||||
Splitting and Merging Image Channels
|
||||
------------------------------------
|
||||
|
||||
Sometimes you will need to work separately on B,G,R channels of image. Then you need to split the
|
||||
BGR images to single planes. Or another time, you may need to join these individual channels to BGR
|
||||
image. You can do it simply by:
|
||||
Sometimes you will need to work separately on B,G,R channels of image. In this case, you need
|
||||
to split the BGR images to single channels. In other cases, you may need to join these individual
|
||||
channels to a BGR image. You can do it simply by:
|
||||
@code{.py}
|
||||
>>> b,g,r = cv2.split(img)
|
||||
>>> img = cv2.merge((b,g,r))
|
||||
@@ -129,13 +129,13 @@ Or
|
||||
@code
|
||||
>>> b = img[:,:,0]
|
||||
@endcode
|
||||
Suppose, you want to make all the red pixels to zero, you need not split like this and put it equal
|
||||
to zero. You can simply use Numpy indexing, and that is faster.
|
||||
Suppose you want to set all the red pixels to zero, you do not need to split the channels first.
|
||||
Numpy indexing is faster:
|
||||
@code{.py}
|
||||
>>> img[:,:,2] = 0
|
||||
@endcode
|
||||
|
||||
**warning**
|
||||
**Warning**
|
||||
|
||||
cv2.split() is a costly operation (in terms of time). So do it only if you need it. Otherwise go
|
||||
for Numpy indexing.
|
||||
@@ -144,7 +144,7 @@ Making Borders for Images (Padding)
|
||||
-----------------------------------
|
||||
|
||||
If you want to create a border around the image, something like a photo frame, you can use
|
||||
**cv2.copyMakeBorder()** function. But it has more applications for convolution operation, zero
|
||||
**cv2.copyMakeBorder()**. But it has more applications for convolution operation, zero
|
||||
padding etc. This function takes following arguments:
|
||||
|
||||
- **src** - input image
|
||||
@@ -190,7 +190,7 @@ plt.subplot(236),plt.imshow(constant,'gray'),plt.title('CONSTANT')
|
||||
|
||||
plt.show()
|
||||
@endcode
|
||||
See the result below. (Image is displayed with matplotlib. So RED and BLUE planes will be
|
||||
See the result below. (Image is displayed with matplotlib. So RED and BLUE channels will be
|
||||
interchanged):
|
||||
|
||||

|
||||
|
||||
@@ -279,8 +279,4 @@ quality cameras.
|
||||
You may observe a runtime instance of this on the [YouTube
|
||||
here](https://www.youtube.com/watch?v=ViPN810E0SU).
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title=" Camera calibration With OpenCV - Chessboard or asymmetrical circle pattern." width="560" height="349" src="http://www.youtube.com/embed/ViPN810E0SU?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{ViPN810E0SU}
|
||||
|
||||
@@ -791,13 +791,5 @@ int minInliersKalman = 30; // Kalman threshold updating
|
||||
You can watch the real time pose estimation on the [YouTube
|
||||
here](http://www.youtube.com/user/opencvdev/videos).
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Pose estimation of textured object using OpenCV" width="560" height="349" src="http://www.youtube.com/embed/XNATklaJlSQ?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Pose estimation of textured object using OpenCV in cluttered background" width="560" height="349" src="http://www.youtube.com/embed/YLS9bWek78k?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{XNATklaJlSQ}
|
||||
@youtube{YLS9bWek78k}
|
||||
|
||||
+1
-5
@@ -263,8 +263,4 @@ MyData:
|
||||
You may observe a runtime instance of this on the [YouTube
|
||||
here](https://www.youtube.com/watch?v=A4yqVnByMMM) .
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="File Input and Output using XML and YAML files in OpenCV" width="560" height="349" src="http://www.youtube.com/embed/A4yqVnByMMM?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{A4yqVnByMMM}
|
||||
|
||||
@@ -214,8 +214,4 @@ the safety trait of iterators.
|
||||
|
||||
Finally, you may watch a sample run of the program on the [video posted](https://www.youtube.com/watch?v=fB3AN5fjgwc) on our YouTube channel.
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="How to scan images in OpenCV?" width="560" height="349" src="http://www.youtube.com/embed/fB3AN5fjgwc?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{fB3AN5fjgwc}
|
||||
|
||||
+1
-5
@@ -137,8 +137,4 @@ or find it in the
|
||||
`samples/cpp/tutorial_code/core/interoperability_with_OpenCV_1/interoperability_with_OpenCV_1.cpp`
|
||||
of the OpenCV source code library.
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Interoperability with OpenCV 1" width="560" height="349" src="http://www.youtube.com/embed/qckm-zvo31w?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{qckm-zvo31w}
|
||||
|
||||
+1
-5
@@ -266,8 +266,4 @@ or in the core section of the cpp samples.
|
||||
You can also find a quick video demonstration of this on
|
||||
[YouTube](https://www.youtube.com/watch?v=1tibU7vGWpk).
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Install OpenCV by using its source files - Part 1" width="560" height="349" src="http://www.youtube.com/embed/1tibU7vGWpk?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{1tibU7vGWpk}
|
||||
|
||||
@@ -203,8 +203,4 @@ In both cases we managed a performance increase of almost 100% compared to the C
|
||||
It may be just the improvement needed for your application to work. You may observe a runtime
|
||||
instance of this on the [YouTube here](https://www.youtube.com/watch?v=3_ESXmFlnvY).
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Similarity check (PNSR and SSIM) on the GPU" width="560" height="349" src="http://www.youtube.com/embed/3_ESXmFlnvY?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{3_ESXmFlnvY}
|
||||
|
||||
@@ -105,8 +105,4 @@ Result
|
||||
|
||||

|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Introduction - Display an Image" width="560" height="349" src="http://www.youtube.com/embed/1OJEqpuaGc4?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{1OJEqpuaGc4}
|
||||
|
||||
@@ -105,12 +105,8 @@ Installation by Making Your Own Libraries from the Source Files {#tutorial_windo
|
||||
You may find the content of this tutorial also inside the following videos:
|
||||
[Part 1](https://www.youtube.com/watch?v=NnovZ1cTlMs) and [Part 2](https://www.youtube.com/watch?v=qGNWMcfWwPU), hosted on YouTube.
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Install OpenCV by using its source files - Part 1" width="560" height="349" src="http://www.youtube.com/embed/NnovZ1cTlMs?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
<iframe title="Install OpenCV by using its source files - Part 2" width="560" height="349" src="http://www.youtube.com/embed/qGNWMcfWwPU?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{NnovZ1cTlMs}
|
||||
@youtube{qGNWMcfWwPU}
|
||||
|
||||
**warning**
|
||||
|
||||
|
||||
@@ -115,8 +115,4 @@ Output
|
||||
Check out an instance of running code with more Image Effects on
|
||||
[YouTube](http://www.youtube.com/watch?v=Ko3K_xdhJ1I) .
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe width="560" height="350" src="http://www.youtube.com/embed/Ko3K_xdhJ1I" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{Ko3K_xdhJ1I}
|
||||
|
||||
@@ -184,8 +184,4 @@ Results
|
||||
|
||||
You may observe a runtime instance of this on the [YouTube here](https://www.youtube.com/watch?v=vFv2yPcSo-Q).
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Support Vector Machines for Non-Linearly Separable Data" width="560" height="349" src="http://www.youtube.com/embed/vFv2yPcSo-Q?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{vFv2yPcSo-Q}
|
||||
|
||||
@@ -244,8 +244,4 @@ the console. Expect to see something like:
|
||||
|
||||
You may observe a runtime instance of this on the [YouTube here](https://www.youtube.com/watch?v=iOcNljutOgg).
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Video Input with OpenCV (Plus PSNR and MSSIM)" width="560" height="349" src="http://www.youtube.com/embed/iOcNljutOgg?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{iOcNljutOgg}
|
||||
|
||||
@@ -153,8 +153,4 @@ around the idea:
|
||||
You may observe a runtime instance of this on the [YouTube
|
||||
here](https://www.youtube.com/watch?v=jpBwHxsl1_0).
|
||||
|
||||
\htmlonly
|
||||
<div align="center">
|
||||
<iframe title="Creating a video with OpenCV" width="560" height="349" src="http://www.youtube.com/embed/jpBwHxsl1_0?rel=0&loop=1" frameborder="0" allowfullscreen align="middle"></iframe>
|
||||
</div>
|
||||
\endhtmlonly
|
||||
@youtube{jpBwHxsl1_0}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
Creating a 3D histogram {#tutorial_histo3D}
|
||||
================
|
||||
|
||||
Goal
|
||||
----
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
- Create your own callback keyboard function for viz window.
|
||||
- Show your 3D histogram in a viz window.
|
||||
|
||||
Code
|
||||
----
|
||||
|
||||
You can download the code from [here ](https://github.com/opencv/opencv/tree/master/samples/cpp/tutorial_code/viz/histo3D.cpp).
|
||||
@include samples/cpp/tutorial_code/viz/histo3D.cpp
|
||||
|
||||
Explanation
|
||||
-----------
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
- You can give full path to an image in command line
|
||||
@snippet histo3D.cpp command_line_parser
|
||||
|
||||
or without path, a synthetic image is generated with pixel values are a gaussian distribution @ref cv::RNG::fill center(60+/-10,40+/-5,50+/-20) in first quadrant,
|
||||
(160+/-20,10+/-5,50+/-10) in second quadrant, (90+/-10,100+/-20,50+/-20) in third quadrant, (100+/-10,10+/-5,150+/-40) in last quadrant.
|
||||
@snippet histo3D.cpp synthetic_image
|
||||
Image tridimensional histogram is calculated using opencv @ref cv::calcHist and @ref cv::normalize between 0 and 100.
|
||||
@snippet histo3D.cpp calchist_for_histo3d
|
||||
channel are 2, 1 and 0 to synchronise color with Viz axis color in objetc cv::viz::WCoordinateSystem.
|
||||
|
||||
A slidebar is inserted in image window. Init slidebar value is 90, it means that only histogram cell greater than 9/100000.0 (23 pixels for an 512X512 pixels) will be display.
|
||||
@snippet histo3D.cpp slide_bar_for_thresh
|
||||
We are ready to open a viz window with a callback function to capture keyboard event in viz window. Using @ref cv::viz::Viz3d::spinOnce enable keyboard event to be capture in @ref cv::imshow window too.
|
||||
@snippet histo3D.cpp manage_viz_imshow_window
|
||||
The function DrawHistogram3D processes histogram Mat to display it in a Viz window. Number of plan, row and column in [three dimensional Mat](@ref CVMat_Details ) can be found using this code :
|
||||
@snippet histo3D.cpp get_cube_size
|
||||
To get histogram value at a specific location we use @ref cv::Mat::at(int i0,int i1, int i2) method with three arguments k, i and j where k is plane number, i row number and j column number.
|
||||
@snippet histo3D.cpp get_cube_values
|
||||
|
||||
- Callback function
|
||||
Principle are as mouse callback function. Key code pressed is in field code of class @ref cv::viz::KeyboardEvent.
|
||||
@snippet histo3D.cpp viz_keyboard_callback
|
||||
|
||||
Results
|
||||
-------
|
||||
|
||||
Here is the result of the program with no argument and threshold equal to 50.
|
||||
|
||||

|
||||
Binary file not shown.
|
After Width: | Height: | Size: 839 KiB |
@@ -32,3 +32,11 @@ OpenCV Viz {#tutorial_table_of_content_viz}
|
||||
*Author:* Ozan Tonkal
|
||||
|
||||
You will learn how to create your own widgets.
|
||||
|
||||
- @subpage tutorial_histo3D
|
||||
|
||||
*Compatibility:* \> OpenCV 3.0.0
|
||||
|
||||
*Author:* Laurent Berger
|
||||
|
||||
You will learn how to plot a 3D histogram.
|
||||
|
||||
@@ -392,6 +392,12 @@ void CirclesGridClusterFinder::rectifyPatternPoints(const std::vector<cv::Point2
|
||||
|
||||
void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f> &patternPoints, const std::vector<cv::Point2f> &rectifiedPatternPoints, std::vector<cv::Point2f> ¢ers)
|
||||
{
|
||||
#ifndef HAVE_OPENCV_FLANN
|
||||
(void)patternPoints;
|
||||
(void)rectifiedPatternPoints;
|
||||
(void)centers;
|
||||
CV_Error(Error::StsNotImplemented, "The desired functionality requires flann module, which was disabled.");
|
||||
#else
|
||||
flann::LinearIndexParams flannIndexParams;
|
||||
flann::Index flannIndex(Mat(rectifiedPatternPoints).reshape(1), flannIndexParams);
|
||||
|
||||
@@ -425,6 +431,7 @@ void CirclesGridClusterFinder::parsePatternPoints(const std::vector<cv::Point2f>
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
Graph::Graph(size_t n)
|
||||
|
||||
@@ -2273,10 +2273,10 @@ Rect getValidDisparityROI( Rect roi1, Rect roi2,
|
||||
int SADWindowSize )
|
||||
{
|
||||
int SW2 = SADWindowSize/2;
|
||||
int minD = minDisparity, maxD = minDisparity + numberOfDisparities - 1;
|
||||
int maxD = minDisparity + numberOfDisparities - 1;
|
||||
|
||||
int xmin = std::max(roi1.x, roi2.x + maxD) + SW2;
|
||||
int xmax = std::min(roi1.x + roi1.width, roi2.x + roi2.width - minD) - SW2;
|
||||
int xmax = std::min(roi1.x + roi1.width, roi2.x + roi2.width) - SW2;
|
||||
int ymin = std::max(roi1.y, roi2.y) + SW2;
|
||||
int ymax = std::min(roi1.y + roi1.height, roi2.y + roi2.height) - SW2;
|
||||
|
||||
|
||||
@@ -468,6 +468,8 @@ bool CV_ChessboardDetectorTest::checkByGenerator()
|
||||
TEST(Calib3d_ChessboardDetector, accuracy) { CV_ChessboardDetectorTest test( CHESSBOARD ); test.safe_run(); }
|
||||
TEST(Calib3d_CirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( CIRCLES_GRID ); test.safe_run(); }
|
||||
TEST(Calib3d_AsymmetricCirclesPatternDetector, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID ); test.safe_run(); }
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
TEST(Calib3d_AsymmetricCirclesPatternDetectorWithClustering, accuracy) { CV_ChessboardDetectorTest test( ASYMMETRIC_CIRCLES_GRID, CALIB_CB_CLUSTERING ); test.safe_run(); }
|
||||
#endif
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -740,5 +740,6 @@ CV_EXPORTS_W void setUseIPP_NE(bool flag);
|
||||
} // cv
|
||||
|
||||
#include "opencv2/core/neon_utils.hpp"
|
||||
#include "opencv2/core/vsx_utils.hpp"
|
||||
|
||||
#endif //OPENCV_CORE_BASE_HPP
|
||||
|
||||
@@ -99,6 +99,14 @@
|
||||
# include <arm_neon.h>
|
||||
#endif
|
||||
|
||||
#if defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
|
||||
# include <altivec.h>
|
||||
# undef vector
|
||||
# undef pixel
|
||||
# undef bool
|
||||
# define CV_VSX 1
|
||||
#endif
|
||||
|
||||
#endif // CV_ENABLE_INTRINSICS && !CV_DISABLE_OPTIMIZATION && !__CUDACC__
|
||||
|
||||
#if defined CV_CPU_COMPILE_AVX && !defined CV_CPU_BASELINE_COMPILE_AVX
|
||||
@@ -135,6 +143,12 @@ struct VZeroUpperGuard {
|
||||
#elif defined(__ARM_NEON__) || (defined (__ARM_NEON) && defined(__aarch64__))
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
#elif defined(__VSX__) && defined(__PPC64__) && defined(__LITTLE_ENDIAN__)
|
||||
# include <altivec.h>
|
||||
# undef vector
|
||||
# undef pixel
|
||||
# undef bool
|
||||
# define CV_VSX 1
|
||||
#endif
|
||||
|
||||
#endif // !__OPENCV_BUILD && !__CUDACC (Compatibility code)
|
||||
@@ -208,3 +222,7 @@ struct VZeroUpperGuard {
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
#ifndef CV_VSX
|
||||
# define CV_VSX 0
|
||||
#endif
|
||||
|
||||
@@ -180,5 +180,20 @@
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_NEON(fn, args, mode, ...) CV_CPU_CALL_NEON(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#if !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_COMPILE_VSX
|
||||
# define CV_TRY_VSX 1
|
||||
# define CV_CPU_HAS_SUPPORT_VSX 1
|
||||
# define CV_CPU_CALL_VSX(fn, args) return (opt_VSX::fn args)
|
||||
#elif !defined CV_DISABLE_OPTIMIZATION && defined CV_ENABLE_INTRINSICS && defined CV_CPU_DISPATCH_COMPILE_VSX
|
||||
# define CV_TRY_VSX 1
|
||||
# define CV_CPU_HAS_SUPPORT_VSX (cv::checkHardwareSupport(CV_CPU_VSX))
|
||||
# define CV_CPU_CALL_VSX(fn, args) if (CV_CPU_HAS_SUPPORT_VSX) return (opt_VSX::fn args)
|
||||
#else
|
||||
# define CV_TRY_VSX 0
|
||||
# define CV_CPU_HAS_SUPPORT_VSX 0
|
||||
# define CV_CPU_CALL_VSX(fn, args)
|
||||
#endif
|
||||
#define __CV_CPU_DISPATCH_CHAIN_VSX(fn, args, mode, ...) CV_CPU_CALL_VSX(fn, args); __CV_EXPAND(__CV_CPU_DISPATCH_CHAIN_ ## mode(fn, args, __VA_ARGS__))
|
||||
|
||||
#define CV_CPU_CALL_BASELINE(fn, args) return (cpu_baseline::fn args)
|
||||
#define __CV_CPU_DISPATCH_CHAIN_BASELINE(fn, args, mode, ...) CV_CPU_CALL_BASELINE(fn, args) /* last in sequence */
|
||||
|
||||
@@ -153,6 +153,8 @@ namespace cv { namespace debug_build_guard { } using namespace debug_build_guard
|
||||
|
||||
#define CV_CPU_NEON 100
|
||||
|
||||
#define CV_CPU_VSX 200
|
||||
|
||||
// when adding to this list remember to update the following enum
|
||||
#define CV_HARDWARE_MAX_FEATURE 255
|
||||
|
||||
@@ -182,7 +184,9 @@ enum CpuFeatures {
|
||||
CPU_AVX_512VBMI = 20,
|
||||
CPU_AVX_512VL = 21,
|
||||
|
||||
CPU_NEON = 100
|
||||
CPU_NEON = 100,
|
||||
|
||||
CPU_VSX = 200
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -308,6 +308,7 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
#ifdef CV_DOXYGEN
|
||||
# undef CV_SSE2
|
||||
# undef CV_NEON
|
||||
# undef CV_VSX
|
||||
#endif
|
||||
|
||||
#if CV_SSE2
|
||||
@@ -318,6 +319,10 @@ CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
#include "opencv2/core/hal/intrin_neon.hpp"
|
||||
|
||||
#elif CV_VSX
|
||||
|
||||
#include "opencv2/core/hal/intrin_vsx.hpp"
|
||||
|
||||
#else
|
||||
|
||||
#include "opencv2/core/hal/intrin_cpp.hpp"
|
||||
@@ -435,7 +440,7 @@ template <> struct V_RegTrait128<double> {
|
||||
|
||||
inline unsigned int trailingZeros32(unsigned int value) {
|
||||
#if defined(_MSC_VER)
|
||||
#if (_MSC_VER < 1700)
|
||||
#if (_MSC_VER < 1700) || defined(_M_ARM)
|
||||
unsigned long index = 0;
|
||||
_BitScanForward(&index, value);
|
||||
return (unsigned int)index;
|
||||
|
||||
@@ -0,0 +1,927 @@
|
||||
/*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.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Copyright (C) 2015, Itseez 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_HAL_VSX_HPP
|
||||
#define OPENCV_HAL_VSX_HPP
|
||||
|
||||
#include <algorithm>
|
||||
#include "opencv2/core/utility.hpp"
|
||||
|
||||
#define CV_SIMD128 1
|
||||
#define CV_SIMD128_64F 1
|
||||
|
||||
/**
|
||||
* todo: supporting half precision for power9
|
||||
* convert instractions xvcvhpsp, xvcvsphp
|
||||
**/
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
//! @cond IGNORED
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_BEGIN
|
||||
|
||||
///////// Types ////////////
|
||||
|
||||
struct v_uint8x16
|
||||
{
|
||||
typedef uchar lane_type;
|
||||
enum { nlanes = 16 };
|
||||
vec_uchar16 val;
|
||||
|
||||
explicit v_uint8x16(const vec_uchar16& v) : val(v)
|
||||
{}
|
||||
v_uint8x16() : val(vec_uchar16_z)
|
||||
{}
|
||||
v_uint8x16(vec_bchar16 v) : val(vec_uchar16_c(v))
|
||||
{}
|
||||
v_uint8x16(uchar v0, uchar v1, uchar v2, uchar v3, uchar v4, uchar v5, uchar v6, uchar v7,
|
||||
uchar v8, uchar v9, uchar v10, uchar v11, uchar v12, uchar v13, uchar v14, uchar v15)
|
||||
: val(vec_uchar16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15))
|
||||
{}
|
||||
uchar get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int8x16
|
||||
{
|
||||
typedef schar lane_type;
|
||||
enum { nlanes = 16 };
|
||||
vec_char16 val;
|
||||
|
||||
explicit v_int8x16(const vec_char16& v) : val(v)
|
||||
{}
|
||||
v_int8x16() : val(vec_char16_z)
|
||||
{}
|
||||
v_int8x16(vec_bchar16 v) : val(vec_char16_c(v))
|
||||
{}
|
||||
v_int8x16(schar v0, schar v1, schar v2, schar v3, schar v4, schar v5, schar v6, schar v7,
|
||||
schar v8, schar v9, schar v10, schar v11, schar v12, schar v13, schar v14, schar v15)
|
||||
: val(vec_char16_set(v0, v1, v2, v3, v4, v5, v6, v7, v8, v9, v10, v11, v12, v13, v14, v15))
|
||||
{}
|
||||
schar get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_uint16x8
|
||||
{
|
||||
typedef ushort lane_type;
|
||||
enum { nlanes = 8 };
|
||||
vec_ushort8 val;
|
||||
|
||||
explicit v_uint16x8(const vec_ushort8& v) : val(v)
|
||||
{}
|
||||
v_uint16x8() : val(vec_ushort8_z)
|
||||
{}
|
||||
v_uint16x8(vec_bshort8 v) : val(vec_ushort8_c(v))
|
||||
{}
|
||||
v_uint16x8(ushort v0, ushort v1, ushort v2, ushort v3, ushort v4, ushort v5, ushort v6, ushort v7)
|
||||
: val(vec_ushort8_set(v0, v1, v2, v3, v4, v5, v6, v7))
|
||||
{}
|
||||
ushort get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int16x8
|
||||
{
|
||||
typedef short lane_type;
|
||||
enum { nlanes = 8 };
|
||||
vec_short8 val;
|
||||
|
||||
explicit v_int16x8(const vec_short8& v) : val(v)
|
||||
{}
|
||||
v_int16x8() : val(vec_short8_z)
|
||||
{}
|
||||
v_int16x8(vec_bshort8 v) : val(vec_short8_c(v))
|
||||
{}
|
||||
v_int16x8(short v0, short v1, short v2, short v3, short v4, short v5, short v6, short v7)
|
||||
: val(vec_short8_set(v0, v1, v2, v3, v4, v5, v6, v7))
|
||||
{}
|
||||
short get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_uint32x4
|
||||
{
|
||||
typedef unsigned lane_type;
|
||||
enum { nlanes = 4 };
|
||||
vec_uint4 val;
|
||||
|
||||
explicit v_uint32x4(const vec_uint4& v) : val(v)
|
||||
{}
|
||||
v_uint32x4() : val(vec_uint4_z)
|
||||
{}
|
||||
v_uint32x4(vec_bint4 v) : val(vec_uint4_c(v))
|
||||
{}
|
||||
v_uint32x4(unsigned v0, unsigned v1, unsigned v2, unsigned v3) : val(vec_uint4_set(v0, v1, v2, v3))
|
||||
{}
|
||||
uint get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int32x4
|
||||
{
|
||||
typedef int lane_type;
|
||||
enum { nlanes = 4 };
|
||||
vec_int4 val;
|
||||
|
||||
explicit v_int32x4(const vec_int4& v) : val(v)
|
||||
{}
|
||||
v_int32x4() : val(vec_int4_z)
|
||||
{}
|
||||
v_int32x4(vec_bint4 v) : val(vec_int4_c(v))
|
||||
{}
|
||||
v_int32x4(int v0, int v1, int v2, int v3) : val(vec_int4_set(v0, v1, v2, v3))
|
||||
{}
|
||||
int get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_float32x4
|
||||
{
|
||||
typedef float lane_type;
|
||||
enum { nlanes = 4 };
|
||||
vec_float4 val;
|
||||
|
||||
explicit v_float32x4(const vec_float4& v) : val(v)
|
||||
{}
|
||||
v_float32x4() : val(vec_float4_z)
|
||||
{}
|
||||
v_float32x4(vec_bint4 v) : val(vec_float4_c(v))
|
||||
{}
|
||||
v_float32x4(float v0, float v1, float v2, float v3) : val(vec_float4_set(v0, v1, v2, v3))
|
||||
{}
|
||||
float get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_uint64x2
|
||||
{
|
||||
typedef uint64 lane_type;
|
||||
enum { nlanes = 2 };
|
||||
vec_udword2 val;
|
||||
|
||||
explicit v_uint64x2(const vec_udword2& v) : val(v)
|
||||
{}
|
||||
v_uint64x2() : val(vec_udword2_z)
|
||||
{}
|
||||
v_uint64x2(vec_bdword2 v) : val(vec_udword2_c(v))
|
||||
{}
|
||||
v_uint64x2(uint64 v0, uint64 v1) : val(vec_udword2_set(v0, v1))
|
||||
{}
|
||||
uint64 get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_int64x2
|
||||
{
|
||||
typedef int64 lane_type;
|
||||
enum { nlanes = 2 };
|
||||
vec_dword2 val;
|
||||
|
||||
explicit v_int64x2(const vec_dword2& v) : val(v)
|
||||
{}
|
||||
v_int64x2() : val(vec_dword2_z)
|
||||
{}
|
||||
v_int64x2(vec_bdword2 v) : val(vec_dword2_c(v))
|
||||
{}
|
||||
v_int64x2(int64 v0, int64 v1) : val(vec_dword2_set(v0, v1))
|
||||
{}
|
||||
int64 get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
struct v_float64x2
|
||||
{
|
||||
typedef double lane_type;
|
||||
enum { nlanes = 2 };
|
||||
vec_double2 val;
|
||||
|
||||
explicit v_float64x2(const vec_double2& v) : val(v)
|
||||
{}
|
||||
v_float64x2() : val(vec_double2_z)
|
||||
{}
|
||||
v_float64x2(vec_bdword2 v) : val(vec_double2_c(v))
|
||||
{}
|
||||
v_float64x2(double v0, double v1) : val(vec_double2_set(v0, v1))
|
||||
{}
|
||||
double get0() const
|
||||
{ return vec_extract(val, 0); }
|
||||
};
|
||||
|
||||
//////////////// Load and store operations ///////////////
|
||||
|
||||
/*
|
||||
* clang-5 aborted during parse "vec_xxx_c" only if it's
|
||||
* inside a function template which is defined by preprocessor macro.
|
||||
*
|
||||
* if vec_xxx_c defined as C++ cast, clang-5 will pass it
|
||||
*/
|
||||
#define OPENCV_HAL_IMPL_VSX_INITVEC(_Tpvec, _Tp, suffix, cast) \
|
||||
inline _Tpvec v_setzero_##suffix() { return _Tpvec(); } \
|
||||
inline _Tpvec v_setall_##suffix(_Tp v) { return _Tpvec(vec_splats((_Tp)v));} \
|
||||
template<typename _Tpvec0> inline _Tpvec v_reinterpret_as_##suffix(const _Tpvec0 &a) \
|
||||
{ return _Tpvec((cast)a.val); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint8x16, uchar, u8, vec_uchar16)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int8x16, schar, s8, vec_char16)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint16x8, ushort, u16, vec_ushort8)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int16x8, short, s16, vec_short8)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint32x4, uint, u32, vec_uint4)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int32x4, int, s32, vec_int4)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_uint64x2, uint64, u64, vec_udword2)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_int64x2, int64, s64, vec_dword2)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_float32x4, float, f32, vec_float4)
|
||||
OPENCV_HAL_IMPL_VSX_INITVEC(v_float64x2, double, f64, vec_double2)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(_Tpvec, _Tp, ld_func, st_func) \
|
||||
inline _Tpvec v_load(const _Tp* ptr) \
|
||||
{ return _Tpvec(ld_func(0, ptr)); } \
|
||||
inline _Tpvec v_load_aligned(const _Tp* ptr) \
|
||||
{ return _Tpvec(ld_func(0, ptr)); } \
|
||||
inline _Tpvec v_load_halves(const _Tp* ptr0, const _Tp* ptr1) \
|
||||
{ return _Tpvec(vec_mergesqh(vec_ld_l8(ptr0), vec_ld_l8(ptr1))); } \
|
||||
inline void v_store(_Tp* ptr, const _Tpvec& a) \
|
||||
{ st_func(a.val, 0, ptr); } \
|
||||
inline void v_store_aligned(_Tp* ptr, const _Tpvec& a) \
|
||||
{ st_func(a.val, 0, ptr); } \
|
||||
inline void v_store_low(_Tp* ptr, const _Tpvec& a) \
|
||||
{ vec_st_l8(a.val, ptr); } \
|
||||
inline void v_store_high(_Tp* ptr, const _Tpvec& a) \
|
||||
{ vec_st_h8(a.val, ptr); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint8x16, uchar, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int8x16, schar, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint16x8, ushort, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int16x8, short, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint32x4, uint, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int32x4, int, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_float32x4, float, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_float64x2, double, vsx_ld, vsx_st)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_uint64x2, uint64, vsx_ld2, vsx_st2)
|
||||
OPENCV_HAL_IMPL_VSX_LOADSTORE_INT_OP(v_int64x2, int64, vsx_ld2, vsx_st2)
|
||||
|
||||
//////////////// Value reordering ///////////////
|
||||
|
||||
/* de&interleave */
|
||||
#define OPENCV_HAL_IMPL_VSX_INTERLEAVE(_Tp, _Tpvec) \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b) \
|
||||
{ vec_ld_deinterleave(ptr, a.val, b.val);} \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, \
|
||||
_Tpvec& b, _Tpvec& c) \
|
||||
{ vec_ld_deinterleave(ptr, a.val, b.val, c.val); } \
|
||||
inline void v_load_deinterleave(const _Tp* ptr, _Tpvec& a, _Tpvec& b, \
|
||||
_Tpvec& c, _Tpvec& d) \
|
||||
{ vec_ld_deinterleave(ptr, a.val, b.val, c.val, d.val); } \
|
||||
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b) \
|
||||
{ vec_st_interleave(a.val, b.val, ptr); } \
|
||||
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, \
|
||||
const _Tpvec& b, const _Tpvec& c) \
|
||||
{ vec_st_interleave(a.val, b.val, c.val, ptr); } \
|
||||
inline void v_store_interleave(_Tp* ptr, const _Tpvec& a, const _Tpvec& b, \
|
||||
const _Tpvec& c, const _Tpvec& d) \
|
||||
{ vec_st_interleave(a.val, b.val, c.val, d.val, ptr); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(uchar, v_uint8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(schar, v_int8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(ushort, v_uint16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(short, v_int16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(uint, v_uint32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(int, v_int32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(float, v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INTERLEAVE(double, v_float64x2)
|
||||
|
||||
/* Expand */
|
||||
#define OPENCV_HAL_IMPL_VSX_EXPAND(_Tpvec, _Tpwvec, _Tp, fl, fh) \
|
||||
inline void v_expand(const _Tpvec& a, _Tpwvec& b0, _Tpwvec& b1) \
|
||||
{ \
|
||||
b0.val = fh(a.val); \
|
||||
b1.val = fl(a.val); \
|
||||
} \
|
||||
inline _Tpwvec v_load_expand(const _Tp* ptr) \
|
||||
{ return _Tpwvec(fh(vsx_ld(0, ptr))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_uint8x16, v_uint16x8, uchar, vec_unpacklu, vec_unpackhu)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_int8x16, v_int16x8, schar, vec_unpackl, vec_unpackh)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_uint16x8, v_uint32x4, ushort, vec_unpacklu, vec_unpackhu)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_int16x8, v_int32x4, short, vec_unpackl, vec_unpackh)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_uint32x4, v_uint64x2, uint, vec_unpacklu, vec_unpackhu)
|
||||
OPENCV_HAL_IMPL_VSX_EXPAND(v_int32x4, v_int64x2, int, vec_unpackl, vec_unpackh)
|
||||
|
||||
inline v_uint32x4 v_load_expand_q(const uchar* ptr)
|
||||
{ return v_uint32x4(vec_ld_buw(ptr)); }
|
||||
|
||||
inline v_int32x4 v_load_expand_q(const schar* ptr)
|
||||
{ return v_int32x4(vec_ld_bsw(ptr)); }
|
||||
|
||||
/* pack */
|
||||
#define OPENCV_HAL_IMPL_VSX_PACK(_Tpvec, _Tp, _Tpwvec, _Tpvn, _Tpdel, sfnc, pkfnc, addfnc, pack) \
|
||||
inline _Tpvec v_##pack(const _Tpwvec& a, const _Tpwvec& b) \
|
||||
{ \
|
||||
return _Tpvec(pkfnc(a.val, b.val)); \
|
||||
} \
|
||||
inline void v_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
|
||||
{ \
|
||||
vec_st_l8(pkfnc(a.val, a.val), ptr); \
|
||||
} \
|
||||
template<int n> \
|
||||
inline _Tpvec v_rshr_##pack(const _Tpwvec& a, const _Tpwvec& b) \
|
||||
{ \
|
||||
const __vector _Tpvn vn = vec_splats((_Tpvn)n); \
|
||||
const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \
|
||||
return _Tpvec(pkfnc(sfnc(addfnc(a.val, delta), vn), sfnc(addfnc(b.val, delta), vn))); \
|
||||
} \
|
||||
template<int n> \
|
||||
inline void v_rshr_##pack##_store(_Tp* ptr, const _Tpwvec& a) \
|
||||
{ \
|
||||
const __vector _Tpvn vn = vec_splats((_Tpvn)n); \
|
||||
const __vector _Tpdel delta = vec_splats((_Tpdel)((_Tpdel)1 << (n-1))); \
|
||||
vec_st_l8(pkfnc(sfnc(addfnc(a.val, delta), vn), delta), ptr); \
|
||||
}
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_uint16x8, unsigned short, unsigned short,
|
||||
vec_sr, vec_packs, vec_adds, pack)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_int8x16, schar, v_int16x8, unsigned short, short,
|
||||
vec_sra, vec_packs, vec_adds, pack)
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_uint32x4, unsigned int, unsigned int,
|
||||
vec_sr, vec_packs, vec_add, pack)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_int16x8, short, v_int32x4, unsigned int, int,
|
||||
vec_sra, vec_packs, vec_add, pack)
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_uint64x2, unsigned long long, unsigned long long,
|
||||
vec_sr, vec_packs, vec_add, pack)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_int32x4, int, v_int64x2, unsigned long long, long long,
|
||||
vec_sra, vec_packs, vec_add, pack)
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint8x16, uchar, v_int16x8, unsigned short, short,
|
||||
vec_sra, vec_packsu, vec_adds, pack_u)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint16x8, ushort, v_int32x4, unsigned int, int,
|
||||
vec_sra, vec_packsu, vec_add, pack_u)
|
||||
OPENCV_HAL_IMPL_VSX_PACK(v_uint32x4, uint, v_int64x2, unsigned long long, long long,
|
||||
vec_sra, vec_packsu, vec_add, pack_u)
|
||||
|
||||
/* Recombine */
|
||||
template <typename _Tpvec>
|
||||
inline void v_zip(const _Tpvec& a0, const _Tpvec& a1, _Tpvec& b0, _Tpvec& b1)
|
||||
{
|
||||
b0.val = vec_mergeh(a0.val, a1.val);
|
||||
b1.val = vec_mergel(a0.val, a1.val);
|
||||
}
|
||||
|
||||
template <typename _Tpvec>
|
||||
inline _Tpvec v_combine_high(const _Tpvec& a, const _Tpvec& b)
|
||||
{ return _Tpvec(vec_mergesql(a.val, b.val)); }
|
||||
|
||||
template <typename _Tpvec>
|
||||
inline _Tpvec v_combine_low(const _Tpvec& a, const _Tpvec& b)
|
||||
{ return _Tpvec(vec_mergesqh(a.val, b.val)); }
|
||||
|
||||
template <typename _Tpvec>
|
||||
inline void v_recombine(const _Tpvec& a, const _Tpvec& b, _Tpvec& c, _Tpvec& d)
|
||||
{
|
||||
c.val = vec_mergesqh(a.val, b.val);
|
||||
d.val = vec_mergesql(a.val, b.val);
|
||||
}
|
||||
|
||||
/* Extract */
|
||||
template<int s, typename _Tpvec>
|
||||
inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b)
|
||||
{
|
||||
const int w = sizeof(typename _Tpvec::lane_type);
|
||||
const int n = _Tpvec::nlanes;
|
||||
const unsigned int sf = ((w * n) - (s * w));
|
||||
if (s == 0)
|
||||
return _Tpvec(a.val);
|
||||
else if (sf > 15)
|
||||
return _Tpvec();
|
||||
// bitwise it just to make xlc happy
|
||||
return _Tpvec(vec_sld(b.val, a.val, sf & 15));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_EXTRACT_2(_Tpvec) \
|
||||
template<int s> \
|
||||
inline _Tpvec v_extract(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ \
|
||||
switch(s) { \
|
||||
case 0: return _Tpvec(a.val); \
|
||||
case 2: return _Tpvec(b.val); \
|
||||
case 1: return _Tpvec(vec_sldw(b.val, a.val, 2)); \
|
||||
default: return _Tpvec(); \
|
||||
} \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_EXTRACT_2(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_VSX_EXTRACT_2(v_int64x2)
|
||||
|
||||
|
||||
////////// Arithmetic, bitwise and comparison operations /////////
|
||||
|
||||
/* Element-wise binary and unary operations */
|
||||
/** Arithmetics **/
|
||||
#define OPENCV_HAL_IMPL_VSX_BIN_OP(bin_op, _Tpvec, intrin) \
|
||||
inline _Tpvec operator bin_op (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(intrin(a.val, b.val)); } \
|
||||
inline _Tpvec& operator bin_op##= (_Tpvec& a, const _Tpvec& b) \
|
||||
{ a.val = intrin(a.val, b.val); return a; }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint8x16, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint8x16, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int8x16, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int8x16, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint16x8, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint16x8, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_uint16x8, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int16x8, vec_adds)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int16x8, vec_subs)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_int16x8, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint32x4, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint32x4, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_uint32x4, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int32x4, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int32x4, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_int32x4, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float32x4, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float32x4, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float32x4, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float32x4, vec_div)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_float64x2, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_float64x2, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(*, v_float64x2, vec_mul)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(/, v_float64x2, vec_div)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_uint64x2, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_uint64x2, vec_sub)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(+, v_int64x2, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(-, v_int64x2, vec_sub)
|
||||
|
||||
inline void v_mul_expand(const v_int16x8& a, const v_int16x8& b, v_int32x4& c, v_int32x4& d)
|
||||
{
|
||||
c.val = vec_mul(vec_unpackh(a.val), vec_unpackh(b.val));
|
||||
d.val = vec_mul(vec_unpackl(a.val), vec_unpackl(b.val));
|
||||
}
|
||||
inline void v_mul_expand(const v_uint16x8& a, const v_uint16x8& b, v_uint32x4& c, v_uint32x4& d)
|
||||
{
|
||||
c.val = vec_mul(vec_unpackhu(a.val), vec_unpackhu(b.val));
|
||||
d.val = vec_mul(vec_unpacklu(a.val), vec_unpacklu(b.val));
|
||||
}
|
||||
inline void v_mul_expand(const v_uint32x4& a, const v_uint32x4& b, v_uint64x2& c, v_uint64x2& d)
|
||||
{
|
||||
c.val = vec_mul(vec_unpackhu(a.val), vec_unpackhu(b.val));
|
||||
d.val = vec_mul(vec_unpacklu(a.val), vec_unpacklu(b.val));
|
||||
}
|
||||
|
||||
/** Non-saturating arithmetics **/
|
||||
#define OPENCV_HAL_IMPL_VSX_BIN_FUNC(func, intrin) \
|
||||
template<typename _Tpvec> \
|
||||
inline _Tpvec func(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(intrin(a.val, b.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_add_wrap, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_sub_wrap, vec_sub)
|
||||
|
||||
/** Bitwise shifts **/
|
||||
#define OPENCV_HAL_IMPL_VSX_SHIFT_OP(_Tpuvec, splfunc) \
|
||||
inline _Tpuvec operator << (const _Tpuvec& a, int imm) \
|
||||
{ return _Tpuvec(vec_sl(a.val, splfunc(imm))); } \
|
||||
inline _Tpuvec operator >> (const _Tpuvec& a, int imm) \
|
||||
{ return _Tpuvec(vec_sr(a.val, splfunc(imm))); } \
|
||||
template<int imm> inline _Tpuvec v_shl(const _Tpuvec& a) \
|
||||
{ return _Tpuvec(vec_sl(a.val, splfunc(imm))); } \
|
||||
template<int imm> inline _Tpuvec v_shr(const _Tpuvec& a) \
|
||||
{ return _Tpuvec(vec_sr(a.val, splfunc(imm))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint8x16, vec_uchar16_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int8x16, vec_uchar16_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint16x8, vec_ushort8_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int16x8, vec_ushort8_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint32x4, vec_uint4_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int32x4, vec_uint4_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_uint64x2, vec_udword2_sp)
|
||||
OPENCV_HAL_IMPL_VSX_SHIFT_OP(v_int64x2, vec_udword2_sp)
|
||||
|
||||
/** Bitwise logic **/
|
||||
#define OPENCV_HAL_IMPL_VSX_LOGIC_OP(_Tpvec) \
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(&, _Tpvec, vec_and) \
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(|, _Tpvec, vec_or) \
|
||||
OPENCV_HAL_IMPL_VSX_BIN_OP(^, _Tpvec, vec_xor) \
|
||||
inline _Tpvec operator ~ (const _Tpvec& a) \
|
||||
{ return _Tpvec(vec_not(a.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint8x16)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int8x16)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint16x8)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int16x8)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint32x4)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int32x4)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_int64x2)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_LOGIC_OP(v_float64x2)
|
||||
|
||||
/** Bitwise select **/
|
||||
#define OPENCV_HAL_IMPL_VSX_SELECT(_Tpvec, cast) \
|
||||
inline _Tpvec v_select(const _Tpvec& mask, const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_sel(b.val, a.val, cast(mask.val))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_uint8x16, vec_bchar16_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_int8x16, vec_bchar16_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_uint16x8, vec_bshort8_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_int16x8, vec_bshort8_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_uint32x4, vec_bint4_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_int32x4, vec_bint4_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_float32x4, vec_bint4_c)
|
||||
OPENCV_HAL_IMPL_VSX_SELECT(v_float64x2, vec_bdword2_c)
|
||||
|
||||
/** Comparison **/
|
||||
#define OPENCV_HAL_IMPL_VSX_INT_CMP_OP(_Tpvec) \
|
||||
inline _Tpvec operator == (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpeq(a.val, b.val)); } \
|
||||
inline _Tpvec operator != (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpne(a.val, b.val)); } \
|
||||
inline _Tpvec operator < (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmplt(a.val, b.val)); } \
|
||||
inline _Tpvec operator > (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpgt(a.val, b.val)); } \
|
||||
inline _Tpvec operator <= (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmple(a.val, b.val)); } \
|
||||
inline _Tpvec operator >= (const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_cmpge(a.val, b.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int8x16)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int16x8)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_float64x2)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_uint64x2)
|
||||
OPENCV_HAL_IMPL_VSX_INT_CMP_OP(v_int64x2)
|
||||
|
||||
/** min/max **/
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_max, vec_max)
|
||||
|
||||
////////// Reduce and mask /////////
|
||||
|
||||
/** Reduce **/
|
||||
inline short v_reduce_sum(const v_int16x8& a)
|
||||
{
|
||||
const vec_int4 zero = vec_int4_z;
|
||||
return saturate_cast<short>(vec_extract(vec_sums(vec_sum4s(a.val, zero), zero), 3));
|
||||
}
|
||||
inline ushort v_reduce_sum(const v_uint16x8& a)
|
||||
{
|
||||
const vec_int4 v4 = vec_int4_c(vec_unpackhu(vec_adds(a.val, vec_sld(a.val, a.val, 8))));
|
||||
return saturate_cast<ushort>(vec_extract(vec_sums(v4, vec_int4_z), 3));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(_Tpvec, _Tpvec2, scalartype, suffix, func) \
|
||||
inline scalartype v_reduce_##suffix(const _Tpvec& a) \
|
||||
{ \
|
||||
const _Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \
|
||||
return vec_extract(func(rs, vec_sld(rs, rs, 4)), 0); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, sum, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_uint32x4, vec_uint4, uint, min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, sum, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_int32x4, vec_int4, int, min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, sum, vec_add)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_4(v_float32x4, vec_float4, float, min, vec_min)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(_Tpvec, _Tpvec2, scalartype, suffix, func) \
|
||||
inline scalartype v_reduce_##suffix(const _Tpvec& a) \
|
||||
{ \
|
||||
_Tpvec2 rs = func(a.val, vec_sld(a.val, a.val, 8)); \
|
||||
rs = func(rs, vec_sld(rs, rs, 4)); \
|
||||
return vec_extract(func(rs, vec_sld(rs, rs, 2)), 0); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_uint16x8, vec_ushort8, ushort, min, vec_min)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, max, vec_max)
|
||||
OPENCV_HAL_IMPL_VSX_REDUCE_OP_8(v_int16x8, vec_short8, short, min, vec_min)
|
||||
|
||||
inline v_float32x4 v_reduce_sum4(const v_float32x4& a, const v_float32x4& b,
|
||||
const v_float32x4& c, const v_float32x4& d)
|
||||
{
|
||||
vec_float4 ac = vec_add(vec_mergel(a.val, c.val), vec_mergeh(a.val, c.val));
|
||||
ac = vec_add(ac, vec_sld(ac, ac, 8));
|
||||
|
||||
vec_float4 bd = vec_add(vec_mergel(b.val, d.val), vec_mergeh(b.val, d.val));
|
||||
bd = vec_add(bd, vec_sld(bd, bd, 8));
|
||||
return v_float32x4(vec_mergeh(ac, bd));
|
||||
}
|
||||
|
||||
/** Popcount **/
|
||||
#define OPENCV_HAL_IMPL_VSX_POPCOUNT_8(_Tpvec) \
|
||||
inline v_uint32x4 v_popcount(const _Tpvec& a) \
|
||||
{ \
|
||||
vec_uchar16 v16 = vec_popcntu(a.val); \
|
||||
vec_ushort8 v8 = vec_add(vec_unpacklu(v16), vec_unpackhu(v16)); \
|
||||
return v_uint32x4(vec_add(vec_unpacklu(v8), vec_unpackhu(v8))); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_POPCOUNT_8(v_int8x16)
|
||||
OPENCV_HAL_IMPL_VSX_POPCOUNT_8(v_uint8x16)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_POPCOUNT_16(_Tpvec) \
|
||||
inline v_uint32x4 v_popcount(const _Tpvec& a) \
|
||||
{ \
|
||||
vec_ushort8 v8 = vec_popcntu(a.val); \
|
||||
return v_uint32x4(vec_add(vec_unpacklu(v8), vec_unpackhu(v8))); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_POPCOUNT_16(v_int16x8)
|
||||
OPENCV_HAL_IMPL_VSX_POPCOUNT_16(v_uint16x8)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_POPCOUNT_32(_Tpvec) \
|
||||
inline v_uint32x4 v_popcount(const _Tpvec& a) \
|
||||
{ return v_uint32x4(vec_popcntu(a.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_POPCOUNT_32(v_int32x4)
|
||||
OPENCV_HAL_IMPL_VSX_POPCOUNT_32(v_uint32x4)
|
||||
|
||||
/** Mask **/
|
||||
inline int v_signmask(const v_uint8x16& a)
|
||||
{
|
||||
vec_uchar16 sv = vec_sr(a.val, vec_uchar16_sp(7));
|
||||
static const vec_uchar16 slm = {0, 1, 2, 3, 4, 5, 6, 7, 0, 1, 2, 3, 4, 5, 6, 7};
|
||||
sv = vec_sl(sv, slm);
|
||||
vec_uint4 sv4 = vec_sum4s(sv, vec_uint4_z);
|
||||
static const vec_uint4 slm4 = {0, 0, 8, 8};
|
||||
sv4 = vec_sl(sv4, slm4);
|
||||
return vec_extract(vec_sums((vec_int4) sv4, vec_int4_z), 3);
|
||||
}
|
||||
inline int v_signmask(const v_int8x16& a)
|
||||
{ return v_signmask(v_reinterpret_as_u8(a)); }
|
||||
|
||||
inline int v_signmask(const v_int16x8& a)
|
||||
{
|
||||
static const vec_ushort8 slm = {0, 1, 2, 3, 4, 5, 6, 7};
|
||||
vec_short8 sv = vec_sr(a.val, vec_ushort8_sp(15));
|
||||
sv = vec_sl(sv, slm);
|
||||
vec_int4 svi = vec_int4_z;
|
||||
svi = vec_sums(vec_sum4s(sv, svi), svi);
|
||||
return vec_extract(svi, 3);
|
||||
}
|
||||
inline int v_signmask(const v_uint16x8& a)
|
||||
{ return v_signmask(v_reinterpret_as_s16(a)); }
|
||||
|
||||
inline int v_signmask(const v_int32x4& a)
|
||||
{
|
||||
static const vec_uint4 slm = {0, 1, 2, 3};
|
||||
vec_int4 sv = vec_sr(a.val, vec_uint4_sp(31));
|
||||
sv = vec_sl(sv, slm);
|
||||
sv = vec_sums(sv, vec_int4_z);
|
||||
return vec_extract(sv, 3);
|
||||
}
|
||||
inline int v_signmask(const v_uint32x4& a)
|
||||
{ return v_signmask(v_reinterpret_as_s32(a)); }
|
||||
inline int v_signmask(const v_float32x4& a)
|
||||
{ return v_signmask(v_reinterpret_as_s32(a)); }
|
||||
|
||||
inline int v_signmask(const v_int64x2& a)
|
||||
{
|
||||
const vec_dword2 sv = vec_sr(a.val, vec_udword2_sp(63));
|
||||
return (int)vec_extract(sv, 0) | (int)vec_extract(sv, 1) << 1;
|
||||
}
|
||||
inline int v_signmask(const v_uint64x2& a)
|
||||
{ return v_signmask(v_reinterpret_as_s64(a)); }
|
||||
inline int v_signmask(const v_float64x2& a)
|
||||
{ return v_signmask(v_reinterpret_as_s64(a)); }
|
||||
|
||||
|
||||
template<typename _Tpvec>
|
||||
inline bool v_check_all(const _Tpvec& a)
|
||||
{ return vec_all_lt(a.val, _Tpvec().val);}
|
||||
inline bool v_check_all(const v_uint8x16 &a)
|
||||
{ return v_check_all(v_reinterpret_as_s8(a)); }
|
||||
inline bool v_check_all(const v_uint16x8 &a)
|
||||
{ return v_check_all(v_reinterpret_as_s16(a)); }
|
||||
inline bool v_check_all(const v_uint32x4 &a)
|
||||
{ return v_check_all(v_reinterpret_as_s32(a)); }
|
||||
|
||||
template<typename _Tpvec>
|
||||
inline bool v_check_any(const _Tpvec& a)
|
||||
{ return vec_any_lt(a.val, _Tpvec().val);}
|
||||
inline bool v_check_any(const v_uint8x16 &a)
|
||||
{ return v_check_any(v_reinterpret_as_s8(a)); }
|
||||
inline bool v_check_any(const v_uint16x8 &a)
|
||||
{ return v_check_any(v_reinterpret_as_s16(a)); }
|
||||
inline bool v_check_any(const v_uint32x4 &a)
|
||||
{ return v_check_any(v_reinterpret_as_s32(a)); }
|
||||
|
||||
////////// Other math /////////
|
||||
|
||||
/** Some frequent operations **/
|
||||
inline v_float32x4 v_sqrt(const v_float32x4& x)
|
||||
{ return v_float32x4(vec_sqrt(x.val)); }
|
||||
inline v_float64x2 v_sqrt(const v_float64x2& x)
|
||||
{ return v_float64x2(vec_sqrt(x.val)); }
|
||||
|
||||
inline v_float32x4 v_invsqrt(const v_float32x4& x)
|
||||
{ return v_float32x4(vec_rsqrt(x.val)); }
|
||||
inline v_float64x2 v_invsqrt(const v_float64x2& x)
|
||||
{ return v_float64x2(vec_rsqrt(x.val)); }
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_MULADD(_Tpvec) \
|
||||
inline _Tpvec v_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_sqrt(vec_madd(a.val, a.val, vec_mul(b.val, b.val)))); } \
|
||||
inline _Tpvec v_sqr_magnitude(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec(vec_madd(a.val, a.val, vec_mul(b.val, b.val))); } \
|
||||
inline _Tpvec v_muladd(const _Tpvec& a, const _Tpvec& b, const _Tpvec& c) \
|
||||
{ return _Tpvec(vec_madd(a.val, b.val, c.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_MULADD(v_float32x4)
|
||||
OPENCV_HAL_IMPL_VSX_MULADD(v_float64x2)
|
||||
|
||||
// TODO: exp, log, sin, cos
|
||||
|
||||
/** Absolute values **/
|
||||
inline v_uint8x16 v_abs(const v_int8x16& x)
|
||||
{ return v_uint8x16(vec_uchar16_c(vec_abs(x.val))); }
|
||||
|
||||
inline v_uint16x8 v_abs(const v_int16x8& x)
|
||||
{ return v_uint16x8(vec_ushort8_c(vec_abs(x.val))); }
|
||||
|
||||
inline v_uint32x4 v_abs(const v_int32x4& x)
|
||||
{ return v_uint32x4(vec_uint4_c(vec_abs(x.val))); }
|
||||
|
||||
inline v_float32x4 v_abs(const v_float32x4& x)
|
||||
{ return v_float32x4(vec_abs(x.val)); }
|
||||
|
||||
inline v_float64x2 v_abs(const v_float64x2& x)
|
||||
{ return v_float64x2(vec_abs(x.val)); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC(v_absdiff, vec_absd)
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_BIN_FUNC2(_Tpvec, _Tpvec2, cast, func, intrin) \
|
||||
inline _Tpvec2 func(const _Tpvec& a, const _Tpvec& b) \
|
||||
{ return _Tpvec2(cast(intrin(a.val, b.val))); }
|
||||
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int8x16, v_uint8x16, vec_uchar16_c, v_absdiff, vec_absd)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int16x8, v_uint16x8, vec_ushort8_c, v_absdiff, vec_absd)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int32x4, v_uint32x4, vec_uint4_c, v_absdiff, vec_absd)
|
||||
OPENCV_HAL_IMPL_VSX_BIN_FUNC2(v_int64x2, v_uint64x2, vec_udword2_c, v_absdiff, vec_absd)
|
||||
|
||||
////////// Conversions /////////
|
||||
|
||||
/** Rounding **/
|
||||
inline v_int32x4 v_round(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(vec_round(a.val), 0)); }
|
||||
|
||||
inline v_int32x4 v_round(const v_float64x2& a)
|
||||
{
|
||||
static const vec_uchar16 perm = {16, 17, 18, 19, 24, 25, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
return v_int32x4(vec_perm(vec_int4_z, vec_ctsw(vec_round(a.val)), perm));
|
||||
}
|
||||
|
||||
inline v_int32x4 v_floor(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(vec_floor(a.val), 0)); }
|
||||
|
||||
inline v_int32x4 v_floor(const v_float64x2& a)
|
||||
{
|
||||
static const vec_uchar16 perm = {16, 17, 18, 19, 24, 25, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
return v_int32x4(vec_perm(vec_int4_z, vec_ctsw(vec_floor(a.val)), perm));
|
||||
}
|
||||
|
||||
inline v_int32x4 v_ceil(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(vec_ceil(a.val), 0)); }
|
||||
|
||||
inline v_int32x4 v_ceil(const v_float64x2& a)
|
||||
{
|
||||
static const vec_uchar16 perm = {16, 17, 18, 19, 24, 25, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
return v_int32x4(vec_perm(vec_int4_z, vec_ctsw(vec_ceil(a.val)), perm));
|
||||
}
|
||||
|
||||
inline v_int32x4 v_trunc(const v_float32x4& a)
|
||||
{ return v_int32x4(vec_cts(a.val, 0)); }
|
||||
|
||||
inline v_int32x4 v_trunc(const v_float64x2& a)
|
||||
{
|
||||
static const vec_uchar16 perm = {16, 17, 18, 19, 24, 25, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
return v_int32x4(vec_perm(vec_int4_z, vec_ctsw(a.val), perm));
|
||||
}
|
||||
|
||||
/** To float **/
|
||||
inline v_float32x4 v_cvt_f32(const v_int32x4& a)
|
||||
{ return v_float32x4(vec_ctf(a.val, 0)); }
|
||||
|
||||
inline v_float32x4 v_cvt_f32(const v_float64x2& a)
|
||||
{
|
||||
static const vec_uchar16 perm = {16, 17, 18, 19, 24, 25, 26, 27, 0, 0, 0, 0, 0, 0, 0, 0};
|
||||
return v_float32x4(vec_perm(vec_float4_z, vec_cvf(a.val), perm));
|
||||
}
|
||||
inline v_float64x2 v_cvt_f64(const v_int32x4& a)
|
||||
{
|
||||
return v_float64x2(vec_ctd(vec_mergeh(a.val, a.val), 0));
|
||||
}
|
||||
inline v_float64x2 v_cvt_f64_high(const v_int32x4& a)
|
||||
{
|
||||
return v_float64x2(vec_ctd(vec_mergel(a.val, a.val), 0));
|
||||
}
|
||||
inline v_float64x2 v_cvt_f64(const v_float32x4& a)
|
||||
{
|
||||
return v_float64x2(vec_cvf(vec_mergeh(a.val, a.val)));
|
||||
}
|
||||
inline v_float64x2 v_cvt_f64_high(const v_float32x4& a)
|
||||
{
|
||||
return v_float64x2(vec_cvf(vec_mergel(a.val, a.val)));
|
||||
}
|
||||
|
||||
/** Reinterpret **/
|
||||
/** its up there with load and store operations **/
|
||||
|
||||
////////// Matrix operations /////////
|
||||
|
||||
inline v_int32x4 v_dotprod(const v_int16x8& a, const v_int16x8& b)
|
||||
{ return v_int32x4(vec_msum(a.val, b.val, vec_int4_z)); }
|
||||
|
||||
inline v_float32x4 v_matmul(const v_float32x4& v, const v_float32x4& m0,
|
||||
const v_float32x4& m1, const v_float32x4& m2,
|
||||
const v_float32x4& m3)
|
||||
{
|
||||
const vec_float4 v0 = vec_splat(v.val, 0);
|
||||
const vec_float4 v1 = vec_splat(v.val, 1);
|
||||
const vec_float4 v2 = vec_splat(v.val, 2);
|
||||
const vec_float4 v3 = vec_splat(v.val, 3);
|
||||
return v_float32x4(vec_madd(v0, m0.val, vec_madd(v1, m1.val, vec_madd(v2, m2.val, vec_mul(v3, m3.val)))));
|
||||
}
|
||||
|
||||
#define OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(_Tpvec, _Tpvec2) \
|
||||
inline void v_transpose4x4(const _Tpvec& a0, const _Tpvec& a1, \
|
||||
const _Tpvec& a2, const _Tpvec& a3, \
|
||||
_Tpvec& b0, _Tpvec& b1, _Tpvec& b2, _Tpvec& b3) \
|
||||
{ \
|
||||
_Tpvec2 a02 = vec_mergeh(a0.val, a2.val); \
|
||||
_Tpvec2 a13 = vec_mergeh(a1.val, a3.val); \
|
||||
b0.val = vec_mergeh(a02, a13); \
|
||||
b1.val = vec_mergel(a02, a13); \
|
||||
a02 = vec_mergel(a0.val, a2.val); \
|
||||
a13 = vec_mergel(a1.val, a3.val); \
|
||||
b2.val = vec_mergeh(a02, a13); \
|
||||
b3.val = vec_mergel(a02, a13); \
|
||||
}
|
||||
OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_uint32x4, vec_uint4)
|
||||
OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_int32x4, vec_int4)
|
||||
OPENCV_HAL_IMPL_VSX_TRANSPOSE4x4(v_float32x4, vec_float4)
|
||||
|
||||
//! @name Check SIMD support
|
||||
//! @{
|
||||
//! @brief Check CPU capability of SIMD operation
|
||||
static inline bool hasSIMD128()
|
||||
{
|
||||
return (CV_CPU_HAS_SUPPORT_VSX) ? true : false;
|
||||
}
|
||||
|
||||
//! @}
|
||||
|
||||
CV_CPU_OPTIMIZATION_HAL_NAMESPACE_END
|
||||
|
||||
//! @endcond
|
||||
|
||||
}
|
||||
|
||||
#endif // OPENCV_HAL_VSX_HPP
|
||||
@@ -582,7 +582,7 @@ protected:
|
||||
An example demonstrating the serial out capabilities of cv::Mat
|
||||
*/
|
||||
|
||||
/** @brief n-dimensional dense array class
|
||||
/** @brief n-dimensional dense array class \anchor CVMat_Details
|
||||
|
||||
The class Mat represents an n-dimensional dense numerical single-channel or multi-channel array. It
|
||||
can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel
|
||||
@@ -2418,7 +2418,7 @@ public:
|
||||
void copyTo( OutputArray m ) const;
|
||||
//! copies those matrix elements to "m" that are marked with non-zero mask elements.
|
||||
void copyTo( OutputArray m, InputArray mask ) const;
|
||||
//! converts matrix to another datatype with optional scalng. See cvConvertScale.
|
||||
//! converts matrix to another datatype with optional scaling. See cvConvertScale.
|
||||
void convertTo( OutputArray m, int rtype, double alpha=1, double beta=0 ) const;
|
||||
|
||||
void assignTo( UMat& m, int type=-1 ) const;
|
||||
|
||||
@@ -1058,6 +1058,34 @@ const uchar* Mat::ptr(const int* idx) const
|
||||
return p;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
_Tp* Mat::ptr(const int* idx)
|
||||
{
|
||||
int i, d = dims;
|
||||
uchar* p = data;
|
||||
CV_DbgAssert( d >= 1 && p );
|
||||
for( i = 0; i < d; i++ )
|
||||
{
|
||||
CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] );
|
||||
p += idx[i] * step.p[i];
|
||||
}
|
||||
return (_Tp*)p;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
const _Tp* Mat::ptr(const int* idx) const
|
||||
{
|
||||
int i, d = dims;
|
||||
uchar* p = data;
|
||||
CV_DbgAssert( d >= 1 && p );
|
||||
for( i = 0; i < d; i++ )
|
||||
{
|
||||
CV_DbgAssert( (unsigned)idx[i] < (unsigned)size.p[i] );
|
||||
p += idx[i] * step.p[i];
|
||||
}
|
||||
return (const _Tp*)p;
|
||||
}
|
||||
|
||||
template<typename _Tp> inline
|
||||
_Tp& Mat::at(int i0, int i1)
|
||||
{
|
||||
|
||||
@@ -742,13 +742,16 @@ public:
|
||||
~Timer();
|
||||
void start();
|
||||
void stop();
|
||||
float milliSeconds();
|
||||
float microSeconds();
|
||||
float seconds();
|
||||
|
||||
uint64 durationNS() const; //< duration in nanoseconds
|
||||
|
||||
protected:
|
||||
struct Impl;
|
||||
Impl* p;
|
||||
Impl* const p;
|
||||
|
||||
private:
|
||||
Timer(const Timer&); // disabled
|
||||
Timer& operator=(const Timer&); // disabled
|
||||
};
|
||||
|
||||
CV_EXPORTS MatAllocator* getOpenCLAllocator();
|
||||
|
||||
@@ -44,13 +44,7 @@
|
||||
|
||||
#ifdef HAVE_CLAMDBLAS
|
||||
|
||||
#ifndef CL_RUNTIME_EXPORT
|
||||
#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined _WIN32 || defined WINCE)
|
||||
#define CL_RUNTIME_EXPORT __declspec(dllimport)
|
||||
#else
|
||||
#define CL_RUNTIME_EXPORT
|
||||
#endif
|
||||
#endif
|
||||
#include "opencl_core.hpp"
|
||||
|
||||
#include "autogenerated/opencl_clamdblas.hpp"
|
||||
|
||||
|
||||
@@ -44,13 +44,7 @@
|
||||
|
||||
#ifdef HAVE_CLAMDFFT
|
||||
|
||||
#ifndef CL_RUNTIME_EXPORT
|
||||
#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined _WIN32 || defined WINCE)
|
||||
#define CL_RUNTIME_EXPORT __declspec(dllimport)
|
||||
#else
|
||||
#define CL_RUNTIME_EXPORT
|
||||
#endif
|
||||
#endif
|
||||
#include "opencl_core.hpp"
|
||||
|
||||
#include "autogenerated/opencl_clamdfft.hpp"
|
||||
|
||||
|
||||
@@ -45,7 +45,8 @@
|
||||
#ifdef HAVE_OPENCL
|
||||
|
||||
#ifndef CL_RUNTIME_EXPORT
|
||||
#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined _WIN32 || defined WINCE)
|
||||
#if (defined(BUILD_SHARED_LIBS) || defined(OPENCV_CORE_SHARED)) && (defined _WIN32 || defined WINCE) && \
|
||||
!(defined(__OPENCV_BUILD) && defined(OPENCV_MODULE_IS_PART_OF_WORLD))
|
||||
#define CL_RUNTIME_EXPORT __declspec(dllimport)
|
||||
#else
|
||||
#define CL_RUNTIME_EXPORT
|
||||
|
||||
@@ -53,7 +53,7 @@
|
||||
#define CV_VERSION_MAJOR 3
|
||||
#define CV_VERSION_MINOR 3
|
||||
#define CV_VERSION_REVISION 1
|
||||
#define CV_VERSION_STATUS "-cvsdk"
|
||||
#define CV_VERSION_STATUS ""
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -0,0 +1,945 @@
|
||||
/*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.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Copyright (C) 2015, Itseez 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_HAL_VSX_UTILS_HPP
|
||||
#define OPENCV_HAL_VSX_UTILS_HPP
|
||||
|
||||
#include "opencv2/core/cvdef.h"
|
||||
|
||||
//! @addtogroup core_utils_vsx
|
||||
//! @{
|
||||
#if CV_VSX
|
||||
|
||||
#define FORCE_INLINE(tp) extern inline tp __attribute__((always_inline))
|
||||
|
||||
#define VSX_REDIRECT_1RG(rt, rg, fnm, fn2) \
|
||||
FORCE_INLINE(rt) fnm(const rg& a) { return fn2(a); }
|
||||
|
||||
#define VSX_REDIRECT_2RG(rt, rg, fnm, fn2) \
|
||||
FORCE_INLINE(rt) fnm(const rg& a, const rg& b) { return fn2(a, b); }
|
||||
|
||||
#define VSX_IMPL_PERM(rt, fnm, ...) \
|
||||
FORCE_INLINE(rt) fnm(const rt& a, const rt& b) \
|
||||
{ static const vec_uchar16 perm = {__VA_ARGS__}; return vec_perm(a, b, perm); }
|
||||
|
||||
#define __VSX_S16__(c, v) (c){v, v, v, v, v, v, v, v, v, v, v, v, v, v, v, v}
|
||||
#define __VSX_S8__(c, v) (c){v, v, v, v, v, v, v, v}
|
||||
#define __VSX_S4__(c, v) (c){v, v, v, v}
|
||||
#define __VSX_S2__(c, v) (c){v, v}
|
||||
|
||||
typedef __vector unsigned char vec_uchar16;
|
||||
#define vec_uchar16_set(...) (vec_uchar16){__VA_ARGS__}
|
||||
#define vec_uchar16_sp(c) (__VSX_S16__(vec_uchar16, c))
|
||||
#define vec_uchar16_c(v) ((vec_uchar16)(v))
|
||||
#define vec_uchar16_mx vec_uchar16_sp(0xFF)
|
||||
#define vec_uchar16_mn vec_uchar16_sp(0)
|
||||
#define vec_uchar16_z vec_uchar16_mn
|
||||
|
||||
typedef __vector signed char vec_char16;
|
||||
#define vec_char16_set(...) (vec_char16){__VA_ARGS__}
|
||||
#define vec_char16_sp(c) (__VSX_S16__(vec_char16, c))
|
||||
#define vec_char16_c(v) ((vec_char16)(v))
|
||||
#define vec_char16_mx vec_char16_sp(0x7F)
|
||||
#define vec_char16_mn vec_char16_sp(-0x7F-1)
|
||||
#define vec_char16_z vec_char16_sp(0)
|
||||
|
||||
typedef __vector unsigned short vec_ushort8;
|
||||
#define vec_ushort8_set(...) (vec_ushort8){__VA_ARGS__}
|
||||
#define vec_ushort8_sp(c) (__VSX_S8__(vec_ushort8, c))
|
||||
#define vec_ushort8_c(v) ((vec_ushort8)(v))
|
||||
#define vec_ushort8_mx vec_ushort8_sp(0xFFFF)
|
||||
#define vec_ushort8_mn vec_ushort8_sp(0)
|
||||
#define vec_ushort8_z vec_ushort8_mn
|
||||
|
||||
typedef __vector signed short vec_short8;
|
||||
#define vec_short8_set(...) (vec_short8){__VA_ARGS__}
|
||||
#define vec_short8_sp(c) (__VSX_S8__(vec_short8, c))
|
||||
#define vec_short8_c(v) ((vec_short8)(v))
|
||||
#define vec_short8_mx vec_short8_sp(0x7FFF)
|
||||
#define vec_short8_mn vec_short8_sp(-0x7FFF-1)
|
||||
#define vec_short8_z vec_short8_sp(0)
|
||||
|
||||
typedef __vector unsigned int vec_uint4;
|
||||
#define vec_uint4_set(...) (vec_uint4){__VA_ARGS__}
|
||||
#define vec_uint4_sp(c) (__VSX_S4__(vec_uint4, c))
|
||||
#define vec_uint4_c(v) ((vec_uint4)(v))
|
||||
#define vec_uint4_mx vec_uint4_sp(0xFFFFFFFFU)
|
||||
#define vec_uint4_mn vec_uint4_sp(0)
|
||||
#define vec_uint4_z vec_uint4_mn
|
||||
|
||||
typedef __vector signed int vec_int4;
|
||||
#define vec_int4_set(...) (vec_int4){__VA_ARGS__}
|
||||
#define vec_int4_sp(c) (__VSX_S4__(vec_int4, c))
|
||||
#define vec_int4_c(v) ((vec_int4)(v))
|
||||
#define vec_int4_mx vec_int4_sp(0x7FFFFFFF)
|
||||
#define vec_int4_mn vec_int4_sp(-0x7FFFFFFF-1)
|
||||
#define vec_int4_z vec_int4_sp(0)
|
||||
|
||||
typedef __vector float vec_float4;
|
||||
#define vec_float4_set(...) (vec_float4){__VA_ARGS__}
|
||||
#define vec_float4_sp(c) (__VSX_S4__(vec_float4, c))
|
||||
#define vec_float4_c(v) ((vec_float4)(v))
|
||||
#define vec_float4_mx vec_float4_sp(3.40282347E+38F)
|
||||
#define vec_float4_mn vec_float4_sp(1.17549435E-38F)
|
||||
#define vec_float4_z vec_float4_sp(0)
|
||||
|
||||
typedef __vector unsigned long long vec_udword2;
|
||||
#define vec_udword2_set(...) (vec_udword2){__VA_ARGS__}
|
||||
#define vec_udword2_sp(c) (__VSX_S2__(vec_udword2, c))
|
||||
#define vec_udword2_c(v) ((vec_udword2)(v))
|
||||
#define vec_udword2_mx vec_udword2_sp(18446744073709551615ULL)
|
||||
#define vec_udword2_mn vec_udword2_sp(0)
|
||||
#define vec_udword2_z vec_udword2_mn
|
||||
|
||||
typedef __vector signed long long vec_dword2;
|
||||
#define vec_dword2_set(...) (vec_dword2){__VA_ARGS__}
|
||||
#define vec_dword2_sp(c) (__VSX_S2__(vec_dword2, c))
|
||||
#define vec_dword2_c(v) ((vec_dword2)(v))
|
||||
#define vec_dword2_mx vec_dword2_sp(9223372036854775807LL)
|
||||
#define vec_dword2_mn vec_dword2_sp(-9223372036854775807LL-1)
|
||||
#define vec_dword2_z vec_dword2_sp(0)
|
||||
|
||||
typedef __vector double vec_double2;
|
||||
#define vec_double2_set(...) (vec_double2){__VA_ARGS__}
|
||||
#define vec_double2_c(v) ((vec_double2)(v))
|
||||
#define vec_double2_sp(c) (__VSX_S2__(vec_double2, c))
|
||||
#define vec_double2_mx vec_double2_sp(1.7976931348623157E+308)
|
||||
#define vec_double2_mn vec_double2_sp(2.2250738585072014E-308)
|
||||
#define vec_double2_z vec_double2_sp(0)
|
||||
|
||||
#define vec_bchar16 __vector __bool char
|
||||
#define vec_bchar16_set(...) (vec_bchar16){__VA_ARGS__}
|
||||
#define vec_bchar16_c(v) ((vec_bchar16)(v))
|
||||
#define vec_bchar16_f (__VSX_S16__(vec_bchar16, 0))
|
||||
#define vec_bchar16_t (__VSX_S16__(vec_bchar16, 1))
|
||||
|
||||
#define vec_bshort8 __vector __bool short
|
||||
#define vec_bshort8_set(...) (vec_bshort8){__VA_ARGS__}
|
||||
#define vec_bshort8_c(v) ((vec_bshort8)(v))
|
||||
#define vec_bshort8_f (__VSX_S8__(vec_bshort8, 0))
|
||||
#define vec_bshort8_t (__VSX_S8__(vec_bshort8, 1))
|
||||
|
||||
#define vec_bint4 __vector __bool int
|
||||
#define vec_bint4_set(...) (vec_bint4){__VA_ARGS__}
|
||||
#define vec_bint4_c(v) ((vec_bint4)(v))
|
||||
#define vec_bint4_f (__VSX_S4__(vec_bint4, 0))
|
||||
#define vec_bint4_t (__VSX_S4__(vec_bint4, 1))
|
||||
|
||||
#define vec_bdword2 __vector __bool long long
|
||||
#define vec_bdword2_set(...) (vec_bdword2){__VA_ARGS__}
|
||||
#define vec_bdword2_c(v) ((vec_bdword2)(v))
|
||||
#define vec_bdword2_f (__VSX_S2__(vec_bdword2, 0))
|
||||
#define vec_bdword2_t (__VSX_S2__(vec_bdword2, 1))
|
||||
|
||||
/*
|
||||
* GCC VSX compatibility
|
||||
**/
|
||||
#if defined(__GNUG__) && !defined(__IBMCPP__) && !defined(__clang__)
|
||||
|
||||
// inline asm helper
|
||||
#define VSX_IMPL_1RG(rt, rto, rg, rgo, opc, fnm) \
|
||||
FORCE_INLINE(rt) fnm(const rg& a) \
|
||||
{ rt rs; __asm__ __volatile__(#opc" %x0,%x1" : "="#rto (rs) : #rgo (a)); return rs; }
|
||||
|
||||
#define VSX_IMPL_1VRG(rt, rg, opc, fnm) \
|
||||
FORCE_INLINE(rt) fnm(const rg& a) \
|
||||
{ rt rs; __asm__ __volatile__(#opc" %0,%1" : "=v" (rs) : "v" (a)); return rs; }
|
||||
|
||||
#define VSX_IMPL_2VRG_F(rt, rg, fopc, fnm) \
|
||||
FORCE_INLINE(rt) fnm(const rg& a, const rg& b) \
|
||||
{ rt rs; __asm__ __volatile__(fopc : "=v" (rs) : "v" (a), "v" (b)); return rs; }
|
||||
|
||||
#define VSX_IMPL_2VRG(rt, rg, opc, fnm) VSX_IMPL_2VRG_F(rt, rg, #opc" %0,%1,%2", fnm)
|
||||
|
||||
#if __GNUG__ < 7
|
||||
/* up to GCC 6 vec_mul only supports precisions and llong */
|
||||
# ifdef vec_mul
|
||||
# undef vec_mul
|
||||
# endif
|
||||
/*
|
||||
* there's no a direct instruction for supporting 16-bit multiplication in ISA 2.07,
|
||||
* XLC Implement it by using instruction "multiply even", "multiply oden" and "permute"
|
||||
* todo: Do I need to support 8-bit ?
|
||||
**/
|
||||
# define VSX_IMPL_MULH(Tvec, Tcast) \
|
||||
FORCE_INLINE(Tvec) vec_mul(const Tvec& a, const Tvec& b) \
|
||||
{ \
|
||||
static const vec_uchar16 even_perm = {0, 1, 16, 17, 4, 5, 20, 21, \
|
||||
8, 9, 24, 25, 12, 13, 28, 29}; \
|
||||
return vec_perm(Tcast(vec_mule(a, b)), Tcast(vec_mulo(a, b)), even_perm); \
|
||||
}
|
||||
VSX_IMPL_MULH(vec_short8, vec_short8_c)
|
||||
VSX_IMPL_MULH(vec_ushort8, vec_ushort8_c)
|
||||
/* vmuluwm can be used for unsigned or signed integers, that's what they said */
|
||||
VSX_IMPL_2VRG(vec_int4, vec_int4, vmuluwm, vec_mul)
|
||||
VSX_IMPL_2VRG(vec_uint4, vec_uint4, vmuluwm, vec_mul)
|
||||
/* redirect to GCC builtin vec_mul, since it already supports precisions and llong */
|
||||
VSX_REDIRECT_2RG(vec_float4, vec_float4, vec_mul, __builtin_vec_mul)
|
||||
VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mul, __builtin_vec_mul)
|
||||
VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mul, __builtin_vec_mul)
|
||||
VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mul, __builtin_vec_mul)
|
||||
#endif // __GNUG__ < 7
|
||||
|
||||
#if __GNUG__ < 6
|
||||
/*
|
||||
* Instruction "compare greater than or equal" in ISA 2.07 only supports single
|
||||
* and double precision.
|
||||
* In XLC and new versions of GCC implement integers by using instruction "greater than" and NOR.
|
||||
**/
|
||||
# ifdef vec_cmpge
|
||||
# undef vec_cmpge
|
||||
# endif
|
||||
# ifdef vec_cmple
|
||||
# undef vec_cmple
|
||||
# endif
|
||||
# define vec_cmple(a, b) vec_cmpge(b, a)
|
||||
# define VSX_IMPL_CMPGE(rt, rg, opc, fnm) \
|
||||
VSX_IMPL_2VRG_F(rt, rg, #opc" %0,%2,%1\n\t xxlnor %x0,%x0,%x0", fnm)
|
||||
|
||||
VSX_IMPL_CMPGE(vec_bchar16, vec_char16, vcmpgtsb, vec_cmpge)
|
||||
VSX_IMPL_CMPGE(vec_bchar16, vec_uchar16, vcmpgtub, vec_cmpge)
|
||||
VSX_IMPL_CMPGE(vec_bshort8, vec_short8, vcmpgtsh, vec_cmpge)
|
||||
VSX_IMPL_CMPGE(vec_bshort8, vec_ushort8, vcmpgtuh, vec_cmpge)
|
||||
VSX_IMPL_CMPGE(vec_bint4, vec_int4, vcmpgtsw, vec_cmpge)
|
||||
VSX_IMPL_CMPGE(vec_bint4, vec_uint4, vcmpgtuw, vec_cmpge)
|
||||
VSX_IMPL_CMPGE(vec_bdword2, vec_dword2, vcmpgtsd, vec_cmpge)
|
||||
VSX_IMPL_CMPGE(vec_bdword2, vec_udword2, vcmpgtud, vec_cmpge)
|
||||
/* redirect to GCC builtin cmpge, since it already supports precisions */
|
||||
VSX_REDIRECT_2RG(vec_bint4, vec_float4, vec_cmpge, __builtin_vec_cmpge)
|
||||
VSX_REDIRECT_2RG(vec_bdword2, vec_double2, vec_cmpge, __builtin_vec_cmpge)
|
||||
|
||||
// up to gcc5 vec_nor doesn't support bool long long
|
||||
# undef vec_nor
|
||||
template<typename T>
|
||||
VSX_REDIRECT_2RG(T, T, vec_nor, __builtin_vec_nor)
|
||||
|
||||
FORCE_INLINE(vec_bdword2) vec_nor(const vec_bdword2& a, const vec_bdword2& b)
|
||||
{ return vec_bdword2_c(__builtin_vec_nor(vec_dword2_c(a), vec_dword2_c(b))); }
|
||||
#endif // __GNUG__ < 6
|
||||
|
||||
// vector population count
|
||||
#ifndef vec_popcnt
|
||||
VSX_IMPL_1VRG(vec_uchar16, vec_uchar16, vpopcntb, vec_popcnt)
|
||||
VSX_IMPL_1VRG(vec_uchar16, vec_char16, vpopcntb, vec_popcnt)
|
||||
VSX_IMPL_1VRG(vec_ushort8, vec_ushort8, vpopcnth, vec_popcnt)
|
||||
VSX_IMPL_1VRG(vec_ushort8, vec_short8, vpopcnth, vec_popcnt)
|
||||
VSX_IMPL_1VRG(vec_uint4, vec_uint4, vpopcntw, vec_popcnt)
|
||||
VSX_IMPL_1VRG(vec_uint4, vec_int4, vpopcntw, vec_popcnt)
|
||||
VSX_IMPL_1VRG(vec_udword2, vec_udword2, vpopcntd, vec_popcnt)
|
||||
VSX_IMPL_1VRG(vec_udword2, vec_dword2, vpopcntd, vec_popcnt)
|
||||
#endif // vec_popcnt
|
||||
|
||||
#if __GNUG__ < 5
|
||||
// vec_xxpermdi in gcc4 missing little-endian supports just like clang
|
||||
# define vec_permi(a, b, c) vec_xxpermdi(b, a, (3 ^ ((c & 1) << 1 | c >> 1)))
|
||||
// vec_packs doesn't support double words in gcc4
|
||||
# undef vec_packs
|
||||
VSX_REDIRECT_2RG(vec_char16, vec_short8, vec_packs, __builtin_vec_packs)
|
||||
VSX_REDIRECT_2RG(vec_uchar16, vec_ushort8, vec_packs, __builtin_vec_packs)
|
||||
VSX_REDIRECT_2RG(vec_short8, vec_int4, vec_packs, __builtin_vec_packs)
|
||||
VSX_REDIRECT_2RG(vec_ushort8, vec_uint4, vec_packs, __builtin_vec_packs)
|
||||
VSX_IMPL_2VRG_F(vec_int4, vec_dword2, "vpksdss %0,%2,%1", vec_packs)
|
||||
VSX_IMPL_2VRG_F(vec_uint4, vec_udword2, "vpkudus %0,%2,%1", vec_packs)
|
||||
#else
|
||||
# define vec_permi vec_xxpermdi
|
||||
#endif
|
||||
|
||||
// converts between single and double-precision
|
||||
#ifndef vec_cvf
|
||||
VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvf, __builtin_vsx_xvcvdpsp)
|
||||
FORCE_INLINE(vec_double2) vec_cvf(const vec_float4& a)
|
||||
{ return __builtin_vsx_xvcvspdp(vec_sld(a, a, 4)); }
|
||||
#endif
|
||||
|
||||
// converts 32 and 64 bit integers to double-precision
|
||||
#ifndef vec_ctd
|
||||
# define vec_ctd(a, b) __vec_ctd(a)
|
||||
VSX_IMPL_1RG(vec_double2, wd, vec_int4, wa, xvcvsxwdp, __vec_ctd)
|
||||
VSX_IMPL_1RG(vec_double2, wd, vec_uint4, wa, xvcvuxwdp, __vec_ctd)
|
||||
VSX_IMPL_1RG(vec_double2, wd, vec_dword2, wi, xvcvsxddp, __vec_ctd)
|
||||
VSX_IMPL_1RG(vec_double2, wd, vec_udword2, wi, xvcvuxddp, __vec_ctd)
|
||||
#endif
|
||||
|
||||
// shift left double by word immediate
|
||||
#ifndef vec_sldw
|
||||
# define vec_sldw __builtin_vsx_xxsldwi
|
||||
#endif
|
||||
|
||||
// just in case if GCC doesn't define it
|
||||
#ifndef vec_xl
|
||||
# define vec_xl vec_vsx_ld
|
||||
# define vec_xst vec_vsx_st
|
||||
#endif
|
||||
|
||||
#endif // GCC VSX compatibility
|
||||
|
||||
/*
|
||||
* CLANG VSX compatibility
|
||||
**/
|
||||
#if defined(__clang__) && !defined(__IBMCPP__)
|
||||
|
||||
/*
|
||||
* CLANG doesn't support %x<n> in the inline asm template which fixes register number
|
||||
* when using any of the register constraints wa, wd, wf
|
||||
*
|
||||
* For more explanation checkout PowerPC and IBM RS6000 in https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
|
||||
* Also there's already an open bug https://bugs.llvm.org/show_bug.cgi?id=31837
|
||||
*
|
||||
* So we're not able to use inline asm and only use built-in functions that CLANG supports
|
||||
*/
|
||||
|
||||
#if __clang_major__ < 5
|
||||
// implement vec_permi in a dirty way
|
||||
# define VSX_IMPL_CLANG_4_PERMI(Tvec) \
|
||||
FORCE_INLINE(Tvec) vec_permi(const Tvec& a, const Tvec& b, unsigned const char c) \
|
||||
{ \
|
||||
switch (c) \
|
||||
{ \
|
||||
case 0: \
|
||||
return vec_mergeh(a, b); \
|
||||
case 1: \
|
||||
return vec_mergel(vec_mergeh(a, a), b); \
|
||||
case 2: \
|
||||
return vec_mergeh(vec_mergel(a, a), b); \
|
||||
default: \
|
||||
return vec_mergel(a, b); \
|
||||
} \
|
||||
}
|
||||
VSX_IMPL_CLANG_4_PERMI(vec_udword2)
|
||||
VSX_IMPL_CLANG_4_PERMI(vec_dword2)
|
||||
VSX_IMPL_CLANG_4_PERMI(vec_double2)
|
||||
|
||||
// vec_xxsldwi is missing in clang 4
|
||||
# define vec_xxsldwi(a, b, c) vec_sld(a, b, (c) * 4)
|
||||
#else
|
||||
// vec_xxpermdi is missing little-endian supports in clang 4 just like gcc4
|
||||
# define vec_permi(a, b, c) vec_xxpermdi(b, a, (3 ^ ((c & 1) << 1 | c >> 1)))
|
||||
#endif // __clang_major__ < 5
|
||||
|
||||
// shift left double by word immediate
|
||||
#ifndef vec_sldw
|
||||
# define vec_sldw vec_xxsldwi
|
||||
#endif
|
||||
|
||||
/* converts between single and double precision */
|
||||
#ifndef vec_cvf
|
||||
VSX_REDIRECT_1RG(vec_float4, vec_double2, vec_cvf, __builtin_vsx_xvcvdpsp)
|
||||
FORCE_INLINE(vec_double2) vec_cvf(const vec_float4& a)
|
||||
{ return __builtin_vsx_xvcvspdp(vec_sld(a, a, 4)); }
|
||||
#endif
|
||||
|
||||
/* converts 32 and 64 bit integers to double-precision */
|
||||
#ifndef vec_ctd
|
||||
# define vec_ctd(a, b) __vec_ctd(a)
|
||||
VSX_REDIRECT_1RG(vec_double2, vec_int4, __vec_ctd, __builtin_vsx_xvcvsxwdp)
|
||||
VSX_REDIRECT_1RG(vec_double2, vec_uint4, __vec_ctd, __builtin_vsx_xvcvuxwdp)
|
||||
// implement vec_ctd for double word in a dirty way since we are missing builtin xvcvsxddp, xvcvuxddp
|
||||
// please try to avoid using it for double words
|
||||
FORCE_INLINE(vec_double2) __vec_ctd(const vec_dword2& a)
|
||||
{ return vec_double2_set((double)vec_extract(a, 0), (double)vec_extract(a, 1)); }
|
||||
FORCE_INLINE(vec_double2) __vec_ctd(const vec_udword2& a)
|
||||
{ return vec_double2_set((double)vec_extract(a, 0), (double)vec_extract(a, 1)); }
|
||||
#endif
|
||||
|
||||
// Implement vec_rsqrt since clang only supports vec_rsqrte
|
||||
#ifndef vec_rsqrt
|
||||
FORCE_INLINE(vec_float4) vec_rsqrt(const vec_float4& a)
|
||||
{ return vec_div(vec_float4_sp(1), vec_sqrt(a)); }
|
||||
|
||||
FORCE_INLINE(vec_double2) vec_rsqrt(const vec_double2& a)
|
||||
{ return vec_div(vec_double2_sp(1), vec_sqrt(a)); }
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* __builtin_altivec_vctsxs in clang 5 and 6 causes ambiguous which used by vec_cts
|
||||
* so we just redefine it and cast it
|
||||
*/
|
||||
#if __clang_major__ > 4
|
||||
# undef vec_cts
|
||||
# define vec_cts(__a, __b) \
|
||||
_Generic((__a), vector float \
|
||||
: (vector signed int)__builtin_altivec_vctsxs((__a), (__b)), vector double \
|
||||
: __extension__({ \
|
||||
vector double __ret = \
|
||||
(__a) * \
|
||||
(vector double)(vector unsigned long long)((0x3ffULL + (__b)) \
|
||||
<< 52); \
|
||||
__builtin_convertvector(__ret, vector signed long long); \
|
||||
}))
|
||||
#endif // __clang_major__ > 4
|
||||
|
||||
#endif // CLANG VSX compatibility
|
||||
|
||||
/*
|
||||
* implement vsx_ld(offset, pointer), vsx_st(vector, offset, pointer)
|
||||
* load and set using offset depend on the pointer type
|
||||
*
|
||||
* implement vsx_ldf(offset, pointer), vsx_stf(vector, offset, pointer)
|
||||
* load and set using offset depend on fixed bytes size
|
||||
*
|
||||
* Note: In clang vec_xl and vec_xst fails to load unaligned addresses
|
||||
* so we are using vec_vsx_ld, vec_vsx_st instead
|
||||
*/
|
||||
|
||||
#if defined(__clang__) && !defined(__IBMCPP__)
|
||||
# define vsx_ldf vec_vsx_ld
|
||||
# define vsx_stf vec_vsx_st
|
||||
#else // GCC , XLC
|
||||
# define vsx_ldf vec_xl
|
||||
# define vsx_stf vec_xst
|
||||
#endif
|
||||
|
||||
#define VSX_OFFSET(o, p) ((o) * sizeof(*(p)))
|
||||
#define vsx_ld(o, p) vsx_ldf(VSX_OFFSET(o, p), p)
|
||||
#define vsx_st(v, o, p) vsx_stf(v, VSX_OFFSET(o, p), p)
|
||||
|
||||
/*
|
||||
* implement vsx_ld2(offset, pointer), vsx_st2(vector, offset, pointer) to load and store double words
|
||||
* In GCC vec_xl and vec_xst it maps to vec_vsx_ld, vec_vsx_st which doesn't support long long
|
||||
* and in CLANG we are using vec_vsx_ld, vec_vsx_st because vec_xl, vec_xst fails to load unaligned addresses
|
||||
*
|
||||
* In XLC vec_xl and vec_xst fail to cast int64(long int) to long long
|
||||
*/
|
||||
#if (defined(__GNUG__) || defined(__clang__)) && !defined(__IBMCPP__)
|
||||
FORCE_INLINE(vec_udword2) vsx_ld2(long o, const uint64* p)
|
||||
{ return vec_udword2_c(vsx_ldf(VSX_OFFSET(o, p), (unsigned int*)p)); }
|
||||
|
||||
FORCE_INLINE(vec_dword2) vsx_ld2(long o, const int64* p)
|
||||
{ return vec_dword2_c(vsx_ldf(VSX_OFFSET(o, p), (int*)p)); }
|
||||
|
||||
FORCE_INLINE(void) vsx_st2(const vec_udword2& vec, long o, uint64* p)
|
||||
{ vsx_stf(vec_uint4_c(vec), VSX_OFFSET(o, p), (unsigned int*)p); }
|
||||
|
||||
FORCE_INLINE(void) vsx_st2(const vec_dword2& vec, long o, int64* p)
|
||||
{ vsx_stf(vec_int4_c(vec), VSX_OFFSET(o, p), (int*)p); }
|
||||
#else // XLC
|
||||
FORCE_INLINE(vec_udword2) vsx_ld2(long o, const uint64* p)
|
||||
{ return vsx_ldf(VSX_OFFSET(o, p), (unsigned long long*)p); }
|
||||
|
||||
FORCE_INLINE(vec_dword2) vsx_ld2(long o, const int64* p)
|
||||
{ return vsx_ldf(VSX_OFFSET(o, p), (long long*)p); }
|
||||
|
||||
FORCE_INLINE(void) vsx_st2(const vec_udword2& vec, long o, uint64* p)
|
||||
{ vsx_stf(vec, VSX_OFFSET(o, p), (unsigned long long*)p); }
|
||||
|
||||
FORCE_INLINE(void) vsx_st2(const vec_dword2& vec, long o, int64* p)
|
||||
{ vsx_stf(vec, VSX_OFFSET(o, p), (long long*)p); }
|
||||
#endif
|
||||
|
||||
#if defined(__clang__) || defined(__IBMCPP__)
|
||||
// gcc can find his way in casting log int and XLC, CLANG ambiguous
|
||||
FORCE_INLINE(vec_udword2) vec_splats(uint64 v)
|
||||
{ return vec_splats((unsigned long long) v); }
|
||||
|
||||
FORCE_INLINE(vec_dword2) vec_splats(int64 v)
|
||||
{ return vec_splats((long long) v); }
|
||||
#endif
|
||||
|
||||
// Implement store vector bool char for XLC
|
||||
#if defined(__IBMCPP__) && defined(__clang__)
|
||||
FORCE_INLINE(void) vec_xst(const vec_bchar16 &vec, long o, uchar* p)
|
||||
{ vec_xst(vec_uchar16_c(vec), VSX_OFFSET(o, p), p); }
|
||||
#endif
|
||||
|
||||
// Working around vec_popcnt compatibility
|
||||
/*
|
||||
* vec_popcnt should return unsigned but clang has different thought just like gcc in vec_vpopcnt
|
||||
*
|
||||
* use vec_popcntu instead to deal with it
|
||||
*/
|
||||
#if defined(__clang__) && !defined(__IBMCPP__)
|
||||
# define VSX_IMPL_CLANG_POPCNTU(Tvec, Tvec2, ucast) \
|
||||
FORCE_INLINE(Tvec) vec_popcntu(const Tvec2& a) \
|
||||
{ return ucast(vec_popcnt(a)); }
|
||||
|
||||
VSX_IMPL_CLANG_POPCNTU(vec_uchar16, vec_char16, vec_uchar16_c);
|
||||
VSX_IMPL_CLANG_POPCNTU(vec_ushort8, vec_short8, vec_ushort8_c);
|
||||
VSX_IMPL_CLANG_POPCNTU(vec_uint4, vec_int4, vec_uint4_c);
|
||||
// redirect unsigned types
|
||||
VSX_REDIRECT_1RG(vec_uchar16, vec_uchar16, vec_popcntu, vec_popcnt)
|
||||
VSX_REDIRECT_1RG(vec_ushort8, vec_ushort8, vec_popcntu, vec_popcnt)
|
||||
VSX_REDIRECT_1RG(vec_uint4, vec_uint4, vec_popcntu, vec_popcnt)
|
||||
#else
|
||||
# define vec_popcntu vec_popcnt
|
||||
#endif
|
||||
|
||||
// Working around vec_cts compatibility
|
||||
/*
|
||||
* vec_cts in gcc and clang converts single-precision to signed fixed-point word
|
||||
* and from double-precision to signed doubleword, also there's no implement for vec_ctsl
|
||||
*
|
||||
* vec_cts in xlc converts single and double precision to signed fixed-point word
|
||||
* and xlc has vec_ctsl which converts single and double precision to signed doubleword
|
||||
*
|
||||
* so to deal with this situation, use vec_cts only if you want to convert single-precision to signed fixed-point word
|
||||
* and use vec_ctsl when you want to convert double-precision to signed doubleword
|
||||
*
|
||||
* Also we implemented vec_ctsw(a) to convert double-precision to signed fixed-point word
|
||||
*/
|
||||
|
||||
// converts double-precision to signed doubleword for GCC and CLANG
|
||||
#if !defined(vec_ctsl) && !defined(__IBMCPP__) && (defined(__GNUG__) || defined(__clang__))
|
||||
// GCC4 has incorrect results in convert to signed doubleword
|
||||
# if !defined(__clang__) && __GNUG__ < 5
|
||||
# define vec_ctsl(a, b) __vec_ctsl(a)
|
||||
VSX_IMPL_1RG(vec_dword2, wi, vec_double2, wd, xvcvdpsxds, __vec_ctsl)
|
||||
# else // GCC > 4 , CLANG
|
||||
# define vec_ctsl vec_cts
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// converts double-precision to signed fixed-point word
|
||||
#if defined(__IBMCPP__)
|
||||
# define vec_ctsw(a) vec_cts(a, 0)
|
||||
#else // GCC, CLANG
|
||||
# define vec_ctsw(a) vec_int4_c(__builtin_vsx_xvcvdpsxws(a))
|
||||
#endif
|
||||
|
||||
// load 4 unsigned bytes into uint4 vector
|
||||
#define vec_ld_buw(p) vec_uint4_set((p)[0], (p)[1], (p)[2], (p)[3])
|
||||
|
||||
// load 4 signed bytes into int4 vector
|
||||
#define vec_ld_bsw(p) vec_int4_set((p)[0], (p)[1], (p)[2], (p)[3])
|
||||
|
||||
// load 4 unsigned bytes into float vector
|
||||
#define vec_ld_bps(p) vec_ctf(vec_ld_buw(p), 0)
|
||||
|
||||
// Store lower 8 byte
|
||||
#define vec_st_l8(v, p) *((uint64*)(p)) = vec_extract(vec_udword2_c(v), 0)
|
||||
|
||||
// Store higher 8 byte
|
||||
#define vec_st_h8(v, p) *((uint64*)(p)) = vec_extract(vec_udword2_c(v), 1)
|
||||
|
||||
/*
|
||||
* vec_ld_l8(ptr) -> Load 64-bits of integer data to lower part
|
||||
* vec_ldz_l8(ptr) -> Load 64-bits of integer data to lower part and zero upper part
|
||||
**/
|
||||
#if defined(__clang__) && !defined(__IBMCPP__)
|
||||
# define __VSX_LOAD_L8(Tvec, p) (Tvec)((vec_udword2)*((uint64*)(p)))
|
||||
#else
|
||||
# define __VSX_LOAD_L8(Tvec, p) *((Tvec*)(p))
|
||||
#endif
|
||||
|
||||
#define VSX_IMPL_LOAD_L8(Tvec, Tp) \
|
||||
FORCE_INLINE(Tvec) vec_ld_l8(const Tp *p) \
|
||||
{ return __VSX_LOAD_L8(Tvec, p); } \
|
||||
FORCE_INLINE(Tvec) vec_ldz_l8(const Tp *p) \
|
||||
{ \
|
||||
static const vec_bdword2 mask = {0xFFFFFFFFFFFFFFFF, 0x0000000000000000}; \
|
||||
return vec_and(vec_ld_l8(p), (Tvec)mask); \
|
||||
}
|
||||
VSX_IMPL_LOAD_L8(vec_uchar16, uchar)
|
||||
VSX_IMPL_LOAD_L8(vec_char16, schar)
|
||||
VSX_IMPL_LOAD_L8(vec_ushort8, ushort)
|
||||
VSX_IMPL_LOAD_L8(vec_short8, short)
|
||||
VSX_IMPL_LOAD_L8(vec_uint4, uint)
|
||||
VSX_IMPL_LOAD_L8(vec_int4, int)
|
||||
VSX_IMPL_LOAD_L8(vec_float4, float)
|
||||
VSX_IMPL_LOAD_L8(vec_udword2, uint64)
|
||||
VSX_IMPL_LOAD_L8(vec_dword2, int64)
|
||||
VSX_IMPL_LOAD_L8(vec_double2, double)
|
||||
|
||||
// logical not
|
||||
#define vec_not(a) vec_nor(a, a)
|
||||
|
||||
// power9 yaya
|
||||
// not equal
|
||||
#ifndef vec_cmpne
|
||||
# define vec_cmpne(a, b) vec_not(vec_cmpeq(a, b))
|
||||
#endif
|
||||
|
||||
// absoulte difference
|
||||
#ifndef vec_absd
|
||||
# define vec_absd(a, b) vec_sub(vec_max(a, b), vec_min(a, b))
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Implement vec_unpacklu and vec_unpackhu
|
||||
* since vec_unpackl, vec_unpackh only support signed integers
|
||||
**/
|
||||
#define VSX_IMPL_UNPACKU(rt, rg, zero) \
|
||||
FORCE_INLINE(rt) vec_unpacklu(const rg& a) \
|
||||
{ return reinterpret_cast<rt>(vec_mergel(a, zero)); } \
|
||||
FORCE_INLINE(rt) vec_unpackhu(const rg& a) \
|
||||
{ return reinterpret_cast<rt>(vec_mergeh(a, zero)); }
|
||||
|
||||
VSX_IMPL_UNPACKU(vec_ushort8, vec_uchar16, vec_uchar16_z)
|
||||
VSX_IMPL_UNPACKU(vec_uint4, vec_ushort8, vec_ushort8_z)
|
||||
VSX_IMPL_UNPACKU(vec_udword2, vec_uint4, vec_uint4_z)
|
||||
|
||||
/*
|
||||
* Implement vec_mergesqe and vec_mergesqo
|
||||
* Merges the sequence values of even and odd elements of two vectors
|
||||
*/
|
||||
// 16
|
||||
#define perm16_mergesqe 0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30
|
||||
#define perm16_mergesqo 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31
|
||||
VSX_IMPL_PERM(vec_uchar16, vec_mergesqe, perm16_mergesqe)
|
||||
VSX_IMPL_PERM(vec_uchar16, vec_mergesqo, perm16_mergesqo)
|
||||
VSX_IMPL_PERM(vec_char16, vec_mergesqe, perm16_mergesqe)
|
||||
VSX_IMPL_PERM(vec_char16, vec_mergesqo, perm16_mergesqo)
|
||||
// 8
|
||||
#define perm8_mergesqe 0, 1, 4, 5, 8, 9, 12, 13, 16, 17, 20, 21, 24, 25, 28, 29
|
||||
#define perm8_mergesqo 2, 3, 6, 7, 10, 11, 14, 15, 18, 19, 22, 23, 26, 27, 30, 31
|
||||
VSX_IMPL_PERM(vec_ushort8, vec_mergesqe, perm8_mergesqe)
|
||||
VSX_IMPL_PERM(vec_ushort8, vec_mergesqo, perm8_mergesqo)
|
||||
VSX_IMPL_PERM(vec_short8, vec_mergesqe, perm8_mergesqe)
|
||||
VSX_IMPL_PERM(vec_short8, vec_mergesqo, perm8_mergesqo)
|
||||
// 4
|
||||
#define perm4_mergesqe 0, 1, 2, 3, 8, 9, 10, 11, 16, 17, 18, 19, 24, 25, 26, 27
|
||||
#define perm4_mergesqo 4, 5, 6, 7, 12, 13, 14, 15, 20, 21, 22, 23, 28, 29, 30, 31
|
||||
VSX_IMPL_PERM(vec_uint4, vec_mergesqe, perm4_mergesqe)
|
||||
VSX_IMPL_PERM(vec_uint4, vec_mergesqo, perm4_mergesqo)
|
||||
VSX_IMPL_PERM(vec_int4, vec_mergesqe, perm4_mergesqe)
|
||||
VSX_IMPL_PERM(vec_int4, vec_mergesqo, perm4_mergesqo)
|
||||
VSX_IMPL_PERM(vec_float4, vec_mergesqe, perm4_mergesqe)
|
||||
VSX_IMPL_PERM(vec_float4, vec_mergesqo, perm4_mergesqo)
|
||||
// 2
|
||||
VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqe, vec_mergeh)
|
||||
VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqo, vec_mergel)
|
||||
VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqe, vec_mergeh)
|
||||
VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqo, vec_mergel)
|
||||
VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqe, vec_mergeh)
|
||||
VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqo, vec_mergel)
|
||||
|
||||
/*
|
||||
* Implement vec_mergesqh and vec_mergesql
|
||||
* Merges the sequence most and least significant halves of two vectors
|
||||
*/
|
||||
#define VSX_IMPL_MERGESQHL(Tvec) \
|
||||
FORCE_INLINE(Tvec) vec_mergesqh(const Tvec& a, const Tvec& b) \
|
||||
{ return (Tvec)vec_mergeh(vec_udword2_c(a), vec_udword2_c(b)); } \
|
||||
FORCE_INLINE(Tvec) vec_mergesql(const Tvec& a, const Tvec& b) \
|
||||
{ return (Tvec)vec_mergel(vec_udword2_c(a), vec_udword2_c(b)); }
|
||||
VSX_IMPL_MERGESQHL(vec_uchar16)
|
||||
VSX_IMPL_MERGESQHL(vec_char16)
|
||||
VSX_IMPL_MERGESQHL(vec_ushort8)
|
||||
VSX_IMPL_MERGESQHL(vec_short8)
|
||||
VSX_IMPL_MERGESQHL(vec_uint4)
|
||||
VSX_IMPL_MERGESQHL(vec_int4)
|
||||
VSX_IMPL_MERGESQHL(vec_float4)
|
||||
VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesqh, vec_mergeh)
|
||||
VSX_REDIRECT_2RG(vec_udword2, vec_udword2, vec_mergesql, vec_mergel)
|
||||
VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesqh, vec_mergeh)
|
||||
VSX_REDIRECT_2RG(vec_dword2, vec_dword2, vec_mergesql, vec_mergel)
|
||||
VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesqh, vec_mergeh)
|
||||
VSX_REDIRECT_2RG(vec_double2, vec_double2, vec_mergesql, vec_mergel)
|
||||
|
||||
|
||||
// 2 and 4 channels interleave for all types except 2 lanes
|
||||
#define VSX_IMPL_ST_INTERLEAVE(Tp, Tvec) \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, Tp* ptr) \
|
||||
{ \
|
||||
vsx_stf(vec_mergeh(a, b), 0, ptr); \
|
||||
vsx_stf(vec_mergel(a, b), 16, ptr); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \
|
||||
const Tvec& c, const Tvec& d, Tp* ptr) \
|
||||
{ \
|
||||
Tvec ac = vec_mergeh(a, c); \
|
||||
Tvec bd = vec_mergeh(b, d); \
|
||||
vsx_stf(vec_mergeh(ac, bd), 0, ptr); \
|
||||
vsx_stf(vec_mergel(ac, bd), 16, ptr); \
|
||||
ac = vec_mergel(a, c); \
|
||||
bd = vec_mergel(b, d); \
|
||||
vsx_stf(vec_mergeh(ac, bd), 32, ptr); \
|
||||
vsx_stf(vec_mergel(ac, bd), 48, ptr); \
|
||||
}
|
||||
VSX_IMPL_ST_INTERLEAVE(uchar, vec_uchar16)
|
||||
VSX_IMPL_ST_INTERLEAVE(schar, vec_char16)
|
||||
VSX_IMPL_ST_INTERLEAVE(ushort, vec_ushort8)
|
||||
VSX_IMPL_ST_INTERLEAVE(short, vec_short8)
|
||||
VSX_IMPL_ST_INTERLEAVE(uint, vec_uint4)
|
||||
VSX_IMPL_ST_INTERLEAVE(int, vec_int4)
|
||||
VSX_IMPL_ST_INTERLEAVE(float, vec_float4)
|
||||
|
||||
// 2 and 4 channels deinterleave for 16 lanes
|
||||
#define VSX_IMPL_ST_DINTERLEAVE_8(Tp, Tvec) \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \
|
||||
{ \
|
||||
Tvec v0 = vsx_ld(0, ptr); \
|
||||
Tvec v1 = vsx_ld(16, ptr); \
|
||||
a = vec_mergesqe(v0, v1); \
|
||||
b = vec_mergesqo(v0, v1); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \
|
||||
Tvec& c, Tvec& d) \
|
||||
{ \
|
||||
Tvec v0 = vsx_ld(0, ptr); \
|
||||
Tvec v1 = vsx_ld(16, ptr); \
|
||||
Tvec v2 = vsx_ld(32, ptr); \
|
||||
Tvec v3 = vsx_ld(48, ptr); \
|
||||
Tvec m0 = vec_mergesqe(v0, v1); \
|
||||
Tvec m1 = vec_mergesqe(v2, v3); \
|
||||
a = vec_mergesqe(m0, m1); \
|
||||
c = vec_mergesqo(m0, m1); \
|
||||
m0 = vec_mergesqo(v0, v1); \
|
||||
m1 = vec_mergesqo(v2, v3); \
|
||||
b = vec_mergesqe(m0, m1); \
|
||||
d = vec_mergesqo(m0, m1); \
|
||||
}
|
||||
VSX_IMPL_ST_DINTERLEAVE_8(uchar, vec_uchar16)
|
||||
VSX_IMPL_ST_DINTERLEAVE_8(schar, vec_char16)
|
||||
|
||||
// 2 and 4 channels deinterleave for 8 lanes
|
||||
#define VSX_IMPL_ST_DINTERLEAVE_16(Tp, Tvec) \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \
|
||||
{ \
|
||||
Tvec v0 = vsx_ld(0, ptr); \
|
||||
Tvec v1 = vsx_ld(8, ptr); \
|
||||
a = vec_mergesqe(v0, v1); \
|
||||
b = vec_mergesqo(v0, v1); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \
|
||||
Tvec& c, Tvec& d) \
|
||||
{ \
|
||||
Tvec v0 = vsx_ld(0, ptr); \
|
||||
Tvec v1 = vsx_ld(8, ptr); \
|
||||
Tvec m0 = vec_mergeh(v0, v1); \
|
||||
Tvec m1 = vec_mergel(v0, v1); \
|
||||
Tvec ab0 = vec_mergeh(m0, m1); \
|
||||
Tvec cd0 = vec_mergel(m0, m1); \
|
||||
v0 = vsx_ld(16, ptr); \
|
||||
v1 = vsx_ld(24, ptr); \
|
||||
m0 = vec_mergeh(v0, v1); \
|
||||
m1 = vec_mergel(v0, v1); \
|
||||
Tvec ab1 = vec_mergeh(m0, m1); \
|
||||
Tvec cd1 = vec_mergel(m0, m1); \
|
||||
a = vec_mergesqh(ab0, ab1); \
|
||||
b = vec_mergesql(ab0, ab1); \
|
||||
c = vec_mergesqh(cd0, cd1); \
|
||||
d = vec_mergesql(cd0, cd1); \
|
||||
}
|
||||
VSX_IMPL_ST_DINTERLEAVE_16(ushort, vec_ushort8)
|
||||
VSX_IMPL_ST_DINTERLEAVE_16(short, vec_short8)
|
||||
|
||||
// 2 and 4 channels deinterleave for 4 lanes
|
||||
#define VSX_IMPL_ST_DINTERLEAVE_32(Tp, Tvec) \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \
|
||||
{ \
|
||||
a = vsx_ld(0, ptr); \
|
||||
b = vsx_ld(4, ptr); \
|
||||
Tvec m0 = vec_mergeh(a, b); \
|
||||
Tvec m1 = vec_mergel(a, b); \
|
||||
a = vec_mergeh(m0, m1); \
|
||||
b = vec_mergel(m0, m1); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \
|
||||
Tvec& c, Tvec& d) \
|
||||
{ \
|
||||
Tvec v0 = vsx_ld(0, ptr); \
|
||||
Tvec v1 = vsx_ld(4, ptr); \
|
||||
Tvec v2 = vsx_ld(8, ptr); \
|
||||
Tvec v3 = vsx_ld(12, ptr); \
|
||||
Tvec m0 = vec_mergeh(v0, v2); \
|
||||
Tvec m1 = vec_mergeh(v1, v3); \
|
||||
a = vec_mergeh(m0, m1); \
|
||||
b = vec_mergel(m0, m1); \
|
||||
m0 = vec_mergel(v0, v2); \
|
||||
m1 = vec_mergel(v1, v3); \
|
||||
c = vec_mergeh(m0, m1); \
|
||||
d = vec_mergel(m0, m1); \
|
||||
}
|
||||
VSX_IMPL_ST_DINTERLEAVE_32(uint, vec_uint4)
|
||||
VSX_IMPL_ST_DINTERLEAVE_32(int, vec_int4)
|
||||
VSX_IMPL_ST_DINTERLEAVE_32(float, vec_float4)
|
||||
|
||||
// 2 and 4 channels interleave and deinterleave for 2 lanes
|
||||
#define VSX_IMPL_ST_D_INTERLEAVE_64(Tp, Tvec, ld_func, st_func) \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, Tp* ptr) \
|
||||
{ \
|
||||
st_func(vec_mergeh(a, b), 0, ptr); \
|
||||
st_func(vec_mergel(a, b), 2, ptr); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \
|
||||
const Tvec& c, const Tvec& d, Tp* ptr) \
|
||||
{ \
|
||||
st_func(vec_mergeh(a, b), 0, ptr); \
|
||||
st_func(vec_mergel(a, b), 2, ptr); \
|
||||
st_func(vec_mergeh(c, d), 4, ptr); \
|
||||
st_func(vec_mergel(c, d), 6, ptr); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b) \
|
||||
{ \
|
||||
Tvec m0 = ld_func(0, ptr); \
|
||||
Tvec m1 = ld_func(2, ptr); \
|
||||
a = vec_mergeh(m0, m1); \
|
||||
b = vec_mergel(m0, m1); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, \
|
||||
Tvec& c, Tvec& d) \
|
||||
{ \
|
||||
Tvec v0 = ld_func(0, ptr); \
|
||||
Tvec v1 = ld_func(2, ptr); \
|
||||
a = vec_mergeh(v0, v1); \
|
||||
b = vec_mergel(v0, v1); \
|
||||
v0 = ld_func(4, ptr); \
|
||||
v1 = ld_func(6, ptr); \
|
||||
c = vec_mergeh(v0, v1); \
|
||||
d = vec_mergel(v0, v1); \
|
||||
}
|
||||
VSX_IMPL_ST_D_INTERLEAVE_64(int64, vec_dword2, vsx_ld2, vsx_st2)
|
||||
VSX_IMPL_ST_D_INTERLEAVE_64(uint64, vec_udword2, vsx_ld2, vsx_st2)
|
||||
VSX_IMPL_ST_D_INTERLEAVE_64(double, vec_double2, vsx_ld, vsx_st)
|
||||
|
||||
/* 3 channels */
|
||||
#define VSX_IMPL_ST_INTERLEAVE_3CH_16(Tp, Tvec) \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \
|
||||
const Tvec& c, Tp* ptr) \
|
||||
{ \
|
||||
static const vec_uchar16 a12 = {0, 16, 0, 1, 17, 0, 2, 18, 0, 3, 19, 0, 4, 20, 0, 5}; \
|
||||
static const vec_uchar16 a123 = {0, 1, 16, 3, 4, 17, 6, 7, 18, 9, 10, 19, 12, 13, 20, 15}; \
|
||||
vsx_st(vec_perm(vec_perm(a, b, a12), c, a123), 0, ptr); \
|
||||
static const vec_uchar16 b12 = {21, 0, 6, 22, 0, 7, 23, 0, 8, 24, 0, 9, 25, 0, 10, 26}; \
|
||||
static const vec_uchar16 b123 = {0, 21, 2, 3, 22, 5, 6, 23, 8, 9, 24, 11, 12, 25, 14, 15}; \
|
||||
vsx_st(vec_perm(vec_perm(a, b, b12), c, b123), 16, ptr); \
|
||||
static const vec_uchar16 c12 = {0, 11, 27, 0, 12, 28, 0, 13, 29, 0, 14, 30, 0, 15, 31, 0}; \
|
||||
static const vec_uchar16 c123 = {26, 1, 2, 27, 4, 5, 28, 7, 8, 29, 10, 11, 30, 13, 14, 31}; \
|
||||
vsx_st(vec_perm(vec_perm(a, b, c12), c, c123), 32, ptr); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \
|
||||
{ \
|
||||
Tvec v1 = vsx_ld(0, ptr); \
|
||||
Tvec v2 = vsx_ld(16, ptr); \
|
||||
Tvec v3 = vsx_ld(32, ptr); \
|
||||
static const vec_uchar16 a12_perm = {0, 3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 0, 0, 0, 0, 0}; \
|
||||
static const vec_uchar16 a123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 17, 20, 23, 26, 29}; \
|
||||
a = vec_perm(vec_perm(v1, v2, a12_perm), v3, a123_perm); \
|
||||
static const vec_uchar16 b12_perm = {1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 0, 0, 0, 0, 0}; \
|
||||
static const vec_uchar16 b123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 18, 21, 24, 27, 30}; \
|
||||
b = vec_perm(vec_perm(v1, v2, b12_perm), v3, b123_perm); \
|
||||
static const vec_uchar16 c12_perm = {2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 0, 0, 0, 0, 0, 0}; \
|
||||
static const vec_uchar16 c123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 19, 22, 25, 28, 31}; \
|
||||
c = vec_perm(vec_perm(v1, v2, c12_perm), v3, c123_perm); \
|
||||
}
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_16(uchar, vec_uchar16)
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_16(schar, vec_char16)
|
||||
|
||||
#define VSX_IMPL_ST_INTERLEAVE_3CH_8(Tp, Tvec) \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \
|
||||
const Tvec& c, Tp* ptr) \
|
||||
{ \
|
||||
static const vec_uchar16 a12 = {0, 1, 16, 17, 0, 0, 2, 3, 18, 19, 0, 0, 4, 5, 20, 21}; \
|
||||
static const vec_uchar16 a123 = {0, 1, 2, 3, 16, 17, 6, 7, 8, 9, 18, 19, 12, 13, 14, 15}; \
|
||||
vsx_st(vec_perm(vec_perm(a, b, a12), c, a123), 0, ptr); \
|
||||
static const vec_uchar16 b12 = {0, 0, 6, 7, 22, 23, 0, 0, 8, 9, 24, 25, 0, 0, 10, 11}; \
|
||||
static const vec_uchar16 b123 = {20, 21, 2, 3, 4, 5, 22, 23, 8, 9, 10, 11, 24, 25, 14, 15}; \
|
||||
vsx_st(vec_perm(vec_perm(a, b, b12), c, b123), 8, ptr); \
|
||||
static const vec_uchar16 c12 = {26, 27, 0, 0, 12, 13, 28, 29, 0, 0, 14, 15, 30, 31, 0, 0}; \
|
||||
static const vec_uchar16 c123 = {0, 1, 26, 27, 4, 5, 6, 7, 28, 29, 10, 11, 12, 13, 30, 31}; \
|
||||
vsx_st(vec_perm(vec_perm(a, b, c12), c, c123), 16, ptr); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \
|
||||
{ \
|
||||
Tvec v1 = vsx_ld(0, ptr); \
|
||||
Tvec v2 = vsx_ld(8, ptr); \
|
||||
Tvec v3 = vsx_ld(16, ptr); \
|
||||
static const vec_uchar16 a12_perm = {0, 1, 6, 7, 12, 13, 18, 19, 24, 25, 30, 31, 0, 0, 0, 0}; \
|
||||
static const vec_uchar16 a123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 20, 21, 26, 27}; \
|
||||
a = vec_perm(vec_perm(v1, v2, a12_perm), v3, a123_perm); \
|
||||
static const vec_uchar16 b12_perm = {2, 3, 8, 9, 14, 15, 20, 21, 26, 27, 0, 0, 0, 0, 0, 0}; \
|
||||
static const vec_uchar16 b123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 16, 17, 22, 23, 28, 29}; \
|
||||
b = vec_perm(vec_perm(v1, v2, b12_perm), v3, b123_perm); \
|
||||
static const vec_uchar16 c12_perm = {4, 5, 10, 11, 16, 17, 22, 23, 28, 29, 0, 0, 0, 0, 0, 0}; \
|
||||
static const vec_uchar16 c123_perm = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 18, 19, 24, 25, 30, 31}; \
|
||||
c = vec_perm(vec_perm(v1, v2, c12_perm), v3, c123_perm); \
|
||||
}
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_8(ushort, vec_ushort8)
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_8(short, vec_short8)
|
||||
|
||||
#define VSX_IMPL_ST_INTERLEAVE_3CH_4(Tp, Tvec) \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \
|
||||
const Tvec& c, Tp* ptr) \
|
||||
{ \
|
||||
Tvec hbc = vec_mergeh(b, c); \
|
||||
static const vec_uchar16 ahbc = {0, 1, 2, 3, 16, 17, 18, 19, 20, 21, 22, 23, 4, 5, 6, 7}; \
|
||||
vsx_st(vec_perm(a, hbc, ahbc), 0, ptr); \
|
||||
Tvec lab = vec_mergel(a, b); \
|
||||
vsx_st(vec_sld(lab, hbc, 8), 4, ptr); \
|
||||
static const vec_uchar16 clab = {8, 9, 10, 11, 24, 25, 26, 27, 28, 29, 30, 31, 12, 13, 14, 15};\
|
||||
vsx_st(vec_perm(c, lab, clab), 8, ptr); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, Tvec& b, Tvec& c) \
|
||||
{ \
|
||||
Tvec v1 = vsx_ld(0, ptr); \
|
||||
Tvec v2 = vsx_ld(4, ptr); \
|
||||
Tvec v3 = vsx_ld(8, ptr); \
|
||||
static const vec_uchar16 flp = {0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19, 28, 29, 30, 31}; \
|
||||
a = vec_perm(v1, vec_sld(v3, v2, 8), flp); \
|
||||
static const vec_uchar16 flp2 = {28, 29, 30, 31, 0, 1, 2, 3, 12, 13, 14, 15, 16, 17, 18, 19}; \
|
||||
b = vec_perm(v2, vec_sld(v1, v3, 8), flp2); \
|
||||
c = vec_perm(vec_sld(v2, v1, 8), v3, flp); \
|
||||
}
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_4(uint, vec_uint4)
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_4(int, vec_int4)
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_4(float, vec_float4)
|
||||
|
||||
#define VSX_IMPL_ST_INTERLEAVE_3CH_2(Tp, Tvec, ld_func, st_func) \
|
||||
FORCE_INLINE(void) vec_st_interleave(const Tvec& a, const Tvec& b, \
|
||||
const Tvec& c, Tp* ptr) \
|
||||
{ \
|
||||
st_func(vec_mergeh(a, b), 0, ptr); \
|
||||
st_func(vec_permi(c, a, 1), 2, ptr); \
|
||||
st_func(vec_mergel(b, c), 4, ptr); \
|
||||
} \
|
||||
FORCE_INLINE(void) vec_ld_deinterleave(const Tp* ptr, Tvec& a, \
|
||||
Tvec& b, Tvec& c) \
|
||||
{ \
|
||||
Tvec v1 = ld_func(0, ptr); \
|
||||
Tvec v2 = ld_func(2, ptr); \
|
||||
Tvec v3 = ld_func(4, ptr); \
|
||||
a = vec_permi(v1, v2, 1); \
|
||||
b = vec_permi(v1, v3, 2); \
|
||||
c = vec_permi(v2, v3, 1); \
|
||||
}
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_2(int64, vec_dword2, vsx_ld2, vsx_st2)
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_2(uint64, vec_udword2, vsx_ld2, vsx_st2)
|
||||
VSX_IMPL_ST_INTERLEAVE_3CH_2(double, vec_double2, vsx_ld, vsx_st)
|
||||
|
||||
#endif // CV_VSX
|
||||
|
||||
//! @}
|
||||
|
||||
#endif // OPENCV_HAL_VSX_UTILS_HPP
|
||||
@@ -727,7 +727,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
|
||||
//! @cond IGNORED
|
||||
#define CALL_HAL_RET(name, fun, retval, ...) \
|
||||
{ \
|
||||
int res = fun(__VA_ARGS__, &retval); \
|
||||
int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \
|
||||
if (res == CV_HAL_ERROR_OK) \
|
||||
return retval; \
|
||||
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
|
||||
@@ -738,7 +738,7 @@ inline int hal_ni_gemm64fc(const double* src1, size_t src1_step, const double* s
|
||||
|
||||
#define CALL_HAL(name, fun, ...) \
|
||||
{ \
|
||||
int res = fun(__VA_ARGS__); \
|
||||
int res = __CV_EXPAND(fun(__VA_ARGS__)); \
|
||||
if (res == CV_HAL_ERROR_OK) \
|
||||
return; \
|
||||
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
|
||||
|
||||
@@ -605,24 +605,18 @@ void polarToCart( InputArray src1, InputArray src2,
|
||||
{
|
||||
k = 0;
|
||||
|
||||
#if CV_NEON
|
||||
for( ; k <= len - 4; k += 4 )
|
||||
#if CV_SIMD128
|
||||
if( hasSIMD128() )
|
||||
{
|
||||
float32x4_t v_m = vld1q_f32(mag + k);
|
||||
vst1q_f32(x + k, vmulq_f32(vld1q_f32(x + k), v_m));
|
||||
vst1q_f32(y + k, vmulq_f32(vld1q_f32(y + k), v_m));
|
||||
}
|
||||
#elif CV_SSE2
|
||||
if (USE_SSE2)
|
||||
{
|
||||
for( ; k <= len - 4; k += 4 )
|
||||
int cWidth = v_float32x4::nlanes;
|
||||
for( ; k <= len - cWidth; k += cWidth )
|
||||
{
|
||||
__m128 v_m = _mm_loadu_ps(mag + k);
|
||||
_mm_storeu_ps(x + k, _mm_mul_ps(_mm_loadu_ps(x + k), v_m));
|
||||
_mm_storeu_ps(y + k, _mm_mul_ps(_mm_loadu_ps(y + k), v_m));
|
||||
v_float32x4 v_m = v_load(mag + k);
|
||||
v_store(x + k, v_load(x + k) * v_m);
|
||||
v_store(y + k, v_load(y + k) * v_m);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
for( ; k < len; k++ )
|
||||
{
|
||||
@@ -1599,12 +1593,9 @@ void patchNaNs( InputOutputArray _a, double _val )
|
||||
Cv32suf val;
|
||||
val.f = (float)_val;
|
||||
|
||||
#if CV_SSE2
|
||||
__m128i v_mask1 = _mm_set1_epi32(0x7fffffff), v_mask2 = _mm_set1_epi32(0x7f800000);
|
||||
__m128i v_val = _mm_set1_epi32(val.i);
|
||||
#elif CV_NEON
|
||||
int32x4_t v_mask1 = vdupq_n_s32(0x7fffffff), v_mask2 = vdupq_n_s32(0x7f800000),
|
||||
v_val = vdupq_n_s32(val.i);
|
||||
#if CV_SIMD128
|
||||
v_int32x4 v_mask1 = v_setall_s32(0x7fffffff), v_mask2 = v_setall_s32(0x7f800000);
|
||||
v_int32x4 v_val = v_setall_s32(val.i);
|
||||
#endif
|
||||
|
||||
for( size_t i = 0; i < it.nplanes; i++, ++it )
|
||||
@@ -1612,25 +1603,18 @@ void patchNaNs( InputOutputArray _a, double _val )
|
||||
int* tptr = ptrs[0];
|
||||
size_t j = 0;
|
||||
|
||||
#if CV_SSE2
|
||||
if (USE_SSE2)
|
||||
#if CV_SIMD128
|
||||
if( hasSIMD128() )
|
||||
{
|
||||
for ( ; j + 4 <= len; j += 4)
|
||||
size_t cWidth = (size_t)v_int32x4::nlanes;
|
||||
for ( ; j + cWidth <= len; j += cWidth)
|
||||
{
|
||||
__m128i v_src = _mm_loadu_si128((__m128i const *)(tptr + j));
|
||||
__m128i v_cmp_mask = _mm_cmplt_epi32(v_mask2, _mm_and_si128(v_src, v_mask1));
|
||||
__m128i v_res = _mm_or_si128(_mm_andnot_si128(v_cmp_mask, v_src), _mm_and_si128(v_cmp_mask, v_val));
|
||||
_mm_storeu_si128((__m128i *)(tptr + j), v_res);
|
||||
v_int32x4 v_src = v_load(tptr + j);
|
||||
v_int32x4 v_cmp_mask = v_mask2 < (v_src & v_mask1);
|
||||
v_int32x4 v_dst = v_select(v_cmp_mask, v_val, v_src);
|
||||
v_store(tptr + j, v_dst);
|
||||
}
|
||||
}
|
||||
#elif CV_NEON
|
||||
for ( ; j + 4 <= len; j += 4)
|
||||
{
|
||||
int32x4_t v_src = vld1q_s32(tptr + j);
|
||||
uint32x4_t v_cmp_mask = vcltq_s32(v_mask2, vandq_s32(v_src, v_mask1));
|
||||
int32x4_t v_dst = vbslq_s32(v_cmp_mask, v_val, v_src);
|
||||
vst1q_s32(tptr + j, v_dst);
|
||||
}
|
||||
#endif
|
||||
|
||||
for( ; j < len; j++ )
|
||||
|
||||
@@ -845,11 +845,11 @@ static bool ocl_gemm( InputArray matA, InputArray matB, double alpha,
|
||||
int vectorWidths[] = { 4, 4, 2, 2, 1, 4, cn, -1 };
|
||||
int kercn = ocl::checkOptimalVectorWidth(vectorWidths, B, D);
|
||||
|
||||
opts += format(" -D T=%s -D T1=%s -D WT=%s -D cn=%d -D kercn=%d -D LOCAL_SIZE=%d %s %s %s",
|
||||
opts += format(" -D T=%s -D T1=%s -D WT=%s -D cn=%d -D kercn=%d -D LOCAL_SIZE=%d%s%s%s",
|
||||
ocl::typeToStr(type), ocl::typeToStr(depth), ocl::typeToStr(CV_MAKETYPE(depth, kercn)),
|
||||
cn, kercn, block_size,
|
||||
(sizeA.width % block_size !=0) ? "-D NO_MULT" : "",
|
||||
haveC ? "-D HAVE_C" : "",
|
||||
(sizeA.width % block_size !=0) ? " -D NO_MULT" : "",
|
||||
haveC ? " -D HAVE_C" : "",
|
||||
doubleSupport ? " -D DOUBLE_SUPPORT" : "");
|
||||
|
||||
ocl::Kernel k("gemm", cv::ocl::core::gemm_oclsrc, opts);
|
||||
|
||||
@@ -1151,7 +1151,7 @@ int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) con
|
||||
}
|
||||
|
||||
template <typename T> static inline
|
||||
void scalarToRawData(const Scalar& s, T * const buf, const int cn, const int unroll_to)
|
||||
void scalarToRawData_(const Scalar& s, T * const buf, const int cn, const int unroll_to)
|
||||
{
|
||||
int i = 0;
|
||||
for(; i < cn; i++)
|
||||
@@ -1169,25 +1169,25 @@ void scalarToRawData(const Scalar& s, void* _buf, int type, int unroll_to)
|
||||
switch(depth)
|
||||
{
|
||||
case CV_8U:
|
||||
scalarToRawData<uchar>(s, (uchar*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<uchar>(s, (uchar*)_buf, cn, unroll_to);
|
||||
break;
|
||||
case CV_8S:
|
||||
scalarToRawData<schar>(s, (schar*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<schar>(s, (schar*)_buf, cn, unroll_to);
|
||||
break;
|
||||
case CV_16U:
|
||||
scalarToRawData<ushort>(s, (ushort*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<ushort>(s, (ushort*)_buf, cn, unroll_to);
|
||||
break;
|
||||
case CV_16S:
|
||||
scalarToRawData<short>(s, (short*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<short>(s, (short*)_buf, cn, unroll_to);
|
||||
break;
|
||||
case CV_32S:
|
||||
scalarToRawData<int>(s, (int*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<int>(s, (int*)_buf, cn, unroll_to);
|
||||
break;
|
||||
case CV_32F:
|
||||
scalarToRawData<float>(s, (float*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<float>(s, (float*)_buf, cn, unroll_to);
|
||||
break;
|
||||
case CV_64F:
|
||||
scalarToRawData<double>(s, (double*)_buf, cn, unroll_to);
|
||||
scalarToRawData_<double>(s, (double*)_buf, cn, unroll_to);
|
||||
break;
|
||||
default:
|
||||
CV_Error(CV_StsUnsupportedFormat,"");
|
||||
|
||||
+15
-46
@@ -1387,7 +1387,7 @@ struct Context::Impl
|
||||
}
|
||||
}
|
||||
Program prog(src, buildflags, errmsg);
|
||||
if(prog.ptr())
|
||||
// Cache result of build failures too (to prevent unnecessary compiler invocations)
|
||||
{
|
||||
cv::AutoLock lock(program_cache_mutex);
|
||||
phash.insert(std::pair<std::string, Program>(key, prog));
|
||||
@@ -5288,68 +5288,37 @@ struct Timer::Impl
|
||||
#endif
|
||||
}
|
||||
|
||||
float microSeconds()
|
||||
uint64 durationNS() const
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return (float)timer.getTimeMicro();
|
||||
return (uint64)(timer.getTimeSec() * 1e9);
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float milliSeconds()
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return (float)timer.getTimeMilli();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
float seconds()
|
||||
{
|
||||
#ifdef HAVE_OPENCL
|
||||
return (float)timer.getTimeSec();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
TickMeter timer;
|
||||
};
|
||||
|
||||
Timer::Timer(const Queue& q)
|
||||
{
|
||||
p = new Impl(q);
|
||||
}
|
||||
|
||||
Timer::~Timer()
|
||||
{
|
||||
if(p)
|
||||
{
|
||||
delete p;
|
||||
p = 0;
|
||||
}
|
||||
}
|
||||
Timer::Timer(const Queue& q) : p(new Impl(q)) { }
|
||||
Timer::~Timer() { delete p; }
|
||||
|
||||
void Timer::start()
|
||||
{
|
||||
if(p)
|
||||
p->start();
|
||||
CV_Assert(p);
|
||||
p->start();
|
||||
}
|
||||
|
||||
void Timer::stop()
|
||||
{
|
||||
if(p)
|
||||
p->stop();
|
||||
CV_Assert(p);
|
||||
p->stop();
|
||||
}
|
||||
|
||||
float Timer::microSeconds()
|
||||
{ return p ? p->microSeconds() : 0; }
|
||||
uint64 Timer::durationNS() const
|
||||
{
|
||||
CV_Assert(p);
|
||||
return p->durationNS();
|
||||
}
|
||||
|
||||
float Timer::milliSeconds()
|
||||
{ return p ? p->milliSeconds() : 0; }
|
||||
|
||||
float Timer::seconds()
|
||||
{ return p ? p->seconds() : 0; }
|
||||
|
||||
}}
|
||||
}} // namespace
|
||||
|
||||
@@ -85,7 +85,7 @@
|
||||
#include "opencv2/core/hal/intrin.hpp"
|
||||
#include "opencv2/core/sse_utils.hpp"
|
||||
#include "opencv2/core/neon_utils.hpp"
|
||||
|
||||
#include "opencv2/core/vsx_utils.hpp"
|
||||
#include "arithm_core.hpp"
|
||||
#include "hal_replacement.hpp"
|
||||
|
||||
|
||||
@@ -80,6 +80,18 @@ Mutex* __initialization_mutex_initializer = &getInitializationMutex();
|
||||
# include <cpu-features.h>
|
||||
#endif
|
||||
|
||||
#ifndef __VSX__
|
||||
# if defined __PPC64__ && defined __linux__
|
||||
# include "sys/auxv.h"
|
||||
# ifndef AT_HWCAP2
|
||||
# define AT_HWCAP2 26
|
||||
# endif
|
||||
# ifndef PPC_FEATURE2_ARCH_2_07
|
||||
# define PPC_FEATURE2_ARCH_2_07 0x80000000
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined _WIN32 || defined WINCE
|
||||
#ifndef _WIN32_WINNT // This is needed for the declaration of TryEnterCriticalSection in winbase.h with Visual Studio 2005 (and older?)
|
||||
#define _WIN32_WINNT 0x0400 // http://msdn.microsoft.com/en-us/library/ms686857(VS.85).aspx
|
||||
@@ -295,6 +307,8 @@ struct HWFeatures
|
||||
g_hwFeatureNames[CPU_AVX_512VL] = "AVX512VL";
|
||||
|
||||
g_hwFeatureNames[CPU_NEON] = "NEON";
|
||||
|
||||
g_hwFeatureNames[CPU_VSX] = "VSX";
|
||||
}
|
||||
|
||||
void initialize(void)
|
||||
@@ -504,6 +518,16 @@ struct HWFeatures
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifdef __VSX__
|
||||
have[CV_CPU_VSX] = true;
|
||||
#elif (defined __PPC64__ && defined __linux__)
|
||||
uint64 hwcaps = getauxval(AT_HWCAP);
|
||||
uint64 hwcap2 = getauxval(AT_HWCAP2);
|
||||
have[CV_CPU_VSX] = (hwcaps & PPC_FEATURE_PPC_LE && hwcaps & PPC_FEATURE_HAS_VSX && hwcap2 & PPC_FEATURE2_ARCH_2_07);
|
||||
#else
|
||||
have[CV_CPU_VSX] = false;
|
||||
#endif
|
||||
|
||||
int baseline_features[] = { CV_CPU_BASELINE_FEATURES };
|
||||
if (!checkFeatures(baseline_features, sizeof(baseline_features) / sizeof(baseline_features[0])))
|
||||
{
|
||||
|
||||
@@ -133,7 +133,7 @@ int Core_ReduceTest::checkOp( const Mat& src, int dstType, int opType, const Mat
|
||||
|
||||
assert( opRes.type() == CV_64FC1 );
|
||||
Mat _dst, dst, diff;
|
||||
reduce( src, _dst, dim, opType, dstType );
|
||||
cv::reduce( src, _dst, dim, opType, dstType );
|
||||
_dst.convertTo( dst, CV_64FC1 );
|
||||
|
||||
absdiff( opRes,dst,diff );
|
||||
@@ -313,7 +313,7 @@ protected:
|
||||
Mat rBackPrjTestPoints = rPCA.backProject( rPrjTestPoints );
|
||||
|
||||
Mat avg(1, sz.width, CV_32FC1 );
|
||||
reduce( rPoints, avg, 0, CV_REDUCE_AVG );
|
||||
cv::reduce( rPoints, avg, 0, CV_REDUCE_AVG );
|
||||
Mat Q = rPoints - repeat( avg, rPoints.rows, 1 ), Qt = Q.t(), eval, evec;
|
||||
Q = Qt * Q;
|
||||
Q = Q /(float)rPoints.rows;
|
||||
@@ -1804,4 +1804,24 @@ TEST(Mat_, from_initializer_list)
|
||||
ASSERT_DOUBLE_EQ(norm(A, B, NORM_INF), 0.);
|
||||
}
|
||||
|
||||
|
||||
TEST(Mat, template_based_ptr)
|
||||
{
|
||||
Mat mat = (Mat_<float>(2, 2) << 11.0f, 22.0f, 33.0f, 44.0f);
|
||||
int idx[2] = {1, 0};
|
||||
ASSERT_FLOAT_EQ(33.0f, *(mat.ptr<float>(idx)));
|
||||
idx[0] = 1;
|
||||
idx[1] = 1;
|
||||
ASSERT_FLOAT_EQ(44.0f, *(mat.ptr<float>(idx)));
|
||||
}
|
||||
|
||||
TEST(Mat_, template_based_ptr)
|
||||
{
|
||||
int dim[4] = {2, 2, 1, 2};
|
||||
Mat_<float> mat = (Mat_<float>(4, dim) << 11.0f, 22.0f, 33.0f, 44.0f,
|
||||
55.0f, 66.0f, 77.0f, 88.0f);
|
||||
int idx[4] = {1, 0, 0, 1};
|
||||
ASSERT_FLOAT_EQ(66.0f, *(mat.ptr<float>(idx)));
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -263,14 +263,6 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
static Ptr<SoftmaxLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS LPNormalizeLayer : public Layer
|
||||
{
|
||||
public:
|
||||
float pnorm, epsilon;
|
||||
|
||||
static Ptr<LPNormalizeLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS InnerProductLayer : public Layer
|
||||
{
|
||||
public:
|
||||
@@ -422,7 +414,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
class CV_EXPORTS ChannelsPReLULayer : public ActivationLayer
|
||||
{
|
||||
public:
|
||||
static Ptr<ChannelsPReLULayer> create(const LayerParams& params);
|
||||
static Ptr<Layer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ELULayer : public ActivationLayer
|
||||
@@ -527,15 +519,55 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
static Ptr<PriorBoxLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS ReorgLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<ReorgLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS RegionLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<RegionLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
class CV_EXPORTS DetectionOutputLayer : public Layer
|
||||
{
|
||||
public:
|
||||
static Ptr<DetectionOutputLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
/**
|
||||
* @brief \f$ L_p \f$ - normalization layer.
|
||||
* @param p Normalization factor. The most common `p = 1` for \f$ L_1 \f$ -
|
||||
* normalization or `p = 2` for \f$ L_2 \f$ - normalization or a custom one.
|
||||
* @param eps Parameter \f$ \epsilon \f$ to prevent a division by zero.
|
||||
* @param across_spatial If true, normalize an input across all non-batch dimensions.
|
||||
* Otherwise normalize an every channel separately.
|
||||
*
|
||||
* Across spatial:
|
||||
* @f[
|
||||
* norm = \sqrt[p]{\epsilon + \sum_{x, y, c} |src(x, y, c)|^p } \\
|
||||
* dst(x, y, c) = \frac{ src(x, y, c) }{norm}
|
||||
* @f]
|
||||
*
|
||||
* Channel wise normalization:
|
||||
* @f[
|
||||
* norm(c) = \sqrt[p]{\epsilon + \sum_{x, y} |src(x, y, c)|^p } \\
|
||||
* dst(x, y, c) = \frac{ src(x, y, c) }{norm(c)}
|
||||
* @f]
|
||||
*
|
||||
* Where `x, y` - spatial cooridnates, `c` - channel.
|
||||
*
|
||||
* An every sample in the batch is normalized separately. Optionally,
|
||||
* output is scaled by the trained parameters.
|
||||
*/
|
||||
class NormalizeBBoxLayer : public Layer
|
||||
{
|
||||
public:
|
||||
float pnorm, epsilon;
|
||||
bool acrossSpatial;
|
||||
|
||||
static Ptr<NormalizeBBoxLayer> create(const LayerParams& params);
|
||||
};
|
||||
|
||||
|
||||
@@ -612,6 +612,14 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
virtual ~Importer();
|
||||
};
|
||||
|
||||
/** @brief Reads a network model stored in <a href="https://pjreddie.com/darknet/">Darknet</a> model files.
|
||||
* @param cfgFile path to the .cfg file with text description of the network architecture.
|
||||
* @param darknetModel path to the .weights file with learned network.
|
||||
* @returns Network object that ready to do forward, throw an exception in failure cases.
|
||||
* @details This is shortcut consisting from DarknetImporter and Net::populateNet calls.
|
||||
*/
|
||||
CV_EXPORTS_W Net readNetFromDarknet(const String &cfgFile, const String &darknetModel = String());
|
||||
|
||||
/**
|
||||
* @deprecated Use @ref readNetFromCaffe instead.
|
||||
* @brief Creates the importer of <a href="http://caffe.berkeleyvision.org">Caffe</a> framework network.
|
||||
@@ -629,7 +637,7 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
/** @brief Reads a network model stored in Tensorflow model file.
|
||||
* @details This is shortcut consisting from createTensorflowImporter and Net::populateNet calls.
|
||||
*/
|
||||
CV_EXPORTS_W Net readNetFromTensorflow(const String &model);
|
||||
CV_EXPORTS_W Net readNetFromTensorflow(const String &model, const String &config = String());
|
||||
|
||||
/** @brief Reads a network model stored in Torch model file.
|
||||
* @details This is shortcut consisting from createTorchImporter and Net::populateNet calls.
|
||||
@@ -687,12 +695,14 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
* @param scalefactor multiplier for @p image values.
|
||||
* @param swapRB flag which indicates that swap first and last channels
|
||||
* in 3-channel image is necessary.
|
||||
* @details input image is resized so one side after resize is equal to corresponing
|
||||
* @param crop flag which indicates whether image will be cropped after resize or not
|
||||
* @details if @p crop is true, input image is resized so one side after resize is equal to corresponing
|
||||
* dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
|
||||
* If @p crop is false, direct resize without cropping and preserving aspect ratio is performed.
|
||||
* @returns 4-dimansional Mat with NCHW dimensions order.
|
||||
*/
|
||||
CV_EXPORTS_W Mat blobFromImage(const Mat& image, double scalefactor=1.0, const Size& size = Size(),
|
||||
const Scalar& mean = Scalar(), bool swapRB=true);
|
||||
const Scalar& mean = Scalar(), bool swapRB=true, bool crop=true);
|
||||
/** @brief Creates 4-dimensional blob from series of images. Optionally resizes and
|
||||
* crops @p images from center, subtract @p mean values, scales values by @p scalefactor,
|
||||
* swap Blue and Red channels.
|
||||
@@ -703,12 +713,14 @@ CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
* @param scalefactor multiplier for @p images values.
|
||||
* @param swapRB flag which indicates that swap first and last channels
|
||||
* in 3-channel image is necessary.
|
||||
* @details input image is resized so one side after resize is equal to corresponing
|
||||
* @param crop flag which indicates whether image will be cropped after resize or not
|
||||
* @details if @p crop is true, input image is resized so one side after resize is equal to corresponing
|
||||
* dimension in @p size and another one is equal or larger. Then, crop from the center is performed.
|
||||
* If @p crop is false, direct resize without cropping and preserving aspect ratio is performed.
|
||||
* @returns 4-dimansional Mat with NCHW dimensions order.
|
||||
*/
|
||||
CV_EXPORTS_W Mat blobFromImages(const std::vector<Mat>& images, double scalefactor=1.0,
|
||||
Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=true);
|
||||
Size size = Size(), const Scalar& mean = Scalar(), bool swapRB=true, bool crop=true);
|
||||
|
||||
/** @brief Convert all weights of Caffe network to half precision floating point.
|
||||
* @param src Path to origin model from Caffe framework contains single
|
||||
|
||||
+472
-411
@@ -347,7 +347,7 @@ void protobuf_AssignDesc_caffe_2eproto() {
|
||||
sizeof(NormalizeBBoxParameter),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(NormalizeBBoxParameter, _internal_metadata_));
|
||||
PriorBoxParameter_descriptor_ = file->message_type(5);
|
||||
static const int PriorBoxParameter_offsets_[13] = {
|
||||
static const int PriorBoxParameter_offsets_[14] = {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, min_size_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, max_size_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, aspect_ratio_),
|
||||
@@ -361,6 +361,7 @@ void protobuf_AssignDesc_caffe_2eproto() {
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, step_h_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, step_w_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, offset_),
|
||||
GOOGLE_PROTOBUF_GENERATED_MESSAGE_FIELD_OFFSET(PriorBoxParameter, additional_y_offset_),
|
||||
};
|
||||
PriorBoxParameter_reflection_ =
|
||||
::google::protobuf::internal::GeneratedMessageReflection::NewGeneratedMessageReflection(
|
||||
@@ -2130,418 +2131,419 @@ void protobuf_AddDesc_caffe_2eproto_impl() {
|
||||
"(\r\"\226\001\n\026NormalizeBBoxParameter\022\034\n\016across_"
|
||||
"spatial\030\001 \001(\010:\004true\022,\n\014scale_filler\030\002 \001("
|
||||
"\0132\026.caffe.FillerParameter\022\034\n\016channel_sha"
|
||||
"red\030\003 \001(\010:\004true\022\022\n\003eps\030\004 \001(\002:\0051e-10\"\243\002\n\021"
|
||||
"red\030\003 \001(\010:\004true\022\022\n\003eps\030\004 \001(\002:\0051e-10\"\307\002\n\021"
|
||||
"PriorBoxParameter\022\020\n\010min_size\030\001 \001(\002\022\020\n\010m"
|
||||
"ax_size\030\002 \001(\002\022\024\n\014aspect_ratio\030\003 \003(\002\022\022\n\004f"
|
||||
"lip\030\004 \001(\010:\004true\022\022\n\004clip\030\005 \001(\010:\004true\022\020\n\010v"
|
||||
"ariance\030\006 \003(\002\022\020\n\010img_size\030\007 \001(\r\022\r\n\005img_h"
|
||||
"\030\010 \001(\r\022\r\n\005img_w\030\t \001(\r\022\014\n\004step\030\n \001(\002\022\016\n\006s"
|
||||
"tep_h\030\013 \001(\002\022\016\n\006step_w\030\014 \001(\002\022\023\n\006offset\030\r "
|
||||
"\001(\002:\0030.5\"\'\n\010CodeType\022\n\n\006CORNER\020\001\022\017\n\013CENT"
|
||||
"ER_SIZE\020\002\"\375\002\n\030DetectionOutputParameter\022\023"
|
||||
"\n\013num_classes\030\001 \001(\r\022\034\n\016share_location\030\002 "
|
||||
"\001(\010:\004true\022\036\n\023background_label_id\030\003 \001(\005:\001"
|
||||
"0\0228\n\tnms_param\030\004 \001(\0132%.caffe.NonMaximumS"
|
||||
"uppressionParameter\0225\n\021save_output_param"
|
||||
"\030\005 \001(\0132\032.caffe.SaveOutputParameter\022<\n\tco"
|
||||
"de_type\030\006 \001(\0162!.caffe.PriorBoxParameter."
|
||||
"CodeType:\006CORNER\022)\n\032variance_encoded_in_"
|
||||
"target\030\010 \001(\010:\005false\022\026\n\nkeep_top_k\030\007 \001(\005:"
|
||||
"\002-1\022\034\n\024confidence_threshold\030\t \001(\002\"\201\001\n\005Da"
|
||||
"tum\022\020\n\010channels\030\001 \001(\005\022\016\n\006height\030\002 \001(\005\022\r\n"
|
||||
"\005width\030\003 \001(\005\022\014\n\004data\030\004 \001(\014\022\r\n\005label\030\005 \001("
|
||||
"\005\022\022\n\nfloat_data\030\006 \003(\002\022\026\n\007encoded\030\007 \001(\010:\005"
|
||||
"false\"\212\002\n\017FillerParameter\022\026\n\004type\030\001 \001(\t:"
|
||||
"\010constant\022\020\n\005value\030\002 \001(\002:\0010\022\016\n\003min\030\003 \001(\002"
|
||||
":\0010\022\016\n\003max\030\004 \001(\002:\0011\022\017\n\004mean\030\005 \001(\002:\0010\022\016\n\003"
|
||||
"std\030\006 \001(\002:\0011\022\022\n\006sparse\030\007 \001(\005:\002-1\022B\n\rvari"
|
||||
"ance_norm\030\010 \001(\0162#.caffe.FillerParameter."
|
||||
"VarianceNorm:\006FAN_IN\"4\n\014VarianceNorm\022\n\n\006"
|
||||
"FAN_IN\020\000\022\013\n\007FAN_OUT\020\001\022\013\n\007AVERAGE\020\002\"\216\002\n\014N"
|
||||
"etParameter\022\014\n\004name\030\001 \001(\t\022\r\n\005input\030\003 \003(\t"
|
||||
"\022%\n\013input_shape\030\010 \003(\0132\020.caffe.BlobShape\022"
|
||||
"\021\n\tinput_dim\030\004 \003(\005\022\035\n\016force_backward\030\005 \001"
|
||||
"(\010:\005false\022\036\n\005state\030\006 \001(\0132\017.caffe.NetStat"
|
||||
"e\022\031\n\ndebug_info\030\007 \001(\010:\005false\022$\n\005layer\030d "
|
||||
"\003(\0132\025.caffe.LayerParameter\022\'\n\006layers\030\002 \003"
|
||||
"(\0132\027.caffe.V1LayerParameter\"\242\n\n\017SolverPa"
|
||||
"rameter\022\013\n\003net\030\030 \001(\t\022&\n\tnet_param\030\031 \001(\0132"
|
||||
"\023.caffe.NetParameter\022\021\n\ttrain_net\030\001 \001(\t\022"
|
||||
"\020\n\010test_net\030\002 \003(\t\022,\n\017train_net_param\030\025 \001"
|
||||
"(\0132\023.caffe.NetParameter\022+\n\016test_net_para"
|
||||
"m\030\026 \003(\0132\023.caffe.NetParameter\022$\n\013train_st"
|
||||
"ate\030\032 \001(\0132\017.caffe.NetState\022#\n\ntest_state"
|
||||
"\030\033 \003(\0132\017.caffe.NetState\022\021\n\ttest_iter\030\003 \003"
|
||||
"(\005\022\030\n\rtest_interval\030\004 \001(\005:\0010\022 \n\021test_com"
|
||||
"pute_loss\030\023 \001(\010:\005false\022!\n\023test_initializ"
|
||||
"ation\030 \001(\010:\004true\022\017\n\007base_lr\030\005 \001(\002\022\017\n\007di"
|
||||
"splay\030\006 \001(\005\022\027\n\014average_loss\030! \001(\005:\0011\022\020\n\010"
|
||||
"max_iter\030\007 \001(\005\022\024\n\titer_size\030$ \001(\005:\0011\022\021\n\t"
|
||||
"lr_policy\030\010 \001(\t\022\r\n\005gamma\030\t \001(\002\022\r\n\005power\030"
|
||||
"\n \001(\002\022\020\n\010momentum\030\013 \001(\002\022\024\n\014weight_decay\030"
|
||||
"\014 \001(\002\022\037\n\023regularization_type\030\035 \001(\t:\002L2\022\020"
|
||||
"\n\010stepsize\030\r \001(\005\022\021\n\tstepvalue\030\" \003(\005\022\032\n\016c"
|
||||
"lip_gradients\030# \001(\002:\002-1\022\023\n\010snapshot\030\016 \001("
|
||||
"\005:\0010\022\027\n\017snapshot_prefix\030\017 \001(\t\022\034\n\rsnapsho"
|
||||
"t_diff\030\020 \001(\010:\005false\022K\n\017snapshot_format\030%"
|
||||
" \001(\0162%.caffe.SolverParameter.SnapshotFor"
|
||||
"mat:\013BINARYPROTO\022;\n\013solver_mode\030\021 \001(\0162!."
|
||||
"caffe.SolverParameter.SolverMode:\003GPU\022\024\n"
|
||||
"\tdevice_id\030\022 \001(\005:\0010\022\027\n\013random_seed\030\024 \001(\003"
|
||||
":\002-1\022\021\n\004type\030( \001(\t:\003SGD\022\024\n\005delta\030\037 \001(\002:\005"
|
||||
"1e-08\022\030\n\tmomentum2\030\' \001(\002:\0050.999\022\027\n\trms_d"
|
||||
"ecay\030& \001(\002:\0040.99\022\031\n\ndebug_info\030\027 \001(\010:\005fa"
|
||||
"lse\022\"\n\024snapshot_after_train\030\034 \001(\010:\004true\022"
|
||||
";\n\013solver_type\030\036 \001(\0162!.caffe.SolverParam"
|
||||
"eter.SolverType:\003SGD\"+\n\016SnapshotFormat\022\010"
|
||||
"\n\004HDF5\020\000\022\017\n\013BINARYPROTO\020\001\"\036\n\nSolverMode\022"
|
||||
"\007\n\003CPU\020\000\022\007\n\003GPU\020\001\"U\n\nSolverType\022\007\n\003SGD\020\000"
|
||||
"\022\014\n\010NESTEROV\020\001\022\013\n\007ADAGRAD\020\002\022\013\n\007RMSPROP\020\003"
|
||||
"\022\014\n\010ADADELTA\020\004\022\010\n\004ADAM\020\005\"l\n\013SolverState\022"
|
||||
"\014\n\004iter\030\001 \001(\005\022\023\n\013learned_net\030\002 \001(\t\022!\n\007hi"
|
||||
"story\030\003 \003(\0132\020.caffe.BlobProto\022\027\n\014current"
|
||||
"_step\030\004 \001(\005:\0010\"N\n\010NetState\022!\n\005phase\030\001 \001("
|
||||
"\0162\014.caffe.Phase:\004TEST\022\020\n\005level\030\002 \001(\005:\0010\022"
|
||||
"\r\n\005stage\030\003 \003(\t\"s\n\014NetStateRule\022\033\n\005phase\030"
|
||||
"\001 \001(\0162\014.caffe.Phase\022\021\n\tmin_level\030\002 \001(\005\022\021"
|
||||
"\n\tmax_level\030\003 \001(\005\022\r\n\005stage\030\004 \003(\t\022\021\n\tnot_"
|
||||
"stage\030\005 \003(\t\"\243\001\n\tParamSpec\022\014\n\004name\030\001 \001(\t\022"
|
||||
"1\n\nshare_mode\030\002 \001(\0162\035.caffe.ParamSpec.Di"
|
||||
"mCheckMode\022\022\n\007lr_mult\030\003 \001(\002:\0011\022\025\n\ndecay_"
|
||||
"mult\030\004 \001(\002:\0011\"*\n\014DimCheckMode\022\n\n\006STRICT\020"
|
||||
"\000\022\016\n\nPERMISSIVE\020\001\"\335\025\n\016LayerParameter\022\014\n\004"
|
||||
"name\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022\016\n\006bottom\030\003 \003(\t"
|
||||
"\022\013\n\003top\030\004 \003(\t\022\033\n\005phase\030\n \001(\0162\014.caffe.Pha"
|
||||
"se\022\023\n\013loss_weight\030\005 \003(\002\022\037\n\005param\030\006 \003(\0132\020"
|
||||
".caffe.ParamSpec\022\037\n\005blobs\030\007 \003(\0132\020.caffe."
|
||||
"BlobProto\022\026\n\016propagate_down\030\013 \003(\010\022$\n\007inc"
|
||||
"lude\030\010 \003(\0132\023.caffe.NetStateRule\022$\n\007exclu"
|
||||
"de\030\t \003(\0132\023.caffe.NetStateRule\0227\n\017transfo"
|
||||
"rm_param\030d \001(\0132\036.caffe.TransformationPar"
|
||||
"ameter\022(\n\nloss_param\030e \001(\0132\024.caffe.LossP"
|
||||
"arameter\0220\n\016accuracy_param\030f \001(\0132\030.caffe"
|
||||
".AccuracyParameter\022,\n\014argmax_param\030g \001(\013"
|
||||
"2\026.caffe.ArgMaxParameter\0224\n\020batch_norm_p"
|
||||
"aram\030\213\001 \001(\0132\031.caffe.BatchNormParameter\022)"
|
||||
"\n\nbias_param\030\215\001 \001(\0132\024.caffe.BiasParamete"
|
||||
"r\022,\n\014concat_param\030h \001(\0132\026.caffe.ConcatPa"
|
||||
"rameter\022\?\n\026contrastive_loss_param\030i \001(\0132"
|
||||
"\037.caffe.ContrastiveLossParameter\0226\n\021conv"
|
||||
"olution_param\030j \001(\0132\033.caffe.ConvolutionP"
|
||||
"arameter\022)\n\ncrop_param\030\220\001 \001(\0132\024.caffe.Cr"
|
||||
"opParameter\022(\n\ndata_param\030k \001(\0132\024.caffe."
|
||||
"DataParameter\022@\n\026detection_output_param\030"
|
||||
"\223\001 \001(\0132\037.caffe.DetectionOutputParameter\022"
|
||||
".\n\rdropout_param\030l \001(\0132\027.caffe.DropoutPa"
|
||||
"rameter\0223\n\020dummy_data_param\030m \001(\0132\031.caff"
|
||||
"e.DummyDataParameter\022.\n\reltwise_param\030n "
|
||||
"\001(\0132\027.caffe.EltwiseParameter\022\'\n\telu_para"
|
||||
"m\030\214\001 \001(\0132\023.caffe.ELUParameter\022+\n\013embed_p"
|
||||
"aram\030\211\001 \001(\0132\025.caffe.EmbedParameter\022&\n\tex"
|
||||
"p_param\030o \001(\0132\023.caffe.ExpParameter\022/\n\rfl"
|
||||
"atten_param\030\207\001 \001(\0132\027.caffe.FlattenParame"
|
||||
"ter\0221\n\017hdf5_data_param\030p \001(\0132\030.caffe.HDF"
|
||||
"5DataParameter\0225\n\021hdf5_output_param\030q \001("
|
||||
"\0132\032.caffe.HDF5OutputParameter\0223\n\020hinge_l"
|
||||
"oss_param\030r \001(\0132\031.caffe.HingeLossParamet"
|
||||
"er\0223\n\020image_data_param\030s \001(\0132\031.caffe.Ima"
|
||||
"geDataParameter\0229\n\023infogain_loss_param\030t"
|
||||
" \001(\0132\034.caffe.InfogainLossParameter\0229\n\023in"
|
||||
"ner_product_param\030u \001(\0132\034.caffe.InnerPro"
|
||||
"ductParameter\022+\n\013input_param\030\217\001 \001(\0132\025.ca"
|
||||
"ffe.InputParameter\022\'\n\tlog_param\030\206\001 \001(\0132\023"
|
||||
".caffe.LogParameter\022&\n\tlrn_param\030v \001(\0132\023"
|
||||
".caffe.LRNParameter\0225\n\021memory_data_param"
|
||||
"\030w \001(\0132\032.caffe.MemoryDataParameter\022&\n\tmv"
|
||||
"n_param\030x \001(\0132\023.caffe.MVNParameter\0222\n\nno"
|
||||
"rm_param\030\225\001 \001(\0132\035.caffe.NormalizeBBoxPar"
|
||||
"ameter\022/\n\rpermute_param\030\224\001 \001(\0132\027.caffe.P"
|
||||
"ermuteParameter\0223\n\017parameter_param\030\221\001 \001("
|
||||
"\0132\031.caffe.ParameterParameter\022.\n\rpooling_"
|
||||
"param\030y \001(\0132\027.caffe.PoolingParameter\022*\n\013"
|
||||
"power_param\030z \001(\0132\025.caffe.PowerParameter"
|
||||
"\022+\n\013prelu_param\030\203\001 \001(\0132\025.caffe.PReLUPara"
|
||||
"meter\0222\n\017prior_box_param\030\226\001 \001(\0132\030.caffe."
|
||||
"PriorBoxParameter\022-\n\014python_param\030\202\001 \001(\013"
|
||||
"2\026.caffe.PythonParameter\0223\n\017recurrent_pa"
|
||||
"ram\030\222\001 \001(\0132\031.caffe.RecurrentParameter\0223\n"
|
||||
"\017reduction_param\030\210\001 \001(\0132\031.caffe.Reductio"
|
||||
"nParameter\022(\n\nrelu_param\030{ \001(\0132\024.caffe.R"
|
||||
"eLUParameter\022/\n\rreshape_param\030\205\001 \001(\0132\027.c"
|
||||
"affe.ReshapeParameter\022+\n\013scale_param\030\216\001 "
|
||||
"\001(\0132\025.caffe.ScaleParameter\022.\n\rsigmoid_pa"
|
||||
"ram\030| \001(\0132\027.caffe.SigmoidParameter\022.\n\rso"
|
||||
"ftmax_param\030} \001(\0132\027.caffe.SoftmaxParamet"
|
||||
"er\022\'\n\tspp_param\030\204\001 \001(\0132\023.caffe.SPPParame"
|
||||
"ter\022*\n\013slice_param\030~ \001(\0132\025.caffe.SlicePa"
|
||||
"rameter\022(\n\ntanh_param\030\177 \001(\0132\024.caffe.TanH"
|
||||
"Parameter\0223\n\017threshold_param\030\200\001 \001(\0132\031.ca"
|
||||
"ffe.ThresholdParameter\022)\n\ntile_param\030\212\001 "
|
||||
"\001(\0132\024.caffe.TileParameter\0226\n\021window_data"
|
||||
"_param\030\201\001 \001(\0132\032.caffe.WindowDataParamete"
|
||||
"r\"\266\001\n\027TransformationParameter\022\020\n\005scale\030\001"
|
||||
" \001(\002:\0011\022\025\n\006mirror\030\002 \001(\010:\005false\022\024\n\tcrop_s"
|
||||
"ize\030\003 \001(\r:\0010\022\021\n\tmean_file\030\004 \001(\t\022\022\n\nmean_"
|
||||
"value\030\005 \003(\002\022\032\n\013force_color\030\006 \001(\010:\005false\022"
|
||||
"\031\n\nforce_gray\030\007 \001(\010:\005false\"\302\001\n\rLossParam"
|
||||
"eter\022\024\n\014ignore_label\030\001 \001(\005\022D\n\rnormalizat"
|
||||
"ion\030\003 \001(\0162&.caffe.LossParameter.Normaliz"
|
||||
"ationMode:\005VALID\022\021\n\tnormalize\030\002 \001(\010\"B\n\021N"
|
||||
"ormalizationMode\022\010\n\004FULL\020\000\022\t\n\005VALID\020\001\022\016\n"
|
||||
"\nBATCH_SIZE\020\002\022\010\n\004NONE\020\003\"L\n\021AccuracyParam"
|
||||
"eter\022\020\n\005top_k\030\001 \001(\r:\0011\022\017\n\004axis\030\002 \001(\005:\0011\022"
|
||||
"\024\n\014ignore_label\030\003 \001(\005\"M\n\017ArgMaxParameter"
|
||||
"\022\032\n\013out_max_val\030\001 \001(\010:\005false\022\020\n\005top_k\030\002 "
|
||||
"\001(\r:\0011\022\014\n\004axis\030\003 \001(\005\"9\n\017ConcatParameter\022"
|
||||
"\017\n\004axis\030\002 \001(\005:\0011\022\025\n\nconcat_dim\030\001 \001(\r:\0011\""
|
||||
"j\n\022BatchNormParameter\022\030\n\020use_global_stat"
|
||||
"s\030\001 \001(\010\022&\n\027moving_average_fraction\030\002 \001(\002"
|
||||
":\0050.999\022\022\n\003eps\030\003 \001(\002:\0051e-05\"]\n\rBiasParam"
|
||||
"eter\022\017\n\004axis\030\001 \001(\005:\0011\022\023\n\010num_axes\030\002 \001(\005:"
|
||||
"\0011\022&\n\006filler\030\003 \001(\0132\026.caffe.FillerParamet"
|
||||
"er\"L\n\030ContrastiveLossParameter\022\021\n\006margin"
|
||||
"\030\001 \001(\002:\0011\022\035\n\016legacy_version\030\002 \001(\010:\005false"
|
||||
"\"\374\003\n\024ConvolutionParameter\022\022\n\nnum_output\030"
|
||||
"\001 \001(\r\022\027\n\tbias_term\030\002 \001(\010:\004true\022\013\n\003pad\030\003 "
|
||||
"\003(\r\022\023\n\013kernel_size\030\004 \003(\r\022\016\n\006stride\030\006 \003(\r"
|
||||
"\022\020\n\010dilation\030\022 \003(\r\022\020\n\005pad_h\030\t \001(\r:\0010\022\020\n\005"
|
||||
"pad_w\030\n \001(\r:\0010\022\020\n\010kernel_h\030\013 \001(\r\022\020\n\010kern"
|
||||
"el_w\030\014 \001(\r\022\020\n\010stride_h\030\r \001(\r\022\020\n\010stride_w"
|
||||
"\030\016 \001(\r\022\020\n\005group\030\005 \001(\r:\0011\022-\n\rweight_fille"
|
||||
"r\030\007 \001(\0132\026.caffe.FillerParameter\022+\n\013bias_"
|
||||
"filler\030\010 \001(\0132\026.caffe.FillerParameter\022;\n\006"
|
||||
"engine\030\017 \001(\0162\".caffe.ConvolutionParamete"
|
||||
"r.Engine:\007DEFAULT\022\017\n\004axis\030\020 \001(\005:\0011\022\036\n\017fo"
|
||||
"rce_nd_im2col\030\021 \001(\010:\005false\"+\n\006Engine\022\013\n\007"
|
||||
"DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"0\n\rCropP"
|
||||
"arameter\022\017\n\004axis\030\001 \001(\005:\0012\022\016\n\006offset\030\002 \003("
|
||||
"\r\"\244\002\n\rDataParameter\022\016\n\006source\030\001 \001(\t\022\022\n\nb"
|
||||
"atch_size\030\004 \001(\r\022\024\n\trand_skip\030\007 \001(\r:\0010\0221\n"
|
||||
"\007backend\030\010 \001(\0162\027.caffe.DataParameter.DB:"
|
||||
"\007LEVELDB\022\020\n\005scale\030\002 \001(\002:\0011\022\021\n\tmean_file\030"
|
||||
"\003 \001(\t\022\024\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006mirror\030\006 "
|
||||
"\001(\010:\005false\022\"\n\023force_encoded_color\030\t \001(\010:"
|
||||
"\005false\022\023\n\010prefetch\030\n \001(\r:\0014\"\033\n\002DB\022\013\n\007LEV"
|
||||
"ELDB\020\000\022\010\n\004LMDB\020\001\"[\n\036NonMaximumSuppressio"
|
||||
"nParameter\022\032\n\rnms_threshold\030\001 \001(\002:\0030.3\022\r"
|
||||
"\n\005top_k\030\002 \001(\005\022\016\n\003eta\030\003 \001(\002:\0011\"\252\001\n\023SaveOu"
|
||||
"tputParameter\022\030\n\020output_directory\030\001 \001(\t\022"
|
||||
"\032\n\022output_name_prefix\030\002 \001(\t\022\025\n\routput_fo"
|
||||
"rmat\030\003 \001(\t\022\026\n\016label_map_file\030\004 \001(\t\022\026\n\016na"
|
||||
"me_size_file\030\005 \001(\t\022\026\n\016num_test_image\030\006 \001"
|
||||
"(\r\".\n\020DropoutParameter\022\032\n\rdropout_ratio\030"
|
||||
"\001 \001(\002:\0030.5\"\240\001\n\022DummyDataParameter\022+\n\013dat"
|
||||
"a_filler\030\001 \003(\0132\026.caffe.FillerParameter\022\037"
|
||||
"\n\005shape\030\006 \003(\0132\020.caffe.BlobShape\022\013\n\003num\030\002"
|
||||
" \003(\r\022\020\n\010channels\030\003 \003(\r\022\016\n\006height\030\004 \003(\r\022\r"
|
||||
"\n\005width\030\005 \003(\r\"\245\001\n\020EltwiseParameter\0229\n\top"
|
||||
"eration\030\001 \001(\0162!.caffe.EltwiseParameter.E"
|
||||
"ltwiseOp:\003SUM\022\r\n\005coeff\030\002 \003(\002\022\036\n\020stable_p"
|
||||
"rod_grad\030\003 \001(\010:\004true\"\'\n\tEltwiseOp\022\010\n\004PRO"
|
||||
"D\020\000\022\007\n\003SUM\020\001\022\007\n\003MAX\020\002\" \n\014ELUParameter\022\020\n"
|
||||
"\005alpha\030\001 \001(\002:\0011\"\254\001\n\016EmbedParameter\022\022\n\nnu"
|
||||
"m_output\030\001 \001(\r\022\021\n\tinput_dim\030\002 \001(\r\022\027\n\tbia"
|
||||
"s_term\030\003 \001(\010:\004true\022-\n\rweight_filler\030\004 \001("
|
||||
"\0132\026.caffe.FillerParameter\022+\n\013bias_filler"
|
||||
"\030\005 \001(\0132\026.caffe.FillerParameter\"D\n\014ExpPar"
|
||||
"ameter\022\020\n\004base\030\001 \001(\002:\002-1\022\020\n\005scale\030\002 \001(\002:"
|
||||
"\0011\022\020\n\005shift\030\003 \001(\002:\0010\"9\n\020FlattenParameter"
|
||||
"\022\017\n\004axis\030\001 \001(\005:\0011\022\024\n\010end_axis\030\002 \001(\005:\002-1\""
|
||||
"O\n\021HDF5DataParameter\022\016\n\006source\030\001 \001(\t\022\022\n\n"
|
||||
"batch_size\030\002 \001(\r\022\026\n\007shuffle\030\003 \001(\010:\005false"
|
||||
"\"(\n\023HDF5OutputParameter\022\021\n\tfile_name\030\001 \001"
|
||||
"(\t\"^\n\022HingeLossParameter\0220\n\004norm\030\001 \001(\0162\036"
|
||||
".caffe.HingeLossParameter.Norm:\002L1\"\026\n\004No"
|
||||
"rm\022\006\n\002L1\020\001\022\006\n\002L2\020\002\"\227\002\n\022ImageDataParamete"
|
||||
"r\022\016\n\006source\030\001 \001(\t\022\025\n\nbatch_size\030\004 \001(\r:\0011"
|
||||
"\022\024\n\trand_skip\030\007 \001(\r:\0010\022\026\n\007shuffle\030\010 \001(\010:"
|
||||
"\005false\022\025\n\nnew_height\030\t \001(\r:\0010\022\024\n\tnew_wid"
|
||||
"th\030\n \001(\r:\0010\022\026\n\010is_color\030\013 \001(\010:\004true\022\020\n\005s"
|
||||
"cale\030\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001(\t\022\024\n\tcrop"
|
||||
"_size\030\005 \001(\r:\0010\022\025\n\006mirror\030\006 \001(\010:\005false\022\025\n"
|
||||
"\013root_folder\030\014 \001(\t:\000\"\'\n\025InfogainLossPara"
|
||||
"meter\022\016\n\006source\030\001 \001(\t\"\313\001\n\025InnerProductPa"
|
||||
"rameter\022\022\n\nnum_output\030\001 \001(\r\022\027\n\tbias_term"
|
||||
"\030\002 \001(\010:\004true\022-\n\rweight_filler\030\003 \001(\0132\026.ca"
|
||||
"ffe.FillerParameter\022+\n\013bias_filler\030\004 \001(\013"
|
||||
"2\026.caffe.FillerParameter\022\017\n\004axis\030\005 \001(\005:\001"
|
||||
"1\022\030\n\ttranspose\030\006 \001(\010:\005false\"1\n\016InputPara"
|
||||
"meter\022\037\n\005shape\030\001 \003(\0132\020.caffe.BlobShape\"D"
|
||||
"\n\014LogParameter\022\020\n\004base\030\001 \001(\002:\002-1\022\020\n\005scal"
|
||||
"e\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001(\002:\0010\"\270\002\n\014LRNPara"
|
||||
"meter\022\025\n\nlocal_size\030\001 \001(\r:\0015\022\020\n\005alpha\030\002 "
|
||||
"\001(\002:\0011\022\022\n\004beta\030\003 \001(\002:\0040.75\022D\n\013norm_regio"
|
||||
"n\030\004 \001(\0162\036.caffe.LRNParameter.NormRegion:"
|
||||
"\017ACROSS_CHANNELS\022\014\n\001k\030\005 \001(\002:\0011\0223\n\006engine"
|
||||
"\030\006 \001(\0162\032.caffe.LRNParameter.Engine:\007DEFA"
|
||||
"ULT\"5\n\nNormRegion\022\023\n\017ACROSS_CHANNELS\020\000\022\022"
|
||||
"\n\016WITHIN_CHANNEL\020\001\"+\n\006Engine\022\013\n\007DEFAULT\020"
|
||||
"\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"Z\n\023MemoryDataPar"
|
||||
"ameter\022\022\n\nbatch_size\030\001 \001(\r\022\020\n\010channels\030\002"
|
||||
" \001(\r\022\016\n\006height\030\003 \001(\r\022\r\n\005width\030\004 \001(\r\"d\n\014M"
|
||||
"VNParameter\022 \n\022normalize_variance\030\001 \001(\010:"
|
||||
"\004true\022\036\n\017across_channels\030\002 \001(\010:\005false\022\022\n"
|
||||
"\003eps\030\003 \001(\002:\0051e-09\"5\n\022ParameterParameter\022"
|
||||
"\037\n\005shape\030\001 \001(\0132\020.caffe.BlobShape\"\242\003\n\020Poo"
|
||||
"lingParameter\0225\n\004pool\030\001 \001(\0162\".caffe.Pool"
|
||||
"ingParameter.PoolMethod:\003MAX\022\016\n\003pad\030\004 \001("
|
||||
"\r:\0010\022\020\n\005pad_h\030\t \001(\r:\0010\022\020\n\005pad_w\030\n \001(\r:\0010"
|
||||
"\022\023\n\013kernel_size\030\002 \001(\r\022\020\n\010kernel_h\030\005 \001(\r\022"
|
||||
"\020\n\010kernel_w\030\006 \001(\r\022\021\n\006stride\030\003 \001(\r:\0011\022\020\n\010"
|
||||
"stride_h\030\007 \001(\r\022\020\n\010stride_w\030\010 \001(\r\0227\n\006engi"
|
||||
"ne\030\013 \001(\0162\036.caffe.PoolingParameter.Engine"
|
||||
":\007DEFAULT\022\035\n\016global_pooling\030\014 \001(\010:\005false"
|
||||
"\".\n\nPoolMethod\022\007\n\003MAX\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOC"
|
||||
"HASTIC\020\002\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE"
|
||||
"\020\001\022\t\n\005CUDNN\020\002\"F\n\016PowerParameter\022\020\n\005power"
|
||||
"\030\001 \001(\002:\0011\022\020\n\005scale\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001"
|
||||
"(\002:\0010\"g\n\017PythonParameter\022\016\n\006module\030\001 \001(\t"
|
||||
"\022\r\n\005layer\030\002 \001(\t\022\023\n\tparam_str\030\003 \001(\t:\000\022 \n\021"
|
||||
"share_in_parallel\030\004 \001(\010:\005false\"\300\001\n\022Recur"
|
||||
"rentParameter\022\025\n\nnum_output\030\001 \001(\r:\0010\022-\n\r"
|
||||
"weight_filler\030\002 \001(\0132\026.caffe.FillerParame"
|
||||
"ter\022+\n\013bias_filler\030\003 \001(\0132\026.caffe.FillerP"
|
||||
"arameter\022\031\n\ndebug_info\030\004 \001(\010:\005false\022\034\n\re"
|
||||
"xpose_hidden\030\005 \001(\010:\005false\"\255\001\n\022ReductionP"
|
||||
"arameter\022=\n\toperation\030\001 \001(\0162%.caffe.Redu"
|
||||
"ctionParameter.ReductionOp:\003SUM\022\017\n\004axis\030"
|
||||
"\002 \001(\005:\0010\022\020\n\005coeff\030\003 \001(\002:\0011\"5\n\013ReductionO"
|
||||
"p\022\007\n\003SUM\020\001\022\010\n\004ASUM\020\002\022\t\n\005SUMSQ\020\003\022\010\n\004MEAN\020"
|
||||
"\004\"\215\001\n\rReLUParameter\022\031\n\016negative_slope\030\001 "
|
||||
"\001(\002:\0010\0224\n\006engine\030\002 \001(\0162\033.caffe.ReLUParam"
|
||||
"eter.Engine:\007DEFAULT\"+\n\006Engine\022\013\n\007DEFAUL"
|
||||
"T\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"Z\n\020ReshapePara"
|
||||
"meter\022\037\n\005shape\030\001 \001(\0132\020.caffe.BlobShape\022\017"
|
||||
"\n\004axis\030\002 \001(\005:\0010\022\024\n\010num_axes\030\003 \001(\005:\002-1\"\245\001"
|
||||
"\n\016ScaleParameter\022\017\n\004axis\030\001 \001(\005:\0011\022\023\n\010num"
|
||||
"_axes\030\002 \001(\005:\0011\022&\n\006filler\030\003 \001(\0132\026.caffe.F"
|
||||
"illerParameter\022\030\n\tbias_term\030\004 \001(\010:\005false"
|
||||
"\022+\n\013bias_filler\030\005 \001(\0132\026.caffe.FillerPara"
|
||||
"meter\"x\n\020SigmoidParameter\0227\n\006engine\030\001 \001("
|
||||
"\0162\036.caffe.SigmoidParameter.Engine:\007DEFAU"
|
||||
"LT\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005"
|
||||
"CUDNN\020\002\"L\n\016SliceParameter\022\017\n\004axis\030\003 \001(\005:"
|
||||
"\0011\022\023\n\013slice_point\030\002 \003(\r\022\024\n\tslice_dim\030\001 \001"
|
||||
"(\r:\0011\"\211\001\n\020SoftmaxParameter\0227\n\006engine\030\001 \001"
|
||||
"(\0162\036.caffe.SoftmaxParameter.Engine:\007DEFA"
|
||||
"ULT\022\017\n\004axis\030\002 \001(\005:\0011\"+\n\006Engine\022\013\n\007DEFAUL"
|
||||
"T\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"r\n\rTanHParamet"
|
||||
"er\0224\n\006engine\030\001 \001(\0162\033.caffe.TanHParameter"
|
||||
".Engine:\007DEFAULT\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022"
|
||||
"\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"/\n\rTileParameter\022\017"
|
||||
"\n\004axis\030\001 \001(\005:\0011\022\r\n\005tiles\030\002 \001(\005\"*\n\022Thresh"
|
||||
"oldParameter\022\024\n\tthreshold\030\001 \001(\002:\0010\"\301\002\n\023W"
|
||||
"indowDataParameter\022\016\n\006source\030\001 \001(\t\022\020\n\005sc"
|
||||
"ale\030\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001(\t\022\022\n\nbatch"
|
||||
"_size\030\004 \001(\r\022\024\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006mir"
|
||||
"ror\030\006 \001(\010:\005false\022\031\n\014fg_threshold\030\007 \001(\002:\003"
|
||||
"0.5\022\031\n\014bg_threshold\030\010 \001(\002:\0030.5\022\031\n\013fg_fra"
|
||||
"ction\030\t \001(\002:\0040.25\022\026\n\013context_pad\030\n \001(\r:\001"
|
||||
"0\022\027\n\tcrop_mode\030\013 \001(\t:\004warp\022\033\n\014cache_imag"
|
||||
"es\030\014 \001(\010:\005false\022\025\n\013root_folder\030\r \001(\t:\000\"\353"
|
||||
"\001\n\014SPPParameter\022\026\n\016pyramid_height\030\001 \001(\r\022"
|
||||
"1\n\004pool\030\002 \001(\0162\036.caffe.SPPParameter.PoolM"
|
||||
"ethod:\003MAX\0223\n\006engine\030\006 \001(\0162\032.caffe.SPPPa"
|
||||
"rameter.Engine:\007DEFAULT\".\n\nPoolMethod\022\007\n"
|
||||
"\003MAX\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"+\n\006Engin"
|
||||
"e\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"\340\023\n"
|
||||
"\020V1LayerParameter\022\016\n\006bottom\030\002 \003(\t\022\013\n\003top"
|
||||
"\030\003 \003(\t\022\014\n\004name\030\004 \001(\t\022$\n\007include\030 \003(\0132\023."
|
||||
"caffe.NetStateRule\022$\n\007exclude\030! \003(\0132\023.ca"
|
||||
"ffe.NetStateRule\022/\n\004type\030\005 \001(\0162!.caffe.V"
|
||||
"1LayerParameter.LayerType\022\037\n\005blobs\030\006 \003(\013"
|
||||
"2\020.caffe.BlobProto\022\016\n\005param\030\351\007 \003(\t\022>\n\017bl"
|
||||
"ob_share_mode\030\352\007 \003(\0162$.caffe.V1LayerPara"
|
||||
"meter.DimCheckMode\022\020\n\010blobs_lr\030\007 \003(\002\022\024\n\014"
|
||||
"weight_decay\030\010 \003(\002\022\023\n\013loss_weight\030# \003(\002\022"
|
||||
"0\n\016accuracy_param\030\033 \001(\0132\030.caffe.Accuracy"
|
||||
"Parameter\022,\n\014argmax_param\030\027 \001(\0132\026.caffe."
|
||||
"ArgMaxParameter\022,\n\014concat_param\030\t \001(\0132\026."
|
||||
"caffe.ConcatParameter\022\?\n\026contrastive_los"
|
||||
"s_param\030( \001(\0132\037.caffe.ContrastiveLossPar"
|
||||
"ameter\0226\n\021convolution_param\030\n \001(\0132\033.caff"
|
||||
"e.ConvolutionParameter\022(\n\ndata_param\030\013 \001"
|
||||
"(\0132\024.caffe.DataParameter\022.\n\rdropout_para"
|
||||
"m\030\014 \001(\0132\027.caffe.DropoutParameter\0223\n\020dumm"
|
||||
"y_data_param\030\032 \001(\0132\031.caffe.DummyDataPara"
|
||||
"meter\022.\n\reltwise_param\030\030 \001(\0132\027.caffe.Elt"
|
||||
"wiseParameter\022&\n\texp_param\030) \001(\0132\023.caffe"
|
||||
".ExpParameter\0221\n\017hdf5_data_param\030\r \001(\0132\030"
|
||||
".caffe.HDF5DataParameter\0225\n\021hdf5_output_"
|
||||
"param\030\016 \001(\0132\032.caffe.HDF5OutputParameter\022"
|
||||
"3\n\020hinge_loss_param\030\035 \001(\0132\031.caffe.HingeL"
|
||||
"ossParameter\0223\n\020image_data_param\030\017 \001(\0132\031"
|
||||
".caffe.ImageDataParameter\0229\n\023infogain_lo"
|
||||
"ss_param\030\020 \001(\0132\034.caffe.InfogainLossParam"
|
||||
"eter\0229\n\023inner_product_param\030\021 \001(\0132\034.caff"
|
||||
"e.InnerProductParameter\022&\n\tlrn_param\030\022 \001"
|
||||
"(\0132\023.caffe.LRNParameter\0225\n\021memory_data_p"
|
||||
"aram\030\026 \001(\0132\032.caffe.MemoryDataParameter\022&"
|
||||
"\n\tmvn_param\030\" \001(\0132\023.caffe.MVNParameter\022."
|
||||
"\n\rpooling_param\030\023 \001(\0132\027.caffe.PoolingPar"
|
||||
"ameter\022*\n\013power_param\030\025 \001(\0132\025.caffe.Powe"
|
||||
"rParameter\022(\n\nrelu_param\030\036 \001(\0132\024.caffe.R"
|
||||
"eLUParameter\022.\n\rsigmoid_param\030& \001(\0132\027.ca"
|
||||
"ffe.SigmoidParameter\022.\n\rsoftmax_param\030\' "
|
||||
"\001(\0132\027.caffe.SoftmaxParameter\022*\n\013slice_pa"
|
||||
"ram\030\037 \001(\0132\025.caffe.SliceParameter\022(\n\ntanh"
|
||||
"_param\030% \001(\0132\024.caffe.TanHParameter\0222\n\017th"
|
||||
"reshold_param\030\031 \001(\0132\031.caffe.ThresholdPar"
|
||||
"ameter\0225\n\021window_data_param\030\024 \001(\0132\032.caff"
|
||||
"e.WindowDataParameter\0227\n\017transform_param"
|
||||
"\030$ \001(\0132\036.caffe.TransformationParameter\022("
|
||||
"\n\nloss_param\030* \001(\0132\024.caffe.LossParameter"
|
||||
"\022&\n\005layer\030\001 \001(\0132\027.caffe.V0LayerParameter"
|
||||
"\"\330\004\n\tLayerType\022\010\n\004NONE\020\000\022\n\n\006ABSVAL\020#\022\014\n\010"
|
||||
"ACCURACY\020\001\022\n\n\006ARGMAX\020\036\022\010\n\004BNLL\020\002\022\n\n\006CONC"
|
||||
"AT\020\003\022\024\n\020CONTRASTIVE_LOSS\020%\022\017\n\013CONVOLUTIO"
|
||||
"N\020\004\022\010\n\004DATA\020\005\022\021\n\rDECONVOLUTION\020\'\022\013\n\007DROP"
|
||||
"OUT\020\006\022\016\n\nDUMMY_DATA\020 \022\022\n\016EUCLIDEAN_LOSS\020"
|
||||
"\007\022\013\n\007ELTWISE\020\031\022\007\n\003EXP\020&\022\013\n\007FLATTEN\020\010\022\r\n\t"
|
||||
"HDF5_DATA\020\t\022\017\n\013HDF5_OUTPUT\020\n\022\016\n\nHINGE_LO"
|
||||
"SS\020\034\022\n\n\006IM2COL\020\013\022\016\n\nIMAGE_DATA\020\014\022\021\n\rINFO"
|
||||
"GAIN_LOSS\020\r\022\021\n\rINNER_PRODUCT\020\016\022\007\n\003LRN\020\017\022"
|
||||
"\017\n\013MEMORY_DATA\020\035\022\035\n\031MULTINOMIAL_LOGISTIC"
|
||||
"_LOSS\020\020\022\007\n\003MVN\020\"\022\013\n\007POOLING\020\021\022\t\n\005POWER\020\032"
|
||||
"\022\010\n\004RELU\020\022\022\013\n\007SIGMOID\020\023\022\036\n\032SIGMOID_CROSS"
|
||||
"_ENTROPY_LOSS\020\033\022\013\n\007SILENCE\020$\022\013\n\007SOFTMAX\020"
|
||||
"\024\022\020\n\014SOFTMAX_LOSS\020\025\022\t\n\005SPLIT\020\026\022\t\n\005SLICE\020"
|
||||
"!\022\010\n\004TANH\020\027\022\017\n\013WINDOW_DATA\020\030\022\r\n\tTHRESHOL"
|
||||
"D\020\037\"*\n\014DimCheckMode\022\n\n\006STRICT\020\000\022\016\n\nPERMI"
|
||||
"SSIVE\020\001\"\375\007\n\020V0LayerParameter\022\014\n\004name\030\001 \001"
|
||||
"(\t\022\014\n\004type\030\002 \001(\t\022\022\n\nnum_output\030\003 \001(\r\022\026\n\010"
|
||||
"biasterm\030\004 \001(\010:\004true\022-\n\rweight_filler\030\005 "
|
||||
"\001(\002:\0030.5\022\"\n\023additional_y_offset\030\016 \001(\010:\005f"
|
||||
"alse\"\'\n\010CodeType\022\n\n\006CORNER\020\001\022\017\n\013CENTER_S"
|
||||
"IZE\020\002\"\375\002\n\030DetectionOutputParameter\022\023\n\013nu"
|
||||
"m_classes\030\001 \001(\r\022\034\n\016share_location\030\002 \001(\010:"
|
||||
"\004true\022\036\n\023background_label_id\030\003 \001(\005:\0010\0228\n"
|
||||
"\tnms_param\030\004 \001(\0132%.caffe.NonMaximumSuppr"
|
||||
"essionParameter\0225\n\021save_output_param\030\005 \001"
|
||||
"(\0132\032.caffe.SaveOutputParameter\022<\n\tcode_t"
|
||||
"ype\030\006 \001(\0162!.caffe.PriorBoxParameter.Code"
|
||||
"Type:\006CORNER\022)\n\032variance_encoded_in_targ"
|
||||
"et\030\010 \001(\010:\005false\022\026\n\nkeep_top_k\030\007 \001(\005:\002-1\022"
|
||||
"\034\n\024confidence_threshold\030\t \001(\002\"\201\001\n\005Datum\022"
|
||||
"\020\n\010channels\030\001 \001(\005\022\016\n\006height\030\002 \001(\005\022\r\n\005wid"
|
||||
"th\030\003 \001(\005\022\014\n\004data\030\004 \001(\014\022\r\n\005label\030\005 \001(\005\022\022\n"
|
||||
"\nfloat_data\030\006 \003(\002\022\026\n\007encoded\030\007 \001(\010:\005fals"
|
||||
"e\"\212\002\n\017FillerParameter\022\026\n\004type\030\001 \001(\t:\010con"
|
||||
"stant\022\020\n\005value\030\002 \001(\002:\0010\022\016\n\003min\030\003 \001(\002:\0010\022"
|
||||
"\016\n\003max\030\004 \001(\002:\0011\022\017\n\004mean\030\005 \001(\002:\0010\022\016\n\003std\030"
|
||||
"\006 \001(\002:\0011\022\022\n\006sparse\030\007 \001(\005:\002-1\022B\n\rvariance"
|
||||
"_norm\030\010 \001(\0162#.caffe.FillerParameter.Vari"
|
||||
"anceNorm:\006FAN_IN\"4\n\014VarianceNorm\022\n\n\006FAN_"
|
||||
"IN\020\000\022\013\n\007FAN_OUT\020\001\022\013\n\007AVERAGE\020\002\"\216\002\n\014NetPa"
|
||||
"rameter\022\014\n\004name\030\001 \001(\t\022\r\n\005input\030\003 \003(\t\022%\n\013"
|
||||
"input_shape\030\010 \003(\0132\020.caffe.BlobShape\022\021\n\ti"
|
||||
"nput_dim\030\004 \003(\005\022\035\n\016force_backward\030\005 \001(\010:\005"
|
||||
"false\022\036\n\005state\030\006 \001(\0132\017.caffe.NetState\022\031\n"
|
||||
"\ndebug_info\030\007 \001(\010:\005false\022$\n\005layer\030d \003(\0132"
|
||||
"\025.caffe.LayerParameter\022\'\n\006layers\030\002 \003(\0132\027"
|
||||
".caffe.V1LayerParameter\"\242\n\n\017SolverParame"
|
||||
"ter\022\013\n\003net\030\030 \001(\t\022&\n\tnet_param\030\031 \001(\0132\023.ca"
|
||||
"ffe.NetParameter\022\021\n\ttrain_net\030\001 \001(\t\022\020\n\010t"
|
||||
"est_net\030\002 \003(\t\022,\n\017train_net_param\030\025 \001(\0132\023"
|
||||
".caffe.NetParameter\022+\n\016test_net_param\030\026 "
|
||||
"\003(\0132\023.caffe.NetParameter\022$\n\013train_state\030"
|
||||
"\032 \001(\0132\017.caffe.NetState\022#\n\ntest_state\030\033 \003"
|
||||
"(\0132\017.caffe.NetState\022\021\n\ttest_iter\030\003 \003(\005\022\030"
|
||||
"\n\rtest_interval\030\004 \001(\005:\0010\022 \n\021test_compute"
|
||||
"_loss\030\023 \001(\010:\005false\022!\n\023test_initializatio"
|
||||
"n\030 \001(\010:\004true\022\017\n\007base_lr\030\005 \001(\002\022\017\n\007displa"
|
||||
"y\030\006 \001(\005\022\027\n\014average_loss\030! \001(\005:\0011\022\020\n\010max_"
|
||||
"iter\030\007 \001(\005\022\024\n\titer_size\030$ \001(\005:\0011\022\021\n\tlr_p"
|
||||
"olicy\030\010 \001(\t\022\r\n\005gamma\030\t \001(\002\022\r\n\005power\030\n \001("
|
||||
"\002\022\020\n\010momentum\030\013 \001(\002\022\024\n\014weight_decay\030\014 \001("
|
||||
"\002\022\037\n\023regularization_type\030\035 \001(\t:\002L2\022\020\n\010st"
|
||||
"epsize\030\r \001(\005\022\021\n\tstepvalue\030\" \003(\005\022\032\n\016clip_"
|
||||
"gradients\030# \001(\002:\002-1\022\023\n\010snapshot\030\016 \001(\005:\0010"
|
||||
"\022\027\n\017snapshot_prefix\030\017 \001(\t\022\034\n\rsnapshot_di"
|
||||
"ff\030\020 \001(\010:\005false\022K\n\017snapshot_format\030% \001(\016"
|
||||
"2%.caffe.SolverParameter.SnapshotFormat:"
|
||||
"\013BINARYPROTO\022;\n\013solver_mode\030\021 \001(\0162!.caff"
|
||||
"e.SolverParameter.SolverMode:\003GPU\022\024\n\tdev"
|
||||
"ice_id\030\022 \001(\005:\0010\022\027\n\013random_seed\030\024 \001(\003:\002-1"
|
||||
"\022\021\n\004type\030( \001(\t:\003SGD\022\024\n\005delta\030\037 \001(\002:\0051e-0"
|
||||
"8\022\030\n\tmomentum2\030\' \001(\002:\0050.999\022\027\n\trms_decay"
|
||||
"\030& \001(\002:\0040.99\022\031\n\ndebug_info\030\027 \001(\010:\005false\022"
|
||||
"\"\n\024snapshot_after_train\030\034 \001(\010:\004true\022;\n\013s"
|
||||
"olver_type\030\036 \001(\0162!.caffe.SolverParameter"
|
||||
".SolverType:\003SGD\"+\n\016SnapshotFormat\022\010\n\004HD"
|
||||
"F5\020\000\022\017\n\013BINARYPROTO\020\001\"\036\n\nSolverMode\022\007\n\003C"
|
||||
"PU\020\000\022\007\n\003GPU\020\001\"U\n\nSolverType\022\007\n\003SGD\020\000\022\014\n\010"
|
||||
"NESTEROV\020\001\022\013\n\007ADAGRAD\020\002\022\013\n\007RMSPROP\020\003\022\014\n\010"
|
||||
"ADADELTA\020\004\022\010\n\004ADAM\020\005\"l\n\013SolverState\022\014\n\004i"
|
||||
"ter\030\001 \001(\005\022\023\n\013learned_net\030\002 \001(\t\022!\n\007histor"
|
||||
"y\030\003 \003(\0132\020.caffe.BlobProto\022\027\n\014current_ste"
|
||||
"p\030\004 \001(\005:\0010\"N\n\010NetState\022!\n\005phase\030\001 \001(\0162\014."
|
||||
"caffe.Phase:\004TEST\022\020\n\005level\030\002 \001(\005:\0010\022\r\n\005s"
|
||||
"tage\030\003 \003(\t\"s\n\014NetStateRule\022\033\n\005phase\030\001 \001("
|
||||
"\0162\014.caffe.Phase\022\021\n\tmin_level\030\002 \001(\005\022\021\n\tma"
|
||||
"x_level\030\003 \001(\005\022\r\n\005stage\030\004 \003(\t\022\021\n\tnot_stag"
|
||||
"e\030\005 \003(\t\"\243\001\n\tParamSpec\022\014\n\004name\030\001 \001(\t\0221\n\ns"
|
||||
"hare_mode\030\002 \001(\0162\035.caffe.ParamSpec.DimChe"
|
||||
"ckMode\022\022\n\007lr_mult\030\003 \001(\002:\0011\022\025\n\ndecay_mult"
|
||||
"\030\004 \001(\002:\0011\"*\n\014DimCheckMode\022\n\n\006STRICT\020\000\022\016\n"
|
||||
"\nPERMISSIVE\020\001\"\335\025\n\016LayerParameter\022\014\n\004name"
|
||||
"\030\001 \001(\t\022\014\n\004type\030\002 \001(\t\022\016\n\006bottom\030\003 \003(\t\022\013\n\003"
|
||||
"top\030\004 \003(\t\022\033\n\005phase\030\n \001(\0162\014.caffe.Phase\022\023"
|
||||
"\n\013loss_weight\030\005 \003(\002\022\037\n\005param\030\006 \003(\0132\020.caf"
|
||||
"fe.ParamSpec\022\037\n\005blobs\030\007 \003(\0132\020.caffe.Blob"
|
||||
"Proto\022\026\n\016propagate_down\030\013 \003(\010\022$\n\007include"
|
||||
"\030\010 \003(\0132\023.caffe.NetStateRule\022$\n\007exclude\030\t"
|
||||
" \003(\0132\023.caffe.NetStateRule\0227\n\017transform_p"
|
||||
"aram\030d \001(\0132\036.caffe.TransformationParamet"
|
||||
"er\022(\n\nloss_param\030e \001(\0132\024.caffe.LossParam"
|
||||
"eter\0220\n\016accuracy_param\030f \001(\0132\030.caffe.Acc"
|
||||
"uracyParameter\022,\n\014argmax_param\030g \001(\0132\026.c"
|
||||
"affe.ArgMaxParameter\0224\n\020batch_norm_param"
|
||||
"\030\213\001 \001(\0132\031.caffe.BatchNormParameter\022)\n\nbi"
|
||||
"as_param\030\215\001 \001(\0132\024.caffe.BiasParameter\022,\n"
|
||||
"\014concat_param\030h \001(\0132\026.caffe.ConcatParame"
|
||||
"ter\022\?\n\026contrastive_loss_param\030i \001(\0132\037.ca"
|
||||
"ffe.ContrastiveLossParameter\0226\n\021convolut"
|
||||
"ion_param\030j \001(\0132\033.caffe.ConvolutionParam"
|
||||
"eter\022)\n\ncrop_param\030\220\001 \001(\0132\024.caffe.CropPa"
|
||||
"rameter\022(\n\ndata_param\030k \001(\0132\024.caffe.Data"
|
||||
"Parameter\022@\n\026detection_output_param\030\223\001 \001"
|
||||
"(\0132\037.caffe.DetectionOutputParameter\022.\n\rd"
|
||||
"ropout_param\030l \001(\0132\027.caffe.DropoutParame"
|
||||
"ter\0223\n\020dummy_data_param\030m \001(\0132\031.caffe.Du"
|
||||
"mmyDataParameter\022.\n\reltwise_param\030n \001(\0132"
|
||||
"\027.caffe.EltwiseParameter\022\'\n\telu_param\030\214\001"
|
||||
" \001(\0132\023.caffe.ELUParameter\022+\n\013embed_param"
|
||||
"\030\211\001 \001(\0132\025.caffe.EmbedParameter\022&\n\texp_pa"
|
||||
"ram\030o \001(\0132\023.caffe.ExpParameter\022/\n\rflatte"
|
||||
"n_param\030\207\001 \001(\0132\027.caffe.FlattenParameter\022"
|
||||
"1\n\017hdf5_data_param\030p \001(\0132\030.caffe.HDF5Dat"
|
||||
"aParameter\0225\n\021hdf5_output_param\030q \001(\0132\032."
|
||||
"caffe.HDF5OutputParameter\0223\n\020hinge_loss_"
|
||||
"param\030r \001(\0132\031.caffe.HingeLossParameter\0223"
|
||||
"\n\020image_data_param\030s \001(\0132\031.caffe.ImageDa"
|
||||
"taParameter\0229\n\023infogain_loss_param\030t \001(\013"
|
||||
"2\034.caffe.InfogainLossParameter\0229\n\023inner_"
|
||||
"product_param\030u \001(\0132\034.caffe.InnerProduct"
|
||||
"Parameter\022+\n\013input_param\030\217\001 \001(\0132\025.caffe."
|
||||
"InputParameter\022\'\n\tlog_param\030\206\001 \001(\0132\023.caf"
|
||||
"fe.LogParameter\022&\n\tlrn_param\030v \001(\0132\023.caf"
|
||||
"fe.LRNParameter\0225\n\021memory_data_param\030w \001"
|
||||
"(\0132\032.caffe.MemoryDataParameter\022&\n\tmvn_pa"
|
||||
"ram\030x \001(\0132\023.caffe.MVNParameter\0222\n\nnorm_p"
|
||||
"aram\030\225\001 \001(\0132\035.caffe.NormalizeBBoxParamet"
|
||||
"er\022/\n\rpermute_param\030\224\001 \001(\0132\027.caffe.Permu"
|
||||
"teParameter\0223\n\017parameter_param\030\221\001 \001(\0132\031."
|
||||
"caffe.ParameterParameter\022.\n\rpooling_para"
|
||||
"m\030y \001(\0132\027.caffe.PoolingParameter\022*\n\013powe"
|
||||
"r_param\030z \001(\0132\025.caffe.PowerParameter\022+\n\013"
|
||||
"prelu_param\030\203\001 \001(\0132\025.caffe.PReLUParamete"
|
||||
"r\0222\n\017prior_box_param\030\226\001 \001(\0132\030.caffe.Prio"
|
||||
"rBoxParameter\022-\n\014python_param\030\202\001 \001(\0132\026.c"
|
||||
"affe.PythonParameter\0223\n\017recurrent_param\030"
|
||||
"\222\001 \001(\0132\031.caffe.RecurrentParameter\0223\n\017red"
|
||||
"uction_param\030\210\001 \001(\0132\031.caffe.ReductionPar"
|
||||
"ameter\022(\n\nrelu_param\030{ \001(\0132\024.caffe.ReLUP"
|
||||
"arameter\022/\n\rreshape_param\030\205\001 \001(\0132\027.caffe"
|
||||
".ReshapeParameter\022+\n\013scale_param\030\216\001 \001(\0132"
|
||||
"\025.caffe.ScaleParameter\022.\n\rsigmoid_param\030"
|
||||
"| \001(\0132\027.caffe.SigmoidParameter\022.\n\rsoftma"
|
||||
"x_param\030} \001(\0132\027.caffe.SoftmaxParameter\022\'"
|
||||
"\n\tspp_param\030\204\001 \001(\0132\023.caffe.SPPParameter\022"
|
||||
"*\n\013slice_param\030~ \001(\0132\025.caffe.SliceParame"
|
||||
"ter\022(\n\ntanh_param\030\177 \001(\0132\024.caffe.TanHPara"
|
||||
"meter\0223\n\017threshold_param\030\200\001 \001(\0132\031.caffe."
|
||||
"ThresholdParameter\022)\n\ntile_param\030\212\001 \001(\0132"
|
||||
"\024.caffe.TileParameter\0226\n\021window_data_par"
|
||||
"am\030\201\001 \001(\0132\032.caffe.WindowDataParameter\"\266\001"
|
||||
"\n\027TransformationParameter\022\020\n\005scale\030\001 \001(\002"
|
||||
":\0011\022\025\n\006mirror\030\002 \001(\010:\005false\022\024\n\tcrop_size\030"
|
||||
"\003 \001(\r:\0010\022\021\n\tmean_file\030\004 \001(\t\022\022\n\nmean_valu"
|
||||
"e\030\005 \003(\002\022\032\n\013force_color\030\006 \001(\010:\005false\022\031\n\nf"
|
||||
"orce_gray\030\007 \001(\010:\005false\"\302\001\n\rLossParameter"
|
||||
"\022\024\n\014ignore_label\030\001 \001(\005\022D\n\rnormalization\030"
|
||||
"\003 \001(\0162&.caffe.LossParameter.Normalizatio"
|
||||
"nMode:\005VALID\022\021\n\tnormalize\030\002 \001(\010\"B\n\021Norma"
|
||||
"lizationMode\022\010\n\004FULL\020\000\022\t\n\005VALID\020\001\022\016\n\nBAT"
|
||||
"CH_SIZE\020\002\022\010\n\004NONE\020\003\"L\n\021AccuracyParameter"
|
||||
"\022\020\n\005top_k\030\001 \001(\r:\0011\022\017\n\004axis\030\002 \001(\005:\0011\022\024\n\014i"
|
||||
"gnore_label\030\003 \001(\005\"M\n\017ArgMaxParameter\022\032\n\013"
|
||||
"out_max_val\030\001 \001(\010:\005false\022\020\n\005top_k\030\002 \001(\r:"
|
||||
"\0011\022\014\n\004axis\030\003 \001(\005\"9\n\017ConcatParameter\022\017\n\004a"
|
||||
"xis\030\002 \001(\005:\0011\022\025\n\nconcat_dim\030\001 \001(\r:\0011\"j\n\022B"
|
||||
"atchNormParameter\022\030\n\020use_global_stats\030\001 "
|
||||
"\001(\010\022&\n\027moving_average_fraction\030\002 \001(\002:\0050."
|
||||
"999\022\022\n\003eps\030\003 \001(\002:\0051e-05\"]\n\rBiasParameter"
|
||||
"\022\017\n\004axis\030\001 \001(\005:\0011\022\023\n\010num_axes\030\002 \001(\005:\0011\022&"
|
||||
"\n\006filler\030\003 \001(\0132\026.caffe.FillerParameter\"L"
|
||||
"\n\030ContrastiveLossParameter\022\021\n\006margin\030\001 \001"
|
||||
"(\002:\0011\022\035\n\016legacy_version\030\002 \001(\010:\005false\"\374\003\n"
|
||||
"\024ConvolutionParameter\022\022\n\nnum_output\030\001 \001("
|
||||
"\r\022\027\n\tbias_term\030\002 \001(\010:\004true\022\013\n\003pad\030\003 \003(\r\022"
|
||||
"\023\n\013kernel_size\030\004 \003(\r\022\016\n\006stride\030\006 \003(\r\022\020\n\010"
|
||||
"dilation\030\022 \003(\r\022\020\n\005pad_h\030\t \001(\r:\0010\022\020\n\005pad_"
|
||||
"w\030\n \001(\r:\0010\022\020\n\010kernel_h\030\013 \001(\r\022\020\n\010kernel_w"
|
||||
"\030\014 \001(\r\022\020\n\010stride_h\030\r \001(\r\022\020\n\010stride_w\030\016 \001"
|
||||
"(\r\022\020\n\005group\030\005 \001(\r:\0011\022-\n\rweight_filler\030\007 "
|
||||
"\001(\0132\026.caffe.FillerParameter\022+\n\013bias_fill"
|
||||
"er\030\006 \001(\0132\026.caffe.FillerParameter\022\016\n\003pad\030"
|
||||
"\007 \001(\r:\0010\022\022\n\nkernelsize\030\010 \001(\r\022\020\n\005group\030\t "
|
||||
"\001(\r:\0011\022\021\n\006stride\030\n \001(\r:\0011\0225\n\004pool\030\013 \001(\0162"
|
||||
"\".caffe.V0LayerParameter.PoolMethod:\003MAX"
|
||||
"\022\032\n\rdropout_ratio\030\014 \001(\002:\0030.5\022\025\n\nlocal_si"
|
||||
"ze\030\r \001(\r:\0015\022\020\n\005alpha\030\016 \001(\002:\0011\022\022\n\004beta\030\017 "
|
||||
"\001(\002:\0040.75\022\014\n\001k\030\026 \001(\002:\0011\022\016\n\006source\030\020 \001(\t\022"
|
||||
"\020\n\005scale\030\021 \001(\002:\0011\022\020\n\010meanfile\030\022 \001(\t\022\021\n\tb"
|
||||
"atchsize\030\023 \001(\r\022\023\n\010cropsize\030\024 \001(\r:\0010\022\025\n\006m"
|
||||
"irror\030\025 \001(\010:\005false\022\037\n\005blobs\0302 \003(\0132\020.caff"
|
||||
"e.BlobProto\022\020\n\010blobs_lr\0303 \003(\002\022\024\n\014weight_"
|
||||
"decay\0304 \003(\002\022\024\n\trand_skip\0305 \001(\r:\0010\022\035\n\020det"
|
||||
"_fg_threshold\0306 \001(\002:\0030.5\022\035\n\020det_bg_thres"
|
||||
"hold\0307 \001(\002:\0030.5\022\035\n\017det_fg_fraction\0308 \001(\002"
|
||||
":\0040.25\022\032\n\017det_context_pad\030: \001(\r:\0010\022\033\n\rde"
|
||||
"t_crop_mode\030; \001(\t:\004warp\022\022\n\007new_num\030< \001(\005"
|
||||
":\0010\022\027\n\014new_channels\030= \001(\005:\0010\022\025\n\nnew_heig"
|
||||
"ht\030> \001(\005:\0010\022\024\n\tnew_width\030\? \001(\005:\0010\022\035\n\016shu"
|
||||
"ffle_images\030@ \001(\010:\005false\022\025\n\nconcat_dim\030A"
|
||||
" \001(\r:\0011\0226\n\021hdf5_output_param\030\351\007 \001(\0132\032.ca"
|
||||
"ffe.HDF5OutputParameter\".\n\nPoolMethod\022\007\n"
|
||||
"\003MAX\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"W\n\016PReLU"
|
||||
"Parameter\022&\n\006filler\030\001 \001(\0132\026.caffe.Filler"
|
||||
"Parameter\022\035\n\016channel_shared\030\002 \001(\010:\005false"
|
||||
"\"\207\001\n\016NormalizedBBox\022\014\n\004xmin\030\001 \001(\002\022\014\n\004ymi"
|
||||
"n\030\002 \001(\002\022\014\n\004xmax\030\003 \001(\002\022\014\n\004ymax\030\004 \001(\002\022\r\n\005l"
|
||||
"abel\030\005 \001(\005\022\021\n\tdifficult\030\006 \001(\010\022\r\n\005score\030\007"
|
||||
" \001(\002\022\014\n\004size\030\010 \001(\002*=\n\004Type\022\n\n\006DOUBLE\020\000\022\t"
|
||||
"\n\005FLOAT\020\001\022\013\n\007FLOAT16\020\002\022\007\n\003INT\020\003\022\010\n\004UINT\020"
|
||||
"\004*\034\n\005Phase\022\t\n\005TRAIN\020\000\022\010\n\004TEST\020\001", 16991);
|
||||
"er\030\010 \001(\0132\026.caffe.FillerParameter\022;\n\006engi"
|
||||
"ne\030\017 \001(\0162\".caffe.ConvolutionParameter.En"
|
||||
"gine:\007DEFAULT\022\017\n\004axis\030\020 \001(\005:\0011\022\036\n\017force_"
|
||||
"nd_im2col\030\021 \001(\010:\005false\"+\n\006Engine\022\013\n\007DEFA"
|
||||
"ULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"0\n\rCropParam"
|
||||
"eter\022\017\n\004axis\030\001 \001(\005:\0012\022\016\n\006offset\030\002 \003(\r\"\244\002"
|
||||
"\n\rDataParameter\022\016\n\006source\030\001 \001(\t\022\022\n\nbatch"
|
||||
"_size\030\004 \001(\r\022\024\n\trand_skip\030\007 \001(\r:\0010\0221\n\007bac"
|
||||
"kend\030\010 \001(\0162\027.caffe.DataParameter.DB:\007LEV"
|
||||
"ELDB\022\020\n\005scale\030\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001("
|
||||
"\t\022\024\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006mirror\030\006 \001(\010:"
|
||||
"\005false\022\"\n\023force_encoded_color\030\t \001(\010:\005fal"
|
||||
"se\022\023\n\010prefetch\030\n \001(\r:\0014\"\033\n\002DB\022\013\n\007LEVELDB"
|
||||
"\020\000\022\010\n\004LMDB\020\001\"[\n\036NonMaximumSuppressionPar"
|
||||
"ameter\022\032\n\rnms_threshold\030\001 \001(\002:\0030.3\022\r\n\005to"
|
||||
"p_k\030\002 \001(\005\022\016\n\003eta\030\003 \001(\002:\0011\"\252\001\n\023SaveOutput"
|
||||
"Parameter\022\030\n\020output_directory\030\001 \001(\t\022\032\n\022o"
|
||||
"utput_name_prefix\030\002 \001(\t\022\025\n\routput_format"
|
||||
"\030\003 \001(\t\022\026\n\016label_map_file\030\004 \001(\t\022\026\n\016name_s"
|
||||
"ize_file\030\005 \001(\t\022\026\n\016num_test_image\030\006 \001(\r\"."
|
||||
"\n\020DropoutParameter\022\032\n\rdropout_ratio\030\001 \001("
|
||||
"\002:\0030.5\"\240\001\n\022DummyDataParameter\022+\n\013data_fi"
|
||||
"ller\030\001 \003(\0132\026.caffe.FillerParameter\022\037\n\005sh"
|
||||
"ape\030\006 \003(\0132\020.caffe.BlobShape\022\013\n\003num\030\002 \003(\r"
|
||||
"\022\020\n\010channels\030\003 \003(\r\022\016\n\006height\030\004 \003(\r\022\r\n\005wi"
|
||||
"dth\030\005 \003(\r\"\245\001\n\020EltwiseParameter\0229\n\toperat"
|
||||
"ion\030\001 \001(\0162!.caffe.EltwiseParameter.Eltwi"
|
||||
"seOp:\003SUM\022\r\n\005coeff\030\002 \003(\002\022\036\n\020stable_prod_"
|
||||
"grad\030\003 \001(\010:\004true\"\'\n\tEltwiseOp\022\010\n\004PROD\020\000\022"
|
||||
"\007\n\003SUM\020\001\022\007\n\003MAX\020\002\" \n\014ELUParameter\022\020\n\005alp"
|
||||
"ha\030\001 \001(\002:\0011\"\254\001\n\016EmbedParameter\022\022\n\nnum_ou"
|
||||
"tput\030\001 \001(\r\022\021\n\tinput_dim\030\002 \001(\r\022\027\n\tbias_te"
|
||||
"rm\030\003 \001(\010:\004true\022-\n\rweight_filler\030\004 \001(\0132\026."
|
||||
"caffe.FillerParameter\022+\n\013bias_filler\030\005 \001"
|
||||
"(\0132\026.caffe.FillerParameter\"D\n\014ExpParamet"
|
||||
"er\022\020\n\004base\030\001 \001(\002:\002-1\022\020\n\005scale\030\002 \001(\002:\0011\022\020"
|
||||
"\n\005shift\030\003 \001(\002:\0010\"9\n\020FlattenParameter\022\017\n\004"
|
||||
"axis\030\001 \001(\005:\0011\022\024\n\010end_axis\030\002 \001(\005:\002-1\"O\n\021H"
|
||||
"DF5DataParameter\022\016\n\006source\030\001 \001(\t\022\022\n\nbatc"
|
||||
"h_size\030\002 \001(\r\022\026\n\007shuffle\030\003 \001(\010:\005false\"(\n\023"
|
||||
"HDF5OutputParameter\022\021\n\tfile_name\030\001 \001(\t\"^"
|
||||
"\n\022HingeLossParameter\0220\n\004norm\030\001 \001(\0162\036.caf"
|
||||
"fe.HingeLossParameter.Norm:\002L1\"\026\n\004Norm\022\006"
|
||||
"\n\002L1\020\001\022\006\n\002L2\020\002\"\227\002\n\022ImageDataParameter\022\016\n"
|
||||
"\006source\030\001 \001(\t\022\025\n\nbatch_size\030\004 \001(\r:\0011\022\024\n\t"
|
||||
"rand_skip\030\007 \001(\r:\0010\022\026\n\007shuffle\030\010 \001(\010:\005fal"
|
||||
"se\022\025\n\nnew_height\030\t \001(\r:\0010\022\024\n\tnew_width\030\n"
|
||||
" \001(\r:\0010\022\026\n\010is_color\030\013 \001(\010:\004true\022\020\n\005scale"
|
||||
"\030\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001(\t\022\024\n\tcrop_siz"
|
||||
"e\030\005 \001(\r:\0010\022\025\n\006mirror\030\006 \001(\010:\005false\022\025\n\013roo"
|
||||
"t_folder\030\014 \001(\t:\000\"\'\n\025InfogainLossParamete"
|
||||
"r\022\016\n\006source\030\001 \001(\t\"\313\001\n\025InnerProductParame"
|
||||
"ter\022\022\n\nnum_output\030\001 \001(\r\022\027\n\tbias_term\030\002 \001"
|
||||
"(\010:\004true\022-\n\rweight_filler\030\003 \001(\0132\026.caffe."
|
||||
"FillerParameter\022+\n\013bias_filler\030\004 \001(\0132\026.c"
|
||||
"affe.FillerParameter\022\017\n\004axis\030\005 \001(\005:\0011\022\030\n"
|
||||
"\ttranspose\030\006 \001(\010:\005false\"1\n\016InputParamete"
|
||||
"r\022\037\n\005shape\030\001 \003(\0132\020.caffe.BlobShape\"D\n\014Lo"
|
||||
"gParameter\022\020\n\004base\030\001 \001(\002:\002-1\022\020\n\005scale\030\002 "
|
||||
"\001(\002:\0011\022\020\n\005shift\030\003 \001(\002:\0010\"\270\002\n\014LRNParamete"
|
||||
"r\022\025\n\nlocal_size\030\001 \001(\r:\0015\022\020\n\005alpha\030\002 \001(\002:"
|
||||
"\0011\022\022\n\004beta\030\003 \001(\002:\0040.75\022D\n\013norm_region\030\004 "
|
||||
"\001(\0162\036.caffe.LRNParameter.NormRegion:\017ACR"
|
||||
"OSS_CHANNELS\022\014\n\001k\030\005 \001(\002:\0011\0223\n\006engine\030\006 \001"
|
||||
"(\0162\032.caffe.LRNParameter.Engine:\007DEFAULT\""
|
||||
"5\n\nNormRegion\022\023\n\017ACROSS_CHANNELS\020\000\022\022\n\016WI"
|
||||
"THIN_CHANNEL\020\001\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n"
|
||||
"\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"Z\n\023MemoryDataParamet"
|
||||
"er\022\022\n\nbatch_size\030\001 \001(\r\022\020\n\010channels\030\002 \001(\r"
|
||||
"\022\016\n\006height\030\003 \001(\r\022\r\n\005width\030\004 \001(\r\"d\n\014MVNPa"
|
||||
"rameter\022 \n\022normalize_variance\030\001 \001(\010:\004tru"
|
||||
"e\022\036\n\017across_channels\030\002 \001(\010:\005false\022\022\n\003eps"
|
||||
"\030\003 \001(\002:\0051e-09\"5\n\022ParameterParameter\022\037\n\005s"
|
||||
"hape\030\001 \001(\0132\020.caffe.BlobShape\"\242\003\n\020Pooling"
|
||||
"Parameter\0225\n\004pool\030\001 \001(\0162\".caffe.PoolingP"
|
||||
"arameter.PoolMethod:\003MAX\022\016\n\003pad\030\004 \001(\r:\0010"
|
||||
"\022\020\n\005pad_h\030\t \001(\r:\0010\022\020\n\005pad_w\030\n \001(\r:\0010\022\023\n\013"
|
||||
"kernel_size\030\002 \001(\r\022\020\n\010kernel_h\030\005 \001(\r\022\020\n\010k"
|
||||
"ernel_w\030\006 \001(\r\022\021\n\006stride\030\003 \001(\r:\0011\022\020\n\010stri"
|
||||
"de_h\030\007 \001(\r\022\020\n\010stride_w\030\010 \001(\r\0227\n\006engine\030\013"
|
||||
" \001(\0162\036.caffe.PoolingParameter.Engine:\007DE"
|
||||
"FAULT\022\035\n\016global_pooling\030\014 \001(\010:\005false\".\n\n"
|
||||
"PoolMethod\022\007\n\003MAX\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHAST"
|
||||
"IC\020\002\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t"
|
||||
"\n\005CUDNN\020\002\"F\n\016PowerParameter\022\020\n\005power\030\001 \001"
|
||||
"(\002:\0011\022\020\n\005scale\030\002 \001(\002:\0011\022\020\n\005shift\030\003 \001(\002:\001"
|
||||
"0\"g\n\017PythonParameter\022\016\n\006module\030\001 \001(\t\022\r\n\005"
|
||||
"layer\030\002 \001(\t\022\023\n\tparam_str\030\003 \001(\t:\000\022 \n\021shar"
|
||||
"e_in_parallel\030\004 \001(\010:\005false\"\300\001\n\022Recurrent"
|
||||
"Parameter\022\025\n\nnum_output\030\001 \001(\r:\0010\022-\n\rweig"
|
||||
"ht_filler\030\002 \001(\0132\026.caffe.FillerParameter\022"
|
||||
"+\n\013bias_filler\030\003 \001(\0132\026.caffe.FillerParam"
|
||||
"eter\022\031\n\ndebug_info\030\004 \001(\010:\005false\022\034\n\rexpos"
|
||||
"e_hidden\030\005 \001(\010:\005false\"\255\001\n\022ReductionParam"
|
||||
"eter\022=\n\toperation\030\001 \001(\0162%.caffe.Reductio"
|
||||
"nParameter.ReductionOp:\003SUM\022\017\n\004axis\030\002 \001("
|
||||
"\005:\0010\022\020\n\005coeff\030\003 \001(\002:\0011\"5\n\013ReductionOp\022\007\n"
|
||||
"\003SUM\020\001\022\010\n\004ASUM\020\002\022\t\n\005SUMSQ\020\003\022\010\n\004MEAN\020\004\"\215\001"
|
||||
"\n\rReLUParameter\022\031\n\016negative_slope\030\001 \001(\002:"
|
||||
"\0010\0224\n\006engine\030\002 \001(\0162\033.caffe.ReLUParameter"
|
||||
".Engine:\007DEFAULT\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022"
|
||||
"\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"Z\n\020ReshapeParamete"
|
||||
"r\022\037\n\005shape\030\001 \001(\0132\020.caffe.BlobShape\022\017\n\004ax"
|
||||
"is\030\002 \001(\005:\0010\022\024\n\010num_axes\030\003 \001(\005:\002-1\"\245\001\n\016Sc"
|
||||
"aleParameter\022\017\n\004axis\030\001 \001(\005:\0011\022\023\n\010num_axe"
|
||||
"s\030\002 \001(\005:\0011\022&\n\006filler\030\003 \001(\0132\026.caffe.Fille"
|
||||
"rParameter\022\030\n\tbias_term\030\004 \001(\010:\005false\022+\n\013"
|
||||
"bias_filler\030\005 \001(\0132\026.caffe.FillerParamete"
|
||||
"r\"x\n\020SigmoidParameter\0227\n\006engine\030\001 \001(\0162\036."
|
||||
"caffe.SigmoidParameter.Engine:\007DEFAULT\"+"
|
||||
"\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDN"
|
||||
"N\020\002\"L\n\016SliceParameter\022\017\n\004axis\030\003 \001(\005:\0011\022\023"
|
||||
"\n\013slice_point\030\002 \003(\r\022\024\n\tslice_dim\030\001 \001(\r:\001"
|
||||
"1\"\211\001\n\020SoftmaxParameter\0227\n\006engine\030\001 \001(\0162\036"
|
||||
".caffe.SoftmaxParameter.Engine:\007DEFAULT\022"
|
||||
"\017\n\004axis\030\002 \001(\005:\0011\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022"
|
||||
"\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"r\n\rTanHParameter\0224"
|
||||
"\n\006engine\030\001 \001(\0162\033.caffe.TanHParameter.Eng"
|
||||
"ine:\007DEFAULT\"+\n\006Engine\022\013\n\007DEFAULT\020\000\022\t\n\005C"
|
||||
"AFFE\020\001\022\t\n\005CUDNN\020\002\"/\n\rTileParameter\022\017\n\004ax"
|
||||
"is\030\001 \001(\005:\0011\022\r\n\005tiles\030\002 \001(\005\"*\n\022ThresholdP"
|
||||
"arameter\022\024\n\tthreshold\030\001 \001(\002:\0010\"\301\002\n\023Windo"
|
||||
"wDataParameter\022\016\n\006source\030\001 \001(\t\022\020\n\005scale\030"
|
||||
"\002 \001(\002:\0011\022\021\n\tmean_file\030\003 \001(\t\022\022\n\nbatch_siz"
|
||||
"e\030\004 \001(\r\022\024\n\tcrop_size\030\005 \001(\r:\0010\022\025\n\006mirror\030"
|
||||
"\006 \001(\010:\005false\022\031\n\014fg_threshold\030\007 \001(\002:\0030.5\022"
|
||||
"\031\n\014bg_threshold\030\010 \001(\002:\0030.5\022\031\n\013fg_fractio"
|
||||
"n\030\t \001(\002:\0040.25\022\026\n\013context_pad\030\n \001(\r:\0010\022\027\n"
|
||||
"\tcrop_mode\030\013 \001(\t:\004warp\022\033\n\014cache_images\030\014"
|
||||
" \001(\010:\005false\022\025\n\013root_folder\030\r \001(\t:\000\"\353\001\n\014S"
|
||||
"PPParameter\022\026\n\016pyramid_height\030\001 \001(\r\0221\n\004p"
|
||||
"ool\030\002 \001(\0162\036.caffe.SPPParameter.PoolMetho"
|
||||
"d:\003MAX\0223\n\006engine\030\006 \001(\0162\032.caffe.SPPParame"
|
||||
"ter.Engine:\007DEFAULT\".\n\nPoolMethod\022\007\n\003MAX"
|
||||
"\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"+\n\006Engine\022\013\n"
|
||||
"\007DEFAULT\020\000\022\t\n\005CAFFE\020\001\022\t\n\005CUDNN\020\002\"\340\023\n\020V1L"
|
||||
"ayerParameter\022\016\n\006bottom\030\002 \003(\t\022\013\n\003top\030\003 \003"
|
||||
"(\t\022\014\n\004name\030\004 \001(\t\022$\n\007include\030 \003(\0132\023.caff"
|
||||
"e.NetStateRule\022$\n\007exclude\030! \003(\0132\023.caffe."
|
||||
"NetStateRule\022/\n\004type\030\005 \001(\0162!.caffe.V1Lay"
|
||||
"erParameter.LayerType\022\037\n\005blobs\030\006 \003(\0132\020.c"
|
||||
"affe.BlobProto\022\016\n\005param\030\351\007 \003(\t\022>\n\017blob_s"
|
||||
"hare_mode\030\352\007 \003(\0162$.caffe.V1LayerParamete"
|
||||
"r.DimCheckMode\022\020\n\010blobs_lr\030\007 \003(\002\022\024\n\014weig"
|
||||
"ht_decay\030\010 \003(\002\022\023\n\013loss_weight\030# \003(\002\0220\n\016a"
|
||||
"ccuracy_param\030\033 \001(\0132\030.caffe.AccuracyPara"
|
||||
"meter\022,\n\014argmax_param\030\027 \001(\0132\026.caffe.ArgM"
|
||||
"axParameter\022,\n\014concat_param\030\t \001(\0132\026.caff"
|
||||
"e.ConcatParameter\022\?\n\026contrastive_loss_pa"
|
||||
"ram\030( \001(\0132\037.caffe.ContrastiveLossParamet"
|
||||
"er\0226\n\021convolution_param\030\n \001(\0132\033.caffe.Co"
|
||||
"nvolutionParameter\022(\n\ndata_param\030\013 \001(\0132\024"
|
||||
".caffe.DataParameter\022.\n\rdropout_param\030\014 "
|
||||
"\001(\0132\027.caffe.DropoutParameter\0223\n\020dummy_da"
|
||||
"ta_param\030\032 \001(\0132\031.caffe.DummyDataParamete"
|
||||
"r\022.\n\reltwise_param\030\030 \001(\0132\027.caffe.Eltwise"
|
||||
"Parameter\022&\n\texp_param\030) \001(\0132\023.caffe.Exp"
|
||||
"Parameter\0221\n\017hdf5_data_param\030\r \001(\0132\030.caf"
|
||||
"fe.HDF5DataParameter\0225\n\021hdf5_output_para"
|
||||
"m\030\016 \001(\0132\032.caffe.HDF5OutputParameter\0223\n\020h"
|
||||
"inge_loss_param\030\035 \001(\0132\031.caffe.HingeLossP"
|
||||
"arameter\0223\n\020image_data_param\030\017 \001(\0132\031.caf"
|
||||
"fe.ImageDataParameter\0229\n\023infogain_loss_p"
|
||||
"aram\030\020 \001(\0132\034.caffe.InfogainLossParameter"
|
||||
"\0229\n\023inner_product_param\030\021 \001(\0132\034.caffe.In"
|
||||
"nerProductParameter\022&\n\tlrn_param\030\022 \001(\0132\023"
|
||||
".caffe.LRNParameter\0225\n\021memory_data_param"
|
||||
"\030\026 \001(\0132\032.caffe.MemoryDataParameter\022&\n\tmv"
|
||||
"n_param\030\" \001(\0132\023.caffe.MVNParameter\022.\n\rpo"
|
||||
"oling_param\030\023 \001(\0132\027.caffe.PoolingParamet"
|
||||
"er\022*\n\013power_param\030\025 \001(\0132\025.caffe.PowerPar"
|
||||
"ameter\022(\n\nrelu_param\030\036 \001(\0132\024.caffe.ReLUP"
|
||||
"arameter\022.\n\rsigmoid_param\030& \001(\0132\027.caffe."
|
||||
"SigmoidParameter\022.\n\rsoftmax_param\030\' \001(\0132"
|
||||
"\027.caffe.SoftmaxParameter\022*\n\013slice_param\030"
|
||||
"\037 \001(\0132\025.caffe.SliceParameter\022(\n\ntanh_par"
|
||||
"am\030% \001(\0132\024.caffe.TanHParameter\0222\n\017thresh"
|
||||
"old_param\030\031 \001(\0132\031.caffe.ThresholdParamet"
|
||||
"er\0225\n\021window_data_param\030\024 \001(\0132\032.caffe.Wi"
|
||||
"ndowDataParameter\0227\n\017transform_param\030$ \001"
|
||||
"(\0132\036.caffe.TransformationParameter\022(\n\nlo"
|
||||
"ss_param\030* \001(\0132\024.caffe.LossParameter\022&\n\005"
|
||||
"layer\030\001 \001(\0132\027.caffe.V0LayerParameter\"\330\004\n"
|
||||
"\tLayerType\022\010\n\004NONE\020\000\022\n\n\006ABSVAL\020#\022\014\n\010ACCU"
|
||||
"RACY\020\001\022\n\n\006ARGMAX\020\036\022\010\n\004BNLL\020\002\022\n\n\006CONCAT\020\003"
|
||||
"\022\024\n\020CONTRASTIVE_LOSS\020%\022\017\n\013CONVOLUTION\020\004\022"
|
||||
"\010\n\004DATA\020\005\022\021\n\rDECONVOLUTION\020\'\022\013\n\007DROPOUT\020"
|
||||
"\006\022\016\n\nDUMMY_DATA\020 \022\022\n\016EUCLIDEAN_LOSS\020\007\022\013\n"
|
||||
"\007ELTWISE\020\031\022\007\n\003EXP\020&\022\013\n\007FLATTEN\020\010\022\r\n\tHDF5"
|
||||
"_DATA\020\t\022\017\n\013HDF5_OUTPUT\020\n\022\016\n\nHINGE_LOSS\020\034"
|
||||
"\022\n\n\006IM2COL\020\013\022\016\n\nIMAGE_DATA\020\014\022\021\n\rINFOGAIN"
|
||||
"_LOSS\020\r\022\021\n\rINNER_PRODUCT\020\016\022\007\n\003LRN\020\017\022\017\n\013M"
|
||||
"EMORY_DATA\020\035\022\035\n\031MULTINOMIAL_LOGISTIC_LOS"
|
||||
"S\020\020\022\007\n\003MVN\020\"\022\013\n\007POOLING\020\021\022\t\n\005POWER\020\032\022\010\n\004"
|
||||
"RELU\020\022\022\013\n\007SIGMOID\020\023\022\036\n\032SIGMOID_CROSS_ENT"
|
||||
"ROPY_LOSS\020\033\022\013\n\007SILENCE\020$\022\013\n\007SOFTMAX\020\024\022\020\n"
|
||||
"\014SOFTMAX_LOSS\020\025\022\t\n\005SPLIT\020\026\022\t\n\005SLICE\020!\022\010\n"
|
||||
"\004TANH\020\027\022\017\n\013WINDOW_DATA\020\030\022\r\n\tTHRESHOLD\020\037\""
|
||||
"*\n\014DimCheckMode\022\n\n\006STRICT\020\000\022\016\n\nPERMISSIV"
|
||||
"E\020\001\"\375\007\n\020V0LayerParameter\022\014\n\004name\030\001 \001(\t\022\014"
|
||||
"\n\004type\030\002 \001(\t\022\022\n\nnum_output\030\003 \001(\r\022\026\n\010bias"
|
||||
"term\030\004 \001(\010:\004true\022-\n\rweight_filler\030\005 \001(\0132"
|
||||
"\026.caffe.FillerParameter\022+\n\013bias_filler\030\006"
|
||||
" \001(\0132\026.caffe.FillerParameter\022\016\n\003pad\030\007 \001("
|
||||
"\r:\0010\022\022\n\nkernelsize\030\010 \001(\r\022\020\n\005group\030\t \001(\r:"
|
||||
"\0011\022\021\n\006stride\030\n \001(\r:\0011\0225\n\004pool\030\013 \001(\0162\".ca"
|
||||
"ffe.V0LayerParameter.PoolMethod:\003MAX\022\032\n\r"
|
||||
"dropout_ratio\030\014 \001(\002:\0030.5\022\025\n\nlocal_size\030\r"
|
||||
" \001(\r:\0015\022\020\n\005alpha\030\016 \001(\002:\0011\022\022\n\004beta\030\017 \001(\002:"
|
||||
"\0040.75\022\014\n\001k\030\026 \001(\002:\0011\022\016\n\006source\030\020 \001(\t\022\020\n\005s"
|
||||
"cale\030\021 \001(\002:\0011\022\020\n\010meanfile\030\022 \001(\t\022\021\n\tbatch"
|
||||
"size\030\023 \001(\r\022\023\n\010cropsize\030\024 \001(\r:\0010\022\025\n\006mirro"
|
||||
"r\030\025 \001(\010:\005false\022\037\n\005blobs\0302 \003(\0132\020.caffe.Bl"
|
||||
"obProto\022\020\n\010blobs_lr\0303 \003(\002\022\024\n\014weight_deca"
|
||||
"y\0304 \003(\002\022\024\n\trand_skip\0305 \001(\r:\0010\022\035\n\020det_fg_"
|
||||
"threshold\0306 \001(\002:\0030.5\022\035\n\020det_bg_threshold"
|
||||
"\0307 \001(\002:\0030.5\022\035\n\017det_fg_fraction\0308 \001(\002:\0040."
|
||||
"25\022\032\n\017det_context_pad\030: \001(\r:\0010\022\033\n\rdet_cr"
|
||||
"op_mode\030; \001(\t:\004warp\022\022\n\007new_num\030< \001(\005:\0010\022"
|
||||
"\027\n\014new_channels\030= \001(\005:\0010\022\025\n\nnew_height\030>"
|
||||
" \001(\005:\0010\022\024\n\tnew_width\030\? \001(\005:\0010\022\035\n\016shuffle"
|
||||
"_images\030@ \001(\010:\005false\022\025\n\nconcat_dim\030A \001(\r"
|
||||
":\0011\0226\n\021hdf5_output_param\030\351\007 \001(\0132\032.caffe."
|
||||
"HDF5OutputParameter\".\n\nPoolMethod\022\007\n\003MAX"
|
||||
"\020\000\022\007\n\003AVE\020\001\022\016\n\nSTOCHASTIC\020\002\"W\n\016PReLUPara"
|
||||
"meter\022&\n\006filler\030\001 \001(\0132\026.caffe.FillerPara"
|
||||
"meter\022\035\n\016channel_shared\030\002 \001(\010:\005false\"\207\001\n"
|
||||
"\016NormalizedBBox\022\014\n\004xmin\030\001 \001(\002\022\014\n\004ymin\030\002 "
|
||||
"\001(\002\022\014\n\004xmax\030\003 \001(\002\022\014\n\004ymax\030\004 \001(\002\022\r\n\005label"
|
||||
"\030\005 \001(\005\022\021\n\tdifficult\030\006 \001(\010\022\r\n\005score\030\007 \001(\002"
|
||||
"\022\014\n\004size\030\010 \001(\002*=\n\004Type\022\n\n\006DOUBLE\020\000\022\t\n\005FL"
|
||||
"OAT\020\001\022\013\n\007FLOAT16\020\002\022\007\n\003INT\020\003\022\010\n\004UINT\020\004*\034\n"
|
||||
"\005Phase\022\t\n\005TRAIN\020\000\022\010\n\004TEST\020\001", 17027);
|
||||
::google::protobuf::MessageFactory::InternalRegisterGeneratedFile(
|
||||
"caffe.proto", &protobuf_RegisterTypes);
|
||||
::google::protobuf::internal::OnShutdown(&protobuf_ShutdownFile_caffe_2eproto);
|
||||
@@ -5141,6 +5143,7 @@ const int PriorBoxParameter::kStepFieldNumber;
|
||||
const int PriorBoxParameter::kStepHFieldNumber;
|
||||
const int PriorBoxParameter::kStepWFieldNumber;
|
||||
const int PriorBoxParameter::kOffsetFieldNumber;
|
||||
const int PriorBoxParameter::kAdditionalYOffsetFieldNumber;
|
||||
#endif // !defined(_MSC_VER) || _MSC_VER >= 1900
|
||||
|
||||
PriorBoxParameter::PriorBoxParameter()
|
||||
@@ -5163,8 +5166,8 @@ PriorBoxParameter::PriorBoxParameter(const PriorBoxParameter& from)
|
||||
|
||||
void PriorBoxParameter::SharedCtor() {
|
||||
_cached_size_ = 0;
|
||||
::memset(&min_size_, 0, reinterpret_cast<char*>(&step_w_) -
|
||||
reinterpret_cast<char*>(&min_size_) + sizeof(step_w_));
|
||||
::memset(&min_size_, 0, reinterpret_cast<char*>(&additional_y_offset_) -
|
||||
reinterpret_cast<char*>(&min_size_) + sizeof(additional_y_offset_));
|
||||
flip_ = true;
|
||||
clip_ = true;
|
||||
offset_ = 0.5f;
|
||||
@@ -5226,8 +5229,8 @@ void PriorBoxParameter::Clear() {
|
||||
flip_ = true;
|
||||
clip_ = true;
|
||||
}
|
||||
if (_has_bits_[8 / 32] & 7936u) {
|
||||
ZR_(img_w_, step_w_);
|
||||
if (_has_bits_[8 / 32] & 16128u) {
|
||||
ZR_(img_w_, additional_y_offset_);
|
||||
offset_ = 0.5f;
|
||||
}
|
||||
|
||||
@@ -5450,6 +5453,21 @@ bool PriorBoxParameter::MergePartialFromCodedStream(
|
||||
} else {
|
||||
goto handle_unusual;
|
||||
}
|
||||
if (input->ExpectTag(112)) goto parse_additional_y_offset;
|
||||
break;
|
||||
}
|
||||
|
||||
// optional bool additional_y_offset = 14 [default = false];
|
||||
case 14: {
|
||||
if (tag == 112) {
|
||||
parse_additional_y_offset:
|
||||
set_has_additional_y_offset();
|
||||
DO_((::google::protobuf::internal::WireFormatLite::ReadPrimitive<
|
||||
bool, ::google::protobuf::internal::WireFormatLite::TYPE_BOOL>(
|
||||
input, &additional_y_offset_)));
|
||||
} else {
|
||||
goto handle_unusual;
|
||||
}
|
||||
if (input->ExpectAtEnd()) goto success;
|
||||
break;
|
||||
}
|
||||
@@ -5546,6 +5564,11 @@ void PriorBoxParameter::SerializeWithCachedSizes(
|
||||
::google::protobuf::internal::WireFormatLite::WriteFloat(13, this->offset(), output);
|
||||
}
|
||||
|
||||
// optional bool additional_y_offset = 14 [default = false];
|
||||
if (has_additional_y_offset()) {
|
||||
::google::protobuf::internal::WireFormatLite::WriteBool(14, this->additional_y_offset(), output);
|
||||
}
|
||||
|
||||
if (_internal_metadata_.have_unknown_fields()) {
|
||||
::google::protobuf::internal::WireFormat::SerializeUnknownFields(
|
||||
unknown_fields(), output);
|
||||
@@ -5624,6 +5647,11 @@ void PriorBoxParameter::SerializeWithCachedSizes(
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteFloatToArray(13, this->offset(), target);
|
||||
}
|
||||
|
||||
// optional bool additional_y_offset = 14 [default = false];
|
||||
if (has_additional_y_offset()) {
|
||||
target = ::google::protobuf::internal::WireFormatLite::WriteBoolToArray(14, this->additional_y_offset(), target);
|
||||
}
|
||||
|
||||
if (_internal_metadata_.have_unknown_fields()) {
|
||||
target = ::google::protobuf::internal::WireFormat::SerializeUnknownFieldsToArray(
|
||||
unknown_fields(), target);
|
||||
@@ -5672,7 +5700,7 @@ size_t PriorBoxParameter::ByteSizeLong() const {
|
||||
}
|
||||
|
||||
}
|
||||
if (_has_bits_[8 / 32] & 7936u) {
|
||||
if (_has_bits_[8 / 32] & 16128u) {
|
||||
// optional uint32 img_w = 9;
|
||||
if (has_img_w()) {
|
||||
total_size += 1 +
|
||||
@@ -5700,6 +5728,11 @@ size_t PriorBoxParameter::ByteSizeLong() const {
|
||||
total_size += 1 + 4;
|
||||
}
|
||||
|
||||
// optional bool additional_y_offset = 14 [default = false];
|
||||
if (has_additional_y_offset()) {
|
||||
total_size += 1 + 1;
|
||||
}
|
||||
|
||||
}
|
||||
// repeated float aspect_ratio = 3;
|
||||
{
|
||||
@@ -5797,6 +5830,9 @@ void PriorBoxParameter::UnsafeMergeFrom(const PriorBoxParameter& from) {
|
||||
if (from.has_offset()) {
|
||||
set_offset(from.offset());
|
||||
}
|
||||
if (from.has_additional_y_offset()) {
|
||||
set_additional_y_offset(from.additional_y_offset());
|
||||
}
|
||||
}
|
||||
if (from._internal_metadata_.have_unknown_fields()) {
|
||||
::google::protobuf::UnknownFieldSet::MergeToInternalMetdata(
|
||||
@@ -5841,6 +5877,7 @@ void PriorBoxParameter::InternalSwap(PriorBoxParameter* other) {
|
||||
std::swap(step_h_, other->step_h_);
|
||||
std::swap(step_w_, other->step_w_);
|
||||
std::swap(offset_, other->offset_);
|
||||
std::swap(additional_y_offset_, other->additional_y_offset_);
|
||||
std::swap(_has_bits_[0], other->_has_bits_[0]);
|
||||
_internal_metadata_.Swap(&other->_internal_metadata_);
|
||||
std::swap(_cached_size_, other->_cached_size_);
|
||||
@@ -6181,6 +6218,30 @@ void PriorBoxParameter::set_offset(float value) {
|
||||
// @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.offset)
|
||||
}
|
||||
|
||||
// optional bool additional_y_offset = 14 [default = false];
|
||||
bool PriorBoxParameter::has_additional_y_offset() const {
|
||||
return (_has_bits_[0] & 0x00002000u) != 0;
|
||||
}
|
||||
void PriorBoxParameter::set_has_additional_y_offset() {
|
||||
_has_bits_[0] |= 0x00002000u;
|
||||
}
|
||||
void PriorBoxParameter::clear_has_additional_y_offset() {
|
||||
_has_bits_[0] &= ~0x00002000u;
|
||||
}
|
||||
void PriorBoxParameter::clear_additional_y_offset() {
|
||||
additional_y_offset_ = false;
|
||||
clear_has_additional_y_offset();
|
||||
}
|
||||
bool PriorBoxParameter::additional_y_offset() const {
|
||||
// @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.additional_y_offset)
|
||||
return additional_y_offset_;
|
||||
}
|
||||
void PriorBoxParameter::set_additional_y_offset(bool value) {
|
||||
set_has_additional_y_offset();
|
||||
additional_y_offset_ = value;
|
||||
// @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.additional_y_offset)
|
||||
}
|
||||
|
||||
inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() {
|
||||
return &PriorBoxParameter_default_instance_.get();
|
||||
}
|
||||
|
||||
@@ -1537,6 +1537,13 @@ class PriorBoxParameter : public ::google::protobuf::Message /* @@protoc_inserti
|
||||
float offset() const;
|
||||
void set_offset(float value);
|
||||
|
||||
// optional bool additional_y_offset = 14 [default = false];
|
||||
bool has_additional_y_offset() const;
|
||||
void clear_additional_y_offset();
|
||||
static const int kAdditionalYOffsetFieldNumber = 14;
|
||||
bool additional_y_offset() const;
|
||||
void set_additional_y_offset(bool value);
|
||||
|
||||
// @@protoc_insertion_point(class_scope:caffe.PriorBoxParameter)
|
||||
private:
|
||||
inline void set_has_min_size();
|
||||
@@ -1561,6 +1568,8 @@ class PriorBoxParameter : public ::google::protobuf::Message /* @@protoc_inserti
|
||||
inline void clear_has_step_w();
|
||||
inline void set_has_offset();
|
||||
inline void clear_has_offset();
|
||||
inline void set_has_additional_y_offset();
|
||||
inline void clear_has_additional_y_offset();
|
||||
|
||||
::google::protobuf::internal::InternalMetadataWithArena _internal_metadata_;
|
||||
::google::protobuf::internal::HasBits<1> _has_bits_;
|
||||
@@ -1575,6 +1584,7 @@ class PriorBoxParameter : public ::google::protobuf::Message /* @@protoc_inserti
|
||||
float step_;
|
||||
float step_h_;
|
||||
float step_w_;
|
||||
bool additional_y_offset_;
|
||||
bool flip_;
|
||||
bool clip_;
|
||||
float offset_;
|
||||
@@ -13635,6 +13645,30 @@ inline void PriorBoxParameter::set_offset(float value) {
|
||||
// @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.offset)
|
||||
}
|
||||
|
||||
// optional bool additional_y_offset = 14 [default = false];
|
||||
inline bool PriorBoxParameter::has_additional_y_offset() const {
|
||||
return (_has_bits_[0] & 0x00002000u) != 0;
|
||||
}
|
||||
inline void PriorBoxParameter::set_has_additional_y_offset() {
|
||||
_has_bits_[0] |= 0x00002000u;
|
||||
}
|
||||
inline void PriorBoxParameter::clear_has_additional_y_offset() {
|
||||
_has_bits_[0] &= ~0x00002000u;
|
||||
}
|
||||
inline void PriorBoxParameter::clear_additional_y_offset() {
|
||||
additional_y_offset_ = false;
|
||||
clear_has_additional_y_offset();
|
||||
}
|
||||
inline bool PriorBoxParameter::additional_y_offset() const {
|
||||
// @@protoc_insertion_point(field_get:caffe.PriorBoxParameter.additional_y_offset)
|
||||
return additional_y_offset_;
|
||||
}
|
||||
inline void PriorBoxParameter::set_additional_y_offset(bool value) {
|
||||
set_has_additional_y_offset();
|
||||
additional_y_offset_ = value;
|
||||
// @@protoc_insertion_point(field_set:caffe.PriorBoxParameter.additional_y_offset)
|
||||
}
|
||||
|
||||
inline const PriorBoxParameter* PriorBoxParameter::internal_default_instance() {
|
||||
return &PriorBoxParameter_default_instance_.get();
|
||||
}
|
||||
|
||||
@@ -2,8 +2,7 @@
|
||||
typedef dnn::DictValue LayerId;
|
||||
typedef std::vector<dnn::MatShape> vector_MatShape;
|
||||
typedef std::vector<std::vector<dnn::MatShape> > vector_vector_MatShape;
|
||||
typedef std::vector<size_t> vector_size_t;
|
||||
typedef std::vector<std::vector<Mat> > vector_vector_Mat;
|
||||
|
||||
|
||||
template<>
|
||||
bool pyopencv_to(PyObject *o, dnn::DictValue &dv, const char *name)
|
||||
@@ -16,6 +15,11 @@ bool pyopencv_to(PyObject *o, dnn::DictValue &dv, const char *name)
|
||||
dv = dnn::DictValue((int64)PyLong_AsLongLong(o));
|
||||
return true;
|
||||
}
|
||||
else if (PyInt_Check(o))
|
||||
{
|
||||
dv = dnn::DictValue((int64)PyInt_AS_LONG(o));
|
||||
return true;
|
||||
}
|
||||
else if (PyFloat_Check(o))
|
||||
{
|
||||
dv = dnn::DictValue(PyFloat_AS_DOUBLE(o));
|
||||
|
||||
@@ -145,6 +145,8 @@ message PriorBoxParameter {
|
||||
optional float step_w = 12;
|
||||
// Offset to the top left corner of each cell.
|
||||
optional float offset = 13 [default = 0.5];
|
||||
// If true, two additional boxes for each center will be generated. Their centers will be shifted by y coordinate.
|
||||
optional bool additional_y_offset = 14 [default = false];
|
||||
}
|
||||
|
||||
// Message that store parameters used by DetectionOutputLayer
|
||||
|
||||
@@ -216,7 +216,7 @@ public:
|
||||
shape.push_back((int)_shape.dim(i));
|
||||
}
|
||||
else
|
||||
CV_Error(Error::StsError, "Unknown shape of input blob");
|
||||
shape.resize(1, 1); // Is a scalar.
|
||||
}
|
||||
|
||||
void blobFromProto(const caffe::BlobProto &pbBlob, cv::Mat &dstBlob)
|
||||
@@ -274,9 +274,9 @@ public:
|
||||
struct BlobNote
|
||||
{
|
||||
BlobNote(const std::string &_name, int _layerId, int _outNum) :
|
||||
name(_name.c_str()), layerId(_layerId), outNum(_outNum) {}
|
||||
name(_name), layerId(_layerId), outNum(_outNum) {}
|
||||
|
||||
const char *name;
|
||||
std::string name;
|
||||
int layerId, outNum;
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,195 @@
|
||||
/*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
|
||||
// (3-clause BSD License)
|
||||
//
|
||||
// Copyright (C) 2017, Intel Corporation, 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:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions 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.
|
||||
//
|
||||
// * Neither the names of the copyright holders nor the names of the contributors
|
||||
// may 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 copyright holders 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 <iostream>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include <map>
|
||||
|
||||
#include "darknet_io.hpp"
|
||||
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
CV__DNN_EXPERIMENTAL_NS_BEGIN
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
class DarknetImporter : public Importer
|
||||
{
|
||||
darknet::NetParameter net;
|
||||
|
||||
public:
|
||||
|
||||
DarknetImporter() {}
|
||||
|
||||
DarknetImporter(const char *cfgFile, const char *darknetModel)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
|
||||
ReadNetParamsFromCfgFileOrDie(cfgFile, &net);
|
||||
|
||||
if (darknetModel && darknetModel[0])
|
||||
ReadNetParamsFromBinaryFileOrDie(darknetModel, &net);
|
||||
}
|
||||
|
||||
struct BlobNote
|
||||
{
|
||||
BlobNote(const std::string &_name, int _layerId, int _outNum) :
|
||||
name(_name), layerId(_layerId), outNum(_outNum) {}
|
||||
|
||||
std::string name;
|
||||
int layerId, outNum;
|
||||
};
|
||||
|
||||
std::vector<BlobNote> addedBlobs;
|
||||
std::map<String, int> layerCounter;
|
||||
|
||||
void populateNet(Net dstNet)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
|
||||
int layersSize = net.layer_size();
|
||||
layerCounter.clear();
|
||||
addedBlobs.clear();
|
||||
addedBlobs.reserve(layersSize + 1);
|
||||
|
||||
//setup input layer names
|
||||
{
|
||||
std::vector<String> netInputs(net.input_size());
|
||||
for (int inNum = 0; inNum < net.input_size(); inNum++)
|
||||
{
|
||||
addedBlobs.push_back(BlobNote(net.input(inNum), 0, inNum));
|
||||
netInputs[inNum] = net.input(inNum);
|
||||
}
|
||||
dstNet.setInputsNames(netInputs);
|
||||
}
|
||||
|
||||
for (int li = 0; li < layersSize; li++)
|
||||
{
|
||||
const darknet::LayerParameter &layer = net.layer(li);
|
||||
String name = layer.name();
|
||||
String type = layer.type();
|
||||
LayerParams layerParams = layer.getLayerParams();
|
||||
|
||||
int repetitions = layerCounter[name]++;
|
||||
if (repetitions)
|
||||
name += cv::format("_%d", repetitions);
|
||||
|
||||
int id = dstNet.addLayer(name, type, layerParams);
|
||||
|
||||
// iterate many bottoms layers (for example for: route -1, -4)
|
||||
for (int inNum = 0; inNum < layer.bottom_size(); inNum++)
|
||||
addInput(layer.bottom(inNum), id, inNum, dstNet, layer.name());
|
||||
|
||||
for (int outNum = 0; outNum < layer.top_size(); outNum++)
|
||||
addOutput(layer, id, outNum);
|
||||
}
|
||||
|
||||
addedBlobs.clear();
|
||||
}
|
||||
|
||||
void addOutput(const darknet::LayerParameter &layer, int layerId, int outNum)
|
||||
{
|
||||
const std::string &name = layer.top(outNum);
|
||||
|
||||
bool haveDups = false;
|
||||
for (int idx = (int)addedBlobs.size() - 1; idx >= 0; idx--)
|
||||
{
|
||||
if (addedBlobs[idx].name == name)
|
||||
{
|
||||
haveDups = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (haveDups)
|
||||
{
|
||||
bool isInplace = layer.bottom_size() > outNum && layer.bottom(outNum) == name;
|
||||
if (!isInplace)
|
||||
CV_Error(Error::StsBadArg, "Duplicate blobs produced by multiple sources");
|
||||
}
|
||||
|
||||
addedBlobs.push_back(BlobNote(name, layerId, outNum));
|
||||
}
|
||||
|
||||
void addInput(const std::string &name, int layerId, int inNum, Net &dstNet, std::string nn)
|
||||
{
|
||||
int idx;
|
||||
for (idx = (int)addedBlobs.size() - 1; idx >= 0; idx--)
|
||||
{
|
||||
if (addedBlobs[idx].name == name)
|
||||
break;
|
||||
}
|
||||
|
||||
if (idx < 0)
|
||||
{
|
||||
CV_Error(Error::StsObjectNotFound, "Can't find output blob \"" + name + "\"");
|
||||
return;
|
||||
}
|
||||
|
||||
dstNet.connect(addedBlobs[idx].layerId, addedBlobs[idx].outNum, layerId, inNum);
|
||||
}
|
||||
|
||||
~DarknetImporter()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
Net readNetFromDarknet(const String &cfgFile, const String &darknetModel /*= String()*/)
|
||||
{
|
||||
DarknetImporter darknetImporter(cfgFile.c_str(), darknetModel.c_str());
|
||||
Net net;
|
||||
darknetImporter.populateNet(net);
|
||||
return net;
|
||||
}
|
||||
|
||||
CV__DNN_EXPERIMENTAL_NS_END
|
||||
}} // namespace
|
||||
@@ -0,0 +1,624 @@
|
||||
/*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
|
||||
// (3-clause BSD License)
|
||||
//
|
||||
// Copyright (C) 2017, Intel Corporation, 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:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions 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.
|
||||
//
|
||||
// * Neither the names of the copyright holders nor the names of the contributors
|
||||
// may 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 copyright holders 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*/
|
||||
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//MIT License
|
||||
//
|
||||
//Copyright (c) 2017 Joseph Redmon
|
||||
//
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
//
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include <opencv2/core.hpp>
|
||||
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include "darknet_io.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
namespace darknet {
|
||||
|
||||
template<typename T>
|
||||
T getParam(const std::map<std::string, std::string> ¶ms, const std::string param_name, T init_val)
|
||||
{
|
||||
std::map<std::string, std::string>::const_iterator it = params.find(param_name);
|
||||
if (it != params.end()) {
|
||||
std::stringstream ss(it->second);
|
||||
ss >> init_val;
|
||||
}
|
||||
return init_val;
|
||||
}
|
||||
|
||||
class setLayersParams {
|
||||
|
||||
NetParameter *net;
|
||||
int layer_id;
|
||||
std::string last_layer;
|
||||
std::vector<std::string> fused_layer_names;
|
||||
|
||||
public:
|
||||
setLayersParams(NetParameter *_net, std::string _first_layer = "data") :
|
||||
net(_net), layer_id(0), last_layer(_first_layer)
|
||||
{}
|
||||
|
||||
void setLayerBlobs(int i, std::vector<cv::Mat> blobs)
|
||||
{
|
||||
cv::dnn::LayerParams ¶ms = net->layers[i].layerParams;
|
||||
params.blobs = blobs;
|
||||
}
|
||||
|
||||
cv::dnn::LayerParams getParamConvolution(int kernel, int pad,
|
||||
int stride, int filters_num)
|
||||
{
|
||||
cv::dnn::LayerParams params;
|
||||
params.name = "Convolution-name";
|
||||
params.type = "Convolution";
|
||||
|
||||
params.set<int>("kernel_size", kernel);
|
||||
params.set<int>("pad", pad);
|
||||
params.set<int>("stride", stride);
|
||||
|
||||
params.set<bool>("bias_term", false); // true only if(BatchNorm == false)
|
||||
params.set<int>("num_output", filters_num);
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
|
||||
void setConvolution(int kernel, int pad, int stride,
|
||||
int filters_num, int channels_num, int use_batch_normalize, int use_relu)
|
||||
{
|
||||
cv::dnn::LayerParams conv_param =
|
||||
getParamConvolution(kernel, pad, stride, filters_num);
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
std::string layer_name = cv::format("conv_%d", layer_id);
|
||||
|
||||
// use BIAS in any case
|
||||
if (!use_batch_normalize) {
|
||||
conv_param.set<bool>("bias_term", true);
|
||||
}
|
||||
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = conv_param.type;
|
||||
lp.layerParams = conv_param;
|
||||
lp.bottom_indexes.push_back(last_layer);
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
|
||||
if (use_batch_normalize)
|
||||
{
|
||||
cv::dnn::LayerParams bn_param;
|
||||
|
||||
bn_param.name = "BatchNorm-name";
|
||||
bn_param.type = "BatchNorm";
|
||||
bn_param.set<bool>("has_weight", true);
|
||||
bn_param.set<bool>("has_bias", true);
|
||||
bn_param.set<float>("eps", 1E-6); // .000001f in Darknet Yolo
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
std::string layer_name = cv::format("bn_%d", layer_id);
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = bn_param.type;
|
||||
lp.layerParams = bn_param;
|
||||
lp.bottom_indexes.push_back(last_layer);
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
}
|
||||
|
||||
if (use_relu)
|
||||
{
|
||||
cv::dnn::LayerParams activation_param;
|
||||
activation_param.set<float>("negative_slope", 0.1f);
|
||||
activation_param.name = "ReLU-name";
|
||||
activation_param.type = "ReLU";
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
std::string layer_name = cv::format("relu_%d", layer_id);
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = activation_param.type;
|
||||
lp.layerParams = activation_param;
|
||||
lp.bottom_indexes.push_back(last_layer);
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
}
|
||||
|
||||
layer_id++;
|
||||
fused_layer_names.push_back(last_layer);
|
||||
}
|
||||
|
||||
void setMaxpool(size_t kernel, size_t pad, size_t stride)
|
||||
{
|
||||
cv::dnn::LayerParams maxpool_param;
|
||||
maxpool_param.set<cv::String>("pool", "max");
|
||||
maxpool_param.set<int>("kernel_size", kernel);
|
||||
maxpool_param.set<int>("pad", pad);
|
||||
maxpool_param.set<int>("stride", stride);
|
||||
maxpool_param.set<cv::String>("pad_mode", "SAME");
|
||||
maxpool_param.name = "Pooling-name";
|
||||
maxpool_param.type = "Pooling";
|
||||
darknet::LayerParameter lp;
|
||||
|
||||
std::string layer_name = cv::format("pool_%d", layer_id);
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = maxpool_param.type;
|
||||
lp.layerParams = maxpool_param;
|
||||
lp.bottom_indexes.push_back(last_layer);
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
layer_id++;
|
||||
fused_layer_names.push_back(last_layer);
|
||||
}
|
||||
|
||||
void setConcat(int number_of_inputs, int *input_indexes)
|
||||
{
|
||||
cv::dnn::LayerParams concat_param;
|
||||
concat_param.name = "Concat-name";
|
||||
concat_param.type = "Concat";
|
||||
concat_param.set<int>("axis", 1); // channels are in axis = 1
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
|
||||
std::string layer_name = cv::format("concat_%d", layer_id);
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = concat_param.type;
|
||||
lp.layerParams = concat_param;
|
||||
for (int i = 0; i < number_of_inputs; ++i)
|
||||
lp.bottom_indexes.push_back(fused_layer_names.at(input_indexes[i]));
|
||||
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
|
||||
layer_id++;
|
||||
fused_layer_names.push_back(last_layer);
|
||||
}
|
||||
|
||||
void setIdentity(int bottom_index)
|
||||
{
|
||||
cv::dnn::LayerParams identity_param;
|
||||
identity_param.name = "Identity-name";
|
||||
identity_param.type = "Identity";
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
|
||||
std::string layer_name = cv::format("identity_%d", layer_id);
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = identity_param.type;
|
||||
lp.layerParams = identity_param;
|
||||
lp.bottom_indexes.push_back(fused_layer_names.at(bottom_index));
|
||||
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
|
||||
layer_id++;
|
||||
fused_layer_names.push_back(last_layer);
|
||||
}
|
||||
|
||||
void setReorg(int stride)
|
||||
{
|
||||
cv::dnn::LayerParams reorg_params;
|
||||
reorg_params.name = "Reorg-name";
|
||||
reorg_params.type = "Reorg";
|
||||
reorg_params.set<int>("reorg_stride", stride);
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
std::string layer_name = cv::format("reorg_%d", layer_id);
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = reorg_params.type;
|
||||
lp.layerParams = reorg_params;
|
||||
lp.bottom_indexes.push_back(last_layer);
|
||||
last_layer = layer_name;
|
||||
|
||||
net->layers.push_back(lp);
|
||||
|
||||
layer_id++;
|
||||
fused_layer_names.push_back(last_layer);
|
||||
}
|
||||
|
||||
void setPermute()
|
||||
{
|
||||
cv::dnn::LayerParams permute_params;
|
||||
permute_params.name = "Permute-name";
|
||||
permute_params.type = "Permute";
|
||||
int permute[] = { 0, 2, 3, 1 };
|
||||
cv::dnn::DictValue paramOrder = cv::dnn::DictValue::arrayInt(permute, 4);
|
||||
|
||||
permute_params.set("order", paramOrder);
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
std::string layer_name = cv::format("premute_%d", layer_id);
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = permute_params.type;
|
||||
lp.layerParams = permute_params;
|
||||
lp.bottom_indexes.push_back(last_layer);
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
|
||||
layer_id++;
|
||||
fused_layer_names.push_back(last_layer);
|
||||
}
|
||||
|
||||
void setRegion(float thresh, int coords, int classes, int anchors, int classfix, int softmax, int softmax_tree, float *biasData)
|
||||
{
|
||||
cv::dnn::LayerParams region_param;
|
||||
region_param.name = "Region-name";
|
||||
region_param.type = "Region";
|
||||
|
||||
region_param.set<float>("thresh", thresh);
|
||||
region_param.set<int>("coords", coords);
|
||||
region_param.set<int>("classes", classes);
|
||||
region_param.set<int>("anchors", anchors);
|
||||
region_param.set<int>("classfix", classfix);
|
||||
region_param.set<bool>("softmax_tree", softmax_tree);
|
||||
region_param.set<bool>("softmax", softmax);
|
||||
|
||||
cv::Mat biasData_mat = cv::Mat(1, anchors * 2, CV_32F, biasData).clone();
|
||||
region_param.blobs.push_back(biasData_mat);
|
||||
|
||||
darknet::LayerParameter lp;
|
||||
std::string layer_name = "detection_out";
|
||||
lp.layer_name = layer_name;
|
||||
lp.layer_type = region_param.type;
|
||||
lp.layerParams = region_param;
|
||||
lp.bottom_indexes.push_back(last_layer);
|
||||
last_layer = layer_name;
|
||||
net->layers.push_back(lp);
|
||||
|
||||
layer_id++;
|
||||
fused_layer_names.push_back(last_layer);
|
||||
}
|
||||
};
|
||||
|
||||
std::string escapeString(const std::string &src)
|
||||
{
|
||||
std::string dst;
|
||||
for (size_t i = 0; i < src.size(); ++i)
|
||||
if (src[i] > ' ' && src[i] <= 'z')
|
||||
dst += src[i];
|
||||
return dst;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
std::vector<T> getNumbers(const std::string &src)
|
||||
{
|
||||
std::vector<T> dst;
|
||||
std::stringstream ss(src);
|
||||
|
||||
for (std::string str; std::getline(ss, str, ',');) {
|
||||
std::stringstream line(str);
|
||||
T val;
|
||||
line >> val;
|
||||
dst.push_back(val);
|
||||
}
|
||||
return dst;
|
||||
}
|
||||
|
||||
bool ReadDarknetFromCfgFile(const char *cfgFile, NetParameter *net)
|
||||
{
|
||||
std::ifstream ifile;
|
||||
ifile.open(cfgFile);
|
||||
if (ifile.is_open())
|
||||
{
|
||||
bool read_net = false;
|
||||
int layers_counter = -1;
|
||||
for (std::string line; std::getline(ifile, line);) {
|
||||
line = escapeString(line);
|
||||
if (line.empty()) continue;
|
||||
switch (line[0]) {
|
||||
case '\0': break;
|
||||
case '#': break;
|
||||
case ';': break;
|
||||
case '[':
|
||||
if (line == "[net]") {
|
||||
read_net = true;
|
||||
}
|
||||
else {
|
||||
// read section
|
||||
read_net = false;
|
||||
++layers_counter;
|
||||
const size_t layer_type_size = line.find("]") - 1;
|
||||
CV_Assert(layer_type_size < line.size());
|
||||
std::string layer_type = line.substr(1, layer_type_size);
|
||||
net->layers_cfg[layers_counter]["type"] = layer_type;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
// read entry
|
||||
const size_t separator_index = line.find('=');
|
||||
CV_Assert(separator_index < line.size());
|
||||
if (separator_index != std::string::npos) {
|
||||
std::string name = line.substr(0, separator_index);
|
||||
std::string value = line.substr(separator_index + 1, line.size() - (separator_index + 1));
|
||||
name = escapeString(name);
|
||||
value = escapeString(value);
|
||||
if (name.empty() || value.empty()) continue;
|
||||
if (read_net)
|
||||
net->net_cfg[name] = value;
|
||||
else
|
||||
net->layers_cfg[layers_counter][name] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::string anchors = net->layers_cfg[net->layers_cfg.size() - 1]["anchors"];
|
||||
std::vector<float> vec = getNumbers<float>(anchors);
|
||||
std::map<std::string, std::string> &net_params = net->net_cfg;
|
||||
net->width = getParam(net_params, "width", 416);
|
||||
net->height = getParam(net_params, "height", 416);
|
||||
net->channels = getParam(net_params, "channels", 3);
|
||||
CV_Assert(net->width > 0 && net->height > 0 && net->channels > 0);
|
||||
}
|
||||
else
|
||||
return false;
|
||||
|
||||
int current_channels = net->channels;
|
||||
net->out_channels_vec.resize(net->layers_cfg.size());
|
||||
|
||||
int layers_counter = -1;
|
||||
|
||||
setLayersParams setParams(net);
|
||||
|
||||
typedef std::map<int, std::map<std::string, std::string> >::iterator it_type;
|
||||
for (it_type i = net->layers_cfg.begin(); i != net->layers_cfg.end(); ++i) {
|
||||
++layers_counter;
|
||||
std::map<std::string, std::string> &layer_params = i->second;
|
||||
std::string layer_type = layer_params["type"];
|
||||
|
||||
if (layer_type == "convolutional")
|
||||
{
|
||||
int kernel_size = getParam<int>(layer_params, "size", -1);
|
||||
int pad = getParam<int>(layer_params, "pad", 0);
|
||||
int stride = getParam<int>(layer_params, "stride", 1);
|
||||
int filters = getParam<int>(layer_params, "filters", -1);
|
||||
std::string activation = getParam<std::string>(layer_params, "activation", "linear");
|
||||
bool batch_normalize = getParam<int>(layer_params, "batch_normalize", 0) == 1;
|
||||
if(activation != "linear" && activation != "leaky")
|
||||
CV_Error(cv::Error::StsParseError, "Unsupported activation: " + activation);
|
||||
int flipped = getParam<int>(layer_params, "flipped", 0);
|
||||
if (flipped == 1)
|
||||
CV_Error(cv::Error::StsNotImplemented, "Transpose the convolutional weights is not implemented");
|
||||
|
||||
// correct the strange value of pad=1 for kernel_size=1 in the Darknet cfg-file
|
||||
if (kernel_size < 3) pad = 0;
|
||||
|
||||
CV_Assert(kernel_size > 0 && filters > 0);
|
||||
CV_Assert(current_channels > 0);
|
||||
|
||||
setParams.setConvolution(kernel_size, pad, stride, filters, current_channels,
|
||||
batch_normalize, activation == "leaky");
|
||||
|
||||
current_channels = filters;
|
||||
}
|
||||
else if (layer_type == "maxpool")
|
||||
{
|
||||
int kernel_size = getParam<int>(layer_params, "size", 2);
|
||||
int stride = getParam<int>(layer_params, "stride", 2);
|
||||
int pad = getParam<int>(layer_params, "pad", 0);
|
||||
setParams.setMaxpool(kernel_size, pad, stride);
|
||||
}
|
||||
else if (layer_type == "route")
|
||||
{
|
||||
std::string bottom_layers = getParam<std::string>(layer_params, "layers", "");
|
||||
CV_Assert(!bottom_layers.empty());
|
||||
std::vector<int> layers_vec = getNumbers<int>(bottom_layers);
|
||||
|
||||
current_channels = 0;
|
||||
for (size_t k = 0; k < layers_vec.size(); ++k) {
|
||||
layers_vec[k] += layers_counter;
|
||||
current_channels += net->out_channels_vec[layers_vec[k]];
|
||||
}
|
||||
|
||||
if (layers_vec.size() == 1)
|
||||
setParams.setIdentity(layers_vec.at(0));
|
||||
else
|
||||
setParams.setConcat(layers_vec.size(), layers_vec.data());
|
||||
}
|
||||
else if (layer_type == "reorg")
|
||||
{
|
||||
int stride = getParam<int>(layer_params, "stride", 2);
|
||||
current_channels = current_channels * (stride*stride);
|
||||
|
||||
setParams.setReorg(stride);
|
||||
}
|
||||
else if (layer_type == "region")
|
||||
{
|
||||
float thresh = 0.001; // in the original Darknet is equal to the detection threshold set by the user
|
||||
int coords = getParam<int>(layer_params, "coords", 4);
|
||||
int classes = getParam<int>(layer_params, "classes", -1);
|
||||
int num_of_anchors = getParam<int>(layer_params, "num", -1);
|
||||
int classfix = getParam<int>(layer_params, "classfix", 0);
|
||||
bool softmax = (getParam<int>(layer_params, "softmax", 0) == 1);
|
||||
bool softmax_tree = (getParam<std::string>(layer_params, "tree", "").size() > 0);
|
||||
|
||||
std::string anchors_values = getParam<std::string>(layer_params, "anchors", std::string());
|
||||
CV_Assert(!anchors_values.empty());
|
||||
std::vector<float> anchors_vec = getNumbers<float>(anchors_values);
|
||||
|
||||
CV_Assert(classes > 0 && num_of_anchors > 0 && (num_of_anchors * 2) == anchors_vec.size());
|
||||
|
||||
setParams.setPermute();
|
||||
setParams.setRegion(thresh, coords, classes, num_of_anchors, classfix, softmax, softmax_tree, anchors_vec.data());
|
||||
}
|
||||
else {
|
||||
CV_Error(cv::Error::StsParseError, "Unknown layer type: " + layer_type);
|
||||
}
|
||||
net->out_channels_vec[layers_counter] = current_channels;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool ReadDarknetFromWeightsFile(const char *darknetModel, NetParameter *net)
|
||||
{
|
||||
std::ifstream ifile;
|
||||
ifile.open(darknetModel, std::ios::binary);
|
||||
CV_Assert(ifile.is_open());
|
||||
|
||||
int32_t major_ver, minor_ver, revision;
|
||||
ifile.read(reinterpret_cast<char *>(&major_ver), sizeof(int32_t));
|
||||
ifile.read(reinterpret_cast<char *>(&minor_ver), sizeof(int32_t));
|
||||
ifile.read(reinterpret_cast<char *>(&revision), sizeof(int32_t));
|
||||
|
||||
uint64_t seen;
|
||||
if ((major_ver * 10 + minor_ver) >= 2) {
|
||||
ifile.read(reinterpret_cast<char *>(&seen), sizeof(uint64_t));
|
||||
}
|
||||
else {
|
||||
int32_t iseen = 0;
|
||||
ifile.read(reinterpret_cast<char *>(&iseen), sizeof(int32_t));
|
||||
seen = iseen;
|
||||
}
|
||||
bool transpose = (major_ver > 1000) || (minor_ver > 1000);
|
||||
if(transpose)
|
||||
CV_Error(cv::Error::StsNotImplemented, "Transpose the weights (except for convolutional) is not implemented");
|
||||
|
||||
int current_channels = net->channels;
|
||||
int cv_layers_counter = -1;
|
||||
int darknet_layers_counter = -1;
|
||||
|
||||
setLayersParams setParams(net);
|
||||
|
||||
typedef std::map<int, std::map<std::string, std::string> >::iterator it_type;
|
||||
for (it_type i = net->layers_cfg.begin(); i != net->layers_cfg.end(); ++i) {
|
||||
++darknet_layers_counter;
|
||||
++cv_layers_counter;
|
||||
std::map<std::string, std::string> &layer_params = i->second;
|
||||
std::string layer_type = layer_params["type"];
|
||||
|
||||
if (layer_type == "convolutional")
|
||||
{
|
||||
int kernel_size = getParam<int>(layer_params, "size", -1);
|
||||
int filters = getParam<int>(layer_params, "filters", -1);
|
||||
std::string activation = getParam<std::string>(layer_params, "activation", "linear");
|
||||
bool use_batch_normalize = getParam<int>(layer_params, "batch_normalize", 0) == 1;
|
||||
|
||||
CV_Assert(kernel_size > 0 && filters > 0);
|
||||
CV_Assert(current_channels > 0);
|
||||
|
||||
size_t const weights_size = filters * current_channels * kernel_size * kernel_size;
|
||||
int sizes_weights[] = { filters, current_channels, kernel_size, kernel_size };
|
||||
cv::Mat weightsBlob;
|
||||
weightsBlob.create(4, sizes_weights, CV_32F);
|
||||
CV_Assert(weightsBlob.isContinuous());
|
||||
|
||||
cv::Mat meanData_mat(1, filters, CV_32F); // mean
|
||||
cv::Mat stdData_mat(1, filters, CV_32F); // variance
|
||||
cv::Mat weightsData_mat(1, filters, CV_32F);// scale
|
||||
cv::Mat biasData_mat(1, filters, CV_32F); // bias
|
||||
|
||||
ifile.read(reinterpret_cast<char *>(biasData_mat.ptr<float>()), sizeof(float)*filters);
|
||||
if (use_batch_normalize) {
|
||||
ifile.read(reinterpret_cast<char *>(weightsData_mat.ptr<float>()), sizeof(float)*filters);
|
||||
ifile.read(reinterpret_cast<char *>(meanData_mat.ptr<float>()), sizeof(float)*filters);
|
||||
ifile.read(reinterpret_cast<char *>(stdData_mat.ptr<float>()), sizeof(float)*filters);
|
||||
}
|
||||
ifile.read(reinterpret_cast<char *>(weightsBlob.ptr<float>()), sizeof(float)*weights_size);
|
||||
|
||||
// set convolutional weights
|
||||
std::vector<cv::Mat> conv_blobs;
|
||||
conv_blobs.push_back(weightsBlob);
|
||||
if (!use_batch_normalize) {
|
||||
// use BIAS in any case
|
||||
conv_blobs.push_back(biasData_mat);
|
||||
}
|
||||
setParams.setLayerBlobs(cv_layers_counter, conv_blobs);
|
||||
|
||||
// set batch normalize (mean, variance, scale, bias)
|
||||
if (use_batch_normalize) {
|
||||
++cv_layers_counter;
|
||||
std::vector<cv::Mat> bn_blobs;
|
||||
bn_blobs.push_back(meanData_mat);
|
||||
bn_blobs.push_back(stdData_mat);
|
||||
bn_blobs.push_back(weightsData_mat);
|
||||
bn_blobs.push_back(biasData_mat);
|
||||
setParams.setLayerBlobs(cv_layers_counter, bn_blobs);
|
||||
}
|
||||
|
||||
if(activation == "leaky")
|
||||
++cv_layers_counter;
|
||||
}
|
||||
current_channels = net->out_channels_vec[darknet_layers_counter];
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
void ReadNetParamsFromCfgFileOrDie(const char *cfgFile, darknet::NetParameter *net)
|
||||
{
|
||||
if (!darknet::ReadDarknetFromCfgFile(cfgFile, net)) {
|
||||
CV_Error(cv::Error::StsParseError, "Failed to parse NetParameter file: " + std::string(cfgFile));
|
||||
}
|
||||
}
|
||||
|
||||
void ReadNetParamsFromBinaryFileOrDie(const char *darknetModel, darknet::NetParameter *net)
|
||||
{
|
||||
if (!darknet::ReadDarknetFromWeightsFile(darknetModel, net)) {
|
||||
CV_Error(cv::Error::StsParseError, "Failed to parse NetParameter file: " + std::string(darknetModel));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,118 @@
|
||||
/*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
|
||||
// (3-clause BSD License)
|
||||
//
|
||||
// Copyright (C) 2017, Intel Corporation, 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:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions 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.
|
||||
//
|
||||
// * Neither the names of the copyright holders nor the names of the contributors
|
||||
// may 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 copyright holders 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*/
|
||||
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//MIT License
|
||||
//
|
||||
//Copyright (c) 2017 Joseph Redmon
|
||||
//
|
||||
//Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
//of this software and associated documentation files (the "Software"), to deal
|
||||
//in the Software without restriction, including without limitation the rights
|
||||
//to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
//copies of the Software, and to permit persons to whom the Software is
|
||||
//furnished to do so, subject to the following conditions:
|
||||
//
|
||||
//The above copyright notice and this permission notice shall be included in all
|
||||
//copies or substantial portions of the Software.
|
||||
//
|
||||
//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
//SOFTWARE.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_DNN_DARKNET_IO_HPP__
|
||||
#define __OPENCV_DNN_DARKNET_IO_HPP__
|
||||
|
||||
#include <opencv2/dnn/dnn.hpp>
|
||||
|
||||
namespace cv {
|
||||
namespace dnn {
|
||||
namespace darknet {
|
||||
|
||||
class LayerParameter {
|
||||
std::string layer_name, layer_type;
|
||||
std::vector<std::string> bottom_indexes;
|
||||
cv::dnn::LayerParams layerParams;
|
||||
public:
|
||||
friend class setLayersParams;
|
||||
cv::dnn::LayerParams getLayerParams() const { return layerParams; }
|
||||
std::string name() const { return layer_name; }
|
||||
std::string type() const { return layer_type; }
|
||||
int bottom_size() const { return bottom_indexes.size(); }
|
||||
std::string bottom(const int index) const { return bottom_indexes.at(index); }
|
||||
int top_size() const { return 1; }
|
||||
std::string top(const int index) const { return layer_name; }
|
||||
};
|
||||
|
||||
class NetParameter {
|
||||
public:
|
||||
int width, height, channels;
|
||||
std::vector<LayerParameter> layers;
|
||||
std::vector<int> out_channels_vec;
|
||||
|
||||
std::map<int, std::map<std::string, std::string> > layers_cfg;
|
||||
std::map<std::string, std::string> net_cfg;
|
||||
|
||||
NetParameter() : width(0), height(0), channels(0) {}
|
||||
|
||||
int layer_size() const { return layers.size(); }
|
||||
|
||||
int input_size() const { return 1; }
|
||||
std::string input(const int index) const { return "data"; }
|
||||
LayerParameter layer(const int index) const { return layers.at(index); }
|
||||
};
|
||||
}
|
||||
|
||||
// Read parameters from a file into a NetParameter message.
|
||||
void ReadNetParamsFromCfgFileOrDie(const char *cfgFile, darknet::NetParameter *net);
|
||||
void ReadNetParamsFromBinaryFileOrDie(const char *darknetModel, darknet::NetParameter *net);
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
+43
-42
@@ -85,15 +85,15 @@ static String toString(const T &v)
|
||||
}
|
||||
|
||||
Mat blobFromImage(const Mat& image, double scalefactor, const Size& size,
|
||||
const Scalar& mean, bool swapRB)
|
||||
const Scalar& mean, bool swapRB, bool crop)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
std::vector<Mat> images(1, image);
|
||||
return blobFromImages(images, scalefactor, size, mean, swapRB);
|
||||
return blobFromImages(images, scalefactor, size, mean, swapRB, crop);
|
||||
}
|
||||
|
||||
Mat blobFromImages(const std::vector<Mat>& images_, double scalefactor, Size size,
|
||||
const Scalar& mean_, bool swapRB)
|
||||
const Scalar& mean_, bool swapRB, bool crop)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
std::vector<Mat> images = images_;
|
||||
@@ -104,13 +104,18 @@ Mat blobFromImages(const std::vector<Mat>& images_, double scalefactor, Size siz
|
||||
size = imgSize;
|
||||
if (size != imgSize)
|
||||
{
|
||||
float resizeFactor = std::max(size.width / (float)imgSize.width,
|
||||
size.height / (float)imgSize.height);
|
||||
resize(images[i], images[i], Size(), resizeFactor, resizeFactor);
|
||||
Rect crop(Point(0.5 * (images[i].cols - size.width),
|
||||
0.5 * (images[i].rows - size.height)),
|
||||
size);
|
||||
images[i] = images[i](crop);
|
||||
if(crop)
|
||||
{
|
||||
float resizeFactor = std::max(size.width / (float)imgSize.width,
|
||||
size.height / (float)imgSize.height);
|
||||
resize(images[i], images[i], Size(), resizeFactor, resizeFactor);
|
||||
Rect crop(Point(0.5 * (images[i].cols - size.width),
|
||||
0.5 * (images[i].rows - size.height)),
|
||||
size);
|
||||
images[i] = images[i](crop);
|
||||
}
|
||||
else
|
||||
resize(images[i], images[i], size);
|
||||
}
|
||||
if(images[i].depth() == CV_8U)
|
||||
images[i].convertTo(images[i], CV_32F);
|
||||
@@ -589,33 +594,7 @@ struct Net::Impl
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
class HalideCompiler : public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
HalideCompiler(const MapIdToLayerData& layers_, int preferableTarget_)
|
||||
: layers(&layers_), preferableTarget(preferableTarget_) {}
|
||||
|
||||
void operator()(const Range& r) const
|
||||
{
|
||||
MapIdToLayerData::const_iterator it = layers->begin();
|
||||
for (int i = 0; i < r.start && it != layers->end(); ++i, ++it) {}
|
||||
for (int i = r.start; i < r.end && it != layers->end(); ++i, ++it)
|
||||
{
|
||||
const LayerData &ld = it->second;
|
||||
Ptr<Layer> layer = ld.layerInstance;
|
||||
bool skip = ld.skipFlags.find(DNN_BACKEND_HALIDE)->second;
|
||||
if (layer->supportBackend(DNN_BACKEND_HALIDE) && !skip)
|
||||
{
|
||||
Ptr<BackendNode> node = ld.backendNodes.find(DNN_BACKEND_HALIDE)->second;
|
||||
dnn::compileHalide(ld.outputBlobs, node, preferableTarget);
|
||||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
const MapIdToLayerData* layers;
|
||||
int preferableTarget;
|
||||
};
|
||||
|
||||
#ifdef HAVE_HALIDE
|
||||
void compileHalide()
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
@@ -623,8 +602,8 @@ struct Net::Impl
|
||||
CV_Assert(preferableBackend == DNN_BACKEND_HALIDE);
|
||||
|
||||
HalideScheduler scheduler(halideConfigFile);
|
||||
MapIdToLayerData::iterator it;
|
||||
for (it = layers.begin(); it != layers.end(); ++it)
|
||||
std::vector< std::reference_wrapper<LayerData> > compileList; compileList.reserve(64);
|
||||
for (MapIdToLayerData::iterator it = layers.begin(); it != layers.end(); ++it)
|
||||
{
|
||||
LayerData &ld = it->second;
|
||||
Ptr<Layer> layer = ld.layerInstance;
|
||||
@@ -639,10 +618,30 @@ struct Net::Impl
|
||||
ld.inputBlobs, ld.outputBlobs,
|
||||
preferableTarget);
|
||||
}
|
||||
compileList.emplace_back(ld);
|
||||
}
|
||||
}
|
||||
parallel_for_(Range(0, layers.size()), HalideCompiler(layers, preferableTarget));
|
||||
std::atomic<int> progress(0);
|
||||
auto fn = ([&] () -> void
|
||||
{
|
||||
for (;;)
|
||||
{
|
||||
int id = progress.fetch_add(1);
|
||||
if ((size_t)id >= compileList.size())
|
||||
return;
|
||||
const LayerData& ld = compileList[id].get();
|
||||
Ptr<BackendNode> node = ld.backendNodes.find(DNN_BACKEND_HALIDE)->second;
|
||||
dnn::compileHalide(ld.outputBlobs, node, preferableTarget);
|
||||
}
|
||||
});
|
||||
size_t num_threads = std::min(compileList.size(), (size_t)std::thread::hardware_concurrency());
|
||||
num_threads = std::max((size_t)1u, std::min((size_t)8u, num_threads));
|
||||
std::vector<std::thread> threads(num_threads - 1);
|
||||
for (auto& t: threads) t = std::thread(fn);
|
||||
fn(); // process own tasks
|
||||
for (auto& t: threads) t.join();
|
||||
}
|
||||
#endif
|
||||
|
||||
void clear()
|
||||
{
|
||||
@@ -692,10 +691,12 @@ struct Net::Impl
|
||||
|
||||
if (!netWasAllocated )
|
||||
{
|
||||
// If user didn't call compileHalide() between
|
||||
// setPreferableBackend(DNN_BACKEND_HALIDE) and forward().
|
||||
#ifdef HAVE_HALIDE
|
||||
if (preferableBackend == DNN_BACKEND_HALIDE)
|
||||
compileHalide();
|
||||
#else
|
||||
CV_Assert(preferableBackend != DNN_BACKEND_HALIDE);
|
||||
#endif
|
||||
}
|
||||
|
||||
netWasAllocated = true;
|
||||
|
||||
@@ -92,11 +92,11 @@ void initializeLayerFactory()
|
||||
CV_DNN_REGISTER_LAYER_CLASS(InnerProduct, InnerProductLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(Softmax, SoftmaxLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(MVN, MVNLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(LPNormalize, LPNormalizeLayer);
|
||||
|
||||
CV_DNN_REGISTER_LAYER_CLASS(ReLU, ReLULayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(ReLU6, ReLU6Layer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(ChannelsPReLU, ChannelsPReLULayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(PReLU, ChannelsPReLULayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(Sigmoid, SigmoidLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(TanH, TanHLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(ELU, ELULayer);
|
||||
@@ -113,6 +113,8 @@ void initializeLayerFactory()
|
||||
CV_DNN_REGISTER_LAYER_CLASS(Eltwise, EltwiseLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(Permute, PermuteLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(PriorBox, PriorBoxLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(Reorg, ReorgLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(Region, RegionLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(DetectionOutput, DetectionOutputLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(NormalizeBBox, NormalizeBBoxLayer);
|
||||
CV_DNN_REGISTER_LAYER_CLASS(Normalize, NormalizeBBoxLayer);
|
||||
|
||||
@@ -81,6 +81,8 @@ public:
|
||||
|
||||
float _nmsThreshold;
|
||||
int _topK;
|
||||
// Whenever predicted bounding boxes are respresented in YXHW instead of XYWH layout.
|
||||
bool _locPredTransposed;
|
||||
|
||||
enum { _numAxes = 4 };
|
||||
static const std::string _layerName;
|
||||
@@ -148,6 +150,7 @@ public:
|
||||
_keepTopK = getParameter<int>(params, "keep_top_k");
|
||||
_confidenceThreshold = getParameter<float>(params, "confidence_threshold", 0, false, -FLT_MAX);
|
||||
_topK = getParameter<int>(params, "top_k", 0, false, -1);
|
||||
_locPredTransposed = getParameter<bool>(params, "loc_pred_transposed", 0, false, false);
|
||||
|
||||
getCodeType(params);
|
||||
|
||||
@@ -209,7 +212,7 @@ public:
|
||||
// Retrieve all location predictions
|
||||
std::vector<LabelBBox> allLocationPredictions;
|
||||
GetLocPredictions(locationData, num, numPriors, _numLocClasses,
|
||||
_shareLocation, allLocationPredictions);
|
||||
_shareLocation, _locPredTransposed, allLocationPredictions);
|
||||
|
||||
// Retrieve all confidences
|
||||
GetConfidenceScores(confidenceData, num, numPriors, _numClasses, allConfidenceScores);
|
||||
@@ -540,11 +543,14 @@ public:
|
||||
// num_loc_classes: number of location classes. It is 1 if share_location is
|
||||
// true; and is equal to number of classes needed to predict otherwise.
|
||||
// share_location: if true, all classes share the same location prediction.
|
||||
// loc_pred_transposed: if true, represent four bounding box values as
|
||||
// [y,x,height,width] or [x,y,width,height] otherwise.
|
||||
// loc_preds: stores the location prediction, where each item contains
|
||||
// location prediction for an image.
|
||||
static void GetLocPredictions(const float* locData, const int num,
|
||||
const int numPredsPerClass, const int numLocClasses,
|
||||
const bool shareLocation, std::vector<LabelBBox>& locPreds)
|
||||
const bool shareLocation, const bool locPredTransposed,
|
||||
std::vector<LabelBBox>& locPreds)
|
||||
{
|
||||
locPreds.clear();
|
||||
if (shareLocation)
|
||||
@@ -566,10 +572,20 @@ public:
|
||||
labelBBox[label].resize(numPredsPerClass);
|
||||
}
|
||||
caffe::NormalizedBBox& bbox = labelBBox[label][p];
|
||||
bbox.set_xmin(locData[startIdx + c * 4]);
|
||||
bbox.set_ymin(locData[startIdx + c * 4 + 1]);
|
||||
bbox.set_xmax(locData[startIdx + c * 4 + 2]);
|
||||
bbox.set_ymax(locData[startIdx + c * 4 + 3]);
|
||||
if (locPredTransposed)
|
||||
{
|
||||
bbox.set_ymin(locData[startIdx + c * 4]);
|
||||
bbox.set_xmin(locData[startIdx + c * 4 + 1]);
|
||||
bbox.set_ymax(locData[startIdx + c * 4 + 2]);
|
||||
bbox.set_xmax(locData[startIdx + c * 4 + 3]);
|
||||
}
|
||||
else
|
||||
{
|
||||
bbox.set_xmin(locData[startIdx + c * 4]);
|
||||
bbox.set_ymin(locData[startIdx + c * 4 + 1]);
|
||||
bbox.set_xmax(locData[startIdx + c * 4 + 2]);
|
||||
bbox.set_ymax(locData[startIdx + c * 4 + 3]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -754,8 +754,15 @@ Ptr<PowerLayer> PowerLayer::create(const LayerParams& params)
|
||||
return l;
|
||||
}
|
||||
|
||||
Ptr<ChannelsPReLULayer> ChannelsPReLULayer::create(const LayerParams& params)
|
||||
Ptr<Layer> ChannelsPReLULayer::create(const LayerParams& params)
|
||||
{
|
||||
CV_Assert(params.blobs.size() == 1);
|
||||
if (params.blobs[0].total() == 1)
|
||||
{
|
||||
LayerParams reluParams = params;
|
||||
reluParams.set("negative_slope", params.blobs[0].at<float>(0));
|
||||
return ReLULayer::create(reluParams);
|
||||
}
|
||||
Ptr<ChannelsPReLULayer> l(new ElementWiseLayer<ChannelsPReLUFunctor>(ChannelsPReLUFunctor(params.blobs[0])));
|
||||
l->setParamsFrom(params);
|
||||
|
||||
|
||||
@@ -122,7 +122,7 @@ public:
|
||||
int channels;
|
||||
size_t planeSize;
|
||||
|
||||
EltwiseInvoker() : srcs(0), nsrcs(0), dst(0), coeffs(0), op(EltwiseLayer::PROD), nstripes(0), activ(0) {}
|
||||
EltwiseInvoker() : srcs(0), nsrcs(0), dst(0), coeffs(0), op(EltwiseLayer::PROD), nstripes(0), activ(0), channels(0), planeSize(0) {}
|
||||
|
||||
static void run(const Mat** srcs, int nsrcs, Mat& dst,
|
||||
const std::vector<float>& coeffs, EltwiseOp op,
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
// 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) 2017, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
|
||||
#include "../precomp.hpp"
|
||||
#include "layers_common.hpp"
|
||||
#include <iostream>
|
||||
namespace cv { namespace dnn {
|
||||
|
||||
class LPNormalizeLayerImpl : public LPNormalizeLayer
|
||||
{
|
||||
public:
|
||||
|
||||
LPNormalizeLayerImpl(const LayerParams& params)
|
||||
{
|
||||
setParamsFrom(params);
|
||||
pnorm = params.get<float>("p", 2);
|
||||
epsilon = params.get<float>("eps", 1e-10f);
|
||||
CV_Assert(pnorm > 0);
|
||||
}
|
||||
|
||||
bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
||||
const int requiredOutputs,
|
||||
std::vector<MatShape> &outputs,
|
||||
std::vector<MatShape> &internals) const
|
||||
{
|
||||
Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
|
||||
if (pnorm != 1 && pnorm != 2)
|
||||
{
|
||||
internals.resize(1, inputs[0]);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool supportBackend(int backendId)
|
||||
{
|
||||
return backendId == DNN_BACKEND_DEFAULT;
|
||||
}
|
||||
|
||||
void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
|
||||
CV_Assert(inputs[0]->total() == outputs[0].total());
|
||||
float norm;
|
||||
if (pnorm == 1)
|
||||
norm = cv::norm(*inputs[0], NORM_L1);
|
||||
else if (pnorm == 2)
|
||||
norm = cv::norm(*inputs[0], NORM_L2);
|
||||
else
|
||||
{
|
||||
cv::pow(abs(*inputs[0]), pnorm, internals[0]);
|
||||
norm = pow((float)sum(internals[0])[0], 1.0f / pnorm);
|
||||
}
|
||||
multiply(*inputs[0], 1.0f / (norm + epsilon), outputs[0]);
|
||||
}
|
||||
|
||||
int64 getFLOPS(const std::vector<MatShape> &inputs,
|
||||
const std::vector<MatShape> &) const
|
||||
{
|
||||
int64 flops = 0;
|
||||
for (int i = 0; i < inputs.size(); i++)
|
||||
flops += 3 * total(inputs[i]);
|
||||
return flops;
|
||||
}
|
||||
};
|
||||
|
||||
Ptr<LPNormalizeLayer> LPNormalizeLayer::create(const LayerParams& params)
|
||||
{
|
||||
return Ptr<LPNormalizeLayer>(new LPNormalizeLayerImpl(params));
|
||||
}
|
||||
|
||||
} // namespace dnn
|
||||
} // namespace cv
|
||||
@@ -43,83 +43,18 @@
|
||||
#include "../precomp.hpp"
|
||||
#include "layers_common.hpp"
|
||||
|
||||
#include <float.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace dnn
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
const std::string layerName = "NormalizeBBox";
|
||||
}
|
||||
namespace cv { namespace dnn {
|
||||
|
||||
class NormalizeBBoxLayerImpl : public NormalizeBBoxLayer
|
||||
{
|
||||
float _eps;
|
||||
bool _across_spatial;
|
||||
bool _channel_shared;
|
||||
public:
|
||||
bool getParameterDict(const LayerParams ¶ms,
|
||||
const std::string ¶meterName,
|
||||
DictValue& result)
|
||||
NormalizeBBoxLayerImpl(const LayerParams& params)
|
||||
{
|
||||
if (!params.has(parameterName))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
result = params.get(parameterName);
|
||||
return true;
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
T getParameter(const LayerParams ¶ms,
|
||||
const std::string ¶meterName,
|
||||
const size_t &idx=0,
|
||||
const bool required=true,
|
||||
const T& defaultValue=T())
|
||||
{
|
||||
DictValue dictValue;
|
||||
bool success = getParameterDict(params, parameterName, dictValue);
|
||||
if(!success)
|
||||
{
|
||||
if(required)
|
||||
{
|
||||
std::string message = layerName;
|
||||
message += " layer parameter does not contain ";
|
||||
message += parameterName;
|
||||
message += " parameter.";
|
||||
CV_Error(Error::StsBadArg, message);
|
||||
}
|
||||
else
|
||||
{
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
return dictValue.get<T>(idx);
|
||||
}
|
||||
|
||||
NormalizeBBoxLayerImpl(const LayerParams ¶ms)
|
||||
{
|
||||
_eps = getParameter<float>(params, "eps", 0, false, 1e-10f);
|
||||
_across_spatial = getParameter<bool>(params, "across_spatial");
|
||||
_channel_shared = getParameter<bool>(params, "channel_shared");
|
||||
setParamsFrom(params);
|
||||
}
|
||||
|
||||
void checkInputs(const std::vector<Mat*> &inputs)
|
||||
{
|
||||
CV_Assert(inputs.size() > 0);
|
||||
CV_Assert(inputs[0]->dims == 4 && inputs[0]->type() == CV_32F);
|
||||
for (size_t i = 1; i < inputs.size(); i++)
|
||||
{
|
||||
CV_Assert(inputs[i]->dims == 4 && inputs[i]->type() == CV_32F);
|
||||
CV_Assert(inputs[i]->size == inputs[0]->size);
|
||||
}
|
||||
CV_Assert(inputs[0]->dims > 2);
|
||||
pnorm = params.get<float>("p", 2);
|
||||
epsilon = params.get<float>("eps", 1e-10f);
|
||||
acrossSpatial = params.get<bool>("across_spatial", true);
|
||||
CV_Assert(pnorm > 0);
|
||||
}
|
||||
|
||||
bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
||||
@@ -127,17 +62,11 @@ public:
|
||||
std::vector<MatShape> &outputs,
|
||||
std::vector<MatShape> &internals) const
|
||||
{
|
||||
bool inplace = Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
|
||||
size_t channels = inputs[0][1];
|
||||
size_t rows = inputs[0][2];
|
||||
size_t cols = inputs[0][3];
|
||||
size_t channelSize = rows * cols;
|
||||
|
||||
internals.assign(1, shape(channels, channelSize));
|
||||
internals.push_back(shape(channels, 1));
|
||||
internals.push_back(shape(1, channelSize));
|
||||
|
||||
return inplace;
|
||||
CV_Assert(inputs.size() == 1);
|
||||
Layer::getMemoryShapes(inputs, requiredOutputs, outputs, internals);
|
||||
internals.resize(1, inputs[0]);
|
||||
internals[0][0] = 1; // Batch size.
|
||||
return true;
|
||||
}
|
||||
|
||||
void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
|
||||
@@ -145,60 +74,46 @@ public:
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
|
||||
checkInputs(inputs);
|
||||
|
||||
Mat& buffer = internals[0], sumChannelMultiplier = internals[1],
|
||||
sumSpatialMultiplier = internals[2];
|
||||
|
||||
sumChannelMultiplier.setTo(1.0);
|
||||
sumSpatialMultiplier.setTo(1.0);
|
||||
CV_Assert(inputs.size() == 1 && outputs.size() == 1);
|
||||
CV_Assert(inputs[0]->total() == outputs[0].total());
|
||||
|
||||
const Mat& inp0 = *inputs[0];
|
||||
Mat& buffer = internals[0];
|
||||
size_t num = inp0.size[0];
|
||||
size_t channels = inp0.size[1];
|
||||
size_t channelSize = inp0.size[2] * inp0.size[3];
|
||||
|
||||
Mat zeroBuffer(channels, channelSize, CV_32F, Scalar(0));
|
||||
Mat absDiff;
|
||||
Mat scale = blobs[0];
|
||||
for (size_t j = 0; j < inputs.size(); j++)
|
||||
size_t channelSize = inp0.total() / (num * channels);
|
||||
for (size_t n = 0; n < num; ++n)
|
||||
{
|
||||
for (size_t n = 0; n < num; ++n)
|
||||
Mat src = Mat(channels, channelSize, CV_32F, (void*)inp0.ptr<float>(n));
|
||||
Mat dst = Mat(channels, channelSize, CV_32F, (void*)outputs[0].ptr<float>(n));
|
||||
|
||||
cv::pow(abs(src), pnorm, buffer);
|
||||
|
||||
if (acrossSpatial)
|
||||
{
|
||||
Mat src = Mat(channels, channelSize, CV_32F, inputs[j]->ptr<float>(n));
|
||||
Mat dst = Mat(channels, channelSize, CV_32F, outputs[j].ptr<float>(n));
|
||||
// add eps to avoid overflow
|
||||
float absSum = sum(buffer)[0] + epsilon;
|
||||
float norm = pow(absSum, 1.0f / pnorm);
|
||||
multiply(src, 1.0f / norm, dst);
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat norm;
|
||||
reduce(buffer, norm, 0, REDUCE_SUM);
|
||||
norm += epsilon;
|
||||
|
||||
buffer = src.mul(src);
|
||||
// compute inverted norm to call multiply instead divide
|
||||
cv::pow(norm, -1.0f / pnorm, norm);
|
||||
|
||||
if (_across_spatial)
|
||||
{
|
||||
absdiff(buffer, zeroBuffer, absDiff);
|
||||
|
||||
// add eps to avoid overflow
|
||||
double absSum = sum(absDiff)[0] + _eps;
|
||||
|
||||
float norm = sqrt(absSum);
|
||||
dst = src / norm;
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat norm(channelSize, 1, buffer.type()); // 1 x channelSize
|
||||
|
||||
// (_channels x channelSize)T * _channels x 1 -> channelSize x 1
|
||||
gemm(buffer, sumChannelMultiplier, 1, norm, 0, norm, GEMM_1_T);
|
||||
|
||||
// compute norm
|
||||
pow(norm, 0.5f, norm);
|
||||
|
||||
// scale the layer
|
||||
// _channels x 1 * (channelSize x 1)T -> _channels x channelSize
|
||||
gemm(sumChannelMultiplier, norm, 1, buffer, 0, buffer, GEMM_2_T);
|
||||
|
||||
dst = src / buffer;
|
||||
}
|
||||
repeat(norm, channels, 1, buffer);
|
||||
multiply(src, buffer, dst);
|
||||
}
|
||||
|
||||
if (!blobs.empty())
|
||||
{
|
||||
// scale the output
|
||||
if (_channel_shared)
|
||||
Mat scale = blobs[0];
|
||||
if (scale.total() == 1)
|
||||
{
|
||||
// _scale: 1 x 1
|
||||
dst *= scale.at<float>(0, 0);
|
||||
@@ -206,15 +121,13 @@ public:
|
||||
else
|
||||
{
|
||||
// _scale: _channels x 1
|
||||
// _channels x 1 * 1 x channelSize -> _channels x channelSize
|
||||
gemm(scale, sumSpatialMultiplier, 1, buffer, 0, buffer);
|
||||
|
||||
dst = dst.mul(buffer);
|
||||
CV_Assert(scale.total() == channels);
|
||||
repeat(scale, 1, dst.cols, buffer);
|
||||
multiply(dst, buffer, dst);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -124,6 +124,20 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
void getScales(const LayerParams ¶ms)
|
||||
{
|
||||
DictValue scalesParameter;
|
||||
bool scalesRetieved = getParameterDict(params, "scales", scalesParameter);
|
||||
if (scalesRetieved)
|
||||
{
|
||||
_scales.resize(scalesParameter.size());
|
||||
for (int i = 0; i < scalesParameter.size(); ++i)
|
||||
{
|
||||
_scales[i] = scalesParameter.get<float>(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void getVariance(const LayerParams ¶ms)
|
||||
{
|
||||
DictValue varianceParameter;
|
||||
@@ -169,13 +183,14 @@ public:
|
||||
_flip = getParameter<bool>(params, "flip");
|
||||
_clip = getParameter<bool>(params, "clip");
|
||||
|
||||
_scales.clear();
|
||||
_aspectRatios.clear();
|
||||
_aspectRatios.push_back(1.);
|
||||
|
||||
getAspectRatios(params);
|
||||
getVariance(params);
|
||||
getScales(params);
|
||||
|
||||
_numPriors = _aspectRatios.size();
|
||||
_numPriors = _aspectRatios.size() + 1; // + 1 for an aspect ratio 1.0
|
||||
|
||||
_maxSize = -1;
|
||||
if (params.has("max_size"))
|
||||
@@ -201,6 +216,14 @@ public:
|
||||
_stepY = 0;
|
||||
_stepX = 0;
|
||||
}
|
||||
if(params.has("additional_y_offset"))
|
||||
{
|
||||
_additional_y_offset = getParameter<bool>(params, "additional_y_offset");
|
||||
if(_additional_y_offset)
|
||||
_numPriors *= 2;
|
||||
}
|
||||
else
|
||||
_additional_y_offset = false;
|
||||
}
|
||||
|
||||
bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
||||
@@ -231,6 +254,12 @@ public:
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
|
||||
size_t real_numPriors = _additional_y_offset ? _numPriors / 2 : _numPriors;
|
||||
if (_scales.empty())
|
||||
_scales.resize(real_numPriors, 1.0f);
|
||||
else
|
||||
CV_Assert(_scales.size() == real_numPriors);
|
||||
|
||||
int _layerWidth = inputs[0]->size[3];
|
||||
int _layerHeight = inputs[0]->size[2];
|
||||
|
||||
@@ -256,7 +285,7 @@ public:
|
||||
{
|
||||
for (size_t w = 0; w < _layerWidth; ++w)
|
||||
{
|
||||
_boxWidth = _boxHeight = _minSize;
|
||||
_boxWidth = _boxHeight = _minSize * _scales[0];
|
||||
|
||||
float center_x = (w + 0.5) * stepX;
|
||||
float center_y = (h + 0.5) * stepY;
|
||||
@@ -269,10 +298,23 @@ public:
|
||||
// ymax
|
||||
outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
|
||||
|
||||
if(_additional_y_offset)
|
||||
{
|
||||
float center_y_offset_1 = (h + 1.0) * stepY;
|
||||
// xmin
|
||||
outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
|
||||
// ymin
|
||||
outputPtr[idx++] = (center_y_offset_1 - _boxHeight / 2.) / _imageHeight;
|
||||
// xmax
|
||||
outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
|
||||
// ymax
|
||||
outputPtr[idx++] = (center_y_offset_1 + _boxHeight / 2.) / _imageHeight;
|
||||
}
|
||||
|
||||
if (_maxSize > 0)
|
||||
{
|
||||
// second prior: aspect_ratio = 1, size = sqrt(min_size * max_size)
|
||||
_boxWidth = _boxHeight = sqrt(_minSize * _maxSize);
|
||||
_boxWidth = _boxHeight = sqrt(_minSize * _maxSize) * _scales[1];
|
||||
// xmin
|
||||
outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
|
||||
// ymin
|
||||
@@ -281,18 +323,29 @@ public:
|
||||
outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
|
||||
// ymax
|
||||
outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
|
||||
|
||||
if(_additional_y_offset)
|
||||
{
|
||||
float center_y_offset_1 = (h + 1.0) * stepY;
|
||||
// xmin
|
||||
outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
|
||||
// ymin
|
||||
outputPtr[idx++] = (center_y_offset_1 - _boxHeight / 2.) / _imageHeight;
|
||||
// xmax
|
||||
outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
|
||||
// ymax
|
||||
outputPtr[idx++] = (center_y_offset_1 + _boxHeight / 2.) / _imageHeight;
|
||||
}
|
||||
}
|
||||
|
||||
// rest of priors
|
||||
CV_Assert((_maxSize > 0 ? 2 : 1) + _aspectRatios.size() == _scales.size());
|
||||
for (size_t r = 0; r < _aspectRatios.size(); ++r)
|
||||
{
|
||||
float ar = _aspectRatios[r];
|
||||
if (fabs(ar - 1.) < 1e-6)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
_boxWidth = _minSize * sqrt(ar);
|
||||
_boxHeight = _minSize / sqrt(ar);
|
||||
float scale = _scales[(_maxSize > 0 ? 2 : 1) + r];
|
||||
_boxWidth = _minSize * sqrt(ar) * scale;
|
||||
_boxHeight = _minSize / sqrt(ar) * scale;
|
||||
// xmin
|
||||
outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
|
||||
// ymin
|
||||
@@ -301,6 +354,18 @@ public:
|
||||
outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
|
||||
// ymax
|
||||
outputPtr[idx++] = (center_y + _boxHeight / 2.) / _imageHeight;
|
||||
if(_additional_y_offset)
|
||||
{
|
||||
float center_y_offset_1 = (h + 1.0) * stepY;
|
||||
// xmin
|
||||
outputPtr[idx++] = (center_x - _boxWidth / 2.) / _imageWidth;
|
||||
// ymin
|
||||
outputPtr[idx++] = (center_y_offset_1 - _boxHeight / 2.) / _imageHeight;
|
||||
// xmax
|
||||
outputPtr[idx++] = (center_x + _boxWidth / 2.) / _imageWidth;
|
||||
// ymax
|
||||
outputPtr[idx++] = (center_y_offset_1 + _boxHeight / 2.) / _imageHeight;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -363,9 +428,11 @@ public:
|
||||
|
||||
std::vector<float> _aspectRatios;
|
||||
std::vector<float> _variance;
|
||||
std::vector<float> _scales;
|
||||
|
||||
bool _flip;
|
||||
bool _clip;
|
||||
bool _additional_y_offset;
|
||||
|
||||
size_t _numPriors;
|
||||
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
/*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) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Copyright (C) 2017, Intel Corporation, 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/dnn/shape_utils.hpp>
|
||||
#include <opencv2/dnn/all_layers.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace dnn
|
||||
{
|
||||
|
||||
class RegionLayerImpl : public RegionLayer
|
||||
{
|
||||
public:
|
||||
int coords, classes, anchors, classfix;
|
||||
float thresh, nmsThreshold;
|
||||
bool useSoftmaxTree, useSoftmax;
|
||||
|
||||
RegionLayerImpl(const LayerParams& params)
|
||||
{
|
||||
setParamsFrom(params);
|
||||
CV_Assert(blobs.size() == 1);
|
||||
|
||||
thresh = params.get<float>("thresh", 0.2);
|
||||
coords = params.get<int>("coords", 4);
|
||||
classes = params.get<int>("classes", 0);
|
||||
anchors = params.get<int>("anchors", 5);
|
||||
classfix = params.get<int>("classfix", 0);
|
||||
useSoftmaxTree = params.get<bool>("softmax_tree", false);
|
||||
useSoftmax = params.get<bool>("softmax", false);
|
||||
nmsThreshold = params.get<float>("nms_threshold", 0.4);
|
||||
|
||||
CV_Assert(nmsThreshold >= 0.);
|
||||
CV_Assert(coords == 4);
|
||||
CV_Assert(classes >= 1);
|
||||
CV_Assert(anchors >= 1);
|
||||
CV_Assert(useSoftmaxTree || useSoftmax);
|
||||
}
|
||||
|
||||
bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
||||
const int requiredOutputs,
|
||||
std::vector<MatShape> &outputs,
|
||||
std::vector<MatShape> &internals) const
|
||||
{
|
||||
CV_Assert(inputs.size() > 0);
|
||||
CV_Assert(inputs[0][3] == (1 + coords + classes)*anchors);
|
||||
outputs = std::vector<MatShape>(inputs.size(), shape(inputs[0][1] * inputs[0][2] * anchors, inputs[0][3] / anchors));
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool supportBackend(int backendId)
|
||||
{
|
||||
return backendId == DNN_BACKEND_DEFAULT;
|
||||
}
|
||||
|
||||
float logistic_activate(float x) { return 1.F / (1.F + exp(-x)); }
|
||||
|
||||
void softmax_activate(const float* input, const int n, const float temp, float* output)
|
||||
{
|
||||
int i;
|
||||
float sum = 0;
|
||||
float largest = -FLT_MAX;
|
||||
for (i = 0; i < n; ++i) {
|
||||
if (input[i] > largest) largest = input[i];
|
||||
}
|
||||
for (i = 0; i < n; ++i) {
|
||||
float e = exp((input[i] - largest) / temp);
|
||||
sum += e;
|
||||
output[i] = e;
|
||||
}
|
||||
for (i = 0; i < n; ++i) {
|
||||
output[i] /= sum;
|
||||
}
|
||||
}
|
||||
|
||||
void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
|
||||
CV_Assert(inputs.size() >= 1);
|
||||
int const cell_size = classes + coords + 1;
|
||||
|
||||
const float* biasData = blobs[0].ptr<float>();
|
||||
|
||||
for (size_t ii = 0; ii < outputs.size(); ii++)
|
||||
{
|
||||
Mat &inpBlob = *inputs[ii];
|
||||
Mat &outBlob = outputs[ii];
|
||||
|
||||
int rows = inpBlob.size[1];
|
||||
int cols = inpBlob.size[2];
|
||||
|
||||
const float *srcData = inpBlob.ptr<float>();
|
||||
float *dstData = outBlob.ptr<float>();
|
||||
|
||||
// logistic activation for t0, for each grid cell (X x Y x Anchor-index)
|
||||
for (int i = 0; i < rows*cols*anchors; ++i) {
|
||||
int index = cell_size*i;
|
||||
float x = srcData[index + 4];
|
||||
dstData[index + 4] = logistic_activate(x); // logistic activation
|
||||
}
|
||||
|
||||
if (useSoftmaxTree) { // Yolo 9000
|
||||
CV_Error(cv::Error::StsNotImplemented, "Yolo9000 is not implemented");
|
||||
}
|
||||
else if (useSoftmax) { // Yolo v2
|
||||
// softmax activation for Probability, for each grid cell (X x Y x Anchor-index)
|
||||
for (int i = 0; i < rows*cols*anchors; ++i) {
|
||||
int index = cell_size*i;
|
||||
softmax_activate(srcData + index + 5, classes, 1, dstData + index + 5);
|
||||
}
|
||||
|
||||
for (int x = 0; x < cols; ++x)
|
||||
for(int y = 0; y < rows; ++y)
|
||||
for (int a = 0; a < anchors; ++a) {
|
||||
int index = (y*cols + x)*anchors + a; // index for each grid-cell & anchor
|
||||
int p_index = index * cell_size + 4;
|
||||
float scale = dstData[p_index];
|
||||
if (classfix == -1 && scale < .5) scale = 0; // if(t0 < 0.5) t0 = 0;
|
||||
int box_index = index * cell_size;
|
||||
|
||||
dstData[box_index + 0] = (x + logistic_activate(srcData[box_index + 0])) / cols;
|
||||
dstData[box_index + 1] = (y + logistic_activate(srcData[box_index + 1])) / rows;
|
||||
dstData[box_index + 2] = exp(srcData[box_index + 2]) * biasData[2 * a] / cols;
|
||||
dstData[box_index + 3] = exp(srcData[box_index + 3]) * biasData[2 * a + 1] / rows;
|
||||
|
||||
int class_index = index * cell_size + 5;
|
||||
|
||||
if (useSoftmaxTree) {
|
||||
CV_Error(cv::Error::StsNotImplemented, "Yolo9000 is not implemented");
|
||||
}
|
||||
else {
|
||||
for (int j = 0; j < classes; ++j) {
|
||||
float prob = scale*dstData[class_index + j]; // prob = IoU(box, object) = t0 * class-probability
|
||||
dstData[class_index + j] = (prob > thresh) ? prob : 0; // if (IoU < threshold) IoU = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nmsThreshold > 0) {
|
||||
do_nms_sort(dstData, rows*cols*anchors, nmsThreshold);
|
||||
//do_nms(dstData, rows*cols*anchors, nmsThreshold);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct box {
|
||||
float x, y, w, h;
|
||||
float *probs;
|
||||
};
|
||||
|
||||
float overlap(float x1, float w1, float x2, float w2)
|
||||
{
|
||||
float l1 = x1 - w1 / 2;
|
||||
float l2 = x2 - w2 / 2;
|
||||
float left = l1 > l2 ? l1 : l2;
|
||||
float r1 = x1 + w1 / 2;
|
||||
float r2 = x2 + w2 / 2;
|
||||
float right = r1 < r2 ? r1 : r2;
|
||||
return right - left;
|
||||
}
|
||||
|
||||
float box_intersection(box a, box b)
|
||||
{
|
||||
float w = overlap(a.x, a.w, b.x, b.w);
|
||||
float h = overlap(a.y, a.h, b.y, b.h);
|
||||
if (w < 0 || h < 0) return 0;
|
||||
float area = w*h;
|
||||
return area;
|
||||
}
|
||||
|
||||
float box_union(box a, box b)
|
||||
{
|
||||
float i = box_intersection(a, b);
|
||||
float u = a.w*a.h + b.w*b.h - i;
|
||||
return u;
|
||||
}
|
||||
|
||||
float box_iou(box a, box b)
|
||||
{
|
||||
return box_intersection(a, b) / box_union(a, b);
|
||||
}
|
||||
|
||||
struct sortable_bbox {
|
||||
int index;
|
||||
float *probs;
|
||||
};
|
||||
|
||||
struct nms_comparator {
|
||||
int k;
|
||||
nms_comparator(int _k) : k(_k) {}
|
||||
bool operator ()(sortable_bbox v1, sortable_bbox v2) {
|
||||
return v2.probs[k] < v1.probs[k];
|
||||
}
|
||||
};
|
||||
|
||||
void do_nms_sort(float *detections, int total, float nms_thresh)
|
||||
{
|
||||
std::vector<box> boxes(total);
|
||||
for (int i = 0; i < total; ++i) {
|
||||
box &b = boxes[i];
|
||||
int box_index = i * (classes + coords + 1);
|
||||
b.x = detections[box_index + 0];
|
||||
b.y = detections[box_index + 1];
|
||||
b.w = detections[box_index + 2];
|
||||
b.h = detections[box_index + 3];
|
||||
int class_index = i * (classes + 5) + 5;
|
||||
b.probs = (detections + class_index);
|
||||
}
|
||||
|
||||
std::vector<sortable_bbox> s(total);
|
||||
|
||||
for (int i = 0; i < total; ++i) {
|
||||
s[i].index = i;
|
||||
int class_index = i * (classes + 5) + 5;
|
||||
s[i].probs = (detections + class_index);
|
||||
}
|
||||
|
||||
for (int k = 0; k < classes; ++k) {
|
||||
std::stable_sort(s.begin(), s.end(), nms_comparator(k));
|
||||
for (int i = 0; i < total; ++i) {
|
||||
if (boxes[s[i].index].probs[k] == 0) continue;
|
||||
box a = boxes[s[i].index];
|
||||
for (int j = i + 1; j < total; ++j) {
|
||||
box b = boxes[s[j].index];
|
||||
if (box_iou(a, b) > nms_thresh) {
|
||||
boxes[s[j].index].probs[k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void do_nms(float *detections, int total, float nms_thresh)
|
||||
{
|
||||
std::vector<box> boxes(total);
|
||||
for (int i = 0; i < total; ++i) {
|
||||
box &b = boxes[i];
|
||||
int box_index = i * (classes + coords + 1);
|
||||
b.x = detections[box_index + 0];
|
||||
b.y = detections[box_index + 1];
|
||||
b.w = detections[box_index + 2];
|
||||
b.h = detections[box_index + 3];
|
||||
int class_index = i * (classes + 5) + 5;
|
||||
b.probs = (detections + class_index);
|
||||
}
|
||||
|
||||
for (int i = 0; i < total; ++i) {
|
||||
bool any = false;
|
||||
for (int k = 0; k < classes; ++k) any = any || (boxes[i].probs[k] > 0);
|
||||
if (!any) {
|
||||
continue;
|
||||
}
|
||||
for (int j = i + 1; j < total; ++j) {
|
||||
if (box_iou(boxes[i], boxes[j]) > nms_thresh) {
|
||||
for (int k = 0; k < classes; ++k) {
|
||||
if (boxes[i].probs[k] < boxes[j].probs[k]) boxes[i].probs[k] = 0;
|
||||
else boxes[j].probs[k] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
|
||||
const std::vector<MatShape> &outputs) const
|
||||
{
|
||||
(void)outputs; // suppress unused variable warning
|
||||
|
||||
int64 flops = 0;
|
||||
for(int i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
flops += 60*total(inputs[i]);
|
||||
}
|
||||
return flops;
|
||||
}
|
||||
};
|
||||
|
||||
Ptr<RegionLayer> RegionLayer::create(const LayerParams& params)
|
||||
{
|
||||
return Ptr<RegionLayer>(new RegionLayerImpl(params));
|
||||
}
|
||||
|
||||
} // namespace dnn
|
||||
} // namespace cv
|
||||
@@ -0,0 +1,140 @@
|
||||
/*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) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Copyright (C) 2017, Intel Corporation, 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/dnn/shape_utils.hpp>
|
||||
#include <opencv2/dnn/all_layers.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
namespace dnn
|
||||
{
|
||||
|
||||
class ReorgLayerImpl : public ReorgLayer
|
||||
{
|
||||
int reorgStride;
|
||||
public:
|
||||
|
||||
ReorgLayerImpl(const LayerParams& params)
|
||||
{
|
||||
setParamsFrom(params);
|
||||
|
||||
reorgStride = params.get<int>("reorg_stride", 2);
|
||||
CV_Assert(reorgStride > 0);
|
||||
}
|
||||
|
||||
bool getMemoryShapes(const std::vector<MatShape> &inputs,
|
||||
const int requiredOutputs,
|
||||
std::vector<MatShape> &outputs,
|
||||
std::vector<MatShape> &internals) const
|
||||
{
|
||||
CV_Assert(inputs.size() > 0);
|
||||
outputs = std::vector<MatShape>(inputs.size(), shape(
|
||||
inputs[0][0],
|
||||
inputs[0][1] * reorgStride * reorgStride,
|
||||
inputs[0][2] / reorgStride,
|
||||
inputs[0][3] / reorgStride));
|
||||
|
||||
CV_Assert(outputs[0][0] > 0 && outputs[0][1] > 0 && outputs[0][2] > 0 && outputs[0][3] > 0);
|
||||
CV_Assert(total(outputs[0]) == total(inputs[0]));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool supportBackend(int backendId)
|
||||
{
|
||||
return backendId == DNN_BACKEND_DEFAULT;
|
||||
}
|
||||
void forward(std::vector<Mat*> &inputs, std::vector<Mat> &outputs, std::vector<Mat> &internals)
|
||||
{
|
||||
CV_TRACE_FUNCTION();
|
||||
CV_TRACE_ARG_VALUE(name, "name", name.c_str());
|
||||
|
||||
for (size_t i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
Mat srcBlob = *inputs[i];
|
||||
MatShape inputShape = shape(srcBlob), outShape = shape(outputs[i]);
|
||||
float *dstData = outputs[0].ptr<float>();
|
||||
const float *srcData = srcBlob.ptr<float>();
|
||||
|
||||
int channels = inputShape[1], height = inputShape[2], width = inputShape[3];
|
||||
|
||||
int out_c = channels / (reorgStride*reorgStride);
|
||||
|
||||
for (int k = 0; k < channels; ++k) {
|
||||
for (int j = 0; j < height; ++j) {
|
||||
for (int i = 0; i < width; ++i) {
|
||||
int out_index = i + width*(j + height*k);
|
||||
int c2 = k % out_c;
|
||||
int offset = k / out_c;
|
||||
int w2 = i*reorgStride + offset % reorgStride;
|
||||
int h2 = j*reorgStride + offset / reorgStride;
|
||||
int in_index = w2 + width*reorgStride*(h2 + height*reorgStride*c2);
|
||||
dstData[out_index] = srcData[in_index];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
virtual int64 getFLOPS(const std::vector<MatShape> &inputs,
|
||||
const std::vector<MatShape> &outputs) const
|
||||
{
|
||||
(void)outputs; // suppress unused variable warning
|
||||
|
||||
int64 flops = 0;
|
||||
for(int i = 0; i < inputs.size(); i++)
|
||||
{
|
||||
flops += 21*total(inputs[i]);
|
||||
}
|
||||
return flops;
|
||||
}
|
||||
};
|
||||
|
||||
Ptr<ReorgLayer> ReorgLayer::create(const LayerParams& params)
|
||||
{
|
||||
return Ptr<ReorgLayer>(new ReorgLayerImpl(params));
|
||||
}
|
||||
|
||||
} // namespace dnn
|
||||
} // namespace cv
|
||||
@@ -100,6 +100,7 @@ public:
|
||||
config.in_shape = shape(*inputs[0]);
|
||||
config.axis = axisRaw;
|
||||
config.channels = inputs[0]->size[axisRaw];
|
||||
config.logsoftmax = logSoftMax;
|
||||
|
||||
softmaxOp = Ptr<OCL4DNNSoftmax<float> >(new OCL4DNNSoftmax<float>(config));
|
||||
}
|
||||
@@ -108,7 +109,7 @@ public:
|
||||
srcMat = inputs[0]->getUMat(ACCESS_READ);
|
||||
dstMat = outputs[0].getUMat(ACCESS_WRITE);
|
||||
|
||||
if (!logSoftMax && softmaxOp->Forward(srcMat, dstMat))
|
||||
if (softmaxOp->Forward(srcMat, dstMat))
|
||||
return true;
|
||||
|
||||
const Mat &src = *inputs[0];
|
||||
|
||||
@@ -445,11 +445,12 @@ class OCL4DNNLRN
|
||||
|
||||
struct OCL4DNNSoftmaxConfig
|
||||
{
|
||||
OCL4DNNSoftmaxConfig() : axis(0), channels(0)
|
||||
OCL4DNNSoftmaxConfig() : axis(0), channels(0), logsoftmax(false)
|
||||
{}
|
||||
MatShape in_shape;
|
||||
int axis;
|
||||
int channels;
|
||||
bool logsoftmax;
|
||||
};
|
||||
|
||||
template<typename Dtype>
|
||||
@@ -467,6 +468,7 @@ class OCL4DNNSoftmax
|
||||
int32_t channels_;
|
||||
int32_t count_;
|
||||
bool use_slm_;
|
||||
bool log_softmax_;
|
||||
UMat scale_data_;
|
||||
};
|
||||
#endif // HAVE_OPENCL
|
||||
|
||||
@@ -890,7 +890,7 @@ float OCL4DNNConvSpatial<float>::timedConvolve(const UMat &bottom, UMat &top,
|
||||
return 1e5;
|
||||
}
|
||||
|
||||
float elapsedTime = timer.milliSeconds() / loop_cnt;
|
||||
float elapsedTime = timer.durationNS() * 1e-6 / loop_cnt;
|
||||
#ifdef dbg
|
||||
double out_w = output_w_;
|
||||
double out_h = output_h_;
|
||||
@@ -899,9 +899,9 @@ float OCL4DNNConvSpatial<float>::timedConvolve(const UMat &bottom, UMat &top,
|
||||
double k_h = kernel_h_;
|
||||
double k_z = channels_;
|
||||
double totalFlops = ((k_w*k_h*k_z -1)*2)*(out_w*out_h*out_z)*num_;
|
||||
std::cout << "\tEstimated Gflops:" << ((totalFlops/1000)/1000)/1000
|
||||
std::cout << "\tEstimated Gflops:" << (totalFlops * 1e-9)
|
||||
<< std::endl;
|
||||
std::cout << "\tEstimated GFLOPS/S: " << (((totalFlops/1000)/1000)/1000)*(1000.0/elapsedTime)
|
||||
std::cout << "\tEstimated GFLOPS/S: " << ((totalFlops * 1e-9)*(1000.0/elapsedTime))
|
||||
<< std::endl;
|
||||
#if 0
|
||||
std::cout << "Estimated utilization: " <<
|
||||
|
||||
@@ -52,6 +52,7 @@ OCL4DNNSoftmax<Dtype>::OCL4DNNSoftmax(OCL4DNNSoftmaxConfig config)
|
||||
{
|
||||
softmax_axis_ = config.axis;
|
||||
channels_ = config.channels;
|
||||
log_softmax_ = config.logsoftmax;
|
||||
|
||||
inner_num_ = 1;
|
||||
outer_num_ = 1;
|
||||
@@ -90,6 +91,7 @@ bool OCL4DNNSoftmax<Dtype>::Forward(const UMat& bottom, UMat& top)
|
||||
String kname;
|
||||
ocl::Kernel oclk_softmax_forward_kernel;
|
||||
|
||||
if (log_softmax_) opts += " -DLOG_SOFTMAX ";
|
||||
if (use_slm_)
|
||||
kname = CL_KERNEL_SELECT("softmax_forward_slm");
|
||||
else
|
||||
|
||||
@@ -112,7 +112,11 @@ __kernel void TEMPLATE(softmax_forward_slm,Dtype)(const int num, const int chann
|
||||
for (int index = get_global_id(0); index < channels * spatial_dim;
|
||||
index += get_global_size(0)) {
|
||||
int s = index % spatial_dim;
|
||||
out[n * channels * spatial_dim + index] = out_tmp[index] / scale_tmp[s];
|
||||
Dtype v = out_tmp[index] / scale_tmp[s];
|
||||
#ifdef LOG_SOFTMAX
|
||||
v = log(v);
|
||||
#endif
|
||||
out[n * channels * spatial_dim + index] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -177,6 +181,10 @@ __kernel void TEMPLATE(softmax_forward,Dtype)(const int num, const int channels,
|
||||
for (int index = get_global_id(0); index < channels * spatial_dim;
|
||||
index += get_global_size(0)) {
|
||||
int s = index % spatial_dim;
|
||||
out[n * channels * spatial_dim + index] /= scale[n * spatial_dim + s];
|
||||
Dtype v = out[n * channels * spatial_dim + index] / scale[n * spatial_dim + s];
|
||||
#ifdef LOG_SOFTMAX
|
||||
v = log(v);
|
||||
#endif
|
||||
out[n * channels * spatial_dim + index] = v;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -321,10 +321,10 @@ DictValue parseDims(const tensorflow::TensorProto &tensor) {
|
||||
CV_Assert(tensor.dtype() == tensorflow::DT_INT32);
|
||||
CV_Assert(dims == 1);
|
||||
|
||||
int size = tensor.tensor_content().size() / sizeof(int);
|
||||
const int *data = reinterpret_cast<const int*>(tensor.tensor_content().c_str());
|
||||
Mat values = getTensorContent(tensor);
|
||||
CV_Assert(values.type() == CV_32SC1);
|
||||
// TODO: add reordering shape if dims == 4
|
||||
return DictValue::arrayInt(data, size);
|
||||
return DictValue::arrayInt((int*)values.data, values.total());
|
||||
}
|
||||
|
||||
void setKSize(LayerParams &layerParams, const tensorflow::NodeDef &layer)
|
||||
@@ -448,7 +448,7 @@ void ExcludeLayer(tensorflow::GraphDef& net, const int layer_index, const int in
|
||||
|
||||
class TFImporter : public Importer {
|
||||
public:
|
||||
TFImporter(const char *model);
|
||||
TFImporter(const char *model, const char *config = NULL);
|
||||
void populateNet(Net dstNet);
|
||||
~TFImporter() {}
|
||||
|
||||
@@ -463,13 +463,20 @@ private:
|
||||
int input_blob_index = -1, int* actual_inp_blob_idx = 0);
|
||||
|
||||
|
||||
tensorflow::GraphDef net;
|
||||
// Binary serialized TensorFlow graph includes weights.
|
||||
tensorflow::GraphDef netBin;
|
||||
// Optional text definition of TensorFlow graph. More flexible than binary format
|
||||
// and may be used to build the network using binary format only as a weights storage.
|
||||
// This approach is similar to Caffe's `.prorotxt` and `.caffemodel`.
|
||||
tensorflow::GraphDef netTxt;
|
||||
};
|
||||
|
||||
TFImporter::TFImporter(const char *model)
|
||||
TFImporter::TFImporter(const char *model, const char *config)
|
||||
{
|
||||
if (model && model[0])
|
||||
ReadTFNetParamsFromBinaryFileOrDie(model, &net);
|
||||
ReadTFNetParamsFromBinaryFileOrDie(model, &netBin);
|
||||
if (config && config[0])
|
||||
ReadTFNetParamsFromTextFileOrDie(config, &netTxt);
|
||||
}
|
||||
|
||||
void TFImporter::kernelFromTensor(const tensorflow::TensorProto &tensor, Mat &dstBlob)
|
||||
@@ -557,21 +564,23 @@ const tensorflow::TensorProto& TFImporter::getConstBlob(const tensorflow::NodeDe
|
||||
*actual_inp_blob_idx = input_blob_index;
|
||||
}
|
||||
|
||||
return net.node(const_layers.at(kernel_inp.name)).attr().at("value").tensor();
|
||||
int nodeIdx = const_layers.at(kernel_inp.name);
|
||||
if (nodeIdx < netBin.node_size() && netBin.node(nodeIdx).name() == kernel_inp.name)
|
||||
{
|
||||
return netBin.node(nodeIdx).attr().at("value").tensor();
|
||||
}
|
||||
else
|
||||
{
|
||||
CV_Assert(nodeIdx < netTxt.node_size(),
|
||||
netTxt.node(nodeIdx).name() == kernel_inp.name);
|
||||
return netTxt.node(nodeIdx).attr().at("value").tensor();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void TFImporter::populateNet(Net dstNet)
|
||||
static void addConstNodes(const tensorflow::GraphDef& net, std::map<String, int>& const_layers,
|
||||
std::set<String>& layers_to_ignore)
|
||||
{
|
||||
RemoveIdentityOps(net);
|
||||
|
||||
std::map<int, String> layers_to_ignore;
|
||||
|
||||
int layersSize = net.node_size();
|
||||
|
||||
// find all Const layers for params
|
||||
std::map<String, int> value_id;
|
||||
for (int li = 0; li < layersSize; li++)
|
||||
for (int li = 0; li < net.node_size(); li++)
|
||||
{
|
||||
const tensorflow::NodeDef &layer = net.node(li);
|
||||
String name = layer.name();
|
||||
@@ -582,11 +591,27 @@ void TFImporter::populateNet(Net dstNet)
|
||||
|
||||
if (layer.attr().find("value") != layer.attr().end())
|
||||
{
|
||||
value_id.insert(std::make_pair(name, li));
|
||||
CV_Assert(const_layers.insert(std::make_pair(name, li)).second);
|
||||
}
|
||||
|
||||
layers_to_ignore[li] = name;
|
||||
layers_to_ignore.insert(name);
|
||||
}
|
||||
}
|
||||
|
||||
void TFImporter::populateNet(Net dstNet)
|
||||
{
|
||||
RemoveIdentityOps(netBin);
|
||||
RemoveIdentityOps(netTxt);
|
||||
|
||||
std::set<String> layers_to_ignore;
|
||||
|
||||
tensorflow::GraphDef& net = netTxt.ByteSize() != 0 ? netTxt : netBin;
|
||||
|
||||
int layersSize = net.node_size();
|
||||
|
||||
// find all Const layers for params
|
||||
std::map<String, int> value_id;
|
||||
addConstNodes(netBin, value_id, layers_to_ignore);
|
||||
addConstNodes(netTxt, value_id, layers_to_ignore);
|
||||
|
||||
std::map<String, int> layer_id;
|
||||
|
||||
@@ -597,7 +622,7 @@ void TFImporter::populateNet(Net dstNet)
|
||||
String type = layer.op();
|
||||
LayerParams layerParams;
|
||||
|
||||
if(layers_to_ignore.find(li) != layers_to_ignore.end())
|
||||
if(layers_to_ignore.find(name) != layers_to_ignore.end())
|
||||
continue;
|
||||
|
||||
if (type == "Conv2D" || type == "SpaceToBatchND" || type == "DepthwiseConv2dNative")
|
||||
@@ -627,7 +652,7 @@ void TFImporter::populateNet(Net dstNet)
|
||||
StrIntVector next_layers = getNextLayers(net, name, "Conv2D");
|
||||
CV_Assert(next_layers.size() == 1);
|
||||
layer = net.node(next_layers[0].second);
|
||||
layers_to_ignore[next_layers[0].second] = next_layers[0].first;
|
||||
layers_to_ignore.insert(next_layers[0].first);
|
||||
name = layer.name();
|
||||
type = layer.op();
|
||||
}
|
||||
@@ -644,7 +669,7 @@ void TFImporter::populateNet(Net dstNet)
|
||||
|
||||
blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs[1]);
|
||||
ExcludeLayer(net, weights_layer_index, 0, false);
|
||||
layers_to_ignore[weights_layer_index] = next_layers[0].first;
|
||||
layers_to_ignore.insert(next_layers[0].first);
|
||||
}
|
||||
|
||||
kernelFromTensor(getConstBlob(layer, value_id), layerParams.blobs[0]);
|
||||
@@ -684,7 +709,7 @@ void TFImporter::populateNet(Net dstNet)
|
||||
layerParams.set("pad_mode", ""); // We use padding values.
|
||||
CV_Assert(next_layers.size() == 1);
|
||||
ExcludeLayer(net, next_layers[0].second, 0, false);
|
||||
layers_to_ignore[next_layers[0].second] = next_layers[0].first;
|
||||
layers_to_ignore.insert(next_layers[0].first);
|
||||
}
|
||||
|
||||
int id = dstNet.addLayer(name, "Convolution", layerParams);
|
||||
@@ -748,7 +773,7 @@ void TFImporter::populateNet(Net dstNet)
|
||||
int weights_layer_index = next_layers[0].second;
|
||||
blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs[1]);
|
||||
ExcludeLayer(net, weights_layer_index, 0, false);
|
||||
layers_to_ignore[weights_layer_index] = next_layers[0].first;
|
||||
layers_to_ignore.insert(next_layers[0].first);
|
||||
}
|
||||
|
||||
int kernel_blob_index = -1;
|
||||
@@ -778,6 +803,30 @@ void TFImporter::populateNet(Net dstNet)
|
||||
// one input only
|
||||
connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
|
||||
}
|
||||
else if (type == "Flatten")
|
||||
{
|
||||
int id = dstNet.addLayer(name, "Flatten", layerParams);
|
||||
layer_id[name] = id;
|
||||
connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
|
||||
}
|
||||
else if (type == "Transpose")
|
||||
{
|
||||
Mat perm = getTensorContent(getConstBlob(layer, value_id, 1));
|
||||
CV_Assert(perm.type() == CV_32SC1);
|
||||
int* permData = (int*)perm.data;
|
||||
if (perm.total() == 4)
|
||||
{
|
||||
for (int i = 0; i < 4; ++i)
|
||||
permData[i] = toNCHW[permData[i]];
|
||||
}
|
||||
layerParams.set("order", DictValue::arrayInt<int*>(permData, perm.total()));
|
||||
|
||||
int id = dstNet.addLayer(name, "Permute", layerParams);
|
||||
layer_id[name] = id;
|
||||
|
||||
// one input only
|
||||
connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
|
||||
}
|
||||
else if (type == "Const")
|
||||
{
|
||||
}
|
||||
@@ -807,7 +856,7 @@ void TFImporter::populateNet(Net dstNet)
|
||||
{
|
||||
int axisId = (type == "Concat" ? 0 : layer.input_size() - 1);
|
||||
int axis = getConstBlob(layer, value_id, axisId).int_val().Get(0);
|
||||
layerParams.set("axis", toNCHW[axis]);
|
||||
layerParams.set("axis", 0 <= axis && axis < 4 ? toNCHW[axis] : axis);
|
||||
|
||||
int id = dstNet.addLayer(name, "Concat", layerParams);
|
||||
layer_id[name] = id;
|
||||
@@ -929,6 +978,19 @@ void TFImporter::populateNet(Net dstNet)
|
||||
else // is a vector
|
||||
{
|
||||
layerParams.blobs.resize(1, scaleMat);
|
||||
|
||||
StrIntVector next_layers = getNextLayers(net, name, "Add");
|
||||
if (!next_layers.empty())
|
||||
{
|
||||
layerParams.set("bias_term", true);
|
||||
layerParams.blobs.resize(2);
|
||||
|
||||
int weights_layer_index = next_layers[0].second;
|
||||
blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs.back());
|
||||
ExcludeLayer(net, weights_layer_index, 0, false);
|
||||
layers_to_ignore.insert(next_layers[0].first);
|
||||
}
|
||||
|
||||
id = dstNet.addLayer(name, "Scale", layerParams);
|
||||
}
|
||||
layer_id[name] = id;
|
||||
@@ -1037,7 +1099,7 @@ void TFImporter::populateNet(Net dstNet)
|
||||
|
||||
blobFromTensor(getConstBlob(net.node(weights_layer_index), value_id), layerParams.blobs[1]);
|
||||
ExcludeLayer(net, weights_layer_index, 0, false);
|
||||
layers_to_ignore[weights_layer_index] = next_layers[0].first;
|
||||
layers_to_ignore.insert(next_layers[0].first);
|
||||
}
|
||||
|
||||
kernelFromTensor(getConstBlob(layer, value_id, 1), layerParams.blobs[0]);
|
||||
@@ -1148,6 +1210,71 @@ void TFImporter::populateNet(Net dstNet)
|
||||
|
||||
connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
|
||||
}
|
||||
else if (type == "PriorBox")
|
||||
{
|
||||
if (hasLayerAttr(layer, "min_size"))
|
||||
layerParams.set("min_size", getLayerAttr(layer, "min_size").i());
|
||||
if (hasLayerAttr(layer, "max_size"))
|
||||
layerParams.set("max_size", getLayerAttr(layer, "max_size").i());
|
||||
if (hasLayerAttr(layer, "flip"))
|
||||
layerParams.set("flip", getLayerAttr(layer, "flip").b());
|
||||
if (hasLayerAttr(layer, "clip"))
|
||||
layerParams.set("clip", getLayerAttr(layer, "clip").b());
|
||||
if (hasLayerAttr(layer, "offset"))
|
||||
layerParams.set("offset", getLayerAttr(layer, "offset").f());
|
||||
if (hasLayerAttr(layer, "variance"))
|
||||
{
|
||||
Mat variance = getTensorContent(getLayerAttr(layer, "variance").tensor());
|
||||
layerParams.set("variance",
|
||||
DictValue::arrayReal<float*>((float*)variance.data, variance.total()));
|
||||
}
|
||||
if (hasLayerAttr(layer, "aspect_ratio"))
|
||||
{
|
||||
Mat aspectRatios = getTensorContent(getLayerAttr(layer, "aspect_ratio").tensor());
|
||||
layerParams.set("aspect_ratio",
|
||||
DictValue::arrayReal<float*>((float*)aspectRatios.data, aspectRatios.total()));
|
||||
}
|
||||
if (hasLayerAttr(layer, "scales"))
|
||||
{
|
||||
Mat scales = getTensorContent(getLayerAttr(layer, "scales").tensor());
|
||||
layerParams.set("scales",
|
||||
DictValue::arrayReal<float*>((float*)scales.data, scales.total()));
|
||||
}
|
||||
int id = dstNet.addLayer(name, "PriorBox", layerParams);
|
||||
layer_id[name] = id;
|
||||
connect(layer_id, dstNet, parsePin(layer.input(0)), id, 0);
|
||||
connect(layer_id, dstNet, parsePin(layer.input(1)), id, 1);
|
||||
}
|
||||
else if (type == "DetectionOutput")
|
||||
{
|
||||
// op: "DetectionOutput"
|
||||
// input_0: "locations"
|
||||
// input_1: "classifications"
|
||||
// input_2: "prior_boxes"
|
||||
if (hasLayerAttr(layer, "num_classes"))
|
||||
layerParams.set("num_classes", getLayerAttr(layer, "num_classes").i());
|
||||
if (hasLayerAttr(layer, "share_location"))
|
||||
layerParams.set("share_location", getLayerAttr(layer, "share_location").b());
|
||||
if (hasLayerAttr(layer, "background_label_id"))
|
||||
layerParams.set("background_label_id", getLayerAttr(layer, "background_label_id").i());
|
||||
if (hasLayerAttr(layer, "nms_threshold"))
|
||||
layerParams.set("nms_threshold", getLayerAttr(layer, "nms_threshold").f());
|
||||
if (hasLayerAttr(layer, "top_k"))
|
||||
layerParams.set("top_k", getLayerAttr(layer, "top_k").i());
|
||||
if (hasLayerAttr(layer, "code_type"))
|
||||
layerParams.set("code_type", getLayerAttr(layer, "code_type").s());
|
||||
if (hasLayerAttr(layer, "keep_top_k"))
|
||||
layerParams.set("keep_top_k", getLayerAttr(layer, "keep_top_k").i());
|
||||
if (hasLayerAttr(layer, "confidence_threshold"))
|
||||
layerParams.set("confidence_threshold", getLayerAttr(layer, "confidence_threshold").f());
|
||||
if (hasLayerAttr(layer, "loc_pred_transposed"))
|
||||
layerParams.set("loc_pred_transposed", getLayerAttr(layer, "loc_pred_transposed").b());
|
||||
|
||||
int id = dstNet.addLayer(name, "DetectionOutput", layerParams);
|
||||
layer_id[name] = id;
|
||||
for (int i = 0; i < 3; ++i)
|
||||
connect(layer_id, dstNet, parsePin(layer.input(i)), id, i);
|
||||
}
|
||||
else if (type == "Abs" || type == "Tanh" || type == "Sigmoid" ||
|
||||
type == "Relu" || type == "Elu" || type == "Softmax" ||
|
||||
type == "Identity" || type == "Relu6")
|
||||
@@ -1188,9 +1315,9 @@ Ptr<Importer> createTensorflowImporter(const String&)
|
||||
|
||||
#endif //HAVE_PROTOBUF
|
||||
|
||||
Net readNetFromTensorflow(const String &model)
|
||||
Net readNetFromTensorflow(const String &model, const String &config)
|
||||
{
|
||||
TFImporter importer(model.c_str());
|
||||
TFImporter importer(model.c_str(), config.c_str());
|
||||
Net net;
|
||||
importer.populateNet(net);
|
||||
return net;
|
||||
|
||||
@@ -52,12 +52,27 @@ bool ReadProtoFromBinaryFileTF(const char* filename, Message* proto) {
|
||||
return success;
|
||||
}
|
||||
|
||||
bool ReadProtoFromTextFileTF(const char* filename, Message* proto) {
|
||||
std::ifstream fs(filename, std::ifstream::in);
|
||||
CHECK(fs.is_open()) << "Can't open \"" << filename << "\"";
|
||||
IstreamInputStream input(&fs);
|
||||
bool success = google::protobuf::TextFormat::Parse(&input, proto);
|
||||
fs.close();
|
||||
return success;
|
||||
}
|
||||
|
||||
void ReadTFNetParamsFromBinaryFileOrDie(const char* param_file,
|
||||
tensorflow::GraphDef* param) {
|
||||
CHECK(ReadProtoFromBinaryFileTF(param_file, param))
|
||||
<< "Failed to parse GraphDef file: " << param_file;
|
||||
}
|
||||
|
||||
void ReadTFNetParamsFromTextFileOrDie(const char* param_file,
|
||||
tensorflow::GraphDef* param) {
|
||||
CHECK(ReadProtoFromTextFileTF(param_file, param))
|
||||
<< "Failed to parse GraphDef file: " << param_file;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -22,6 +22,9 @@ namespace dnn {
|
||||
void ReadTFNetParamsFromBinaryFileOrDie(const char* param_file,
|
||||
tensorflow::GraphDef* param);
|
||||
|
||||
void ReadTFNetParamsFromTextFileOrDie(const char* param_file,
|
||||
tensorflow::GraphDef* param);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -706,7 +706,7 @@ struct TorchImporter : public ::cv::dnn::Importer
|
||||
if (scalarParams.has("eps"))
|
||||
layerParams.set("eps", scalarParams.get<float>("eps"));
|
||||
|
||||
newModule->apiType = "LPNormalize";
|
||||
newModule->apiType = "Normalize";
|
||||
curModule->modules.push_back(newModule);
|
||||
}
|
||||
else if (nnName == "Padding")
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
/*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
|
||||
// (3-clause BSD License)
|
||||
//
|
||||
// Copyright (C) 2017, Intel Corporation, 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:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions 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.
|
||||
//
|
||||
// * Neither the names of the copyright holders nor the names of the contributors
|
||||
// may 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 copyright holders 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 "test_precomp.hpp"
|
||||
#include <opencv2/dnn/shape_utils.hpp>
|
||||
#include <algorithm>
|
||||
|
||||
namespace cvtest
|
||||
{
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::dnn;
|
||||
|
||||
template<typename TString>
|
||||
static std::string _tf(TString filename)
|
||||
{
|
||||
return (getOpenCVExtraDir() + "/dnn/") + filename;
|
||||
}
|
||||
|
||||
TEST(Test_Darknet, read_tiny_yolo_voc)
|
||||
{
|
||||
Net net = readNetFromDarknet(_tf("tiny-yolo-voc.cfg"));
|
||||
ASSERT_FALSE(net.empty());
|
||||
}
|
||||
|
||||
TEST(Test_Darknet, read_yolo_voc)
|
||||
{
|
||||
Net net = readNetFromDarknet(_tf("yolo-voc.cfg"));
|
||||
ASSERT_FALSE(net.empty());
|
||||
}
|
||||
|
||||
TEST(Reproducibility_TinyYoloVoc, Accuracy)
|
||||
{
|
||||
Net net;
|
||||
{
|
||||
const string cfg = findDataFile("dnn/tiny-yolo-voc.cfg", false);
|
||||
const string model = findDataFile("dnn/tiny-yolo-voc.weights", false);
|
||||
net = readNetFromDarknet(cfg, model);
|
||||
ASSERT_FALSE(net.empty());
|
||||
}
|
||||
|
||||
// dog416.png is dog.jpg that resized to 416x416 in the lossless PNG format
|
||||
Mat sample = imread(_tf("dog416.png"));
|
||||
ASSERT_TRUE(!sample.empty());
|
||||
|
||||
Size inputSize(416, 416);
|
||||
|
||||
if (sample.size() != inputSize)
|
||||
resize(sample, sample, inputSize);
|
||||
|
||||
net.setInput(blobFromImage(sample, 1 / 255.F), "data");
|
||||
Mat out = net.forward("detection_out");
|
||||
|
||||
Mat detection;
|
||||
const float confidenceThreshold = 0.24;
|
||||
|
||||
for (int i = 0; i < out.rows; i++) {
|
||||
const int probability_index = 5;
|
||||
const int probability_size = out.cols - probability_index;
|
||||
float *prob_array_ptr = &out.at<float>(i, probability_index);
|
||||
size_t objectClass = std::max_element(prob_array_ptr, prob_array_ptr + probability_size) - prob_array_ptr;
|
||||
float confidence = out.at<float>(i, (int)objectClass + probability_index);
|
||||
|
||||
if (confidence > confidenceThreshold)
|
||||
detection.push_back(out.row(i));
|
||||
}
|
||||
|
||||
// obtained by: ./darknet detector test ./cfg/voc.data ./cfg/tiny-yolo-voc.cfg ./tiny-yolo-voc.weights -thresh 0.24 ./dog416.png
|
||||
// There are 2 objects (6-car, 11-dog) with 25 values for each:
|
||||
// { relative_center_x, relative_center_y, relative_width, relative_height, unused_t0, probability_for_each_class[20] }
|
||||
float ref_array[] = {
|
||||
0.736762F, 0.239551F, 0.315440F, 0.160779F, 0.761977F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.761967F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
|
||||
0.287486F, 0.653731F, 0.315579F, 0.534527F, 0.782737F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.780595F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F
|
||||
};
|
||||
|
||||
const int number_of_objects = 2;
|
||||
Mat ref(number_of_objects, sizeof(ref_array) / (number_of_objects * sizeof(float)), CV_32FC1, &ref_array);
|
||||
|
||||
normAssert(ref, detection);
|
||||
}
|
||||
|
||||
TEST(Reproducibility_YoloVoc, Accuracy)
|
||||
{
|
||||
Net net;
|
||||
{
|
||||
const string cfg = findDataFile("dnn/yolo-voc.cfg", false);
|
||||
const string model = findDataFile("dnn/yolo-voc.weights", false);
|
||||
net = readNetFromDarknet(cfg, model);
|
||||
ASSERT_FALSE(net.empty());
|
||||
}
|
||||
|
||||
// dog416.png is dog.jpg that resized to 416x416 in the lossless PNG format
|
||||
Mat sample = imread(_tf("dog416.png"));
|
||||
ASSERT_TRUE(!sample.empty());
|
||||
|
||||
Size inputSize(416, 416);
|
||||
|
||||
if (sample.size() != inputSize)
|
||||
resize(sample, sample, inputSize);
|
||||
|
||||
net.setInput(blobFromImage(sample, 1 / 255.F), "data");
|
||||
Mat out = net.forward("detection_out");
|
||||
|
||||
Mat detection;
|
||||
const float confidenceThreshold = 0.24;
|
||||
|
||||
for (int i = 0; i < out.rows; i++) {
|
||||
const int probability_index = 5;
|
||||
const int probability_size = out.cols - probability_index;
|
||||
float *prob_array_ptr = &out.at<float>(i, probability_index);
|
||||
size_t objectClass = std::max_element(prob_array_ptr, prob_array_ptr + probability_size) - prob_array_ptr;
|
||||
float confidence = out.at<float>(i, (int)objectClass + probability_index);
|
||||
|
||||
if (confidence > confidenceThreshold)
|
||||
detection.push_back(out.row(i));
|
||||
}
|
||||
|
||||
// obtained by: ./darknet detector test ./cfg/voc.data ./cfg/yolo-voc.cfg ./yolo-voc.weights -thresh 0.24 ./dog416.png
|
||||
// There are 3 objects (6-car, 1-bicycle, 11-dog) with 25 values for each:
|
||||
// { relative_center_x, relative_center_y, relative_width, relative_height, unused_t0, probability_for_each_class[20] }
|
||||
float ref_array[] = {
|
||||
0.740161F, 0.214100F, 0.325575F, 0.173418F, 0.750769F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.750469F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
|
||||
0.501618F, 0.504757F, 0.461713F, 0.481310F, 0.783550F, 0.000000F, 0.780879F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
|
||||
0.279968F, 0.638651F, 0.282737F, 0.600284F, 0.901864F, 0.000000F, 0.000000F, 0.000000F, 0.000000F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.901615F,
|
||||
0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F, 0.000000F
|
||||
};
|
||||
|
||||
const int number_of_objects = 3;
|
||||
Mat ref(number_of_objects, sizeof(ref_array) / (number_of_objects * sizeof(float)), CV_32FC1, &ref_array);
|
||||
|
||||
normAssert(ref, detection);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Copyright (C) 2017, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
@@ -279,6 +279,11 @@ TEST(Layer_Test_Eltwise, Accuracy)
|
||||
testLayerUsingCaffeModels("layer_eltwise");
|
||||
}
|
||||
|
||||
TEST(Layer_Test_PReLU, Accuracy)
|
||||
{
|
||||
testLayerUsingCaffeModels("layer_prelu", DNN_TARGET_CPU, true);
|
||||
}
|
||||
|
||||
//template<typename XMat>
|
||||
//static void test_Layer_Concat()
|
||||
//{
|
||||
@@ -480,4 +485,36 @@ TEST_F(Layer_RNN_Test, get_set_test)
|
||||
EXPECT_EQ(shape(outputs[1]), shape(nT, nS, nH));
|
||||
}
|
||||
|
||||
void testLayerUsingDarknetModels(String basename, bool useDarknetModel = false, bool useCommonInputBlob = true)
|
||||
{
|
||||
String cfg = _tf(basename + ".cfg");
|
||||
String weights = _tf(basename + ".weights");
|
||||
|
||||
String inpfile = (useCommonInputBlob) ? _tf("blob.npy") : _tf(basename + ".input.npy");
|
||||
String outfile = _tf(basename + ".npy");
|
||||
|
||||
cv::setNumThreads(cv::getNumberOfCPUs());
|
||||
|
||||
Net net = readNetFromDarknet(cfg, (useDarknetModel) ? weights : String());
|
||||
ASSERT_FALSE(net.empty());
|
||||
|
||||
Mat inp = blobFromNPY(inpfile);
|
||||
Mat ref = blobFromNPY(outfile);
|
||||
|
||||
net.setInput(inp, "data");
|
||||
Mat out = net.forward();
|
||||
|
||||
normAssert(ref, out);
|
||||
}
|
||||
|
||||
TEST(Layer_Test_Region, Accuracy)
|
||||
{
|
||||
testLayerUsingDarknetModels("region", false, false);
|
||||
}
|
||||
|
||||
TEST(Layer_Test_Reorg, Accuracy)
|
||||
{
|
||||
testLayerUsingDarknetModels("reorg", false, false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -74,14 +74,15 @@ static std::string path(const std::string& file)
|
||||
return findDataFile("dnn/tensorflow/" + file, false);
|
||||
}
|
||||
|
||||
static void runTensorFlowNet(const std::string& prefix,
|
||||
static void runTensorFlowNet(const std::string& prefix, bool hasText = false,
|
||||
double l1 = 1e-5, double lInf = 1e-4)
|
||||
{
|
||||
std::string netPath = path(prefix + "_net.pb");
|
||||
std::string netConfig = (hasText ? path(prefix + "_net.pbtxt") : "");
|
||||
std::string inpPath = path(prefix + "_in.npy");
|
||||
std::string outPath = path(prefix + "_out.npy");
|
||||
|
||||
Net net = readNetFromTensorflow(netPath);
|
||||
Net net = readNetFromTensorflow(netPath, netConfig);
|
||||
|
||||
cv::Mat input = blobFromNPY(inpPath);
|
||||
cv::Mat target = blobFromNPY(outPath);
|
||||
@@ -120,6 +121,7 @@ TEST(Test_TensorFlow, batch_norm)
|
||||
{
|
||||
runTensorFlowNet("batch_norm");
|
||||
runTensorFlowNet("fused_batch_norm");
|
||||
runTensorFlowNet("batch_norm_text", true);
|
||||
}
|
||||
|
||||
TEST(Test_TensorFlow, pooling)
|
||||
@@ -148,26 +150,60 @@ TEST(Test_TensorFlow, reshape)
|
||||
{
|
||||
runTensorFlowNet("shift_reshape_no_reorder");
|
||||
runTensorFlowNet("reshape_reduce");
|
||||
runTensorFlowNet("flatten", true);
|
||||
}
|
||||
|
||||
TEST(Test_TensorFlow, fp16)
|
||||
{
|
||||
const float l1 = 1e-3;
|
||||
const float lInf = 1e-2;
|
||||
runTensorFlowNet("fp16_single_conv", l1, lInf);
|
||||
runTensorFlowNet("fp16_deconvolution", l1, lInf);
|
||||
runTensorFlowNet("fp16_max_pool_odd_same", l1, lInf);
|
||||
runTensorFlowNet("fp16_padding_valid", l1, lInf);
|
||||
runTensorFlowNet("fp16_eltwise_add_mul", l1, lInf);
|
||||
runTensorFlowNet("fp16_max_pool_odd_valid", l1, lInf);
|
||||
runTensorFlowNet("fp16_pad_and_concat", l1, lInf);
|
||||
runTensorFlowNet("fp16_max_pool_even", l1, lInf);
|
||||
runTensorFlowNet("fp16_padding_same", l1, lInf);
|
||||
runTensorFlowNet("fp16_single_conv", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_deconvolution", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_max_pool_odd_same", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_padding_valid", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_eltwise_add_mul", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_max_pool_odd_valid", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_pad_and_concat", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_max_pool_even", false, l1, lInf);
|
||||
runTensorFlowNet("fp16_padding_same", false, l1, lInf);
|
||||
}
|
||||
|
||||
TEST(Test_TensorFlow, MobileNet_SSD)
|
||||
{
|
||||
std::string netPath = findDataFile("dnn/ssd_mobilenet_v1_coco.pb", false);
|
||||
std::string netConfig = findDataFile("dnn/ssd_mobilenet_v1_coco.pbtxt", false);
|
||||
std::string imgPath = findDataFile("dnn/street.png", false);
|
||||
|
||||
Mat inp;
|
||||
resize(imread(imgPath), inp, Size(300, 300));
|
||||
inp = blobFromImage(inp, 1.0f / 127.5, Size(), Scalar(127.5, 127.5, 127.5), true);
|
||||
|
||||
std::vector<String> outNames(3);
|
||||
outNames[0] = "concat";
|
||||
outNames[1] = "concat_1";
|
||||
outNames[2] = "detection_out";
|
||||
|
||||
std::vector<Mat> target(outNames.size());
|
||||
for (int i = 0; i < outNames.size(); ++i)
|
||||
{
|
||||
std::string path = findDataFile("dnn/tensorflow/ssd_mobilenet_v1_coco." + outNames[i] + ".npy", false);
|
||||
target[i] = blobFromNPY(path);
|
||||
}
|
||||
|
||||
Net net = readNetFromTensorflow(netPath, netConfig);
|
||||
net.setInput(inp);
|
||||
|
||||
std::vector<Mat> output;
|
||||
net.forward(output, outNames);
|
||||
|
||||
normAssert(target[0].reshape(1, 1), output[0].reshape(1, 1));
|
||||
normAssert(target[1].reshape(1, 1), output[1].reshape(1, 1), "", 1e-5, 2e-4);
|
||||
normAssert(target[2].reshape(1, 1), output[2].reshape(1, 1), "", 4e-5, 1e-2);
|
||||
}
|
||||
|
||||
TEST(Test_TensorFlow, lstm)
|
||||
{
|
||||
runTensorFlowNet("lstm");
|
||||
runTensorFlowNet("lstm", true);
|
||||
}
|
||||
|
||||
TEST(Test_TensorFlow, split)
|
||||
|
||||
@@ -169,7 +169,7 @@ TEST(Torch_Importer, run_deconv)
|
||||
|
||||
TEST(Torch_Importer, run_batch_norm)
|
||||
{
|
||||
runTorchNet("net_batch_norm");
|
||||
runTorchNet("net_batch_norm", DNN_TARGET_CPU, "", false, true);
|
||||
}
|
||||
|
||||
TEST(Torch_Importer, net_prelu)
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
set(the_description "2D Features Framework")
|
||||
ocv_define_module(features2d opencv_imgproc opencv_flann OPTIONAL opencv_highgui WRAP java python)
|
||||
ocv_define_module(features2d opencv_imgproc OPTIONAL opencv_flann opencv_highgui WRAP java python)
|
||||
|
||||
@@ -43,8 +43,12 @@
|
||||
#ifndef OPENCV_FEATURES_2D_HPP
|
||||
#define OPENCV_FEATURES_2D_HPP
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
#include "opencv2/core.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
#include "opencv2/flann/miniflann.hpp"
|
||||
#endif
|
||||
|
||||
/**
|
||||
@defgroup features2d 2D Features Framework
|
||||
@@ -1099,6 +1103,7 @@ protected:
|
||||
bool crossCheck;
|
||||
};
|
||||
|
||||
#if defined(HAVE_OPENCV_FLANN) || defined(CV_DOXYGEN)
|
||||
|
||||
/** @brief Flann-based descriptor matcher.
|
||||
|
||||
@@ -1145,6 +1150,8 @@ protected:
|
||||
int addedDescCount;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//! @} features2d_match
|
||||
|
||||
/****************************************************************************************\
|
||||
|
||||
@@ -1005,11 +1005,14 @@ void BFMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vector<std::
|
||||
Ptr<DescriptorMatcher> DescriptorMatcher::create( const String& descriptorMatcherType )
|
||||
{
|
||||
Ptr<DescriptorMatcher> dm;
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
if( !descriptorMatcherType.compare( "FlannBased" ) )
|
||||
{
|
||||
dm = makePtr<FlannBasedMatcher>();
|
||||
}
|
||||
else if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2
|
||||
else
|
||||
#endif
|
||||
if( !descriptorMatcherType.compare( "BruteForce" ) ) // L2
|
||||
{
|
||||
dm = makePtr<BFMatcher>(int(NORM_L2)); // anonymous enums can't be template parameters
|
||||
}
|
||||
@@ -1044,9 +1047,11 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType)
|
||||
|
||||
switch(matcherType)
|
||||
{
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
case FLANNBASED:
|
||||
name = "FlannBased";
|
||||
break;
|
||||
#endif
|
||||
case BRUTEFORCE:
|
||||
name = "BruteForce";
|
||||
break;
|
||||
@@ -1071,6 +1076,7 @@ Ptr<DescriptorMatcher> DescriptorMatcher::create(int matcherType)
|
||||
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
|
||||
/*
|
||||
* Flann based matcher
|
||||
@@ -1419,4 +1425,7 @@ void FlannBasedMatcher::radiusMatchImpl( InputArray _queryDescriptors, std::vect
|
||||
|
||||
convertToDMatches( mergedDescriptors, indices, dists, matches );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
@@ -536,12 +536,14 @@ TEST( Features2d_DescriptorMatcher_BruteForce, regression )
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
TEST( Features2d_DescriptorMatcher_FlannBased, regression )
|
||||
{
|
||||
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based",
|
||||
DescriptorMatcher::create("FlannBased"), 0.04f );
|
||||
test.safe_run();
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST( Features2d_DMatch, read_write )
|
||||
{
|
||||
|
||||
@@ -49,7 +49,9 @@
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
using namespace cv::flann;
|
||||
#endif
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
class NearestNeighborTest : public cvtest::BaseTest
|
||||
@@ -158,6 +160,8 @@ void NearestNeighborTest::run( int /*start_from*/ ) {
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------
|
||||
#ifdef HAVE_OPENCV_FLANN
|
||||
|
||||
class CV_FlannTest : public NearestNeighborTest
|
||||
{
|
||||
public:
|
||||
@@ -331,3 +335,5 @@ TEST(Features2d_FLANN_KDTree, regression) { CV_FlannKDTreeIndexTest test; test.s
|
||||
TEST(Features2d_FLANN_Composite, regression) { CV_FlannCompositeIndexTest test; test.safe_run(); }
|
||||
TEST(Features2d_FLANN_Auto, regression) { CV_FlannAutotunedIndexTest test; test.safe_run(); }
|
||||
TEST(Features2d_FLANN_Saved, regression) { CV_FlannSavedIndexTest test; test.safe_run(); }
|
||||
|
||||
#endif
|
||||
|
||||
@@ -3015,6 +3015,7 @@ void DefaultViewPort::drawImgRegion(QPainter *painter)
|
||||
|
||||
|
||||
for (int j=-1;j<height()/pixel_height;j++)//-1 because display the pixels top rows left columns
|
||||
{
|
||||
for (int i=-1;i<width()/pixel_width;i++)//-1
|
||||
{
|
||||
// Calculate top left of the pixel's position in the viewport (screen space)
|
||||
@@ -3067,15 +3068,15 @@ void DefaultViewPort::drawImgRegion(QPainter *painter)
|
||||
Qt::AlignCenter, val);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
painter->setPen(QPen(Qt::black, 1));
|
||||
painter->drawLines(linesX.data(), linesX.size());
|
||||
painter->drawLines(linesY.data(), linesY.size());
|
||||
|
||||
//restore font size
|
||||
f.setPointSize(original_font_size);
|
||||
painter->setFont(f);
|
||||
painter->setPen(QPen(Qt::black, 1));
|
||||
painter->drawLines(linesX.data(), linesX.size());
|
||||
painter->drawLines(linesY.data(), linesY.size());
|
||||
|
||||
//restore font size
|
||||
f.setPointSize(original_font_size);
|
||||
painter->setFont(f);
|
||||
}
|
||||
|
||||
void DefaultViewPort::drawViewOverview(QPainter *painter)
|
||||
|
||||
@@ -118,7 +118,7 @@ bool BmpDecoder::readHeader()
|
||||
|
||||
if( m_bpp <= 8 )
|
||||
{
|
||||
CV_Assert(clrused <= 256);
|
||||
CV_Assert(clrused >= 0 && clrused <= 256);
|
||||
memset(m_palette, 0, sizeof(m_palette));
|
||||
m_strm.getBytes(m_palette, (clrused == 0? 1<<m_bpp : clrused)*4 );
|
||||
iscolor = IsColorPalette( m_palette, m_bpp );
|
||||
|
||||
@@ -562,7 +562,6 @@ ImageDecoder GdalDecoder::newDecoder()const{
|
||||
*/
|
||||
bool GdalDecoder::checkSignature( const String& signature )const{
|
||||
|
||||
|
||||
// look for NITF
|
||||
std::string str(signature);
|
||||
if( str.substr(0,4).find("NITF") != std::string::npos ){
|
||||
@@ -570,7 +569,7 @@ bool GdalDecoder::checkSignature( const String& signature )const{
|
||||
}
|
||||
|
||||
// look for DTED
|
||||
if( str.substr(140,4) == "DTED" ){
|
||||
if( str.size() > 144 && str.substr(140,4) == "DTED" ){
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -3920,9 +3920,8 @@ CV_EXPORTS_W double contourArea( InputArray contour, bool oriented = false );
|
||||
/** @brief Finds a rotated rectangle of the minimum area enclosing the input 2D point set.
|
||||
|
||||
The function calculates and returns the minimum-area bounding rectangle (possibly rotated) for a
|
||||
specified point set. See the OpenCV sample minarea.cpp . Developer should keep in mind that the
|
||||
returned rotatedRect can contain negative indices when data is close to the containing Mat element
|
||||
boundary.
|
||||
specified point set. Developer should keep in mind that the returned RotatedRect can contain negative
|
||||
indices when data is close to the containing Mat element boundary.
|
||||
|
||||
@param points Input vector of 2D points, stored in std::vector\<\> or Mat
|
||||
*/
|
||||
@@ -3943,8 +3942,7 @@ CV_EXPORTS_W void boxPoints(RotatedRect box, OutputArray points);
|
||||
|
||||
/** @brief Finds a circle of the minimum area enclosing a 2D point set.
|
||||
|
||||
The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm. See
|
||||
the OpenCV sample minarea.cpp .
|
||||
The function finds the minimal enclosing circle of a 2D point set using an iterative algorithm.
|
||||
|
||||
@param points Input vector of 2D points, stored in std::vector\<\> or Mat
|
||||
@param center Output center of the circle.
|
||||
|
||||
@@ -627,7 +627,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src
|
||||
|
||||
//! @cond IGNORED
|
||||
#define CALL_HAL_RET(name, fun, retval, ...) \
|
||||
int res = fun(__VA_ARGS__, &retval); \
|
||||
int res = __CV_EXPAND(fun(__VA_ARGS__, &retval)); \
|
||||
if (res == CV_HAL_ERROR_OK) \
|
||||
return retval; \
|
||||
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
|
||||
@@ -636,7 +636,7 @@ inline int hal_ni_integral(int depth, int sdepth, int sqdepth, const uchar * src
|
||||
|
||||
|
||||
#define CALL_HAL(name, fun, ...) \
|
||||
int res = fun(__VA_ARGS__); \
|
||||
int res = __CV_EXPAND(fun(__VA_ARGS__)); \
|
||||
if (res == CV_HAL_ERROR_OK) \
|
||||
return; \
|
||||
else if (res != CV_HAL_ERROR_NOT_IMPLEMENTED) \
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user