mirror of
https://github.com/opencv/opencv.git
synced 2026-07-25 13:23:02 +04:00
Compare commits
350 Commits
2.4.3.2
...
2.4.4-beta
| Author | SHA1 | Date | |
|---|---|---|---|
| b6e7aeabe0 | |||
| 3990564a83 | |||
| 2495b23a7d | |||
| 059ea5bebe | |||
| 54bcaa4934 | |||
| 80d760c96e | |||
| a370404d9c | |||
| 92e7e7d8e8 | |||
| 74e5650350 | |||
| 5cae645ba1 | |||
| b337d84adf | |||
| 9f9c333a26 | |||
| 7071bd63ab | |||
| 1869f77c0f | |||
| ffb3b5ddbe | |||
| 2ed6bc8aaf | |||
| 9d7300f003 | |||
| c61d7088ae | |||
| 5335c2f920 | |||
| d92a56ee2d | |||
| cc79f40e2b | |||
| 2a98c1f89c | |||
| 81832d76a8 | |||
| d067dc5a05 | |||
| 283b26e2db | |||
| 2075236757 | |||
| 716e0192b3 | |||
| 3ed6c09485 | |||
| 504264ab7b | |||
| 4045e6e588 | |||
| 46ca5c32cd | |||
| bb25111d23 | |||
| 4f4fe553bc | |||
| 571665b559 | |||
| 43d61d961e | |||
| e0ead7b606 | |||
| c7e7b77093 | |||
| 6ffd5edfb5 | |||
| 9591fb8f63 | |||
| 9a2d6f854b | |||
| 507e2dc0ad | |||
| b558bb4894 | |||
| 902463b6e9 | |||
| 08cd51df1f | |||
| b943277559 | |||
| 33502c86ac | |||
| 192ee15520 | |||
| 076941bb07 | |||
| 4d6827212d | |||
| 79d5724794 | |||
| 51e58aeb25 | |||
| f8720ec60e | |||
| 03f7d2f1ca | |||
| afe85e7e51 | |||
| 93d4abecf8 | |||
| 6e4aeff4c9 | |||
| 37d695a62e | |||
| b81f0887f0 | |||
| 4e243e1759 | |||
| 6645f50dd0 | |||
| 1120289fdb | |||
| 3ed99b7700 | |||
| ffb9da14fb | |||
| 60f056061a | |||
| 7882aba7af | |||
| 2e2e1355ac | |||
| bb3b1441c5 | |||
| bf575ba7fb | |||
| 7cdede0c55 | |||
| e31e924cf7 | |||
| fe0516c877 | |||
| 53e77ed468 | |||
| 568b935246 | |||
| 6b5eac328f | |||
| 3ef588b877 | |||
| f608df9640 | |||
| c0e3d48ebc | |||
| 7244fc1f6a | |||
| 727b6a7259 | |||
| 3c39e146a3 | |||
| d235c3a678 | |||
| 0b1599d88a | |||
| 9711ef6dee | |||
| 15d0484485 | |||
| c768731e89 | |||
| 9c939a8dcf | |||
| e58f4e44c8 | |||
| 650609aaeb | |||
| 6dc3b662f6 | |||
| 58c4d5f4b4 | |||
| fc4a2244fa | |||
| 37460acb21 | |||
| e2536f1c35 | |||
| a639a1ae5c | |||
| 3c5cb4931e | |||
| ac8744af6a | |||
| c8cad0857e | |||
| b79e8053c1 | |||
| b497380a68 | |||
| 2a669555de | |||
| 7e06b4755b | |||
| e7ea90f87f | |||
| 3154cdf8ac | |||
| bc68dfb4e8 | |||
| 0cd8684ade | |||
| db9de43fa5 | |||
| 6f1961031c | |||
| 87b0126e0d | |||
| 25086ed257 | |||
| 9e32c6993a | |||
| 013d54c230 | |||
| 51eba617a8 | |||
| b179e2dd2d | |||
| 992d47e9dc | |||
| 5ef58a474a | |||
| 0b6677f6d3 | |||
| 638c0d1bf4 | |||
| 57aa089ad6 | |||
| b24e4bddb1 | |||
| 7745c8806c | |||
| 098ea6fcb7 | |||
| 1becbd9fcc | |||
| 50299c1d5e | |||
| 18039d7829 | |||
| 39b4bf1828 | |||
| a8c014de33 | |||
| 13d2412d24 | |||
| 34ef209940 | |||
| 54e0765d80 | |||
| 7ca38d63d9 | |||
| 6de422701a | |||
| 92460adebe | |||
| 55b90d7bae | |||
| fe5b9df45f | |||
| 79e278c008 | |||
| ed4c687d45 | |||
| 82b6419d12 | |||
| e3b45910aa | |||
| e63b4591ff | |||
| 4f1913ed26 | |||
| abd9675a99 | |||
| acb2cb5bf0 | |||
| 53b0df87f1 | |||
| bf53ebd590 | |||
| b5ed86c6a1 | |||
| fe30da6e2c | |||
| fda32d3d8d | |||
| 50c2f87add | |||
| f3ae185fd0 | |||
| 2d6253609c | |||
| e0426148ba | |||
| 8b3c717e8f | |||
| e72c7736e7 | |||
| 9b4f2d1b53 | |||
| 33c26a93c6 | |||
| 5b03d47fb8 | |||
| 4ceb8dd149 | |||
| bc53a054f2 | |||
| 31d3c508db | |||
| 1f261c2f9d | |||
| f65a14d1ef | |||
| 5bc6365ba5 | |||
| f489eb9a5d | |||
| 26c7e7f292 | |||
| eaa5012163 | |||
| 11871528ce | |||
| c9d8e9900f | |||
| 6a29b13c45 | |||
| b362affd13 | |||
| 3c8787980c | |||
| 56fbcc541f | |||
| 3a55fb9d1b | |||
| 52b32ba8f0 | |||
| b6de1fccc3 | |||
| d7874238f6 | |||
| 62b9180c50 | |||
| 81f5e72630 | |||
| 8d9af7de61 | |||
| ae7460440e | |||
| 86b4b30a6d | |||
| 68be50bbab | |||
| e79e81c6cd | |||
| 6feade3110 | |||
| eeb865ee8a | |||
| 627b441022 | |||
| 7e5f877ad9 | |||
| d0350402de | |||
| 9ce2197e9d | |||
| 9690ed8232 | |||
| 82e325cbfa | |||
| 9908ff33de | |||
| 7305f955a5 | |||
| f9de98ec64 | |||
| 568591670c | |||
| 62ce815197 | |||
| b4d0dff4c5 | |||
| daa02aaa98 | |||
| c69312ea0d | |||
| 3dbb98e454 | |||
| c78cb21999 | |||
| 0b1fe53a46 | |||
| daead680cd | |||
| ab8d92e1b8 | |||
| 5021a792b1 | |||
| fe86f31f44 | |||
| 98fdd70466 | |||
| 287fb2c611 | |||
| 63873a8393 | |||
| 519e23bf0b | |||
| da884b4e1d | |||
| e7cbf65280 | |||
| 8c45b9d03d | |||
| 04f01ed21d | |||
| 11dfceb2c9 | |||
| bdf189faac | |||
| 5bd56e7464 | |||
| 7a6475c3f9 | |||
| 2b4ffd1161 | |||
| d7ea27b279 | |||
| 3a9c978b5e | |||
| 6abb69bd25 | |||
| 17130477c9 | |||
| 4044fbcb33 | |||
| 2320ec76b4 | |||
| a519bbc617 | |||
| 09d93af975 | |||
| ca98710640 | |||
| e33f3e8345 | |||
| cd46a674d1 | |||
| 4c9c27b244 | |||
| cf407c2ec0 | |||
| f9bff103dd | |||
| 146ca61a27 | |||
| 1a84bcc565 | |||
| 681ffd9a21 | |||
| d90b8d615c | |||
| 255cd61a8c | |||
| 7374445398 | |||
| 7e92826efc | |||
| d83914d478 | |||
| 8521ac5d21 | |||
| e87355463f | |||
| 1df10553bb | |||
| d8f749da52 | |||
| 9509dfd1de | |||
| b445f4b01d | |||
| dc11acf041 | |||
| 6385b0f7ed | |||
| ed949bc211 | |||
| 20de2f35f9 | |||
| f9ed0037b3 | |||
| 14c31bfda0 | |||
| 5d65d000ab | |||
| 94e2b5c140 | |||
| 7ad81ed46f | |||
| d5b15d6523 | |||
| 33ca4ba5c7 | |||
| 195d501b43 | |||
| cc399e2ade | |||
| a441980d68 | |||
| 3c4cfccc88 | |||
| 9f417268b3 | |||
| 2aae501234 | |||
| d574e6dc09 | |||
| 4f778436b5 | |||
| 395f0201e3 | |||
| 9cb4292d5c | |||
| e446903aac | |||
| 281d036fcf | |||
| ae6266e101 | |||
| b7e6b5af1b | |||
| 0773ab4d07 | |||
| e287dea91b | |||
| 2c32536bf4 | |||
| caa2c06e50 | |||
| 5eabcf8e4f | |||
| 4668a133f0 | |||
| 3889b34ec3 | |||
| 81721d0dce | |||
| 311d799344 | |||
| e05112a364 | |||
| 9060365f5e | |||
| 56c1a7fab6 | |||
| b5bd2cde9e | |||
| 02c9e0a3e0 | |||
| f6d82773f9 | |||
| 78dc44a7fd | |||
| 4d64db8be7 | |||
| 608fab60fd | |||
| 46c4390a2e | |||
| c92743d124 | |||
| 594f969641 | |||
| 93f8e7ba74 | |||
| a45eb275e3 | |||
| abb9e08671 | |||
| f14b7af5ac | |||
| 9c7a8dd584 | |||
| 1ed507c065 | |||
| 55c74ebea8 | |||
| e9301c3c4b | |||
| e3474878b6 | |||
| 4feae810fa | |||
| 101e9bd456 | |||
| 82a9f9a5a9 | |||
| a8c0f1d962 | |||
| 7341eaa654 | |||
| 28afa8d2d4 | |||
| 0fed75a880 | |||
| 069844cd4e | |||
| b362d47d95 | |||
| bf3c2b0bbb | |||
| 0587bef667 | |||
| 3cdfa654ae | |||
| 3cb84ed17c | |||
| 9f0d5f60b5 | |||
| 8cb0343f4c | |||
| 8e42ca1764 | |||
| c49b23d4dd | |||
| b0e1cb473a | |||
| 5e2726fb17 | |||
| 64d89d3546 | |||
| cf8deac2b2 | |||
| b1384a6da8 | |||
| dff59ec960 | |||
| 59c6e2cc44 | |||
| 6131a847a2 | |||
| b81d1b25c7 | |||
| 3271e395c8 | |||
| 0d7ce141aa | |||
| 0334cf11cc | |||
| e383d39598 | |||
| 399c20a928 | |||
| e34aba60d9 | |||
| 873aefae19 | |||
| 46cf2e96b5 | |||
| 4e1ba6f02f | |||
| da9089612a | |||
| 47df8f4c2a | |||
| dcde359181 | |||
| 7f4bcd3d72 | |||
| 0e2958e888 | |||
| 260bdc057c | |||
| c49b1bc6d5 | |||
| e331787645 | |||
| c0411caef4 | |||
| b401c6a0c3 | |||
| aabbe11e64 | |||
| 5f41971305 | |||
| 5023afffc7 | |||
| ad326cb0be |
Vendored
+28
-16
@@ -1,15 +1,18 @@
|
||||
#build TBB for Android from source
|
||||
if(NOT ANDROID)
|
||||
message(FATAL_ERROR "The script is designed for Android only!")
|
||||
endif()
|
||||
|
||||
#Cross compile TBB from source
|
||||
project(tbb)
|
||||
|
||||
# 4.1 update 1 - works fine
|
||||
set(tbb_ver "tbb41_20121003oss")
|
||||
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20121003oss_src.tgz")
|
||||
set(tbb_md5 "2a684fefb855d2d0318d1ef09afa75ff")
|
||||
# 4.1 update 2 - works fine
|
||||
set(tbb_ver "tbb41_20130116oss")
|
||||
set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20130116oss_src.tgz")
|
||||
set(tbb_md5 "3809790e1001a1b32d59c9fee590ee85")
|
||||
set(tbb_version_file "version_string.ver")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow)
|
||||
|
||||
# 4.1 update 1 - works fine
|
||||
#set(tbb_ver "tbb41_20121003oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/sites/default/files/software_releases/source/tbb41_20121003oss_src.tgz")
|
||||
#set(tbb_md5 "2a684fefb855d2d0318d1ef09afa75ff")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
|
||||
# 4.1 - works fine
|
||||
#set(tbb_ver "tbb41_20120718oss")
|
||||
@@ -121,9 +124,9 @@ list(APPEND lib_srcs "${tbb_src_dir}/src/rml/client/rml_tbb.cpp")
|
||||
|
||||
add_definitions(-D__TBB_DYNAMIC_LOAD_ENABLED=0 #required
|
||||
-D__TBB_BUILD=1 #required
|
||||
-D__TBB_SURVIVE_THREAD_SWITCH=0 #no cilk on Android ?
|
||||
-DUSE_PTHREAD #required
|
||||
-DTBB_USE_GCC_BUILTINS=1 #required
|
||||
-D__TBB_SURVIVE_THREAD_SWITCH=0 #no cilk support
|
||||
-DUSE_PTHREAD #required for Unix
|
||||
-DTBB_USE_GCC_BUILTINS=1 #required for ARM GCC
|
||||
-DTBB_USE_DEBUG=0 #just to be sure
|
||||
-DTBB_NO_LEGACY=1 #don't need backward compatibility
|
||||
-DDO_ITT_NOTIFY=0 #it seems that we don't need these notifications
|
||||
@@ -140,14 +143,24 @@ if(tbb_need_GENERIC_DWORD_LOAD_STORE)
|
||||
set(tbb_need_GENERIC_DWORD_LOAD_STORE ON PARENT_SCOPE)
|
||||
endif()
|
||||
|
||||
add_library(tbb STATIC ${lib_srcs} ${lib_hdrs} "${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h" "${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}")
|
||||
set(TBB_SOURCE_FILES ${lib_srcs} ${lib_hdrs})
|
||||
|
||||
if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "arm")
|
||||
if (NOT ANDROID)
|
||||
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/arm_linux_stub.cpp")
|
||||
endif()
|
||||
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h\"")
|
||||
endif()
|
||||
|
||||
set(TBB_SOURCE_FILES ${TBB_SOURCE_FILES} "${CMAKE_CURRENT_SOURCE_DIR}/${tbb_version_file}")
|
||||
|
||||
add_library(tbb ${TBB_SOURCE_FILES})
|
||||
target_link_libraries(tbb c m dl)
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wmissing-declarations)
|
||||
string(REPLACE "-Werror=non-virtual-dtor" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -include \"${CMAKE_CURRENT_SOURCE_DIR}/android_additional.h\"")
|
||||
|
||||
set_target_properties(tbb
|
||||
PROPERTIES OUTPUT_NAME tbb
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
@@ -164,4 +177,3 @@ endif()
|
||||
|
||||
# get TBB version
|
||||
ocv_parse_header("${tbb_src_dir}/include/tbb/tbb_stddef.h" TBB_VERSION_LINES TBB_VERSION_MAJOR TBB_VERSION_MINOR TBB_INTERFACE_VERSION CACHE)
|
||||
|
||||
|
||||
Vendored
+10
@@ -0,0 +1,10 @@
|
||||
#include "tbb/tbb_misc.h"
|
||||
|
||||
namespace tbb {
|
||||
namespace internal {
|
||||
|
||||
void affinity_helper::protect_affinity_mask() {}
|
||||
affinity_helper::~affinity_helper() {}
|
||||
|
||||
}
|
||||
}
|
||||
+33
-22
@@ -110,14 +110,15 @@ endif()
|
||||
|
||||
# Optional 3rd party components
|
||||
# ===================================================
|
||||
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (UNIX AND NOT ANDROID AND NOT IOS AND NOT CARMA) )
|
||||
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O" ON IF IOS)
|
||||
OCV_OPTION(WITH_CARBON "Use Carbon for UI instead of Cocoa" OFF IF APPLE )
|
||||
OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS AND NOT APPLE) )
|
||||
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" ON)
|
||||
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_FFMPEG "Include FFMPEG support" ON IF (NOT ANDROID AND NOT IOS))
|
||||
OCV_OPTION(WITH_GSTREAMER "Include Gstreamer support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_GTK "Include GTK support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_IMAGEIO "ImageIO support for OS X" OFF IF APPLE)
|
||||
@@ -136,18 +137,19 @@ OCV_OPTION(WITH_TBB "Include Intel TBB support" OFF
|
||||
OCV_OPTION(WITH_CSTRIPES "Include C= support" OFF IF WIN32 )
|
||||
OCV_OPTION(WITH_TIFF "Include TIFF support" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_UNICAP "Include Unicap support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON IF (UNIX AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_VIDEOINPUT "Build HighGUI with DirectShow support" ON IF WIN32 )
|
||||
OCV_OPTION(WITH_XIMEA "Include XIMEA cameras support" OFF IF (NOT ANDROID AND NOT APPLE) )
|
||||
OCV_OPTION(WITH_XINE "Include Xine support (GPL)" OFF IF (UNIX AND NOT APPLE AND NOT ANDROID) )
|
||||
OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENCL "Include OpenCL Runtime support" OFF IF (NOT ANDROID AND NOT IOS AND NOT CARMA) )
|
||||
OCV_OPTION(WITH_OPENCLAMDFFT "Include AMD OpenCL FFT library support" OFF IF (NOT ANDROID AND NOT IOS AND NOT CARMA) )
|
||||
OCV_OPTION(WITH_OPENCLAMDBLAS "Include AMD OpenCL BLAS library support" OFF IF (NOT ANDROID AND NOT IOS AND NOT CARMA) )
|
||||
|
||||
|
||||
# OpenCV build components
|
||||
# ===================================================
|
||||
OCV_OPTION(BUILD_SHARED_LIBS "Build shared libraries (.dll/.so) instead of static ones (.lib/.a)" NOT (ANDROID OR IOS) )
|
||||
OCV_OPTION(BUILD_opencv_apps "Build utility applications (used for example to train classifiers)" (NOT ANDROID) IF (NOT IOS) )
|
||||
OCV_OPTION(BUILD_ANDROID_EXAMPLES "Build examples for Android platform" ON IF ANDROID )
|
||||
OCV_OPTION(BUILD_DOCS "Create build rules for OpenCV Documentation" ON )
|
||||
OCV_OPTION(BUILD_EXAMPLES "Build all examples" OFF )
|
||||
@@ -156,18 +158,18 @@ OCV_OPTION(BUILD_PERF_TESTS "Build performance tests"
|
||||
OCV_OPTION(BUILD_TESTS "Build accuracy & regression tests" ON IF (NOT IOS) )
|
||||
OCV_OPTION(BUILD_WITH_DEBUG_INFO "Include debug info into debug libs (not MSCV only)" ON )
|
||||
OCV_OPTION(BUILD_WITH_STATIC_CRT "Enables use of staticaly linked CRT for staticaly linked OpenCV" ON IF MSVC )
|
||||
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF ANDROID AND NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whole OpenCV library" ON IF NOT BUILD_SHARED_LIBS AND CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_SOURCE_TREE )
|
||||
OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID )
|
||||
|
||||
# 3rd party libs
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE )
|
||||
OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR ANDROID OR APPLE )
|
||||
OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR ANDROID OR APPLE )
|
||||
OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR ANDROID OR APPLE )
|
||||
OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR ANDROID OR APPLE )
|
||||
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" WIN32 OR ANDROID OR APPLE )
|
||||
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_JASPER "Build libjasper from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_PNG "Build libpng from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_OPENEXR "Build openexr from source" WIN32 OR ANDROID OR APPLE OR CARMA )
|
||||
OCV_OPTION(BUILD_TBB "Download and build TBB from source" ANDROID IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
|
||||
# OpenCV installation options
|
||||
# ===================================================
|
||||
@@ -415,10 +417,10 @@ if(WITH_OPENCL)
|
||||
if(OPENCL_FOUND)
|
||||
set(HAVE_OPENCL 1)
|
||||
endif()
|
||||
if(WITH_OPENCLAMDFFT)
|
||||
if(WITH_OPENCLAMDFFT AND CLAMDFFT_INCLUDE_DIR)
|
||||
set(HAVE_CLAMDFFT 1)
|
||||
endif()
|
||||
if(WITH_OPENCLAMDBLAS)
|
||||
if(WITH_OPENCLAMDBLAS AND CLAMDBLAS_INCLUDE_DIR)
|
||||
set(HAVE_CLAMDBLAS 1)
|
||||
endif()
|
||||
endif()
|
||||
@@ -452,7 +454,9 @@ add_subdirectory(doc)
|
||||
add_subdirectory(data)
|
||||
|
||||
# extra applications
|
||||
add_subdirectory(apps)
|
||||
if(BUILD_opencv_apps)
|
||||
add_subdirectory(apps)
|
||||
endif()
|
||||
|
||||
# examples
|
||||
if(BUILD_EXAMPLES OR BUILD_ANDROID_EXAMPLES OR INSTALL_PYTHON_EXAMPLES)
|
||||
@@ -551,7 +555,11 @@ foreach(m ${OPENCV_MODULES_DISABLED_AUTO})
|
||||
list(APPEND __mdeps ${d})
|
||||
endif()
|
||||
endforeach()
|
||||
list(APPEND OPENCV_MODULES_DISABLED_AUTO_ST "${m}(deps: ${__mdeps})")
|
||||
if(__mdeps)
|
||||
list(APPEND OPENCV_MODULES_DISABLED_AUTO_ST "${m}(deps: ${__mdeps})")
|
||||
else()
|
||||
list(APPEND OPENCV_MODULES_DISABLED_AUTO_ST "${m}")
|
||||
endif()
|
||||
endforeach()
|
||||
string(REPLACE "opencv_" "" OPENCV_MODULES_DISABLED_AUTO_ST "${OPENCV_MODULES_DISABLED_AUTO_ST}")
|
||||
|
||||
@@ -720,11 +728,13 @@ if(DEFINED WITH_V4L)
|
||||
endif()
|
||||
if(HAVE_CAMV4L2)
|
||||
set(HAVE_CAMV4L2_STR "YES")
|
||||
elseif(HAVE_VIDEOIO)
|
||||
set(HAVE_CAMV4L2_STR "YES(videoio)")
|
||||
else()
|
||||
set(HAVE_CAMV4L2_STR "NO")
|
||||
endif()
|
||||
status(" V4L/V4L2:" HAVE_LIBV4L THEN "Using libv4l (ver ${ALIASOF_libv4l1_VERSION})"
|
||||
ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
|
||||
ELSE "${HAVE_CAMV4L_STR}/${HAVE_CAMV4L2_STR}")
|
||||
endif(DEFINED WITH_V4L)
|
||||
|
||||
if(DEFINED WITH_VIDEOINPUT)
|
||||
@@ -772,8 +782,9 @@ if(HAVE_CUDA)
|
||||
status("")
|
||||
status(" NVIDIA CUDA")
|
||||
|
||||
status(" Use CUFFT:" HAVE_CUFFT THEN YES ELSE NO)
|
||||
status(" Use CUBLAS:" HAVE_CUBLAS THEN YES ELSE NO)
|
||||
status(" Use CUFFT:" HAVE_CUFFT THEN YES ELSE NO)
|
||||
status(" Use CUBLAS:" HAVE_CUBLAS THEN YES ELSE NO)
|
||||
status(" USE NVCUVID:" HAVE_NVCUVID THEN YES ELSE NO)
|
||||
status(" NVIDIA GPU arch:" ${OPENCV_CUDA_ARCH_BIN})
|
||||
status(" NVIDIA PTX archs:" ${OPENCV_CUDA_ARCH_PTX})
|
||||
status(" Use fast math:" CUDA_FAST_MATH THEN YES ELSE NO)
|
||||
|
||||
@@ -6,8 +6,8 @@ const char* GetRevision(void);
|
||||
const char* GetLibraryList(void);
|
||||
JNIEXPORT jstring JNICALL Java_org_opencv_android_StaticHelper_getLibraryList(JNIEnv *, jclass);
|
||||
|
||||
#define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" ANDROID_PACKAGE_PLATFORM
|
||||
#define PACKAGE_REVISION CVAUX_STR(CV_SUBMINOR_VERSION) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE)
|
||||
#define PACKAGE_NAME "org.opencv.lib_v" CVAUX_STR(CV_VERSION_EPOCH) CVAUX_STR(CV_VERSION_MAJOR) "_" ANDROID_PACKAGE_PLATFORM
|
||||
#define PACKAGE_REVISION CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE)
|
||||
|
||||
const char* GetPackageName(void)
|
||||
{
|
||||
|
||||
@@ -56,7 +56,7 @@ configure_file("${CMAKE_CURRENT_SOURCE_DIR}/${ANDROID_MANIFEST_FILE}" "${PACKAGE
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/values/strings.xml" "${PACKAGE_DIR}/res/values/strings.xml" @ONLY)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/res/drawable/icon.png" "${PACKAGE_DIR}/res/drawable/icon.png" COPYONLY)
|
||||
|
||||
set(target_name "OpenCV_${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}_binary_pack_${ANDROID_PACKAGE_PLATFORM}")
|
||||
set(target_name "OpenCV_${OPENCV_VERSION}_binary_pack_${ANDROID_PACKAGE_PLATFORM}")
|
||||
get_target_property(opencv_java_location opencv_java LOCATION)
|
||||
|
||||
set(android_proj_target_files ${ANDROID_PROJECT_FILES})
|
||||
@@ -86,7 +86,7 @@ add_custom_command(
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${APK_NAME}"
|
||||
WORKING_DIRECTORY "${PACKAGE_DIR}"
|
||||
MAIN_DEPENDENCY "${PACKAGE_DIR}/${ANDROID_MANIFEST_FILE}"
|
||||
DEPENDS "${OpenCV_BINARY_DIR}/bin/.classes.jar.dephelper" "${PACKAGE_DIR}/res/values/strings.xml" "${PACKAGE_DIR}/res/drawable/icon.png" ${camera_wrappers} opencv_java
|
||||
DEPENDS "${OpenCV_BINARY_DIR}/bin/classes.jar.dephelper" "${PACKAGE_DIR}/res/values/strings.xml" "${PACKAGE_DIR}/res/drawable/icon.png" ${camera_wrappers} opencv_java
|
||||
)
|
||||
|
||||
install(FILES "${APK_NAME}" DESTINATION "apk/" COMPONENT main)
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.opencv.engine"
|
||||
android:versionCode="24@ANDROID_PLATFORM_VERSION_CODE@"
|
||||
android:versionName="2.4" >
|
||||
android:versionCode="25@ANDROID_PLATFORM_VERSION_CODE@"
|
||||
android:versionName="2.5" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||
|
||||
@@ -15,60 +15,44 @@ using namespace android;
|
||||
|
||||
const int OpenCVEngine::Platform = DetectKnownPlatforms();
|
||||
const int OpenCVEngine::CpuID = GetCpuID();
|
||||
const int OpenCVEngine::KnownVersions[] = {2040000, 2040100, 2040200, 2040300, 2040301, 2040302};
|
||||
|
||||
std::set<std::string> OpenCVEngine::InitKnownOpenCVersions()
|
||||
bool OpenCVEngine::ValidateVersion(int version)
|
||||
{
|
||||
std::set<std::string> result;
|
||||
for (size_t i = 0; i < sizeof(KnownVersions)/sizeof(int); i++)
|
||||
if (KnownVersions[i] == version)
|
||||
return true;
|
||||
|
||||
result.insert("240");
|
||||
result.insert("241");
|
||||
result.insert("242");
|
||||
result.insert("243");
|
||||
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
const std::set<std::string> OpenCVEngine::KnownVersions = InitKnownOpenCVersions();
|
||||
|
||||
bool OpenCVEngine::ValidateVersionString(const std::string& version)
|
||||
int OpenCVEngine::NormalizeVersionString(std::string version)
|
||||
{
|
||||
return (KnownVersions.find(version) != KnownVersions.end());
|
||||
}
|
||||
|
||||
std::string OpenCVEngine::NormalizeVersionString(std::string version)
|
||||
{
|
||||
std::string result = "";
|
||||
std::string suffix = "";
|
||||
int result = 0;
|
||||
|
||||
if (version.empty())
|
||||
{
|
||||
return result;
|
||||
}
|
||||
|
||||
if (('a' == version[version.size()-1]) || ('b' == version[version.size()-1]))
|
||||
{
|
||||
suffix = version[version.size()-1];
|
||||
version.erase(version.size()-1);
|
||||
}
|
||||
|
||||
std::vector<std::string> parts = SplitStringVector(version, '.');
|
||||
|
||||
if (parts.size() >= 2)
|
||||
// Use only 4 digits of the version, i.e. 1.2.3.4.
|
||||
// Other digits will be ignored.
|
||||
if (parts.size() > 4)
|
||||
parts.erase(parts.begin()+4, parts.end());
|
||||
|
||||
int multiplyer = 1000000;
|
||||
for (std::vector<std::string>::const_iterator it = parts.begin(); it != parts.end(); ++it)
|
||||
{
|
||||
if (parts.size() >= 3)
|
||||
{
|
||||
result = parts[0] + parts[1] + parts[2] + suffix;
|
||||
if (!ValidateVersionString(result))
|
||||
result = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = parts[0] + parts[1] + "0" + suffix;
|
||||
if (!ValidateVersionString(result))
|
||||
result = "";
|
||||
}
|
||||
int digit = atoi(it->c_str());
|
||||
result += multiplyer*digit;
|
||||
multiplyer /= 100;
|
||||
}
|
||||
|
||||
if (!ValidateVersion(result))
|
||||
result = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -86,19 +70,19 @@ int32_t OpenCVEngine::GetVersion()
|
||||
String16 OpenCVEngine::GetLibPathByVersion(android::String16 version)
|
||||
{
|
||||
std::string std_version(String8(version).string());
|
||||
std::string norm_version;
|
||||
int norm_version;
|
||||
std::string path;
|
||||
|
||||
LOGD("OpenCVEngine::GetLibPathByVersion(%s) impl", String8(version).string());
|
||||
|
||||
norm_version = NormalizeVersionString(std_version);
|
||||
|
||||
if (!norm_version.empty())
|
||||
if (0 != norm_version)
|
||||
{
|
||||
path = PackageManager->GetPackagePathByVersion(norm_version, Platform, CpuID);
|
||||
if (path.empty())
|
||||
{
|
||||
LOGI("Package OpenCV of version %s is not installed. Try to install it :)", norm_version.c_str());
|
||||
LOGI("Package OpenCV of version \"%s\" (%d) is not installed. Try to install it :)", String8(version).string(), norm_version);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -107,7 +91,7 @@ String16 OpenCVEngine::GetLibPathByVersion(android::String16 version)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGE("OpenCV version \"%s\" (%s) is not supported", String8(version).string(), norm_version.c_str());
|
||||
LOGE("OpenCV version \"%s\" (%d) is not supported", String8(version).string(), norm_version);
|
||||
}
|
||||
|
||||
return String16(path.c_str());
|
||||
@@ -116,11 +100,11 @@ String16 OpenCVEngine::GetLibPathByVersion(android::String16 version)
|
||||
android::String16 OpenCVEngine::GetLibraryList(android::String16 version)
|
||||
{
|
||||
std::string std_version = String8(version).string();
|
||||
std::string norm_version;
|
||||
int norm_version;
|
||||
String16 result;
|
||||
norm_version = NormalizeVersionString(std_version);
|
||||
|
||||
if (!norm_version.empty())
|
||||
if (0 != norm_version)
|
||||
{
|
||||
std::string tmp = PackageManager->GetPackagePathByVersion(norm_version, Platform, CpuID);
|
||||
if (!tmp.empty())
|
||||
@@ -156,12 +140,12 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version)
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("Package OpenCV of version %s is not installed. Try to install it :)", norm_version.c_str());
|
||||
LOGI("Package OpenCV of version \"%s\" (%d) is not installed. Try to install it :)", std_version.c_str(), norm_version);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str());
|
||||
LOGE("OpenCV version \"%s\" is not supported", std_version.c_str());
|
||||
}
|
||||
|
||||
return result;
|
||||
@@ -170,21 +154,21 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version)
|
||||
bool OpenCVEngine::InstallVersion(android::String16 version)
|
||||
{
|
||||
std::string std_version = String8(version).string();
|
||||
std::string norm_version;
|
||||
int norm_version;
|
||||
bool result = false;
|
||||
|
||||
LOGD("OpenCVEngine::InstallVersion() begin");
|
||||
|
||||
norm_version = NormalizeVersionString(std_version);
|
||||
|
||||
if (!norm_version.empty())
|
||||
if (0 != norm_version)
|
||||
{
|
||||
LOGD("PackageManager->InstallVersion call");
|
||||
result = PackageManager->InstallVersion(norm_version, Platform, CpuID);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGE("OpenCV version \"%s\" is not supported", norm_version.c_str());
|
||||
LOGE("OpenCV version \"%s\" (%d) is not supported", std_version.c_str(), norm_version);
|
||||
}
|
||||
|
||||
LOGD("OpenCVEngine::InstallVersion() end");
|
||||
|
||||
@@ -23,16 +23,15 @@ public:
|
||||
|
||||
protected:
|
||||
IPackageManager* PackageManager;
|
||||
static const std::set<std::string> KnownVersions;
|
||||
static const int KnownVersions[];
|
||||
|
||||
OpenCVEngine();
|
||||
static std::set<std::string> InitKnownOpenCVersions();
|
||||
bool ValidateVersionString(const std::string& version);
|
||||
std::string NormalizeVersionString(std::string version);
|
||||
bool ValidateVersion(int version);
|
||||
int NormalizeVersionString(std::string version);
|
||||
bool FixPermissions(const std::string& path);
|
||||
|
||||
static const int Platform;
|
||||
static const int CpuID;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -46,7 +46,9 @@ bool JavaBasedPackageManager::InstallPackage(const PackageInfo& package)
|
||||
LOGD("Calling java package manager with package name %s\n", package.GetFullName().c_str());
|
||||
jobject jpkgname = jenv->NewStringUTF(package.GetFullName().c_str());
|
||||
bool result = jenv->CallNonvirtualBooleanMethod(JavaPackageManager, jclazz, jmethod, jpkgname);
|
||||
|
||||
jenv->DeleteLocalRef(jpkgname);
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
|
||||
if (self_attached)
|
||||
{
|
||||
@@ -104,9 +106,12 @@ vector<PackageInfo> JavaBasedPackageManager::GetInstalledPackages()
|
||||
|
||||
if (tmp.IsValid())
|
||||
result.push_back(tmp);
|
||||
|
||||
jenv->DeleteLocalRef(jtmp);
|
||||
}
|
||||
|
||||
jenv->DeleteLocalRef(jpkgs);
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
|
||||
if (self_attached)
|
||||
{
|
||||
@@ -118,6 +123,16 @@ vector<PackageInfo> JavaBasedPackageManager::GetInstalledPackages()
|
||||
return result;
|
||||
}
|
||||
|
||||
static jint GetAndroidVersion(JNIEnv* jenv)
|
||||
{
|
||||
jclass jclazz = jenv->FindClass("android/os/Build$VERSION");
|
||||
jfieldID jfield = jenv->GetStaticFieldID(jclazz, "SDK_INT", "I");
|
||||
jint api_level = jenv->GetStaticIntField(jclazz, jfield);
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
|
||||
return api_level;
|
||||
}
|
||||
|
||||
// IMPORTANT: This method can be called only if thread is attached to Dalvik
|
||||
PackageInfo JavaBasedPackageManager::ConvertPackageFromJava(jobject package, JNIEnv* jenv)
|
||||
{
|
||||
@@ -133,23 +148,27 @@ PackageInfo JavaBasedPackageManager::ConvertPackageFromJava(jobject package, JNI
|
||||
const char* jversionstr = jenv->GetStringUTFChars(jversionobj, NULL);
|
||||
string verison(jversionstr);
|
||||
jenv->DeleteLocalRef(jversionobj);
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
|
||||
static const jint api_level = GetAndroidVersion(jenv);
|
||||
string path;
|
||||
jclazz = jenv->FindClass("android/os/Build$VERSION");
|
||||
jfield = jenv->GetStaticFieldID(jclazz, "SDK_INT", "I");
|
||||
jint api_level = jenv->GetStaticIntField(jclazz, jfield);
|
||||
if (api_level > 8)
|
||||
{
|
||||
jclazz = jenv->GetObjectClass(package);
|
||||
jfield = jenv->GetFieldID(jclazz, "applicationInfo", "Landroid/content/pm/ApplicationInfo;");
|
||||
jobject japp_info = jenv->GetObjectField(package, jfield);
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
|
||||
jclazz = jenv->GetObjectClass(japp_info);
|
||||
jfield = jenv->GetFieldID(jclazz, "nativeLibraryDir", "Ljava/lang/String;");
|
||||
jstring jpathobj = static_cast<jstring>(jenv->GetObjectField(japp_info, jfield));
|
||||
const char* jpathstr = jenv->GetStringUTFChars(jpathobj, NULL);
|
||||
path = string(jpathstr);
|
||||
jenv->ReleaseStringUTFChars(jpathobj, jpathstr);
|
||||
|
||||
jenv->DeleteLocalRef(japp_info);
|
||||
jenv->DeleteLocalRef(jpathobj);
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -19,4 +19,4 @@ private:
|
||||
|
||||
JavaBasedPackageManager();
|
||||
PackageInfo ConvertPackageFromJava(jobject package, JNIEnv* jenv);
|
||||
};
|
||||
};
|
||||
|
||||
@@ -11,22 +11,24 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
set<string> CommonPackageManager::GetInstalledVersions()
|
||||
vector<int> CommonPackageManager::GetInstalledVersions()
|
||||
{
|
||||
set<string> result;
|
||||
vector<int> result;
|
||||
vector<PackageInfo> installed_packages = GetInstalledPackages();
|
||||
|
||||
for (vector<PackageInfo>::const_iterator it = installed_packages.begin(); it != installed_packages.end(); ++it)
|
||||
result.resize(installed_packages.size());
|
||||
|
||||
for (size_t i = 0; i < installed_packages.size(); i++)
|
||||
{
|
||||
string version = it->GetVersion();
|
||||
assert(!version.empty());
|
||||
result.insert(version);
|
||||
int version = installed_packages[i].GetVersion();
|
||||
assert(version);
|
||||
result[i] = version;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CommonPackageManager::CheckVersionInstalled(const std::string& version, int platform, int cpu_id)
|
||||
bool CommonPackageManager::CheckVersionInstalled(int version, int platform, int cpu_id)
|
||||
{
|
||||
bool result = false;
|
||||
LOGD("CommonPackageManager::CheckVersionInstalled() begin");
|
||||
@@ -48,14 +50,14 @@ bool CommonPackageManager::CheckVersionInstalled(const std::string& version, int
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CommonPackageManager::InstallVersion(const std::string& version, int platform, int cpu_id)
|
||||
bool CommonPackageManager::InstallVersion(int version, int platform, int cpu_id)
|
||||
{
|
||||
LOGD("CommonPackageManager::InstallVersion() begin");
|
||||
PackageInfo package(version, platform, cpu_id);
|
||||
return InstallPackage(package);
|
||||
}
|
||||
|
||||
string CommonPackageManager::GetPackagePathByVersion(const std::string& version, int platform, int cpu_id)
|
||||
string CommonPackageManager::GetPackagePathByVersion(int version, int platform, int cpu_id)
|
||||
{
|
||||
string result;
|
||||
PackageInfo target_package(version, platform, cpu_id);
|
||||
@@ -64,7 +66,7 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
|
||||
for (vector<PackageInfo>::iterator it = all_packages.begin(); it != all_packages.end(); ++it)
|
||||
{
|
||||
LOGD("Check version \"%s\" compatibility with \"%s\"\n", version.c_str(), it->GetVersion().c_str());
|
||||
LOGD("Check version \"%d\" compatibility with \"%d\"\n", version, it->GetVersion());
|
||||
if (IsVersionCompatible(version, it->GetVersion()))
|
||||
{
|
||||
LOGD("Compatible");
|
||||
@@ -79,7 +81,7 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
if (!packages.empty())
|
||||
{
|
||||
int OptRating = -1;
|
||||
std::string OptVersion = "";
|
||||
int OptVersion = 0;
|
||||
std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
|
||||
|
||||
if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
|
||||
@@ -124,20 +126,13 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
return result;
|
||||
}
|
||||
|
||||
bool CommonPackageManager::IsVersionCompatible(const std::string& target_version, const std::string& package_version)
|
||||
bool CommonPackageManager::IsVersionCompatible(int target_version, int package_version)
|
||||
{
|
||||
assert (target_version.size() == 3);
|
||||
assert (package_version.size() == 3);
|
||||
|
||||
bool result = false;
|
||||
assert(target_version);
|
||||
assert(package_version);
|
||||
|
||||
// major version is the same and minor package version is above or the same as target.
|
||||
if ((package_version[0] == target_version[0]) && (package_version[1] == target_version[1]) && (package_version[2] >= target_version[2]))
|
||||
{
|
||||
result = true;
|
||||
}
|
||||
|
||||
return result;
|
||||
return ( (package_version/10000 == target_version/10000) && (package_version%10000 >= target_version%10000) );
|
||||
}
|
||||
|
||||
int CommonPackageManager::GetHardwareRating(int platform, int cpu_id, const std::vector<std::pair<int, int> >& group)
|
||||
|
||||
@@ -3,17 +3,16 @@
|
||||
|
||||
#include "IPackageManager.h"
|
||||
#include "PackageInfo.h"
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class CommonPackageManager: public IPackageManager
|
||||
{
|
||||
public:
|
||||
std::set<std::string> GetInstalledVersions();
|
||||
bool CheckVersionInstalled(const std::string& version, int platform, int cpu_id);
|
||||
bool InstallVersion(const std::string& version, int platform, int cpu_id);
|
||||
std::string GetPackagePathByVersion(const std::string& version, int platform, int cpu_id);
|
||||
std::vector<int> GetInstalledVersions();
|
||||
bool CheckVersionInstalled(int version, int platform, int cpu_id);
|
||||
bool InstallVersion(int version, int platform, int cpu_id);
|
||||
std::string GetPackagePathByVersion(int version, int platform, int cpu_id);
|
||||
virtual ~CommonPackageManager();
|
||||
|
||||
protected:
|
||||
@@ -23,7 +22,7 @@ protected:
|
||||
static std::vector<std::pair<int, int> > InitArmRating();
|
||||
static std::vector<std::pair<int, int> > InitIntelRating();
|
||||
|
||||
bool IsVersionCompatible(const std::string& target_version, const std::string& package_version);
|
||||
bool IsVersionCompatible(int target_version, int package_version);
|
||||
int GetHardwareRating(int platform, int cpu_id, const std::vector<std::pair<int, int> >& group);
|
||||
|
||||
virtual bool InstallPackage(const PackageInfo& package) = 0;
|
||||
@@ -31,4 +30,4 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -124,14 +124,19 @@ inline int SplitIntelFeatures(const vector<string>& features)
|
||||
return result;
|
||||
}
|
||||
|
||||
inline string SplitVersion(const vector<string>& features, const string& package_version)
|
||||
inline int SplitVersion(const vector<string>& features, const string& package_version)
|
||||
{
|
||||
string result;
|
||||
int result = 0;
|
||||
|
||||
if ((features.size() > 1) && ('v' == features[1][0]))
|
||||
{
|
||||
result = features[1].substr(1);
|
||||
result += SplitStringVector(package_version, '.')[0];
|
||||
// Taking major and minor mart of library version from package name
|
||||
string tmp1 = features[1].substr(1);
|
||||
result += atoi(tmp1.substr(0,1).c_str())*1000000 + atoi(tmp1.substr(1,1).c_str())*10000;
|
||||
|
||||
// Taking release and build number from package revision
|
||||
vector<string> tmp2 = SplitStringVector(package_version, '.');
|
||||
result += atoi(tmp2[0].c_str())*100 + atoi(tmp2[1].c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -186,9 +191,9 @@ inline int SplitPlatfrom(const vector<string>& features)
|
||||
* Second part is version. Version starts from "v" symbol. After "v" symbol version nomber without dot symbol added.
|
||||
* If platform is known third part is platform name
|
||||
* If platform is unknown it is defined by hardware capabilities using pattern: <arch>_<floating point and vectorization features>_<other features>
|
||||
* Example: armv7_neon, armv5_vfpv3
|
||||
* Example: armv7_neon
|
||||
*/
|
||||
PackageInfo::PackageInfo(const string& version, int platform, int cpu_id, std::string install_path):
|
||||
PackageInfo::PackageInfo(int version, int platform, int cpu_id, std::string install_path):
|
||||
Version(version),
|
||||
Platform(platform),
|
||||
CpuID(cpu_id),
|
||||
@@ -198,7 +203,14 @@ InstallPath("")
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
#endif
|
||||
|
||||
FullName = BasePackageName + "_v" + Version.substr(0, Version.size()-1);
|
||||
int major_version = version/1000000;
|
||||
int minor_version = version/10000 - major_version*100;
|
||||
|
||||
char tmp[32];
|
||||
|
||||
sprintf(tmp, "%d%d", major_version, minor_version);
|
||||
|
||||
FullName = BasePackageName + std::string("_v") + std::string(tmp);
|
||||
if (PLATFORM_UNKNOWN != Platform)
|
||||
{
|
||||
FullName += string("_") + JoinPlatform(platform);
|
||||
@@ -296,7 +308,7 @@ InstallPath("")
|
||||
else
|
||||
{
|
||||
LOGD("PackageInfo::PackageInfo: package arch unknown");
|
||||
Version.clear();
|
||||
Version = 0;
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
}
|
||||
@@ -304,7 +316,7 @@ InstallPath("")
|
||||
else
|
||||
{
|
||||
LOGD("PackageInfo::PackageInfo: package arch unknown");
|
||||
Version.clear();
|
||||
Version = 0;
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
}
|
||||
@@ -371,7 +383,7 @@ InstallPath(install_path)
|
||||
{
|
||||
LOGI("Info library not found in package");
|
||||
LOGI("OpenCV Manager package does not contain any verison of OpenCV library");
|
||||
Version.clear();
|
||||
Version = 0;
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
return;
|
||||
@@ -383,7 +395,7 @@ InstallPath(install_path)
|
||||
if (!features.empty() && (BasePackageName == features[0]))
|
||||
{
|
||||
Version = SplitVersion(features, package_version);
|
||||
if (Version.empty())
|
||||
if (0 == Version)
|
||||
{
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
@@ -410,7 +422,7 @@ InstallPath(install_path)
|
||||
if (features.size() < 3)
|
||||
{
|
||||
LOGD("It is not OpenCV library package for this platform");
|
||||
Version.clear();
|
||||
Version = 0;
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
return;
|
||||
@@ -444,7 +456,7 @@ InstallPath(install_path)
|
||||
else
|
||||
{
|
||||
LOGD("It is not OpenCV library package for this platform");
|
||||
Version.clear();
|
||||
Version = 0;
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
return;
|
||||
@@ -454,7 +466,7 @@ InstallPath(install_path)
|
||||
else
|
||||
{
|
||||
LOGD("It is not OpenCV library package for this platform");
|
||||
Version.clear();
|
||||
Version = 0;
|
||||
CpuID = ARCH_UNKNOWN;
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
return;
|
||||
@@ -463,7 +475,7 @@ InstallPath(install_path)
|
||||
|
||||
bool PackageInfo::IsValid() const
|
||||
{
|
||||
return !(Version.empty() && (PLATFORM_UNKNOWN == Platform) && (ARCH_UNKNOWN == CpuID));
|
||||
return !((0 == Version) && (PLATFORM_UNKNOWN == Platform) && (ARCH_UNKNOWN == CpuID));
|
||||
}
|
||||
|
||||
int PackageInfo::GetPlatform() const
|
||||
@@ -481,7 +493,7 @@ string PackageInfo::GetFullName() const
|
||||
return FullName;
|
||||
}
|
||||
|
||||
string PackageInfo::GetVersion() const
|
||||
int PackageInfo::GetVersion() const
|
||||
{
|
||||
return Version;
|
||||
}
|
||||
@@ -494,4 +506,4 @@ string PackageInfo::GetInstalationPath() const
|
||||
bool PackageInfo::operator==(const PackageInfo& package) const
|
||||
{
|
||||
return (package.FullName == FullName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
class PackageInfo
|
||||
{
|
||||
public:
|
||||
PackageInfo(const std::string& version, int platform, int cpu_id, std::string install_path = "/data/data/");
|
||||
PackageInfo(int version, int platform, int cpu_id, std::string install_path = "/data/data/");
|
||||
PackageInfo(const std::string& fullname, const std::string& install_path, std::string package_version = "0.0");
|
||||
std::string GetFullName() const;
|
||||
std::string GetVersion() const;
|
||||
int GetVersion() const;
|
||||
int GetPlatform() const;
|
||||
int GetCpuID() const;
|
||||
std::string GetInstalationPath() const;
|
||||
@@ -43,7 +43,7 @@ public:
|
||||
|
||||
protected:
|
||||
static std::map<int, std::string> InitPlatformNameMap();
|
||||
std::string Version;
|
||||
int Version;
|
||||
int Platform;
|
||||
int CpuID;
|
||||
std::string FullName;
|
||||
@@ -51,4 +51,4 @@ protected:
|
||||
static const std::string BasePackageName;
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
#ifndef __IPACKAGE_MANAGER__
|
||||
#define __IPACKAGE_MANAGER__
|
||||
|
||||
#include <set>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
|
||||
class IPackageManager
|
||||
{
|
||||
public:
|
||||
virtual std::set<std::string> GetInstalledVersions() = 0;
|
||||
virtual bool CheckVersionInstalled(const std::string& version, int platform, int cpu_id) = 0;
|
||||
virtual bool InstallVersion(const std::string&, int platform, int cpu_id) = 0;
|
||||
virtual std::string GetPackagePathByVersion(const std::string&, int platform, int cpu_id) = 0;
|
||||
virtual std::vector<int> GetInstalledVersions() = 0;
|
||||
virtual bool CheckVersionInstalled(int version, int platform, int cpu_id) = 0;
|
||||
virtual bool InstallVersion(int version, int platform, int cpu_id) = 0;
|
||||
virtual std::string GetPackagePathByVersion(int version, int platform, int cpu_id) = 0;
|
||||
virtual ~IPackageManager(){};
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Version: "
|
||||
android:text="Library version: "
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
android:id="@+id/EngineVersionCaption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Version: "
|
||||
android:text="OpenCV Manager version: "
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
if(IOS OR ANDROID)
|
||||
return()
|
||||
endif()
|
||||
|
||||
SET(OPENCV_HAARTRAINING_DEPS opencv_core opencv_imgproc opencv_highgui opencv_objdetect opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
|
||||
ocv_check_dependencies(${OPENCV_HAARTRAINING_DEPS})
|
||||
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
if(IOS OR ANDROID)
|
||||
return()
|
||||
endif()
|
||||
|
||||
SET(OPENCV_TRAINCASCADE_DEPS opencv_core opencv_ml opencv_imgproc opencv_objdetect opencv_highgui opencv_calib3d opencv_video opencv_features2d opencv_flann opencv_legacy)
|
||||
ocv_check_dependencies(${OPENCV_TRAINCASCADE_DEPS})
|
||||
|
||||
|
||||
+47
-26
@@ -360,7 +360,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
|
||||
if (is_buf_16u)
|
||||
{
|
||||
unsigned short* udst_idx = (unsigned short*)(buf->data.s + root->buf_idx*buf->cols +
|
||||
unsigned short* udst_idx = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
|
||||
vi*sample_count + data_root->offset);
|
||||
for( int i = 0; i < num_valid; i++ )
|
||||
{
|
||||
@@ -373,7 +373,7 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
}
|
||||
else
|
||||
{
|
||||
int* idst_idx = buf->data.i + root->buf_idx*buf->cols +
|
||||
int* idst_idx = buf->data.i + root->buf_idx*get_length_subbuf() +
|
||||
vi*sample_count + root->offset;
|
||||
for( int i = 0; i < num_valid; i++ )
|
||||
{
|
||||
@@ -390,14 +390,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
const int* src_lbls = get_cv_labels(data_root, (int*)(uchar*)inn_buf);
|
||||
if (is_buf_16u)
|
||||
{
|
||||
unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*buf->cols +
|
||||
unsigned short* udst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
|
||||
(workVarCount-1)*sample_count + root->offset);
|
||||
for( int i = 0; i < count; i++ )
|
||||
udst[i] = (unsigned short)src_lbls[sidx[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
int* idst = buf->data.i + root->buf_idx*buf->cols +
|
||||
int* idst = buf->data.i + root->buf_idx*get_length_subbuf() +
|
||||
(workVarCount-1)*sample_count + root->offset;
|
||||
for( int i = 0; i < count; i++ )
|
||||
idst[i] = src_lbls[sidx[i]];
|
||||
@@ -407,14 +407,14 @@ CvDTreeNode* CvCascadeBoostTrainData::subsample_data( const CvMat* _subsample_id
|
||||
const int* sample_idx_src = get_sample_indices(data_root, (int*)(uchar*)inn_buf);
|
||||
if (is_buf_16u)
|
||||
{
|
||||
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*buf->cols +
|
||||
unsigned short* sample_idx_dst = (unsigned short*)(buf->data.s + root->buf_idx*get_length_subbuf() +
|
||||
workVarCount*sample_count + root->offset);
|
||||
for( int i = 0; i < count; i++ )
|
||||
sample_idx_dst[i] = (unsigned short)sample_idx_src[sidx[i]];
|
||||
}
|
||||
else
|
||||
{
|
||||
int* sample_idx_dst = buf->data.i + root->buf_idx*buf->cols +
|
||||
int* sample_idx_dst = buf->data.i + root->buf_idx*get_length_subbuf() +
|
||||
workVarCount*sample_count + root->offset;
|
||||
for( int i = 0; i < count; i++ )
|
||||
sample_idx_dst[i] = sample_idx_src[sidx[i]];
|
||||
@@ -489,6 +489,10 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
|
||||
int* idst = 0;
|
||||
unsigned short* udst = 0;
|
||||
|
||||
uint64 effective_buf_size = 0;
|
||||
int effective_buf_height = 0, effective_buf_width = 0;
|
||||
|
||||
|
||||
clear();
|
||||
shared = true;
|
||||
have_labels = true;
|
||||
@@ -548,13 +552,28 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
|
||||
var_type->data.i[var_count] = cat_var_count;
|
||||
var_type->data.i[var_count+1] = cat_var_count+1;
|
||||
work_var_count = ( cat_var_count ? 0 : numPrecalcIdx ) + 1/*cv_lables*/;
|
||||
buf_size = (work_var_count + 1) * sample_count/*sample_indices*/;
|
||||
buf_count = 2;
|
||||
|
||||
if ( is_buf_16u )
|
||||
buf = cvCreateMat( buf_count, buf_size, CV_16UC1 );
|
||||
buf_size = -1; // the member buf_size is obsolete
|
||||
|
||||
effective_buf_size = (uint64)(work_var_count + 1)*(uint64)sample_count * buf_count; // this is the total size of "CvMat buf" to be allocated
|
||||
effective_buf_width = sample_count;
|
||||
effective_buf_height = work_var_count+1;
|
||||
|
||||
if (effective_buf_width >= effective_buf_height)
|
||||
effective_buf_height *= buf_count;
|
||||
else
|
||||
buf = cvCreateMat( buf_count, buf_size, CV_32SC1 );
|
||||
effective_buf_width *= buf_count;
|
||||
|
||||
if ((uint64)effective_buf_width * (uint64)effective_buf_height != effective_buf_size)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "The memory buffer cannot be allocated since its size exceeds integer fields limit");
|
||||
}
|
||||
|
||||
if ( is_buf_16u )
|
||||
buf = cvCreateMat( effective_buf_height, effective_buf_width, CV_16UC1 );
|
||||
else
|
||||
buf = cvCreateMat( effective_buf_height, effective_buf_width, CV_32SC1 );
|
||||
|
||||
cat_count = cvCreateMat( 1, cat_var_count + 1, CV_32SC1 );
|
||||
|
||||
@@ -609,7 +628,7 @@ void CvCascadeBoostTrainData::setData( const CvFeatureEvaluator* _featureEvaluat
|
||||
priors_mult = cvCloneMat( priors );
|
||||
counts = cvCreateMat( 1, get_num_classes(), CV_32SC1 );
|
||||
direction = cvCreateMat( 1, sample_count, CV_8UC1 );
|
||||
split_buf = cvCreateMat( 1, sample_count, CV_32SC1 );
|
||||
split_buf = cvCreateMat( 1, sample_count, CV_32SC1 );//TODO: make a pointer
|
||||
}
|
||||
|
||||
void CvCascadeBoostTrainData::free_train_data()
|
||||
@@ -652,10 +671,10 @@ void CvCascadeBoostTrainData::get_ord_var_data( CvDTreeNode* n, int vi, float* o
|
||||
if ( vi < numPrecalcIdx )
|
||||
{
|
||||
if( !is_buf_16u )
|
||||
*sortedIndices = buf->data.i + n->buf_idx*buf->cols + vi*sample_count + n->offset;
|
||||
*sortedIndices = buf->data.i + n->buf_idx*get_length_subbuf() + vi*sample_count + n->offset;
|
||||
else
|
||||
{
|
||||
const unsigned short* shortIndices = (const unsigned short*)(buf->data.s + n->buf_idx*buf->cols +
|
||||
const unsigned short* shortIndices = (const unsigned short*)(buf->data.s + n->buf_idx*get_length_subbuf() +
|
||||
vi*sample_count + n->offset );
|
||||
for( int i = 0; i < nodeSampleCount; i++ )
|
||||
sortedIndicesBuf[i] = shortIndices[i];
|
||||
@@ -1027,6 +1046,7 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
int newBufIdx = data->get_child_buf_idx( node );
|
||||
int workVarCount = data->get_work_var_count();
|
||||
CvMat* buf = data->buf;
|
||||
size_t length_buf_row = data->get_length_subbuf();
|
||||
cv::AutoBuffer<uchar> inn_buf(n*(3*sizeof(int)+sizeof(float)));
|
||||
int* tempBuf = (int*)(uchar*)inn_buf;
|
||||
bool splitInputData;
|
||||
@@ -1070,7 +1090,7 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
if (data->is_buf_16u)
|
||||
{
|
||||
ushort *ldst, *rdst;
|
||||
ldst = (ushort*)(buf->data.s + left->buf_idx*buf->cols +
|
||||
ldst = (ushort*)(buf->data.s + left->buf_idx*length_buf_row +
|
||||
vi*scount + left->offset);
|
||||
rdst = (ushort*)(ldst + nl);
|
||||
|
||||
@@ -1096,9 +1116,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
else
|
||||
{
|
||||
int *ldst, *rdst;
|
||||
ldst = buf->data.i + left->buf_idx*buf->cols +
|
||||
ldst = buf->data.i + left->buf_idx*length_buf_row +
|
||||
vi*scount + left->offset;
|
||||
rdst = buf->data.i + right->buf_idx*buf->cols +
|
||||
rdst = buf->data.i + right->buf_idx*length_buf_row +
|
||||
vi*scount + right->offset;
|
||||
|
||||
// split sorted
|
||||
@@ -1131,9 +1151,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
|
||||
if (data->is_buf_16u)
|
||||
{
|
||||
unsigned short *ldst = (unsigned short *)(buf->data.s + left->buf_idx*buf->cols +
|
||||
unsigned short *ldst = (unsigned short *)(buf->data.s + left->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + left->offset);
|
||||
unsigned short *rdst = (unsigned short *)(buf->data.s + right->buf_idx*buf->cols +
|
||||
unsigned short *rdst = (unsigned short *)(buf->data.s + right->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + right->offset);
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
@@ -1154,9 +1174,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
}
|
||||
else
|
||||
{
|
||||
int *ldst = buf->data.i + left->buf_idx*buf->cols +
|
||||
int *ldst = buf->data.i + left->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + left->offset;
|
||||
int *rdst = buf->data.i + right->buf_idx*buf->cols +
|
||||
int *rdst = buf->data.i + right->buf_idx*length_buf_row +
|
||||
(workVarCount-1)*scount + right->offset;
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
@@ -1184,9 +1204,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
|
||||
if (data->is_buf_16u)
|
||||
{
|
||||
unsigned short* ldst = (unsigned short*)(buf->data.s + left->buf_idx*buf->cols +
|
||||
unsigned short* ldst = (unsigned short*)(buf->data.s + left->buf_idx*length_buf_row +
|
||||
workVarCount*scount + left->offset);
|
||||
unsigned short* rdst = (unsigned short*)(buf->data.s + right->buf_idx*buf->cols +
|
||||
unsigned short* rdst = (unsigned short*)(buf->data.s + right->buf_idx*length_buf_row +
|
||||
workVarCount*scount + right->offset);
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
@@ -1205,9 +1225,9 @@ void CvCascadeBoostTree::split_node_data( CvDTreeNode* node )
|
||||
}
|
||||
else
|
||||
{
|
||||
int* ldst = buf->data.i + left->buf_idx*buf->cols +
|
||||
int* ldst = buf->data.i + left->buf_idx*length_buf_row +
|
||||
workVarCount*scount + left->offset;
|
||||
int* rdst = buf->data.i + right->buf_idx*buf->cols +
|
||||
int* rdst = buf->data.i + right->buf_idx*length_buf_row +
|
||||
workVarCount*scount + right->offset;
|
||||
for (int i = 0; i < n; i++)
|
||||
{
|
||||
@@ -1352,6 +1372,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
|
||||
sampleIdx = data->get_sample_indices( data->data_root, sampleIdxBuf );
|
||||
}
|
||||
CvMat* buf = data->buf;
|
||||
size_t length_buf_row = data->get_length_subbuf();
|
||||
if( !tree ) // before training the first tree, initialize weights and other parameters
|
||||
{
|
||||
int* classLabelsBuf = (int*)cur_inn_buf_pos; cur_inn_buf_pos = (uchar*)(classLabelsBuf + n);
|
||||
@@ -1375,7 +1396,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
|
||||
|
||||
if (data->is_buf_16u)
|
||||
{
|
||||
unsigned short* labels = (unsigned short*)(buf->data.s + data->data_root->buf_idx*buf->cols +
|
||||
unsigned short* labels = (unsigned short*)(buf->data.s + data->data_root->buf_idx*length_buf_row +
|
||||
data->data_root->offset + (data->work_var_count-1)*data->sample_count);
|
||||
for( int i = 0; i < n; i++ )
|
||||
{
|
||||
@@ -1393,7 +1414,7 @@ void CvCascadeBoost::update_weights( CvBoostTree* tree )
|
||||
}
|
||||
else
|
||||
{
|
||||
int* labels = buf->data.i + data->data_root->buf_idx*buf->cols +
|
||||
int* labels = buf->data.i + data->data_root->buf_idx*length_buf_row +
|
||||
data->data_root->offset + (data->work_var_count-1)*data->sample_count;
|
||||
|
||||
for( int i = 0; i < n; i++ )
|
||||
|
||||
@@ -302,7 +302,7 @@ macro(add_android_project target path)
|
||||
COMMAND ${CMAKE_COMMAND} -E touch "${android_proj_bin_dir}/bin/${target}-debug.apk" # needed because ant does not update the timestamp of updated apk
|
||||
WORKING_DIRECTORY "${android_proj_bin_dir}"
|
||||
MAIN_DEPENDENCY "${android_proj_bin_dir}/${ANDROID_MANIFEST_FILE}"
|
||||
DEPENDS "${OpenCV_BINARY_DIR}/bin/.classes.jar.dephelper" opencv_java # as we are part of OpenCV we can just force this dependency
|
||||
DEPENDS "${OpenCV_BINARY_DIR}/bin/classes.jar.dephelper" opencv_java # as we are part of OpenCV we can just force this dependency
|
||||
DEPENDS ${android_proj_file_deps} ${JNI_LIB_NAME})
|
||||
endif()
|
||||
|
||||
|
||||
@@ -3,17 +3,17 @@ if(${CMAKE_VERSION} VERSION_LESS "2.8.3")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (WIN32 AND NOT MSVC)
|
||||
message(STATUS "CUDA compilation is disabled (due to only Visual Studio compiler suppoted on your platform).")
|
||||
if(WIN32 AND NOT MSVC)
|
||||
message(STATUS "CUDA compilation is disabled (due to only Visual Studio compiler supported on your platform).")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
message(STATUS "CUDA compilation is disabled (due to Clang unsuppoted on your platform).")
|
||||
if(CMAKE_COMPILER_IS_GNUCXX AND NOT APPLE AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
message(STATUS "CUDA compilation is disabled (due to Clang unsupported on your platform).")
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(CUDA 4.1)
|
||||
find_package(CUDA 4.2 QUIET)
|
||||
|
||||
if(CUDA_FOUND)
|
||||
set(HAVE_CUDA 1)
|
||||
@@ -26,15 +26,20 @@ if(CUDA_FOUND)
|
||||
set(HAVE_CUBLAS 1)
|
||||
endif()
|
||||
|
||||
message(STATUS "CUDA detected: " ${CUDA_VERSION})
|
||||
|
||||
if(${CUDA_VERSION_STRING} VERSION_GREATER "4.1")
|
||||
set(CUDA_ARCH_BIN "1.1 1.2 1.3 2.0 2.1(2.0) 3.0" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
|
||||
else()
|
||||
set(CUDA_ARCH_BIN "1.1 1.2 1.3 2.0 2.1(2.0)" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
|
||||
if(WITH_NVCUVID)
|
||||
find_cuda_helper_libs(nvcuvid)
|
||||
set(HAVE_NVCUVID 1)
|
||||
endif()
|
||||
|
||||
set(CUDA_ARCH_PTX "2.0" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
|
||||
message(STATUS "CUDA detected: " ${CUDA_VERSION})
|
||||
|
||||
if (CARMA)
|
||||
set(CUDA_ARCH_BIN "2.1(2.0) 3.0" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
|
||||
set(CUDA_ARCH_PTX "3.0" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
|
||||
else()
|
||||
set(CUDA_ARCH_BIN "1.1 1.2 1.3 2.0 2.1(2.0) 3.0" CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
|
||||
set(CUDA_ARCH_PTX "2.0 3.0" CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
|
||||
endif()
|
||||
|
||||
string(REGEX REPLACE "\\." "" ARCH_BIN_NO_POINTS "${CUDA_ARCH_BIN}")
|
||||
string(REGEX REPLACE "\\." "" ARCH_PTX_NO_POINTS "${CUDA_ARCH_PTX}")
|
||||
@@ -72,11 +77,20 @@ if(CUDA_FOUND)
|
||||
|
||||
# Tell NVCC to add PTX intermediate code for the specified architectures
|
||||
string(REGEX MATCHALL "[0-9]+" ARCH_LIST "${ARCH_PTX_NO_POINTS}")
|
||||
foreach(ARCH IN LISTS ARCH_LIST)
|
||||
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${ARCH},code=compute_${ARCH})
|
||||
set(OPENCV_CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX} ${ARCH}")
|
||||
set(OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${ARCH}")
|
||||
endforeach()
|
||||
foreach(ARCH IN LISTS ARCH_LIST)
|
||||
set(NVCC_FLAGS_EXTRA ${NVCC_FLAGS_EXTRA} -gencode arch=compute_${ARCH},code=compute_${ARCH})
|
||||
set(OPENCV_CUDA_ARCH_PTX "${OPENCV_CUDA_ARCH_PTX} ${ARCH}")
|
||||
set(OPENCV_CUDA_ARCH_FEATURES "${OPENCV_CUDA_ARCH_FEATURES} ${ARCH}")
|
||||
endforeach()
|
||||
|
||||
if(CARMA)
|
||||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --target-cpu-architecture=ARM" )
|
||||
|
||||
if (CMAKE_VERSION VERSION_LESS 2.8.10)
|
||||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -ccbin=${CMAKE_CXX_COMPILER}" )
|
||||
endif()
|
||||
|
||||
endif()
|
||||
|
||||
# These vars will be processed in other scripts
|
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ${NVCC_FLAGS_EXTRA})
|
||||
@@ -84,7 +98,7 @@ if(CUDA_FOUND)
|
||||
|
||||
message(STATUS "CUDA NVCC target flags: ${CUDA_NVCC_FLAGS}")
|
||||
|
||||
OCV_OPTION(CUDA_FAST_MATH "Enable --use_fast_math for CUDA compiler " OFF)
|
||||
OCV_OPTION(CUDA_FAST_MATH "Enable --use_fast_math for CUDA compiler " OFF)
|
||||
|
||||
if(CUDA_FAST_MATH)
|
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} --use_fast_math)
|
||||
@@ -92,7 +106,6 @@ if(CUDA_FOUND)
|
||||
|
||||
mark_as_advanced(CUDA_BUILD_CUBIN CUDA_BUILD_EMULATION CUDA_VERBOSE_BUILD CUDA_SDK_ROOT_DIR)
|
||||
|
||||
unset(CUDA_npp_LIBRARY CACHE)
|
||||
find_cuda_helper_libs(npp)
|
||||
|
||||
macro(ocv_cuda_compile VAR)
|
||||
@@ -106,15 +119,15 @@ if(CUDA_FOUND)
|
||||
string(REPLACE "-ggdb3" "" ${var} "${${var}}")
|
||||
endforeach()
|
||||
|
||||
if (BUILD_SHARED_LIBS)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -DCVAPI_EXPORTS)
|
||||
endif()
|
||||
|
||||
if(UNIX OR APPLE)
|
||||
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fPIC)
|
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fPIC)
|
||||
endif()
|
||||
if(APPLE)
|
||||
set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fno-finite-math-only)
|
||||
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} -Xcompiler -fno-finite-math-only)
|
||||
endif()
|
||||
|
||||
# disabled because of multiple warnings during building nvcc auto generated files
|
||||
|
||||
+140
-72
@@ -1,78 +1,146 @@
|
||||
if(APPLE)
|
||||
set(OPENCL_FOUND YES)
|
||||
set(OPENCL_LIBRARIES "-framework OpenCL")
|
||||
set(OPENCL_FOUND YES)
|
||||
set(OPENCL_LIBRARIES "-framework OpenCL")
|
||||
else()
|
||||
#find_package(OpenCL QUIET)
|
||||
if(WITH_OPENCLAMDFFT)
|
||||
find_path(CLAMDFFT_INCLUDE_DIR
|
||||
NAMES clAmdFft.h)
|
||||
find_library(CLAMDFFT_LIBRARIES
|
||||
NAMES clAmdFft.Runtime)
|
||||
find_package(OpenCL QUIET)
|
||||
if(WITH_OPENCLAMDFFT)
|
||||
set(CLAMDFFT_SEARCH_PATH $ENV{CLAMDFFT_PATH})
|
||||
if(NOT CLAMDFFT_SEARCH_PATH)
|
||||
if(WIN32)
|
||||
set( CLAMDFFT_SEARCH_PATH "C:\\Program Files (x86)\\AMD\\clAmdFft" )
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_OPENCLAMDBLAS)
|
||||
find_path(CLAMDBLAS_INCLUDE_DIR
|
||||
NAMES clAmdBlas.h)
|
||||
find_library(CLAMDBLAS_LIBRARIES
|
||||
NAMES clAmdBlas)
|
||||
endif()
|
||||
# Try AMD/ATI Stream SDK
|
||||
if (NOT OPENCL_FOUND)
|
||||
set(ENV_AMDSTREAMSDKROOT $ENV{AMDAPPSDKROOT})
|
||||
set(ENV_OPENCLROOT $ENV{OPENCLROOT})
|
||||
set(ENV_CUDA_PATH $ENV{CUDA_PATH})
|
||||
if(ENV_AMDSTREAMSDKROOT)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_AMDSTREAMSDKROOT}/include)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_AMDSTREAMSDKROOT}/lib/x86)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_AMDSTREAMSDKROOT}/lib/x86_64)
|
||||
endif()
|
||||
elseif(ENV_CUDA_PATH AND WIN32)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_CUDA_PATH}/include)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_CUDA_PATH}/lib/Win32)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_CUDA_PATH}/lib/x64)
|
||||
endif()
|
||||
elseif(ENV_OPENCLROOT AND UNIX)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_OPENCLROOT}/inc)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} /usr/lib)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} /usr/lib64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OPENCL_INCLUDE_SEARCH_PATH)
|
||||
find_path(OPENCL_INCLUDE_DIR
|
||||
NAMES CL/cl.h OpenCL/cl.h
|
||||
PATHS ${OPENCL_INCLUDE_SEARCH_PATH}
|
||||
NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_path(OPENCL_INCLUDE_DIR
|
||||
NAMES CL/cl.h OpenCL/cl.h)
|
||||
endif()
|
||||
|
||||
if(OPENCL_LIB_SEARCH_PATH)
|
||||
find_library(OPENCL_LIBRARY NAMES OpenCL PATHS ${OPENCL_LIB_SEARCH_PATH} NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library(OPENCL_LIBRARY NAMES OpenCL)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
OPENCL
|
||||
DEFAULT_MSG
|
||||
OPENCL_LIBRARY OPENCL_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(OPENCL_FOUND)
|
||||
set(OPENCL_LIBRARIES ${OPENCL_LIBRARY})
|
||||
set(HAVE_OPENCL 1)
|
||||
else()
|
||||
set(OPENCL_LIBRARIES)
|
||||
endif()
|
||||
set( CLAMDFFT_INCLUDE_SEARCH_PATH ${CLAMDFFT_SEARCH_PATH}/include )
|
||||
if(UNIX)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(CLAMDFFT_LIB_SEARCH_PATH /usr/lib)
|
||||
else()
|
||||
set(CLAMDFFT_LIB_SEARCH_PATH /usr/lib64)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_OPENCL 1)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(CLAMDFFT_LIB_SEARCH_PATH ${CLAMDFFT_SEARCH_PATH}\\lib32\\import)
|
||||
else()
|
||||
set(CLAMDFFT_LIB_SEARCH_PATH ${CLAMDFFT_SEARCH_PATH}\\lib64\\import)
|
||||
endif()
|
||||
endif()
|
||||
find_path(CLAMDFFT_INCLUDE_DIR
|
||||
NAMES clAmdFft.h
|
||||
PATHS ${CLAMDFFT_INCLUDE_SEARCH_PATH}
|
||||
PATH_SUFFIXES clAmdFft
|
||||
NO_DEFAULT_PATH)
|
||||
find_library(CLAMDFFT_LIBRARY
|
||||
NAMES clAmdFft.Runtime
|
||||
PATHS ${CLAMDFFT_LIB_SEARCH_PATH}
|
||||
NO_DEFAULT_PATH)
|
||||
if(CLAMDFFT_LIBRARY)
|
||||
set(CLAMDFFT_LIBRARIES ${CLAMDFFT_LIBRARY})
|
||||
else()
|
||||
set(CLAMDFFT_LIBRARIES "")
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_OPENCLAMDBLAS)
|
||||
set(CLAMDBLAS_SEARCH_PATH $ENV{CLAMDBLAS_PATH})
|
||||
if(NOT CLAMDBLAS_SEARCH_PATH)
|
||||
if(WIN32)
|
||||
set( CLAMDBLAS_SEARCH_PATH "C:\\Program Files (x86)\\AMD\\clAmdBlas" )
|
||||
endif()
|
||||
endif()
|
||||
set( CLAMDBLAS_INCLUDE_SEARCH_PATH ${CLAMDBLAS_SEARCH_PATH}/include )
|
||||
if(UNIX)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(CLAMDBLAS_LIB_SEARCH_PATH /usr/lib)
|
||||
else()
|
||||
set(CLAMDBLAS_LIB_SEARCH_PATH /usr/lib64)
|
||||
endif()
|
||||
else()
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(CLAMDBLAS_LIB_SEARCH_PATH ${CLAMDBLAS_SEARCH_PATH}\\lib32\\import)
|
||||
else()
|
||||
set(CLAMDBLAS_LIB_SEARCH_PATH ${CLAMDBLAS_SEARCH_PATH}\\lib64\\import)
|
||||
endif()
|
||||
endif()
|
||||
find_path(CLAMDBLAS_INCLUDE_DIR
|
||||
NAMES clAmdBlas.h
|
||||
PATHS ${CLAMDBLAS_INCLUDE_SEARCH_PATH}
|
||||
PATH_SUFFIXES clAmdBlas
|
||||
NO_DEFAULT_PATH)
|
||||
find_library(CLAMDBLAS_LIBRARY
|
||||
NAMES clAmdBlas
|
||||
PATHS ${CLAMDBLAS_LIB_SEARCH_PATH}
|
||||
NO_DEFAULT_PATH)
|
||||
if(CLAMDBLAS_LIBRARY)
|
||||
set(CLAMDBLAS_LIBRARIES ${CLAMDBLAS_LIBRARY})
|
||||
else()
|
||||
set(CLAMDBLAS_LIBRARIES "")
|
||||
endif()
|
||||
endif()
|
||||
# Try AMD/ATI Stream SDK
|
||||
if (NOT OPENCL_FOUND)
|
||||
set(ENV_AMDSTREAMSDKROOT $ENV{AMDAPPSDKROOT})
|
||||
set(ENV_AMDAPPSDKROOT $ENV{AMDAPPSDKROOT})
|
||||
set(ENV_OPENCLROOT $ENV{OPENCLROOT})
|
||||
set(ENV_CUDA_PATH $ENV{CUDA_PATH})
|
||||
if(ENV_AMDSTREAMSDKROOT)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_AMDAPPSDKROOT}/include)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_AMDAPPSDKROOT}/lib/x86)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_AMDAPPSDKROOT}/lib/x86_64)
|
||||
endif()
|
||||
elseif(ENV_AMDSTREAMSDKROOT)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_AMDSTREAMSDKROOT}/include)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_AMDSTREAMSDKROOT}/lib/x86)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_AMDSTREAMSDKROOT}/lib/x86_64)
|
||||
endif()
|
||||
elseif(ENV_CUDA_PATH AND WIN32)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_CUDA_PATH}/include)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_CUDA_PATH}/lib/Win32)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_CUDA_PATH}/lib/x64)
|
||||
endif()
|
||||
elseif(ENV_OPENCLROOT AND UNIX)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_OPENCLROOT}/inc)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} /usr/lib)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} /usr/lib64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OPENCL_INCLUDE_SEARCH_PATH)
|
||||
find_path(OPENCL_INCLUDE_DIR
|
||||
NAMES CL/cl.h OpenCL/cl.h
|
||||
PATHS ${OPENCL_INCLUDE_SEARCH_PATH}
|
||||
NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_path(OPENCL_INCLUDE_DIR
|
||||
NAMES CL/cl.h OpenCL/cl.h)
|
||||
endif()
|
||||
|
||||
if(OPENCL_LIB_SEARCH_PATH)
|
||||
find_library(OPENCL_LIBRARY NAMES OpenCL PATHS ${OPENCL_LIB_SEARCH_PATH} NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library(OPENCL_LIBRARY NAMES OpenCL)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(
|
||||
OPENCL
|
||||
DEFAULT_MSG
|
||||
OPENCL_LIBRARY OPENCL_INCLUDE_DIR
|
||||
)
|
||||
|
||||
if(OPENCL_FOUND)
|
||||
set(OPENCL_LIBRARIES ${OPENCL_LIBRARY})
|
||||
set(HAVE_OPENCL 1)
|
||||
else()
|
||||
set(OPENCL_LIBRARIES)
|
||||
endif()
|
||||
else()
|
||||
set(HAVE_OPENCL 1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
if(ANDROID AND NOT MIPS)
|
||||
if(BUILD_TBB)
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/tbb")
|
||||
include_directories(SYSTEM ${TBB_INCLUDE_DIRS})
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
|
||||
@@ -22,7 +22,7 @@ endif()
|
||||
|
||||
if(NOT HAVE_TBB)
|
||||
set(TBB_DEFAULT_INCLUDE_DIRS
|
||||
"/opt/intel/tbb" "/usr/local/include" "/usr/include"
|
||||
"/opt/intel/tbb/include" "/usr/local/include" "/usr/include"
|
||||
"C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB"
|
||||
"C:/Program Files (x86)/tbb/include"
|
||||
"C:/Program Files (x86)/tbb/include"
|
||||
|
||||
@@ -16,7 +16,7 @@ endif()
|
||||
# Source package, for "make package_source"
|
||||
# ----------------------------------------------------------------------------
|
||||
if(BUILD_PACKAGE)
|
||||
set(TARBALL_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
|
||||
set(TARBALL_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VERSION}")
|
||||
if (NOT WIN32)
|
||||
if(APPLE)
|
||||
set(TAR_CMD gnutar)
|
||||
|
||||
@@ -85,11 +85,12 @@ if(WITH_XINE)
|
||||
endif(WITH_XINE)
|
||||
|
||||
# --- V4L ---
|
||||
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2)
|
||||
ocv_clear_vars(HAVE_LIBV4L HAVE_CAMV4L HAVE_CAMV4L2 HAVE_VIDEOIO)
|
||||
if(WITH_V4L)
|
||||
CHECK_MODULE(libv4l1 HAVE_LIBV4L)
|
||||
CHECK_INCLUDE_FILE(linux/videodev.h HAVE_CAMV4L)
|
||||
CHECK_INCLUDE_FILE(linux/videodev2.h HAVE_CAMV4L2)
|
||||
CHECK_INCLUDE_FILE(sys/videoio.h HAVE_VIDEOIO)
|
||||
endif(WITH_V4L)
|
||||
|
||||
# --- OpenNI ---
|
||||
|
||||
@@ -164,6 +164,9 @@ macro(ocv_module_disable module)
|
||||
set(HAVE_${__modname} OFF CACHE INTERNAL "Module ${__modname} can not be built in current configuration")
|
||||
set(OPENCV_MODULE_${__modname}_LOCATION "${CMAKE_CURRENT_SOURCE_DIR}" CACHE INTERNAL "Location of ${__modname} module sources")
|
||||
set(OPENCV_MODULES_DISABLED_FORCE "${OPENCV_MODULES_DISABLED_FORCE}" CACHE INTERNAL "List of OpenCV modules which can not be build in current configuration")
|
||||
if(BUILD_${__modname})
|
||||
# touch variable controlling build of the module to suppress "unused variable" CMake warning
|
||||
endif()
|
||||
unset(__modname)
|
||||
return() # leave the current folder
|
||||
endmacro()
|
||||
@@ -171,6 +174,7 @@ endmacro()
|
||||
|
||||
# Internal macro; partly disables OpenCV module
|
||||
macro(__ocv_module_turn_off the_module)
|
||||
list(REMOVE_ITEM OPENCV_MODULES_DISABLED_AUTO "${the_module}")
|
||||
list(APPEND OPENCV_MODULES_DISABLED_AUTO "${the_module}")
|
||||
list(REMOVE_ITEM OPENCV_MODULES_BUILD "${the_module}")
|
||||
list(REMOVE_ITEM OPENCV_MODULES_PUBLIC "${the_module}")
|
||||
@@ -190,7 +194,7 @@ macro(__ocv_flatten_module_required_dependencies the_module)
|
||||
break()
|
||||
elseif(";${OPENCV_MODULES_DISABLED_USER};${OPENCV_MODULES_DISABLED_AUTO};" MATCHES ";${__dep};")
|
||||
__ocv_module_turn_off(${the_module}) # depends on disabled module
|
||||
break()
|
||||
list(APPEND __flattened_deps "${__dep}")
|
||||
elseif(";${OPENCV_MODULES_BUILD};" MATCHES ";${__dep};")
|
||||
if(";${__resolved_deps};" MATCHES ";${__dep};")
|
||||
list(APPEND __flattened_deps "${__dep}") # all dependencies of this module are already resolved
|
||||
@@ -259,6 +263,7 @@ macro(__ocv_flatten_module_dependencies)
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
set(HAVE_${m} ON CACHE INTERNAL "Module ${m} will be built in current configuration")
|
||||
__ocv_flatten_module_required_dependencies(${m})
|
||||
set(OPENCV_MODULE_${m}_DEPS ${OPENCV_MODULE_${m}_DEPS} CACHE INTERNAL "Flattened required dependencies of ${m} module")
|
||||
endforeach()
|
||||
|
||||
foreach(m ${OPENCV_MODULES_BUILD})
|
||||
@@ -283,7 +288,7 @@ macro(__ocv_flatten_module_dependencies)
|
||||
ocv_list_unique(OPENCV_MODULES_BUILD_)
|
||||
|
||||
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} CACHE INTERNAL "List of OpenCV modules marked for export")
|
||||
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD_} CACHE INTERNAL "List of OpenCV modules included into the build")
|
||||
set(OPENCV_MODULES_BUILD ${OPENCV_MODULES_BUILD_} CACHE INTERNAL "List of OpenCV modules included into the build")
|
||||
set(OPENCV_MODULES_DISABLED_AUTO ${OPENCV_MODULES_DISABLED_AUTO} CACHE INTERNAL "List of OpenCV modules implicitly disabled due to dependencies")
|
||||
endmacro()
|
||||
|
||||
@@ -456,6 +461,7 @@ macro(ocv_create_module)
|
||||
OUTPUT_NAME "${the_module}${OPENCV_DLLVERSION}"
|
||||
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${LIBRARY_OUTPUT_PATH}
|
||||
RUNTIME_OUTPUT_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
|
||||
INSTALL_NAME_DIR lib
|
||||
)
|
||||
@@ -465,7 +471,7 @@ macro(ocv_create_module)
|
||||
# Android SDK build scripts can include only .so files into final .apk
|
||||
# As result we should not set version properties for Android
|
||||
set_target_properties(${the_module} PROPERTIES
|
||||
VERSION ${OPENCV_VERSION}
|
||||
VERSION ${OPENCV_LIBVERSION}
|
||||
SOVERSION ${OPENCV_SOVERSION}
|
||||
)
|
||||
endif()
|
||||
|
||||
@@ -64,6 +64,13 @@ MACRO(ocv_check_compiler_flag LANG FLAG RESULT)
|
||||
else()
|
||||
FILE(WRITE "${_fname}" "#pragma\nint main(void) { return 0; }\n")
|
||||
endif()
|
||||
elseif("_${LANG}_" MATCHES "_OBJCXX_")
|
||||
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.mm")
|
||||
if("${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror " OR "${CMAKE_CXX_FLAGS} ${FLAG} " MATCHES "-Werror=unknown-pragmas ")
|
||||
FILE(WRITE "${_fname}" "int main() { return 0; }\n")
|
||||
else()
|
||||
FILE(WRITE "${_fname}" "#pragma\nint main() { return 0; }\n")
|
||||
endif()
|
||||
else()
|
||||
unset(_fname)
|
||||
endif()
|
||||
@@ -100,6 +107,8 @@ macro(ocv_check_flag_support lang flag varname)
|
||||
set(_lang CXX)
|
||||
elseif("_${lang}_" MATCHES "_C_")
|
||||
set(_lang C)
|
||||
elseif("_${lang}_" MATCHES "_OBJCXX_")
|
||||
set(_lang OBJCXX)
|
||||
else()
|
||||
set(_lang ${lang})
|
||||
endif()
|
||||
|
||||
@@ -1,12 +1,18 @@
|
||||
SET(OPENCV_VERSION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/modules/core/include/opencv2/core/version.hpp")
|
||||
FILE(STRINGS "${OPENCV_VERSION_FILE}" OPENCV_VERSION_PARTS REGEX "#define CV_.+OR_VERSION[ ]+[0-9]+" )
|
||||
FILE(STRINGS "${OPENCV_VERSION_FILE}" OPENCV_VERSION_PARTS REGEX "#define CV_VERSION_[A-Z]+[ ]+[0-9]+" )
|
||||
|
||||
string(REGEX REPLACE ".+CV_MAJOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MAJOR "${OPENCV_VERSION_PARTS}")
|
||||
string(REGEX REPLACE ".+CV_MINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MINOR "${OPENCV_VERSION_PARTS}")
|
||||
string(REGEX REPLACE ".+CV_SUBMINOR_VERSION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_PATCH "${OPENCV_VERSION_PARTS}")
|
||||
string(REGEX REPLACE ".+CV_VERSION_EPOCH[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MAJOR "${OPENCV_VERSION_PARTS}")
|
||||
string(REGEX REPLACE ".+CV_VERSION_MAJOR[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_MINOR "${OPENCV_VERSION_PARTS}")
|
||||
string(REGEX REPLACE ".+CV_VERSION_MINOR[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_PATCH "${OPENCV_VERSION_PARTS}")
|
||||
string(REGEX REPLACE ".+CV_VERSION_REVISION[ ]+([0-9]+).*" "\\1" OPENCV_VERSION_TWEAK "${OPENCV_VERSION_PARTS}")
|
||||
|
||||
set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
|
||||
if(OPENCV_VERSION_TWEAK GREATER 0)
|
||||
set(OPENCV_VERSION "${OPENCV_VERSION}.${OPENCV_VERSION_TWEAK}")
|
||||
endif()
|
||||
|
||||
set(OPENCV_VERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}.2")
|
||||
set(OPENCV_SOVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}")
|
||||
set(OPENCV_LIBVERSION "${OPENCV_VERSION_MAJOR}.${OPENCV_VERSION_MINOR}.${OPENCV_VERSION_PATCH}")
|
||||
|
||||
# create a dependency on version file
|
||||
# we never use output of the following command but cmake will rerun automatically if the version file changes
|
||||
|
||||
@@ -89,14 +89,20 @@ define add_opencv_camera_module
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
endef
|
||||
|
||||
ifeq ($(OPENCV_INSTALL_MODULES),on)
|
||||
$(foreach module,$(OPENCV_LIBS),$(eval $(call add_opencv_module,$(module))))
|
||||
endif
|
||||
$(foreach module,$(OPENCV_3RDPARTY_COMPONENTS),$(eval $(call add_opencv_3rdparty_component,$(module))))
|
||||
$(foreach module,$(OPENCV_CAMERA_MODULES),$(eval $(call add_opencv_camera_module,$(module))))
|
||||
ifeq ($(OPENCV_MK_ALREADY_INCLUDED),)
|
||||
ifeq ($(OPENCV_INSTALL_MODULES),on)
|
||||
$(foreach module,$(OPENCV_LIBS),$(eval $(call add_opencv_module,$(module))))
|
||||
endif
|
||||
|
||||
ifneq ($(OPENCV_BASEDIR),)
|
||||
OPENCV_LOCAL_C_INCLUDES += $(foreach mod, $(OPENCV_MODULES), $(OPENCV_BASEDIR)/modules/$(mod)/include)
|
||||
$(foreach module,$(OPENCV_3RDPARTY_COMPONENTS),$(eval $(call add_opencv_3rdparty_component,$(module))))
|
||||
$(foreach module,$(OPENCV_CAMERA_MODULES),$(eval $(call add_opencv_camera_module,$(module))))
|
||||
|
||||
ifneq ($(OPENCV_BASEDIR),)
|
||||
OPENCV_LOCAL_C_INCLUDES += $(foreach mod, $(OPENCV_MODULES), $(OPENCV_BASEDIR)/modules/$(mod)/include)
|
||||
endif
|
||||
|
||||
#turn off module installation to prevent their redefinition
|
||||
OPENCV_MK_ALREADY_INCLUDED:=on
|
||||
endif
|
||||
|
||||
ifeq ($(OPENCV_LOCAL_CFLAGS),)
|
||||
|
||||
@@ -22,10 +22,11 @@
|
||||
# - OpenCV_INCLUDE_DIRS : The OpenCV include directories.
|
||||
# - OpenCV_COMPUTE_CAPABILITIES : The version of compute capability
|
||||
# - OpenCV_ANDROID_NATIVE_API_LEVEL : Minimum required level of Android API
|
||||
# - OpenCV_VERSION : The version of this OpenCV build. Example: "@OPENCV_VERSION@"
|
||||
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_MAJOR@"
|
||||
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_MINOR@"
|
||||
# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION. Example: "@OPENCV_VERSION_PATCH@"
|
||||
# - OpenCV_VERSION : The version of this OpenCV build: "@OPENCV_VERSION@"
|
||||
# - OpenCV_VERSION_MAJOR : Major version part of OpenCV_VERSION: "@OPENCV_VERSION_MAJOR@"
|
||||
# - OpenCV_VERSION_MINOR : Minor version part of OpenCV_VERSION: "@OPENCV_VERSION_MINOR@"
|
||||
# - OpenCV_VERSION_PATCH : Patch version part of OpenCV_VERSION: "@OPENCV_VERSION_PATCH@"
|
||||
# - OpenCV_VERSION_TWEAK : Tweak version part of OpenCV_VERSION: "@OPENCV_VERSION_TWEAK@"
|
||||
#
|
||||
# Advanced variables:
|
||||
# - OpenCV_SHARED
|
||||
@@ -41,8 +42,9 @@
|
||||
set(OpenCV_COMPUTE_CAPABILITIES @OpenCV_CUDA_CC_CONFIGCMAKE@)
|
||||
|
||||
set(OpenCV_CUDA_VERSION @OpenCV_CUDA_VERSION@)
|
||||
set(OpenCV_USE_CUBLAS @HAVE_CUBLAS@)
|
||||
set(OpenCV_USE_CUFFT @HAVE_CUFFT@)
|
||||
set(OpenCV_USE_CUBLAS @HAVE_CUBLAS@)
|
||||
set(OpenCV_USE_CUFFT @HAVE_CUFFT@)
|
||||
set(OpenCV_USE_NVCUVID @HAVE_NVCUVID@)
|
||||
|
||||
# Android API level from which OpenCV has been compiled is remembered
|
||||
set(OpenCV_ANDROID_NATIVE_API_LEVEL @OpenCV_ANDROID_NATIVE_API_LEVEL_CONFIGCMAKE@)
|
||||
@@ -99,6 +101,7 @@ SET(OpenCV_VERSION @OPENCV_VERSION@)
|
||||
SET(OpenCV_VERSION_MAJOR @OPENCV_VERSION_MAJOR@)
|
||||
SET(OpenCV_VERSION_MINOR @OPENCV_VERSION_MINOR@)
|
||||
SET(OpenCV_VERSION_PATCH @OPENCV_VERSION_PATCH@)
|
||||
SET(OpenCV_VERSION_TWEAK @OPENCV_VERSION_TWEAK@)
|
||||
|
||||
# ====================================================================
|
||||
# Link libraries: e.g. libopencv_core.so, opencv_imgproc220d.lib, etc...
|
||||
@@ -183,7 +186,7 @@ set(OpenCV_FIND_COMPONENTS ${OpenCV_FIND_COMPONENTS_})
|
||||
# Resolve dependencies
|
||||
# ==============================================================
|
||||
if(OpenCV_USE_MANGLED_PATHS)
|
||||
set(OpenCV_LIB_SUFFIX ".${OpenCV_VERSION}")
|
||||
set(OpenCV_LIB_SUFFIX ".${OpenCV_VERSION_MAJOR}.${OpenCV_VERSION_MINOR}.${OpenCV_VERSION_PATCH}")
|
||||
else()
|
||||
set(OpenCV_LIB_SUFFIX "")
|
||||
endif()
|
||||
@@ -216,17 +219,22 @@ foreach(__opttype OPT DBG)
|
||||
else()
|
||||
#TODO: duplicates are annoying but they should not be the problem
|
||||
endif()
|
||||
# fix hard coded paths for CUDA libraries under Windows
|
||||
if(WIN32 AND OpenCV_CUDA_VERSION AND NOT OpenCV_SHARED)
|
||||
|
||||
# CUDA
|
||||
if(OpenCV_CUDA_VERSION AND (CARMA OR (WIN32 AND NOT OpenCV_SHARED)))
|
||||
if(NOT CUDA_FOUND)
|
||||
find_package(CUDA ${OpenCV_CUDA_VERSION} EXACT REQUIRED)
|
||||
else()
|
||||
if(NOT CUDA_VERSION_STRING VERSION_EQUAL OpenCV_CUDA_VERSION)
|
||||
message(FATAL_ERROR "OpenCV static library compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}")
|
||||
if(WIN32)
|
||||
message(FATAL_ERROR "OpenCV static library was compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}")
|
||||
else()
|
||||
message(FATAL_ERROR "OpenCV library for CARMA was compiled with CUDA ${OpenCV_CUDA_VERSION} support. Please, use the same version or rebuild OpenCV with CUDA ${CUDA_VERSION_STRING}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY} ${CUDA_nvcuvid_LIBRARY} ${CUDA_nvcuvenc_LIBRARY})
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
|
||||
if(OpenCV_USE_CUBLAS)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_CUBLAS_LIBRARIES})
|
||||
@@ -236,6 +244,13 @@ foreach(__opttype OPT DBG)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_CUFFT_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(OpenCV_USE_NVCUVID)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nvcuvid_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND OpenCV_EXTRA_LIBS_${__opttype} ${CUDA_nvcuvenc_LIBRARIES})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
|
||||
@@ -19,6 +19,9 @@
|
||||
/* V4L2 capturing support */
|
||||
#cmakedefine HAVE_CAMV4L2
|
||||
|
||||
/* V4L2 capturing support in videoio.h */
|
||||
#cmakedefine HAVE_VIDEOIO
|
||||
|
||||
/* V4L/V4L2 capturing support via libv4l */
|
||||
#cmakedefine HAVE_LIBV4L
|
||||
|
||||
@@ -175,21 +178,15 @@
|
||||
/* NVidia Cuda Runtime API*/
|
||||
#cmakedefine HAVE_CUDA
|
||||
|
||||
/* OpenCL Support */
|
||||
#cmakedefine HAVE_OPENCL
|
||||
|
||||
/* AMD's OpenCL Fast Fourier Transform Library*/
|
||||
#cmakedefine HAVE_CLAMDFFT
|
||||
|
||||
/* AMD's Basic Linear Algebra Subprograms Library*/
|
||||
#cmakedefine HAVE_CLAMDBLAS
|
||||
|
||||
/* NVidia Cuda Fast Fourier Transform (FFT) API*/
|
||||
#cmakedefine HAVE_CUFFT
|
||||
|
||||
/* NVidia Cuda Basic Linear Algebra Subprograms (BLAS) API*/
|
||||
#cmakedefine HAVE_CUBLAS
|
||||
|
||||
/* NVidia Video Decoding API*/
|
||||
#cmakedefine HAVE_NVCUVID
|
||||
|
||||
/* Compile for 'real' NVIDIA GPU architectures */
|
||||
#define CUDA_ARCH_BIN "${OPENCV_CUDA_ARCH_BIN}"
|
||||
|
||||
@@ -202,6 +199,15 @@
|
||||
/* Create PTX or BIN for 1.0 compute capability */
|
||||
#cmakedefine CUDA_ARCH_BIN_OR_PTX_10
|
||||
|
||||
/* OpenCL Support */
|
||||
#cmakedefine HAVE_OPENCL
|
||||
|
||||
/* AMD's OpenCL Fast Fourier Transform Library*/
|
||||
#cmakedefine HAVE_CLAMDFFT
|
||||
|
||||
/* AMD's Basic Linear Algebra Subprograms Library*/
|
||||
#cmakedefine HAVE_CLAMDBLAS
|
||||
|
||||
/* VideoInput library */
|
||||
#cmakedefine HAVE_VIDEOINPUT
|
||||
|
||||
|
||||
+16
-9
@@ -60,7 +60,7 @@ if(BUILD_DOCS AND HAVE_SPHINX)
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/modules/refman.rst.in" "${OpenCV_SOURCE_DIR}/modules/refman.rst" IMMEDIATE @ONLY)
|
||||
|
||||
file(GLOB_RECURSE OPENCV_FILES_UG user_guide/*.rst)
|
||||
file(GLOB_RECURSE OPENCV_FILES_UG user_guide/*.rst)
|
||||
file(GLOB_RECURSE OPENCV_FILES_TUT tutorials/*.rst)
|
||||
file(GLOB_RECURSE OPENCV_FILES_TUT_PICT tutorials/*.png tutorials/*.jpg)
|
||||
|
||||
@@ -74,14 +74,21 @@ if(BUILD_DOCS AND HAVE_SPHINX)
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/mymath.sty ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2refman.tex
|
||||
COMMAND ${PYTHON_EXECUTABLE} "${CMAKE_CURRENT_SOURCE_DIR}/patch_refman_latex.py" opencv2manager.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv2refman.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv2manager.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv_user.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv_user.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} opencv_tutorials.tex
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv2refman.pdf"
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2refman.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2refman.tex
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv2manager.pdf"
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2manager.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv2manager.tex
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv_user.pdf"
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_user.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_user.tex
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv_tutorials.pdf"
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_tutorials.tex
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode opencv_tutorials.tex
|
||||
COMMAND ${CMAKE_COMMAND} -E echo "Generating opencv_cheatsheet.pdf"
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode "${CMAKE_CURRENT_SOURCE_DIR}/opencv_cheatsheet.tex"
|
||||
COMMAND ${PDFLATEX_COMPILER} -interaction=batchmode "${CMAKE_CURRENT_SOURCE_DIR}/opencv_cheatsheet.tex"
|
||||
DEPENDS ${OPENCV_DOC_DEPS}
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating the PDF Manuals"
|
||||
|
||||
@@ -116,6 +116,8 @@ def compareSignatures(f, s):
|
||||
sarg = arg[1]
|
||||
ftype = re.sub(r"\b(cv|std)::", "", (farg[0] or ""))
|
||||
stype = re.sub(r"\b(cv|std)::", "", (sarg[0] or ""))
|
||||
ftype = re.sub(r"\s+(\*|&)$", "\\1", ftype)
|
||||
stype = re.sub(r"\s+(\*|&)$", "\\1", stype)
|
||||
if ftype != stype:
|
||||
return False, "type of argument #" + str(idx+1) + " mismatch"
|
||||
fname = farg[1] or "arg" + str(idx)
|
||||
@@ -151,6 +153,7 @@ def formatSignature(s):
|
||||
if idx > 0:
|
||||
_str += ", "
|
||||
argtype = re.sub(r"\bcv::", "", arg[0])
|
||||
argtype = re.sub(r"\s+(\*|&)$", "\\1", arg[0])
|
||||
bidx = argtype.find('[')
|
||||
if bidx < 0:
|
||||
_str += argtype + " "
|
||||
|
||||
+9
-6
@@ -44,21 +44,24 @@ master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'OpenCV'
|
||||
copyright = u'2011-2012, opencv dev team'
|
||||
copyright = u'2011-2013, opencv dev team'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
|
||||
version_file = open("../modules/core/include/opencv2/core/version.hpp", "rt").read()
|
||||
version_major = re.search("^W*#\W*define\W+CV_MAJOR_VERSION\W+(\d+)\W*$", version_file, re.MULTILINE).group(1)
|
||||
version_minor = re.search("^W*#\W*define\W+CV_MINOR_VERSION\W+(\d+)\W*$", version_file, re.MULTILINE).group(1)
|
||||
version_patch = re.search("^W*#\W*define\W+CV_SUBMINOR_VERSION\W+(\d+)\W*$", version_file, re.MULTILINE).group(1)
|
||||
version_epoch = re.search("^W*#\W*define\W+CV_VERSION_EPOCH\W+(\d+)\W*$", version_file, re.MULTILINE).group(1)
|
||||
version_major = re.search("^W*#\W*define\W+CV_VERSION_MAJOR\W+(\d+)\W*$", version_file, re.MULTILINE).group(1)
|
||||
version_minor = re.search("^W*#\W*define\W+CV_VERSION_MINOR\W+(\d+)\W*$", version_file, re.MULTILINE).group(1)
|
||||
version_patch = re.search("^W*#\W*define\W+CV_VERSION_REVISION\W+(\d+)\W*$", version_file, re.MULTILINE).group(1)
|
||||
|
||||
# The short X.Y version.
|
||||
version = version_major + '.' + version_minor
|
||||
version = version_epoch + '.' + version_major
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = version_major + '.' + version_minor + '.' + version_patch
|
||||
release = version_epoch + '.' + version_major + '.' + version_minor
|
||||
if version_patch:
|
||||
release = release + '.' + version_patch
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -67,6 +67,7 @@
|
||||
\usepackage[pdftex]{color,graphicx}
|
||||
\usepackage[landscape]{geometry}
|
||||
\usepackage{hyperref}
|
||||
\usepackage[T1]{fontenc}
|
||||
\hypersetup{colorlinks=true, filecolor=black, linkcolor=black, urlcolor=blue, citecolor=black}
|
||||
\graphicspath{{./images/}}
|
||||
|
||||
@@ -214,7 +215,7 @@
|
||||
\> \texttt{for(int y = 1; y < image.rows-1; y++) \{}\\
|
||||
\> \> \texttt{Vec3b* prevRow = image.ptr<Vec3b>(y-1);}\\
|
||||
\> \> \texttt{Vec3b* nextRow = image.ptr<Vec3b>(y+1);}\\
|
||||
\> \> \texttt{for(int x = 0; y < image.cols; x++)}\\
|
||||
\> \> \texttt{for(int x = 0; x < image.cols; x++)}\\
|
||||
\> \> \> \texttt{for(int c = 0; c < 3; c++)}\\
|
||||
\> \> \> \texttt{ dyImage.at<Vec3b>(y,x)[c] =}\\
|
||||
\> \> \> \texttt{ saturate\_cast<uchar>(}\\
|
||||
|
||||
+33
-31
@@ -6,26 +6,28 @@ Mat - The Basic Image Container
|
||||
Goal
|
||||
====
|
||||
|
||||
We have multiple ways to acquire digital images from the real world: digital cameras, scanners, computed tomography or magnetic resonance imaging to just name a few. In every case what we (humans) see are images. However, when transforming this to our digital devices what we record are numerical values for each of the points of the image.
|
||||
We have multiple ways to acquire digital images from the real world: digital cameras, scanners, computed tomography, and magnetic resonance imaging to name a few. In every case what we (humans) see are images. However, when transforming this to our digital devices what we record are numerical values for each of the points of the image.
|
||||
|
||||
.. image:: images/MatBasicImageForComputer.jpg
|
||||
:alt: A matrix of the mirror of a car
|
||||
:align: center
|
||||
|
||||
For example in the above image you can see that the mirror of the care is nothing more than a matrix containing all the intensity values of the pixel points. Now, how we get and store the pixels values may vary according to what fits best our need, in the end all images inside a computer world may be reduced to numerical matrices and some other information's describing the matric itself. *OpenCV* is a computer vision library whose main focus is to process and manipulate these information to find out further ones. Therefore, the first thing you need to learn and get accommodated with is how OpenCV stores and handles images.
|
||||
For example in the above image you can see that the mirror of the car is nothing more than a matrix containing all the intensity values of the pixel points. How we get and store the pixels values may vary according to our needs, but in the end all images inside a computer world may be reduced to numerical matrices and other information describing the matrix itself. *OpenCV* is a computer vision library whose main focus is to process and manipulate this information. Therefore, the first thing you need to be familiar with is how OpenCV stores and handles images.
|
||||
|
||||
*Mat*
|
||||
=====
|
||||
|
||||
OpenCV has been around ever since 2001. In those days the library was built around a *C* interface. In those days to store the image in the memory they used a C structure entitled *IplImage*. This is the one you'll see in most of the older tutorials and educational materials. The problem with this is that it brings to the table all the minuses of the C language. The biggest issue is the manual management. It builds on the assumption that the user is responsible for taking care of memory allocation and deallocation. While this is no issue in case of smaller programs once your code base start to grove larger and larger it will be more and more a struggle to handle all this rather than focusing on actually solving your development goal.
|
||||
OpenCV has been around since 2001. In those days the library was built around a *C* interface and to store the image in the memory they used a C structure called *IplImage*. This is the one you'll see in most of the older tutorials and educational materials. The problem with this is that it brings to the table all the minuses of the C language. The biggest issue is the manual memory management. It builds on the assumption that the user is responsible for taking care of memory allocation and deallocation. While this is not a problem with smaller programs, once your code base grows it will be more of a struggle to handle all this rather than focusing on solving your development goal.
|
||||
|
||||
Luckily C++ came around and introduced the concept of classes making possible to build another road for the user: automatic memory management (more or less). The good news is that C++ if fully compatible with C so no compatibility issues can arise from making the change. Therefore, OpenCV with its 2.0 version introduced a new C++ interface that by taking advantage of these offers a new way of doing things. A way, in which you do not need to fiddle with memory management; making your code concise (less to write, to achieve more). The only main downside of the C++ interface is that many embedded development systems at the moment support only C. Therefore, unless you are targeting this platform, there's no point on using the *old* methods (unless you're a masochist programmer and you're asking for trouble).
|
||||
Luckily C++ came around and introduced the concept of classes making easier for the user through automatic memory management (more or less). The good news is that C++ is fully compatible with C so no compatibility issues can arise from making the change. Therefore, OpenCV 2.0 introduced a new C++ interface which offered a new way of doing things which means you do not need to fiddle with memory management, making your code concise (less to write, to achieve more). The main downside of the C++ interface is that many embedded development systems at the moment support only C. Therefore, unless you are targeting embedded platforms, there's no point to using the *old* methods (unless you're a masochist programmer and you're asking for trouble).
|
||||
|
||||
The first thing you need to know about *Mat* is that you no longer need to manually allocate its size and release it as soon as you do not need it. While doing this is still a possibility, most of the OpenCV functions will allocate its output data manually. As a nice bonus if you pass on an already existing *Mat* object, what already has allocated the required space for the matrix, this will be reused. In other words we use at all times only as much memory as much we must to perform the task.
|
||||
The first thing you need to know about *Mat* is that you no longer need to manually allocate its memory and release it as soon as you do not need it. While doing this is still a possibility, most of the OpenCV functions will allocate its output data manually. As a nice bonus if you pass on an already existing *Mat* object, which has already allocated the required space for the matrix, this will be reused. In other words we use at all times only as much memory as we need to perform the task.
|
||||
|
||||
*Mat* is basically a class having two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored and so on) and a pointer to the matrix containing the pixel values (may take any dimensionality depending on the method chosen for storing) . The matrix header size is constant. However, the size of the matrix itself may vary from image to image and usually is larger by order of magnitudes. Therefore, when you're passing on images in your program and at some point you need to create a copy of the image the big price you will need to build is for the matrix itself rather than its header. OpenCV is an image processing library. It contains a large collection of image processing functions. To solve a computational challenge most of the time you will end up using multiple functions of the library. Due to this passing on images to functions is a common practice. We should not forget that we are talking about image processing algorithms, which tend to be quite computational heavy. The last thing we want to do is to further decrease the speed of your program by making unnecessary copies of potentially *large* images.
|
||||
*Mat* is basically a class with two data parts: the matrix header (containing information such as the size of the matrix, the method used for storing, at which address is the matrix stored, and so on) and a pointer to the matrix containing the pixel values (taking any dimensionality depending on the method chosen for storing) . The matrix header size is constant, however the size of the matrix itself may vary from image to image and usually is larger by orders of magnitude.
|
||||
|
||||
To tackle this issue OpenCV uses a reference counting system. The idea is that each *Mat* object has its own header, however the matrix may be shared between two instance of them by having their matrix pointer point to the same address. Moreover, the copy operators **will only copy the headers**, and as also copy the pointer to the large matrix too, however not the matrix itself.
|
||||
OpenCV is an image processing library. It contains a large collection of image processing functions. To solve a computational challenge, most of the time you will end up using multiple functions of the library. Because of this, passing images to functions is a common practice. We should not forget that we are talking about image processing algorithms, which tend to be quite computational heavy. The last thing we want to do is further decrease the speed of your program by making unnecessary copies of potentially *large* images.
|
||||
|
||||
To tackle this issue OpenCV uses a reference counting system. The idea is that each *Mat* object has its own header, however the matrix may be shared between two instance of them by having their matrix pointers point to the same address. Moreover, the copy operators **will only copy the headers** and the pointer to the large matrix, not the data itself.
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
@@ -37,7 +39,7 @@ To tackle this issue OpenCV uses a reference counting system. The idea is that e
|
||||
|
||||
C = A; // Assignment operator
|
||||
|
||||
All the above objects, in the end point to the same single data matrix. Their headers are different, however making any modification using either one of them will affect all the other ones too. In practice the different objects just provide different access method to the same underlying data. Nevertheless, their header parts are different. The real interesting part comes that you can create headers that refer only to a subsection of the full data. For example, to create a region of interest (*ROI*) in an image you just create a new header with the new boundaries:
|
||||
All the above objects, in the end, point to the same single data matrix. Their headers are different, however, and making a modification using any of them will affect all the other ones as well. In practice the different objects just provide different access method to the same underlying data. Nevertheless, their header parts are different. The real interesting part is that you can create headers which refer to only a subsection of the full data. For example, to create a region of interest (*ROI*) in an image you just create a new header with the new boundaries:
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
@@ -45,7 +47,7 @@ All the above objects, in the end point to the same single data matrix. Their he
|
||||
Mat D (A, Rect(10, 10, 100, 100) ); // using a rectangle
|
||||
Mat E = A(Range:all(), Range(1,3)); // using row and column boundaries
|
||||
|
||||
Now you may ask if the matrix itself may belong to multiple *Mat* objects who will take responsibility for its cleaning when it's no longer needed. The short answer is: the last object that used it. For this a reference counting mechanism is used. Whenever somebody copies a header of a *Mat* object a counter is increased for the matrix. Whenever a header is cleaned this counter is decreased. When the counter reaches zero the matrix too is freed. Because, sometimes you will still want to copy the matrix itself too, there exists the :basicstructures:`clone() <mat-clone>` or the :basicstructures:`copyTo() <mat-copyto>` function.
|
||||
Now you may ask if the matrix itself may belong to multiple *Mat* objects who takes responsibility for cleaning it up when it's no longer needed. The short answer is: the last object that used it. This is handled by using a reference counting mechanism. Whenever somebody copies a header of a *Mat* object, a counter is increased for the matrix. Whenever a header is cleaned this counter is decreased. When the counter reaches zero the matrix too is freed. Sometimes you will want to copy the matrix itself too, so OpenCV provides the :basicstructures:`clone() <mat-clone>` and :basicstructures:`copyTo() <mat-copyto>` functions.
|
||||
|
||||
.. code-block:: cpp
|
||||
:linenos:
|
||||
@@ -59,34 +61,34 @@ Now modifying *F* or *G* will not affect the matrix pointed by the *Mat* header.
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Output image allocation for OpenCV functions is automatic (unless specified otherwise).
|
||||
* No need to think about memory freeing with OpenCVs C++ interface.
|
||||
* The assignment operator and the copy constructor (*ctor*)copies only the header.
|
||||
* Use the :basicstructures:`clone()<mat-clone>` or the :basicstructures:`copyTo() <mat-copyto>` function to copy the underlying matrix of an image.
|
||||
* You do not need to think about memory management with OpenCVs C++ interface.
|
||||
* The assignment operator and the copy constructor only copies the header.
|
||||
* The underlying matrix of an image may be copied using the :basicstructures:`clone()<mat-clone>` and :basicstructures:`copyTo() <mat-copyto>` functions.
|
||||
|
||||
*Storing* methods
|
||||
=================
|
||||
|
||||
This is about how you store the pixel values. You can select the color space and the data type used. The color space refers to how we combine color components in order to code a given color. The simplest one is the gray scale. Here the colors at our disposal are black and white. The combination of these allows us to create many shades of gray.
|
||||
This is about how you store the pixel values. You can select the color space and the data type used. The color space refers to how we combine color components in order to code a given color. The simplest one is the gray scale where the colors at our disposal are black and white. The combination of these allows us to create many shades of gray.
|
||||
|
||||
For *colorful* ways we have a lot more of methods to choose from. However, every one of them breaks it down to three or four basic components and the combination of this will give all others. The most popular one of this is RGB, mainly because this is also how our eye builds up colors in our eyes. Its base colors are red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is added.
|
||||
For *colorful* ways we have a lot more methods to choose from. Each of them breaks it down to three or four basic components and we can use the combination of these to create the others. The most popular one is RGB, mainly because this is also how our eye builds up colors. Its base colors are red, green and blue. To code the transparency of a color sometimes a fourth element: alpha (A) is added.
|
||||
|
||||
However, they are many color systems each with their own advantages:
|
||||
There are, however, many other color systems each with their own advantages:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* RGB is the most common as our eyes use something similar, our display systems also compose colors using these.
|
||||
* The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors. Using you may for example dismiss the last component, making your algorithm less sensible to light conditions of the input image.
|
||||
* The HSV and HLS decompose colors into their hue, saturation and value/luminance components, which is a more natural way for us to describe colors. You might, for example, dismiss the last component, making your algorithm less sensible to the light conditions of the input image.
|
||||
* YCrCb is used by the popular JPEG image format.
|
||||
* CIE L*a*b* is a perceptually uniform color space, which comes handy if you need to measure the *distance* of a given color to another color.
|
||||
|
||||
Now each of the building components has their own valid domains. This leads to the data type used. How we store a component defines just how fine control we have over its domain. The smallest data type possible is *char*, which means one byte or 8 bits. This may be unsigned (so can store values from 0 to 255) or signed (values from -127 to +127). Although in case of three components this already gives 16 million possible colors to represent (like in case of RGB) we may acquire an even finer control by using the float (4 byte = 32 bit) or double (8 byte = 64 bit) data types for each component. Nevertheless, remember that increasing the size of a component also increases the size of the whole picture in the memory.
|
||||
Each of the building components has their own valid domains. This leads to the data type used. How we store a component defines the control we have over its domain. The smallest data type possible is *char*, which means one byte or 8 bits. This may be unsigned (so can store values from 0 to 255) or signed (values from -127 to +127). Although in case of three components this already gives 16 million possible colors to represent (like in case of RGB) we may acquire an even finer control by using the float (4 byte = 32 bit) or double (8 byte = 64 bit) data types for each component. Nevertheless, remember that increasing the size of a component also increases the size of the whole picture in the memory.
|
||||
|
||||
Creating explicitly a *Mat* object
|
||||
Creating a *Mat* object explicitly
|
||||
==================================
|
||||
|
||||
In the :ref:`Load_Save_Image` tutorial you could already see how to write a matrix to an image file by using the :readWriteImageVideo:` imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can achieve this via the << operator of *Mat*. However, be aware that this only works for two dimensional matrices.
|
||||
In the :ref:`Load_Save_Image` tutorial you have already learned how to write a matrix to an image file by using the :readWriteImageVideo:` imwrite() <imwrite>` function. However, for debugging purposes it's much more convenient to see the actual values. You can do this using the << operator of *Mat*. Be aware that this only works for two dimensional matrices.
|
||||
|
||||
Although *Mat* is a great class as image container it is also a general matrix class. Therefore, it is possible to create and manipulate multidimensional matrices. You can create a Mat object in multiple ways:
|
||||
Although *Mat* works really well as an image container, it is also a general matrix class. Therefore, it is possible to create and manipulate multidimensional matrices. You can create a Mat object in multiple ways:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@@ -103,13 +105,13 @@ Although *Mat* is a great class as image container it is also a general matrix c
|
||||
|
||||
For two dimensional and multichannel images we first define their size: row and column count wise.
|
||||
|
||||
Then we need to specify the data type to use for storing the elements and the number of channels per matrix point. To do this we have multiple definitions made according to the following convention:
|
||||
Then we need to specify the data type to use for storing the elements and the number of channels per matrix point. To do this we have multiple definitions constructed according to the following convention:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
CV_[The number of bits per item][Signed or Unsigned][Type Prefix]C[The channel number]
|
||||
|
||||
For instance, *CV_8UC3* means we use unsigned char types that are 8 bit long and each pixel has three items of this to form the three channels. This are predefined for up to four channel numbers. The :basicstructures:`Scalar <scalar>` is four element short vector. Specify this and you can initialize all matrix points with a custom value. However if you need more you can create the type with the upper macro and putting the channel number in parenthesis as you can see below.
|
||||
For instance, *CV_8UC3* means we use unsigned char types that are 8 bit long and each pixel has three of these to form the three channels. This are predefined for up to four channel numbers. The :basicstructures:`Scalar <scalar>` is four element short vector. Specify this and you can initialize all matrix points with a custom value. If you need more you can create the type with the upper macro, setting the channel number in parenthesis as you can see below.
|
||||
|
||||
+ Use C\\C++ arrays and initialize via constructor
|
||||
|
||||
@@ -118,7 +120,7 @@ Although *Mat* is a great class as image container it is also a general matrix c
|
||||
:tab-width: 4
|
||||
:lines: 35-36
|
||||
|
||||
The upper example shows how to create a matrix with more than two dimensions. Specify its dimension, then pass a pointer containing the size for each dimension and the rest remains the same.
|
||||
The upper example shows how to create a matrix with more than two dimensions. Specify its dimension, then pass a pointer containing the size for each dimension and the rest remains the same.
|
||||
|
||||
|
||||
+ Create a header for an already existing IplImage pointer:
|
||||
@@ -176,7 +178,7 @@ Although *Mat* is a great class as image container it is also a general matrix c
|
||||
|
||||
.. note::
|
||||
|
||||
You can fill out a matrix with random values using the :operationsOnArrays:`randu() <randu>` function. You need to give the lower and upper value between what you want the random values:
|
||||
You can fill out a matrix with random values using the :operationsOnArrays:`randu() <randu>` function. You need to give the lower and upper value for the random values:
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp
|
||||
:language: cpp
|
||||
@@ -184,10 +186,10 @@ Although *Mat* is a great class as image container it is also a general matrix c
|
||||
:lines: 57-58
|
||||
|
||||
|
||||
Print out formatting
|
||||
====================
|
||||
Output formatting
|
||||
=================
|
||||
|
||||
In the above examples you could see the default formatting option. Nevertheless, OpenCV allows you to format your matrix output format to fit the rules of:
|
||||
In the above examples you could see the default formatting option. OpenCV, however, allows you to format your matrix output:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@@ -246,10 +248,10 @@ In the above examples you could see the default formatting option. Nevertheless,
|
||||
:alt: Default Output
|
||||
:align: center
|
||||
|
||||
Print for other common items
|
||||
Output of other common items
|
||||
============================
|
||||
|
||||
OpenCV offers support for print of other common OpenCV data structures too via the << operator like:
|
||||
OpenCV offers support for output of other common OpenCV data structures too via the << operator:
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
@@ -298,9 +300,9 @@ OpenCV offers support for print of other common OpenCV data structures too via t
|
||||
:alt: Default Output
|
||||
:align: center
|
||||
|
||||
Most of the samples here have been included into a small console application. You can download it from :download:`here <../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp>` or in the core section of the cpp samples.
|
||||
Most of the samples here have been included in a small console application. You can download it from :download:`here <../../../../samples/cpp/tutorial_code/core/mat_the_basic_image_container/mat_the_basic_image_container.cpp>` or in the core section of the cpp samples.
|
||||
|
||||
A quick video demonstration of this you can find on `YouTube <https://www.youtube.com/watch?v=1tibU7vGWpk>`_.
|
||||
You can also find a quick video demonstration of this on `YouTube <https://www.youtube.com/watch?v=1tibU7vGWpk>`_.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@ This tutorial code's is shown lines below. You can also download it from `here <
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/nonfree/features2d.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
|
||||
+2
-121
@@ -22,127 +22,8 @@ Code
|
||||
|
||||
This tutorial code's is shown lines below. You can also download it from `here <http://code.opencv.org/projects/opencv/repository/revisions/master/raw/samples/cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp>`_
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include <iostream>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
/// Global variables
|
||||
Mat src, src_gray;
|
||||
Mat myHarris_dst; Mat myHarris_copy; Mat Mc;
|
||||
Mat myShiTomasi_dst; Mat myShiTomasi_copy;
|
||||
|
||||
int myShiTomasi_qualityLevel = 50;
|
||||
int myHarris_qualityLevel = 50;
|
||||
int max_qualityLevel = 100;
|
||||
|
||||
double myHarris_minVal; double myHarris_maxVal;
|
||||
double myShiTomasi_minVal; double myShiTomasi_maxVal;
|
||||
|
||||
RNG rng(12345);
|
||||
|
||||
char* myHarris_window = "My Harris corner detector";
|
||||
char* myShiTomasi_window = "My Shi Tomasi corner detector";
|
||||
|
||||
/// Function headers
|
||||
void myShiTomasi_function( int, void* );
|
||||
void myHarris_function( int, void* );
|
||||
|
||||
/** @function main */
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
/// Load source image and convert it to gray
|
||||
src = imread( argv[1], 1 );
|
||||
cvtColor( src, src_gray, CV_BGR2GRAY );
|
||||
|
||||
/// Set some parameters
|
||||
int blockSize = 3; int apertureSize = 3;
|
||||
|
||||
/// My Harris matrix -- Using cornerEigenValsAndVecs
|
||||
myHarris_dst = Mat::zeros( src_gray.size(), CV_32FC(6) );
|
||||
Mc = Mat::zeros( src_gray.size(), CV_32FC1 );
|
||||
|
||||
cornerEigenValsAndVecs( src_gray, myHarris_dst, blockSize, apertureSize, BORDER_DEFAULT );
|
||||
|
||||
/* calculate Mc */
|
||||
for( int j = 0; j < src_gray.rows; j++ )
|
||||
{ for( int i = 0; i < src_gray.cols; i++ )
|
||||
{
|
||||
float lambda_1 = myHarris_dst.at<float>( j, i, 0 );
|
||||
float lambda_2 = myHarris_dst.at<float>( j, i, 1 );
|
||||
Mc.at<float>(j,i) = lambda_1*lambda_2 - 0.04*pow( ( lambda_1 + lambda_2 ), 2 );
|
||||
}
|
||||
}
|
||||
|
||||
minMaxLoc( Mc, &myHarris_minVal, &myHarris_maxVal, 0, 0, Mat() );
|
||||
|
||||
/* Create Window and Trackbar */
|
||||
namedWindow( myHarris_window, CV_WINDOW_AUTOSIZE );
|
||||
createTrackbar( " Quality Level:", myHarris_window, &myHarris_qualityLevel, max_qualityLevel,
|
||||
myHarris_function );
|
||||
myHarris_function( 0, 0 );
|
||||
|
||||
/// My Shi-Tomasi -- Using cornerMinEigenVal
|
||||
myShiTomasi_dst = Mat::zeros( src_gray.size(), CV_32FC1 );
|
||||
cornerMinEigenVal( src_gray, myShiTomasi_dst, blockSize, apertureSize, BORDER_DEFAULT );
|
||||
|
||||
minMaxLoc( myShiTomasi_dst, &myShiTomasi_minVal, &myShiTomasi_maxVal, 0, 0, Mat() );
|
||||
|
||||
/* Create Window and Trackbar */
|
||||
namedWindow( myShiTomasi_window, CV_WINDOW_AUTOSIZE );
|
||||
createTrackbar( " Quality Level:", myShiTomasi_window, &myShiTomasi_qualityLevel, max_qualityLevel,
|
||||
myShiTomasi_function );
|
||||
myShiTomasi_function( 0, 0 );
|
||||
|
||||
waitKey(0);
|
||||
return(0);
|
||||
}
|
||||
|
||||
/** @function myShiTomasi_function */
|
||||
void myShiTomasi_function( int, void* )
|
||||
{
|
||||
myShiTomasi_copy = src.clone();
|
||||
|
||||
if( myShiTomasi_qualityLevel < 1 ) { myShiTomasi_qualityLevel = 1; }
|
||||
|
||||
for( int j = 0; j < src_gray.rows; j++ )
|
||||
{ for( int i = 0; i < src_gray.cols; i++ )
|
||||
{
|
||||
if( myShiTomasi_dst.at<float>(j,i) > myShiTomasi_minVal + ( myShiTomasi_maxVal -
|
||||
myShiTomasi_minVal )*myShiTomasi_qualityLevel/max_qualityLevel )
|
||||
{ circle( myShiTomasi_copy, Point(i,j), 4, Scalar( rng.uniform(0,255),
|
||||
rng.uniform(0,255), rng.uniform(0,255) ), -1, 8, 0 ); }
|
||||
}
|
||||
}
|
||||
imshow( myShiTomasi_window, myShiTomasi_copy );
|
||||
}
|
||||
|
||||
/** @function myHarris_function */
|
||||
void myHarris_function( int, void* )
|
||||
{
|
||||
myHarris_copy = src.clone();
|
||||
|
||||
if( myHarris_qualityLevel < 1 ) { myHarris_qualityLevel = 1; }
|
||||
|
||||
for( int j = 0; j < src_gray.rows; j++ )
|
||||
{ for( int i = 0; i < src_gray.cols; i++ )
|
||||
{
|
||||
if( Mc.at<float>(j,i) > myHarris_minVal + ( myHarris_maxVal - myHarris_minVal )
|
||||
*myHarris_qualityLevel/max_qualityLevel )
|
||||
{ circle( myHarris_copy, Point(i,j), 4, Scalar( rng.uniform(0,255), rng.uniform(0,255),
|
||||
rng.uniform(0,255) ), -1, 8, 0 ); }
|
||||
}
|
||||
}
|
||||
imshow( myHarris_window, myHarris_copy );
|
||||
}
|
||||
|
||||
|
||||
.. literalinclude:: ../../../../../samples/cpp/tutorial_code/TrackingMotion/cornerDetector_Demo.cpp
|
||||
:language: cpp
|
||||
|
||||
Explanation
|
||||
============
|
||||
|
||||
@@ -16,7 +16,7 @@ Today it is common to have a digital video recording system at your disposal. Th
|
||||
The source code
|
||||
===============
|
||||
|
||||
As a test case where to show off these using OpenCV I've created a small program that reads in two video files and performs a similarity check between them. This is something you could use to check just how well a new video compressing algorithms works. Let there be a reference (original) video like :download:`this small Megamind clip <../../../../samples/cpp/tutorial_code/highgui/video-input-psnr-ssim/video/Megamind.avi>` and :download:`a compressed version of it <../../../../samples/cpp/tutorial_code/highgui/video-input-psnr-ssim/video/Megamind_bugy.avi>`. You may also find the source code and these video file in the :file:`samples/cpp/tutorial_code/highgui/video-input-psnr-ssim/` folder of the OpenCV source library.
|
||||
As a test case where to show off these using OpenCV I've created a small program that reads in two video files and performs a similarity check between them. This is something you could use to check just how well a new video compressing algorithms works. Let there be a reference (original) video like :download:`this small Megamind clip <../../../../samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video/Megamind.avi>` and :download:`a compressed version of it <../../../../samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video/Megamind_bugy.avi>`. You may also find the source code and these video file in the :file:`samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/` folder of the OpenCV source library.
|
||||
|
||||
.. literalinclude:: ../../../../samples/cpp/tutorial_code/HighGUI/video-input-psnr-ssim/video-input-psnr-ssim.cpp
|
||||
:language: cpp
|
||||
|
||||
@@ -36,7 +36,6 @@ You may also find the source code and these video file in the :file:`samples/cpp
|
||||
:language: cpp
|
||||
:linenos:
|
||||
:tab-width: 4
|
||||
:lines: 1-8, 21-22, 24-97
|
||||
|
||||
The structure of a video
|
||||
========================
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
.. _dev_with_OCV_on_Android:
|
||||
|
||||
|
||||
Android development with OpenCV
|
||||
Android Development with OpenCV
|
||||
*******************************
|
||||
|
||||
This tutorial is created to help you use OpenCV library within your Android project.
|
||||
This tutorial has been created to help you use OpenCV library within your Android project.
|
||||
|
||||
This guide was written with Windows 7 in mind, though it should work with any other OS supported by OpenCV4Android SDK.
|
||||
This guide was written with Windows 7 in mind, though it should work with any other OS supported by
|
||||
OpenCV4Android SDK.
|
||||
|
||||
This tutorial assumes you have the following installed and configured:
|
||||
|
||||
@@ -23,109 +23,132 @@ This tutorial assumes you have the following installed and configured:
|
||||
|
||||
If you need help with anything of the above, you may refer to our :ref:`android_dev_intro` guide.
|
||||
|
||||
This tutorial also assumes you have OpenCV4Android SDK already installed on your development machine and OpenCV Manager on your testing device correspondingly. If you need help with any of these, you may consult our :ref:`O4A_SDK` tutorial.
|
||||
This tutorial also assumes you have OpenCV4Android SDK already installed on your development
|
||||
machine and OpenCV Manager on your testing device correspondingly. If you need help with any of
|
||||
these, you may consult our :ref:`O4A_SDK` tutorial.
|
||||
|
||||
If you encounter any error after thoroughly following these steps, feel free to contact us via `OpenCV4Android <https://groups.google.com/group/android-opencv/>`_ discussion group or OpenCV `Q&A forum <http://answers.opencv.org>`_ . We'll do our best to help you out.
|
||||
If you encounter any error after thoroughly following these steps, feel free to contact us via
|
||||
`OpenCV4Android <https://groups.google.com/group/android-opencv/>`_ discussion group or OpenCV
|
||||
`Q&A forum <http://answers.opencv.org>`_ . We'll do our best to help you out.
|
||||
|
||||
Using OpenCV library within your Android project
|
||||
|
||||
Using OpenCV Library Within Your Android Project
|
||||
================================================
|
||||
|
||||
In this section we will explain how to make some existing project to use OpenCV.
|
||||
Starting with 2.4.2 release for Android, *OpenCV Manager* is used to provide apps with the best available version of OpenCV.
|
||||
You can get more information here: :ref:`Android_OpenCV_Manager` and in these `slides <https://docs.google.com/a/itseez.com/presentation/d/1EO_1kijgBg_BsjNp2ymk-aarg-0K279_1VZRcPplSuk/present#slide=id.p>`_.
|
||||
In this section we will explain how to make some existing project to use OpenCV.
|
||||
Starting with 2.4.2 release for Android, *OpenCV Manager* is used to provide apps with the best
|
||||
available version of OpenCV.
|
||||
You can get more information here: :ref:`Android_OpenCV_Manager` and in these
|
||||
`slides <https://docs.google.com/a/itseez.com/presentation/d/1EO_1kijgBg_BsjNp2ymk-aarg-0K279_1VZRcPplSuk/present#slide=id.p>`_.
|
||||
|
||||
|
||||
Java
|
||||
----
|
||||
Application development with async initialization
|
||||
|
||||
Application Development with Async Initialization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
Using async initialization is a **recommended** way for application development. It uses the OpenCV Manager to access OpenCV libraries externally installed in the target system.
|
||||
Using async initialization is a **recommended** way for application development. It uses the OpenCV
|
||||
Manager to access OpenCV libraries externally installed in the target system.
|
||||
|
||||
#. Add OpenCV library project to your workspace. Use menu :guilabel:`File -> Import -> Existing project in your workspace`,
|
||||
press :guilabel:`Browse` button and locate OpenCV4Android SDK (:file:`OpenCV-2.4.3-android-sdk/sdk`).
|
||||
#. Add OpenCV library project to your workspace. Use menu
|
||||
:guilabel:`File -> Import -> Existing project in your workspace`.
|
||||
|
||||
Press :guilabel:`Browse` button and locate OpenCV4Android SDK
|
||||
(:file:`OpenCV-2.4.3-android-sdk/sdk`).
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency0.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. In application project add a reference to the OpenCV Java SDK in :guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.3``.
|
||||
#. In application project add a reference to the OpenCV Java SDK in
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.3``.
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency1.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
In most cases OpenCV Manager may be installed automatically from Google Play. For such case, when Google Play is not available, i.e. emulator, developer board, etc, you can
|
||||
install it manually using adb tool. See :ref:`manager_selection` for details.
|
||||
In most cases OpenCV Manager may be installed automatically from Google Play. For the case, when
|
||||
Google Play is not available, i.e. emulator, developer board, etc, you can install it manually
|
||||
using adb tool. See :ref:`manager_selection` for details.
|
||||
|
||||
There is a very base code snippet implementing the async initialization. It shows basic principles. See the "15-puzzle" OpenCV sample for details.
|
||||
There is a very base code snippet implementing the async initialization. It shows basic principles.
|
||||
See the "15-puzzle" OpenCV sample for details.
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
public class MyActivity extends Activity implements HelperCallbackInterface
|
||||
{
|
||||
private BaseLoaderCallback mOpenCVCallBack = new BaseLoaderCallback(this) {
|
||||
@Override
|
||||
public void onManagerConnected(int status) {
|
||||
switch (status) {
|
||||
case LoaderCallbackInterface.SUCCESS:
|
||||
{
|
||||
Log.i(TAG, "OpenCV loaded successfully");
|
||||
// Create and set View
|
||||
mView = new puzzle15View(mAppContext);
|
||||
setContentView(mView);
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
super.onManagerConnected(status);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
};
|
||||
public class Sample1Java extends Activity implements CvCameraViewListener {
|
||||
|
||||
/** Call on every application resume **/
|
||||
@Override
|
||||
protected void onResume()
|
||||
{
|
||||
Log.i(TAG, "called onResume");
|
||||
super.onResume();
|
||||
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
|
||||
@Override
|
||||
public void onManagerConnected(int status) {
|
||||
switch (status) {
|
||||
case LoaderCallbackInterface.SUCCESS:
|
||||
{
|
||||
Log.i(TAG, "OpenCV loaded successfully");
|
||||
mOpenCvCameraView.enableView();
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
super.onManagerConnected(status);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Log.i(TAG, "Trying to load OpenCV library");
|
||||
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_2, this, mOpenCVCallBack))
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
Log.e(TAG, "Cannot connect to OpenCV Manager");
|
||||
super.onResume();
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||
}
|
||||
|
||||
...
|
||||
}
|
||||
|
||||
It this case application works with OpenCV Manager in asynchronous fashion. ``OnManagerConnected`` callback will be called in UI thread, when initialization finishes.
|
||||
Please note, that it is not allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback.
|
||||
Load your own native libraries that depend on OpenCV after the successful OpenCV initialization.
|
||||
Default BaseLoaderCallback implementation treat application context as Activity and calls Activity.finish() method to exit in case of initialization failure.
|
||||
To override this behavior you need to override finish() method of BaseLoaderCallback class and implement your own finalization method.
|
||||
It this case application works with OpenCV Manager in asynchronous fashion. ``OnManagerConnected``
|
||||
callback will be called in UI thread, when initialization finishes. Please note, that it is not
|
||||
allowed to use OpenCV calls or load OpenCV-dependent native libs before invoking this callback.
|
||||
Load your own native libraries that depend on OpenCV after the successful OpenCV initialization.
|
||||
Default ``BaseLoaderCallback`` implementation treat application context as Activity and calls
|
||||
``Activity.finish()`` method to exit in case of initialization failure. To override this behavior
|
||||
you need to override ``finish()`` method of ``BaseLoaderCallback`` class and implement your own
|
||||
finalization method.
|
||||
|
||||
Application development with static initialization
|
||||
|
||||
Application Development with Static Initialization
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
According to this approach all OpenCV binaries are included into your application package. It is designed mostly for development purposes.
|
||||
This approach is deprecated for the production code, release package is recommended to communicate with OpenCV Manager via the async initialization described above.
|
||||
According to this approach all OpenCV binaries are included into your application package. It is
|
||||
designed mostly for development purposes. This approach is deprecated for the production code,
|
||||
release package is recommended to communicate with OpenCV Manager via the async initialization
|
||||
described above.
|
||||
|
||||
#. Add the OpenCV library project to your workspace the same way as for the async initialization above.
|
||||
Use menu :guilabel:`File -> Import -> Existing project in your workspace`, push :guilabel:`Browse` button and select OpenCV SDK path (:file:`OpenCV-2.4.3-android-sdk/sdk`).
|
||||
#. Add the OpenCV library project to your workspace the same way as for the async initialization
|
||||
above. Use menu :guilabel:`File -> Import -> Existing project in your workspace`,
|
||||
press :guilabel:`Browse` button and select OpenCV SDK path
|
||||
(:file:`OpenCV-2.4.3-android-sdk/sdk`).
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency0.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. In the application project add a reference to the OpenCV4Android SDK in :guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.3``;
|
||||
#. In the application project add a reference to the OpenCV4Android SDK in
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.3``;
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency1.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV native libs from :file:`<OpenCV-2.4.3-android-sdk>/sdk/native/libs/<target_arch>` to your project directory to folder :file:`libs/<target_arch>`.
|
||||
#. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV
|
||||
native libs from :file:`<OpenCV-2.4.3-android-sdk>/sdk/native/libs/<target_arch>` to your
|
||||
project directory to folder :file:`libs/<target_arch>`.
|
||||
|
||||
In case of the application project **with a JNI part**, instead of manual libraries copying you need to modify your ``Android.mk`` file:
|
||||
add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before ``"include path_to_OpenCV-2.4.3-android-sdk/sdk/native/jni/OpenCV.mk"``
|
||||
In case of the application project **with a JNI part**, instead of manual libraries copying you
|
||||
need to modify your ``Android.mk`` file:
|
||||
add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before
|
||||
``"include path_to_OpenCV-2.4.3-android-sdk/sdk/native/jni/OpenCV.mk"``
|
||||
|
||||
.. code-block:: make
|
||||
:linenos:
|
||||
@@ -145,12 +168,14 @@ This approach is deprecated for the production code, release package is recommen
|
||||
OPENCV_INSTALL_MODULES:=on
|
||||
include ../../sdk/native/jni/OpenCV.mk
|
||||
|
||||
After that the OpenCV libraries will be copied to your application :file:`libs` folder during the JNI part build.
|
||||
After that the OpenCV libraries will be copied to your application :file:`libs` folder during
|
||||
the JNI build.v
|
||||
|
||||
Eclipse will automatically include all the libraries from the :file:`libs` folder to the application package (APK).
|
||||
Eclipse will automatically include all the libraries from the :file:`libs` folder to the
|
||||
application package (APK).
|
||||
|
||||
#. The last step of enabling OpenCV in your application is Java initialization code before call to OpenCV API.
|
||||
It can be done, for example, in the static section of the ``Activity`` class:
|
||||
#. The last step of enabling OpenCV in your application is Java initialization code before calling
|
||||
OpenCV API. It can be done, for example, in the static section of the ``Activity`` class:
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
@@ -161,7 +186,8 @@ This approach is deprecated for the production code, release package is recommen
|
||||
}
|
||||
}
|
||||
|
||||
If you application includes other OpenCV-dependent native libraries you should load them **after** OpenCV initialization:
|
||||
If you application includes other OpenCV-dependent native libraries you should load them
|
||||
**after** OpenCV initialization:
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
@@ -175,39 +201,45 @@ This approach is deprecated for the production code, release package is recommen
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Native/C++
|
||||
----------
|
||||
|
||||
To build your own Android application, which uses OpenCV from native part, the following steps should be done:
|
||||
To build your own Android application, using OpenCV as native part, the following steps should be
|
||||
taken:
|
||||
|
||||
#. You can use an environment variable to specify the location of OpenCV package or just hardcode absolute or relative path in the :file:`jni/Android.mk` of your projects.
|
||||
#. You can use an environment variable to specify the location of OpenCV package or just hardcode
|
||||
absolute or relative path in the :file:`jni/Android.mk` of your projects.
|
||||
|
||||
#. The file :file:`jni/Android.mk` should be written for the current application using the common rules for this file.
|
||||
#. The file :file:`jni/Android.mk` should be written for the current application using the common
|
||||
rules for this file.
|
||||
|
||||
For detailed information see the Android NDK documentation from the Android NDK archive, in the file
|
||||
:file:`<path_where_NDK_is_placed>/docs/ANDROID-MK.html`
|
||||
For detailed information see the Android NDK documentation from the Android NDK archive, in the
|
||||
file :file:`<path_where_NDK_is_placed>/docs/ANDROID-MK.html`.
|
||||
|
||||
#. The line
|
||||
#. The following line:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
include C:\Work\OpenCV4Android\OpenCV-2.4.3-android-sdk\sdk\native\jni\OpenCV.mk
|
||||
|
||||
should be inserted into the :file:`jni/Android.mk` file **after** the line
|
||||
Should be inserted into the :file:`jni/Android.mk` file **after** this line:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
#. Several variables can be used to customize OpenCV stuff, but you **don't need** to use them when your application uses the `async initialization` via the `OpenCV Manager` API.
|
||||
#. Several variables can be used to customize OpenCV stuff, but you **don't need** to use them when
|
||||
your application uses the `async initialization` via the `OpenCV Manager` API.
|
||||
|
||||
Note: these variables should be set **before** the ``"include .../OpenCV.mk"`` line:
|
||||
.. note:: These variables should be set **before** the ``"include .../OpenCV.mk"`` line:
|
||||
|
||||
.. code-block:: make
|
||||
.. code-block:: make
|
||||
|
||||
OPENCV_INSTALL_MODULES:=on
|
||||
OPENCV_INSTALL_MODULES:=on
|
||||
|
||||
Copies necessary OpenCV dynamic libs to the project ``libs`` folder in order to include them into the APK.
|
||||
Copies necessary OpenCV dynamic libs to the project ``libs`` folder in order to include them
|
||||
into the APK.
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
@@ -219,7 +251,8 @@ To build your own Android application, which uses OpenCV from native part, the f
|
||||
|
||||
OPENCV_LIB_TYPE:=STATIC
|
||||
|
||||
Perform static link with OpenCV. By default dynamic link is used and the project JNI lib depends on ``libopencv_java.so``.
|
||||
Perform static linking with OpenCV. By default dynamic link is used and the project JNI lib
|
||||
depends on ``libopencv_java.so``.
|
||||
|
||||
#. The file :file:`Application.mk` should exist and should contain lines:
|
||||
|
||||
@@ -228,145 +261,46 @@ To build your own Android application, which uses OpenCV from native part, the f
|
||||
APP_STL := gnustl_static
|
||||
APP_CPPFLAGS := -frtti -fexceptions
|
||||
|
||||
Also the line like this one:
|
||||
Also, the line like this one:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
APP_ABI := armeabi-v7a
|
||||
|
||||
should specify the application target platforms.
|
||||
Should specify the application target platforms.
|
||||
|
||||
In some cases a linkage error (like ``"In function 'cv::toUtf16(std::basic_string<...>... undefined reference to 'mbstowcs'"``) happens
|
||||
when building an application JNI library depending on OpenCV.
|
||||
The following line in the :file:`Application.mk` usually fixes it:
|
||||
In some cases a linkage error (like ``"In function 'cv::toUtf16(std::basic_string<...>...
|
||||
undefined reference to 'mbstowcs'"``) happens when building an application JNI library,
|
||||
depending on OpenCV. The following line in the :file:`Application.mk` usually fixes it:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
APP_PLATFORM := android-9
|
||||
|
||||
|
||||
#. Either use :ref:`manual <NDK_build_cli>` ``ndk-build`` invocation or :ref:`setup Eclipse CDT Builder <CDT_Builder>` to build native JNI lib before Java part [re]build and APK creation.
|
||||
#. Either use :ref:`manual <NDK_build_cli>` ``ndk-build`` invocation or
|
||||
:ref:`setup Eclipse CDT Builder <CDT_Builder>` to build native JNI lib before (re)building the Java
|
||||
part and creating an APK.
|
||||
|
||||
|
||||
Hello OpenCV Sample
|
||||
===================
|
||||
|
||||
Here are basic steps to guide you trough the process of creating a simple OpenCV-centric application.
|
||||
It will be capable of accessing camera output, processing it and displaying the result.
|
||||
Here are basic steps to guide you trough the process of creating a simple OpenCV-centric
|
||||
application. It will be capable of accessing camera output, processing it and displaying the
|
||||
result.
|
||||
|
||||
#. Open Eclipse IDE, create a new clean workspace, create a new Android project (*File -> New -> Android Project*).
|
||||
#. Open Eclipse IDE, create a new clean workspace, create a new Android project
|
||||
:menuselection:`File --> New --> Android Project`
|
||||
|
||||
#. Set name, target, package and minSDKVersion accordingly.
|
||||
#. Set name, target, package and ``minSDKVersion`` accordingly. The minimal SDK version for build
|
||||
with OpenCV4Android SDK is 11. Minimal device API Level (for application manifest) is 8.
|
||||
|
||||
#. Create a new class (*File -> New -> Class*). Name it for example: *HelloOpenCVView*.
|
||||
#. Allow Eclipse to create default activity. Lets name the activity ``HelloOpenCvActivity``.
|
||||
|
||||
.. image:: images/dev_OCV_new_class.png
|
||||
:alt: Add a new class.
|
||||
:align: center
|
||||
#. Choose Blank Activity with full screen layout. Lets name the layout ``HelloOpenCvLayout``.
|
||||
|
||||
* It should extend *SurfaceView* class.
|
||||
* It also should implement *SurfaceHolder.Callback*, *Runnable*.
|
||||
|
||||
#. Edit *HelloOpenCVView* class.
|
||||
|
||||
* Add an *import* line for *android.content.context*.
|
||||
|
||||
* Modify autogenerated stubs: *HelloOpenCVView*, *surfaceCreated*, *surfaceDestroyed* and *surfaceChanged*.
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
package com.hello.opencv.test;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
public class HelloOpenCVView extends SurfaceView implements Callback, Runnable {
|
||||
|
||||
public HelloOpenCVView(Context context) {
|
||||
super(context);
|
||||
getHolder().addCallback(this);
|
||||
}
|
||||
|
||||
public void surfaceCreated(SurfaceHolder holder) {
|
||||
(new Thread(this)).start();
|
||||
}
|
||||
|
||||
public void surfaceDestroyed(SurfaceHolder holder) {
|
||||
cameraRelease();
|
||||
}
|
||||
|
||||
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
|
||||
cameraSetup(width, height);
|
||||
}
|
||||
|
||||
//...
|
||||
|
||||
* Add *cameraOpen*, *cameraRelease* and *cameraSetup* voids as shown below.
|
||||
|
||||
* Also, don't forget to add the public void *run()* as follows:
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
public void run() {
|
||||
// TODO: loop { getFrame(), processFrame(), drawFrame() }
|
||||
}
|
||||
|
||||
public boolean cameraOpen() {
|
||||
return false; //TODO: open camera
|
||||
}
|
||||
|
||||
private void cameraRelease() {
|
||||
// TODO release camera
|
||||
}
|
||||
|
||||
private void cameraSetup(int width, int height) {
|
||||
// TODO setup camera
|
||||
}
|
||||
|
||||
#. Create a new *Activity* (*New -> Other -> Android -> Android Activity*) and name it, for example: *HelloOpenCVActivity*. For this activity define *onCreate*, *onResume* and *onPause* voids.
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
public void onCreate (Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
mView = new HelloOpenCVView(this);
|
||||
setContentView (mView);
|
||||
}
|
||||
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
mView.cameraRelease();
|
||||
}
|
||||
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
if( !mView.cameraOpen() ) {
|
||||
// MessageBox and exit app
|
||||
AlertDialog ad = new AlertDialog.Builder(this).create();
|
||||
ad.setCancelable(false); // This blocks the "BACK" button
|
||||
ad.setMessage("Fatal error: can't open camera!");
|
||||
ad.setButton("OK", new DialogInterface.OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dialog.dismiss();
|
||||
finish();
|
||||
}
|
||||
});
|
||||
ad.show();
|
||||
}
|
||||
}
|
||||
|
||||
#. Add the following permissions to the AndroidManifest.xml file:
|
||||
|
||||
.. code-block:: xml
|
||||
:linenos:
|
||||
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-feature android:name="android.hardware.camera" />
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" />
|
||||
#. Import OpenCV library project to your workspace.
|
||||
|
||||
#. Reference OpenCV library within your project properties.
|
||||
|
||||
@@ -374,98 +308,148 @@ It will be capable of accessing camera output, processing it and displaying the
|
||||
:alt: Reference OpenCV library.
|
||||
:align: center
|
||||
|
||||
#. We now need some code to handle the camera. Update the *HelloOpenCVView* class as follows:
|
||||
#. Edit your layout file as xml file and pass the following layout there:
|
||||
|
||||
.. code-block:: xml
|
||||
:linenos:
|
||||
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:opencv="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" >
|
||||
|
||||
<org.opencv.android.JavaCameraView
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:visibility="gone"
|
||||
android:id="@+id/HelloOpenCvView"
|
||||
opencv:show_fps="true"
|
||||
opencv:camera_id="any" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
#. Add the following permissions to the :file:`AndroidManifest.xml` file:
|
||||
|
||||
.. code-block:: xml
|
||||
:linenos:
|
||||
|
||||
</application>
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA"/>
|
||||
|
||||
<uses-feature android:name="android.hardware.camera" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.camera.autofocus" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.camera.front" android:required="false"/>
|
||||
<uses-feature android:name="android.hardware.camera.front.autofocus" android:required="false"/>
|
||||
|
||||
#. Set application theme in AndroidManifest.xml to hide title and system buttons.
|
||||
|
||||
.. code-block:: xml
|
||||
:linenos:
|
||||
|
||||
<application
|
||||
android:icon="@drawable/icon"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@android:style/Theme.NoTitleBar.Fullscreen" >
|
||||
|
||||
#. Add OpenCV library initialization to your activity. Fix errors by adding requited imports.
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
private BaseLoaderCallback mLoaderCallback = new BaseLoaderCallback(this) {
|
||||
@Override
|
||||
public void onManagerConnected(int status) {
|
||||
switch (status) {
|
||||
case LoaderCallbackInterface.SUCCESS:
|
||||
{
|
||||
Log.i(TAG, "OpenCV loaded successfully");
|
||||
mOpenCvCameraView.enableView();
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
super.onManagerConnected(status);
|
||||
} break;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||
}
|
||||
|
||||
#. Defines that your activity implements CvViewFrameListener interface and fix activity related
|
||||
errors by defining missed methods. For this activity define ``onCreate``, ``onDestroy`` and
|
||||
``onPause`` and implement them according code snippet bellow. Fix errors by adding requited
|
||||
imports.
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
|
||||
private VideoCapture mCamera;
|
||||
private CameraBridgeViewBase mOpenCvCameraView;
|
||||
|
||||
public boolean cameraOpen() {
|
||||
synchronized (this) {
|
||||
cameraRelease();
|
||||
mCamera = new VideoCapture(Highgui.CV_CAP_ANDROID);
|
||||
if (!mCamera.isOpened()) {
|
||||
mCamera.release();
|
||||
mCamera = null;
|
||||
Log.e("HelloOpenCVView", "Failed to open native camera");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
Log.i(TAG, "called onCreate");
|
||||
super.onCreate(savedInstanceState);
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
setContentView(R.layout.HelloOpenCvLayout);
|
||||
mOpenCvCameraView = (CameraBridgeViewBase) findViewById(R.id.HelloOpenCvView);
|
||||
mOpenCvCameraView.setVisibility(SurfaceView.VISIBLE);
|
||||
mOpenCvCameraView.setCvCameraViewListener(this);
|
||||
}
|
||||
|
||||
public void cameraRelease() {
|
||||
synchronized(this) {
|
||||
if (mCamera != null) {
|
||||
mCamera.release();
|
||||
mCamera = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onPause()
|
||||
{
|
||||
super.onPause();
|
||||
if (mOpenCvCameraView != null)
|
||||
mOpenCvCameraView.disableView();
|
||||
}
|
||||
|
||||
private void cameraSetup(int width, int height) {
|
||||
synchronized (this) {
|
||||
if (mCamera != null && mCamera.isOpened()) {
|
||||
List<Size> sizes = mCamera.getSupportedPreviewSizes();
|
||||
int mFrameWidth = width;
|
||||
int mFrameHeight = height;
|
||||
{ // selecting optimal camera preview size
|
||||
double minDiff = Double.MAX_VALUE;
|
||||
for (Size size : sizes) {
|
||||
if (Math.abs(size.height - height) < minDiff) {
|
||||
mFrameWidth = (int) size.width;
|
||||
mFrameHeight = (int) size.height;
|
||||
minDiff = Math.abs(size.height - height);
|
||||
}
|
||||
}
|
||||
}
|
||||
mCamera.set(Highgui.CV_CAP_PROP_FRAME_WIDTH, mFrameWidth);
|
||||
mCamera.set(Highgui.CV_CAP_PROP_FRAME_HEIGHT, mFrameHeight);
|
||||
}
|
||||
}
|
||||
}
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
if (mOpenCvCameraView != null)
|
||||
mOpenCvCameraView.disableView();
|
||||
}
|
||||
|
||||
#. The last step would be to update the *run()* void in *HelloOpenCVView* class as follows:
|
||||
public void onCameraViewStarted(int width, int height) {
|
||||
}
|
||||
|
||||
.. code-block:: java
|
||||
:linenos:
|
||||
public void onCameraViewStopped() {
|
||||
}
|
||||
|
||||
public void run() {
|
||||
while (true) {
|
||||
Bitmap bmp = null;
|
||||
synchronized (this) {
|
||||
if (mCamera == null)
|
||||
break;
|
||||
if (!mCamera.grab())
|
||||
break;
|
||||
public Mat onCameraFrame(Mat inputFrame) {
|
||||
return inputFrame;
|
||||
}
|
||||
|
||||
bmp = processFrame(mCamera);
|
||||
}
|
||||
if (bmp != null) {
|
||||
Canvas canvas = getHolder().lockCanvas();
|
||||
if (canvas != null) {
|
||||
canvas.drawBitmap(bmp, (canvas.getWidth() - bmp.getWidth()) / 2,
|
||||
(canvas.getHeight() - bmp.getHeight()) / 2, null);
|
||||
getHolder().unlockCanvasAndPost(canvas);
|
||||
#. Run your application on device or emulator.
|
||||
|
||||
}
|
||||
bmp.recycle();
|
||||
}
|
||||
}
|
||||
}
|
||||
Lets discuss some most important steps. Every Android application with UI must implement Activity
|
||||
and View. By the first steps we create blank activity and default view layout. The simplest
|
||||
OpenCV-centric application must implement OpenCV initialization, create its own view to show
|
||||
preview from camera and implements ``CvViewFrameListener`` interface to get frames from camera and
|
||||
process it.
|
||||
|
||||
protected Bitmap processFrame(VideoCapture capture) {
|
||||
Mat mRgba = new Mat();
|
||||
capture.retrieve(mRgba, Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA);
|
||||
//process mRgba
|
||||
Bitmap bmp = Bitmap.createBitmap(mRgba.cols(), mRgba.rows(), Bitmap.Config.ARGB_8888);
|
||||
try {
|
||||
Utils.matToBitmap(mRgba, bmp);
|
||||
} catch(Exception e) {
|
||||
Log.e("processFrame", "Utils.matToBitmap() throws an exception: " + e.getMessage());
|
||||
bmp.recycle();
|
||||
bmp = null;
|
||||
}
|
||||
return bmp;
|
||||
}
|
||||
First of all we create our application view using xml layout. Our layout consists of the only
|
||||
one full screen component of class ``org.opencv.android.JavaCameraView``. This class is
|
||||
implemented inside OpenCV library. It is inherited from ``CameraBridgeViewBase``, that extends
|
||||
``SurfaceView`` and uses standard Android camera API. Alternatively you can use
|
||||
``org.opencv.android.NativeCameraView`` class, that implements the same interface, but uses
|
||||
``VideoCapture`` class as camera access back-end. ``opencv:show_fps="true"`` and
|
||||
``opencv:camera_id="any"`` options enable FPS message and allow to use any camera on device.
|
||||
Application tries to use back camera first.
|
||||
|
||||
After creating layout we need to implement ``Activity`` class. OpenCV initialization process has
|
||||
been already discussed above. In this sample we use asynchronous initialization. Implementation of
|
||||
``CvCameraViewListener`` interface allows you to add processing steps after frame grabbing from
|
||||
camera and before its rendering on screen. The most important function is ``onCameraFrame``. It is
|
||||
callback function and it is called on retrieving frame from camera. The callback input is frame
|
||||
from camera. RGBA format is used by default. You can change this behavior by ``SetCaptureFormat``
|
||||
method of ``View`` class. ``Highgui.CV_CAP_ANDROID_COLOR_FRAME_RGBA`` and
|
||||
``Highgui.CV_CAP_ANDROID_GREY_FRAME`` are supported. It expects that function returns RGBA frame
|
||||
that will be drawn on the screen.
|
||||
|
||||
@@ -25,8 +25,8 @@ Let's use a simple program such as DisplayImage.cpp shown below.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <cv.h>
|
||||
#include <highgui.h>
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
using namespace cv;
|
||||
|
||||
@@ -55,9 +55,10 @@ Now you have to create your CMakeLists.txt file. It should look like this:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project( DisplayImage )
|
||||
find_package( OpenCV REQUIRED )
|
||||
add_executable( DisplayImage DisplayImage )
|
||||
add_executable( DisplayImage DisplayImage.cpp )
|
||||
target_link_libraries( DisplayImage ${OpenCV_LIBS} )
|
||||
|
||||
Generate the executable
|
||||
|
||||
@@ -15,7 +15,7 @@ In this tutorial you will learn how to:
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Load an image using :imread:`imread <>`
|
||||
* Transform an image from RGB to Grayscale format by using :cvt_color:`cvtColor <>`
|
||||
* Transform an image from BGR to Grayscale format by using :cvt_color:`cvtColor <>`
|
||||
* Save your transformed image in a file on disk (using :imwrite:`imwrite <>`)
|
||||
|
||||
Code
|
||||
@@ -45,7 +45,7 @@ Here it is:
|
||||
}
|
||||
|
||||
Mat gray_image;
|
||||
cvtColor( image, gray_image, CV_RGB2GRAY );
|
||||
cvtColor( image, gray_image, CV_BGR2GRAY );
|
||||
|
||||
imwrite( "../../images/Gray_Image.jpg", gray_image );
|
||||
|
||||
@@ -68,11 +68,11 @@ Explanation
|
||||
* Creating a Mat object to store the image information
|
||||
* Load an image using :imread:`imread <>`, located in the path given by *imageName*. Fort this example, assume you are loading a RGB image.
|
||||
|
||||
#. Now we are going to convert our image from RGB to Grayscale format. OpenCV has a really nice function to do this kind of transformations:
|
||||
#. Now we are going to convert our image from BGR to Grayscale format. OpenCV has a really nice function to do this kind of transformations:
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
cvtColor( image, gray_image, CV_RGB2GRAY );
|
||||
cvtColor( image, gray_image, CV_BGR2GRAY );
|
||||
|
||||
As you can see, :cvt_color:`cvtColor <>` takes as arguments:
|
||||
|
||||
@@ -80,7 +80,7 @@ Explanation
|
||||
|
||||
* a source image (*image*)
|
||||
* a destination image (*gray_image*), in which we will save the converted image.
|
||||
* an additional parameter that indicates what kind of transformation will be performed. In this case we use **CV_RGB2GRAY** (self-explanatory).
|
||||
* an additional parameter that indicates what kind of transformation will be performed. In this case we use **CV_BGR2GRAY** (because of :imread:`imread <>` has BGR default channel order in case of color images).
|
||||
|
||||
#. So now we have our new *gray_image* and want to save it on disk (otherwise it will get lost after the program ends). To save it, we will use a function analagous to :imread:`imread <>`: :imwrite:`imwrite <>`
|
||||
|
||||
|
||||
+1
-1
@@ -137,7 +137,7 @@ Here you can read tutorials about how to set up your computer to work with the O
|
||||
================ =================================================
|
||||
|AndroidLogo| **Title:** :ref:`dev_with_OCV_on_Android`
|
||||
|
||||
*Compatibility:* > OpenCV 2.4.2
|
||||
*Compatibility:* > OpenCV 2.4.3
|
||||
|
||||
*Author:* |Author_VsevolodG|
|
||||
|
||||
|
||||
@@ -20,11 +20,7 @@ Installation by Using the Pre-built Libraries
|
||||
|
||||
.. If you downloaded the source files present here see :ref:`CppTutWindowsMakeOwn`.
|
||||
|
||||
#. Make sure you have admin rights. Start the setup and follow the wizard.
|
||||
|
||||
#. While adding the OpenCV library to the system path is a good decision for a better control, we will do it manually for the sake of this tutorial. Make sure you do not set this option.
|
||||
|
||||
#. Most of the time it is a good idea to install the source files too, as this will allow for you to debug into the OpenCV library, if it is necessary. Follow the default settings of the wizard and finish the installation.
|
||||
#. Make sure you have admin rights. Unpack the self-extracting archive.
|
||||
|
||||
#. You can check the installation at the chosen path as you can see below.
|
||||
|
||||
@@ -294,15 +290,7 @@ Building the library
|
||||
:alt: The Install Project
|
||||
:align: center
|
||||
|
||||
This will create an *install* directory inside the *Build* one collecting all the built binaries into a single place. Use this only after you built both the *Release* and *Debug* versions.
|
||||
|
||||
.. note::
|
||||
|
||||
To create an installer you need to install `NSIS <http://nsis.sourceforge.net/Download>`_. Then just build the *Package* project to build the installer into the :file:`Build/_CPack_Packages/{win32}/NSIS` folder. You can then use this to distribute OpenCV with your build settings on other systems.
|
||||
|
||||
.. image:: images/WindowsOpenCVInstaller.png
|
||||
:alt: The Installer directory
|
||||
:align: center
|
||||
This will create an *Install* directory inside the *Build* one collecting all the built binaries into a single place. Use this only after you built both the *Release* and *Debug* versions.
|
||||
|
||||
To test your build just go into the :file:`Build/bin/Debug` or :file:`Build/bin/Release` directory and start a couple of applications like the *contours.exe*. If they run, you are done. Otherwise, something definitely went awfully wrong. In this case you should contact us via our :opencv_group:`user group <>`.
|
||||
If everything is okay the *contours.exe* output should resemble the following image (if built with Qt support):
|
||||
@@ -320,15 +308,15 @@ Building the library
|
||||
Set the OpenCV enviroment variable and add it to the systems path
|
||||
=================================================================
|
||||
|
||||
First we set an enviroment variable to make easier our work. This will hold the install directory of our OpenCV library that we use in our projects. Start up a command window and enter:
|
||||
First we set an enviroment variable to make easier our work. This will hold the build directory of our OpenCV library that we use in our projects. Start up a command window and enter:
|
||||
|
||||
::
|
||||
|
||||
setx -m OPENCV_DIR D:\OpenCV\Build\Install
|
||||
setx -m OPENCV_DIR D:\OpenCV\Build\x86\vc10
|
||||
|
||||
Here the directory is where you have your OpenCV binaries (*installed* or *built*). Inside this you should have folders like *bin* and *include*. The -m should be added if you wish to make the settings computer wise, instead of user wise.
|
||||
Here the directory is where you have your OpenCV binaries (*extracted* or *built*). You can have different platform (e.g. x64 instead of x86) or compiler type, so substitute appropriate value. Inside this you should have folders like *bin* and *include*. The -m should be added if you wish to make the settings computer wise, instead of user wise.
|
||||
|
||||
If you built static libraries then you are done. Otherwise, you need to add the *bin* folders path to the systems path.This is cause you will use the OpenCV library in form of *\"Dynamic-link libraries\"* (also known as **DLL**). Inside these are stored all the algorithms and information the OpenCV library contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems **PATH** contains a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (*exe*) for the OS to find it, which is highly unpleasent if you work on many projects. To do this start up again the |PathEditor|_ and add the following new entry (right click in the application to bring up the menu):
|
||||
If you built static libraries then you are done. Otherwise, you need to add the *bin* folders path to the systems path. This is cause you will use the OpenCV library in form of *\"Dynamic-link libraries\"* (also known as **DLL**). Inside these are stored all the algorithms and information the OpenCV library contains. The operating system will load them only on demand, during runtime. However, to do this he needs to know where they are. The systems **PATH** contains a list of folders where DLLs can be found. Add the OpenCV library path to this and the OS will know where to look if he ever needs the OpenCV binaries. Otherwise, you will need to copy the used DLLs right beside the applications executable file (*exe*) for the OS to find it, which is highly unpleasent if you work on many projects. To do this start up again the |PathEditor|_ and add the following new entry (right click in the application to bring up the menu):
|
||||
|
||||
::
|
||||
|
||||
@@ -342,6 +330,6 @@ If you built static libraries then you are done. Otherwise, you need to add the
|
||||
:alt: Add the entry.
|
||||
:align: center
|
||||
|
||||
Save it to the registry and you are done. If you ever change the location of your install directories or want to try out your applicaton with a different build all you will need to do is to update the OPENCV_DIR variable via the *setx* command inside a command window.
|
||||
Save it to the registry and you are done. If you ever change the location of your build directories or want to try out your applicaton with a different build all you will need to do is to update the OPENCV_DIR variable via the *setx* command inside a command window.
|
||||
|
||||
Now you can continue reading the tutorials with the :ref:`Windows_Visual_Studio_How_To` section. There you will find out how to use the OpenCV library in your own projects with the help of the Microsoft Visual Studio IDE.
|
||||
|
||||
@@ -144,7 +144,7 @@ A call to ``waitKey()`` starts a message passing cycle that waits for a key stro
|
||||
|
||||
Mat img = imread("image.jpg");
|
||||
Mat grey;
|
||||
cvtColor(img, grey, CV_BGR2GREY);
|
||||
cvtColor(img, grey, CV_BGR2GRAY);
|
||||
|
||||
Mat sobelx;
|
||||
Sobel(grey, sobelx, CV_32F, 1, 0);
|
||||
|
||||
@@ -269,7 +269,7 @@ void CameraWrapperConnector::fillListWrapperLibs(const string& folderPath, vecto
|
||||
|
||||
std::string CameraWrapperConnector::getDefaultPathLibFolder()
|
||||
{
|
||||
#define BIN_PACKAGE_NAME(x) "org.opencv.lib_v" CVAUX_STR(CV_MAJOR_VERSION) CVAUX_STR(CV_MINOR_VERSION) "_" x
|
||||
#define BIN_PACKAGE_NAME(x) "org.opencv.lib_v" CVAUX_STR(CV_VERSION_EPOCH) CVAUX_STR(CV_VERSION_MAJOR) "_" x
|
||||
const char* const packageList[] = {BIN_PACKAGE_NAME("armv7a"), OPENCV_ENGINE_PACKAGE};
|
||||
for (size_t i = 0; i < sizeof(packageList)/sizeof(packageList[0]); i++)
|
||||
{
|
||||
|
||||
@@ -1201,7 +1201,7 @@ StereoSGBM::StereoSGBM
|
||||
|
||||
:param speckleWindowSize: Maximum size of smooth disparity regions to consider their noise speckles and invalidate. Set it to 0 to disable speckle filtering. Otherwise, set it somewhere in the 50-200 range.
|
||||
|
||||
:param speckleRange: Maximum disparity variation within each connected component. If you do speckle filtering, set the parameter to a positive value, multiple of 16. Normally, 16 or 32 is good enough.
|
||||
:param speckleRange: Maximum disparity variation within each connected component. If you do speckle filtering, set the parameter to a positive value, it will be implicitly multiplied by 16. Normally, 1 or 2 is good enough.
|
||||
|
||||
:param fullDP: Set it to ``true`` to run the full-scale two-pass dynamic programming algorithm. It will consume O(W*H*numDisparities) bytes, which is large for 640x480 stereo and huge for HD-size pictures. By default, it is set to ``false`` .
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@
|
||||
#ifndef _CV_MODEL_EST_H_
|
||||
#define _CV_MODEL_EST_H_
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
|
||||
class CvModelEstimator2
|
||||
class CV_EXPORTS CvModelEstimator2
|
||||
{
|
||||
public:
|
||||
CvModelEstimator2(int _modelPoints, CvSize _modelSize, int _maxBasicSolutions);
|
||||
|
||||
@@ -412,7 +412,7 @@ CV_IMPL void cvComposeRT( const CvMat* _rvec1, const CvMat* _tvec1,
|
||||
cvRodrigues2( &r1, &R1, &dR1dr1 );
|
||||
cvRodrigues2( &r2, &R2, &dR2dr2 );
|
||||
|
||||
if( _rvec3 || dr3dr1 || dr3dr1 )
|
||||
if( _rvec3 || dr3dr1 || dr3dr2 )
|
||||
{
|
||||
double _r3[3], _R3[9], _dR3dR1[9*9], _dR3dR2[9*9], _dr3dR3[9*3];
|
||||
double _W1[9*3], _W2[3*3];
|
||||
@@ -3360,7 +3360,11 @@ void cv::projectPoints( InputArray _opoints,
|
||||
CvMat c_cameraMatrix = cameraMatrix;
|
||||
CvMat c_rvec = rvec, c_tvec = tvec;
|
||||
|
||||
double dc0buf[5]={0};
|
||||
Mat dc0(5,1,CV_64F,dc0buf);
|
||||
Mat distCoeffs = _distCoeffs.getMat();
|
||||
if( distCoeffs.empty() )
|
||||
distCoeffs = dc0;
|
||||
CvMat c_distCoeffs = distCoeffs;
|
||||
int ndistCoeffs = distCoeffs.rows + distCoeffs.cols - 1;
|
||||
|
||||
@@ -3375,8 +3379,7 @@ void cv::projectPoints( InputArray _opoints,
|
||||
pdpddist = &(dpddist = jacobian.colRange(10, 10+ndistCoeffs));
|
||||
}
|
||||
|
||||
cvProjectPoints2( &c_objectPoints, &c_rvec, &c_tvec, &c_cameraMatrix,
|
||||
(distCoeffs.empty())? 0: &c_distCoeffs,
|
||||
cvProjectPoints2( &c_objectPoints, &c_rvec, &c_tvec, &c_cameraMatrix, &c_distCoeffs,
|
||||
&c_imagePoints, pdpdrot, pdpdt, pdpdf, pdpdc, pdpddist, aspectRatio );
|
||||
}
|
||||
|
||||
@@ -3735,13 +3738,13 @@ float cv::rectify3Collinear( InputArray _cameraMatrix1, InputArray _distCoeffs1,
|
||||
OutputArray _Rmat1, OutputArray _Rmat2, OutputArray _Rmat3,
|
||||
OutputArray _Pmat1, OutputArray _Pmat2, OutputArray _Pmat3,
|
||||
OutputArray _Qmat,
|
||||
double alpha, Size /*newImgSize*/,
|
||||
double alpha, Size newImgSize,
|
||||
Rect* roi1, Rect* roi2, int flags )
|
||||
{
|
||||
// first, rectify the 1-2 stereo pair
|
||||
stereoRectify( _cameraMatrix1, _distCoeffs1, _cameraMatrix2, _distCoeffs2,
|
||||
imageSize, _Rmat12, _Tmat12, _Rmat1, _Rmat2, _Pmat1, _Pmat2, _Qmat,
|
||||
flags, alpha, imageSize, roi1, roi2 );
|
||||
flags, alpha, newImgSize, roi1, roi2 );
|
||||
|
||||
Mat R12 = _Rmat12.getMat(), R13 = _Rmat13.getMat(), T12 = _Tmat12.getMat(), T13 = _Tmat13.getMat();
|
||||
|
||||
|
||||
@@ -319,6 +319,9 @@ bool CvModelEstimator2::getSubset( const CvMat* m1, const CvMat* m2,
|
||||
|
||||
bool CvModelEstimator2::checkSubset( const CvMat* m, int count )
|
||||
{
|
||||
if( count <= 2 )
|
||||
return true;
|
||||
|
||||
int j, k, i, i0, i1;
|
||||
CvPoint2D64f* ptr = (CvPoint2D64f*)m->data.ptr;
|
||||
|
||||
@@ -351,7 +354,7 @@ bool CvModelEstimator2::checkSubset( const CvMat* m, int count )
|
||||
break;
|
||||
}
|
||||
|
||||
return i >= i1;
|
||||
return i > i1;
|
||||
}
|
||||
|
||||
|
||||
@@ -457,23 +460,24 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to,
|
||||
double param1, double param2)
|
||||
{
|
||||
Mat from = _from.getMat(), to = _to.getMat();
|
||||
int count = from.checkVector(3, CV_32F);
|
||||
int count = from.checkVector(3);
|
||||
|
||||
CV_Assert( count >= 0 && to.checkVector(3, CV_32F) == count );
|
||||
CV_Assert( count >= 0 && to.checkVector(3) == count );
|
||||
|
||||
_out.create(3, 4, CV_64F);
|
||||
Mat out = _out.getMat();
|
||||
|
||||
_inliers.create(count, 1, CV_8U, -1, true);
|
||||
Mat inliers = _inliers.getMat();
|
||||
Mat inliers(1, count, CV_8U);
|
||||
inliers = Scalar::all(1);
|
||||
|
||||
Mat dFrom, dTo;
|
||||
from.convertTo(dFrom, CV_64F);
|
||||
to.convertTo(dTo, CV_64F);
|
||||
dFrom = dFrom.reshape(3, 1);
|
||||
dTo = dTo.reshape(3, 1);
|
||||
|
||||
CvMat F3x4 = out;
|
||||
CvMat mask = inliers;
|
||||
CvMat mask = inliers;
|
||||
CvMat m1 = dFrom;
|
||||
CvMat m2 = dTo;
|
||||
|
||||
@@ -481,5 +485,9 @@ int cv::estimateAffine3D(InputArray _from, InputArray _to,
|
||||
param1 = param1 <= 0 ? 3 : param1;
|
||||
param2 = (param2 < epsilon) ? 0.99 : (param2 > 1 - epsilon) ? 0.99 : param2;
|
||||
|
||||
return Affine3DEstimator().runRANSAC(&m1, &m2, &F3x4, &mask, param1, param2 );
|
||||
int ok = Affine3DEstimator().runRANSAC(&m1, &m2, &F3x4, &mask, param1, param2 );
|
||||
if( _inliers.needed() )
|
||||
transpose(inliers, _inliers);
|
||||
|
||||
return ok;
|
||||
}
|
||||
|
||||
@@ -119,12 +119,6 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
|
||||
float diff = (float)criteria.epsilon;
|
||||
float inv_focalLength = 1 / focalLength;
|
||||
|
||||
/* init variables */
|
||||
int N = pObject->N;
|
||||
float *objectVectors = pObject->obj_vecs;
|
||||
float *invMatrix = pObject->inv_matr;
|
||||
float *imgVectors = pObject->img_vecs;
|
||||
|
||||
/* Check bad arguments */
|
||||
if( imagePoints == NULL )
|
||||
return CV_NULLPTR_ERR;
|
||||
@@ -143,6 +137,12 @@ static CvStatus icvPOSIT( CvPOSITObject *pObject, CvPoint2D32f *imagePoints,
|
||||
if( (criteria.type & CV_TERMCRIT_ITER) && criteria.max_iter <= 0 )
|
||||
return CV_BADFACTOR_ERR;
|
||||
|
||||
/* init variables */
|
||||
int N = pObject->N;
|
||||
float *objectVectors = pObject->obj_vecs;
|
||||
float *invMatrix = pObject->inv_matr;
|
||||
float *imgVectors = pObject->img_vecs;
|
||||
|
||||
while( !converged )
|
||||
{
|
||||
if( count == 0 )
|
||||
|
||||
@@ -857,105 +857,120 @@ Rect getValidDisparityROI( Rect roi1, Rect roi2,
|
||||
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
template <typename T>
|
||||
void filterSpecklesImpl(cv::Mat& img, int newVal, int maxSpeckleSize, int maxDiff, cv::Mat& _buf)
|
||||
{
|
||||
using namespace cv;
|
||||
|
||||
int width = img.cols, height = img.rows, npixels = width*height;
|
||||
size_t bufSize = npixels*(int)(sizeof(Point2s) + sizeof(int) + sizeof(uchar));
|
||||
if( !_buf.isContinuous() || !_buf.data || _buf.cols*_buf.rows*_buf.elemSize() < bufSize )
|
||||
_buf.create(1, (int)bufSize, CV_8U);
|
||||
|
||||
uchar* buf = _buf.data;
|
||||
int i, j, dstep = (int)(img.step/sizeof(T));
|
||||
int* labels = (int*)buf;
|
||||
buf += npixels*sizeof(labels[0]);
|
||||
Point2s* wbuf = (Point2s*)buf;
|
||||
buf += npixels*sizeof(wbuf[0]);
|
||||
uchar* rtype = (uchar*)buf;
|
||||
int curlabel = 0;
|
||||
|
||||
// clear out label assignments
|
||||
memset(labels, 0, npixels*sizeof(labels[0]));
|
||||
|
||||
for( i = 0; i < height; i++ )
|
||||
{
|
||||
T* ds = img.ptr<T>(i);
|
||||
int* ls = labels + width*i;
|
||||
|
||||
for( j = 0; j < width; j++ )
|
||||
{
|
||||
if( ds[j] != newVal ) // not a bad disparity
|
||||
{
|
||||
if( ls[j] ) // has a label, check for bad label
|
||||
{
|
||||
if( rtype[ls[j]] ) // small region, zero out disparity
|
||||
ds[j] = (T)newVal;
|
||||
}
|
||||
// no label, assign and propagate
|
||||
else
|
||||
{
|
||||
Point2s* ws = wbuf; // initialize wavefront
|
||||
Point2s p((short)j, (short)i); // current pixel
|
||||
curlabel++; // next label
|
||||
int count = 0; // current region size
|
||||
ls[j] = curlabel;
|
||||
|
||||
// wavefront propagation
|
||||
while( ws >= wbuf ) // wavefront not empty
|
||||
{
|
||||
count++;
|
||||
// put neighbors onto wavefront
|
||||
T* dpp = &img.at<T>(p.y, p.x);
|
||||
T dp = *dpp;
|
||||
int* lpp = labels + width*p.y + p.x;
|
||||
|
||||
if( p.x < width-1 && !lpp[+1] && dpp[+1] != newVal && std::abs(dp - dpp[+1]) <= maxDiff )
|
||||
{
|
||||
lpp[+1] = curlabel;
|
||||
*ws++ = Point2s(p.x+1, p.y);
|
||||
}
|
||||
|
||||
if( p.x > 0 && !lpp[-1] && dpp[-1] != newVal && std::abs(dp - dpp[-1]) <= maxDiff )
|
||||
{
|
||||
lpp[-1] = curlabel;
|
||||
*ws++ = Point2s(p.x-1, p.y);
|
||||
}
|
||||
|
||||
if( p.y < height-1 && !lpp[+width] && dpp[+dstep] != newVal && std::abs(dp - dpp[+dstep]) <= maxDiff )
|
||||
{
|
||||
lpp[+width] = curlabel;
|
||||
*ws++ = Point2s(p.x, p.y+1);
|
||||
}
|
||||
|
||||
if( p.y > 0 && !lpp[-width] && dpp[-dstep] != newVal && std::abs(dp - dpp[-dstep]) <= maxDiff )
|
||||
{
|
||||
lpp[-width] = curlabel;
|
||||
*ws++ = Point2s(p.x, p.y-1);
|
||||
}
|
||||
|
||||
// pop most recent and propagate
|
||||
// NB: could try least recent, maybe better convergence
|
||||
p = *--ws;
|
||||
}
|
||||
|
||||
// assign label type
|
||||
if( count <= maxSpeckleSize ) // speckle region
|
||||
{
|
||||
rtype[ls[j]] = 1; // small region label
|
||||
ds[j] = (T)newVal;
|
||||
}
|
||||
else
|
||||
rtype[ls[j]] = 0; // large region label
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void cv::filterSpeckles( InputOutputArray _img, double _newval, int maxSpeckleSize,
|
||||
double _maxDiff, InputOutputArray __buf )
|
||||
{
|
||||
Mat img = _img.getMat();
|
||||
Mat temp, &_buf = __buf.needed() ? __buf.getMatRef() : temp;
|
||||
CV_Assert( img.type() == CV_16SC1 );
|
||||
CV_Assert( img.type() == CV_8UC1 || img.type() == CV_16SC1 );
|
||||
|
||||
int newVal = cvRound(_newval);
|
||||
int maxDiff = cvRound(_maxDiff);
|
||||
int width = img.cols, height = img.rows, npixels = width*height;
|
||||
size_t bufSize = npixels*(int)(sizeof(Point2s) + sizeof(int) + sizeof(uchar));
|
||||
if( !_buf.isContinuous() || !_buf.data || _buf.cols*_buf.rows*_buf.elemSize() < bufSize )
|
||||
_buf.create(1, (int)bufSize, CV_8U);
|
||||
|
||||
uchar* buf = _buf.data;
|
||||
int i, j, dstep = (int)(img.step/sizeof(short));
|
||||
int* labels = (int*)buf;
|
||||
buf += npixels*sizeof(labels[0]);
|
||||
Point2s* wbuf = (Point2s*)buf;
|
||||
buf += npixels*sizeof(wbuf[0]);
|
||||
uchar* rtype = (uchar*)buf;
|
||||
int curlabel = 0;
|
||||
|
||||
// clear out label assignments
|
||||
memset(labels, 0, npixels*sizeof(labels[0]));
|
||||
|
||||
for( i = 0; i < height; i++ )
|
||||
{
|
||||
short* ds = img.ptr<short>(i);
|
||||
int* ls = labels + width*i;
|
||||
|
||||
for( j = 0; j < width; j++ )
|
||||
{
|
||||
if( ds[j] != newVal ) // not a bad disparity
|
||||
{
|
||||
if( ls[j] ) // has a label, check for bad label
|
||||
{
|
||||
if( rtype[ls[j]] ) // small region, zero out disparity
|
||||
ds[j] = (short)newVal;
|
||||
}
|
||||
// no label, assign and propagate
|
||||
else
|
||||
{
|
||||
Point2s* ws = wbuf; // initialize wavefront
|
||||
Point2s p((short)j, (short)i); // current pixel
|
||||
curlabel++; // next label
|
||||
int count = 0; // current region size
|
||||
ls[j] = curlabel;
|
||||
|
||||
// wavefront propagation
|
||||
while( ws >= wbuf ) // wavefront not empty
|
||||
{
|
||||
count++;
|
||||
// put neighbors onto wavefront
|
||||
short* dpp = &img.at<short>(p.y, p.x);
|
||||
short dp = *dpp;
|
||||
int* lpp = labels + width*p.y + p.x;
|
||||
|
||||
if( p.x < width-1 && !lpp[+1] && dpp[+1] != newVal && std::abs(dp - dpp[+1]) <= maxDiff )
|
||||
{
|
||||
lpp[+1] = curlabel;
|
||||
*ws++ = Point2s(p.x+1, p.y);
|
||||
}
|
||||
|
||||
if( p.x > 0 && !lpp[-1] && dpp[-1] != newVal && std::abs(dp - dpp[-1]) <= maxDiff )
|
||||
{
|
||||
lpp[-1] = curlabel;
|
||||
*ws++ = Point2s(p.x-1, p.y);
|
||||
}
|
||||
|
||||
if( p.y < height-1 && !lpp[+width] && dpp[+dstep] != newVal && std::abs(dp - dpp[+dstep]) <= maxDiff )
|
||||
{
|
||||
lpp[+width] = curlabel;
|
||||
*ws++ = Point2s(p.x, p.y+1);
|
||||
}
|
||||
|
||||
if( p.y > 0 && !lpp[-width] && dpp[-dstep] != newVal && std::abs(dp - dpp[-dstep]) <= maxDiff )
|
||||
{
|
||||
lpp[-width] = curlabel;
|
||||
*ws++ = Point2s(p.x, p.y-1);
|
||||
}
|
||||
|
||||
// pop most recent and propagate
|
||||
// NB: could try least recent, maybe better convergence
|
||||
p = *--ws;
|
||||
}
|
||||
|
||||
// assign label type
|
||||
if( count <= maxSpeckleSize ) // speckle region
|
||||
{
|
||||
rtype[ls[j]] = 1; // small region label
|
||||
ds[j] = (short)newVal;
|
||||
}
|
||||
else
|
||||
rtype[ls[j]] = 0; // large region label
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (img.type() == CV_8UC1)
|
||||
filterSpecklesImpl<uchar>(img, newVal, maxSpeckleSize, maxDiff, _buf);
|
||||
else
|
||||
filterSpecklesImpl<short>(img, newVal, maxSpeckleSize, maxDiff, _buf);
|
||||
}
|
||||
|
||||
void cv::validateDisparity( InputOutputArray _disp, InputArray _cost, int minDisparity,
|
||||
|
||||
@@ -0,0 +1,226 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, 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 Intel Corporation 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 "test_precomp.hpp"
|
||||
#include "_modelest.h"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
class BareModelEstimator : public CvModelEstimator2
|
||||
{
|
||||
public:
|
||||
BareModelEstimator(int modelPoints, CvSize modelSize, int maxBasicSolutions);
|
||||
|
||||
virtual int runKernel( const CvMat*, const CvMat*, CvMat* );
|
||||
virtual void computeReprojError( const CvMat*, const CvMat*,
|
||||
const CvMat*, CvMat* );
|
||||
|
||||
bool checkSubsetPublic( const CvMat* ms1, int count, bool checkPartialSubset );
|
||||
};
|
||||
|
||||
BareModelEstimator::BareModelEstimator(int _modelPoints, CvSize _modelSize, int _maxBasicSolutions)
|
||||
:CvModelEstimator2(_modelPoints, _modelSize, _maxBasicSolutions)
|
||||
{
|
||||
}
|
||||
|
||||
int BareModelEstimator::runKernel( const CvMat*, const CvMat*, CvMat* )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void BareModelEstimator::computeReprojError( const CvMat*, const CvMat*,
|
||||
const CvMat*, CvMat* )
|
||||
{
|
||||
}
|
||||
|
||||
bool BareModelEstimator::checkSubsetPublic( const CvMat* ms1, int count, bool checkPartialSubset )
|
||||
{
|
||||
checkPartialSubsets = checkPartialSubset;
|
||||
return checkSubset(ms1, count);
|
||||
}
|
||||
|
||||
class CV_ModelEstimator2_Test : public cvtest::ArrayTest
|
||||
{
|
||||
public:
|
||||
CV_ModelEstimator2_Test();
|
||||
|
||||
protected:
|
||||
void get_test_array_types_and_sizes( int test_case_idx, vector<vector<Size> >& sizes, vector<vector<int> >& types );
|
||||
void fill_array( int test_case_idx, int i, int j, Mat& arr );
|
||||
double get_success_error_level( int test_case_idx, int i, int j );
|
||||
void run_func();
|
||||
void prepare_to_validation( int test_case_idx );
|
||||
|
||||
bool checkPartialSubsets;
|
||||
int usedPointsCount;
|
||||
|
||||
bool checkSubsetResult;
|
||||
int generalPositionsCount;
|
||||
int maxPointsCount;
|
||||
};
|
||||
|
||||
CV_ModelEstimator2_Test::CV_ModelEstimator2_Test()
|
||||
{
|
||||
generalPositionsCount = get_test_case_count() / 2;
|
||||
maxPointsCount = 100;
|
||||
|
||||
test_array[INPUT].push_back(NULL);
|
||||
test_array[OUTPUT].push_back(NULL);
|
||||
test_array[REF_OUTPUT].push_back(NULL);
|
||||
}
|
||||
|
||||
void CV_ModelEstimator2_Test::get_test_array_types_and_sizes( int /*test_case_idx*/,
|
||||
vector<vector<Size> > &sizes, vector<vector<int> > &types )
|
||||
{
|
||||
RNG &rng = ts->get_rng();
|
||||
checkPartialSubsets = (cvtest::randInt(rng) % 2 == 0);
|
||||
|
||||
int pointsCount = cvtest::randInt(rng) % maxPointsCount;
|
||||
usedPointsCount = pointsCount == 0 ? 0 : cvtest::randInt(rng) % pointsCount;
|
||||
|
||||
sizes[INPUT][0] = cvSize(1, pointsCount);
|
||||
types[INPUT][0] = CV_64FC2;
|
||||
|
||||
sizes[OUTPUT][0] = sizes[REF_OUTPUT][0] = cvSize(1, 1);
|
||||
types[OUTPUT][0] = types[REF_OUTPUT][0] = CV_8UC1;
|
||||
}
|
||||
|
||||
void CV_ModelEstimator2_Test::fill_array( int test_case_idx, int i, int j, Mat& arr )
|
||||
{
|
||||
if( i != INPUT )
|
||||
{
|
||||
cvtest::ArrayTest::fill_array( test_case_idx, i, j, arr );
|
||||
return;
|
||||
}
|
||||
|
||||
if (test_case_idx < generalPositionsCount)
|
||||
{
|
||||
//generate points in a general position (i.e. no three points can lie on the same line.)
|
||||
|
||||
bool isGeneralPosition;
|
||||
do
|
||||
{
|
||||
ArrayTest::fill_array(test_case_idx, i, j, arr);
|
||||
|
||||
//a simple check that the position is general:
|
||||
// for each line check that all other points don't belong to it
|
||||
isGeneralPosition = true;
|
||||
for (int startPointIndex = 0; startPointIndex < usedPointsCount && isGeneralPosition; startPointIndex++)
|
||||
{
|
||||
for (int endPointIndex = startPointIndex + 1; endPointIndex < usedPointsCount && isGeneralPosition; endPointIndex++)
|
||||
{
|
||||
|
||||
for (int testPointIndex = 0; testPointIndex < usedPointsCount && isGeneralPosition; testPointIndex++)
|
||||
{
|
||||
if (testPointIndex == startPointIndex || testPointIndex == endPointIndex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
CV_Assert(arr.type() == CV_64FC2);
|
||||
Point2d tangentVector_1 = arr.at<Point2d>(endPointIndex) - arr.at<Point2d>(startPointIndex);
|
||||
Point2d tangentVector_2 = arr.at<Point2d>(testPointIndex) - arr.at<Point2d>(startPointIndex);
|
||||
|
||||
const float eps = 1e-4f;
|
||||
//TODO: perhaps it is better to normalize the cross product by norms of the tangent vectors
|
||||
if (fabs(tangentVector_1.cross(tangentVector_2)) < eps)
|
||||
{
|
||||
isGeneralPosition = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
while(!isGeneralPosition);
|
||||
}
|
||||
else
|
||||
{
|
||||
//create points in a degenerate position (there are at least 3 points belonging to the same line)
|
||||
|
||||
ArrayTest::fill_array(test_case_idx, i, j, arr);
|
||||
if (usedPointsCount <= 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
RNG &rng = ts->get_rng();
|
||||
int startPointIndex, endPointIndex, modifiedPointIndex;
|
||||
do
|
||||
{
|
||||
startPointIndex = cvtest::randInt(rng) % usedPointsCount;
|
||||
endPointIndex = cvtest::randInt(rng) % usedPointsCount;
|
||||
modifiedPointIndex = checkPartialSubsets ? usedPointsCount - 1 : cvtest::randInt(rng) % usedPointsCount;
|
||||
}
|
||||
while (startPointIndex == endPointIndex || startPointIndex == modifiedPointIndex || endPointIndex == modifiedPointIndex);
|
||||
|
||||
double startWeight = cvtest::randReal(rng);
|
||||
CV_Assert(arr.type() == CV_64FC2);
|
||||
arr.at<Point2d>(modifiedPointIndex) = startWeight * arr.at<Point2d>(startPointIndex) + (1.0 - startWeight) * arr.at<Point2d>(endPointIndex);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
double CV_ModelEstimator2_Test::get_success_error_level( int /*test_case_idx*/, int /*i*/, int /*j*/ )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CV_ModelEstimator2_Test::prepare_to_validation( int test_case_idx )
|
||||
{
|
||||
test_mat[OUTPUT][0].at<uchar>(0) = checkSubsetResult;
|
||||
test_mat[REF_OUTPUT][0].at<uchar>(0) = test_case_idx < generalPositionsCount || usedPointsCount <= 2;
|
||||
}
|
||||
|
||||
void CV_ModelEstimator2_Test::run_func()
|
||||
{
|
||||
//make the input continuous
|
||||
Mat input = test_mat[INPUT][0].clone();
|
||||
CvMat _input = input;
|
||||
|
||||
RNG &rng = ts->get_rng();
|
||||
int modelPoints = cvtest::randInt(rng);
|
||||
CvSize modelSize = cvSize(2, modelPoints);
|
||||
int maxBasicSolutions = cvtest::randInt(rng);
|
||||
BareModelEstimator modelEstimator(modelPoints, modelSize, maxBasicSolutions);
|
||||
checkSubsetResult = modelEstimator.checkSubsetPublic(&_input, usedPointsCount, checkPartialSubsets);
|
||||
}
|
||||
|
||||
TEST(Calib3d_ModelEstimator2, accuracy) { CV_ModelEstimator2_Test test; test.safe_run(); }
|
||||
@@ -325,7 +325,7 @@ Retina::RetinaParameters
|
||||
.. ocv:struct:: Retina::RetinaParameters
|
||||
|
||||
This structure merges all the parameters that can be adjusted threw the **Retina::setup()**, **Retina::setupOPLandIPLParvoChannel** and **Retina::setupIPLMagnoChannel** setup methods
|
||||
Parameters structure for better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel. ::
|
||||
Parameters structure for better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel. ::
|
||||
|
||||
class RetinaParameters{
|
||||
struct OPLandIplParvoParameters{ // Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
|
||||
|
||||
@@ -115,7 +115,7 @@ class CV_EXPORTS Retina {
|
||||
public:
|
||||
|
||||
// parameters structure for better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel
|
||||
struct RetinaParameters{
|
||||
struct RetinaParameters{
|
||||
struct OPLandIplParvoParameters{ // Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
|
||||
OPLandIplParvoParameters():colorMode(true),
|
||||
normaliseOutput(true),
|
||||
@@ -166,14 +166,14 @@ public:
|
||||
virtual ~Retina();
|
||||
|
||||
/**
|
||||
* retreive retina input buffer size
|
||||
*/
|
||||
Size inputSize();
|
||||
* retreive retina input buffer size
|
||||
*/
|
||||
Size inputSize();
|
||||
|
||||
/**
|
||||
* retreive retina output buffer size
|
||||
*/
|
||||
Size outputSize();
|
||||
* retreive retina output buffer size
|
||||
*/
|
||||
Size outputSize();
|
||||
|
||||
/**
|
||||
* try to open an XML retina parameters file to adjust current retina instance setup
|
||||
@@ -190,9 +190,9 @@ public:
|
||||
* => if the xml file does not exist, then default setup is applied
|
||||
* => warning, Exceptions are thrown if read XML file is not valid
|
||||
* @param fs : the open Filestorage which contains retina parameters
|
||||
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
|
||||
* @param applyDefaultSetupOnFailure : set to true if an error must be thrown on error
|
||||
*/
|
||||
void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true);
|
||||
void setup(cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true);
|
||||
|
||||
/**
|
||||
* try to open an XML retina parameters file to adjust current retina instance setup
|
||||
@@ -203,10 +203,10 @@ public:
|
||||
*/
|
||||
void setup(RetinaParameters newParameters);
|
||||
|
||||
/**
|
||||
* @return the current parameters setup
|
||||
*/
|
||||
struct Retina::RetinaParameters getParameters();
|
||||
/**
|
||||
* @return the current parameters setup
|
||||
*/
|
||||
Retina::RetinaParameters getParameters();
|
||||
|
||||
/**
|
||||
* parameters setup display method
|
||||
@@ -305,17 +305,17 @@ public:
|
||||
*/
|
||||
void clearBuffers();
|
||||
|
||||
/**
|
||||
* Activate/desactivate the Magnocellular pathway processing (motion information extraction), by default, it is activated
|
||||
* @param activate: true if Magnocellular output should be activated, false if not
|
||||
*/
|
||||
void activateMovingContoursProcessing(const bool activate);
|
||||
/**
|
||||
* Activate/desactivate the Magnocellular pathway processing (motion information extraction), by default, it is activated
|
||||
* @param activate: true if Magnocellular output should be activated, false if not
|
||||
*/
|
||||
void activateMovingContoursProcessing(const bool activate);
|
||||
|
||||
/**
|
||||
* Activate/desactivate the Parvocellular pathway processing (contours information extraction), by default, it is activated
|
||||
* @param activate: true if Parvocellular (contours information extraction) output should be activated, false if not
|
||||
*/
|
||||
void activateContoursProcessing(const bool activate);
|
||||
/**
|
||||
* Activate/desactivate the Parvocellular pathway processing (contours information extraction), by default, it is activated
|
||||
* @param activate: true if Parvocellular (contours information extraction) output should be activated, false if not
|
||||
*/
|
||||
void activateContoursProcessing(const bool activate);
|
||||
|
||||
protected:
|
||||
// Parameteres setup members
|
||||
|
||||
@@ -622,7 +622,6 @@ void ChamferMatcher::Matching::followContour(Mat& templ_img, template_coords_t&
|
||||
{
|
||||
const int dir[][2] = { {-1,-1}, {-1,0}, {-1,1}, {0,1}, {1,1}, {1,0}, {1,-1}, {0,-1} };
|
||||
coordinate_t next;
|
||||
coordinate_t next_temp;
|
||||
unsigned char ptr;
|
||||
|
||||
assert (direction==-1 || !coords.empty());
|
||||
@@ -931,15 +930,13 @@ void ChamferMatcher::Template::show() const
|
||||
void ChamferMatcher::Matching::addTemplateFromImage(Mat& templ, float scale)
|
||||
{
|
||||
Template* cmt = new Template(templ, scale);
|
||||
if(templates.size() > 0)
|
||||
templates.clear();
|
||||
templates.clear();
|
||||
templates.push_back(cmt);
|
||||
cmt->show();
|
||||
}
|
||||
|
||||
void ChamferMatcher::Matching::addTemplate(Template& template_){
|
||||
if(templates.size() > 0)
|
||||
templates.clear();
|
||||
templates.clear();
|
||||
templates.push_back(&template_);
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -10,7 +10,6 @@ if(HAVE_CUDA)
|
||||
file(GLOB lib_cuda "src/cuda/*.cu")
|
||||
ocv_cuda_compile(cuda_objs ${lib_cuda})
|
||||
|
||||
|
||||
set(cuda_link_libs ${CUDA_LIBRARIES} ${CUDA_npp_LIBRARY})
|
||||
else()
|
||||
set(lib_cuda "")
|
||||
|
||||
@@ -210,16 +210,40 @@ The sample below demonstrates how to use RotatedRect:
|
||||
|
||||
.. seealso::
|
||||
|
||||
:ocv:cfunc:`CamShift`,
|
||||
:ocv:func:`fitEllipse`,
|
||||
:ocv:func:`minAreaRect`,
|
||||
:ocv:func:`CamShift` ,
|
||||
:ocv:func:`fitEllipse` ,
|
||||
:ocv:func:`minAreaRect` ,
|
||||
:ocv:struct:`CvBox2D`
|
||||
|
||||
TermCriteria
|
||||
------------
|
||||
.. ocv:class:: TermCriteria
|
||||
|
||||
Template class defining termination criteria for iterative algorithms.
|
||||
The class defining termination criteria for iterative algorithms. You can initialize it by default constructor and then override any parameters, or the structure may be fully initialized using the advanced variant of the constructor.
|
||||
|
||||
TermCriteria::TermCriteria
|
||||
--------------------------
|
||||
The constructors.
|
||||
|
||||
.. ocv:function:: TermCriteria::TermCriteria()
|
||||
|
||||
.. ocv:function:: TermCriteria::TermCriteria(int type, int maxCount, double epsilon)
|
||||
|
||||
.. ocv:function:: TermCriteria::TermCriteria(const CvTermCriteria& criteria)
|
||||
|
||||
:param type: The type of termination criteria: ``TermCriteria::COUNT``, ``TermCriteria::EPS`` or ``TermCriteria::COUNT`` + ``TermCriteria::EPS``.
|
||||
|
||||
:param maxCount: The maximum number of iterations or elements to compute.
|
||||
|
||||
:param epsilon: The desired accuracy or change in parameters at which the iterative algorithm stops.
|
||||
|
||||
:param criteria: Termination criteria in the deprecated ``CvTermCriteria`` format.
|
||||
|
||||
TermCriteria::operator CvTermCriteria
|
||||
-------------------------------------
|
||||
Converts to the deprecated ``CvTermCriteria`` format.
|
||||
|
||||
.. ocv:function:: TermCriteria::operator CvTermCriteria() const
|
||||
|
||||
Matx
|
||||
----
|
||||
@@ -1303,7 +1327,7 @@ because ``cvtColor`` , as well as the most of OpenCV functions, calls ``Mat::cre
|
||||
|
||||
|
||||
Mat::addref
|
||||
---------------
|
||||
-----------
|
||||
Increments the reference counter.
|
||||
|
||||
.. ocv:function:: void Mat::addref()
|
||||
@@ -1313,7 +1337,7 @@ The method increments the reference counter associated with the matrix data. If
|
||||
|
||||
|
||||
Mat::release
|
||||
----------------
|
||||
------------
|
||||
Decrements the reference counter and deallocates the matrix if needed.
|
||||
|
||||
.. ocv:function:: void Mat::release()
|
||||
@@ -1324,7 +1348,7 @@ The method decrements the reference counter associated with the matrix data. Whe
|
||||
This method can be called manually to force the matrix data deallocation. But since this method is automatically called in the destructor, or by any other method that changes the data pointer, it is usually not needed. The reference counter decrement and check for 0 is an atomic operation on the platforms that support it. Thus, it is safe to operate on the same matrices asynchronously in different threads.
|
||||
|
||||
Mat::resize
|
||||
---------------
|
||||
-----------
|
||||
Changes the number of matrix rows.
|
||||
|
||||
.. ocv:function:: void Mat::resize( size_t sz )
|
||||
@@ -1337,7 +1361,7 @@ The methods change the number of matrix rows. If the matrix is reallocated, the
|
||||
|
||||
|
||||
Mat::reserve
|
||||
---------------
|
||||
------------
|
||||
Reserves space for the certain number of rows.
|
||||
|
||||
.. ocv:function:: void Mat::reserve( size_t sz )
|
||||
@@ -1370,7 +1394,7 @@ The method removes one or more rows from the bottom of the matrix.
|
||||
|
||||
|
||||
Mat::locateROI
|
||||
------------------
|
||||
--------------
|
||||
Locates the matrix header within a parent matrix.
|
||||
|
||||
.. ocv:function:: void Mat::locateROI( Size& wholeSize, Point& ofs ) const
|
||||
@@ -1387,7 +1411,7 @@ After you extracted a submatrix from a matrix using
|
||||
|
||||
|
||||
Mat::adjustROI
|
||||
------------------
|
||||
--------------
|
||||
Adjusts a submatrix size and position within the parent matrix.
|
||||
|
||||
.. ocv:function:: Mat& Mat::adjustROI( int dtop, int dbottom, int dleft, int dright )
|
||||
@@ -1417,7 +1441,7 @@ The function is used internally by the OpenCV filtering functions, like
|
||||
|
||||
|
||||
Mat::operator()
|
||||
-------------------
|
||||
---------------
|
||||
Extracts a rectangular submatrix.
|
||||
|
||||
.. ocv:function:: Mat Mat::operator()( Range rowRange, Range colRange ) const
|
||||
@@ -1955,202 +1979,6 @@ SparseMat
|
||||
---------
|
||||
.. ocv:class:: SparseMat
|
||||
|
||||
Sparse n-dimensional array. ::
|
||||
|
||||
class SparseMat
|
||||
{
|
||||
public:
|
||||
typedef SparseMatIterator iterator;
|
||||
typedef SparseMatConstIterator const_iterator;
|
||||
|
||||
// internal structure - sparse matrix header
|
||||
struct Hdr
|
||||
{
|
||||
...
|
||||
};
|
||||
|
||||
// sparse matrix node - element of a hash table
|
||||
struct Node
|
||||
{
|
||||
size_t hashval;
|
||||
size_t next;
|
||||
int idx[CV_MAX_DIM];
|
||||
};
|
||||
|
||||
////////// constructors and destructor //////////
|
||||
// default constructor
|
||||
SparseMat();
|
||||
// creates matrix of the specified size and type
|
||||
SparseMat(int dims, const int* _sizes, int _type);
|
||||
// copy constructor
|
||||
SparseMat(const SparseMat& m);
|
||||
// converts dense array to the sparse form,
|
||||
// if try1d is true and matrix is a single-column matrix (Nx1),
|
||||
// then the sparse matrix will be 1-dimensional.
|
||||
SparseMat(const Mat& m, bool try1d=false);
|
||||
// converts an old-style sparse matrix to the new style.
|
||||
// all the data is copied so that "m" can be safely
|
||||
// deleted after the conversion
|
||||
SparseMat(const CvSparseMat* m);
|
||||
// destructor
|
||||
~SparseMat();
|
||||
|
||||
///////// assignment operations ///////////
|
||||
|
||||
// this is an O(1) operation; no data is copied
|
||||
SparseMat& operator = (const SparseMat& m);
|
||||
// (equivalent to the corresponding constructor with try1d=false)
|
||||
SparseMat& operator = (const Mat& m);
|
||||
|
||||
// creates a full copy of the matrix
|
||||
SparseMat clone() const;
|
||||
|
||||
// copy all the data to the destination matrix.
|
||||
// the destination will be reallocated if needed.
|
||||
void copyTo( SparseMat& m ) const;
|
||||
// converts 1D or 2D sparse matrix to dense 2D matrix.
|
||||
// If the sparse matrix is 1D, the result will
|
||||
// be a single-column matrix.
|
||||
void copyTo( Mat& m ) const;
|
||||
// converts arbitrary sparse matrix to dense matrix.
|
||||
// multiplies all the matrix elements by the specified scalar
|
||||
void convertTo( SparseMat& m, int rtype, double alpha=1 ) const;
|
||||
// converts sparse matrix to dense matrix with optional type conversion and scaling.
|
||||
// When rtype=-1, the destination element type will be the same
|
||||
// as the sparse matrix element type.
|
||||
// Otherwise, rtype will specify the depth and
|
||||
// the number of channels will remain the same as in the sparse matrix
|
||||
void convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const;
|
||||
|
||||
// not used now
|
||||
void assignTo( SparseMat& m, int type=-1 ) const;
|
||||
|
||||
// reallocates sparse matrix. If it was already of the proper size and type,
|
||||
// it is simply cleared with clear(), otherwise,
|
||||
// the old matrix is released (using release()) and the new one is allocated.
|
||||
void create(int dims, const int* _sizes, int _type);
|
||||
// sets all the matrix elements to 0, which means clearing the hash table.
|
||||
void clear();
|
||||
// manually increases reference counter to the header.
|
||||
void addref();
|
||||
// decreses the header reference counter when it reaches 0.
|
||||
// the header and all the underlying data are deallocated.
|
||||
void release();
|
||||
|
||||
// converts sparse matrix to the old-style representation.
|
||||
// all the elements are copied.
|
||||
operator CvSparseMat*() const;
|
||||
// size of each element in bytes
|
||||
// (the matrix nodes will be bigger because of
|
||||
// element indices and other SparseMat::Node elements).
|
||||
size_t elemSize() const;
|
||||
// elemSize()/channels()
|
||||
size_t elemSize1() const;
|
||||
|
||||
// the same is in Mat
|
||||
int type() const;
|
||||
int depth() const;
|
||||
int channels() const;
|
||||
|
||||
// returns the array of sizes and 0 if the matrix is not allocated
|
||||
const int* size() const;
|
||||
// returns i-th size (or 0)
|
||||
int size(int i) const;
|
||||
// returns the matrix dimensionality
|
||||
int dims() const;
|
||||
// returns the number of non-zero elements
|
||||
size_t nzcount() const;
|
||||
|
||||
// compute element hash value from the element indices:
|
||||
// 1D case
|
||||
size_t hash(int i0) const;
|
||||
// 2D case
|
||||
size_t hash(int i0, int i1) const;
|
||||
// 3D case
|
||||
size_t hash(int i0, int i1, int i2) const;
|
||||
// n-D case
|
||||
size_t hash(const int* idx) const;
|
||||
|
||||
// low-level element-access functions,
|
||||
// special variants for 1D, 2D, 3D cases, and the generic one for n-D case.
|
||||
//
|
||||
// return pointer to the matrix element.
|
||||
// if the element is there (it is non-zero), the pointer to it is returned
|
||||
// if it is not there and createMissing=false, NULL pointer is returned
|
||||
// if it is not there and createMissing=true, the new element
|
||||
// is created and initialized with 0. Pointer to it is returned.
|
||||
// If the optional hashval pointer is not NULL, the element hash value is
|
||||
// not computed but *hashval is taken instead.
|
||||
uchar* ptr(int i0, bool createMissing, size_t* hashval=0);
|
||||
uchar* ptr(int i0, int i1, bool createMissing, size_t* hashval=0);
|
||||
uchar* ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0);
|
||||
uchar* ptr(const int* idx, bool createMissing, size_t* hashval=0);
|
||||
|
||||
// higher-level element access functions:
|
||||
// ref<_Tp>(i0,...[,hashval]) - equivalent to *(_Tp*)ptr(i0,...true[,hashval]).
|
||||
// always return valid reference to the element.
|
||||
// If it does not exist, it is created.
|
||||
// find<_Tp>(i0,...[,hashval]) - equivalent to (_const Tp*)ptr(i0,...false[,hashval]).
|
||||
// return pointer to the element or NULL pointer if the element is not there.
|
||||
// value<_Tp>(i0,...[,hashval]) - equivalent to
|
||||
// { const _Tp* p = find<_Tp>(i0,...[,hashval]); return p ? *p : _Tp(); }
|
||||
// that is, 0 is returned when the element is not there.
|
||||
// note that _Tp must match the actual matrix type -
|
||||
// the functions do not do any on-fly type conversion
|
||||
|
||||
// 1D case
|
||||
template<typename _Tp> _Tp& ref(int i0, size_t* hashval=0);
|
||||
template<typename _Tp> _Tp value(int i0, size_t* hashval=0) const;
|
||||
template<typename _Tp> const _Tp* find(int i0, size_t* hashval=0) const;
|
||||
|
||||
// 2D case
|
||||
template<typename _Tp> _Tp& ref(int i0, int i1, size_t* hashval=0);
|
||||
template<typename _Tp> _Tp value(int i0, int i1, size_t* hashval=0) const;
|
||||
template<typename _Tp> const _Tp* find(int i0, int i1, size_t* hashval=0) const;
|
||||
|
||||
// 3D case
|
||||
template<typename _Tp> _Tp& ref(int i0, int i1, int i2, size_t* hashval=0);
|
||||
template<typename _Tp> _Tp value(int i0, int i1, int i2, size_t* hashval=0) const;
|
||||
template<typename _Tp> const _Tp* find(int i0, int i1, int i2, size_t* hashval=0) const;
|
||||
|
||||
// n-D case
|
||||
template<typename _Tp> _Tp& ref(const int* idx, size_t* hashval=0);
|
||||
template<typename _Tp> _Tp value(const int* idx, size_t* hashval=0) const;
|
||||
template<typename _Tp> const _Tp* find(const int* idx, size_t* hashval=0) const;
|
||||
|
||||
// erase the specified matrix element.
|
||||
// when there is no such an element, the methods do nothing
|
||||
void erase(int i0, int i1, size_t* hashval=0);
|
||||
void erase(int i0, int i1, int i2, size_t* hashval=0);
|
||||
void erase(const int* idx, size_t* hashval=0);
|
||||
|
||||
// return the matrix iterators,
|
||||
// pointing to the first sparse matrix element,
|
||||
SparseMatIterator begin();
|
||||
SparseMatConstIterator begin() const;
|
||||
// ... or to the point after the last sparse matrix element
|
||||
SparseMatIterator end();
|
||||
SparseMatConstIterator end() const;
|
||||
|
||||
// and the template forms of the above methods.
|
||||
// _Tp must match the actual matrix type.
|
||||
template<typename _Tp> SparseMatIterator_<_Tp> begin();
|
||||
template<typename _Tp> SparseMatConstIterator_<_Tp> begin() const;
|
||||
template<typename _Tp> SparseMatIterator_<_Tp> end();
|
||||
template<typename _Tp> SparseMatConstIterator_<_Tp> end() const;
|
||||
|
||||
// return value stored in the sparse martix node
|
||||
template<typename _Tp> _Tp& value(Node* n);
|
||||
template<typename _Tp> const _Tp& value(const Node* n) const;
|
||||
|
||||
////////////// some internally used methods ///////////////
|
||||
...
|
||||
|
||||
// pointer to the sparse matrix header
|
||||
Hdr* hdr;
|
||||
};
|
||||
|
||||
|
||||
The class ``SparseMat`` represents multi-dimensional sparse numerical arrays. Such a sparse array can store elements of any type that
|
||||
:ocv:class:`Mat` can store. *Sparse* means that only non-zero elements are stored (though, as a result of operations on a sparse matrix, some of its stored elements can actually become 0. It is up to you to detect such elements and delete them using ``SparseMat::erase`` ). The non-zero elements are stored in a hash table that grows when it is filled so that the search time is O(1) in average (regardless of whether element is there or not). Elements can be accessed using the following methods:
|
||||
|
||||
@@ -2231,6 +2059,204 @@ The class ``SparseMat`` represents multi-dimensional sparse numerical arrays. Su
|
||||
|
||||
..
|
||||
|
||||
SparseMat::SparseMat
|
||||
--------------------
|
||||
Various SparseMat constructors.
|
||||
|
||||
.. ocv:function:: SparseMat::SparseMat()
|
||||
.. ocv:function:: SparseMat::SparseMat(int dims, const int* _sizes, int _type)
|
||||
.. ocv:function:: SparseMat::SparseMat(const SparseMat& m)
|
||||
.. ocv:function:: SparseMat::SparseMat(const Mat& m, bool try1d=false)
|
||||
.. ocv:function:: SparseMat::SparseMat(const CvSparseMat* m)
|
||||
|
||||
:param m: Source matrix for copy constructor. If m is dense matrix (ocv:class:`Mat`) then it will be converted to sparse representation.
|
||||
:param dims: Array dimensionality.
|
||||
:param _sizes: Sparce matrix size on all dementions.
|
||||
:param _type: Sparse matrix data type.
|
||||
:param try1d: if try1d is true and matrix is a single-column matrix (Nx1), then the sparse matrix will be 1-dimensional.
|
||||
|
||||
SparseMat::~SparseMat
|
||||
---------------------
|
||||
SparseMat object destructor.
|
||||
|
||||
.. ocv:function:: SparseMat::~SparseMat()
|
||||
|
||||
SparseMat::operator =
|
||||
---------------------
|
||||
Provides sparse matrix assignment operators.
|
||||
|
||||
.. ocv:function:: SparseMat& SparseMat::operator=(const SparseMat& m)
|
||||
.. ocv:function:: SparseMat& SparseMat::operator=(const Mat& m)
|
||||
|
||||
The last variant is equivalent to the corresponding constructor with try1d=false.
|
||||
|
||||
|
||||
SparseMat::clone
|
||||
----------------
|
||||
Creates a full copy of the matrix.
|
||||
|
||||
.. ocv:function:: SparseMat SparseMat::clone() const
|
||||
|
||||
SparseMat::copyTo
|
||||
-----------------
|
||||
Copy all the data to the destination matrix.The destination will be reallocated if needed.
|
||||
|
||||
.. ocv:function:: void SparseMat::copyTo( SparseMat& m ) const
|
||||
.. ocv:function:: void SparseMat::copyTo( Mat& m ) const
|
||||
|
||||
:param m: Target for copiing.
|
||||
|
||||
The last variant converts 1D or 2D sparse matrix to dense 2D matrix. If the sparse matrix is 1D, the result will be a single-column matrix.
|
||||
|
||||
SparceMat::convertTo
|
||||
--------------------
|
||||
Convert sparse matrix with possible type change and scaling.
|
||||
|
||||
.. ocv:function:: void SparseMat::convertTo( SparseMat& m, int rtype, double alpha=1 ) const
|
||||
.. ocv:function:: void SparseMat::convertTo( Mat& m, int rtype, double alpha=1, double beta=0 ) const
|
||||
|
||||
The first version converts arbitrary sparse matrix to dense matrix and multiplies all the matrix elements by the specified scalar.
|
||||
The second versiob converts sparse matrix to dense matrix with optional type conversion and scaling.
|
||||
When rtype=-1, the destination element type will be the same as the sparse matrix element type.
|
||||
Otherwise, rtype will specify the depth and the number of channels will remain the same as in the sparse matrix.
|
||||
|
||||
SparseMat:create
|
||||
----------------
|
||||
Reallocates sparse matrix. If it was already of the proper size and type, it is simply cleared with clear(), otherwise,
|
||||
the old matrix is released (using release()) and the new one is allocated.
|
||||
|
||||
.. ocv:function:: void SparseMat::create(int dims, const int* _sizes, int _type)
|
||||
|
||||
:param dims: Array dimensionality.
|
||||
:param _sizes: Sparce matrix size on all dementions.
|
||||
:param _type: Sparse matrix data type.
|
||||
|
||||
SparseMat::clear
|
||||
----------------
|
||||
Sets all the matrix elements to 0, which means clearing the hash table.
|
||||
|
||||
.. ocv:function:: void SparseMat::clear()
|
||||
|
||||
SparseMat::addref
|
||||
-----------------
|
||||
Manually increases reference counter to the header.
|
||||
|
||||
.. ocv:function:: void SparseMat::addref()
|
||||
|
||||
SparseMat::release
|
||||
------------------
|
||||
Decreses the header reference counter when it reaches 0. The header and all the underlying data are deallocated.
|
||||
|
||||
.. ocv:function:: void SparseMat::release()
|
||||
|
||||
SparseMat::CvSparseMat *
|
||||
------------------------
|
||||
Converts sparse matrix to the old-style representation. All the elements are copied.
|
||||
|
||||
.. ocv:function:: SparseMat::operator CvSparseMat*() const
|
||||
|
||||
SparseMat::elemSize
|
||||
-------------------
|
||||
Size of each element in bytes (the matrix nodes will be bigger because of element indices and other SparseMat::Node elements).
|
||||
|
||||
.. ocv:function:: size_t SparseMat::elemSize() const
|
||||
|
||||
SparseMat::elemSize1
|
||||
--------------------
|
||||
elemSize()/channels().
|
||||
|
||||
.. ocv:function:: size_t SparseMat::elemSize() const
|
||||
|
||||
SparseMat::type
|
||||
---------------
|
||||
Returns the type of a matrix element.
|
||||
|
||||
.. ocv:function:: int SparseMat::type() const
|
||||
|
||||
The method returns a sparse matrix element type. This is an identifier compatible with the ``CvMat`` type system, like ``CV_16SC3`` or 16-bit signed 3-channel array, and so on.
|
||||
|
||||
SparseMat::depth
|
||||
----------------
|
||||
Returns the depth of a sparse matrix element.
|
||||
|
||||
.. ocv:function:: int SparseMat::depth() const
|
||||
|
||||
The method returns the identifier of the matrix element depth (the type of each individual channel). For example, for a 16-bit signed 3-channel array, the method returns ``CV_16S``
|
||||
|
||||
* ``CV_8U`` - 8-bit unsigned integers ( ``0..255`` )
|
||||
|
||||
* ``CV_8S`` - 8-bit signed integers ( ``-128..127`` )
|
||||
|
||||
* ``CV_16U`` - 16-bit unsigned integers ( ``0..65535`` )
|
||||
|
||||
* ``CV_16S`` - 16-bit signed integers ( ``-32768..32767`` )
|
||||
|
||||
* ``CV_32S`` - 32-bit signed integers ( ``-2147483648..2147483647`` )
|
||||
|
||||
* ``CV_32F`` - 32-bit floating-point numbers ( ``-FLT_MAX..FLT_MAX, INF, NAN`` )
|
||||
|
||||
* ``CV_64F`` - 64-bit floating-point numbers ( ``-DBL_MAX..DBL_MAX, INF, NAN`` )
|
||||
|
||||
SparseMat::channels
|
||||
-------------------
|
||||
Returns the number of matrix channels.
|
||||
|
||||
.. ocv:function:: int SparseMat::channels() const
|
||||
|
||||
The method returns the number of matrix channels.
|
||||
|
||||
SparseMat::size
|
||||
---------------
|
||||
Returns the array of sizes or matrix size by i dimention and 0 if the matrix is not allocated.
|
||||
|
||||
.. ocv:function:: const int* SparseMat::size() const
|
||||
.. ocv:function:: int SparseMat::size(int i) const
|
||||
|
||||
:param i: Dimention index.
|
||||
|
||||
SparseMat::dims
|
||||
---------------
|
||||
Returns the matrix dimensionality.
|
||||
|
||||
.. ocv:function:: int SparseMat::dims() const
|
||||
|
||||
SparseMat::nzcount
|
||||
------------------
|
||||
Returns the number of non-zero elements.
|
||||
|
||||
.. ocv:function:: size_t SparseMat::nzcount() const
|
||||
|
||||
SparseMat::hash
|
||||
---------------
|
||||
Compute element hash value from the element indices.
|
||||
|
||||
.. ocv:function:: size_t SparseMat::hash(int i0) const
|
||||
.. ocv:function:: size_t SparseMat::hash(int i0, int i1) const
|
||||
.. ocv:function:: size_t SparseMat::hash(int i0, int i1, int i2) const
|
||||
.. ocv:function:: size_t SparseMat::hash(const int* idx) const
|
||||
|
||||
SparseMat::ptr
|
||||
--------------
|
||||
Low-level element-access functions, special variants for 1D, 2D, 3D cases, and the generic one for n-D case.
|
||||
|
||||
.. ocv:function:: uchar* SparseMat::ptr(int i0, bool createMissing, size_t* hashval=0)
|
||||
.. ocv:function:: uchar* SparseMat::ptr(int i0, int i1, bool createMissing, size_t* hashval=0)
|
||||
.. ocv:function:: uchar* SparseMat::ptr(int i0, int i1, int i2, bool createMissing, size_t* hashval=0)
|
||||
.. ocv:function:: uchar* SparseMat::ptr(const int* idx, bool createMissing, size_t* hashval=0)
|
||||
|
||||
Return pointer to the matrix element. If the element is there (it is non-zero), the pointer to it is returned.
|
||||
If it is not there and ``createMissing=false``, NULL pointer is returned. If it is not there and ``createMissing=true``,
|
||||
the new elementis created and initialized with 0. Pointer to it is returned. If the optional hashval pointer is not ``NULL``,
|
||||
the element hash value is not computed but ``hashval`` is taken instead.
|
||||
|
||||
SparseMat::erase
|
||||
----------------
|
||||
Erase the specified matrix element. When there is no such an element, the methods do nothing.
|
||||
|
||||
.. ocv:function:: void SparseMat::erase(int i0, int i1, size_t* hashval=0)
|
||||
.. ocv:function:: void SparseMat::erase(int i0, int i1, int i2, size_t* hashval=0)
|
||||
.. ocv:function:: void SparseMat::erase(const int* idx, size_t* hashval=0)
|
||||
|
||||
SparseMat\_
|
||||
-----------
|
||||
.. ocv:class:: SparseMat_
|
||||
@@ -2286,7 +2312,7 @@ Template sparse n-dimensional array class derived from
|
||||
SparseMatConstIterator_<_Tp> end() const;
|
||||
};
|
||||
|
||||
``SparseMat_`` is a thin wrapper on top of :ocv:class:`SparseMat` created in the same way as ``Mat_`` .
|
||||
``SparseMat_`` is a thin wrapper on top of :ocv:class:`SparseMat` created in the same way as ``Mat_`` .
|
||||
It simplifies notation of some operations. ::
|
||||
|
||||
int sz[] = {10, 20, 30};
|
||||
@@ -2340,6 +2366,11 @@ Here is example of SIFT use in your application via Algorithm interface: ::
|
||||
vector<KeyPoint> keypoints;
|
||||
(*sift)(image, noArray(), keypoints, descriptors);
|
||||
|
||||
Algorithm::name
|
||||
---------------
|
||||
Returns the algorithm name
|
||||
|
||||
.. ocv:function:: string Algorithm::name() const
|
||||
|
||||
Algorithm::get
|
||||
--------------
|
||||
|
||||
@@ -245,7 +245,6 @@ Calculates the width and height of a text string.
|
||||
The function ``getTextSize`` calculates and returns the size of a box that contains the specified text.
|
||||
That is, the following code renders some text, the tight box surrounding it, and the baseline: ::
|
||||
|
||||
// Use "y" to show that the baseLine is about
|
||||
string text = "Funny text inside the box";
|
||||
int fontFace = FONT_HERSHEY_SCRIPT_SIMPLEX;
|
||||
double fontScale = 2;
|
||||
|
||||
@@ -166,6 +166,12 @@ field of the set is the total number of nodes both occupied and free. When an oc
|
||||
|
||||
``CvSet`` is used to represent graphs (:ocv:struct:`CvGraph`), sparse multi-dimensional arrays (:ocv:struct:`CvSparseMat`), and planar subdivisions (:ocv:struct:`CvSubdiv2D`).
|
||||
|
||||
CvSetElem
|
||||
---------
|
||||
|
||||
.. ocv:struct:: CvSetElem
|
||||
|
||||
The structure is represent single element of :ocv:struct:`CvSet`. It consists of two fields: element data pointer and flags.
|
||||
|
||||
CvGraph
|
||||
-------
|
||||
@@ -174,6 +180,24 @@ CvGraph
|
||||
The structure ``CvGraph`` is a base for graphs used in OpenCV 1.x. It inherits from
|
||||
:ocv:struct:`CvSet`, that is, it is considered as a set of vertices. Besides, it contains another set as a member, a set of graph edges. Graphs in OpenCV are represented using adjacency lists format.
|
||||
|
||||
CvGraphVtx
|
||||
----------
|
||||
.. ocv:struct:: CvGraphVtx
|
||||
|
||||
The structure represents single vertex in :ocv:struct:`CvGraph`. It consists of two filds: pointer to first edge and flags.
|
||||
|
||||
CvGraphEdge
|
||||
-----------
|
||||
.. ocv:struct:: CvGraphEdge
|
||||
|
||||
The structure represents edge in :ocv:struct:`CvGraph`. Each edge consists of:
|
||||
|
||||
- Two pointers to the starting and ending vertices (vtx[0] and vtx[1] respectively);
|
||||
- Two pointers to next edges for the starting and ending vertices, where
|
||||
next[0] points to the next edge in the vtx[0] adjacency list and
|
||||
next[1] points to the next edge in the vtx[1] adjacency list;
|
||||
- Weight;
|
||||
- Flags.
|
||||
|
||||
CvGraphScanner
|
||||
--------------
|
||||
|
||||
@@ -3243,7 +3243,7 @@ The constructors.
|
||||
|
||||
* **SVD::NO_UV** indicates that only a vector of singular values ``w`` is to be processed, while ``u`` and ``vt`` will be set to empty matrices.
|
||||
|
||||
* **SVD::FULL_UV** when the matrix is not square, by default the algorithm produces ``u`` and ``vt`` matrices of sufficiently large size for the further ``A`` reconstruction; if, however, ``FULL_UV`` flag is specified, ``u`` and ``vt``will be full-size square orthogonal matrices.
|
||||
* **SVD::FULL_UV** when the matrix is not square, by default the algorithm produces ``u`` and ``vt`` matrices of sufficiently large size for the further ``A`` reconstruction; if, however, ``FULL_UV`` flag is specified, ``u`` and ``vt`` will be full-size square orthogonal matrices.
|
||||
|
||||
The first constructor initializes an empty ``SVD`` structure. The second constructor initializes an empty ``SVD`` structure and then calls
|
||||
:ocv:funcx:`SVD::operator()` .
|
||||
|
||||
@@ -2037,10 +2037,10 @@ public:
|
||||
//! default constructor
|
||||
TermCriteria();
|
||||
//! full constructor
|
||||
TermCriteria(int _type, int _maxCount, double _epsilon);
|
||||
TermCriteria(int type, int maxCount, double epsilon);
|
||||
//! conversion from CvTermCriteria
|
||||
TermCriteria(const CvTermCriteria& criteria);
|
||||
//! conversion from CvTermCriteria
|
||||
//! conversion to CvTermCriteria
|
||||
operator CvTermCriteria() const;
|
||||
|
||||
int type; //!< the type of termination criteria: COUNT, EPS or COUNT + EPS
|
||||
|
||||
@@ -177,6 +177,20 @@ namespace cv
|
||||
//#undef __CV_GPU_DEPR_BEFORE__
|
||||
//#undef __CV_GPU_DEPR_AFTER__
|
||||
|
||||
namespace device
|
||||
{
|
||||
using cv::gpu::PtrSz;
|
||||
using cv::gpu::PtrStep;
|
||||
using cv::gpu::PtrStepSz;
|
||||
|
||||
using cv::gpu::PtrStepSzb;
|
||||
using cv::gpu::PtrStepSzf;
|
||||
using cv::gpu::PtrStepSzi;
|
||||
|
||||
using cv::gpu::PtrStepb;
|
||||
using cv::gpu::PtrStepf;
|
||||
using cv::gpu::PtrStepi;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,6 +79,8 @@ namespace cv { namespace gpu
|
||||
WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30
|
||||
};
|
||||
|
||||
CV_EXPORTS bool deviceSupports(FeatureSet feature_set);
|
||||
|
||||
// Gives information about what GPU archs this OpenCV GPU module was
|
||||
// compiled for
|
||||
class CV_EXPORTS TargetArchs
|
||||
|
||||
@@ -716,12 +716,12 @@ template<typename _Tp, int m> struct CV_EXPORTS Matx_DetOp
|
||||
double operator ()(const Matx<_Tp, m, m>& a) const
|
||||
{
|
||||
Matx<_Tp, m, m> temp = a;
|
||||
double p = LU(temp.val, m, m, 0, 0, 0);
|
||||
double p = LU(temp.val, m*sizeof(_Tp), m, 0, 0, 0);
|
||||
if( p == 0 )
|
||||
return p;
|
||||
for( int i = 0; i < m; i++ )
|
||||
p *= temp(i, i);
|
||||
return p;
|
||||
return 1./p;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -342,9 +342,8 @@ CV_INLINE int cvFloor( double value )
|
||||
return i - (i > value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
Cv32suf diff;
|
||||
diff.f = (float)(value - i);
|
||||
return i - (diff.i < 0);
|
||||
float diff = (float)(value - i);
|
||||
return i - (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -360,9 +359,8 @@ CV_INLINE int cvCeil( double value )
|
||||
return i + (i < value);
|
||||
#else
|
||||
int i = cvRound(value);
|
||||
Cv32suf diff;
|
||||
diff.f = (float)(i - value);
|
||||
return i + (diff.i < 0);
|
||||
float diff = (float)(i - value);
|
||||
return i + (diff < 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -371,31 +369,19 @@ CV_INLINE int cvCeil( double value )
|
||||
|
||||
CV_INLINE int cvIsNaN( double value )
|
||||
{
|
||||
#if 1/*defined _MSC_VER || defined __BORLANDC__
|
||||
return _isnan(value);
|
||||
#elif defined __GNUC__
|
||||
return isnan(value);
|
||||
#else*/
|
||||
Cv64suf ieee754;
|
||||
ieee754.f = value;
|
||||
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) +
|
||||
((unsigned)ieee754.u != 0) > 0x7ff00000;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
CV_INLINE int cvIsInf( double value )
|
||||
{
|
||||
#if 1/*defined _MSC_VER || defined __BORLANDC__
|
||||
return !_finite(value);
|
||||
#elif defined __GNUC__
|
||||
return isinf(value);
|
||||
#else*/
|
||||
Cv64suf ieee754;
|
||||
ieee754.f = value;
|
||||
return ((unsigned)(ieee754.u >> 32) & 0x7fffffff) == 0x7ff00000 &&
|
||||
(unsigned)ieee754.u == 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -47,12 +47,23 @@
|
||||
#ifndef __OPENCV_VERSION_HPP__
|
||||
#define __OPENCV_VERSION_HPP__
|
||||
|
||||
#define CV_MAJOR_VERSION 2
|
||||
#define CV_MINOR_VERSION 4
|
||||
#define CV_SUBMINOR_VERSION 3
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 4
|
||||
#define CV_VERSION_REVISION 0
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
#define CV_VERSION CVAUX_STR(CV_MAJOR_VERSION) "." CVAUX_STR(CV_MINOR_VERSION) "." CVAUX_STR(CV_SUBMINOR_VERSION) ".2"
|
||||
|
||||
#if CV_VERSION_REVISION
|
||||
# define CV_VERSION CVAUX_STR(CV_VERSION_EPOCH) "." CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION)
|
||||
#else
|
||||
# define CV_VERSION CVAUX_STR(CV_VERSION_EPOCH) "." CVAUX_STR(CV_VERSION_MAJOR) "." CVAUX_STR(CV_VERSION_MINOR)
|
||||
#endif
|
||||
|
||||
/* old style version constants*/
|
||||
#define CV_MAJOR_VERSION CV_VERSION_EPOCH
|
||||
#define CV_MINOR_VERSION CV_VERSION_MAJOR
|
||||
#define CV_SUBMINOR_VERSION CV_VERSION_MINOR
|
||||
|
||||
#endif
|
||||
|
||||
@@ -6,7 +6,7 @@ using namespace perf;
|
||||
using std::tr1::make_tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
#define TYPICAL_MAT_TYPES_ADWEIGHTED CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32SC4
|
||||
#define TYPICAL_MAT_TYPES_ADWEIGHTED CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1
|
||||
#define TYPICAL_MATS_ADWEIGHTED testing::Combine(testing::Values(szVGA, sz720p, sz1080p), testing::Values(TYPICAL_MAT_TYPES_ADWEIGHTED))
|
||||
|
||||
PERF_TEST_P(Size_MatType, addWeighted, TYPICAL_MATS_ADWEIGHTED)
|
||||
|
||||
@@ -6,7 +6,7 @@ using namespace perf;
|
||||
using std::tr1::make_tuple;
|
||||
using std::tr1::get;
|
||||
|
||||
#define TYPICAL_MAT_SIZES_CORE_ARITHM TYPICAL_MAT_SIZES
|
||||
#define TYPICAL_MAT_SIZES_CORE_ARITHM ::szVGA, ::sz720p, ::sz1080p
|
||||
#define TYPICAL_MAT_TYPES_CORE_ARITHM CV_8UC1, CV_8SC1, CV_16SC1, CV_16SC2, CV_16SC3, CV_16SC4, CV_8UC4, CV_32SC1, CV_32FC1
|
||||
#define TYPICAL_MATS_CORE_ARITHM testing::Combine( testing::Values( TYPICAL_MAT_SIZES_CORE_ARITHM ), testing::Values( TYPICAL_MAT_TYPES_CORE_ARITHM ) )
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ PERF_TEST_P(Size_MatType, bitwise_not, TYPICAL_MATS_BITW_ARITHM)
|
||||
cv::Mat c = Mat(sz, type);
|
||||
|
||||
declare.in(a, WARMUP_RNG).out(c);
|
||||
declare.time(100);
|
||||
declare.iterations(200);
|
||||
|
||||
TEST_CYCLE() cv::bitwise_not(a, c);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ typedef perf::TestBaseWithParam<Size_MatType_CmpType_t> Size_MatType_CmpType;
|
||||
|
||||
PERF_TEST_P( Size_MatType_CmpType, compare,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(::perf::szVGA, ::perf::sz1080p),
|
||||
testing::Values(CV_8UC1, CV_8UC4, CV_8SC1, CV_16UC1, CV_16SC1, CV_32SC1, CV_32FC1),
|
||||
testing::ValuesIn(CmpType::all())
|
||||
)
|
||||
|
||||
@@ -29,6 +29,7 @@ PERF_TEST_P( Size_DepthSrc_DepthDst_Channels_alpha, convertTo,
|
||||
Mat src(sz, CV_MAKETYPE(depthSrc, channels));
|
||||
randu(src, 0, 255);
|
||||
Mat dst(sz, CV_MAKETYPE(depthDst, channels));
|
||||
declare.iterations(500);
|
||||
|
||||
TEST_CYCLE() src.convertTo(dst, depthDst, alpha);
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ PERF_TEST_P(Size_MatType_NormType, normalize,
|
||||
|
||||
PERF_TEST_P(Size_MatType_NormType, normalize_mask,
|
||||
testing::Combine(
|
||||
testing::Values(TYPICAL_MAT_SIZES),
|
||||
testing::Values(::perf::szVGA, ::perf::sz1080p),
|
||||
testing::Values(TYPICAL_MAT_TYPES),
|
||||
testing::Values((int)NORM_INF, (int)NORM_L1, (int)NORM_L2)
|
||||
)
|
||||
@@ -192,6 +192,7 @@ PERF_TEST_P( Size_MatType, normalize_minmax, TYPICAL_MATS )
|
||||
Mat dst(sz, matType);
|
||||
|
||||
declare.in(src, WARMUP_RNG).out(dst);
|
||||
declare.time(30);
|
||||
|
||||
TEST_CYCLE() normalize(src, dst, 20., 100., NORM_MINMAX);
|
||||
|
||||
|
||||
@@ -1242,11 +1242,15 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
Mat src1 = _src1.getMat(), src2 = _src2.getMat();
|
||||
bool haveMask = !_mask.empty();
|
||||
bool reallocate = false;
|
||||
|
||||
bool src1Scalar = checkScalar(src1, src2.type(), kind1, kind2);
|
||||
bool src2Scalar = checkScalar(src2, src1.type(), kind2, kind1);
|
||||
|
||||
if( (kind1 == kind2 || src1.channels() == 1) && src1.dims <= 2 && src2.dims <= 2 &&
|
||||
src1.size() == src2.size() && src1.type() == src2.type() &&
|
||||
!haveMask && ((!_dst.fixedType() && (dtype < 0 || CV_MAT_DEPTH(dtype) == src1.depth())) ||
|
||||
(_dst.fixedType() && _dst.type() == _src1.type())) )
|
||||
(_dst.fixedType() && _dst.type() == _src1.type())) &&
|
||||
((src1Scalar && src2Scalar) || (!src1Scalar && !src2Scalar)) )
|
||||
{
|
||||
_dst.create(src1.size(), src1.type());
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
#include "opencv2/gpu/device/saturate_cast.hpp"
|
||||
#include "opencv2/gpu/device/transform.hpp"
|
||||
#include "opencv2/gpu/device/functional.hpp"
|
||||
#include "opencv2/gpu/device/type_traits.hpp"
|
||||
|
||||
namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
@@ -54,6 +55,7 @@ namespace cv { namespace gpu { namespace device
|
||||
void writeScalar(const int*);
|
||||
void writeScalar(const float*);
|
||||
void writeScalar(const double*);
|
||||
void copyToWithMask_gpu(PtrStepSzb src, PtrStepSzb dst, size_t elemSize1, int cn, PtrStepSzb mask, bool colorMask, cudaStream_t stream);
|
||||
void convert_gpu(PtrStepSzb, int, PtrStepSzb, int, double, double, cudaStream_t);
|
||||
}}}
|
||||
|
||||
@@ -226,16 +228,16 @@ namespace cv { namespace gpu { namespace device
|
||||
//////////////////////////////// ConvertTo ////////////////////////////////
|
||||
///////////////////////////////////////////////////////////////////////////
|
||||
|
||||
template <typename T, typename D> struct Convertor : unary_function<T, D>
|
||||
template <typename T, typename D, typename S> struct Convertor : unary_function<T, D>
|
||||
{
|
||||
Convertor(double alpha_, double beta_) : alpha(alpha_), beta(beta_) {}
|
||||
Convertor(S alpha_, S beta_) : alpha(alpha_), beta(beta_) {}
|
||||
|
||||
__device__ __forceinline__ D operator()(const T& src) const
|
||||
__device__ __forceinline__ D operator()(typename TypeTraits<T>::ParameterType src) const
|
||||
{
|
||||
return saturate_cast<D>(alpha * src + beta);
|
||||
}
|
||||
|
||||
double alpha, beta;
|
||||
S alpha, beta;
|
||||
};
|
||||
|
||||
namespace detail
|
||||
@@ -282,16 +284,16 @@ namespace cv { namespace gpu { namespace device
|
||||
};
|
||||
}
|
||||
|
||||
template <typename T, typename D> struct TransformFunctorTraits< Convertor<T, D> > : detail::ConvertTraits< Convertor<T, D> >
|
||||
template <typename T, typename D, typename S> struct TransformFunctorTraits< Convertor<T, D, S> > : detail::ConvertTraits< Convertor<T, D, S> >
|
||||
{
|
||||
};
|
||||
|
||||
template<typename T, typename D>
|
||||
template<typename T, typename D, typename S>
|
||||
void cvt_(PtrStepSzb src, PtrStepSzb dst, double alpha, double beta, cudaStream_t stream)
|
||||
{
|
||||
cudaSafeCall( cudaSetDoubleForDevice(&alpha) );
|
||||
cudaSafeCall( cudaSetDoubleForDevice(&beta) );
|
||||
Convertor<T, D> op(alpha, beta);
|
||||
Convertor<T, D, S> op(static_cast<S>(alpha), static_cast<S>(beta));
|
||||
cv::gpu::device::transform((PtrStepSz<T>)src, (PtrStepSz<D>)dst, op, WithOutMask(), stream);
|
||||
}
|
||||
|
||||
@@ -304,36 +306,74 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
typedef void (*caller_t)(PtrStepSzb src, PtrStepSzb dst, double alpha, double beta, cudaStream_t stream);
|
||||
|
||||
static const caller_t tab[8][8] =
|
||||
static const caller_t tab[7][7] =
|
||||
{
|
||||
{cvt_<uchar, uchar>, cvt_<uchar, schar>, cvt_<uchar, ushort>, cvt_<uchar, short>,
|
||||
cvt_<uchar, int>, cvt_<uchar, float>, cvt_<uchar, double>, 0},
|
||||
|
||||
{cvt_<schar, uchar>, cvt_<schar, schar>, cvt_<schar, ushort>, cvt_<schar, short>,
|
||||
cvt_<schar, int>, cvt_<schar, float>, cvt_<schar, double>, 0},
|
||||
|
||||
{cvt_<ushort, uchar>, cvt_<ushort, schar>, cvt_<ushort, ushort>, cvt_<ushort, short>,
|
||||
cvt_<ushort, int>, cvt_<ushort, float>, cvt_<ushort, double>, 0},
|
||||
|
||||
{cvt_<short, uchar>, cvt_<short, schar>, cvt_<short, ushort>, cvt_<short, short>,
|
||||
cvt_<short, int>, cvt_<short, float>, cvt_<short, double>, 0},
|
||||
|
||||
{cvt_<int, uchar>, cvt_<int, schar>, cvt_<int, ushort>,
|
||||
cvt_<int, short>, cvt_<int, int>, cvt_<int, float>, cvt_<int, double>, 0},
|
||||
|
||||
{cvt_<float, uchar>, cvt_<float, schar>, cvt_<float, ushort>,
|
||||
cvt_<float, short>, cvt_<float, int>, cvt_<float, float>, cvt_<float, double>, 0},
|
||||
|
||||
{cvt_<double, uchar>, cvt_<double, schar>, cvt_<double, ushort>,
|
||||
cvt_<double, short>, cvt_<double, int>, cvt_<double, float>, cvt_<double, double>, 0},
|
||||
|
||||
{0,0,0,0,0,0,0,0}
|
||||
{
|
||||
cvt_<uchar, uchar, float>,
|
||||
cvt_<uchar, schar, float>,
|
||||
cvt_<uchar, ushort, float>,
|
||||
cvt_<uchar, short, float>,
|
||||
cvt_<uchar, int, float>,
|
||||
cvt_<uchar, float, float>,
|
||||
cvt_<uchar, double, double>
|
||||
},
|
||||
{
|
||||
cvt_<schar, uchar, float>,
|
||||
cvt_<schar, schar, float>,
|
||||
cvt_<schar, ushort, float>,
|
||||
cvt_<schar, short, float>,
|
||||
cvt_<schar, int, float>,
|
||||
cvt_<schar, float, float>,
|
||||
cvt_<schar, double, double>
|
||||
},
|
||||
{
|
||||
cvt_<ushort, uchar, float>,
|
||||
cvt_<ushort, schar, float>,
|
||||
cvt_<ushort, ushort, float>,
|
||||
cvt_<ushort, short, float>,
|
||||
cvt_<ushort, int, float>,
|
||||
cvt_<ushort, float, float>,
|
||||
cvt_<ushort, double, double>
|
||||
},
|
||||
{
|
||||
cvt_<short, uchar, float>,
|
||||
cvt_<short, schar, float>,
|
||||
cvt_<short, ushort, float>,
|
||||
cvt_<short, short, float>,
|
||||
cvt_<short, int, float>,
|
||||
cvt_<short, float, float>,
|
||||
cvt_<short, double, double>
|
||||
},
|
||||
{
|
||||
cvt_<int, uchar, float>,
|
||||
cvt_<int, schar, float>,
|
||||
cvt_<int, ushort, float>,
|
||||
cvt_<int, short, float>,
|
||||
cvt_<int, int, double>,
|
||||
cvt_<int, float, double>,
|
||||
cvt_<int, double, double>
|
||||
},
|
||||
{
|
||||
cvt_<float, uchar, float>,
|
||||
cvt_<float, schar, float>,
|
||||
cvt_<float, ushort, float>,
|
||||
cvt_<float, short, float>,
|
||||
cvt_<float, int, float>,
|
||||
cvt_<float, float, float>,
|
||||
cvt_<float, double, double>
|
||||
},
|
||||
{
|
||||
cvt_<double, uchar, double>,
|
||||
cvt_<double, schar, double>,
|
||||
cvt_<double, ushort, double>,
|
||||
cvt_<double, short, double>,
|
||||
cvt_<double, int, double>,
|
||||
cvt_<double, float, double>,
|
||||
cvt_<double, double, double>
|
||||
}
|
||||
};
|
||||
|
||||
caller_t func = tab[sdepth][ddepth];
|
||||
if (!func)
|
||||
cv::gpu::error("Unsupported convert operation", __FILE__, __LINE__, "convert_gpu");
|
||||
|
||||
func(src, dst, alpha, beta, stream);
|
||||
}
|
||||
|
||||
|
||||
+112
-51
@@ -45,8 +45,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime_api.h>
|
||||
#include <cuda_runtime.h>
|
||||
#include <npp.h>
|
||||
|
||||
#define CUDART_MINIMUM_REQUIRED_VERSION 4010
|
||||
@@ -69,33 +68,89 @@ using namespace cv::gpu;
|
||||
|
||||
namespace
|
||||
{
|
||||
// Compares value to set using the given comparator. Returns true if
|
||||
// there is at least one element x in the set satisfying to: x cmp value
|
||||
// predicate.
|
||||
template <typename Comparer>
|
||||
bool compareToSet(const std::string& set_as_str, int value, Comparer cmp)
|
||||
class CudaArch
|
||||
{
|
||||
public:
|
||||
CudaArch();
|
||||
|
||||
bool builtWith(FeatureSet feature_set) const;
|
||||
bool hasPtx(int major, int minor) const;
|
||||
bool hasBin(int major, int minor) const;
|
||||
bool hasEqualOrLessPtx(int major, int minor) const;
|
||||
bool hasEqualOrGreaterPtx(int major, int minor) const;
|
||||
bool hasEqualOrGreaterBin(int major, int minor) const;
|
||||
|
||||
private:
|
||||
static void fromStr(const string& set_as_str, vector<int>& arr);
|
||||
|
||||
vector<int> bin;
|
||||
vector<int> ptx;
|
||||
vector<int> features;
|
||||
};
|
||||
|
||||
const CudaArch cudaArch;
|
||||
|
||||
CudaArch::CudaArch()
|
||||
{
|
||||
#ifdef HAVE_CUDA
|
||||
fromStr(CUDA_ARCH_BIN, bin);
|
||||
fromStr(CUDA_ARCH_PTX, ptx);
|
||||
fromStr(CUDA_ARCH_FEATURES, features);
|
||||
#endif
|
||||
}
|
||||
|
||||
bool CudaArch::builtWith(FeatureSet feature_set) const
|
||||
{
|
||||
return !features.empty() && (features.back() >= feature_set);
|
||||
}
|
||||
|
||||
bool CudaArch::hasPtx(int major, int minor) const
|
||||
{
|
||||
return find(ptx.begin(), ptx.end(), major * 10 + minor) != ptx.end();
|
||||
}
|
||||
|
||||
bool CudaArch::hasBin(int major, int minor) const
|
||||
{
|
||||
return find(bin.begin(), bin.end(), major * 10 + minor) != bin.end();
|
||||
}
|
||||
|
||||
bool CudaArch::hasEqualOrLessPtx(int major, int minor) const
|
||||
{
|
||||
return !ptx.empty() && (ptx.front() <= major * 10 + minor);
|
||||
}
|
||||
|
||||
bool CudaArch::hasEqualOrGreaterPtx(int major, int minor) const
|
||||
{
|
||||
return !ptx.empty() && (ptx.back() >= major * 10 + minor);
|
||||
}
|
||||
|
||||
bool CudaArch::hasEqualOrGreaterBin(int major, int minor) const
|
||||
{
|
||||
return !bin.empty() && (bin.back() >= major * 10 + minor);
|
||||
}
|
||||
|
||||
void CudaArch::fromStr(const string& set_as_str, vector<int>& arr)
|
||||
{
|
||||
if (set_as_str.find_first_not_of(" ") == string::npos)
|
||||
return false;
|
||||
return;
|
||||
|
||||
std::stringstream stream(set_as_str);
|
||||
istringstream stream(set_as_str);
|
||||
int cur_value;
|
||||
|
||||
while (!stream.eof())
|
||||
{
|
||||
stream >> cur_value;
|
||||
if (cmp(cur_value, value))
|
||||
return true;
|
||||
arr.push_back(cur_value);
|
||||
}
|
||||
|
||||
return false;
|
||||
sort(arr.begin(), arr.end());
|
||||
}
|
||||
}
|
||||
|
||||
bool cv::gpu::TargetArchs::builtWith(cv::gpu::FeatureSet feature_set)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return ::compareToSet(CUDA_ARCH_FEATURES, feature_set, std::greater_equal<int>());
|
||||
return cudaArch.builtWith(feature_set);
|
||||
#else
|
||||
(void)feature_set;
|
||||
return false;
|
||||
@@ -110,7 +165,7 @@ bool cv::gpu::TargetArchs::has(int major, int minor)
|
||||
bool cv::gpu::TargetArchs::hasPtx(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor, std::equal_to<int>());
|
||||
return cudaArch.hasPtx(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
@@ -121,7 +176,7 @@ bool cv::gpu::TargetArchs::hasPtx(int major, int minor)
|
||||
bool cv::gpu::TargetArchs::hasBin(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return ::compareToSet(CUDA_ARCH_BIN, major * 10 + minor, std::equal_to<int>());
|
||||
return cudaArch.hasBin(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
@@ -132,8 +187,7 @@ bool cv::gpu::TargetArchs::hasBin(int major, int minor)
|
||||
bool cv::gpu::TargetArchs::hasEqualOrLessPtx(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor,
|
||||
std::less_equal<int>());
|
||||
return cudaArch.hasEqualOrLessPtx(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
@@ -143,14 +197,13 @@ bool cv::gpu::TargetArchs::hasEqualOrLessPtx(int major, int minor)
|
||||
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreater(int major, int minor)
|
||||
{
|
||||
return hasEqualOrGreaterPtx(major, minor) ||
|
||||
hasEqualOrGreaterBin(major, minor);
|
||||
return hasEqualOrGreaterPtx(major, minor) || hasEqualOrGreaterBin(major, minor);
|
||||
}
|
||||
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreaterPtx(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return ::compareToSet(CUDA_ARCH_PTX, major * 10 + minor, std::greater_equal<int>());
|
||||
return cudaArch.hasEqualOrGreaterPtx(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
@@ -161,8 +214,7 @@ bool cv::gpu::TargetArchs::hasEqualOrGreaterPtx(int major, int minor)
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return ::compareToSet(CUDA_ARCH_BIN, major * 10 + minor,
|
||||
std::greater_equal<int>());
|
||||
return cudaArch.hasEqualOrGreaterBin(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
@@ -170,6 +222,31 @@ bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::gpu::deviceSupports(FeatureSet feature_set)
|
||||
{
|
||||
static int versions[] =
|
||||
{
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
|
||||
};
|
||||
static const int cache_size = static_cast<int>(sizeof(versions) / sizeof(versions[0]));
|
||||
|
||||
const int devId = getDevice();
|
||||
|
||||
int version;
|
||||
|
||||
if (devId < cache_size && versions[devId] >= 0)
|
||||
version = versions[devId];
|
||||
else
|
||||
{
|
||||
DeviceInfo dev(devId);
|
||||
version = dev.majorVersion() * 10 + dev.minorVersion();
|
||||
if (devId < cache_size)
|
||||
versions[devId] = version;
|
||||
}
|
||||
|
||||
return TargetArchs::builtWith(feature_set) && (version >= feature_set);
|
||||
}
|
||||
|
||||
#if !defined (HAVE_CUDA)
|
||||
|
||||
#define throw_nogpu CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support")
|
||||
@@ -315,18 +392,6 @@ void cv::gpu::DeviceInfo::queryMemory(size_t& free_memory, size_t& total_memory)
|
||||
|
||||
namespace
|
||||
{
|
||||
template <class T> void getCudaAttribute(T *attribute, CUdevice_attribute device_attribute, int device)
|
||||
{
|
||||
*attribute = T();
|
||||
//CUresult error = CUDA_SUCCESS;// = cuDeviceGetAttribute( attribute, device_attribute, device ); why link erros under ubuntu??
|
||||
CUresult error = cuDeviceGetAttribute( attribute, device_attribute, device );
|
||||
if( CUDA_SUCCESS == error )
|
||||
return;
|
||||
|
||||
printf("Driver API error = %04d\n", error);
|
||||
cv::gpu::error("driver API error", __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
int convertSMVer2Cores(int major, int minor)
|
||||
{
|
||||
// Defines for GPU Architecture types (using the SM version to determine the # of cores per SM
|
||||
@@ -335,7 +400,7 @@ namespace
|
||||
int Cores;
|
||||
} SMtoCores;
|
||||
|
||||
SMtoCores gpuArchCoresPerSM[] = { { 0x10, 8 }, { 0x11, 8 }, { 0x12, 8 }, { 0x13, 8 }, { 0x20, 32 }, { 0x21, 48 }, {0x30, 192}, { -1, -1 } };
|
||||
SMtoCores gpuArchCoresPerSM[] = { { 0x10, 8 }, { 0x11, 8 }, { 0x12, 8 }, { 0x13, 8 }, { 0x20, 32 }, { 0x21, 48 }, {0x30, 192}, {0x35, 192}, { -1, -1 } };
|
||||
|
||||
int index = 0;
|
||||
while (gpuArchCoresPerSM[index].SM != -1)
|
||||
@@ -344,7 +409,7 @@ namespace
|
||||
return gpuArchCoresPerSM[index].Cores;
|
||||
index++;
|
||||
}
|
||||
printf("MapSMtoCores undefined SMversion %d.%d!\n", major, minor);
|
||||
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@@ -382,22 +447,13 @@ void cv::gpu::printCudaDeviceInfo(int device)
|
||||
printf(" CUDA Driver Version / Runtime Version %d.%d / %d.%d\n", driverVersion/1000, driverVersion%100, runtimeVersion/1000, runtimeVersion%100);
|
||||
printf(" CUDA Capability Major/Minor version number: %d.%d\n", prop.major, prop.minor);
|
||||
printf(" Total amount of global memory: %.0f MBytes (%llu bytes)\n", (float)prop.totalGlobalMem/1048576.0f, (unsigned long long) prop.totalGlobalMem);
|
||||
printf(" (%2d) Multiprocessors x (%2d) CUDA Cores/MP: %d CUDA Cores\n",
|
||||
prop.multiProcessorCount, convertSMVer2Cores(prop.major, prop.minor),
|
||||
convertSMVer2Cores(prop.major, prop.minor) * prop.multiProcessorCount);
|
||||
|
||||
int cores = convertSMVer2Cores(prop.major, prop.minor);
|
||||
if (cores > 0)
|
||||
printf(" (%2d) Multiprocessors x (%2d) CUDA Cores/MP: %d CUDA Cores\n", prop.multiProcessorCount, cores, cores * prop.multiProcessorCount);
|
||||
|
||||
printf(" GPU Clock Speed: %.2f GHz\n", prop.clockRate * 1e-6f);
|
||||
|
||||
// This is not available in the CUDA Runtime API, so we make the necessary calls the driver API to support this for output
|
||||
int memoryClock, memBusWidth, L2CacheSize;
|
||||
getCudaAttribute<int>( &memoryClock, CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE, dev );
|
||||
getCudaAttribute<int>( &memBusWidth, CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH, dev );
|
||||
getCudaAttribute<int>( &L2CacheSize, CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE, dev );
|
||||
|
||||
printf(" Memory Clock rate: %.2f Mhz\n", memoryClock * 1e-3f);
|
||||
printf(" Memory Bus Width: %d-bit\n", memBusWidth);
|
||||
if (L2CacheSize)
|
||||
printf(" L2 Cache Size: %d bytes\n", L2CacheSize);
|
||||
|
||||
printf(" Max Texture Dimension Size (x,y,z) 1D=(%d), 2D=(%d,%d), 3D=(%d,%d,%d)\n",
|
||||
prop.maxTexture1D, prop.maxTexture2D[0], prop.maxTexture2D[1],
|
||||
prop.maxTexture3D[0], prop.maxTexture3D[1], prop.maxTexture3D[2]);
|
||||
@@ -457,7 +513,12 @@ void cv::gpu::printShortCudaDeviceInfo(int device)
|
||||
|
||||
const char *arch_str = prop.major < 2 ? " (not Fermi)" : "";
|
||||
printf("Device %d: \"%s\" %.0fMb", dev, prop.name, (float)prop.totalGlobalMem/1048576.0f);
|
||||
printf(", sm_%d%d%s, %d cores", prop.major, prop.minor, arch_str, convertSMVer2Cores(prop.major, prop.minor) * prop.multiProcessorCount);
|
||||
printf(", sm_%d%d%s", prop.major, prop.minor, arch_str);
|
||||
|
||||
int cores = convertSMVer2Cores(prop.major, prop.minor);
|
||||
if (cores > 0)
|
||||
printf(", %d cores", cores * prop.multiProcessorCount);
|
||||
|
||||
printf(", Driver/Runtime ver.%d.%d/%d.%d\n", driverVersion/1000, driverVersion%100, runtimeVersion/1000, runtimeVersion%100);
|
||||
}
|
||||
fflush(stdout);
|
||||
|
||||
+20
-11
@@ -830,7 +830,8 @@ int Mat::checkVector(int _elemChannels, int _depth, bool _requireContinuous) con
|
||||
{
|
||||
return (depth() == _depth || _depth <= 0) &&
|
||||
(isContinuous() || !_requireContinuous) &&
|
||||
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) || (cols == _elemChannels))) ||
|
||||
((dims == 2 && (((rows == 1 || cols == 1) && channels() == _elemChannels) ||
|
||||
(cols == _elemChannels && channels() == 1))) ||
|
||||
(dims == 3 && channels() == 1 && size.p[2] == _elemChannels && (size.p[0] == 1 || size.p[1] == 1) &&
|
||||
(isContinuous() || step.p[1] == step.p[2]*size.p[2])))
|
||||
? (int)(total()*channels()/_elemChannels) : -1;
|
||||
@@ -1926,6 +1927,14 @@ void cv::transpose( InputArray _src, OutputArray _dst )
|
||||
_dst.create(src.cols, src.rows, src.type());
|
||||
Mat dst = _dst.getMat();
|
||||
|
||||
// handle the case of single-column/single-row matrices, stored in STL vectors.
|
||||
if( src.rows != dst.cols || src.cols != dst.rows )
|
||||
{
|
||||
CV_Assert( src.size() == dst.size() && (src.cols == 1 || src.rows == 1) );
|
||||
src.copyTo(dst);
|
||||
return;
|
||||
}
|
||||
|
||||
if( dst.data == src.data )
|
||||
{
|
||||
TransposeInplaceFunc func = transposeInplaceTab[esz];
|
||||
@@ -2450,7 +2459,7 @@ static void generateRandomCenter(const vector<Vec2f>& box, float* center, RNG& r
|
||||
center[j] = ((float)rng*(1.f+margin*2.f)-margin)*(box[j][1] - box[j][0]) + box[j][0];
|
||||
}
|
||||
|
||||
class KMeansPPDistanceComputer
|
||||
class KMeansPPDistanceComputer : public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
KMeansPPDistanceComputer( float *_tdist2,
|
||||
@@ -2466,10 +2475,10 @@ public:
|
||||
step(_step),
|
||||
stepci(_stepci) { }
|
||||
|
||||
void operator()( const cv::BlockedRange& range ) const
|
||||
void operator()( const cv::Range& range ) const
|
||||
{
|
||||
const int begin = range.begin();
|
||||
const int end = range.end();
|
||||
const int begin = range.start;
|
||||
const int end = range.end;
|
||||
|
||||
for ( int i = begin; i<end; i++ )
|
||||
{
|
||||
@@ -2525,7 +2534,7 @@ static void generateCentersPP(const Mat& _data, Mat& _out_centers,
|
||||
break;
|
||||
int ci = i;
|
||||
|
||||
parallel_for(BlockedRange(0, N),
|
||||
parallel_for_(Range(0, N),
|
||||
KMeansPPDistanceComputer(tdist2, data, dist, dims, step, step*ci));
|
||||
for( i = 0; i < N; i++ )
|
||||
{
|
||||
@@ -2553,7 +2562,7 @@ static void generateCentersPP(const Mat& _data, Mat& _out_centers,
|
||||
}
|
||||
}
|
||||
|
||||
class KMeansDistanceComputer
|
||||
class KMeansDistanceComputer : public ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
KMeansDistanceComputer( double *_distances,
|
||||
@@ -2567,10 +2576,10 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
void operator()( const BlockedRange& range ) const
|
||||
void operator()( const Range& range ) const
|
||||
{
|
||||
const int begin = range.begin();
|
||||
const int end = range.end();
|
||||
const int begin = range.start;
|
||||
const int end = range.end;
|
||||
const int K = centers.rows;
|
||||
const int dims = centers.cols;
|
||||
|
||||
@@ -2827,7 +2836,7 @@ double cv::kmeans( InputArray _data, int K,
|
||||
// assign labels
|
||||
Mat dists(1, N, CV_64F);
|
||||
double* dist = dists.ptr<double>(0);
|
||||
parallel_for(BlockedRange(0, N),
|
||||
parallel_for_(Range(0, N),
|
||||
KMeansDistanceComputer(dist, labels, data, centers));
|
||||
compactness = 0;
|
||||
for( i = 0; i < N; i++ )
|
||||
|
||||
@@ -614,11 +614,12 @@ cvGetHashedKey( CvFileStorage* fs, const char* str, int len, int create_missing
|
||||
CvStringHashNode* node = 0;
|
||||
unsigned hashval = 0;
|
||||
int i, tab_size;
|
||||
CvStringHash* map = fs->str_hash;
|
||||
|
||||
if( !fs )
|
||||
return 0;
|
||||
|
||||
CvStringHash* map = fs->str_hash;
|
||||
|
||||
if( len < 0 )
|
||||
{
|
||||
for( i = 0; str[i] != '\0'; i++ )
|
||||
|
||||
@@ -94,7 +94,7 @@ template<typename T1, typename T2=T1, typename T3=T1> struct OpAdd
|
||||
typedef T1 type1;
|
||||
typedef T2 type2;
|
||||
typedef T3 rtype;
|
||||
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(a + b); }
|
||||
T3 operator ()(const T1 a, const T2 b) const { return saturate_cast<T3>(a + b); }
|
||||
};
|
||||
|
||||
template<typename T1, typename T2=T1, typename T3=T1> struct OpSub
|
||||
@@ -102,7 +102,7 @@ template<typename T1, typename T2=T1, typename T3=T1> struct OpSub
|
||||
typedef T1 type1;
|
||||
typedef T2 type2;
|
||||
typedef T3 rtype;
|
||||
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(a - b); }
|
||||
T3 operator ()(const T1 a, const T2 b) const { return saturate_cast<T3>(a - b); }
|
||||
};
|
||||
|
||||
template<typename T1, typename T2=T1, typename T3=T1> struct OpRSub
|
||||
@@ -110,7 +110,7 @@ template<typename T1, typename T2=T1, typename T3=T1> struct OpRSub
|
||||
typedef T1 type1;
|
||||
typedef T2 type2;
|
||||
typedef T3 rtype;
|
||||
T3 operator ()(T1 a, T2 b) const { return saturate_cast<T3>(b - a); }
|
||||
T3 operator ()(const T1 a, const T2 b) const { return saturate_cast<T3>(b - a); }
|
||||
};
|
||||
|
||||
template<typename T> struct OpMin
|
||||
@@ -118,7 +118,7 @@ template<typename T> struct OpMin
|
||||
typedef T type1;
|
||||
typedef T type2;
|
||||
typedef T rtype;
|
||||
T operator ()(T a, T b) const { return std::min(a, b); }
|
||||
T operator ()(const T a, const T b) const { return std::min(a, b); }
|
||||
};
|
||||
|
||||
template<typename T> struct OpMax
|
||||
@@ -126,7 +126,7 @@ template<typename T> struct OpMax
|
||||
typedef T type1;
|
||||
typedef T type2;
|
||||
typedef T rtype;
|
||||
T operator ()(T a, T b) const { return std::max(a, b); }
|
||||
T operator ()(const T a, const T b) const { return std::max(a, b); }
|
||||
};
|
||||
|
||||
inline Size getContinuousSize( const Mat& m1, int widthScale=1 )
|
||||
|
||||
@@ -1726,7 +1726,7 @@ typedef void (*BatchDistFunc)(const uchar* src1, const uchar* src2, size_t step2
|
||||
int nvecs, int len, uchar* dist, const uchar* mask);
|
||||
|
||||
|
||||
struct BatchDistInvoker
|
||||
struct BatchDistInvoker : public ParallelLoopBody
|
||||
{
|
||||
BatchDistInvoker( const Mat& _src1, const Mat& _src2,
|
||||
Mat& _dist, Mat& _nidx, int _K,
|
||||
@@ -1743,12 +1743,12 @@ struct BatchDistInvoker
|
||||
func = _func;
|
||||
}
|
||||
|
||||
void operator()(const BlockedRange& range) const
|
||||
void operator()(const Range& range) const
|
||||
{
|
||||
AutoBuffer<int> buf(src2->rows);
|
||||
int* bufptr = buf;
|
||||
|
||||
for( int i = range.begin(); i < range.end(); i++ )
|
||||
for( int i = range.start; i < range.end; i++ )
|
||||
{
|
||||
func(src1->ptr(i), src2->ptr(), src2->step, src2->rows, src2->cols,
|
||||
K > 0 ? (uchar*)bufptr : dist->ptr(i), mask->data ? mask->ptr(i) : 0);
|
||||
@@ -1899,8 +1899,8 @@ void cv::batchDistance( InputArray _src1, InputArray _src2,
|
||||
("The combination of type=%d, dtype=%d and normType=%d is not supported",
|
||||
type, dtype, normType));
|
||||
|
||||
parallel_for(BlockedRange(0, src1.rows),
|
||||
BatchDistInvoker(src1, src2, dist, nidx, K, mask, update, func));
|
||||
parallel_for_(Range(0, src1.rows),
|
||||
BatchDistInvoker(src1, src2, dist, nidx, K, mask, update, func));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -439,7 +439,7 @@ void error( const Exception& exc )
|
||||
exc.func.c_str() : "unknown function", exc.file.c_str(), exc.line );
|
||||
fprintf( stderr, "%s\n", buf );
|
||||
fflush( stderr );
|
||||
# ifdef ANDROID
|
||||
# ifdef __ANDROID__
|
||||
__android_log_print(ANDROID_LOG_ERROR, "cv::error()", "%s", buf);
|
||||
# endif
|
||||
}
|
||||
|
||||
@@ -1530,4 +1530,24 @@ TEST(Multiply, FloatingPointRounding)
|
||||
cv::multiply(src, s, dst, 1, CV_16U);
|
||||
// with CV_32F this produce result 16202
|
||||
ASSERT_EQ(dst.at<ushort>(0,0), 16201);
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Core_Add, AddToColumnWhen3Rows)
|
||||
{
|
||||
cv::Mat m1 = (cv::Mat_<double>(3, 2) << 1, 2, 3, 4, 5, 6);
|
||||
m1.col(1) += 10;
|
||||
|
||||
cv::Mat m2 = (cv::Mat_<double>(3, 2) << 1, 12, 3, 14, 5, 16);
|
||||
|
||||
ASSERT_EQ(0, countNonZero(m1 - m2));
|
||||
}
|
||||
|
||||
TEST(Core_Add, AddToColumnWhen4Rows)
|
||||
{
|
||||
cv::Mat m1 = (cv::Mat_<double>(4, 2) << 1, 2, 3, 4, 5, 6, 7, 8);
|
||||
m1.col(1) += 10;
|
||||
|
||||
cv::Mat m2 = (cv::Mat_<double>(4, 2) << 1, 12, 3, 14, 5, 16, 7, 18);
|
||||
|
||||
ASSERT_EQ(0, countNonZero(m1 - m2));
|
||||
}
|
||||
|
||||
@@ -998,6 +998,23 @@ bool CV_OperationsTest::operations1()
|
||||
|
||||
add(Mat::zeros(6, 1, CV_64F), 1, c, noArray(), c.type());
|
||||
CV_Assert( norm(Matx61f(1.f, 1.f, 1.f, 1.f, 1.f, 1.f), c, CV_C) == 0 );
|
||||
|
||||
vector<Point2f> pt2d(3);
|
||||
vector<Point3d> pt3d(2);
|
||||
|
||||
CV_Assert( Mat(pt2d).checkVector(2) == 3 && Mat(pt2d).checkVector(3) < 0 &&
|
||||
Mat(pt3d).checkVector(2) < 0 && Mat(pt3d).checkVector(3) == 2 );
|
||||
|
||||
Matx44f m44(0.8147f, 0.6324f, 0.9575f, 0.9572f,
|
||||
0.9058f, 0.0975f, 0.9649f, 0.4854f,
|
||||
0.1270f, 0.2785f, 0.1576f, 0.8003f,
|
||||
0.9134f, 0.5469f, 0.9706f, 0.1419f);
|
||||
double d = determinant(m44);
|
||||
CV_Assert( fabs(d - (-0.0262)) <= 0.001 );
|
||||
|
||||
Cv32suf z;
|
||||
z.i = 0x80000000;
|
||||
CV_Assert( cvFloor(z.f) == 0 && cvCeil(z.f) == 0 && cvRound(z.f) == 0 );
|
||||
}
|
||||
catch(const test_excep&)
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ Abstract base class for computing descriptors for image keypoints. ::
|
||||
|
||||
|
||||
In this interface, a keypoint descriptor can be represented as a
|
||||
dense, fixed-dimension vector of a basic type. Most descriptors
|
||||
dense, fixed-dimension vector of a basic type. Most descriptors
|
||||
follow this pattern as it simplifies computing
|
||||
distances between descriptors. Therefore, a collection of
|
||||
descriptors is represented as
|
||||
@@ -79,6 +79,7 @@ The current implementation supports the following types of a descriptor extracto
|
||||
* ``"SIFT"`` -- :ocv:class:`SIFT`
|
||||
* ``"SURF"`` -- :ocv:class:`SURF`
|
||||
* ``"ORB"`` -- :ocv:class:`ORB`
|
||||
* ``"BRISK"`` -- :ocv:class:`BRISK`
|
||||
* ``"BRIEF"`` -- :ocv:class:`BriefDescriptorExtractor`
|
||||
|
||||
A combined format is also supported: descriptor extractor adapter name ( ``"Opponent"`` --
|
||||
|
||||
@@ -267,9 +267,9 @@ BFMatcher::BFMatcher
|
||||
--------------------
|
||||
Brute-force matcher constructor.
|
||||
|
||||
.. ocv:function:: BFMatcher::BFMatcher( int normType, bool crossCheck=false )
|
||||
.. ocv:function:: BFMatcher::BFMatcher( int normType=NORM_L2, bool crossCheck=false )
|
||||
|
||||
:param normType: One of ``NORM_L1``, ``NORM_L2``, ``NORM_HAMMING``, ``NORM_HAMMING2``. ``L1`` and ``L2`` norms are preferable choices for SIFT and SURF descriptors, ``NORM_HAMMING`` should be used with ORB and BRIEF, ``NORM_HAMMING2`` should be used with ORB when ``WTA_K==3`` or ``4`` (see ORB::ORB constructor description).
|
||||
:param normType: One of ``NORM_L1``, ``NORM_L2``, ``NORM_HAMMING``, ``NORM_HAMMING2``. ``L1`` and ``L2`` norms are preferable choices for SIFT and SURF descriptors, ``NORM_HAMMING`` should be used with ORB, BRISK and BRIEF, ``NORM_HAMMING2`` should be used with ORB when ``WTA_K==3`` or ``4`` (see ORB::ORB constructor description).
|
||||
|
||||
:param crossCheck: If it is false, this is will be default BFMatcher behaviour when it finds the k nearest neighbors for each query descriptor. If ``crossCheck==true``, then the ``knnMatch()`` method with ``k=1`` will only return pairs ``(i,j)`` such that for ``i-th`` query descriptor the ``j-th`` descriptor in the matcher's collection is the nearest and vice versa, i.e. the ``BFMathcher`` will only return consistent pairs. Such technique usually produces best results with minimal number of outliers when there are enough matches. This is alternative to the ratio test, used by D. Lowe in SIFT paper.
|
||||
|
||||
|
||||
@@ -113,7 +113,7 @@ Detects keypoints in an image (first variant) or image set (second variant).
|
||||
:param masks: Masks for each input image specifying where to look for keypoints (optional). ``masks[i]`` is a mask for ``images[i]``.
|
||||
|
||||
FeatureDetector::create
|
||||
---------------------------
|
||||
-----------------------
|
||||
Creates a feature detector by its name.
|
||||
|
||||
.. ocv:function:: Ptr<FeatureDetector> FeatureDetector::create( const string& detectorType )
|
||||
@@ -127,6 +127,7 @@ The following detector types are supported:
|
||||
* ``"SIFT"`` -- :ocv:class:`SIFT` (nonfree module)
|
||||
* ``"SURF"`` -- :ocv:class:`SURF` (nonfree module)
|
||||
* ``"ORB"`` -- :ocv:class:`ORB`
|
||||
* ``"BRISK"`` -- :ocv:class:`BRISK`
|
||||
* ``"MSER"`` -- :ocv:class:`MSER`
|
||||
* ``"GFTT"`` -- :ocv:class:`GoodFeaturesToTrackDetector`
|
||||
* ``"HARRIS"`` -- :ocv:class:`GoodFeaturesToTrackDetector` with Harris detector enabled
|
||||
@@ -219,8 +220,7 @@ StarFeatureDetector
|
||||
-------------------
|
||||
.. ocv:class:: StarFeatureDetector : public FeatureDetector
|
||||
|
||||
Wrapping class for feature detection using the
|
||||
:ocv:class:`StarDetector` class. ::
|
||||
The class implements the keypoint detector introduced by K. Konolige, synonym of ``StarDetector``. ::
|
||||
|
||||
class StarFeatureDetector : public FeatureDetector
|
||||
{
|
||||
@@ -412,7 +412,7 @@ Example of creating ``DynamicAdaptedFeatureDetector`` : ::
|
||||
|
||||
|
||||
DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector
|
||||
----------------------------------------------------------------
|
||||
------------------------------------------------------------
|
||||
The constructor
|
||||
|
||||
.. ocv:function:: DynamicAdaptedFeatureDetector::DynamicAdaptedFeatureDetector( const Ptr<AdjusterAdapter>& adjuster, int min_features=400, int max_features=500, int max_iters=5 )
|
||||
@@ -484,7 +484,7 @@ Example: ::
|
||||
|
||||
|
||||
AdjusterAdapter::good
|
||||
-------------------------
|
||||
---------------------
|
||||
Returns false if the detector parameters cannot be adjusted any more.
|
||||
|
||||
.. ocv:function:: bool AdjusterAdapter::good() const
|
||||
@@ -497,7 +497,7 @@ Example: ::
|
||||
}
|
||||
|
||||
AdjusterAdapter::create
|
||||
-------------------------
|
||||
-----------------------
|
||||
Creates an adjuster adapter by name
|
||||
|
||||
.. ocv:function:: Ptr<AdjusterAdapter> AdjusterAdapter::create( const string& detectorType )
|
||||
@@ -528,3 +528,23 @@ StarAdjuster
|
||||
StarAdjuster(double initial_thresh = 30.0);
|
||||
...
|
||||
};
|
||||
|
||||
SurfAdjuster
|
||||
------------
|
||||
.. ocv:class:: SurfAdjuster: public AdjusterAdapter
|
||||
|
||||
:ocv:class:`AdjusterAdapter` for ``SurfFeatureDetector``. ::
|
||||
|
||||
class CV_EXPORTS SurfAdjuster: public AdjusterAdapter
|
||||
{
|
||||
public:
|
||||
SurfAdjuster( double initial_thresh=400.f, double min_thresh=2, double max_thresh=1000 );
|
||||
|
||||
virtual void tooFew(int minv, int n_detected);
|
||||
virtual void tooMany(int maxv, int n_detected);
|
||||
virtual bool good() const;
|
||||
|
||||
virtual Ptr<AdjusterAdapter> clone() const;
|
||||
|
||||
...
|
||||
};
|
||||
|
||||
@@ -98,6 +98,58 @@ Finds keypoints in an image and computes their descriptors
|
||||
|
||||
:param useProvidedKeypoints: If it is true, then the method will use the provided vector of keypoints instead of detecting them.
|
||||
|
||||
BRISK
|
||||
-----
|
||||
.. ocv:class:: BRISK : public Feature2D
|
||||
|
||||
Class implementing the BRISK keypoint detector and descriptor extractor, described in [LCS11]_.
|
||||
|
||||
.. [LCS11] Stefan Leutenegger, Margarita Chli and Roland Siegwart: BRISK: Binary Robust Invariant Scalable Keypoints. ICCV 2011: 2548-2555.
|
||||
|
||||
BRISK::BRISK
|
||||
------------
|
||||
The BRISK constructor
|
||||
|
||||
.. ocv:function:: BRISK::BRISK(int thresh=30, int octaves=3, float patternScale=1.0f)
|
||||
|
||||
:param thresh: FAST/AGAST detection threshold score.
|
||||
|
||||
:param octaves: detection octaves. Use 0 to do single scale.
|
||||
|
||||
:param patternScale: apply this scale to the pattern used for sampling the neighbourhood of a keypoint.
|
||||
|
||||
BRISK::BRISK
|
||||
------------
|
||||
The BRISK constructor for a custom pattern
|
||||
|
||||
.. ocv:function:: BRISK::BRISK(std::vector<float> &radiusList, std::vector<int> &numberList, float dMax=5.85f, float dMin=8.2f, std::vector<int> indexChange=std::vector<int>())
|
||||
|
||||
:param radiusList: defines the radii (in pixels) where the samples around a keypoint are taken (for keypoint scale 1).
|
||||
|
||||
:param numberList: defines the number of sampling points on the sampling circle. Must be the same size as radiusList..
|
||||
|
||||
:param dMax: threshold for the short pairings used for descriptor formation (in pixels for keypoint scale 1).
|
||||
|
||||
:param dMin: threshold for the long pairings used for orientation determination (in pixels for keypoint scale 1).
|
||||
|
||||
:param indexChanges: index remapping of the bits.
|
||||
|
||||
BRISK::operator()
|
||||
-----------------
|
||||
Finds keypoints in an image and computes their descriptors
|
||||
|
||||
.. ocv:function:: void BRISK::operator()(InputArray image, InputArray mask, vector<KeyPoint>& keypoints, OutputArray descriptors, bool useProvidedKeypoints=false ) const
|
||||
|
||||
:param image: The input 8-bit grayscale image.
|
||||
|
||||
:param mask: The operation mask.
|
||||
|
||||
:param keypoints: The output vector of keypoints.
|
||||
|
||||
:param descriptors: The output descriptors. Pass ``cv::noArray()`` if you do not need it.
|
||||
|
||||
:param useProvidedKeypoints: If it is true, then the method will use the provided vector of keypoints instead of detecting them.
|
||||
|
||||
FREAK
|
||||
-----
|
||||
.. ocv:class:: FREAK : public DescriptorExtractor
|
||||
|
||||
@@ -1198,13 +1198,14 @@ protected:
|
||||
class CV_EXPORTS_W BFMatcher : public DescriptorMatcher
|
||||
{
|
||||
public:
|
||||
CV_WRAP BFMatcher( int normType, bool crossCheck=false );
|
||||
CV_WRAP BFMatcher( int normType=NORM_L2, bool crossCheck=false );
|
||||
virtual ~BFMatcher() {}
|
||||
|
||||
virtual bool isMaskSupported() const { return true; }
|
||||
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
||||
|
||||
AlgorithmInfo* info() const;
|
||||
protected:
|
||||
virtual void knnMatchImpl( const Mat& queryDescriptors, vector<vector<DMatch> >& matches, int k,
|
||||
const vector<Mat>& masks=vector<Mat>(), bool compactResult=false );
|
||||
@@ -1238,6 +1239,7 @@ public:
|
||||
|
||||
virtual Ptr<DescriptorMatcher> clone( bool emptyTrainData=false ) const;
|
||||
|
||||
AlgorithmInfo* info() const;
|
||||
protected:
|
||||
static void convertToDMatches( const DescriptorCollection& descriptors,
|
||||
const Mat& indices, const Mat& distances,
|
||||
|
||||
@@ -309,10 +309,9 @@ BRISK::generateKernel(std::vector<float> &radiusList, std::vector<int> &numberLi
|
||||
{
|
||||
indexChange.resize(points_ * (points_ - 1) / 2);
|
||||
indSize = (unsigned int)indexChange.size();
|
||||
}
|
||||
for (unsigned int i = 0; i < indSize; i++)
|
||||
{
|
||||
indexChange[i] = i;
|
||||
|
||||
for (unsigned int i = 0; i < indSize; i++)
|
||||
indexChange[i] = i;
|
||||
}
|
||||
const float dMin_sq = dMin_ * dMin_;
|
||||
const float dMax_sq = dMax_ * dMax_;
|
||||
|
||||
@@ -200,10 +200,13 @@ void drawMatches( const Mat& img1, const vector<KeyPoint>& keypoints1,
|
||||
// draw matches
|
||||
for( size_t m = 0; m < matches1to2.size(); m++ )
|
||||
{
|
||||
int i1 = matches1to2[m].queryIdx;
|
||||
int i2 = matches1to2[m].trainIdx;
|
||||
if( matchesMask.empty() || matchesMask[m] )
|
||||
{
|
||||
int i1 = matches1to2[m].queryIdx;
|
||||
int i2 = matches1to2[m].trainIdx;
|
||||
CV_Assert(i1 >= 0 && i1 < static_cast<int>(keypoints1.size()));
|
||||
CV_Assert(i2 >= 0 && i2 < static_cast<int>(keypoints2.size()));
|
||||
|
||||
const KeyPoint &kp1 = keypoints1[i1], &kp2 = keypoints2[i2];
|
||||
_drawMatch( outImg, outImg1, outImg2, kp1, kp2, matchColor, flags );
|
||||
}
|
||||
|
||||
@@ -241,7 +241,6 @@ static void filterEllipticKeyPointsByImageSize( vector<EllipticKeyPoint>& keypoi
|
||||
|
||||
struct IntersectAreaCounter
|
||||
{
|
||||
IntersectAreaCounter() : bua(0), bna(0) {}
|
||||
IntersectAreaCounter( float _dr, int _minx,
|
||||
int _miny, int _maxy,
|
||||
const Point2f& _diff,
|
||||
@@ -257,6 +256,9 @@ struct IntersectAreaCounter
|
||||
|
||||
void operator()( const BlockedRange& range )
|
||||
{
|
||||
CV_Assert( miny < maxy );
|
||||
CV_Assert( dr > FLT_EPSILON );
|
||||
|
||||
int temp_bua = bua, temp_bna = bna;
|
||||
for( int i = range.begin(); i != range.end(); i++ )
|
||||
{
|
||||
@@ -461,7 +463,7 @@ void cv::evaluateFeatureDetector( const Mat& img1, const Mat& img2, const Mat& H
|
||||
keypoints2 = _keypoints2 != 0 ? _keypoints2 : &buf2;
|
||||
|
||||
if( (keypoints1->empty() || keypoints2->empty()) && fdetector.empty() )
|
||||
CV_Error( CV_StsBadArg, "fdetector must be no empty when keypoints1 or keypoints2 is empty" );
|
||||
CV_Error( CV_StsBadArg, "fdetector must not be empty when keypoints1 or keypoints2 is empty" );
|
||||
|
||||
if( keypoints1->empty() )
|
||||
fdetector->detect( img1, *keypoints1 );
|
||||
@@ -572,10 +574,10 @@ void cv::evaluateGenericDescriptorMatcher( const Mat& img1, const Mat& img2, con
|
||||
correctMatches1to2Mask = _correctMatches1to2Mask != 0 ? _correctMatches1to2Mask : &buf2;
|
||||
|
||||
if( keypoints1.empty() )
|
||||
CV_Error( CV_StsBadArg, "keypoints1 must be no empty" );
|
||||
CV_Error( CV_StsBadArg, "keypoints1 must not be empty" );
|
||||
|
||||
if( matches1to2->empty() && dmatcher.empty() )
|
||||
CV_Error( CV_StsBadArg, "dmatch must be no empty when matches1to2 is empty" );
|
||||
CV_Error( CV_StsBadArg, "dmatch must not be empty when matches1to2 is empty" );
|
||||
|
||||
bool computeKeypoints2ByPrj = keypoints2.empty();
|
||||
if( computeKeypoints2ByPrj )
|
||||
|
||||
@@ -166,6 +166,16 @@ CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid",
|
||||
obj.info()->addParam(obj, "gridRows", obj.gridRows);
|
||||
obj.info()->addParam(obj, "gridCols", obj.gridCols));
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CV_INIT_ALGORITHM(BFMatcher, "DescriptorMatcher.BFMatcher",
|
||||
obj.info()->addParam(obj, "normType", obj.normType);
|
||||
obj.info()->addParam(obj, "crossCheck", obj.crossCheck));
|
||||
|
||||
CV_INIT_ALGORITHM(FlannBasedMatcher, "DescriptorMatcher.FlannBasedMatcher",);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
bool cv::initModule_features2d(void)
|
||||
{
|
||||
bool all = true;
|
||||
@@ -181,6 +191,8 @@ bool cv::initModule_features2d(void)
|
||||
all &= !HarrisDetector_info_auto.name().empty();
|
||||
all &= !DenseFeatureDetector_info_auto.name().empty();
|
||||
all &= !GridAdaptedFeatureDetector_info_auto.name().empty();
|
||||
all &= !BFMatcher_info_auto.name().empty();
|
||||
all &= !FlannBasedMatcher_info_auto.name().empty();
|
||||
|
||||
return all;
|
||||
}
|
||||
|
||||
@@ -532,12 +532,12 @@ void CV_DescriptorMatcherTest::run( int )
|
||||
|
||||
TEST( Features2d_DescriptorMatcher_BruteForce, regression )
|
||||
{
|
||||
CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", new BFMatcher(NORM_L2), 0.01f );
|
||||
CV_DescriptorMatcherTest test( "descriptor-matcher-brute-force", Algorithm::create<DescriptorMatcher>("DescriptorMatcher.BFMatcher"), 0.01f );
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
TEST( Features2d_DescriptorMatcher_FlannBased, regression )
|
||||
{
|
||||
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", new FlannBasedMatcher, 0.04f );
|
||||
CV_DescriptorMatcherTest test( "descriptor-matcher-flann-based", Algorithm::create<DescriptorMatcher>("DescriptorMatcher.FlannBasedMatcher"), 0.04f );
|
||||
test.safe_run();
|
||||
}
|
||||
|
||||
@@ -10,11 +10,11 @@ Clusters features using hierarchical k-means algorithm.
|
||||
.. ocv:function:: template<typename Distance> int flann::hierarchicalClustering(const Mat& features, Mat& centers, const cvflann::KMeansIndexParams& params, Distance d = Distance())
|
||||
|
||||
:param features: The points to be clustered. The matrix must have elements of type ``Distance::ElementType``.
|
||||
|
||||
:param centers: The centers of the clusters obtained. The matrix must have type ``Distance::ResultType``. The number of rows in this matrix represents the number of clusters desired, however, because of the way the cut in the hierarchical tree is chosen, the number of clusters computed will be the highest number of the form ``(branching-1)*k+1`` that's lower than the number of clusters desired, where ``branching`` is the tree's branching factor (see description of the KMeansIndexParams).
|
||||
|
||||
|
||||
:param centers: The centers of the clusters obtained. The matrix must have type ``Distance::ResultType``. The number of rows in this matrix represents the number of clusters desired, however, because of the way the cut in the hierarchical tree is chosen, the number of clusters computed will be the highest number of the form ``(branching-1)*k+1`` that's lower than the number of clusters desired, where ``branching`` is the tree's branching factor (see description of the KMeansIndexParams).
|
||||
|
||||
:param params: Parameters used in the construction of the hierarchical k-means tree.
|
||||
|
||||
:param d: Distance to be used for clustering.
|
||||
|
||||
|
||||
The method clusters the given feature vectors by constructing a hierarchical k-means tree and choosing a cut in the tree that minimizes the cluster's variance. It returns the number of clusters found.
|
||||
|
||||
@@ -6,6 +6,7 @@ Fast Approximate Nearest Neighbor Search
|
||||
|
||||
This section documents OpenCV's interface to the FLANN library. FLANN (Fast Library for Approximate Nearest Neighbors) is a library that contains a collection of algorithms optimized for fast nearest neighbor search in large datasets and for high dimensional features. More information about FLANN can be found in [Muja2009]_ .
|
||||
|
||||
.. [Muja2009] Marius Muja, David G. Lowe. Fast Approximate Nearest Neighbors with Automatic Algorithm Configuration, 2009
|
||||
|
||||
flann::Index\_
|
||||
-----------------
|
||||
@@ -20,40 +21,40 @@ flann::Index_<T>::Index\_
|
||||
Constructs a nearest neighbor search index for a given dataset.
|
||||
|
||||
.. ocv:function:: flann::Index_<T>::Index_(const Mat& features, const IndexParams& params)
|
||||
|
||||
:param features: Matrix of containing the features(points) to index. The size of the matrix is ``num_features x feature_dimensionality`` and the data type of the elements in the matrix must coincide with the type of the index.
|
||||
|
||||
|
||||
:param features: Matrix of containing the features(points) to index. The size of the matrix is ``num_features x feature_dimensionality`` and the data type of the elements in the matrix must coincide with the type of the index.
|
||||
|
||||
:param params: Structure containing the index parameters. The type of index that will be constructed depends on the type of this parameter. See the description.
|
||||
|
||||
|
||||
The method constructs a fast search structure from a set of features using the specified algorithm with specified parameters, as defined by ``params``. ``params`` is a reference to one of the following class ``IndexParams`` descendants:
|
||||
|
||||
|
||||
*
|
||||
|
||||
|
||||
**LinearIndexParams** When passing an object of this type, the index will perform a linear, brute-force search. ::
|
||||
|
||||
|
||||
struct LinearIndexParams : public IndexParams
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
*
|
||||
|
||||
|
||||
**KDTreeIndexParams** When passing an object of this type the index constructed will consist of a set of randomized kd-trees which will be searched in parallel. ::
|
||||
|
||||
|
||||
struct KDTreeIndexParams : public IndexParams
|
||||
{
|
||||
KDTreeIndexParams( int trees = 4 );
|
||||
};
|
||||
|
||||
..
|
||||
|
||||
* **trees** The number of parallel kd-trees to use. Good values are in the range [1..16]
|
||||
|
||||
* **trees** The number of parallel kd-trees to use. Good values are in the range [1..16]
|
||||
|
||||
*
|
||||
|
||||
|
||||
**KMeansIndexParams** When passing an object of this type the index constructed will be a hierarchical k-means tree. ::
|
||||
|
||||
|
||||
struct KMeansIndexParams : public IndexParams
|
||||
{
|
||||
KMeansIndexParams(
|
||||
@@ -62,20 +63,20 @@ The method constructs a fast search structure from a set of features using the s
|
||||
flann_centers_init_t centers_init = CENTERS_RANDOM,
|
||||
float cb_index = 0.2 );
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
* **branching** The branching factor to use for the hierarchical k-means tree
|
||||
|
||||
|
||||
* **branching** The branching factor to use for the hierarchical k-means tree
|
||||
|
||||
* **iterations** The maximum number of iterations to use in the k-means clustering stage when building the k-means tree. A value of -1 used here means that the k-means clustering should be iterated until convergence
|
||||
|
||||
|
||||
* **centers_init** The algorithm to use for selecting the initial centers when performing a k-means clustering step. The possible values are ``CENTERS_RANDOM`` (picks the initial cluster centers randomly), ``CENTERS_GONZALES`` (picks the initial centers using Gonzales' algorithm) and ``CENTERS_KMEANSPP`` (picks the initial centers using the algorithm suggested in arthur_kmeanspp_2007 )
|
||||
|
||||
|
||||
* **cb_index** This parameter (cluster boundary index) influences the way exploration is performed in the hierarchical kmeans tree. When ``cb_index`` is zero the next kmeans domain to be explored is chosen to be the one with the closest center. A value greater then zero also takes into account the size of the domain.
|
||||
|
||||
*
|
||||
**CompositeIndexParams** When using a parameters object of this type the index created combines the randomized kd-trees and the hierarchical k-means tree. ::
|
||||
|
||||
|
||||
struct CompositeIndexParams : public IndexParams
|
||||
{
|
||||
CompositeIndexParams(
|
||||
@@ -88,7 +89,7 @@ The method constructs a fast search structure from a set of features using the s
|
||||
|
||||
*
|
||||
**LshIndexParams** When using a parameters object of this type the index created uses multi-probe LSH (by ``Multi-Probe LSH: Efficient Indexing for High-Dimensional Similarity Search`` by Qin Lv, William Josephson, Zhe Wang, Moses Charikar, Kai Li., Proceedings of the 33rd International Conference on Very Large Data Bases (VLDB). Vienna, Austria. September 2007) ::
|
||||
|
||||
|
||||
struct LshIndexParams : public IndexParams
|
||||
{
|
||||
LshIndexParams(
|
||||
@@ -96,9 +97,9 @@ The method constructs a fast search structure from a set of features using the s
|
||||
unsigned int key_size,
|
||||
unsigned int multi_probe_level );
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
* **table_number** the number of hash tables to use (between 10 and 30 usually).
|
||||
|
||||
|
||||
@@ -109,7 +110,7 @@ The method constructs a fast search structure from a set of features using the s
|
||||
|
||||
*
|
||||
**AutotunedIndexParams** When passing an object of this type the index created is automatically tuned to offer the best performance, by choosing the optimal index type (randomized kd-trees, hierarchical kmeans, linear) and parameters for the dataset provided. ::
|
||||
|
||||
|
||||
struct AutotunedIndexParams : public IndexParams
|
||||
{
|
||||
AutotunedIndexParams(
|
||||
@@ -118,80 +119,80 @@ The method constructs a fast search structure from a set of features using the s
|
||||
float memory_weight = 0,
|
||||
float sample_fraction = 0.1 );
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
|
||||
* **target_precision** Is a number between 0 and 1 specifying the percentage of the approximate nearest-neighbor searches that return the exact nearest-neighbor. Using a higher value for this parameter gives more accurate results, but the search takes longer. The optimum value usually depends on the application.
|
||||
|
||||
|
||||
|
||||
|
||||
* **build_weight** Specifies the importance of the index build time raported to the nearest-neighbor search time. In some applications it's acceptable for the index build step to take a long time if the subsequent searches in the index can be performed very fast. In other applications it's required that the index be build as fast as possible even if that leads to slightly longer search times.
|
||||
|
||||
|
||||
* **memory_weight** Is used to specify the tradeoff between time (index build time and search time) and memory used by the index. A value less than 1 gives more importance to the time spent and a value greater than 1 gives more importance to the memory usage.
|
||||
|
||||
|
||||
|
||||
|
||||
* **memory_weight** Is used to specify the tradeoff between time (index build time and search time) and memory used by the index. A value less than 1 gives more importance to the time spent and a value greater than 1 gives more importance to the memory usage.
|
||||
|
||||
|
||||
* **sample_fraction** Is a number between 0 and 1 indicating what fraction of the dataset to use in the automatic parameter configuration algorithm. Running the algorithm on the full dataset gives the most accurate results, but for very large datasets can take longer than desired. In such case using just a fraction of the data helps speeding up this algorithm while still giving good approximations of the optimum parameters.
|
||||
|
||||
*
|
||||
**SavedIndexParams** This object type is used for loading a previously saved index from the disk. ::
|
||||
|
||||
|
||||
struct SavedIndexParams : public IndexParams
|
||||
{
|
||||
SavedIndexParams( std::string filename );
|
||||
};
|
||||
|
||||
|
||||
|
||||
..
|
||||
|
||||
* **filename** The filename in which the index was saved.
|
||||
|
||||
|
||||
* **filename** The filename in which the index was saved.
|
||||
|
||||
|
||||
flann::Index_<T>::knnSearch
|
||||
----------------------------
|
||||
Performs a K-nearest neighbor search for a given query point using the index.
|
||||
|
||||
.. ocv:function:: void flann::Index_<T>::knnSearch(const vector<T>& query, vector<int>& indices, vector<float>& dists, int knn, const SearchParams& params)
|
||||
.. ocv:function:: void flann::Index_<T>::knnSearch(const vector<T>& query, vector<int>& indices, vector<float>& dists, int knn, const SearchParams& params)
|
||||
|
||||
.. ocv:function:: void flann::Index_<T>::knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const SearchParams& params)
|
||||
|
||||
:param query: The query point
|
||||
|
||||
:param indices: Vector that will contain the indices of the K-nearest neighbors found. It must have at least knn size.
|
||||
|
||||
:param dists: Vector that will contain the distances to the K-nearest neighbors found. It must have at least knn size.
|
||||
|
||||
:param knn: Number of nearest neighbors to search for.
|
||||
|
||||
:param query: The query point
|
||||
|
||||
:param indices: Vector that will contain the indices of the K-nearest neighbors found. It must have at least knn size.
|
||||
|
||||
:param dists: Vector that will contain the distances to the K-nearest neighbors found. It must have at least knn size.
|
||||
|
||||
:param knn: Number of nearest neighbors to search for.
|
||||
|
||||
:param params:
|
||||
|
||||
|
||||
Search parameters ::
|
||||
|
||||
|
||||
struct SearchParams {
|
||||
SearchParams(int checks = 32);
|
||||
};
|
||||
|
||||
|
||||
..
|
||||
|
||||
* **checks** The number of times the tree(s) in the index should be recursively traversed. A higher value for this parameter would give better search precision, but also take more time. If automatic configuration was used when the index was created, the number of checks required to achieve the specified precision was also computed, in which case this parameter is ignored.
|
||||
|
||||
* **checks** The number of times the tree(s) in the index should be recursively traversed. A higher value for this parameter would give better search precision, but also take more time. If automatic configuration was used when the index was created, the number of checks required to achieve the specified precision was also computed, in which case this parameter is ignored.
|
||||
|
||||
|
||||
flann::Index_<T>::radiusSearch
|
||||
--------------------------------------
|
||||
Performs a radius nearest neighbor search for a given query point.
|
||||
|
||||
.. ocv:function:: int flann::Index_<T>::radiusSearch(const vector<T>& query, vector<int>& indices, vector<float>& dists, float radius, const SearchParams& params)
|
||||
.. ocv:function:: int flann::Index_<T>::radiusSearch(const vector<T>& query, vector<int>& indices, vector<float>& dists, float radius, const SearchParams& params)
|
||||
|
||||
.. ocv:function:: int flann::Index_<T>::radiusSearch(const Mat& query, Mat& indices, Mat& dists, float radius, const SearchParams& params)
|
||||
.. ocv:function:: int flann::Index_<T>::radiusSearch(const Mat& query, Mat& indices, Mat& dists, float radius, const SearchParams& params)
|
||||
|
||||
:param query: The query point
|
||||
|
||||
:param indices: Vector that will contain the indices of the points found within the search radius in decreasing order of the distance to the query point. If the number of neighbors in the search radius is bigger than the size of this vector, the ones that don't fit in the vector are ignored.
|
||||
|
||||
:param dists: Vector that will contain the distances to the points found within the search radius
|
||||
|
||||
:param radius: The search radius
|
||||
|
||||
:param params: Search parameters
|
||||
:param query: The query point
|
||||
|
||||
:param indices: Vector that will contain the indices of the points found within the search radius in decreasing order of the distance to the query point. If the number of neighbors in the search radius is bigger than the size of this vector, the ones that don't fit in the vector are ignored.
|
||||
|
||||
:param dists: Vector that will contain the distances to the points found within the search radius
|
||||
|
||||
:param radius: The search radius
|
||||
|
||||
:param params: Search parameters
|
||||
|
||||
|
||||
flann::Index_<T>::save
|
||||
@@ -199,8 +200,8 @@ flann::Index_<T>::save
|
||||
Saves the index to a file.
|
||||
|
||||
.. ocv:function:: void flann::Index_<T>::save(std::string filename)
|
||||
|
||||
:param filename: The file to save the index to
|
||||
|
||||
:param filename: The file to save the index to
|
||||
|
||||
|
||||
flann::Index_<T>::getIndexParameters
|
||||
|
||||
@@ -261,6 +261,16 @@ private:
|
||||
*/
|
||||
void initialize(size_t key_size)
|
||||
{
|
||||
const size_t key_size_lower_bound = 1;
|
||||
//a value (size_t(1) << key_size) must fit the size_t type so key_size has to be strictly less than size of size_t
|
||||
const size_t key_size_upper_bound = std::min(sizeof(BucketKey) * CHAR_BIT + 1, sizeof(size_t) * CHAR_BIT);
|
||||
if (key_size < key_size_lower_bound || key_size >= key_size_upper_bound)
|
||||
{
|
||||
std::stringstream errorMessage;
|
||||
errorMessage << "Invalid key_size (=" << key_size << "). Valid values for your system are " << key_size_lower_bound << " <= key_size < " << key_size_upper_bound << ".";
|
||||
CV_Error(CV_StsBadArg, errorMessage.str());
|
||||
}
|
||||
|
||||
speed_level_ = kHash;
|
||||
key_size_ = (unsigned)key_size;
|
||||
}
|
||||
@@ -273,10 +283,10 @@ private:
|
||||
if (speed_level_ == kArray) return;
|
||||
|
||||
// Use an array if it will be more than half full
|
||||
if (buckets_space_.size() > (unsigned int)((1 << key_size_) / 2)) {
|
||||
if (buckets_space_.size() > ((size_t(1) << key_size_) / 2)) {
|
||||
speed_level_ = kArray;
|
||||
// Fill the array version of it
|
||||
buckets_speed_.resize(1 << key_size_);
|
||||
buckets_speed_.resize(size_t(1) << key_size_);
|
||||
for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) buckets_speed_[key_bucket->first] = key_bucket->second;
|
||||
|
||||
// Empty the hash table
|
||||
@@ -287,9 +297,9 @@ private:
|
||||
// If the bitset is going to use less than 10% of the RAM of the hash map (at least 1 size_t for the key and two
|
||||
// for the vector) or less than 512MB (key_size_ <= 30)
|
||||
if (((std::max(buckets_space_.size(), buckets_speed_.size()) * CHAR_BIT * 3 * sizeof(BucketKey)) / 10
|
||||
>= size_t(1 << key_size_)) || (key_size_ <= 32)) {
|
||||
>= (size_t(1) << key_size_)) || (key_size_ <= 32)) {
|
||||
speed_level_ = kBitsetHash;
|
||||
key_bitset_.resize(1 << key_size_);
|
||||
key_bitset_.resize(size_t(1) << key_size_);
|
||||
key_bitset_.reset();
|
||||
// Try with the BucketsSpace
|
||||
for (BucketsSpace::const_iterator key_bucket = buckets_space_.begin(); key_bucket != buckets_space_.end(); ++key_bucket) key_bitset_.set(key_bucket->first);
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
/*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.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, 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 Intel Corporation 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 "test_precomp.hpp"
|
||||
|
||||
using namespace cv;
|
||||
|
||||
class CV_LshTableBadArgTest : public cvtest::BadArgTest
|
||||
{
|
||||
protected:
|
||||
void run(int);
|
||||
void run_func(void) {};
|
||||
|
||||
struct Caller
|
||||
{
|
||||
int table_number, key_size, multi_probe_level;
|
||||
Mat features;
|
||||
|
||||
void operator()() const
|
||||
{
|
||||
flann::LshIndexParams indexParams(table_number, key_size, multi_probe_level);
|
||||
flann::Index lsh(features, indexParams);
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
void CV_LshTableBadArgTest::run( int /* start_from */ )
|
||||
{
|
||||
RNG &rng = ts->get_rng();
|
||||
|
||||
Caller caller;
|
||||
Size featuresSize = cvtest::randomSize(rng, 10.0);
|
||||
caller.features = cvtest::randomMat(rng, featuresSize, CV_8UC1, 0, 255, false);
|
||||
caller.table_number = 12;
|
||||
caller.multi_probe_level = 2;
|
||||
|
||||
int errors = 0;
|
||||
caller.key_size = 0;
|
||||
errors += run_test_case(CV_StsBadArg, "key_size is zero", caller);
|
||||
|
||||
caller.key_size = static_cast<int>(sizeof(size_t) * CHAR_BIT);
|
||||
errors += run_test_case(CV_StsBadArg, "key_size is too big", caller);
|
||||
|
||||
caller.key_size += cvtest::randInt(rng) % 100;
|
||||
errors += run_test_case(CV_StsBadArg, "key_size is too big", caller);
|
||||
|
||||
if (errors != 0)
|
||||
ts->set_failed_test_info(cvtest::TS::FAIL_MISMATCH);
|
||||
else
|
||||
ts->set_failed_test_info(cvtest::TS::OK);
|
||||
}
|
||||
|
||||
TEST(Flann_LshTable, badarg) { CV_LshTableBadArgTest test; test.safe_run(); }
|
||||
@@ -0,0 +1,3 @@
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
CV_TEST_MAIN("cv")
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user