Comparar commits
231 Commits
2.4.4-beta
..
2.4.4
| Autor | SHA1 | Data | |
|---|---|---|---|
| facab40745 | |||
| 08545b8f96 | |||
| f22ee8fc19 | |||
| e6cb44edc3 | |||
| 1094179155 | |||
| a706de2446 | |||
| 65bb4250a4 | |||
| 07b1ccdeb0 | |||
| 2128b82c6b | |||
| 978132edc1 | |||
| 22d33373fa | |||
| eaaba1336a | |||
| 85c7a36f93 | |||
| 6be6adbbed | |||
| da455efc26 | |||
| a910360689 | |||
| 8f3883a28d | |||
| 82b9854837 | |||
| 3cfd3d3ee0 | |||
| af2552d72c | |||
| c865b28243 | |||
| 79cf292d78 | |||
| 1018d110d6 | |||
| fba0e6fc5c | |||
| 4811988caf | |||
| 2a73a6c445 | |||
| d18b2c2502 | |||
| c24d7cc066 | |||
| f533f0dca9 | |||
| bd38a1945d | |||
| 29b763dc60 | |||
| 5321da92cb | |||
| f4b413e830 | |||
| 1f411b5a2b | |||
| bf4c8c6ff1 | |||
| d0e340bc80 | |||
| ddc2e334da | |||
| f12369a53c | |||
| 831580ef31 | |||
| 6ce51d88a4 | |||
| 0771fd82c0 | |||
| f791344810 | |||
| 61ef48eee6 | |||
| 504008dbe0 | |||
| df456245e7 | |||
| 7c1f1d8837 | |||
| ed3c3822fc | |||
| 69eebdd608 | |||
| 2be893a21e | |||
| a5d2253be8 | |||
| 5b7a4cd955 | |||
| 0a8711d76b | |||
| af13c8604d | |||
| cbff75db9e | |||
| bf427c01c1 | |||
| 024185b9ed | |||
| 9ccf27c7f5 | |||
| 5d43ce853e | |||
| 1a82ceac9c | |||
| b836e3c65b | |||
| f03c04c151 | |||
| c54c7c8b2c | |||
| dba2ec0539 | |||
| 6df23428af | |||
| 6409a4b112 | |||
| 9ec5333a9b | |||
| da47ccec9c | |||
| 8304f17d63 | |||
| e9307259d7 | |||
| 7a08bbbcc7 | |||
| 0e5255d4fb | |||
| 1c1c3c29c3 | |||
| 4d2c864bea | |||
| 2304d5367f | |||
| f6dd3651ea | |||
| dcf7a69430 | |||
| 04faaa9e35 | |||
| 8458f5c489 | |||
| 3ff5689fe5 | |||
| 10402c8a85 | |||
| c9868fc01f | |||
| 4f7cfbc26e | |||
| a138e12a26 | |||
| ea433cc496 | |||
| 62f8b0fc48 | |||
| 0ac7f0d374 | |||
| e3a715882e | |||
| 11885e86ee | |||
| ab221e94c0 | |||
| a9b1c5db78 | |||
| 3c7bc6a51e | |||
| 0d12f451be | |||
| 11b83d4000 | |||
| 416432a8e5 | |||
| 087537463d | |||
| 25bbcba0ea | |||
| 9f15daf0a0 | |||
| 41dc829341 | |||
| bb7af3f78e | |||
| 6082f351ab | |||
| b6cdc849db | |||
| 59ebf4ed9f | |||
| 60981565fa | |||
| 620c699456 | |||
| cfd019e2a2 | |||
| 7047c23489 | |||
| 3b1fc16f36 | |||
| 7249457771 | |||
| f1a5c1328c | |||
| b7ebedc23e | |||
| 9bbf170054 | |||
| 720eaf1e1a | |||
| d050159f07 | |||
| 07ea88b8c6 | |||
| e6dd4e840d | |||
| dfbd5f6a02 | |||
| 9bbb0ed060 | |||
| 051aa4cb98 | |||
| 58f546dd93 | |||
| 3406832aa2 | |||
| b1975fb13d | |||
| e68901bbce | |||
| 7cd4edd695 | |||
| 1a488c0542 | |||
| 4bbdfbc9e7 | |||
| 7810254198 | |||
| 3316d0bfb2 | |||
| dea6148a1a | |||
| 2e3f4fdada | |||
| f4ef0c1598 | |||
| c17e9ef7ba | |||
| 8cfba6456b | |||
| 995154d10d | |||
| 379dcf87d5 | |||
| bfb644ac04 | |||
| e7b214b6d2 | |||
| eda2a76ee9 | |||
| e3803f9985 | |||
| f0dce1fa35 | |||
| 73ffd71a22 | |||
| 8b1f88c40f | |||
| afa993316f | |||
| 9f39c8eaa1 | |||
| 16461247ce | |||
| ff0d23e55b | |||
| 21f95a3b11 | |||
| d4e7bec29a | |||
| decf04dfec | |||
| a938534a7e | |||
| 4091eab45e | |||
| f816e10ac9 | |||
| e21a1d3124 | |||
| c1a5d1c44a | |||
| ce2559b332 | |||
| f6e0d327b0 | |||
| a567c03fdf | |||
| 429ae44ae3 | |||
| 637b48eec8 | |||
| 6ebb0e2ad2 | |||
| 96b2898f38 | |||
| 5691fd3abe | |||
| 5cc2a6bdbf | |||
| afa8e4e645 | |||
| 60f7b1d98d | |||
| 2fe7482b73 | |||
| ff7b604a25 | |||
| e06c3ec7c5 | |||
| 2bbb777d95 | |||
| 535f1fb2e2 | |||
| 0570aa6494 | |||
| 7697d79d93 | |||
| 39baa2237e | |||
| c6f6f9ab35 | |||
| a1c7e0368c | |||
| 6503836b4d | |||
| 9613135e8d | |||
| 69fd2d8273 | |||
| 7e5eee5bf1 | |||
| 3ead4449ad | |||
| 2853bab471 | |||
| edb15dee3d | |||
| f58dffe31f | |||
| 50d3e565c5 | |||
| 49c664fad4 | |||
| a8c2fc6908 | |||
| 5f32e0e24d | |||
| 6deda2531c | |||
| da1ddc752b | |||
| 78c924baad | |||
| f3874abf68 | |||
| 37c6357b97 | |||
| f9cf70e93e | |||
| 6619941c90 | |||
| a3a09cf4d1 | |||
| 8547984d29 | |||
| 37e2664cf0 | |||
| 42a2cb0a38 | |||
| 2181a41a07 | |||
| aa73bf6079 | |||
| 50f28c9e25 | |||
| 36e42084f0 | |||
| fe2e89df1b | |||
| 86bd325131 | |||
| 61b54149b1 | |||
| 08914aa708 | |||
| a828b60765 | |||
| ce2fd7fec9 | |||
| 54a0e5085c | |||
| 1498d2f427 | |||
| c7df17e77b | |||
| 0b20faf3d2 | |||
| 9e4792af1f | |||
| 82313b3f6c | |||
| 247df9f3fc | |||
| ca5e6f9522 | |||
| ac389507a0 | |||
| 8b7a28a7e4 | |||
| 0cf9c16adc | |||
| 7c77b402db | |||
| 5512f91d08 | |||
| 1751a963f2 | |||
| fdb07a0ac1 | |||
| 9f01074f4c | |||
| 8c44e1ff81 | |||
| 81b9f9b16b | |||
| 0b365f6aa5 | |||
| 203849d5e4 | |||
| 50cd5d9ce7 | |||
| b85a098d9c | |||
| c2c2403a79 | |||
| 6169b1dc90 |
@@ -1,27 +1,36 @@
|
||||
.git* export-ignore
|
||||
|
||||
* text=auto
|
||||
* whitespace=!indent,trail,space
|
||||
* text=auto whitespace=trailing-space,space-before-tab,-indent-with-non-tab,tab-in-indent,tabwidth=4
|
||||
|
||||
*.py text whitespace=tab-in-indent,trail,space,fix
|
||||
*.cpp text whitespace=tab-in-indent,trail,space,fix
|
||||
*.hpp text whitespace=tab-in-indent,trail,space,fix
|
||||
*.cxx text whitespace=tab-in-indent,trail,space,fix
|
||||
*.hxx text whitespace=tab-in-indent,trail,space,fix
|
||||
*.mm text whitespace=tab-in-indent,trail,space,fix
|
||||
*.c text whitespace=tab-in-indent,trail,space,fix
|
||||
*.h text whitespace=tab-in-indent,trail,space,fix
|
||||
*.i text whitespace=tab-in-indent,trail,space,fix
|
||||
*.java text whitespace=tab-in-indent,trail,space,fix
|
||||
*.cu text whitespace=tab-in-indent,trail,space,fix
|
||||
*.cl text whitespace=tab-in-indent,trail,space,fix
|
||||
*.py text
|
||||
*.cpp text
|
||||
*.hpp text
|
||||
*.cxx text
|
||||
*.hxx text
|
||||
*.mm text
|
||||
*.c text
|
||||
*.h text
|
||||
*.i text
|
||||
*.js text
|
||||
*.java text
|
||||
*.scala text
|
||||
*.cu text
|
||||
*.cl text
|
||||
*.css_t text
|
||||
*.qrc text
|
||||
*.qss text
|
||||
*.S text
|
||||
*.rst text
|
||||
*.tex text
|
||||
*.sty text
|
||||
|
||||
*.cmake text whitespace=tab-in-indent,trail,space,fix
|
||||
*.cmakein text whitespace=tab-in-indent,trail,space,fix
|
||||
*.in text whitespace=tab-in-indent,trail,space,fix
|
||||
CMakeLists.txt text whitespace=tab-in-indent,trail,space,fix
|
||||
*.aidl text
|
||||
*.mk text
|
||||
|
||||
*.rst text whitespace=tab-in-indent,trail,space,fix
|
||||
*.cmake text whitespace=tabwidth=2
|
||||
*.cmakein text whitespace=tabwidth=2
|
||||
*.in text whitespace=tabwidth=2
|
||||
CMakeLists.txt text whitespace=tabwidth=2
|
||||
|
||||
*.png binary
|
||||
*.jepg binary
|
||||
@@ -32,22 +41,21 @@ CMakeLists.txt text whitespace=tab-in-indent,trail,space,fix
|
||||
*.a binary
|
||||
*.so binary
|
||||
*.dll binary
|
||||
*.jar binary
|
||||
|
||||
*.pdf binary
|
||||
*.pbxproj binary
|
||||
*.vec binary
|
||||
*.doc binary
|
||||
|
||||
*.css_t text
|
||||
*.qrc text
|
||||
*.qss text
|
||||
*.S text
|
||||
|
||||
*.xml -text
|
||||
*.yml -text
|
||||
*.xml -text whitespace=cr-at-eol
|
||||
*.yml -text whitespace=cr-at-eol
|
||||
.project -text whitespace=cr-at-eol merge=union
|
||||
.classpath -text whitespace=cr-at-eol merge=union
|
||||
.cproject -text whitespace=cr-at-eol merge=union
|
||||
org.eclipse.jdt.core.prefs -text whitespace=cr-at-eol merge=union
|
||||
|
||||
*.vcproj text eol=crlf merge=union
|
||||
*.cproject text eol=crlf merge=union
|
||||
*.bat text eol=crlf
|
||||
*.cmd text eol=crlf
|
||||
*.cmd.tmpl text eol=crlf
|
||||
|
||||
@@ -110,7 +110,7 @@ endif()
|
||||
|
||||
# Optional 3rd party components
|
||||
# ===================================================
|
||||
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (UNIX AND NOT ANDROID AND NOT IOS AND NOT CARMA) )
|
||||
OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON IF (UNIX AND NOT ANDROID AND NOT IOS) )
|
||||
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_CUDA "Include NVidia Cuda Runtime support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS) )
|
||||
@@ -141,9 +141,9 @@ OCV_OPTION(WITH_V4L "Include Video 4 Linux support" ON
|
||||
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 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) )
|
||||
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) )
|
||||
|
||||
|
||||
# OpenCV build components
|
||||
@@ -163,12 +163,12 @@ OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF I
|
||||
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 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_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_TBB "Download and build TBB from source" ANDROID IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
|
||||
# OpenCV installation options
|
||||
@@ -184,7 +184,7 @@ OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help wi
|
||||
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
|
||||
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
|
||||
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) )
|
||||
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE "Enable SSE instructions" ON IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
@@ -301,21 +301,19 @@ find_host_program(GIT_EXECUTABLE NAMES ${git_names} PATH_SUFFIXES Git/cmd Git/bi
|
||||
mark_as_advanced(GIT_EXECUTABLE)
|
||||
|
||||
if(GIT_EXECUTABLE)
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty --match "2.[0-9].[0-9]*"
|
||||
WORKING_DIRECTORY "${OpenCV_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE OPENCV_GIT_HASH_SORT
|
||||
OUTPUT_VARIABLE OPENCV_VCSVERSION
|
||||
RESULT_VARIABLE GIT_RESULT
|
||||
ERROR_QUIET
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
if(GIT_RESULT EQUAL 0)
|
||||
set(OPENCV_VCSVERSION "commit:${OPENCV_GIT_HASH_SORT}")
|
||||
else()
|
||||
set(OPENCV_VCSVERSION "exported")
|
||||
if(NOT GIT_RESULT EQUAL 0)
|
||||
set(OPENCV_VCSVERSION "unknown")
|
||||
endif()
|
||||
else()
|
||||
# We don't have git:
|
||||
set(OPENCV_VCSVERSION "")
|
||||
set(OPENCV_VCSVERSION "unknown")
|
||||
endif()
|
||||
|
||||
|
||||
@@ -523,10 +521,21 @@ if(NOT CMAKE_GENERATOR MATCHES "Xcode|Visual Studio")
|
||||
endif()
|
||||
|
||||
# ========================== C/C++ options ==========================
|
||||
if(CMAKE_CXX_COMPILER_VERSION)
|
||||
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_CXX_COMPILER_VERSION})")
|
||||
elseif(CMAKE_COMPILER_IS_CLANGCXX)
|
||||
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_CLANG_REGEX_VERSION})")
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_GCC_REGEX_VERSION})")
|
||||
else()
|
||||
set(OPENCV_COMPILER_STR "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}")
|
||||
endif()
|
||||
string(STRIP "${OPENCV_COMPILER_STR}" OPENCV_COMPILER_STR)
|
||||
|
||||
status("")
|
||||
status(" C/C++:")
|
||||
status(" Built as dynamic libs?:" BUILD_SHARED_LIBS THEN YES ELSE NO)
|
||||
status(" C++ Compiler:" CMAKE_COMPILER_IS_GNUCXX THEN "${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} (ver ${CMAKE_GCC_REGEX_VERSION})" ELSE "${CMAKE_CXX_COMPILER}" )
|
||||
status(" C++ Compiler:" ${OPENCV_COMPILER_STR})
|
||||
status(" C++ flags (Release):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE})
|
||||
status(" C++ flags (Debug):" ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG})
|
||||
status(" C Compiler:" ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1})
|
||||
@@ -575,15 +584,16 @@ if(ANDROID)
|
||||
status(" Android ABI:" ${ANDROID_ABI})
|
||||
status(" STL type:" ${ANDROID_STL})
|
||||
status(" Native API level:" android-${ANDROID_NATIVE_API_LEVEL})
|
||||
status(" SDK target:" "${ANDROID_SDK_TARGET}")
|
||||
android_get_compatible_target(android_sdk_target_status ${ANDROID_NATIVE_API_LEVEL} ${ANDROID_SDK_TARGET} 11)
|
||||
status(" SDK target:" "${android_sdk_target_status}")
|
||||
if(BUILD_WITH_ANDROID_NDK)
|
||||
status(" Android NDK:" "${ANDROID_NDK} (toolchain: ${ANDROID_TOOLCHAIN_NAME})")
|
||||
elseif(BUILD_WITH_STANDALONE_TOOLCHAIN)
|
||||
status(" Android toolchain:" "${ANDROID_STANDALONE_TOOLCHAIN}")
|
||||
endif()
|
||||
status(" android tool:" ANDROID_EXECUTABLE THEN "${ANDROID_EXECUTABLE} (${ANDROID_TOOLS_Pkg_Desc})" ELSE NO)
|
||||
status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
|
||||
status(" Google Play package:" BUILD_ANDROID_PACKAGE THEN YES ELSE NO)
|
||||
status(" Google Play package:" BUILD_ANDROID_PACKAGE THEN YES ELSE NO)
|
||||
status(" Android examples:" BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
# ========================== GUI ==========================
|
||||
@@ -707,7 +717,7 @@ if(DEFINED WITH_PVAPI)
|
||||
endif(DEFINED WITH_PVAPI)
|
||||
|
||||
if(DEFINED WITH_GIGEAPI)
|
||||
status(" GigEVisionSDK:" HAVE_GIGE_API THEN YES ELSE NO)
|
||||
status(" GigEVisionSDK:" HAVE_GIGE_API THEN YES ELSE NO)
|
||||
endif(DEFINED WITH_GIGEAPI)
|
||||
|
||||
if(DEFINED WITH_QUICKTIME)
|
||||
@@ -753,30 +763,21 @@ endif(DEFINED WITH_XINE)
|
||||
status("")
|
||||
status(" Other third-party libraries:")
|
||||
|
||||
if(DEFINED WITH_IPP)
|
||||
if(WITH_IPP AND IPP_FOUND)
|
||||
status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
|
||||
status(" at:" "${IPP_ROOT_DIR}")
|
||||
else()
|
||||
status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
|
||||
endif()
|
||||
endif(DEFINED WITH_IPP)
|
||||
if(WITH_IPP AND IPP_FOUND)
|
||||
status(" Use IPP:" "${IPP_LATEST_VERSION_STR} [${IPP_LATEST_VERSION_MAJOR}.${IPP_LATEST_VERSION_MINOR}.${IPP_LATEST_VERSION_BUILD}]")
|
||||
status(" at:" "${IPP_ROOT_DIR}")
|
||||
else()
|
||||
status(" Use IPP:" WITH_IPP AND NOT IPP_FOUND THEN "IPP not found" ELSE NO)
|
||||
endif()
|
||||
|
||||
if(DEFINED WITH_TBB)
|
||||
status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO)
|
||||
endif(DEFINED WITH_TBB)
|
||||
|
||||
if(DEFINED WITH_CSTRIPES)
|
||||
status(" Use C=:" HAVE_CSTRIPES THEN YES ELSE NO)
|
||||
endif(DEFINED WITH_CSTRIPES)
|
||||
|
||||
if(DEFINED WITH_CUDA)
|
||||
status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
|
||||
endif(DEFINED WITH_CUDA)
|
||||
|
||||
status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO)
|
||||
|
||||
status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
|
||||
status(" Use Eigen:" HAVE_EIGEN THEN "YES (ver ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})" ELSE NO)
|
||||
status(" Use TBB:" HAVE_TBB THEN "YES (ver ${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR} interface ${TBB_INTERFACE_VERSION})" ELSE NO)
|
||||
status(" Use OpenMP:" HAVE_OPENMP THEN YES ELSE NO)
|
||||
status(" Use GCD" HAVE_GCD THEN YES ELSE NO)
|
||||
status(" Use Concurrency" HAVE_CONCURRENCY THEN YES ELSE NO)
|
||||
status(" Use C=:" HAVE_CSTRIPES THEN YES ELSE NO)
|
||||
status(" Use Cuda:" HAVE_CUDA THEN "YES (ver ${CUDA_VERSION_STRING})" ELSE NO)
|
||||
status(" Use OpenCL:" HAVE_OPENCL THEN YES ELSE NO)
|
||||
|
||||
if(HAVE_CUDA)
|
||||
status("")
|
||||
@@ -790,10 +791,23 @@ if(HAVE_CUDA)
|
||||
status(" Use fast math:" CUDA_FAST_MATH THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
if(HAVE_OPENCL AND BUILD_opencv_ocl)
|
||||
status("")
|
||||
status(" OpenCL")
|
||||
if(OPENCL_INCLUDE_DIR)
|
||||
status(" Include:" ${OPENCL_INCLUDE_DIR})
|
||||
endif()
|
||||
if(OPENCL_LIBRARIES)
|
||||
status(" libraries:" ${OPENCL_LIBRARIES})
|
||||
endif()
|
||||
status(" Use AMDFFT:" HAVE_CLAMDFFT THEN YES ELSE NO)
|
||||
status(" Use AMDBLAS:" HAVE_CLAMDBLAS THEN YES ELSE NO)
|
||||
endif()
|
||||
|
||||
# ========================== python ==========================
|
||||
status("")
|
||||
status(" Python:")
|
||||
status(" Interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_FULL})" ELSE NO)
|
||||
status(" Interpreter:" PYTHON_EXECUTABLE THEN "${PYTHON_EXECUTABLE} (ver ${PYTHON_VERSION_FULL})" ELSE NO)
|
||||
if(BUILD_opencv_python)
|
||||
if(PYTHONLIBS_VERSION_STRING)
|
||||
status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE NO)
|
||||
@@ -804,6 +818,15 @@ if(BUILD_opencv_python)
|
||||
status(" packages path:" PYTHON_EXECUTABLE THEN "${PYTHON_PACKAGES_PATH}" ELSE "-")
|
||||
endif()
|
||||
|
||||
# ========================== java ==========================
|
||||
status("")
|
||||
status(" Java:")
|
||||
status(" ant:" ANT_EXECUTABLE THEN "${ANT_EXECUTABLE} (ver ${ANT_VERSION})" ELSE NO)
|
||||
if(NOT ANDROID)
|
||||
status(" JNI:" JNI_INCLUDE_DIRS THEN "${JNI_INCLUDE_DIRS}" ELSE NO)
|
||||
endif()
|
||||
status(" Java tests:" BUILD_TESTS AND (NOT ANDROID OR CAN_BUILD_ANDROID_PROJECTS) THEN YES ELSE NO)
|
||||
|
||||
# ========================== documentation ==========================
|
||||
if(BUILD_DOCS)
|
||||
status("")
|
||||
@@ -822,12 +845,7 @@ status("")
|
||||
status(" Tests and samples:")
|
||||
status(" Tests:" BUILD_TESTS AND HAVE_opencv_ts THEN YES ELSE NO)
|
||||
status(" Performance tests:" BUILD_PERF_TESTS AND HAVE_opencv_ts THEN YES ELSE NO)
|
||||
status(" Examples:" BUILD_EXAMPLES THEN YES ELSE NO)
|
||||
|
||||
if(ANDROID)
|
||||
status(" Android tests:" BUILD_TESTS AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
|
||||
status(" Android examples:" BUILD_ANDROID_EXAMPLES AND CAN_BUILD_ANDROID_PROJECTS THEN YES ELSE NO)
|
||||
endif()
|
||||
status(" C/C++ Examples:" BUILD_EXAMPLES THEN YES ELSE NO)
|
||||
|
||||
# ========================== auxiliary ==========================
|
||||
status("")
|
||||
|
||||
@@ -7,7 +7,7 @@ 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_VERSION_EPOCH) CVAUX_STR(CV_VERSION_MAJOR) "_" ANDROID_PACKAGE_PLATFORM
|
||||
#define PACKAGE_REVISION CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE)
|
||||
#define PACKAGE_REVISION CVAUX_STR(CV_VERSION_MINOR) "." CVAUX_STR(CV_VERSION_REVISION) "." CVAUX_STR(ANDROID_PACKAGE_RELEASE)
|
||||
|
||||
const char* GetPackageName(void)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="org.opencv.lib_v@OPENCV_VERSION_MAJOR@@OPENCV_VERSION_MINOR@_@ANDROID_PACKAGE_PLATFORM@"
|
||||
android:versionCode="@OPENCV_VERSION_PATCH@@ANDROID_PACKAGE_RELEASE@"
|
||||
android:versionName="@OPENCV_VERSION_PATCH@.@ANDROID_PACKAGE_RELEASE@" >
|
||||
android:versionCode="@OPENCV_VERSION_PATCH@@OPENCV_VERSION_TWEAK@@ANDROID_PACKAGE_RELEASE@"
|
||||
android:versionName="@OPENCV_VERSION_PATCH@.@OPENCV_VERSION_TWEAK@.@ANDROID_PACKAGE_RELEASE@" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="@ANDROID_SDK_VERSION@" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||
|
||||
@@ -1,130 +1,228 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
from optparse import OptionParser
|
||||
from shutil import rmtree
|
||||
import os
|
||||
import sys
|
||||
|
||||
ANDROID_SDK_PATH = "/opt/android-sdk-linux"
|
||||
ANDROID_NDK_PATH = None
|
||||
INSTALL_DIRECTORY = None
|
||||
CLASS_PATH = None
|
||||
TMP_HEADER_PATH="tmp_include"
|
||||
HEADER_EXTS = set(['h', 'hpp'])
|
||||
SYS_INCLUDES = ["platforms/android-8/arch-arm/usr/include", "sources/cxx-stl/gnu-libstdc++/include", "sources/cxx-stl/gnu-libstdc++/libs/armeabi/include"]
|
||||
|
||||
PROJECT_NAME = "OpenCV-branch"
|
||||
TARGET_LIBS = ["libopencv_java.so"]
|
||||
ARCH = "armeabi"
|
||||
GCC_OPTIONS = "-fpermissive"
|
||||
EXCLUDE_HEADERS = set(["hdf5.h", "eigen.hpp", "cxeigen.hpp"]);
|
||||
architecture = 'armeabi'
|
||||
excludedHeaders = set(['hdf5.h', 'cap_ios.h',
|
||||
'eigen.hpp', 'cxeigen.hpp' #TOREMOVE
|
||||
])
|
||||
systemIncludes = ['sources/cxx-stl/gnu-libstdc++/4.6/include', \
|
||||
'/opt/android-ndk-r8c/platforms/android-8/arch-arm', # TODO: check if this one could be passed as command line arg
|
||||
'sources/cxx-stl/gnu-libstdc++/4.6/libs/armeabi-v7a/include']
|
||||
targetLibs = ['libopencv_java.so']
|
||||
preamble = ['Eigen/Core']
|
||||
# TODO: get gcc_options automatically
|
||||
gcc_options = ['-fexceptions', '-frtti', '-Wno-psabi', '--sysroot=/opt/android-ndk-r8c/platforms/android-8/arch-arm', '-fpic', '-D__ARM_ARCH_5__', '-D__ARM_ARCH_5T__', '-D__ARM_ARCH_5E__', '-D__ARM_ARCH_5TE__', '-fsigned-char', '-march=armv5te', '-mtune=xscale', '-msoft-float', '-fdata-sections', '-ffunction-sections', '-Wa,--noexecstack ', '-W', '-Wall', '-Werror=return-type', '-Werror=address', '-Werror=sequence-point', '-Wformat', '-Werror=format-security', '-Wmissing-declarations', '-Wundef', '-Winit-self', '-Wpointer-arith', '-Wshadow', '-Wsign-promo', '-Wno-narrowing', '-fdiagnostics-show-option', '-fomit-frame-pointer', '-mthumb', '-fomit-frame-pointer', '-O3', '-DNDEBUG ', '-DNDEBUG']
|
||||
excludedOptionsPrefix = '-W'
|
||||
|
||||
def FindClasses(root, prefix):
|
||||
classes = []
|
||||
if ("" != prefix):
|
||||
prefix = prefix + "."
|
||||
for path in os.listdir(root):
|
||||
currentPath = os.path.join(root, path)
|
||||
if (os.path.isdir(currentPath)):
|
||||
classes += FindClasses(currentPath, prefix + path)
|
||||
else:
|
||||
name = str.split(path, ".")[0]
|
||||
ext = str.split(path, ".")[1]
|
||||
if (ext == "class"):
|
||||
#print("class: %s" % (prefix + name))
|
||||
classes.append(prefix+name)
|
||||
return classes
|
||||
|
||||
def FindHeaders(root):
|
||||
|
||||
def GetHeaderFiles(root):
|
||||
headers = []
|
||||
for path in os.listdir(root):
|
||||
currentPath = os.path.join(root, path)
|
||||
if (os.path.isdir(currentPath)):
|
||||
headers += FindHeaders(currentPath)
|
||||
else:
|
||||
ext = str.split(path, ".")[-1]
|
||||
#print("%s: \"%s\"" % (currentPath, ext))
|
||||
if (ext in HEADER_EXTS):
|
||||
#print("Added as header file")
|
||||
if (path not in EXCLUDE_HEADERS):
|
||||
headers.append(currentPath)
|
||||
if not os.path.isdir(os.path.join(root, path)) \
|
||||
and os.path.splitext(path)[1] in ['.h', '.hpp'] \
|
||||
and not path in excludedHeaders:
|
||||
headers.append(os.path.join(root, path))
|
||||
return sorted(headers)
|
||||
|
||||
|
||||
|
||||
def GetClasses(root, prefix):
|
||||
classes = []
|
||||
if ('' != prefix):
|
||||
prefix = prefix + '.'
|
||||
for path in os.listdir(root):
|
||||
currentPath = os.path.join(root, path)
|
||||
if (os.path.isdir(currentPath)):
|
||||
classes += GetClasses(currentPath, prefix + path)
|
||||
else:
|
||||
name = str.split(path, '.')[0]
|
||||
ext = str.split(path, '.')[1]
|
||||
if (ext == 'class'):
|
||||
classes.append(prefix + name)
|
||||
return classes
|
||||
|
||||
|
||||
|
||||
def GetJavaHHeaders():
|
||||
print('\nGenerating JNI headers for Java API ...')
|
||||
|
||||
javahHeaders = os.path.join(managerDir, 'javah_generated_headers')
|
||||
if os.path.exists(javahHeaders):
|
||||
rmtree(javahHeaders)
|
||||
os.makedirs(os.path.join(os.getcwd(), javahHeaders))
|
||||
|
||||
AndroidJavaDeps = os.path.join(SDK_path, 'platforms/android-11/android.jar')
|
||||
|
||||
classPath = os.path.join(managerDir, 'sdk/java/bin/classes')
|
||||
if not os.path.exists(classPath):
|
||||
print('Error: no Java classes found in \'%s\'' % classPath)
|
||||
quit()
|
||||
|
||||
allJavaClasses = GetClasses(classPath, '')
|
||||
if not allJavaClasses:
|
||||
print('Error: no Java classes found')
|
||||
quit()
|
||||
|
||||
for currentClass in allJavaClasses:
|
||||
os.system('javah -d %s -classpath %s:%s %s' % (javahHeaders, classPath, \
|
||||
AndroidJavaDeps, currentClass))
|
||||
|
||||
print('\nBuilding JNI headers list ...')
|
||||
jniHeaders = GetHeaderFiles(javahHeaders)
|
||||
|
||||
return jniHeaders
|
||||
|
||||
|
||||
|
||||
def GetImmediateSubdirs(dir):
|
||||
return [name for name in os.listdir(dir)
|
||||
if os.path.isdir(os.path.join(dir, name))]
|
||||
|
||||
|
||||
|
||||
def GetOpenCVModules():
|
||||
makefile = open(os.path.join(managerDir, 'sdk/native/jni/OpenCV.mk'), 'r')
|
||||
makefileStr = makefile.read()
|
||||
left = makefileStr.find('OPENCV_MODULES:=') + len('OPENCV_MODULES:=')
|
||||
right = makefileStr[left:].find('\n')
|
||||
modules = makefileStr[left:left+right].split()
|
||||
modules = filter(lambda x: x != 'ts' and x != 'androidcamera', modules)
|
||||
return modules
|
||||
|
||||
|
||||
|
||||
def FindHeaders():
|
||||
headers = []
|
||||
|
||||
print('\nBuilding Native OpenCV header list ...')
|
||||
|
||||
cppHeadersFolder = os.path.join(managerDir, 'sdk/native/jni/include/opencv2')
|
||||
|
||||
modulesFolders = GetImmediateSubdirs(cppHeadersFolder)
|
||||
modules = GetOpenCVModules()
|
||||
|
||||
cppHeaders = []
|
||||
for m in modules:
|
||||
for f in modulesFolders:
|
||||
moduleHeaders = []
|
||||
if f == m:
|
||||
moduleHeaders += GetHeaderFiles(os.path.join(cppHeadersFolder, f))
|
||||
if m == 'flann':
|
||||
flann = os.path.join(cppHeadersFolder, f, 'flann.hpp')
|
||||
moduleHeaders.remove(flann)
|
||||
moduleHeaders.insert(0, flann)
|
||||
cppHeaders += moduleHeaders
|
||||
|
||||
|
||||
cppHeaders += GetHeaderFiles(cppHeadersFolder)
|
||||
headers += cppHeaders
|
||||
|
||||
cHeaders = GetHeaderFiles(os.path.join(managerDir, \
|
||||
'sdk/native/jni/include/opencv'))
|
||||
headers += cHeaders
|
||||
|
||||
headers += GetJavaHHeaders()
|
||||
|
||||
return headers
|
||||
|
||||
if (len(sys.argv) < 3):
|
||||
print("Error: Invalid command line arguments")
|
||||
exit(-1)
|
||||
|
||||
INSTALL_DIRECTORY = sys.argv[1]
|
||||
PROJECT_NAME = sys.argv[2]
|
||||
|
||||
CLASS_PATH = os.path.join(INSTALL_DIRECTORY, "sdk/java/bin/classes")
|
||||
if (not os.path.exists(CLASS_PATH)):
|
||||
print("Error: no java classes found in \"%s\"" % CLASS_PATH)
|
||||
exit(-2)
|
||||
def FindLibraries():
|
||||
libraries = []
|
||||
for lib in targetLibs:
|
||||
libraries.append(os.path.join(managerDir, 'sdk/native/libs', architecture, lib))
|
||||
return libraries
|
||||
|
||||
if (os.environ.has_key("NDK_ROOT")):
|
||||
ANDROID_NDK_PATH = os.environ["NDK_ROOT"];
|
||||
print("Using Android NDK from NDK_ROOT (\"%s\")" % ANDROID_NDK_PATH)
|
||||
|
||||
if (not ANDROID_NDK_PATH):
|
||||
pipe = os.popen("which ndk-build")
|
||||
tmp = str.strip(pipe.readline(), "\n")
|
||||
while(not tmp):
|
||||
tmp = str.strip(pipe.readline(), "\n")
|
||||
pipe.close()
|
||||
ANDROID_NDK_PATH = os.path.split(tmp)[0]
|
||||
print("Using Android NDK from PATH (\"%s\")" % ANDROID_NDK_PATH)
|
||||
|
||||
print("Using Android SDK from \"%s\"" % ANDROID_SDK_PATH)
|
||||
def FindIncludes():
|
||||
includes = [os.path.join(managerDir, 'sdk', 'native', 'jni', 'include'),
|
||||
os.path.join(managerDir, 'sdk', 'native', 'jni', 'include', 'opencv'),
|
||||
os.path.join(managerDir, 'sdk', 'native', 'jni', 'include', 'opencv2')]
|
||||
|
||||
outputFileName = PROJECT_NAME + ".xml"
|
||||
try:
|
||||
outputFile = open(outputFileName, "w")
|
||||
except:
|
||||
print("Error: Cannot open output file \"%s\" for writing" % outputFileName)
|
||||
for inc in systemIncludes:
|
||||
includes.append(os.path.join(NDK_path, inc))
|
||||
|
||||
allJavaClasses = FindClasses(CLASS_PATH, "")
|
||||
if (not allJavaClasses):
|
||||
print("Error: No Java classes found :(")
|
||||
exit(-1)
|
||||
return includes
|
||||
|
||||
if (not os.path.exists(TMP_HEADER_PATH)):
|
||||
os.makedirs(os.path.join(os.getcwd(), TMP_HEADER_PATH))
|
||||
|
||||
print("Generating JNI headers for Java API ...")
|
||||
AndroidJavaDeps = os.path.join(ANDROID_SDK_PATH, "platforms/android-11/android.jar")
|
||||
for currentClass in allJavaClasses:
|
||||
os.system("javah -d %s -classpath %s:%s %s" % (TMP_HEADER_PATH, CLASS_PATH, AndroidJavaDeps, currentClass))
|
||||
|
||||
print("Building JNI headers list ...")
|
||||
jniHeaders = FindHeaders(TMP_HEADER_PATH)
|
||||
#print(jniHeaders)
|
||||
def FilterGCCOptions():
|
||||
gcc = filter(lambda x: not x.startswith(excludedOptionsPrefix), gcc_options)
|
||||
return sorted(gcc)
|
||||
|
||||
print("Building Native OpenCV header list ...")
|
||||
cHeaders = FindHeaders(os.path.join(INSTALL_DIRECTORY, "sdk/native/jni/include/opencv"))
|
||||
cppHeaders = FindHeaders(os.path.join(INSTALL_DIRECTORY, "sdk/native/jni/include/opencv2"))
|
||||
#print(cHeaders)
|
||||
#print(cppHeaders)
|
||||
|
||||
print("Writing config file ...")
|
||||
outputFile.write("<descriptor>\n\n<version>\n\t%s\n</version>\n\n<headers>\n" % PROJECT_NAME)
|
||||
outputFile.write("\t" + "\n\t".join(cHeaders))
|
||||
outputFile.write("\n\t" + "\n\t".join(cppHeaders))
|
||||
outputFile.write("\n\t" + "\n\t".join(jniHeaders))
|
||||
outputFile.write("\n</headers>\n\n")
|
||||
|
||||
includes = [os.path.join(INSTALL_DIRECTORY, "sdk", "native", "jni", "include"),
|
||||
os.path.join(INSTALL_DIRECTORY, "sdk", "native", "jni", "include", "opencv"),
|
||||
os.path.join(INSTALL_DIRECTORY, "sdk", "native", "jni", "include", "opencv2")]
|
||||
def WriteXml(version, headers, includes, libraries):
|
||||
xmlName = version + '.xml'
|
||||
|
||||
for inc in SYS_INCLUDES:
|
||||
includes.append(os.path.join(ANDROID_NDK_PATH, inc))
|
||||
print '\noutput file: ' + xmlName
|
||||
try:
|
||||
xml = open(xmlName, 'w')
|
||||
except:
|
||||
print 'Error: Cannot open output file "%s" for writing' % xmlName
|
||||
quit()
|
||||
|
||||
outputFile.write("<include_paths>\n\t%s\n</include_paths>\n\n" % "\n\t".join(includes))
|
||||
xml.write('<descriptor>')
|
||||
|
||||
libraries = []
|
||||
for lib in TARGET_LIBS:
|
||||
libraries.append(os.path.join(INSTALL_DIRECTORY, "sdk/native/libs", ARCH, lib))
|
||||
xml.write('\n\n<version>')
|
||||
xml.write('\n\t%s' % version)
|
||||
xml.write('\n</version>')
|
||||
|
||||
outputFile.write("<libs>\n\t%s\n</libs>\n\n" % "\n\t".join(libraries))
|
||||
outputFile.write("<gcc_options>\n\t%s\n</gcc_options>\n\n</descriptor>" % GCC_OPTIONS)
|
||||
xml.write('\n\n<headers>')
|
||||
xml.write('\n\t%s' % '\n\t'.join(headers))
|
||||
xml.write('\n</headers>')
|
||||
|
||||
print("done!")
|
||||
xml.write('\n\n<include_paths>')
|
||||
xml.write('\n\t%s' % '\n\t'.join(includes))
|
||||
xml.write('\n</include_paths>')
|
||||
|
||||
# TODO: uncomment when Eigen problem is solved
|
||||
# xml.write('\n\n<include_preamble>')
|
||||
# xml.write('\n\t%s' % '\n\t'.join(preamble))
|
||||
# xml.write('\n</include_preamble>')
|
||||
|
||||
xml.write('\n\n<libs>')
|
||||
xml.write('\n\t%s' % '\n\t'.join(libraries))
|
||||
xml.write('\n</libs>')
|
||||
|
||||
xml.write('\n\n<gcc_options>')
|
||||
xml.write('\n\t%s' % '\n\t'.join(gcc_options))
|
||||
xml.write('\n</gcc_options>')
|
||||
|
||||
xml.write('\n\n</descriptor>')
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
usage = '%prog <OpenCV_Manager install directory> <OpenCV_Manager version>'
|
||||
parser = OptionParser(usage = usage)
|
||||
|
||||
args = parser.parse_args()
|
||||
if 2 != len(args):
|
||||
parser.print_help()
|
||||
quit()
|
||||
|
||||
managerDir = args[1][0]
|
||||
version = args[1][1]
|
||||
|
||||
NDK_path = '/opt/android-ndk-r8c'
|
||||
print '\nUsing Android NDK from "%s"' % NDK_path
|
||||
|
||||
SDK_path = '~/NVPACK/android-sdk-linux'
|
||||
print '\nUsing Android SDK from "%s"' % SDK_path
|
||||
|
||||
headers = FindHeaders()
|
||||
|
||||
includes = FindIncludes()
|
||||
|
||||
libraries = FindLibraries()
|
||||
|
||||
gcc_options = FilterGCCOptions()
|
||||
|
||||
WriteXml(version, headers, includes, libraries)
|
||||
|
||||
@@ -5,4 +5,3 @@ mkdir -p build_service
|
||||
cd build_service
|
||||
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_TOOLCHAIN_NAME="arm-linux-androideabi-4.4.3" -DANDROID_STL=stlport_static -DANDROID_STL_FORCE_FEATURES=OFF -DBUILD_ANDROID_SERVICE=ON -DANDROID_SOURCE_TREE=~/Projects/AndroidSource/ServiceStub/ $@ ../..
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ See the "15-puzzle" OpenCV sample for details.
|
||||
super.onResume();
|
||||
|
||||
Log.i(TAG, "Trying to load OpenCV library");
|
||||
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mOpenCVCallBack))
|
||||
if (!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_4, this, mOpenCVCallBack))
|
||||
{
|
||||
Log.e(TAG, "Cannot connect to OpenCV Manager");
|
||||
}
|
||||
|
||||
@@ -47,3 +47,7 @@ OpenCV version constants
|
||||
.. data:: OPENCV_VERSION_2_4_3
|
||||
|
||||
OpenCV Library version 2.4.3
|
||||
|
||||
.. data:: OPENCV_VERSION_2_4_4
|
||||
|
||||
OpenCV Library version 2.4.4
|
||||
|
||||
@@ -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="25@ANDROID_PLATFORM_VERSION_CODE@"
|
||||
android:versionName="2.5" >
|
||||
android:versionCode="26@ANDROID_PLATFORM_VERSION_CODE@"
|
||||
android:versionName="2.6" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="@ANDROID_NATIVE_API_LEVEL@" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||
|
||||
@@ -62,3 +62,14 @@ set_target_properties(${engine}_jni PROPERTIES
|
||||
|
||||
get_target_property(engine_lib_location ${engine}_jni LOCATION)
|
||||
add_custom_command(TARGET ${engine}_jni POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${engine_lib_location}")
|
||||
|
||||
# native tests
|
||||
add_definitions(-DGTEST_HAS_CLONE=0 -DANDROID -DGTEST_HAS_TR1_TUPLE=0)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-allow-shlib-undefined")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/jni/Tests)
|
||||
file(GLOB engine_test_files "jni/Tests/*.cpp")
|
||||
|
||||
add_executable(opencv_test_engine ${engine_test_files} jni/Tests/gtest/gtest-all.cpp)
|
||||
target_link_libraries(opencv_test_engine z binder log utils android_runtime ${engine} ${engine}_jni)
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ using namespace android;
|
||||
|
||||
const int OpenCVEngine::Platform = DetectKnownPlatforms();
|
||||
const int OpenCVEngine::CpuID = GetCpuID();
|
||||
const int OpenCVEngine::KnownVersions[] = {2040000, 2040100, 2040200, 2040300, 2040301, 2040302};
|
||||
const int OpenCVEngine::KnownVersions[] = {2040000, 2040100, 2040200, 2040300, 2040301, 2040302, 2040400};
|
||||
|
||||
bool OpenCVEngine::ValidateVersion(int version)
|
||||
{
|
||||
|
||||
@@ -40,6 +40,7 @@ bool JavaBasedPackageManager::InstallPackage(const PackageInfo& package)
|
||||
if (!jmethod)
|
||||
{
|
||||
LOGE("MarketConnector::GetAppFormMarket method was not found!");
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -74,7 +75,6 @@ vector<PackageInfo> JavaBasedPackageManager::GetInstalledPackages()
|
||||
JavaContext->AttachCurrentThread(&jenv, NULL);
|
||||
}
|
||||
|
||||
LOGD("GetObjectClass call");
|
||||
jclass jclazz = jenv->GetObjectClass(JavaPackageManager);
|
||||
if (!jclazz)
|
||||
{
|
||||
@@ -82,15 +82,14 @@ vector<PackageInfo> JavaBasedPackageManager::GetInstalledPackages()
|
||||
return result;
|
||||
}
|
||||
|
||||
LOGD("GetMethodID call");
|
||||
jmethodID jmethod = jenv->GetMethodID(jclazz, "GetInstalledOpenCVPackages", "()[Landroid/content/pm/PackageInfo;");
|
||||
if (!jmethod)
|
||||
{
|
||||
LOGE("MarketConnector::GetInstalledOpenCVPackages method was not found!");
|
||||
jenv->DeleteLocalRef(jclazz);
|
||||
return result;
|
||||
}
|
||||
|
||||
LOGD("Java package manager call");
|
||||
jobjectArray jpkgs = static_cast<jobjectArray>(jenv->CallNonvirtualObjectMethod(JavaPackageManager, jclazz, jmethod));
|
||||
jsize size = jenv->GetArrayLength(jpkgs);
|
||||
|
||||
@@ -102,7 +101,6 @@ vector<PackageInfo> JavaBasedPackageManager::GetInstalledPackages()
|
||||
{
|
||||
jobject jtmp = jenv->GetObjectArrayElement(jpkgs, i);
|
||||
PackageInfo tmp = ConvertPackageFromJava(jtmp, jenv);
|
||||
jenv->DeleteLocalRef(jtmp);
|
||||
|
||||
if (tmp.IsValid())
|
||||
result.push_back(tmp);
|
||||
@@ -137,6 +135,7 @@ static jint GetAndroidVersion(JNIEnv* jenv)
|
||||
PackageInfo JavaBasedPackageManager::ConvertPackageFromJava(jobject package, JNIEnv* jenv)
|
||||
{
|
||||
jclass jclazz = jenv->GetObjectClass(package);
|
||||
|
||||
jfieldID jfield = jenv->GetFieldID(jclazz, "packageName", "Ljava/lang/String;");
|
||||
jstring jnameobj = static_cast<jstring>(jenv->GetObjectField(package, jfield));
|
||||
const char* jnamestr = jenv->GetStringUTFChars(jnameobj, NULL);
|
||||
@@ -148,6 +147,7 @@ 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);
|
||||
|
||||
@@ -80,17 +80,21 @@ string CommonPackageManager::GetPackagePathByVersion(int version, int platform,
|
||||
|
||||
if (!packages.empty())
|
||||
{
|
||||
int OptRating = -1;
|
||||
int OptVersion = 0;
|
||||
std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
|
||||
int platform_group = 0;
|
||||
|
||||
if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
|
||||
group = CommonPackageManager::IntelRating;
|
||||
platform_group = 1;
|
||||
|
||||
int HardwareRating = GetHardwareRating(platform, cpu_id, group);
|
||||
LOGD("Current hardware platform rating %d for (%d,%d)", HardwareRating, platform, cpu_id);
|
||||
if (cpu_id & ARCH_MIPS)
|
||||
platform_group = 2;
|
||||
|
||||
if (-1 == HardwareRating)
|
||||
int opt_rating = -1;
|
||||
int opt_version = 0;
|
||||
|
||||
const int hardware_rating = GetHardwareRating(platform, cpu_id, ArchRatings[platform_group]);
|
||||
LOGD("Current hardware platform rating %d for (%d,%d)", hardware_rating, platform, cpu_id);
|
||||
|
||||
if (-1 == hardware_rating)
|
||||
{
|
||||
LOGE("Cannot calculate rating for current hardware platform!");
|
||||
}
|
||||
@@ -99,26 +103,38 @@ string CommonPackageManager::GetPackagePathByVersion(int version, int platform,
|
||||
vector<PackageInfo>::iterator found = packages.end();
|
||||
for (vector<PackageInfo>::iterator it = packages.begin(); it != packages.end(); ++it)
|
||||
{
|
||||
int PackageRating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), group);
|
||||
LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), PackageRating, it->GetPlatform(), it->GetCpuID());
|
||||
if ((PackageRating >= 0) && (PackageRating <= HardwareRating))
|
||||
int package_group = 0;
|
||||
|
||||
if ((it->GetCpuID() & ARCH_X86) || (it->GetCpuID() & ARCH_X64))
|
||||
package_group = 1;
|
||||
|
||||
if (it->GetCpuID() & ARCH_MIPS)
|
||||
package_group = 2;
|
||||
|
||||
if (package_group != platform_group)
|
||||
continue;
|
||||
|
||||
const int package_rating = GetHardwareRating(it->GetPlatform(), it->GetCpuID(), ArchRatings[package_group]);
|
||||
|
||||
LOGD("Package \"%s\" rating %d for (%d,%d)", it->GetFullName().c_str(), package_rating, it->GetPlatform(), it->GetCpuID());
|
||||
if ((package_rating >= 0) && (package_rating <= hardware_rating))
|
||||
{
|
||||
if (((it->GetVersion() >= OptVersion) && (PackageRating >= OptRating)) || (it->GetVersion() > OptVersion))
|
||||
if (((it->GetVersion() >= opt_version) && (package_rating >= opt_rating)) || (it->GetVersion() > opt_version))
|
||||
{
|
||||
OptRating = PackageRating;
|
||||
OptVersion = it->GetVersion();
|
||||
opt_rating = package_rating;
|
||||
opt_version = it->GetVersion();
|
||||
found = it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((-1 != OptRating) && (packages.end() != found))
|
||||
if ((-1 != opt_rating) && (packages.end() != found))
|
||||
{
|
||||
result = found->GetInstalationPath();
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGI("Found package is incompatible with current hardware platform");
|
||||
LOGI("No compatible packages found!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -146,10 +162,13 @@ int CommonPackageManager::GetHardwareRating(int platform, int cpu_id, const std:
|
||||
else
|
||||
{
|
||||
// Calculate rating for Arm
|
||||
LOGD("!!! Calculating rating for ARM\n");
|
||||
for (size_t i = 0; i < group.size(); i++)
|
||||
{
|
||||
LOGD("Checking (%d, %d) against (%d,%d)\n", group[i].first, group[i].second, platform, cpu_id);
|
||||
if (group[i] == std::pair<int, int>(platform, cpu_id))
|
||||
{
|
||||
LOGD("Rating found: %d\n", i);
|
||||
result = i;
|
||||
break;
|
||||
}
|
||||
@@ -182,21 +201,27 @@ std::vector<std::pair<int, int> > CommonPackageManager::InitArmRating()
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stub for Intel platforms rating initialization. Common package for all Intel based devices is used now
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::InitIntelRating()
|
||||
{
|
||||
std::vector<std::pair<int, int> > result;
|
||||
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X64));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSSE3));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_X86));
|
||||
return result;
|
||||
}
|
||||
|
||||
// Stub for MIPS platforms rating initialization. Common package for all MIPS based devices is used now
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::InitMipsRating()
|
||||
{
|
||||
std::vector<std::pair<int, int> > result;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::IntelRating = CommonPackageManager::InitIntelRating();
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::ArmRating = InitArmRating();
|
||||
const std::vector<std::pair<int, int> > CommonPackageManager::ArchRatings[] = {
|
||||
CommonPackageManager::InitArmRating(),
|
||||
CommonPackageManager::InitIntelRating(),
|
||||
CommonPackageManager::InitMipsRating()
|
||||
};
|
||||
|
||||
CommonPackageManager::~CommonPackageManager()
|
||||
{
|
||||
|
||||
@@ -16,11 +16,11 @@ public:
|
||||
virtual ~CommonPackageManager();
|
||||
|
||||
protected:
|
||||
static std::vector<std::pair<int, int> > ArmRating;
|
||||
static std::vector<std::pair<int, int> > IntelRating;
|
||||
static const std::vector<std::pair<int, int> > ArchRatings[];
|
||||
|
||||
static std::vector<std::pair<int, int> > InitArmRating();
|
||||
static std::vector<std::pair<int, int> > InitIntelRating();
|
||||
static std::vector<std::pair<int, int> > InitMipsRating();
|
||||
|
||||
bool IsVersionCompatible(int target_version, int package_version);
|
||||
int GetHardwareRating(int platform, int cpu_id, const std::vector<std::pair<int, int> >& group);
|
||||
|
||||
@@ -136,7 +136,17 @@ inline int SplitVersion(const vector<string>& features, const string& package_ve
|
||||
|
||||
// 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());
|
||||
if (tmp2.size() == 2)
|
||||
{
|
||||
// the 2nd digit is revision
|
||||
result += atoi(tmp2[0].c_str())*100 + 00;
|
||||
}
|
||||
else
|
||||
{
|
||||
// the 2nd digit is part of library version
|
||||
// the 3rd digit is revision
|
||||
result += atoi(tmp2[0].c_str())*100 + atoi(tmp2[1].c_str());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -194,10 +204,10 @@ inline int SplitPlatfrom(const vector<string>& features)
|
||||
* Example: armv7_neon
|
||||
*/
|
||||
PackageInfo::PackageInfo(int version, int platform, int cpu_id, std::string install_path):
|
||||
Version(version),
|
||||
Platform(platform),
|
||||
CpuID(cpu_id),
|
||||
InstallPath("")
|
||||
Version(version),
|
||||
Platform(platform),
|
||||
CpuID(cpu_id),
|
||||
InstallPath("")
|
||||
{
|
||||
#ifndef __SUPPORT_TEGRA3
|
||||
Platform = PLATFORM_UNKNOWN;
|
||||
|
||||
@@ -111,7 +111,6 @@ TEST(Split, SplitMultiElementString)
|
||||
TEST(CpuCount, CheckNonZero)
|
||||
{
|
||||
EXPECT_TRUE(GetProcessorCount() != 0);
|
||||
EXPECT_TRUE(a.find("") == a.end());
|
||||
}
|
||||
|
||||
TEST(GetCpuInfo, GetCpuInfo)
|
||||
@@ -127,7 +126,7 @@ TEST(CpuID, CheckNotEmpy)
|
||||
EXPECT_NE(0, cpu_id);
|
||||
}
|
||||
|
||||
#ifdef __i386__
|
||||
#if defined(__i386__)
|
||||
TEST(CpuID, CheckX86)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
@@ -139,14 +138,14 @@ TEST(CpuID, CheckSSE2)
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_TRUE(cpu_id & FEATURES_HAS_SSE2);
|
||||
}
|
||||
#elseif __mips
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(CpuID, CheckMips)
|
||||
{
|
||||
#elif defined(__mips)
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(CpuID, CheckMips)
|
||||
{
|
||||
int cpu_id = GetCpuID();
|
||||
EXPECT_TRUE(cpu_id & ARCH_MIPS);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
TEST(TegraDetector, Detect)
|
||||
{
|
||||
@@ -175,4 +174,4 @@ TEST(PlatfromDetector, CheckTegra)
|
||||
{
|
||||
EXPECT_NE(PLATFORM_UNKNOWN, DetectKnownPlatforms());
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
@@ -69,7 +69,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
Starter.PackageManager->InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string());
|
||||
@@ -79,7 +79,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_x86/lib", String8(result).string());
|
||||
@@ -89,7 +89,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
Starter.PackageManager->InstallVersion(2040100, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@@ -100,7 +100,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
Starter.PackageManager->InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string());
|
||||
@@ -110,7 +110,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", String8(result).string());
|
||||
@@ -120,7 +120,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
Starter.PackageManager->InstallVersion(2040100, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@@ -131,7 +131,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWExistVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("240", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
@@ -149,7 +149,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWOldVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.1"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
@@ -167,7 +167,7 @@ TEST(OpenCVEngineTest, GetPathForExecHWNewVersion)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("241", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040100, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@@ -177,7 +177,7 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", String8(result).string());
|
||||
@@ -187,7 +187,7 @@ TEST(OpenCVEngineTest, GetPathForCompatiblePackage2)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
@@ -218,6 +218,66 @@ TEST(OpenCVEngineTest, InstallAndGetVersion)
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathFor2_4_2)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.2"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathFor2_4_3)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.3"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathFor2_4_3_1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion(2040301, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.3.1"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathFor2_4_3_2)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion(2040302, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.3.2"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathFor2_4_4)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion(2040400, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.4"));
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv7a/lib", String8(result).string());
|
||||
}
|
||||
|
||||
TEST(OpenCVEngineTest, GetPathFor2_4_5)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion(2040500, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4.5"));
|
||||
EXPECT_EQ(0, result.size()); // 2.4.5 is not published yet
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef __i386__
|
||||
@@ -225,7 +285,7 @@ TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_X64);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_X64);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@@ -235,7 +295,7 @@ TEST(OpenCVEngineTest, GetPathForInCompatiblePackage1)
|
||||
{
|
||||
sp<IOpenCVEngine> Engine = InitConnect();
|
||||
Starter.PackageManager->InstalledPackages.clear();
|
||||
Starter.PackageManager->InstallVersion("242", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
Starter.PackageManager->InstallVersion(2040200, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.4"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
@@ -248,4 +308,4 @@ TEST(OpenCVEngineTest, GetPathForUnExistVersion)
|
||||
EXPECT_FALSE(NULL == Engine.get());
|
||||
String16 result = Engine->GetLibPathByVersion(String16("2.5"));
|
||||
EXPECT_EQ(0, result.size());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,14 +11,14 @@ using namespace std;
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7Neon)
|
||||
{
|
||||
PackageInfo info("241", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
PackageInfo info(2040100, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v24_armv7a_neon", name.c_str());
|
||||
@@ -29,14 +29,14 @@ TEST(PackageInfo, FullNameArmv7Neon)
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7VFPv3)
|
||||
{
|
||||
PackageInfo info("233", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
|
||||
PackageInfo info(2030300, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv7VFPv3Neon)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv7a_neon", name.c_str());
|
||||
@@ -47,21 +47,21 @@ TEST(PackageInfo, FullNameArmv7VFPv3Neon)
|
||||
|
||||
TEST(PackageInfo, FullNameArmv5)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv6)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv6);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv6);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5", name.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, FullNameArmv6VFPv3)
|
||||
{
|
||||
PackageInfo info("232", PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3);
|
||||
PackageInfo info(2030200, PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_ARMEABI_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_armv5_vfpv3", name.c_str());
|
||||
@@ -72,7 +72,7 @@ TEST(PackageInfo, FullNameArmv6VFPv3)
|
||||
|
||||
TEST(PackageInfo, FullNameTegra3)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
PackageInfo info(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("org.opencv.lib_v23_tegra3", name.c_str());
|
||||
@@ -87,7 +87,7 @@ TEST(PackageInfo, FullNameTegra3)
|
||||
|
||||
TEST(PackageInfo, FullNameX86SSE2)
|
||||
{
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
string name = info.GetFullName();
|
||||
#ifdef __SUPPORT_INTEL_FEATURES
|
||||
EXPECT_STREQ("org.opencv.lib_v23_x86_sse2", name.c_str());
|
||||
@@ -99,7 +99,7 @@ TEST(PackageInfo, FullNameX86SSE2)
|
||||
#ifdef __SUPPORT_MIPS
|
||||
TEST(PackageInfo, FullNameMips)
|
||||
{
|
||||
PackageInfo info("243", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
PackageInfo info(2040300, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
string name = info.GetFullName();
|
||||
EXPECT_STREQ("org.opencv.lib_v24_mips", name.c_str());
|
||||
}
|
||||
@@ -108,21 +108,21 @@ TEST(PackageInfo, FullNameMips)
|
||||
TEST(PackageInfo, Armv7NeonFromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Armv5FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv5", "/data/data/org.opencv.lib_v23_armv5");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv5, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Armv5VFPv3FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv5_vfpv3", "/data/data/org.opencv.lib_v23_armv5_vfpv3");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv5 | FEATURES_HAS_VFPv3, info.GetCpuID());
|
||||
}
|
||||
|
||||
@@ -131,20 +131,20 @@ TEST(PackageInfo, X86SSE2FromFullName)
|
||||
PackageInfo info("org.opencv.lib_v24_x86_sse2", "/data/data/org.opencv.lib_v24_x86_sse2");
|
||||
EXPECT_EQ(PLATFORM_UNKNOWN, info.GetPlatform());
|
||||
EXPECT_EQ(ARCH_X86 | FEATURES_HAS_SSE2, info.GetCpuID());
|
||||
EXPECT_EQ("240", info.GetVersion());
|
||||
EXPECT_EQ(2040000, info.GetVersion());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Tegra2FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_tegra2", "/data/data/org.opencv.lib_v23_tegra2");
|
||||
EXPECT_EQ("230", info.GetVersion());
|
||||
EXPECT_EQ(2030000, info.GetVersion());
|
||||
EXPECT_EQ(PLATFORM_TEGRA2, info.GetPlatform());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Tegra3FromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v24_tegra3", "/data/data/org.opencv.lib_v24_tegra3");
|
||||
EXPECT_EQ("240", info.GetVersion());
|
||||
EXPECT_EQ(2040000, info.GetVersion());
|
||||
EXPECT_EQ(PLATFORM_TEGRA3, info.GetPlatform());
|
||||
}
|
||||
|
||||
@@ -152,14 +152,28 @@ TEST(PackageInfo, Tegra3FromFullName)
|
||||
TEST(PackageInfo, MipsFromFullName)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v24_mips", "/data/data/org.opencv.lib_v24_mips");
|
||||
EXPECT_EQ("240", info.GetVersion());
|
||||
EXPECT_EQ(2040000, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_MIPS, info.GetCpuID());
|
||||
}
|
||||
#endif
|
||||
|
||||
TEST(PackageInfo, Check2DigitRevision)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon", "4.1");
|
||||
EXPECT_EQ(2030400, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Check3DigitRevision)
|
||||
{
|
||||
PackageInfo info("org.opencv.lib_v23_armv7a_neon", "/data/data/org.opencv.lib_v23_armv7_neon", "4.1.5");
|
||||
EXPECT_EQ(2030401, info.GetVersion());
|
||||
EXPECT_EQ(ARCH_ARMv7 | FEATURES_HAS_NEON, info.GetCpuID());
|
||||
}
|
||||
|
||||
TEST(PackageInfo, Comparator1)
|
||||
{
|
||||
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
PackageInfo info1(2040000, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
PackageInfo info2("org.opencv.lib_v24_x86", "/data/data/org.opencv.lib_v24_x86");
|
||||
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
|
||||
EXPECT_EQ(info1, info2);
|
||||
@@ -167,7 +181,7 @@ TEST(PackageInfo, Comparator1)
|
||||
|
||||
TEST(PackageInfo, Comparator2)
|
||||
{
|
||||
PackageInfo info1("240", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3);
|
||||
PackageInfo info1(2040000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON | FEATURES_HAS_VFPv3);
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
PackageInfo info2("org.opencv.lib_v24_armv7a_neon", "/data/data/org.opencv.lib_v24_armv7a_neon");
|
||||
#else
|
||||
@@ -180,7 +194,7 @@ TEST(PackageInfo, Comparator2)
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
TEST(PackageInfo, Comparator3)
|
||||
{
|
||||
PackageInfo info1("230", PLATFORM_TEGRA3, 0);
|
||||
PackageInfo info1(2030000, PLATFORM_TEGRA3, 0);
|
||||
PackageInfo info2("org.opencv.lib_v23_tegra3", "/data/data/org.opencv.lib_v23_tegra3");
|
||||
EXPECT_STREQ(info1.GetFullName().c_str(), info2.GetFullName().c_str());
|
||||
EXPECT_EQ(info1, info2);
|
||||
|
||||
@@ -5,7 +5,6 @@
|
||||
#include "IOpenCVEngine.h"
|
||||
#include <utils/String16.h>
|
||||
#include <gtest/gtest.h>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@@ -14,52 +13,52 @@ using namespace std;
|
||||
TEST(PackageManager, InstalledVersions)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
pm.InstalledPackages.push_back(info);
|
||||
std::set<string> versions = pm.GetInstalledVersions();
|
||||
std::vector<int> versions = pm.GetInstalledVersions();
|
||||
EXPECT_EQ(1, versions.size());
|
||||
EXPECT_EQ("230", *versions.begin());
|
||||
EXPECT_EQ(2030000, *versions.begin());
|
||||
}
|
||||
|
||||
TEST(PackageManager, CheckVersionInstalled)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
pm.InstalledPackages.push_back(info);
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled("230", PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
}
|
||||
|
||||
TEST(PackageManager, InstallVersion)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
PackageInfo info("230", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
PackageInfo info(2030000, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
pm.InstalledPackages.push_back(info);
|
||||
EXPECT_TRUE(pm.InstallVersion("240", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
EXPECT_TRUE(pm.InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
EXPECT_EQ(2, pm.InstalledPackages.size());
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled("240", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
EXPECT_TRUE(pm.CheckVersionInstalled(2040000, PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv5)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
EXPECT_TRUE(pm.InstallVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
string path = pm.GetPackagePathByVersion(2040300, PLATFORM_UNKNOWN, ARCH_ARMv5);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_armv5/lib", path.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv7)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a/lib", path.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForArmv7Neon)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
#ifdef __SUPPORT_ARMEABI_V7A_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_armv7a_neon/lib", path.c_str());
|
||||
#else
|
||||
@@ -70,16 +69,16 @@ TEST(PackageManager, GetPackagePathForArmv7Neon)
|
||||
TEST(PackageManager, GetPackagePathForX86)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86/lib", path.c_str());
|
||||
}
|
||||
|
||||
TEST(PackageManager, GetPackagePathForX86SSE2)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_UNKNOWN, ARCH_X86 | FEATURES_HAS_SSE2);
|
||||
#ifdef __SUPPORT_INTEL_FEATURES
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_x86_sse2/lib", path.c_str());
|
||||
#else
|
||||
@@ -90,8 +89,8 @@ TEST(PackageManager, GetPackagePathForX86SSE2)
|
||||
TEST(PackageManager, GetPackagePathForTegra3)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion("230", PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_NEON);
|
||||
EXPECT_TRUE(pm.InstallVersion(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
|
||||
string path = pm.GetPackagePathByVersion(2030000, PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON);
|
||||
#ifdef __SUPPORT_TEGRA3
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v23_tegra3/lib", path.c_str());
|
||||
#else
|
||||
@@ -107,8 +106,8 @@ TEST(PackageManager, GetPackagePathForTegra3)
|
||||
TEST(PackageManager, GetPackagePathForMips)
|
||||
{
|
||||
PackageManagerStub pm;
|
||||
EXPECT_TRUE(pm.InstallVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS));
|
||||
string path = pm.GetPackagePathByVersion("243", PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_TRUE(pm.InstallVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS));
|
||||
string path = pm.GetPackagePathByVersion(2040000, PLATFORM_UNKNOWN, ARCH_MIPS);
|
||||
EXPECT_STREQ("/data/data/org.opencv.lib_v24_mips/lib", path.c_str());
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -299,10 +299,9 @@ public class ManagerActivity extends Activity
|
||||
else
|
||||
NativeLibDir = "/data/data/" + mInstalledPackageInfo[i].packageName + "/lib";
|
||||
|
||||
OpenCVLibraryInfo NativeInfo = new OpenCVLibraryInfo(NativeLibDir);
|
||||
|
||||
if (PackageName.equals("org.opencv.engine"))
|
||||
{
|
||||
OpenCVLibraryInfo NativeInfo = new OpenCVLibraryInfo(NativeLibDir);
|
||||
if (NativeInfo.status())
|
||||
{
|
||||
PublicName = "Built-in OpenCV library";
|
||||
@@ -348,9 +347,7 @@ public class ManagerActivity extends Activity
|
||||
|
||||
if (null != ActivePackagePath)
|
||||
{
|
||||
int start = ActivePackagePath.indexOf(mInstalledPackageInfo[i].packageName);
|
||||
int stop = start + mInstalledPackageInfo[i].packageName.length();
|
||||
if (start >= 0 && ActivePackagePath.charAt(stop) == '/')
|
||||
if (ActivePackagePath.equals(NativeLibDir))
|
||||
{
|
||||
temp.put("Activity", "y");
|
||||
Tags = "active";
|
||||
@@ -405,13 +402,22 @@ public class ManagerActivity extends Activity
|
||||
if (OpenCVersion == null || PackageVersion == null)
|
||||
return "unknown";
|
||||
|
||||
int dot = PackageVersion.indexOf(".");
|
||||
if (dot == -1 || OpenCVersion.length() == 0)
|
||||
String[] revisions = PackageVersion.split("\\.");
|
||||
|
||||
if (revisions.length <= 1 || OpenCVersion.length() == 0)
|
||||
return "unknown";
|
||||
else
|
||||
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
|
||||
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
|
||||
PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1);
|
||||
if (revisions.length == 2)
|
||||
// the 2nd digit is revision
|
||||
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
|
||||
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
|
||||
revisions[0] + " rev " + revisions[1];
|
||||
else
|
||||
// the 2nd digit is part of library version
|
||||
// the 3rd digit is revision
|
||||
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
|
||||
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
|
||||
revisions[0] + "." + revisions[1] + " rev " + revisions[2];
|
||||
}
|
||||
|
||||
protected String ConvertPackageName(String Name, String Version)
|
||||
|
||||
@@ -14,20 +14,20 @@ manually using adb tool:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
adb install OpenCV-2.4.3-android-sdk/apk/OpenCV_2.4.3.2_Manager_2.4_<platform>.apk
|
||||
adb install OpenCV-2.4.4-android-sdk/apk/OpenCV_2.4.4_Manager_2.6_<platform>.apk
|
||||
|
||||
Use the table below to determine proper OpenCV Manager package for your device:
|
||||
|
||||
+------------------------------+--------------+-----------------------------------------------------+
|
||||
| Hardware Platform | Android ver. | Package name |
|
||||
+==============================+==============+=====================================================+
|
||||
| armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_armv7a-neon.apk |
|
||||
+------------------------------+--------------+-----------------------------------------------------+
|
||||
| armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.3.2_Manager_2.4_armv7a-neon-android8.apk |
|
||||
+------------------------------+--------------+-----------------------------------------------------+
|
||||
| armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_armeabi.apk |
|
||||
+------------------------------+--------------+-----------------------------------------------------+
|
||||
| Intel x86 | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_x86.apk |
|
||||
+------------------------------+--------------+-----------------------------------------------------+
|
||||
| MIPS | >= 2.3 | OpenCV_2.4.3.2_Manager_2.4_mips.apk |
|
||||
+------------------------------+--------------+-----------------------------------------------------+
|
||||
+------------------------------+--------------+---------------------------------------------------+
|
||||
| Hardware Platform | Android ver. | Package name |
|
||||
+==============================+==============+===================================================+
|
||||
| armeabi-v7a (ARMv7-A + NEON) | >= 2.3 | OpenCV_2.4.4_Manager_2.6_armv7a-neon.apk |
|
||||
+------------------------------+--------------+---------------------------------------------------+
|
||||
| armeabi-v7a (ARMv7-A + NEON) | = 2.2 | OpenCV_2.4.4_Manager_2.6_armv7a-neon-android8.apk |
|
||||
+------------------------------+--------------+---------------------------------------------------+
|
||||
| armeabi (ARMv5, ARMv6) | >= 2.3 | OpenCV_2.4.4_Manager_2.6_armeabi.apk |
|
||||
+------------------------------+--------------+---------------------------------------------------+
|
||||
| Intel x86 | >= 2.3 | OpenCV_2.4.4_Manager_2.6_x86.apk |
|
||||
+------------------------------+--------------+---------------------------------------------------+
|
||||
| MIPS | >= 2.3 | OpenCV_2.4.4_Manager_2.6_mips.apk |
|
||||
+------------------------------+--------------+---------------------------------------------------+
|
||||
|
||||
@@ -97,7 +97,7 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif()
|
||||
|
||||
# We need pthread's
|
||||
if(UNIX AND NOT ANDROID)
|
||||
if(UNIX AND NOT ANDROID AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX))
|
||||
add_extra_compiler_option(-pthread)
|
||||
endif()
|
||||
|
||||
|
||||
@@ -33,13 +33,48 @@ if(CUDA_FOUND)
|
||||
|
||||
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")
|
||||
set(_generations "Fermi" "Kepler")
|
||||
if(NOT CMAKE_CROSSCOMPILING)
|
||||
list(APPEND _generations "Auto")
|
||||
endif()
|
||||
set(CUDA_GENERATION "" CACHE STRING "Build CUDA device code only for specific GPU architecture. Leave empty to build for all architectures.")
|
||||
if( CMAKE_VERSION VERSION_GREATER "2.8" )
|
||||
set_property( CACHE CUDA_GENERATION PROPERTY STRINGS "" ${_generations} )
|
||||
endif()
|
||||
|
||||
if(CUDA_GENERATION)
|
||||
if(NOT ";${_generations};" MATCHES ";${CUDA_GENERATION};")
|
||||
string(REPLACE ";" ", " _generations "${_generations}")
|
||||
message(FATAL_ERROR "ERROR: ${_generations} Generations are suppered.")
|
||||
endif()
|
||||
unset(CUDA_ARCH_BIN CACHE)
|
||||
unset(CUDA_ARCH_PTX CACHE)
|
||||
endif()
|
||||
|
||||
set(__cuda_arch_ptx "")
|
||||
if(CUDA_GENERATION STREQUAL "Fermi")
|
||||
set(__cuda_arch_bin "2.0 2.1(2.0)")
|
||||
elseif(CUDA_GENERATION STREQUAL "Kepler")
|
||||
set(__cuda_arch_bin "3.0")
|
||||
elseif(CUDA_GENERATION STREQUAL "Auto")
|
||||
execute_process( COMMAND "${CUDA_NVCC_EXECUTABLE}" "${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCudaArch.cu" "--run"
|
||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/"
|
||||
RESULT_VARIABLE _nvcc_res OUTPUT_VARIABLE _nvcc_out
|
||||
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
if(NOT _nvcc_res EQUAL 0)
|
||||
message(STATUS "Automatic detection of CUDA generation failed. Going to build for all known architectures.")
|
||||
else()
|
||||
set(__cuda_arch_bin "${_nvcc_out}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED __cuda_arch_bin)
|
||||
set(__cuda_arch_bin "1.1 1.2 1.3 2.0 2.1(2.0) 3.0")
|
||||
set(__cuda_arch_ptx "2.0 3.0")
|
||||
endif()
|
||||
|
||||
set(CUDA_ARCH_BIN ${__cuda_arch_bin} CACHE STRING "Specify 'real' GPU architectures to build binaries for, BIN(PTX) format is supported")
|
||||
set(CUDA_ARCH_PTX ${__cuda_arch_ptx} CACHE STRING "Specify 'virtual' PTX architectures to build PTX intermediate code for")
|
||||
|
||||
string(REGEX REPLACE "\\." "" ARCH_BIN_NO_POINTS "${CUDA_ARCH_BIN}")
|
||||
string(REGEX REPLACE "\\." "" ARCH_PTX_NO_POINTS "${CUDA_ARCH_PTX}")
|
||||
@@ -83,13 +118,8 @@ if(CUDA_FOUND)
|
||||
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()
|
||||
|
||||
if(${CMAKE_SYSTEM_PROCESSOR} STREQUAL "arm")
|
||||
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} --target-cpu-architecture=ARM")
|
||||
endif()
|
||||
|
||||
# These vars will be processed in other scripts
|
||||
|
||||
@@ -5,15 +5,17 @@ if(CMAKE_CL_64)
|
||||
set(MSVC64 1)
|
||||
endif()
|
||||
|
||||
if(NOT APPLE)
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
||||
set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_GNUCC 1)
|
||||
set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_GNUCXX 1)
|
||||
set(CMAKE_COMPILER_IS_CLANGCXX 1)
|
||||
endif()
|
||||
if(CMAKE_C_COMPILER_ID STREQUAL "Clang")
|
||||
set(CMAKE_COMPILER_IS_GNUCC 1)
|
||||
set(CMAKE_COMPILER_IS_CLANGCC 1)
|
||||
endif()
|
||||
|
||||
if((CMAKE_COMPILER_IS_CLANGCXX OR CMAKE_COMPILER_IS_CLANGCC) AND NOT CMAKE_GENERATOR MATCHES "Xcode")
|
||||
set(ENABLE_PRECOMPILED_HEADERS OFF CACHE BOOL "" FORCE)
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@@ -44,16 +46,24 @@ if(MSVC AND CMAKE_C_COMPILER MATCHES "icc")
|
||||
set(CV_ICC __INTEL_COMPILER_FOR_WINDOWS)
|
||||
endif()
|
||||
|
||||
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR (UNIX AND CV_ICC))
|
||||
set(CV_COMPILER_IS_GNU TRUE)
|
||||
else()
|
||||
set(CV_COMPILER_IS_GNU FALSE)
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect GNU version:
|
||||
# ----------------------------------------------------------------------------
|
||||
if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
if(CMAKE_COMPILER_IS_CLANGCXX)
|
||||
set(CMAKE_GCC_REGEX_VERSION "4.2.1")
|
||||
set(CMAKE_OPENCV_GCC_VERSION_MAJOR 4)
|
||||
set(CMAKE_OPENCV_GCC_VERSION_MINOR 2)
|
||||
set(CMAKE_OPENCV_GCC_VERSION 42)
|
||||
set(CMAKE_OPENCV_GCC_VERSION_NUM 402)
|
||||
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -v
|
||||
ERROR_VARIABLE CMAKE_OPENCV_CLANG_VERSION_FULL
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
string(REGEX MATCH "version.*$" CMAKE_OPENCV_CLANG_VERSION_FULL "${CMAKE_OPENCV_CLANG_VERSION_FULL}")
|
||||
string(REGEX MATCH "[0-9]+\\.[0-9]+" CMAKE_CLANG_REGEX_VERSION "${CMAKE_OPENCV_CLANG_VERSION_FULL}")
|
||||
|
||||
elseif(CMAKE_COMPILER_IS_GNUCXX)
|
||||
execute_process(COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1} -dumpversion
|
||||
OUTPUT_VARIABLE CMAKE_OPENCV_GCC_VERSION_FULL
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
#include <stdio.h>
|
||||
int main()
|
||||
{
|
||||
int count = 0;
|
||||
if (cudaSuccess != cudaGetDeviceCount(&count)){return -1;}
|
||||
if (count == 0) {return -1;}
|
||||
for (int device = 0; device < count; ++device)
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
if (cudaSuccess != cudaGetDeviceProperties(&prop, device)){ continue;}
|
||||
printf("%d.%d ", prop.major, prop.minor);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -81,6 +81,7 @@ else()
|
||||
set(ENV_AMDAPPSDKROOT $ENV{AMDAPPSDKROOT})
|
||||
set(ENV_OPENCLROOT $ENV{OPENCLROOT})
|
||||
set(ENV_CUDA_PATH $ENV{CUDA_PATH})
|
||||
set(ENV_INTELOCLSDKROOT $ENV{INTELOCLSDKROOT})
|
||||
if(ENV_AMDSTREAMSDKROOT)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_AMDAPPSDKROOT}/include)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
@@ -109,6 +110,13 @@ else()
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} /usr/lib64)
|
||||
endif()
|
||||
elseif(ENV_INTELOCLSDKROOT)
|
||||
set(OPENCL_INCLUDE_SEARCH_PATH ${ENV_INTELOCLSDKROOT}/include)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_INTELOCLSDKROOT}/lib/x86)
|
||||
else()
|
||||
set(OPENCL_LIB_SEARCH_PATH ${OPENCL_LIB_SEARCH_PATH} ${ENV_INTELOCLSDKROOT}/lib/x64)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(OPENCL_INCLUDE_SEARCH_PATH)
|
||||
|
||||
@@ -19,18 +19,25 @@ unset(HAVE_SPHINX CACHE)
|
||||
if(PYTHON_EXECUTABLE)
|
||||
if(PYTHON_VERSION_STRING)
|
||||
set(PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")
|
||||
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" PYTHON_VERSION_FULL "${PYTHON_VERSION_STRING}")
|
||||
set(PYTHON_VERSION_FULL "${PYTHON_VERSION_STRING}")
|
||||
else()
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} --version
|
||||
ERROR_VARIABLE PYTHON_VERSION_FULL
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
string(REGEX MATCH "[0-9]+.[0-9]+" PYTHON_VERSION_MAJOR_MINOR "${PYTHON_VERSION_FULL}")
|
||||
string(REGEX MATCH "[0-9]+.[0-9]+.[0-9]+" PYTHON_VERSION_FULL "${PYTHON_VERSION_FULL}")
|
||||
endif()
|
||||
|
||||
if("${PYTHON_VERSION_FULL}" MATCHES "[0-9]+.[0-9]+.[0-9]+")
|
||||
set(PYTHON_VERSION_FULL "${CMAKE_MATCH_0}")
|
||||
elseif("${PYTHON_VERSION_FULL}" MATCHES "[0-9]+.[0-9]+")
|
||||
set(PYTHON_VERSION_FULL "${CMAKE_MATCH_0}")
|
||||
else()
|
||||
unset(PYTHON_VERSION_FULL)
|
||||
endif()
|
||||
|
||||
if(NOT ANDROID AND NOT IOS)
|
||||
if(CMAKE_VERSION VERSION_GREATER 2.8.8)
|
||||
if(CMAKE_VERSION VERSION_GREATER 2.8.8 AND PYTHON_VERSION_FULL)
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL} EXACT)
|
||||
else()
|
||||
find_host_package(PythonLibs ${PYTHON_VERSION_FULL})
|
||||
|
||||
@@ -7,11 +7,6 @@ if(WITH_TBB)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake")
|
||||
endif(WITH_TBB)
|
||||
|
||||
# --- C= ---
|
||||
if(WITH_CSTRIPES)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake")
|
||||
endif(WITH_CSTRIPES)
|
||||
|
||||
# --- IPP ---
|
||||
ocv_clear_vars(IPP_FOUND)
|
||||
if(WITH_IPP)
|
||||
@@ -43,3 +38,35 @@ if(WITH_EIGEN)
|
||||
set(HAVE_EIGEN 1)
|
||||
endif()
|
||||
endif(WITH_EIGEN)
|
||||
|
||||
# --- C= ---
|
||||
if(WITH_CSTRIPES AND NOT HAVE_TBB)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCStripes.cmake")
|
||||
else()
|
||||
set(HAVE_CSTRIPES 0)
|
||||
endif()
|
||||
|
||||
# --- OpenMP ---
|
||||
if(NOT HAVE_TBB AND NOT HAVE_CSTRIPES)
|
||||
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/omptest.cpp")
|
||||
FILE(WRITE "${_fname}" "#ifndef _OPENMP\n#error\n#endif\nint main() { return 0; }\n")
|
||||
TRY_COMPILE(HAVE_OPENMP "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp" "${_fname}")
|
||||
else()
|
||||
set(HAVE_OPENMP 0)
|
||||
endif()
|
||||
|
||||
# --- GCD ---
|
||||
if(APPLE AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES AND NOT HAVE_OPENMP)
|
||||
set(HAVE_GCD 1)
|
||||
else()
|
||||
set(HAVE_GCD 0)
|
||||
endif()
|
||||
|
||||
# --- Concurrency ---
|
||||
if(MSVC AND NOT HAVE_TBB AND NOT HAVE_CSTRIPES AND NOT HAVE_OPENMP)
|
||||
set(_fname "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/concurrencytest.cpp")
|
||||
FILE(WRITE "${_fname}" "#if _MSC_VER < 1600\n#error\n#endif\nint main() { return 0; }\n")
|
||||
TRY_COMPILE(HAVE_CONCURRENCY "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp" "${_fname}")
|
||||
else()
|
||||
set(HAVE_CONCURRENCY 0)
|
||||
endif()
|
||||
|
||||
@@ -20,7 +20,7 @@ if(ANDROID)
|
||||
endif()
|
||||
|
||||
# setup lists of camera libs
|
||||
foreach(abi ARMEABI ARMEABI_V7A X86)
|
||||
foreach(abi ARMEABI ARMEABI_V7A X86 MIPS)
|
||||
ANDROID_GET_ABI_RAWNAME(${abi} ndkabi)
|
||||
if(BUILD_ANDROID_CAMERA_WRAPPER)
|
||||
if(ndkabi STREQUAL ANDROID_NDK_ABI_NAME)
|
||||
|
||||
@@ -53,6 +53,10 @@ if(OpenCV_LIB_COMPONENTS)
|
||||
list(REMOVE_ITEM OPENCV_MODULES_CONFIGCMAKE ${OpenCV_LIB_COMPONENTS})
|
||||
endif()
|
||||
|
||||
if(BUILD_FAT_JAVA_LIB AND HAVE_opencv_java)
|
||||
list(APPEND OPENCV_MODULES_CONFIGCMAKE opencv_java)
|
||||
endif()
|
||||
|
||||
macro(ocv_generate_dependencies_map_configcmake suffix configuration)
|
||||
set(OPENCV_DEPENDENCIES_MAP_${suffix} "")
|
||||
set(OPENCV_PROCESSED_LIBS "")
|
||||
@@ -126,8 +130,13 @@ configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.
|
||||
set(OpenCV_INCLUDE_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}/opencv" "\${OpenCV_INSTALL_PATH}/${OPENCV_INCLUDE_INSTALL_PATH}\"")
|
||||
|
||||
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
|
||||
set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_LIB_INSTALL_PATH}\"")
|
||||
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"")
|
||||
if(ANDROID)
|
||||
set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/sdk/native/libs/\${ANDROID_NDK_ABI_NAME}\"")
|
||||
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/sdk/native/3rdparty/libs/\${ANDROID_NDK_ABI_NAME}\"")
|
||||
else()
|
||||
set(OpenCV_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_LIB_INSTALL_PATH}\"")
|
||||
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OPENCV_3P_LIB_INSTALL_PATH}\"")
|
||||
endif()
|
||||
if(INSTALL_TO_MANGLED_PATHS)
|
||||
string(REPLACE "OpenCV" "OpenCV-${OPENCV_VERSION}" OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "${OPENCV_3P_LIB_INSTALL_PATH}")
|
||||
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE}\"")
|
||||
|
||||
@@ -141,7 +141,7 @@ macro(ocv_warnings_disable)
|
||||
set(${var} "${${var}} ${warning}")
|
||||
endforeach()
|
||||
endforeach()
|
||||
elseif(CV_COMPILER_IS_GNU AND _gxx_warnings AND _flag_vars)
|
||||
elseif((CMAKE_COMPILER_IS_GNUCXX OR (UNIX AND CV_ICC)) AND _gxx_warnings AND _flag_vars)
|
||||
foreach(var ${_flag_vars})
|
||||
foreach(warning ${_gxx_warnings})
|
||||
if(NOT warning MATCHES "^-Wno-")
|
||||
|
||||
@@ -42,7 +42,7 @@ else
|
||||
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI),mips)
|
||||
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB@
|
||||
OPENCV_3RDPARTY_COMPONENTS:=@OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE@
|
||||
OPENCV_EXTRA_COMPONENTS:=@OPENCV_EXTRA_COMPONENTS_CONFIGMAKE@
|
||||
endif
|
||||
endif
|
||||
@@ -57,6 +57,9 @@ ifeq (${OPENCV_CAMERA_MODULES},on)
|
||||
ifeq ($(TARGET_ARCH_ABI),x86)
|
||||
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_X86_CONFIGCMAKE@
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI),mips)
|
||||
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_MIPS_CONFIGCMAKE@
|
||||
endif
|
||||
else
|
||||
OPENCV_CAMERA_MODULES:=
|
||||
endif
|
||||
@@ -89,7 +92,7 @@ define add_opencv_camera_module
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
endef
|
||||
|
||||
ifeq ($(OPENCV_MK_ALREADY_INCLUDED),)
|
||||
ifeq ($(OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED),)
|
||||
ifeq ($(OPENCV_INSTALL_MODULES),on)
|
||||
$(foreach module,$(OPENCV_LIBS),$(eval $(call add_opencv_module,$(module))))
|
||||
endif
|
||||
@@ -102,7 +105,7 @@ ifeq ($(OPENCV_MK_ALREADY_INCLUDED),)
|
||||
endif
|
||||
|
||||
#turn off module installation to prevent their redefinition
|
||||
OPENCV_MK_ALREADY_INCLUDED:=on
|
||||
OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED:=on
|
||||
endif
|
||||
|
||||
ifeq ($(OPENCV_LOCAL_CFLAGS),)
|
||||
|
||||
@@ -151,6 +151,7 @@ endif()
|
||||
# ==============================================================
|
||||
if(NOT OpenCV_FIND_COMPONENTS)
|
||||
set(OpenCV_FIND_COMPONENTS ${OpenCV_LIB_COMPONENTS})
|
||||
list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_java)
|
||||
if(GTest_FOUND OR GTEST_FOUND)
|
||||
list(REMOVE_ITEM OpenCV_FIND_COMPONENTS opencv_ts)
|
||||
endif()
|
||||
@@ -201,7 +202,7 @@ foreach(__opttype OPT DBG)
|
||||
#indicate that this module is also found
|
||||
string(TOUPPER "${__cvdep}" __cvdep)
|
||||
set(${__cvdep}_FOUND 1)
|
||||
else()
|
||||
elseif(EXISTS "${OpenCV_3RDPARTY_LIB_DIR_${__opttype}}/${OpenCV_${__cvdep}_LIBNAME_${__opttype}}")
|
||||
list(APPEND OpenCV_LIBS_${__opttype} "${OpenCV_3RDPARTY_LIB_DIR_${__opttype}}/${OpenCV_${__cvdep}_LIBNAME_${__opttype}}")
|
||||
endif()
|
||||
endforeach()
|
||||
@@ -219,18 +220,14 @@ foreach(__opttype OPT DBG)
|
||||
else()
|
||||
#TODO: duplicates are annoying but they should not be the problem
|
||||
endif()
|
||||
|
||||
|
||||
# CUDA
|
||||
if(OpenCV_CUDA_VERSION AND (CARMA OR (WIN32 AND NOT OpenCV_SHARED)))
|
||||
if(OpenCV_CUDA_VERSION AND (CMAKE_CROSSCOMPILING 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)
|
||||
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()
|
||||
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}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -308,3 +305,11 @@ else()
|
||||
SET(OpenCV_LIB_DIR ${OpenCV_LIB_DIR_OPT} ${OpenCV_3RDPARTY_LIB_DIR_OPT})
|
||||
endif()
|
||||
set(OpenCV_LIBRARIES ${OpenCV_LIBS})
|
||||
|
||||
if(CMAKE_CROSSCOMPILING AND OpenCV_SHARED AND (CMAKE_SYSTEM_NAME MATCHES "Linux"))
|
||||
foreach(dir ${OpenCV_LIB_DIR})
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,-rpath-link,${dir}")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-rpath-link,${dir}")
|
||||
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -Wl,-rpath-link,${dir}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
@@ -38,7 +38,7 @@ doc_signatures_whitelist = [
|
||||
"CvArr", "CvFileStorage",
|
||||
# other
|
||||
"InputArray", "OutputArray",
|
||||
]
|
||||
] + ["CvSubdiv2D", "CvQuadEdge2D", "CvSubdiv2DPoint", "cvDrawContours"]
|
||||
|
||||
defines = ["cvGraphEdgeIdx", "cvFree", "CV_Assert", "cvSqrt", "cvGetGraphVtx", "cvGraphVtxIdx",
|
||||
"cvCaptureFromFile", "cvCaptureFromCAM", "cvCalcBackProjectPatch", "cvCalcBackProject",
|
||||
|
||||
@@ -992,6 +992,11 @@ class DefinitionParser(object):
|
||||
return rv
|
||||
|
||||
def _parse_signature(self):
|
||||
if r'CvStatModel::train' in self.definition:
|
||||
# hack to skip parsing of problematic definition
|
||||
self.pos = self.end
|
||||
return [ArgumentDefExpr("const Mat&", "train_data", None), ArgumentDefExpr(None, self.definition[self.definition.find("["):-1], None)], False, True
|
||||
|
||||
self.skip_ws()
|
||||
if not self.skip_string('('):
|
||||
self.fail('expected parentheses for function')
|
||||
@@ -1075,6 +1080,17 @@ class DefinitionParser(object):
|
||||
value = None
|
||||
return MemberObjDefExpr(name, visibility, static, typename, value)
|
||||
|
||||
def parse_enum_member_object(self):
|
||||
visibility, static = self._parse_visibility_static()
|
||||
typename = None
|
||||
name = self._parse_type()
|
||||
self.skip_ws()
|
||||
if self.skip_string('='):
|
||||
value = self.read_rest().strip()
|
||||
else:
|
||||
value = None
|
||||
return MemberObjDefExpr(name, visibility, static, typename, value)
|
||||
|
||||
def parse_function(self):
|
||||
visibility, static = self._parse_visibility_static()
|
||||
if self.skip_word('explicit'):
|
||||
@@ -1180,6 +1196,8 @@ class OCVObject(ObjectDescription):
|
||||
def add_target_and_index(self, sigobj, sig, signode):
|
||||
theid = sig#obj.get_id()
|
||||
theid = re.sub(r" +", " ", theid)
|
||||
if self.objtype == 'emember':
|
||||
theid = re.sub(r" ?=.*", "", theid)
|
||||
theid = re.sub(r"=[^,()]+\([^)]*?\)[^,)]*(,|\))", "\\1", theid)
|
||||
theid = re.sub(r"=\w*[^,)(]+(,|\))", "\\1", theid)
|
||||
theid = theid.replace("( ", "(").replace(" )", ")")
|
||||
@@ -1293,6 +1311,25 @@ class OCVTypeObject(OCVObject):
|
||||
signode += nodes.Text(' ')
|
||||
self.attach_name(signode, obj.name)
|
||||
|
||||
class OCVEnumObject(OCVObject):
|
||||
|
||||
def get_index_text(self, name):
|
||||
if self.objtype == 'enum':
|
||||
return _('%s (enum)') % name
|
||||
return ''
|
||||
|
||||
def parse_definition(self, parser):
|
||||
return parser.parse_type_object()
|
||||
|
||||
def describe_signature(self, signode, obj):
|
||||
self.attach_modifiers(signode, obj)
|
||||
signode += addnodes.desc_annotation('enum ', 'enum ')
|
||||
if obj.typename is not None:
|
||||
self.attach_type(signode, obj.typename)
|
||||
signode += nodes.Text(' ')
|
||||
self.attach_name(signode, obj.name)
|
||||
|
||||
|
||||
class OCVMemberObject(OCVObject):
|
||||
ismember = True
|
||||
|
||||
@@ -1309,12 +1346,20 @@ class OCVMemberObject(OCVObject):
|
||||
|
||||
def describe_signature(self, signode, obj):
|
||||
self.attach_modifiers(signode, obj)
|
||||
self.attach_type(signode, obj.typename)
|
||||
signode += nodes.Text(' ')
|
||||
if obj.typename:
|
||||
self.attach_type(signode, obj.typename)
|
||||
signode += nodes.Text(' ')
|
||||
self.attach_name(signode, obj.name)
|
||||
if obj.value is not None:
|
||||
signode += nodes.Text(u' = ' + obj.value)
|
||||
|
||||
class OCVEnumMemberObject(OCVMemberObject):
|
||||
def parse_definition(self, parser):
|
||||
# parent_class = self.env.temp_data.get('ocv:parent')
|
||||
# if parent_class is None:
|
||||
# parser.fail("missing parent structure/class")
|
||||
return parser.parse_enum_member_object()
|
||||
|
||||
class OCVFunctionObject(OCVObject):
|
||||
|
||||
def attach_function(self, node, func):
|
||||
@@ -1448,7 +1493,9 @@ class OCVDomain(Domain):
|
||||
'pyfunction': ObjType(l_('pyfunction'), 'pyfunc'),
|
||||
'pyoldfunction': ObjType(l_('pyoldfunction'), 'pyoldfunc'),
|
||||
'member': ObjType(l_('member'), 'member'),
|
||||
'type': ObjType(l_('type'), 'type')
|
||||
'emember': ObjType(l_('emember'), 'emember'),
|
||||
'type': ObjType(l_('type'), 'type'),
|
||||
'enum': ObjType(l_('enum'), 'enum')
|
||||
}
|
||||
|
||||
directives = {
|
||||
@@ -1460,7 +1507,9 @@ class OCVDomain(Domain):
|
||||
'pyfunction': OCVPyModulelevel,
|
||||
'pyoldfunction': OCVPyOldModulelevel,
|
||||
'member': OCVMemberObject,
|
||||
'emember': OCVEnumMemberObject,
|
||||
'type': OCVTypeObject,
|
||||
'enum': OCVEnumObject,
|
||||
'namespace': OCVCurrentNamespace
|
||||
}
|
||||
roles = {
|
||||
@@ -1475,7 +1524,9 @@ class OCVDomain(Domain):
|
||||
'pyfunc' : OCVPyXRefRole(),
|
||||
'pyoldfunc' : OCVPyXRefRole(),
|
||||
'member': OCVXRefRole(),
|
||||
'type': OCVXRefRole()
|
||||
'emember': OCVXRefRole(),
|
||||
'type': OCVXRefRole(),
|
||||
'enum': OCVXRefRole()
|
||||
}
|
||||
initial_data = {
|
||||
'objects': {}, # fullname -> docname, objtype
|
||||
@@ -1563,7 +1614,9 @@ class OCVDomain(Domain):
|
||||
'pyfunction': _('Python function'),
|
||||
'pyoldfunction': _('Legacy Python function'),
|
||||
'member': _('C++ member'),
|
||||
'emember': _('enum member'),
|
||||
'type': _('C/C++ type'),
|
||||
'enum': _('C/C++ enum'),
|
||||
'namespace': _('C++ namespace'),
|
||||
}.get(type.lname, _('%s %s') % (self.label, type.lname))
|
||||
|
||||
|
||||
@@ -53,8 +53,8 @@ As usual, after the not-so-lengthy explanation, let's go to the code:
|
||||
std::cout<<"* Enter alpha [0-1]: ";
|
||||
std::cin>>input;
|
||||
|
||||
/// We use the alpha provided by the user iff it is between 0 and 1
|
||||
if( alpha >= 0 && alpha <= 1 )
|
||||
/// We use the alpha provided by the user if it is between 0 and 1
|
||||
if( input >= 0.0 && input <= 1.0 )
|
||||
{ alpha = input; }
|
||||
|
||||
/// Read image ( same size, same type )
|
||||
|
||||
@@ -8,4 +8,6 @@
|
||||
.. |Author_FernandoI| unicode:: Fernando U+0020 Iglesias U+0020 Garc U+00ED a
|
||||
.. |Author_EduardF| unicode:: Eduard U+0020 Feicho
|
||||
.. |Author_AlexB| unicode:: Alexandre U+0020 Benoit
|
||||
|
||||
.. |Author_EricCh| unicode:: Eric U+0020 Christiansen
|
||||
.. |Author_AndreyP| unicode:: Andrey U+0020 Pavlenko
|
||||
.. |Author_AlexS| unicode:: Alexander U+0020 Smorkalov
|
||||
|
||||
@@ -48,10 +48,10 @@ The structure of package contents looks as follows:
|
||||
|
||||
::
|
||||
|
||||
OpenCV-2.4.3-android-sdk
|
||||
OpenCV-2.4.4-android-sdk
|
||||
|_ apk
|
||||
| |_ OpenCV_2.4.3_binary_pack_armv7a.apk
|
||||
| |_ OpenCV_2.4.3_Manager_2.0_XXX.apk
|
||||
| |_ OpenCV_2.4.4_binary_pack_armv7a.apk
|
||||
| |_ OpenCV_2.4.4_Manager_2.6_XXX.apk
|
||||
|
|
||||
|_ doc
|
||||
|_ samples
|
||||
@@ -157,10 +157,10 @@ Get the OpenCV4Android SDK
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
unzip ~/Downloads/OpenCV-2.4.3-android-sdk.zip
|
||||
unzip ~/Downloads/OpenCV-2.4.4-android-sdk.zip
|
||||
|
||||
.. |opencv_android_bin_pack| replace:: OpenCV-2.4.3.2-android-sdk.zip
|
||||
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.3/OpenCV-2.4.3.2-android-sdk.zip/download
|
||||
.. |opencv_android_bin_pack| replace:: :file:`OpenCV-2.4.4-android-sdk.zip`
|
||||
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.4/OpenCV-2.4.4-android-sdk.zip/download
|
||||
.. |opencv_android_bin_pack_url| replace:: |opencv_android_bin_pack|
|
||||
.. |seven_zip| replace:: 7-Zip
|
||||
.. _seven_zip: http://www.7-zip.org/
|
||||
@@ -184,7 +184,7 @@ Import OpenCV library and samples to the Eclipse
|
||||
You can simply reference it in your projects.
|
||||
|
||||
Each sample included into the |opencv_android_bin_pack| is a regular Android project that already
|
||||
references OpenCV library.Follow the steps below to import OpenCV and samples into the workspace:
|
||||
references OpenCV library. Follow the steps below to import OpenCV and samples into the workspace:
|
||||
|
||||
.. note:: OpenCV samples are indeed **dependent** on OpenCV library project so don't forget to import it to your workspace as well.
|
||||
|
||||
@@ -246,8 +246,8 @@ Running OpenCV Samples
|
||||
----------------------
|
||||
|
||||
At this point you should be able to build and run the samples. Keep in mind, that
|
||||
``face-detection``, ``Tutorial 3` and ``Tutorial 4`` include some native code and
|
||||
require Android NDK and CDT plugin for Eclipse to build working applications. If you haven't
|
||||
``face-detection`` and ``Tutorial 2 - Mixed Processing`` include some native code and
|
||||
require Android NDK and NDK/CDT plugin for Eclipse to build working applications. If you haven't
|
||||
installed these tools, see the corresponding section of :ref:`Android_Dev_Intro`.
|
||||
|
||||
.. warning:: Please consider that some samples use Android Java Camera API, which is accessible
|
||||
@@ -295,7 +295,7 @@ Well, running samples from Eclipse is very simple:
|
||||
.. code-block:: sh
|
||||
:linenos:
|
||||
|
||||
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.3_Manager_armv7a-neon.apk
|
||||
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.4_Manager_2.6_armv7a-neon.apk
|
||||
|
||||
.. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for
|
||||
platform targets:
|
||||
@@ -326,15 +326,16 @@ Well, running samples from Eclipse is very simple:
|
||||
|
||||
When done, you will be able to run OpenCV samples on your device/emulator seamlessly.
|
||||
|
||||
* Here is ``Tutorial 2 - Use OpenCV Camera`` sample, running on top of stock camera-preview of the emulator.
|
||||
* Here is ``Sample - image-manipulations`` sample, running on top of stock camera-preview of the emulator.
|
||||
|
||||
.. image:: images/emulator_canny.png
|
||||
:height: 600px
|
||||
:alt: Tutorial 1 Basic - 1. Add OpenCV - running Canny
|
||||
:alt: 'Sample - image-manipulations' running Canny
|
||||
:align: center
|
||||
|
||||
|
||||
What's next
|
||||
===========
|
||||
|
||||
Now, when you have your instance of OpenCV4Adroid SDK set up and configured, you may want to proceed to using OpenCV in your own application. You can learn how to do that in a separate :ref:`dev_with_OCV_on_Android` tutorial.
|
||||
Now, when you have your instance of OpenCV4Adroid SDK set up and configured,
|
||||
you may want to proceed to using OpenCV in your own application.
|
||||
You can learn how to do that in a separate :ref:`dev_with_OCV_on_Android` tutorial.
|
||||
|
||||
@@ -103,8 +103,8 @@ You need the following software to be installed in order to develop for Android
|
||||
|
||||
Here is Google's `install guide <http://developer.android.com/sdk/installing.html>`_ for the SDK.
|
||||
|
||||
.. note:: You can choose downloading ``ADT Bundle package`` that in addition to Android SDK Tools includes
|
||||
Eclipse + ADT + CDT plugins, Android Platform-tools, the latest Android platform and the latest
|
||||
.. note:: You can choose downloading **ADT Bundle package** that in addition to Android SDK Tools includes
|
||||
Eclipse + ADT + NDK/CDT plugins, Android Platform-tools, the latest Android platform and the latest
|
||||
Android system image for the emulator - this is the best choice for those who is setting up Android
|
||||
development environment the first time!
|
||||
|
||||
@@ -112,15 +112,15 @@ You need the following software to be installed in order to develop for Android
|
||||
for use on amd64 and ia64 systems to be installed. You can install them with the
|
||||
following command:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get install ia32-libs
|
||||
sudo apt-get install ia32-libs
|
||||
|
||||
For Red Hat based systems the following command might be helpful:
|
||||
For Red Hat based systems the following command might be helpful:
|
||||
|
||||
.. code-block:: bash
|
||||
.. code-block:: bash
|
||||
|
||||
sudo yum install libXtst.i386
|
||||
sudo yum install libXtst.i386
|
||||
|
||||
#. **Android SDK components**
|
||||
|
||||
@@ -148,7 +148,7 @@ You need the following software to be installed in order to develop for Android
|
||||
|
||||
Check the `Android SDK System Requirements <http://developer.android.com/sdk/requirements.html>`_
|
||||
document for a list of Eclipse versions that are compatible with the Android SDK.
|
||||
For OpenCV 2.4.x we recommend **Eclipse 3.7 (Indigo)** or later versions. They work well for
|
||||
For OpenCV 2.4.x we recommend **Eclipse 3.7 (Indigo)** or **Eclipse 4.2 (Juno)**. They work well for
|
||||
OpenCV under both Windows and Linux.
|
||||
|
||||
If you have no Eclipse installed, you can get it from the `official site <http://www.eclipse.org/downloads/>`_.
|
||||
@@ -210,9 +210,9 @@ You need the following software to be installed in order to develop for Android
|
||||
.. note:: Before start you can read official Android NDK documentation which is in the Android
|
||||
NDK archive, in the folder :file:`docs/`.
|
||||
The main article about using Android NDK build system is in the :file:`ANDROID-MK.html` file.
|
||||
Some additional information you can find in the :file:`APPLICATION-MK.html`,
|
||||
:file:`NDK-BUILD.html` files, and :file:`CPU-ARM-NEON.html`, :file:`CPLUSPLUS-SUPPORT.html`,
|
||||
:file:`PREBUILTS.html`.
|
||||
Some additional information you can find in
|
||||
the :file:`APPLICATION-MK.html`, :file:`NDK-BUILD.html` files,
|
||||
and :file:`CPU-ARM-NEON.html`, :file:`CPLUSPLUS-SUPPORT.html`, :file:`PREBUILTS.html`.
|
||||
|
||||
#. **CDT plugin for Eclipse**
|
||||
|
||||
|
||||
@@ -55,14 +55,14 @@ Manager to access OpenCV libraries externally installed in the target system.
|
||||
:guilabel:`File -> Import -> Existing project in your workspace`.
|
||||
|
||||
Press :guilabel:`Browse` button and locate OpenCV4Android SDK
|
||||
(:file:`OpenCV-2.4.3-android-sdk/sdk`).
|
||||
(:file:`OpenCV-2.4.4-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``.
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.4``.
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency1.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
@@ -128,27 +128,27 @@ 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`,
|
||||
press :guilabel:`Browse` button and select OpenCV SDK path
|
||||
(:file:`OpenCV-2.4.3-android-sdk/sdk`).
|
||||
(:file:`OpenCV-2.4.4-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``;
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.4``;
|
||||
|
||||
.. 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
|
||||
native libs from :file:`<OpenCV-2.4.4-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"``
|
||||
``"include path_to_OpenCV-2.4.4-android-sdk/sdk/native/jni/OpenCV.mk"``
|
||||
|
||||
.. code-block:: make
|
||||
:linenos:
|
||||
@@ -221,7 +221,7 @@ taken:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
include C:\Work\OpenCV4Android\OpenCV-2.4.3-android-sdk\sdk\native\jni\OpenCV.mk
|
||||
include C:\Work\OpenCV4Android\OpenCV-2.4.4-android-sdk\sdk\native\jni\OpenCV.mk
|
||||
|
||||
Should be inserted into the :file:`jni/Android.mk` file **after** this line:
|
||||
|
||||
@@ -382,7 +382,7 @@ result.
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_3, this, mLoaderCallback);
|
||||
}
|
||||
|
||||
#. Defines that your activity implements CvViewFrameListener interface and fix activity related
|
||||
#. Defines that your activity implements ``CvViewFrameListener2`` 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.
|
||||
@@ -423,8 +423,8 @@ result.
|
||||
public void onCameraViewStopped() {
|
||||
}
|
||||
|
||||
public Mat onCameraFrame(Mat inputFrame) {
|
||||
return inputFrame;
|
||||
public Mat onCameraFrame(CvCameraViewFrame inputFrame) {
|
||||
return inputFrame.rgba();
|
||||
}
|
||||
|
||||
#. Run your application on device or emulator.
|
||||
@@ -432,7 +432,7 @@ result.
|
||||
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
|
||||
preview from camera and implements ``CvViewFrameListener2`` interface to get frames from camera and
|
||||
process it.
|
||||
|
||||
First of all we create our application view using xml layout. Our layout consists of the only
|
||||
@@ -448,8 +448,13 @@ After creating layout we need to implement ``Activity`` class. OpenCV initializa
|
||||
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.
|
||||
callback function and it is called on retrieving frame from camera. The callback input is object
|
||||
of ``CvCameraViewFrame`` class that represents frame from camera.
|
||||
|
||||
.. note::
|
||||
Do not save or use ``CvCameraViewFrame`` object out of ``onCameraFrame`` callback. This object
|
||||
does not have its own state and its behavior out of callback is unpredictable!
|
||||
|
||||
It has ``rgba()`` and ``gray()`` methods that allows to get frame as RGBA and one channel gray scale
|
||||
``Mat`` respectively. It expects that ``onCameraFrame`` function returns RGBA frame that will be
|
||||
drawn on the screen.
|
||||
|
||||
|
Antes Largura: | Altura: | Tamanho: 49 KiB Depois Largura: | Altura: | Tamanho: 46 KiB |
|
Antes Largura: | Altura: | Tamanho: 28 KiB Depois Largura: | Altura: | Tamanho: 40 KiB |
|
Antes Largura: | Altura: | Tamanho: 50 KiB Depois Largura: | Altura: | Tamanho: 51 KiB |
|
Antes Largura: | Altura: | Tamanho: 27 KiB Depois Largura: | Altura: | Tamanho: 25 KiB |
@@ -0,0 +1,115 @@
|
||||
|
||||
.. _ARM-Linux-cross-compile:
|
||||
|
||||
Cross compilation for ARM based Linux systems
|
||||
*********************************************
|
||||
|
||||
This steps are tested on Ubuntu Linux 12.04, but should work for other Linux distributions.
|
||||
I case of other distributions package names and names of cross compilation tools may differ.
|
||||
There are several popular EABI versions that are used on ARM platform. This tutorial is
|
||||
written for *gnueabi* and *gnueabihf*, but other variants should work with minimal changes.
|
||||
|
||||
|
||||
Prerequisites
|
||||
=============
|
||||
|
||||
* Host computer with Linux;
|
||||
* Git;
|
||||
* CMake 2.6 or higher;
|
||||
* Cross compilation tools for ARM: gcc, libstc++, etc. Depending on target platform you need
|
||||
to choose *gnueabi* or *gnueabihf* tools.
|
||||
Install command for *gnueabi*:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get install gcc-arm-linux-gnueabi
|
||||
|
||||
Install command for *gnueabihf*:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sudo apt-get install gcc-arm-linux-gnueabihf
|
||||
|
||||
* pkgconfig;
|
||||
* Python 2.6 for host system;
|
||||
* [optional] ffmpeg or libav development packages for armeabi(hf): libavcodec-dev, libavformat-dev, libswscale-dev;
|
||||
* [optional] GTK+2.x or higher, including headers (libgtk2.0-dev) for armeabi(hf);
|
||||
* [optional] libdc1394 2.x;
|
||||
* [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjasper-dev for armeabi(hf).
|
||||
|
||||
|
||||
Getting OpenCV Source Code
|
||||
==========================
|
||||
|
||||
You can use the latest stable OpenCV version available in *sourceforge* or you can grab the latest
|
||||
snapshot from our `Git repository <https://github.com/Itseez/opencv.git>`_.
|
||||
|
||||
|
||||
Getting the Latest Stable OpenCV Version
|
||||
----------------------------------------
|
||||
|
||||
* Go to our `page on Sourceforge <http://sourceforge.net/projects/opencvlibrary>`_;
|
||||
|
||||
* Download the source tarball and unpack it.
|
||||
|
||||
|
||||
Getting the Cutting-edge OpenCV from the Git Repository
|
||||
-------------------------------------------------------
|
||||
|
||||
Launch Git client and clone `OpenCV repository <http://github.com/itseez/opencv>`_
|
||||
|
||||
In Linux it can be achieved with the following command in Terminal:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd ~/<my_working _directory>
|
||||
git clone https://github.com/Itseez/opencv.git
|
||||
|
||||
|
||||
Building OpenCV
|
||||
===============
|
||||
|
||||
#. Create a build directory, make it current and run the following command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cmake [<some optional parameters>] -DCMAKE_TOOLCHAIN_FILE=<path to the OpenCV source directory>/platforms/linux/arm-gnueabi.toolchain.cmake <path to the OpenCV source directory>
|
||||
|
||||
Toolchain uses *gnueabihf* EABI convention by default. Add ``-DSOFTFP=ON`` cmake argument to switch on softfp compiler.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cmake [<some optional parameters>] -DSOFTFP=ON -DCMAKE_TOOLCHAIN_FILE=<path to the OpenCV source directory>/platforms/linux/arm-gnueabi.toolchain.cmake <path to the OpenCV source directory>
|
||||
|
||||
For example:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd ~/opencv/platforms/linux
|
||||
mkdir -p build_hardfp
|
||||
cd build_hardfp
|
||||
|
||||
cmake -DCMAKE_TOOLCHAIN_FILE=../arm-gnueabi.toolchain.cmake ../../..
|
||||
|
||||
#. Run make in build (<cmake_binary_dir>) directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make
|
||||
|
||||
.. note::
|
||||
|
||||
Optionally you can strip symbols info from the created library via install/strip make target.
|
||||
This option produces smaller binary (~ twice smaller) but makes further debugging harder.
|
||||
|
||||
Enable hardware optimizations
|
||||
-----------------------------
|
||||
|
||||
Depending on target platfrom architecture different instruction sets can be used. By default
|
||||
compiler generates code for armv5l without VFPv3 and NEON extensions. Add ``-DUSE_VFPV3=ON``
|
||||
to cmake command line to enable code generation for VFPv3 and ``-DUSE_NEON=ON`` for using
|
||||
NEON SIMD extensions.
|
||||
|
||||
TBB is supported on multi core ARM SoCs also.
|
||||
Add ``-DWITH_TBB=ON`` and ``-DBUILD_TBB=ON`` to enable it. Cmake scripts download TBB sources
|
||||
from official project site `<http://threadingbuildingblocks.org/>`_ and build it.
|
||||
|
Depois Largura: | Altura: | Tamanho: 41 KiB |
|
Depois Largura: | Altura: | Tamanho: 23 KiB |
|
Depois Largura: | Altura: | Tamanho: 15 KiB |
|
Depois Largura: | Altura: | Tamanho: 42 KiB |
|
Depois Largura: | Altura: | Tamanho: 12 KiB |
|
Depois Largura: | Altura: | Tamanho: 74 KiB |
|
Depois Largura: | Altura: | Tamanho: 42 KiB |
|
Depois Largura: | Altura: | Tamanho: 25 KiB |
|
Depois Largura: | Altura: | Tamanho: 25 KiB |
|
Depois Largura: | Altura: | Tamanho: 32 KiB |
|
Depois Largura: | Altura: | Tamanho: 14 KiB |
|
Depois Largura: | Altura: | Tamanho: 34 KiB |
|
Depois Largura: | Altura: | Tamanho: 38 KiB |
|
Depois Largura: | Altura: | Tamanho: 25 KiB |
|
Depois Largura: | Altura: | Tamanho: 500 KiB |
|
Depois Largura: | Altura: | Tamanho: 606 KiB |
|
Depois Largura: | Altura: | Tamanho: 248 KiB |
|
Depois Largura: | Altura: | Tamanho: 195 KiB |
|
Depois Largura: | Altura: | Tamanho: 258 KiB |
@@ -0,0 +1,540 @@
|
||||
|
||||
.. _Java_Dev_Intro:
|
||||
|
||||
|
||||
Introduction to Java Development
|
||||
********************************
|
||||
|
||||
Last updated: 28 February, 2013.
|
||||
|
||||
As of OpenCV 2.4.4, OpenCV supports desktop Java development using nearly the same interface as for
|
||||
Android development. This guide will help you to create your first Java (or Scala) application using OpenCV.
|
||||
We will use either `Eclipse <http://eclipse.org/>`_, `Apache Ant <http://ant.apache.org/>`_ or the
|
||||
`Simple Build Tool (SBT) <http://www.scala-sbt.org/>`_ to build the application.
|
||||
|
||||
For further reading after this guide, look at the :ref:`Android_Dev_Intro` tutorials.
|
||||
|
||||
What we'll do in this guide
|
||||
***************************
|
||||
|
||||
In this guide, we will:
|
||||
|
||||
* Get OpenCV with desktop Java support
|
||||
|
||||
* Create an ``Ant``, ``Eclipse`` or ``SBT`` project
|
||||
|
||||
* Write a simple OpenCV application in Java or Scala
|
||||
|
||||
The same process was used to create the samples in the :file:`samples/java` folder of the OpenCV repository,
|
||||
so consult those files if you get lost.
|
||||
|
||||
Get proper OpenCV
|
||||
*****************
|
||||
|
||||
Starting from version 2.4.4 OpenCV includes desktop Java bindings.
|
||||
|
||||
Download
|
||||
########
|
||||
|
||||
The most simple way to get it is downloading the appropriate package of **version 2.4.4 or higher** from the
|
||||
`OpenCV SourceForge repository <http://sourceforge.net/projects/opencvlibrary/files/>`_.
|
||||
|
||||
.. note:: Windows users can find the prebuilt files needed for Java development in
|
||||
the :file:`opencv/build/java/` folder inside the package.
|
||||
For other OSes it's required to build OpenCV from sources.
|
||||
|
||||
Another option to get OpenCV sources is to clone `OpenCV git repository
|
||||
<https://github.com/Itseez/opencv/>`_.
|
||||
In order to build OpenCV with Java bindings you need :abbr:`JDK (Java Development Kit)`
|
||||
(we recommend `Oracle/Sun JDK 6 or 7 <http://www.oracle.com/technetwork/java/javase/downloads/>`_),
|
||||
`Apache Ant <http://ant.apache.org/>`_ and `Python` v2.6 or higher to be installed.
|
||||
|
||||
Build
|
||||
#####
|
||||
|
||||
Let's build OpenCV:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone git://github.com/Itseez/opencv.git
|
||||
cd opencv
|
||||
git checkout 2.4
|
||||
mkdir build
|
||||
cd build
|
||||
|
||||
Generate a Makefile or a MS Visual Studio* solution, or whatever you use for
|
||||
building executables in your system:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cmake -DBUILD_SHARED_LIBS=OFF ..
|
||||
|
||||
or
|
||||
|
||||
.. code-block:: bat
|
||||
|
||||
cmake -DBUILD_SHARED_LIBS=OFF -G "Visual Studio 10" ..
|
||||
|
||||
.. note:: When OpenCV is built as a set of **static** libraries (``-DBUILD_SHARED_LIBS=OFF`` option)
|
||||
the Java bindings dynamic library is all-sufficient,
|
||||
i.e. doesn't depend on other OpenCV libs, but includes all the OpenCV code inside.
|
||||
|
||||
Examine the output of CMake and ensure ``java`` is one of the modules "To be built".
|
||||
If not, it's likely you're missing a dependency. You should troubleshoot by looking
|
||||
through the CMake output for any Java-related tools that aren't found and installing them.
|
||||
|
||||
.. image:: images/cmake_output.png
|
||||
:alt: CMake output
|
||||
:align: center
|
||||
|
||||
.. note:: If ``CMake`` can't find Java in your system set the ``JAVA_HOME``
|
||||
environment variable with the path to installed JDK
|
||||
before running it. E.g.:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
export JAVA_HOME=/usr/lib/jvm/java-6-oracle
|
||||
cmake -DBUILD_SHARED_LIBS=OFF ..
|
||||
|
||||
|
||||
Now start the build:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make -j8
|
||||
|
||||
or
|
||||
|
||||
.. code-block:: bat
|
||||
|
||||
msbuild /m OpenCV.sln /t:Build /p:Configuration=Release /v:m
|
||||
|
||||
Besides all this will create a ``jar`` containing the Java interface (:file:`bin/opencv-244.jar`)
|
||||
and a native dynamic library containing Java bindings and all the OpenCV stuff
|
||||
(:file:`bin/Release/opencv_java244.dll` or :file:`lib/libopencv_java244.so` respectively).
|
||||
We'll use these files later.
|
||||
|
||||
Java sample with Ant
|
||||
********************
|
||||
|
||||
.. note::
|
||||
The described sample is provided with OpenCV library in the :file:`opencv/samples/java/ant` folder.
|
||||
|
||||
* Create a folder where you'll develop this sample application.
|
||||
|
||||
* In this folder create the :file:`build.xml` file with the following content using any text editor:
|
||||
|
||||
.. code-block:: xml
|
||||
:linenos:
|
||||
|
||||
<project name="SimpleSample" basedir="." default="rebuild-run">
|
||||
|
||||
<property name="src.dir" value="src"/>
|
||||
|
||||
<property name="lib.dir" value="${ocvJarDir}"/>
|
||||
<path id="classpath">
|
||||
<fileset dir="${lib.dir}" includes="**/*.jar"/>
|
||||
</path>
|
||||
|
||||
<property name="build.dir" value="build"/>
|
||||
<property name="classes.dir" value="${build.dir}/classes"/>
|
||||
<property name="jar.dir" value="${build.dir}/jar"/>
|
||||
|
||||
<property name="main-class" value="${ant.project.name}"/>
|
||||
|
||||
|
||||
<target name="clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
</target>
|
||||
|
||||
<target name="compile">
|
||||
<mkdir dir="${classes.dir}"/>
|
||||
<javac includeantruntime="false" srcdir="${src.dir}" destdir="${classes.dir}" classpathref="classpath"/>
|
||||
</target>
|
||||
|
||||
<target name="jar" depends="compile">
|
||||
<mkdir dir="${jar.dir}"/>
|
||||
<jar destfile="${jar.dir}/${ant.project.name}.jar" basedir="${classes.dir}">
|
||||
<manifest>
|
||||
<attribute name="Main-Class" value="${main-class}"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target>
|
||||
|
||||
<target name="run" depends="jar">
|
||||
<java fork="true" classname="${main-class}">
|
||||
<sysproperty key="java.library.path" path="${ocvLibDir}"/>
|
||||
<classpath>
|
||||
<path refid="classpath"/>
|
||||
<path location="${jar.dir}/${ant.project.name}.jar"/>
|
||||
</classpath>
|
||||
</java>
|
||||
</target>
|
||||
|
||||
<target name="rebuild" depends="clean,jar"/>
|
||||
|
||||
<target name="rebuild-run" depends="clean,run"/>
|
||||
|
||||
</project>
|
||||
|
||||
.. note::
|
||||
This XML file can be reused for building other Java applications.
|
||||
It describes a common folder structure in the lines 3 - 12 and common targets
|
||||
for compiling and running the application.
|
||||
|
||||
When reusing this XML don't forget to modify the project name in the line 1,
|
||||
that is also the name of the `main` class (line 14).
|
||||
The paths to OpenCV `jar` and `jni lib` are expected as parameters
|
||||
(``"${ocvJarDir}"`` in line 5 and ``"${ocvLibDir}"`` in line 37), but
|
||||
you can hardcode these paths for your convenience.
|
||||
See `Ant documentation <http://ant.apache.org/manual/>`_ for detailed description
|
||||
of its build file format.
|
||||
|
||||
* Create an :file:`src` folder next to the :file:`build.xml` file and a :file:`SimpleSample.java` file in it.
|
||||
|
||||
* Put the following Java code into the :file:`SimpleSample.java` file:
|
||||
.. code-block:: java
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Scalar;
|
||||
|
||||
class SimpleSample {
|
||||
|
||||
static{ System.loadLibrary(Core.NATIVE_LIBRARY_NAME); }
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Welcome to OpenCV " + Core.VERSION);
|
||||
Mat m = new Mat(5, 10, CvType.CV_8UC1, new Scalar(0));
|
||||
System.out.println("OpenCV Mat: " + m);
|
||||
Mat mr1 = m.row(1);
|
||||
mr1.setTo(new Scalar(1));
|
||||
Mat mc5 = m.col(5);
|
||||
mc5.setTo(new Scalar(5));
|
||||
System.out.println("OpenCV Mat data:\n" + m.dump());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
* Run the following command in console in the folder containing :file:`build.xml`:
|
||||
.. code-block:: bash
|
||||
|
||||
ant -DocvJarDir=path/to/dir/containing/opencv-244.jar -DocvLibDir=path/to/dir/containing/opencv_java244/native/library
|
||||
|
||||
For example:
|
||||
|
||||
.. code-block:: bat
|
||||
|
||||
ant -DocvJarDir=X:\opencv-2.4.4\bin -DocvLibDir=X:\opencv-2.4.4\bin\Release
|
||||
|
||||
The command should initiate [re]building and running the sample.
|
||||
You should see on the screen something like this:
|
||||
|
||||
.. image:: images/ant_output.png
|
||||
:alt: run app with Ant
|
||||
:align: center
|
||||
|
||||
Java project in Eclipse
|
||||
***********************
|
||||
|
||||
Now let's look at the possiblity of using OpenCV in Java when developing in Eclipse IDE.
|
||||
|
||||
* Create a new Eclipse workspace
|
||||
* Create a new Java project via :guilabel:`File --> New --> Java Project`
|
||||
|
||||
.. image:: images/eclipse_new_java_prj.png
|
||||
:alt: Eclipse: new Java project
|
||||
:align: center
|
||||
|
||||
Call it say "HelloCV".
|
||||
|
||||
* Open :guilabel:`Java Build Path` tab on :guilabel:`Project Properties` dialog
|
||||
and configure additional library (OpenCV) reference (jar and native library location):
|
||||
|
||||
.. image:: images/eclipse_user_lib.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
.. image:: images/eclipse_user_lib2.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
.. image:: images/eclipse_user_lib3.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
.. image:: images/eclipse_user_lib4.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
.. image:: images/eclipse_user_lib5.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
.. image:: images/eclipse_user_lib6.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
.. image:: images/eclipse_user_lib7.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
.. image:: images/eclipse_user_lib8.png
|
||||
:alt: Eclipse: external JAR
|
||||
:align: center
|
||||
|
||||
` `
|
||||
|
||||
* Add a new Java class (say ``Main``) containing the application entry:
|
||||
|
||||
.. image:: images/eclipse_main_class.png
|
||||
:alt: Eclipse: Main class
|
||||
:align: center
|
||||
|
||||
* Put some simple OpenCV calls there, e.g.:
|
||||
.. code-block:: java
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.CvType;
|
||||
import org.opencv.core.Mat;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
Mat m = Mat.eye(3, 3, CvType.CV_8UC1);
|
||||
System.out.println("m = " + m.dump());
|
||||
}
|
||||
}
|
||||
|
||||
* Press :guilabel:`Run` button and find the identity matrix content in the Eclipse ``Console`` window.
|
||||
|
||||
.. image:: images/eclipse_run.png
|
||||
:alt: Eclipse: run
|
||||
:align: center
|
||||
|
||||
SBT project for Java and Scala
|
||||
******************************
|
||||
|
||||
Now we'll create a simple Java application using SBT. This serves as a brief introduction to
|
||||
those unfamiliar with this build tool. We're using SBT because it is particularly easy and powerful.
|
||||
|
||||
First, download and install `SBT <http://www.scala-sbt.org/>`_ using the instructions on its `web site <http://www.scala-sbt.org/>`_.
|
||||
|
||||
Next, navigate to a new directory where you'd like the application source to live (outside :file:`opencv` dir).
|
||||
Let's call it "JavaSample" and create a directory for it:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd <somewhere outside opencv>
|
||||
mkdir JavaSample
|
||||
|
||||
Now we will create the necessary folders and an SBT project:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cd JavaSample
|
||||
mkdir -p src/main/java # This is where SBT expects to find Java sources
|
||||
mkdir project # This is where the build definitions live
|
||||
|
||||
Now open :file:`project/build.scala` in your favorite editor and paste the following.
|
||||
It defines your project:
|
||||
|
||||
.. code-block:: scala
|
||||
|
||||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object JavaSampleBuild extends Build {
|
||||
def scalaSettings = Seq(
|
||||
scalaVersion := "2.10.0",
|
||||
scalacOptions ++= Seq(
|
||||
"-optimize",
|
||||
"-unchecked",
|
||||
"-deprecation"
|
||||
)
|
||||
)
|
||||
|
||||
def buildSettings =
|
||||
Project.defaultSettings ++
|
||||
scalaSettings
|
||||
|
||||
lazy val root = {
|
||||
val settings = buildSettings ++ Seq(name := "JavaSample")
|
||||
Project(id = "JavaSample", base = file("."), settings = settings)
|
||||
}
|
||||
}
|
||||
|
||||
Now edit :file:`project/plugins.sbt` and paste the following.
|
||||
This will enable auto-generation of an Eclipse project:
|
||||
|
||||
.. code-block:: scala
|
||||
|
||||
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.1.0")
|
||||
|
||||
Now run ``sbt`` from the :file:`JavaSample` root and from within SBT run ``eclipse`` to generate an eclipse project:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sbt # Starts the sbt console
|
||||
> eclipse # Running "eclipse" from within the sbt console
|
||||
|
||||
You should see something like this:
|
||||
|
||||
.. image:: images/sbt_eclipse.png
|
||||
:alt: SBT output
|
||||
:align: center
|
||||
|
||||
You can now import the SBT project to Eclipse using :guilabel:`Import ... -> Existing projects into workspace`.
|
||||
Whether you actually do this is optional for the guide;
|
||||
we'll be using SBT to build the project, so if you choose to use Eclipse it will just serve as a text editor.
|
||||
|
||||
To test that everything is working, create a simple "Hello OpenCV" application.
|
||||
Do this by creating a file :file:`src/main/java/HelloOpenCV.java` with the following contents:
|
||||
|
||||
.. code-block:: java
|
||||
|
||||
public class HelloOpenCV {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, OpenCV");
|
||||
}
|
||||
}
|
||||
|
||||
Now execute ``run`` from the sbt console, or more concisely, run ``sbt run`` from the command line:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sbt run
|
||||
|
||||
You should see something like this:
|
||||
|
||||
.. image:: images/sbt_run.png
|
||||
:alt: SBT run
|
||||
:align: center
|
||||
|
||||
Running SBT samples
|
||||
###################
|
||||
|
||||
Now we'll create a simple face detection application using OpenCV.
|
||||
|
||||
First, create a :file:`lib/` folder and copy the OpenCV jar into it.
|
||||
By default, SBT adds jars in the lib folder to the Java library search path.
|
||||
You can optionally rerun ``sbt eclipse`` to update your Eclipse project.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
mkdir lib
|
||||
cp <opencv_dir>/build/bin/opencv_<version>.jar lib/
|
||||
sbt eclipse
|
||||
|
||||
Next, create the directory :file:`src/main/resources` and download this Lena image into it:
|
||||
|
||||
.. image:: images/lena.png
|
||||
:alt: Lena
|
||||
:align: center
|
||||
|
||||
Make sure it's called :file:`"lena.png"`.
|
||||
Items in the resources directory are available to the Java application at runtime.
|
||||
|
||||
Next, copy :file:`lbpcascade_frontalface.xml` from :file:`opencv/data/lbpcascades/` into the :file:`resources`
|
||||
directory:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
cp <opencv_dir>/data/lbpcascades/lbpcascade_frontalface.xml src/main/resources/
|
||||
|
||||
Now modify src/main/java/HelloOpenCV.java so it contains the following Java code:
|
||||
|
||||
.. code-block:: java
|
||||
|
||||
import org.opencv.core.Core;
|
||||
import org.opencv.core.Mat;
|
||||
import org.opencv.core.MatOfRect;
|
||||
import org.opencv.core.Point;
|
||||
import org.opencv.core.Rect;
|
||||
import org.opencv.core.Scalar;
|
||||
import org.opencv.highgui.Highgui;
|
||||
import org.opencv.objdetect.CascadeClassifier;
|
||||
|
||||
//
|
||||
// Detects faces in an image, draws boxes around them, and writes the results
|
||||
// to "faceDetection.png".
|
||||
//
|
||||
class DetectFaceDemo {
|
||||
public void run() {
|
||||
System.out.println("\nRunning DetectFaceDemo");
|
||||
|
||||
// Create a face detector from the cascade file in the resources
|
||||
// directory.
|
||||
CascadeClassifier faceDetector = new CascadeClassifier(getClass().getResource("/lbpcascade_frontalface.xml").getPath());
|
||||
Mat image = Highgui.imread(getClass().getResource("/lena.png").getPath());
|
||||
|
||||
// Detect faces in the image.
|
||||
// MatOfRect is a special container class for Rect.
|
||||
MatOfRect faceDetections = new MatOfRect();
|
||||
faceDetector.detectMultiScale(image, faceDetections);
|
||||
|
||||
System.out.println(String.format("Detected %s faces", faceDetections.toArray().length));
|
||||
|
||||
// Draw a bounding box around each face.
|
||||
for (Rect rect : faceDetections.toArray()) {
|
||||
Core.rectangle(image, new Point(rect.x, rect.y), new Point(rect.x + rect.width, rect.y + rect.height), new Scalar(0, 255, 0));
|
||||
}
|
||||
|
||||
// Save the visualized detection.
|
||||
String filename = "faceDetection.png";
|
||||
System.out.println(String.format("Writing %s", filename));
|
||||
Highgui.imwrite(filename, image);
|
||||
}
|
||||
}
|
||||
|
||||
public class HelloOpenCV {
|
||||
public static void main(String[] args) {
|
||||
System.out.println("Hello, OpenCV");
|
||||
|
||||
// Load the native library.
|
||||
System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
|
||||
new DetectFaceDemo().run();
|
||||
}
|
||||
}
|
||||
|
||||
Note the call to ``System.loadLibrary(Core.NATIVE_LIBRARY_NAME)``.
|
||||
This command must be executed exactly once per Java process prior to using any native OpenCV methods.
|
||||
If you don't call it, you will get ``UnsatisfiedLink errors``.
|
||||
You will also get errors if you try to load OpenCV when it has already been loaded.
|
||||
|
||||
Now run the face detection app using ``sbt run``:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
sbt run
|
||||
|
||||
You should see something like this:
|
||||
|
||||
.. image:: images/sbt_run_face.png
|
||||
:alt: SBT run
|
||||
:align: center
|
||||
|
||||
It should also write the following image to :file:`faceDetection.png`:
|
||||
|
||||
.. image:: images/faceDetection.png
|
||||
:alt: Detected face
|
||||
:align: center
|
||||
|
||||
You're done!
|
||||
Now you have a sample Java application working with OpenCV, so you can start the work on your own.
|
||||
We wish you good luck and many years of joyful life!
|
||||
|
Depois Largura: | Altura: | Tamanho: 41 KiB |
@@ -3,7 +3,9 @@
|
||||
Introduction to OpenCV
|
||||
-----------------------------------------------------------
|
||||
|
||||
Here you can read tutorials about how to set up your computer to work with the OpenCV library. Additionaly you can find a few very basic sample source code that will let introduce you to the world of the OpenCV.
|
||||
Here you can read tutorials about how to set up your computer to work with the OpenCV library.
|
||||
Additionally you can find a few very basic sample source code that will let introduce you to the
|
||||
world of the OpenCV.
|
||||
|
||||
.. include:: ../../definitions/tocDefinitions.rst
|
||||
|
||||
@@ -101,6 +103,26 @@ Here you can read tutorials about how to set up your computer to work with the O
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
* **Desktop Java**
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
================ =================================================
|
||||
|JavaLogo| **Title:** :ref:`Java_Dev_Intro`
|
||||
|
||||
*Compatibility:* > OpenCV 2.4.4
|
||||
|
||||
*Authors:* |Author_EricCh| and |Author_AndreyP|
|
||||
|
||||
Explains how to build and run a simple desktop Java application using Eclipse, Ant or the Simple Build Tool (SBT).
|
||||
|
||||
================ =================================================
|
||||
|
||||
.. |JavaLogo| image:: images/Java_logo.png
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
* **Android**
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
@@ -169,6 +191,24 @@ Here you can read tutorials about how to set up your computer to work with the O
|
||||
.. |Install_iOS| image:: images/opencv_ios.png
|
||||
:width: 90pt
|
||||
|
||||
* **Embedded Linux**
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
=========== ======================================================
|
||||
|Usage_1| **Title:** :ref:`ARM-Linux-cross-compile`
|
||||
|
||||
*Compatibility:* > OpenCV 2.4.4
|
||||
|
||||
*Author:* |Author_AlexS|
|
||||
|
||||
We will learn how to setup OpenCV cross compilation environment for ARM Linux.
|
||||
|
||||
=========== ======================================================
|
||||
|
||||
* **Common**
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
@@ -229,7 +269,7 @@ Here you can read tutorials about how to set up your computer to work with the O
|
||||
|
||||
\pagebreak
|
||||
|
||||
.. We use a custom table of content format and as the table of content only imforms Sphinx about the hierarchy of the files, no need to show it.
|
||||
.. We use a custom table of content format and as the table of content only informs Sphinx about the hierarchy of the files, no need to show it.
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
@@ -238,10 +278,12 @@ Here you can read tutorials about how to set up your computer to work with the O
|
||||
../linux_eclipse/linux_eclipse
|
||||
../windows_install/windows_install
|
||||
../windows_visual_studio_Opencv/windows_visual_studio_Opencv
|
||||
../desktop_java/java_dev_intro
|
||||
../android_binary_package/android_dev_intro
|
||||
../android_binary_package/O4A_SDK
|
||||
../android_binary_package/dev_with_OCV_on_Android
|
||||
../ios_install/ios_install
|
||||
../crosscompilation/arm_crosscompile_with_cmake
|
||||
../display_image/display_image
|
||||
../load_save_image/load_save_image
|
||||
../how_to_write_a_tutorial/how_to_write_a_tutorial
|
||||
../how_to_write_a_tutorial/how_to_write_a_tutorial
|
||||
|
||||
@@ -238,7 +238,7 @@ The constructors.
|
||||
: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.
|
||||
@@ -418,27 +418,47 @@ Template class for smart reference-counting pointers ::
|
||||
};
|
||||
|
||||
|
||||
The ``Ptr<_Tp>`` class is a template class that wraps pointers of the corresponding type. It is similar to ``shared_ptr`` that is part of the Boost library (
|
||||
http://www.boost.org/doc/libs/1_40_0/libs/smart_ptr/shared_ptr.htm
|
||||
) and also part of the `C++0x <http://en.wikipedia.org/wiki/C++0x>`_
|
||||
standard.
|
||||
The ``Ptr<_Tp>`` class is a template class that wraps pointers of the corresponding type. It is
|
||||
similar to ``shared_ptr`` that is part of the Boost library
|
||||
(http://www.boost.org/doc/libs/1_40_0/libs/smart_ptr/shared_ptr.htm) and also part of the
|
||||
`C++0x <http://en.wikipedia.org/wiki/C++0x>`_ standard.
|
||||
|
||||
This class provides the following options:
|
||||
|
||||
*
|
||||
Default constructor, copy constructor, and assignment operator for an arbitrary C++ class or a C structure. For some objects, like files, windows, mutexes, sockets, and others, a copy constructor or an assignment operator are difficult to define. For some other objects, like complex classifiers in OpenCV, copy constructors are absent and not easy to implement. Finally, some of complex OpenCV and your own data structures may be written in C. However, copy constructors and default constructors can simplify programming a lot. Besides, they are often required (for example, by STL containers). By wrapping a pointer to such a complex object ``TObj`` to ``Ptr<TObj>`` , you automatically get all of the necessary constructors and the assignment operator.
|
||||
Default constructor, copy constructor, and assignment operator for an arbitrary C++ class
|
||||
or a C structure. For some objects, like files, windows, mutexes, sockets, and others, a copy
|
||||
constructor or an assignment operator are difficult to define. For some other objects, like
|
||||
complex classifiers in OpenCV, copy constructors are absent and not easy to implement. Finally,
|
||||
some of complex OpenCV and your own data structures may be written in C.
|
||||
However, copy constructors and default constructors can simplify programming a lot.Besides,
|
||||
they are often required (for example, by STL containers). By wrapping a pointer to such a
|
||||
complex object ``TObj`` to ``Ptr<TObj>``, you automatically get all of the necessary
|
||||
constructors and the assignment operator.
|
||||
|
||||
*
|
||||
*O(1)* complexity of the above-mentioned operations. While some structures, like ``std::vector``, provide a copy constructor and an assignment operator, the operations may take a considerable amount of time if the data structures are large. But if the structures are put into ``Ptr<>`` , the overhead is small and independent of the data size.
|
||||
*O(1)* complexity of the above-mentioned operations. While some structures, like ``std::vector``,
|
||||
provide a copy constructor and an assignment operator, the operations may take a considerable
|
||||
amount of time if the data structures are large. But if the structures are put into ``Ptr<>``,
|
||||
the overhead is small and independent of the data size.
|
||||
|
||||
*
|
||||
Automatic destruction, even for C structures. See the example below with ``FILE*`` .
|
||||
Automatic destruction, even for C structures. See the example below with ``FILE*``.
|
||||
|
||||
*
|
||||
Heterogeneous collections of objects. The standard STL and most other C++ and OpenCV containers can store only objects of the same type and the same size. The classical solution to store objects of different types in the same container is to store pointers to the base class ``base_class_t*`` instead but then you loose the automatic memory management. Again, by using ``Ptr<base_class_t>()`` instead of the raw pointers, you can solve the problem.
|
||||
Heterogeneous collections of objects. The standard STL and most other C++ and OpenCV containers
|
||||
can store only objects of the same type and the same size. The classical solution to store objects
|
||||
of different types in the same container is to store pointers to the base class ``base_class_t*``
|
||||
instead but then you loose the automatic memory management. Again, by using ``Ptr<base_class_t>()``
|
||||
instead of the raw pointers, you can solve the problem.
|
||||
|
||||
The ``Ptr`` class treats the wrapped object as a black box. The reference counter is allocated and managed separately. The only thing the pointer class needs to know about the object is how to deallocate it. This knowledge is encapsulated in the ``Ptr::delete_obj()`` method that is called when the reference counter becomes 0. If the object is a C++ class instance, no additional coding is needed, because the default implementation of this method calls ``delete obj;`` .
|
||||
However, if the object is deallocated in a different way, the specialized method should be created. For example, if you want to wrap ``FILE`` , the ``delete_obj`` may be implemented as follows: ::
|
||||
The ``Ptr`` class treats the wrapped object as a black box. The reference counter is allocated and
|
||||
managed separately. The only thing the pointer class needs to know about the object is how to
|
||||
deallocate it. This knowledge is encapsulated in the ``Ptr::delete_obj()`` method that is called when
|
||||
the reference counter becomes 0. If the object is a C++ class instance, no additional coding is
|
||||
needed, because the default implementation of this method calls ``delete obj;``. However, if the
|
||||
object is deallocated in a different way, the specialized method should be created. For example,
|
||||
if you want to wrap ``FILE``, the ``delete_obj`` may be implemented as follows: ::
|
||||
|
||||
template<> inline void Ptr<FILE>::delete_obj()
|
||||
{
|
||||
@@ -456,7 +476,73 @@ However, if the object is deallocated in a different way, the specialized method
|
||||
// the file will be closed automatically by the Ptr<FILE> destructor.
|
||||
|
||||
|
||||
.. note:: The reference increment/decrement operations are implemented as atomic operations, and therefore it is normally safe to use the classes in multi-threaded applications. The same is true for :ocv:class:`Mat` and other C++ OpenCV classes that operate on the reference counters.
|
||||
.. note:: The reference increment/decrement operations are implemented as atomic operations,
|
||||
and therefore it is normally safe to use the classes in multi-threaded applications.
|
||||
The same is true for :ocv:class:`Mat` and other C++ OpenCV classes that operate on
|
||||
the reference counters.
|
||||
|
||||
Ptr::Ptr
|
||||
--------
|
||||
Various Ptr constructors.
|
||||
|
||||
.. ocv:function:: Ptr::Ptr()
|
||||
.. ocv:function:: Ptr::Ptr(_Tp* _obj)
|
||||
.. ocv:function:: Ptr::Ptr(const Ptr& ptr)
|
||||
|
||||
Ptr::~Ptr
|
||||
---------
|
||||
The Ptr destructor.
|
||||
|
||||
.. ocv:function:: Ptr::~Ptr()
|
||||
|
||||
Ptr::operator =
|
||||
----------------
|
||||
Assignment operator.
|
||||
|
||||
.. ocv:function:: Ptr& Ptr::operator = (const Ptr& ptr)
|
||||
|
||||
Decrements own reference counter (with ``release()``) and increments ptr's reference counter.
|
||||
|
||||
Ptr::addref
|
||||
-----------
|
||||
Increments reference counter.
|
||||
|
||||
.. ocv:function:: void Ptr::addref()
|
||||
|
||||
Ptr::release
|
||||
------------
|
||||
Decrements reference counter; when it becomes 0, ``delete_obj()`` is called.
|
||||
|
||||
.. ocv:function:: void Ptr::release()
|
||||
|
||||
Ptr::delete_obj
|
||||
---------------
|
||||
User-specified custom object deletion operation. By default, ``delete obj;`` is called.
|
||||
|
||||
.. ocv:function:: void Ptr::delete_obj()
|
||||
|
||||
Ptr::empty
|
||||
----------
|
||||
Returns true if obj == 0;
|
||||
|
||||
bool empty() const;
|
||||
|
||||
Ptr::operator ->
|
||||
----------------
|
||||
Provide access to the object fields and methods.
|
||||
|
||||
.. ocv:function:: template<typename _Tp> _Tp* Ptr::operator -> ()
|
||||
.. ocv:function:: template<typename _Tp> const _Tp* Ptr::operator -> () const
|
||||
|
||||
|
||||
Ptr::operator _Tp*
|
||||
------------------
|
||||
Returns the underlying object pointer. Thanks to the methods, the ``Ptr<_Tp>`` can be used instead
|
||||
of ``_Tp*``.
|
||||
|
||||
.. ocv:function:: template<typename _Tp> Ptr::operator _Tp* ()
|
||||
.. ocv:function:: template<typename _Tp> Ptr::operator const _Tp*() const
|
||||
|
||||
|
||||
Mat
|
||||
---
|
||||
@@ -494,9 +580,9 @@ OpenCV C++ n-dimensional dense array class ::
|
||||
|
||||
|
||||
The class ``Mat`` represents an n-dimensional dense numerical single-channel or multi-channel array. It can be used to store real or complex-valued vectors and matrices, grayscale or color images, voxel volumes, vector fields, point clouds, tensors, histograms (though, very high-dimensional histograms may be better stored in a ``SparseMat`` ). The data layout of the array
|
||||
:math:`M` is defined by the array ``M.step[]`` , so that the address of element
|
||||
:math:`(i_0,...,i_{M.dims-1})` , where
|
||||
:math:`0\leq i_k<M.size[k]` , is computed as:
|
||||
:math:`M` is defined by the array ``M.step[]``, so that the address of element
|
||||
:math:`(i_0,...,i_{M.dims-1})`, where
|
||||
:math:`0\leq i_k<M.size[k]`, is computed as:
|
||||
|
||||
.. math::
|
||||
|
||||
@@ -529,7 +615,7 @@ There are many different ways to create a ``Mat`` object. The most popular optio
|
||||
|
||||
..
|
||||
|
||||
As noted in the introduction to this chapter, ``create()`` allocates only a new array when the shape or type of the current array are different from the specified ones.
|
||||
As noted in the introduction to this chapter, ``create()`` allocates only a new array when the shape or type of the current array are different from the specified ones.
|
||||
|
||||
*
|
||||
|
||||
@@ -543,7 +629,7 @@ There are many different ways to create a ``Mat`` object. The most popular optio
|
||||
|
||||
..
|
||||
|
||||
It passes the number of dimensions =1 to the ``Mat`` constructor but the created array will be 2-dimensional with the number of columns set to 1. So, ``Mat::dims`` is always >= 2 (can also be 0 when the array is empty).
|
||||
It passes the number of dimensions =1 to the ``Mat`` constructor but the created array will be 2-dimensional with the number of columns set to 1. So, ``Mat::dims`` is always >= 2 (can also be 0 when the array is empty).
|
||||
|
||||
*
|
||||
|
||||
@@ -573,7 +659,7 @@ There are many different ways to create a ``Mat`` object. The most popular optio
|
||||
|
||||
..
|
||||
|
||||
Due to the additional ``datastart`` and ``dataend`` members, it is possible to compute a relative sub-array position in the main *container* array using ``locateROI()``:
|
||||
Due to the additional ``datastart`` and ``dataend`` members, it is possible to compute a relative sub-array position in the main *container* array using ``locateROI()``:
|
||||
|
||||
::
|
||||
|
||||
@@ -589,7 +675,7 @@ There are many different ways to create a ``Mat`` object. The most popular optio
|
||||
|
||||
..
|
||||
|
||||
As in case of whole matrices, if you need a deep copy, use the ``clone()`` method of the extracted sub-matrices.
|
||||
As in case of whole matrices, if you need a deep copy, use the ``clone()`` method of the extracted sub-matrices.
|
||||
|
||||
*
|
||||
|
||||
@@ -619,7 +705,7 @@ There are many different ways to create a ``Mat`` object. The most popular optio
|
||||
|
||||
..
|
||||
|
||||
Partial yet very common cases of this *user-allocated data* case are conversions from ``CvMat`` and ``IplImage`` to ``Mat``. For this purpose, there are special constructors taking pointers to ``CvMat`` or ``IplImage`` and the optional flag indicating whether to copy the data or not.
|
||||
Partial yet very common cases of this *user-allocated data* case are conversions from ``CvMat`` and ``IplImage`` to ``Mat``. For this purpose, there are special constructors taking pointers to ``CvMat`` or ``IplImage`` and the optional flag indicating whether to copy the data or not.
|
||||
|
||||
Backward conversion from ``Mat`` to ``CvMat`` or ``IplImage`` is provided via cast operators ``Mat::operator CvMat() const`` and ``Mat::operator IplImage()``. The operators do NOT copy the data.
|
||||
|
||||
@@ -905,7 +991,7 @@ Provides matrix assignment operators.
|
||||
|
||||
:param m: Assigned, right-hand-side matrix. Matrix assignment is an O(1) operation. This means that no data is copied but the data is shared and the reference counter, if any, is incremented. Before assigning new data, the old data is de-referenced via :ocv:func:`Mat::release` .
|
||||
|
||||
:param expr: Assigned matrix expression object. As opposite to the first form of the assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)`` , and :func:`add` takes care of automatic ``C`` reallocation.
|
||||
:param expr: Assigned matrix expression object. As opposite to the first form of the assignment operation, the second form can reuse already allocated matrix if it has the right size and type to fit the matrix expression result. It is automatically handled by the real function that the matrix expressions is expanded to. For example, ``C=A+B`` is expanded to ``add(A, B, C)``, and :func:`add` takes care of automatic ``C`` reallocation.
|
||||
|
||||
:param s: Scalar assigned to each matrix element. The matrix size or type is not changed.
|
||||
|
||||
@@ -970,7 +1056,7 @@ Creates a matrix header for the specified row span.
|
||||
|
||||
:param endrow: An exclusive 0-based ending index of the row span.
|
||||
|
||||
:param r: :ocv:class:`Range` structure containing both the start and the end indices.
|
||||
:param r: :ocv:class:`Range` structure containing both the start and the end indices.
|
||||
|
||||
The method makes a new header for the specified row span of the matrix. Similarly to
|
||||
:ocv:func:`Mat::row` and
|
||||
@@ -1983,7 +2069,7 @@ The class ``SparseMat`` represents multi-dimensional sparse numerical arrays. Su
|
||||
: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:
|
||||
|
||||
*
|
||||
Query operations ( ``SparseMat::ptr`` and the higher-level ``SparseMat::ref``, ``SparseMat::value`` and ``SparseMat::find`` ), for example:
|
||||
Query operations (``SparseMat::ptr`` and the higher-level ``SparseMat::ref``, ``SparseMat::value`` and ``SparseMat::find``), for example:
|
||||
|
||||
::
|
||||
|
||||
@@ -2001,7 +2087,7 @@ The class ``SparseMat`` represents multi-dimensional sparse numerical arrays. Su
|
||||
..
|
||||
|
||||
*
|
||||
Sparse matrix iterators. They are similar to ``MatIterator`` but different from :ocv:class:`NAryMatIterator`. That is, the iteration loop is familiar to STL users:
|
||||
Sparse matrix iterators. They are similar to ``MatIterator`` but different from :ocv:class:`NAryMatIterator`. That is, the iteration loop is familiar to STL users:
|
||||
|
||||
::
|
||||
|
||||
@@ -2064,10 +2150,11 @@ 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)
|
||||
.. 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 )
|
||||
.. 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.
|
||||
@@ -2081,12 +2168,12 @@ SparseMat object destructor.
|
||||
|
||||
.. ocv:function:: SparseMat::~SparseMat()
|
||||
|
||||
SparseMat::operator =
|
||||
---------------------
|
||||
SparseMat::operator=
|
||||
--------------------
|
||||
Provides sparse matrix assignment operators.
|
||||
|
||||
.. ocv:function:: SparseMat& SparseMat::operator=(const SparseMat& m)
|
||||
.. ocv:function:: SparseMat& SparseMat::operator=(const Mat& m)
|
||||
.. 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.
|
||||
|
||||
|
||||
@@ -255,7 +255,7 @@ The function allocates the buffer of the specified size and returns it. When the
|
||||
|
||||
|
||||
fastFree
|
||||
------------
|
||||
--------
|
||||
Deallocates a memory buffer.
|
||||
|
||||
.. ocv:function:: void fastFree(void* ptr)
|
||||
@@ -280,6 +280,14 @@ The function acts like ``sprintf`` but forms and returns an STL string. It can
|
||||
:ocv:class:`Exception` constructor.
|
||||
|
||||
|
||||
getBuildInformation
|
||||
-------------------
|
||||
Returns full configuration time cmake output.
|
||||
|
||||
.. ocv:function:: const std::string& getBuildInformation()
|
||||
|
||||
Returned value is raw cmake output including version control system revision, compiler version, compiler flags, enabled modules and third party libraries, etc. Output format depends on target architecture.
|
||||
|
||||
|
||||
checkHardwareSupport
|
||||
--------------------
|
||||
@@ -303,13 +311,34 @@ Returns true if the specified feature is supported by the host hardware.
|
||||
|
||||
The function returns true if the host hardware supports the specified feature. When user calls ``setUseOptimized(false)``, the subsequent calls to ``checkHardwareSupport()`` will return false until ``setUseOptimized(true)`` is called. This way user can dynamically switch on and off the optimized code in OpenCV.
|
||||
|
||||
|
||||
|
||||
getNumberOfCPUs
|
||||
-----------------
|
||||
Returns the number of logical CPUs available for the process.
|
||||
|
||||
.. ocv:function:: int getNumberOfCPUs()
|
||||
|
||||
|
||||
|
||||
getNumThreads
|
||||
-----------------
|
||||
Returns the number of threads used by OpenCV.
|
||||
Returns the number of threads used by OpenCV for parallel regions.
|
||||
Always returns 1 if OpenCV is built without threading support.
|
||||
|
||||
.. ocv:function:: int getNumThreads()
|
||||
|
||||
The function returns the number of threads that is used by OpenCV.
|
||||
The exact meaning of return value depends on the threading framework used by OpenCV library:
|
||||
|
||||
* **TBB** – The number of threads, that OpenCV will try to use for parallel regions.
|
||||
If there is any ``tbb::thread_scheduler_init`` in user code conflicting with OpenCV, then
|
||||
function returns default number of threads used by TBB library.
|
||||
* **OpenMP** – An upper bound on the number of threads that could be used to form a new team.
|
||||
* **Concurrency** – The number of threads, that OpenCV will try to use for parallel regions.
|
||||
* **GCD** – Unsupported; returns the GCD thread pool limit (512) for compatibility.
|
||||
* **C=** – The number of threads, that OpenCV will try to use for parallel regions,
|
||||
if before called ``setNumThreads`` with ``threads > 0``,
|
||||
otherwise returns the number of logical CPUs, available for the process.
|
||||
|
||||
.. seealso::
|
||||
:ocv:func:`setNumThreads`,
|
||||
@@ -319,20 +348,28 @@ The function returns the number of threads that is used by OpenCV.
|
||||
|
||||
getThreadNum
|
||||
----------------
|
||||
Returns the index of the currently executed thread.
|
||||
Returns the index of the currently executed thread within the current parallel region.
|
||||
Always returns 0 if called outside of parallel region.
|
||||
|
||||
.. ocv:function:: int getThreadNum()
|
||||
|
||||
The function returns a 0-based index of the currently executed thread. The function is only valid inside a parallel OpenMP region. When OpenCV is built without OpenMP support, the function always returns 0.
|
||||
The exact meaning of return value depends on the threading framework used by OpenCV library:
|
||||
|
||||
* **TBB** – Unsupported with current 4.1 TBB release. May be will be supported in future.
|
||||
* **OpenMP** – The thread number, within the current team, of the calling thread.
|
||||
* **Concurrency** – An ID for the virtual processor that the current context is executing
|
||||
on (0 for master thread and unique number for others, but not necessary 1,2,3,...).
|
||||
* **GCD** – System calling thread's ID. Never returns 0 inside parallel region.
|
||||
* **C=** – The index of the current parallel task.
|
||||
|
||||
.. seealso::
|
||||
:ocv:func:`setNumThreads`,
|
||||
:ocv:func:`getNumThreads` .
|
||||
:ocv:func:`getNumThreads`
|
||||
|
||||
|
||||
|
||||
getTickCount
|
||||
----------------
|
||||
------------
|
||||
Returns the number of ticks.
|
||||
|
||||
.. ocv:function:: int64 getTickCount()
|
||||
@@ -346,7 +383,7 @@ It can be used to initialize
|
||||
|
||||
|
||||
getTickFrequency
|
||||
--------------------
|
||||
----------------
|
||||
Returns the number of ticks per second.
|
||||
|
||||
.. ocv:function:: double getTickFrequency()
|
||||
@@ -363,7 +400,7 @@ That is, the following code computes the execution time in seconds: ::
|
||||
|
||||
|
||||
getCPUTickCount
|
||||
----------------
|
||||
---------------
|
||||
Returns the number of CPU ticks.
|
||||
|
||||
.. ocv:function:: int64 getCPUTickCount()
|
||||
@@ -402,13 +439,25 @@ This operation is used in the simplest or most complex image processing function
|
||||
|
||||
setNumThreads
|
||||
-----------------
|
||||
Sets the number of threads used by OpenCV.
|
||||
OpenCV will try to set the number of threads for the next parallel region.
|
||||
If ``threads == 0``, OpenCV will disable threading optimizations and run all it's
|
||||
functions sequentially. Passing ``threads < 0`` will reset threads number to system default.
|
||||
This function must be called outside of parallel region.
|
||||
|
||||
.. ocv:function:: void setNumThreads(int nthreads)
|
||||
|
||||
:param nthreads: Number of threads used by OpenCV.
|
||||
|
||||
The function sets the number of threads used by OpenCV in parallel OpenMP regions. If ``nthreads=0`` , the function uses the default number of threads that is usually equal to the number of the processing cores.
|
||||
OpenCV will try to run it's functions with specified threads number, but
|
||||
some behaviour differs from framework:
|
||||
|
||||
* **TBB** – User-defined parallel constructions will run with the same threads number,
|
||||
if another does not specified. If late on user creates own scheduler, OpenCV will be use it.
|
||||
* **OpenMP** – No special defined behaviour.
|
||||
* **Concurrency** – If ``threads == 1``, OpenCV will disable threading optimizations
|
||||
and run it's functions sequentially.
|
||||
* **GCD** – Supports only values <= 0.
|
||||
* **C=** – No special defined behaviour.
|
||||
|
||||
.. seealso::
|
||||
:ocv:func:`getNumThreads`,
|
||||
@@ -417,7 +466,7 @@ The function sets the number of threads used by OpenCV in parallel OpenMP region
|
||||
|
||||
|
||||
setUseOptimized
|
||||
-----------------
|
||||
---------------
|
||||
Enables or disables the optimized code.
|
||||
|
||||
.. ocv:function:: int cvUseOptimized( int on_off )
|
||||
@@ -433,7 +482,7 @@ The function can be used to dynamically turn on and off optimized code (code tha
|
||||
By default, the optimized code is enabled unless you disable it in CMake. The current status can be retrieved using ``useOptimized``.
|
||||
|
||||
useOptimized
|
||||
-----------------
|
||||
------------
|
||||
Returns the status of optimized code usage.
|
||||
|
||||
.. ocv:function:: bool useOptimized()
|
||||
|
||||
@@ -90,10 +90,18 @@ class Mat;
|
||||
class SparseMat;
|
||||
typedef Mat MatND;
|
||||
|
||||
namespace ogl {
|
||||
class Buffer;
|
||||
class Texture2D;
|
||||
class Arrays;
|
||||
}
|
||||
|
||||
// < Deprecated
|
||||
class GlBuffer;
|
||||
class GlTexture;
|
||||
class GlArrays;
|
||||
class GlCamera;
|
||||
// >
|
||||
|
||||
namespace gpu {
|
||||
class GpuMat;
|
||||
@@ -1327,15 +1335,23 @@ public:
|
||||
template<typename _Tp, int m, int n> _InputArray(const Matx<_Tp, m, n>& matx);
|
||||
_InputArray(const Scalar& s);
|
||||
_InputArray(const double& val);
|
||||
// < Deprecated
|
||||
_InputArray(const GlBuffer& buf);
|
||||
_InputArray(const GlTexture& tex);
|
||||
// >
|
||||
_InputArray(const gpu::GpuMat& d_mat);
|
||||
_InputArray(const ogl::Buffer& buf);
|
||||
_InputArray(const ogl::Texture2D& tex);
|
||||
|
||||
virtual Mat getMat(int i=-1) const;
|
||||
virtual void getMatVector(vector<Mat>& mv) const;
|
||||
// < Deprecated
|
||||
virtual GlBuffer getGlBuffer() const;
|
||||
virtual GlTexture getGlTexture() const;
|
||||
// >
|
||||
virtual gpu::GpuMat getGpuMat() const;
|
||||
/*virtual*/ ogl::Buffer getOGlBuffer() const;
|
||||
/*virtual*/ ogl::Texture2D getOGlTexture2D() const;
|
||||
|
||||
virtual int kind() const;
|
||||
virtual Size size(int i=-1) const;
|
||||
@@ -1387,6 +1403,8 @@ public:
|
||||
template<typename _Tp, int m, int n> _OutputArray(Matx<_Tp, m, n>& matx);
|
||||
template<typename _Tp> _OutputArray(_Tp* vec, int n);
|
||||
_OutputArray(gpu::GpuMat& d_mat);
|
||||
_OutputArray(ogl::Buffer& buf);
|
||||
_OutputArray(ogl::Texture2D& tex);
|
||||
|
||||
_OutputArray(const Mat& m);
|
||||
template<typename _Tp> _OutputArray(const vector<_Tp>& vec);
|
||||
@@ -1397,12 +1415,16 @@ public:
|
||||
template<typename _Tp, int m, int n> _OutputArray(const Matx<_Tp, m, n>& matx);
|
||||
template<typename _Tp> _OutputArray(const _Tp* vec, int n);
|
||||
_OutputArray(const gpu::GpuMat& d_mat);
|
||||
_OutputArray(const ogl::Buffer& buf);
|
||||
_OutputArray(const ogl::Texture2D& tex);
|
||||
|
||||
virtual bool fixedSize() const;
|
||||
virtual bool fixedType() const;
|
||||
virtual bool needed() const;
|
||||
virtual Mat& getMatRef(int i=-1) const;
|
||||
/*virtual*/ gpu::GpuMat& getGpuMatRef() const;
|
||||
/*virtual*/ ogl::Buffer& getOGlBufferRef() const;
|
||||
/*virtual*/ ogl::Texture2D& getOGlTexture2DRef() const;
|
||||
virtual void create(Size sz, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
virtual void create(int rows, int cols, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
virtual void create(int dims, const int* size, int type, int i=-1, bool allowTransposed=false, int fixedDepthMask=0) const;
|
||||
@@ -4457,6 +4479,26 @@ public:
|
||||
Ptr<Algorithm> (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(const Ptr<Algorithm>&)=0,
|
||||
const string& help=string());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
float& value, bool readOnly=false,
|
||||
float (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(float)=0,
|
||||
const string& help=string());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
unsigned int& value, bool readOnly=false,
|
||||
unsigned int (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(unsigned int)=0,
|
||||
const string& help=string());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
uint64& value, bool readOnly=false,
|
||||
uint64 (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(uint64)=0,
|
||||
const string& help=string());
|
||||
void addParam(Algorithm& algo, const char* name,
|
||||
uchar& value, bool readOnly=false,
|
||||
uchar (Algorithm::*getter)()=0,
|
||||
void (Algorithm::*setter)(uchar)=0,
|
||||
const string& help=string());
|
||||
template<typename _Tp, typename _Base> void addParam(Algorithm& algo, const char* name,
|
||||
Ptr<_Tp>& value, bool readOnly=false,
|
||||
Ptr<_Tp> (Algorithm::*getter)()=0,
|
||||
@@ -4476,7 +4518,7 @@ protected:
|
||||
|
||||
struct CV_EXPORTS Param
|
||||
{
|
||||
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9, SHORT=10 };
|
||||
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9, SHORT=10, UCHAR=11 };
|
||||
|
||||
Param();
|
||||
Param(int _type, bool _readonly, int _offset,
|
||||
@@ -4579,6 +4621,13 @@ template<> struct ParamType<uint64>
|
||||
enum { type = Param::UINT64 };
|
||||
};
|
||||
|
||||
template<> struct ParamType<uchar>
|
||||
{
|
||||
typedef uchar const_param_type;
|
||||
typedef uchar member_type;
|
||||
|
||||
enum { type = Param::UCHAR };
|
||||
};
|
||||
|
||||
/*!
|
||||
"\nThe CommandLineParser class is designed for command line arguments parsing\n"
|
||||
|
||||
@@ -73,12 +73,16 @@ namespace cv { namespace gpu
|
||||
FEATURE_SET_COMPUTE_20 = 20,
|
||||
FEATURE_SET_COMPUTE_21 = 21,
|
||||
FEATURE_SET_COMPUTE_30 = 30,
|
||||
FEATURE_SET_COMPUTE_35 = 35,
|
||||
|
||||
GLOBAL_ATOMICS = FEATURE_SET_COMPUTE_11,
|
||||
SHARED_ATOMICS = FEATURE_SET_COMPUTE_12,
|
||||
NATIVE_DOUBLE = FEATURE_SET_COMPUTE_13,
|
||||
WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30
|
||||
WARP_SHUFFLE_FUNCTIONS = FEATURE_SET_COMPUTE_30,
|
||||
DYNAMIC_PARALLELISM = FEATURE_SET_COMPUTE_35
|
||||
};
|
||||
|
||||
// Checks whether current device supports the given feature
|
||||
CV_EXPORTS bool deviceSupports(FeatureSet feature_set);
|
||||
|
||||
// Gives information about what GPU archs this OpenCV GPU module was
|
||||
@@ -116,6 +120,9 @@ namespace cv { namespace gpu
|
||||
|
||||
int multiProcessorCount() const { return multi_processor_count_; }
|
||||
|
||||
size_t sharedMemPerBlock() const;
|
||||
|
||||
void queryMemory(size_t& totalMemory, size_t& freeMemory) const;
|
||||
size_t freeMemory() const;
|
||||
size_t totalMemory() const;
|
||||
|
||||
@@ -129,7 +136,6 @@ namespace cv { namespace gpu
|
||||
|
||||
private:
|
||||
void query();
|
||||
void queryMemory(size_t& free_memory, size_t& total_memory) const;
|
||||
|
||||
int device_id_;
|
||||
|
||||
@@ -549,29 +555,6 @@ namespace cv { namespace gpu
|
||||
{
|
||||
ensureSizeIsEnough(size.height, size.width, type, m);
|
||||
}
|
||||
|
||||
inline void createContinuous(int rows, int cols, int type, GpuMat& m)
|
||||
{
|
||||
int area = rows * cols;
|
||||
if (!m.isContinuous() || m.type() != type || m.size().area() != area)
|
||||
ensureSizeIsEnough(1, area, type, m);
|
||||
m = m.reshape(0, rows);
|
||||
}
|
||||
|
||||
inline void ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m)
|
||||
{
|
||||
if (m.type() == type && m.rows >= rows && m.cols >= cols)
|
||||
m = m(Rect(0, 0, cols, rows));
|
||||
else
|
||||
m.create(rows, cols, type);
|
||||
}
|
||||
|
||||
inline GpuMat allocMatFromBuf(int rows, int cols, int type, GpuMat &mat)
|
||||
{
|
||||
if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols)
|
||||
return mat(Rect(0, 0, cols, rows));
|
||||
return mat = GpuMat(rows, cols, type);
|
||||
}
|
||||
}}
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
@@ -751,7 +751,9 @@ typedef struct CvBigFuncTable
|
||||
(tab).fn_2d[CV_64F] = (void*)FUNCNAME##_64f##FLAG
|
||||
|
||||
#ifdef __cplusplus
|
||||
//! OpenGL extension table
|
||||
|
||||
// < Deprecated
|
||||
|
||||
class CV_EXPORTS CvOpenGlFuncTab
|
||||
{
|
||||
public:
|
||||
@@ -777,10 +779,16 @@ CV_EXPORTS void icvSetOpenGlFuncTab(const CvOpenGlFuncTab* tab);
|
||||
|
||||
CV_EXPORTS bool icvCheckGlError(const char* file, const int line, const char* func = "");
|
||||
|
||||
// >
|
||||
|
||||
namespace cv { namespace ogl {
|
||||
CV_EXPORTS bool checkError(const char* file, const int line, const char* func = "");
|
||||
}}
|
||||
|
||||
#if defined(__GNUC__)
|
||||
#define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__, __func__)) )
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__, __func__)) )
|
||||
#else
|
||||
#define CV_CheckGlError() CV_DbgAssert( (::icvCheckGlError(__FILE__, __LINE__)) )
|
||||
#define CV_CheckGlError() CV_DbgAssert( (cv::ogl::checkError(__FILE__, __LINE__)) )
|
||||
#endif
|
||||
|
||||
#endif //__cplusplus
|
||||
|
||||
@@ -46,289 +46,238 @@
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/opengl_interop_deprecated.hpp"
|
||||
|
||||
namespace cv { namespace ogl {
|
||||
|
||||
/////////////////// OpenGL Objects ///////////////////
|
||||
|
||||
namespace cv
|
||||
{
|
||||
//! Smart pointer for OpenGL buffer memory with reference counting.
|
||||
class CV_EXPORTS GlBuffer
|
||||
class CV_EXPORTS Buffer
|
||||
{
|
||||
public:
|
||||
enum Usage
|
||||
enum Target
|
||||
{
|
||||
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
|
||||
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
|
||||
ARRAY_BUFFER = 0x8892, //!< The buffer will be used as a source for vertex data
|
||||
ELEMENT_ARRAY_BUFFER = 0x8893, //!< The buffer will be used for indices (in glDrawElements, for example)
|
||||
PIXEL_PACK_BUFFER = 0x88EB, //!< The buffer will be used for reading from OpenGL textures
|
||||
PIXEL_UNPACK_BUFFER = 0x88EC //!< The buffer will be used for writing to OpenGL textures
|
||||
};
|
||||
|
||||
enum Access
|
||||
{
|
||||
READ_ONLY = 0x88B8,
|
||||
WRITE_ONLY = 0x88B9,
|
||||
READ_WRITE = 0x88BA
|
||||
};
|
||||
|
||||
//! create empty buffer
|
||||
explicit GlBuffer(Usage usage);
|
||||
Buffer();
|
||||
|
||||
//! create buffer from existed buffer id
|
||||
Buffer(int arows, int acols, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
Buffer(Size asize, int atype, unsigned int abufId, bool autoRelease = false);
|
||||
|
||||
//! create buffer
|
||||
GlBuffer(int rows, int cols, int type, Usage usage);
|
||||
GlBuffer(Size size, int type, Usage usage);
|
||||
Buffer(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
Buffer(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! copy from host/device memory
|
||||
GlBuffer(InputArray mat, Usage usage);
|
||||
explicit Buffer(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
void create(int rows, int cols, int type, Usage usage);
|
||||
void create(Size size, int type, Usage usage);
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
//! create buffer
|
||||
void create(int arows, int acols, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
void create(Size asize, int atype, Target target = ARRAY_BUFFER, bool autoRelease = false) { create(asize.height, asize.width, atype, target, autoRelease); }
|
||||
|
||||
//! release memory and delete buffer object
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat);
|
||||
//! set auto release mode (if true, release will be called in object's destructor)
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false);
|
||||
|
||||
//! copy to host/device memory
|
||||
void copyTo(OutputArray arr, Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! create copy of current buffer
|
||||
Buffer clone(Target target = ARRAY_BUFFER, bool autoRelease = false) const;
|
||||
|
||||
//! bind buffer for specified target
|
||||
void bind(Target target) const;
|
||||
|
||||
//! unbind any buffers from specified target
|
||||
static void unbind(Target target);
|
||||
|
||||
//! map to host memory
|
||||
Mat mapHost();
|
||||
Mat mapHost(Access access);
|
||||
void unmapHost();
|
||||
|
||||
//! map to device memory
|
||||
gpu::GpuMat mapDevice();
|
||||
void unmapDevice();
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
int rows() const { return rows_; }
|
||||
int cols() const { return cols_; }
|
||||
Size size() const { return Size(cols_, rows_); }
|
||||
bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
int type() const { return type_; }
|
||||
int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
int channels() const { return CV_MAT_CN(type_); }
|
||||
int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
inline Usage usage() const { return usage_; }
|
||||
unsigned int bufId() const;
|
||||
|
||||
class Impl;
|
||||
|
||||
private:
|
||||
Ptr<Impl> impl_;
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
Usage usage_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
|
||||
|
||||
//! Smart pointer for OpenGL 2d texture memory with reference counting.
|
||||
class CV_EXPORTS GlTexture
|
||||
//! Smart pointer for OpenGL 2D texture memory with reference counting.
|
||||
class CV_EXPORTS Texture2D
|
||||
{
|
||||
public:
|
||||
enum Format
|
||||
{
|
||||
NONE = 0,
|
||||
DEPTH_COMPONENT = 0x1902, //!< Depth
|
||||
RGB = 0x1907, //!< Red, Green, Blue
|
||||
RGBA = 0x1908 //!< Red, Green, Blue, Alpha
|
||||
};
|
||||
|
||||
//! create empty texture
|
||||
GlTexture();
|
||||
Texture2D();
|
||||
|
||||
//! create texture from existed texture id
|
||||
Texture2D(int arows, int acols, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
Texture2D(Size asize, Format aformat, unsigned int atexId, bool autoRelease = false);
|
||||
|
||||
//! create texture
|
||||
GlTexture(int rows, int cols, int type);
|
||||
GlTexture(Size size, int type);
|
||||
Texture2D(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
Texture2D(Size asize, Format aformat, bool autoRelease = false);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit GlTexture(InputArray mat, bool bgra = true);
|
||||
explicit Texture2D(InputArray arr, bool autoRelease = false);
|
||||
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
//! create texture
|
||||
void create(int arows, int acols, Format aformat, bool autoRelease = false);
|
||||
void create(Size asize, Format aformat, bool autoRelease = false) { create(asize.height, asize.width, aformat, autoRelease); }
|
||||
|
||||
//! release memory and delete texture object
|
||||
void release();
|
||||
|
||||
//! set auto release mode (if true, release will be called in object's destructor)
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat, bool bgra = true);
|
||||
void copyFrom(InputArray arr, bool autoRelease = false);
|
||||
|
||||
//! copy to host/device memory
|
||||
void copyTo(OutputArray arr, int ddepth = CV_32F, bool autoRelease = false) const;
|
||||
|
||||
//! bind texture to current active texture unit for GL_TEXTURE_2D target
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
int rows() const { return rows_; }
|
||||
int cols() const { return cols_; }
|
||||
Size size() const { return Size(cols_, rows_); }
|
||||
bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
Format format() const { return format_; }
|
||||
|
||||
unsigned int texId() const;
|
||||
|
||||
class Impl;
|
||||
|
||||
private:
|
||||
Ptr<Impl> impl_;
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
GlBuffer buf_;
|
||||
Format format_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
|
||||
|
||||
//! OpenGL Arrays
|
||||
class CV_EXPORTS GlArrays
|
||||
class CV_EXPORTS Arrays
|
||||
{
|
||||
public:
|
||||
inline GlArrays()
|
||||
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
|
||||
{
|
||||
}
|
||||
Arrays();
|
||||
|
||||
void setVertexArray(InputArray vertex);
|
||||
inline void resetVertexArray() { vertex_.release(); }
|
||||
void resetVertexArray();
|
||||
|
||||
void setColorArray(InputArray color, bool bgra = true);
|
||||
inline void resetColorArray() { color_.release(); }
|
||||
void setColorArray(InputArray color);
|
||||
void resetColorArray();
|
||||
|
||||
void setNormalArray(InputArray normal);
|
||||
inline void resetNormalArray() { normal_.release(); }
|
||||
void resetNormalArray();
|
||||
|
||||
void setTexCoordArray(InputArray texCoord);
|
||||
inline void resetTexCoordArray() { texCoord_.release(); }
|
||||
void resetTexCoordArray();
|
||||
|
||||
void release();
|
||||
|
||||
void setAutoRelease(bool flag);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return vertex_.rows(); }
|
||||
inline int cols() const { return vertex_.cols(); }
|
||||
inline Size size() const { return vertex_.size(); }
|
||||
inline bool empty() const { return vertex_.empty(); }
|
||||
int size() const { return size_; }
|
||||
bool empty() const { return size_ == 0; }
|
||||
|
||||
private:
|
||||
GlBuffer vertex_;
|
||||
GlBuffer color_;
|
||||
bool bgra_;
|
||||
GlBuffer normal_;
|
||||
GlBuffer texCoord_;
|
||||
int size_;
|
||||
Buffer vertex_;
|
||||
Buffer color_;
|
||||
Buffer normal_;
|
||||
Buffer texCoord_;
|
||||
};
|
||||
|
||||
//! OpenGL Font
|
||||
class CV_EXPORTS GlFont
|
||||
{
|
||||
public:
|
||||
enum Weight
|
||||
{
|
||||
WEIGHT_LIGHT = 300,
|
||||
WEIGHT_NORMAL = 400,
|
||||
WEIGHT_SEMIBOLD = 600,
|
||||
WEIGHT_BOLD = 700,
|
||||
WEIGHT_BLACK = 900
|
||||
};
|
||||
|
||||
enum Style
|
||||
{
|
||||
STYLE_NORMAL = 0,
|
||||
STYLE_ITALIC = 1,
|
||||
STYLE_UNDERLINE = 2
|
||||
};
|
||||
|
||||
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
|
||||
|
||||
void draw(const char* str, int len) const;
|
||||
|
||||
inline const std::string& family() const { return family_; }
|
||||
inline int height() const { return height_; }
|
||||
inline Weight weight() const { return weight_; }
|
||||
inline Style style() const { return style_; }
|
||||
|
||||
private:
|
||||
GlFont(const std::string& family, int height, Weight weight, Style style);
|
||||
|
||||
std::string family_;
|
||||
int height_;
|
||||
Weight weight_;
|
||||
Style style_;
|
||||
|
||||
unsigned int base_;
|
||||
|
||||
GlFont(const GlFont&);
|
||||
GlFont& operator =(const GlFont&);
|
||||
};
|
||||
|
||||
//! render functions
|
||||
/////////////////// Render Functions ///////////////////
|
||||
|
||||
//! render texture rectangle in window
|
||||
CV_EXPORTS void render(const GlTexture& tex,
|
||||
CV_EXPORTS void render(const Texture2D& tex,
|
||||
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
|
||||
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
|
||||
|
||||
//! render mode
|
||||
namespace RenderMode {
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
}
|
||||
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
|
||||
|
||||
//! OpenGL camera
|
||||
class CV_EXPORTS GlCamera
|
||||
{
|
||||
public:
|
||||
GlCamera();
|
||||
|
||||
void lookAt(Point3d eye, Point3d center, Point3d up);
|
||||
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
|
||||
|
||||
void setScale(Point3d scale);
|
||||
|
||||
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
|
||||
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
|
||||
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
|
||||
|
||||
void setupProjectionMatrix() const;
|
||||
void setupModelViewMatrix() const;
|
||||
|
||||
private:
|
||||
Point3d eye_;
|
||||
Point3d center_;
|
||||
Point3d up_;
|
||||
|
||||
Point3d pos_;
|
||||
double yaw_;
|
||||
double pitch_;
|
||||
double roll_;
|
||||
|
||||
bool useLookAtParams_;
|
||||
|
||||
Point3d scale_;
|
||||
|
||||
Mat projectionMatrix_;
|
||||
|
||||
double fov_;
|
||||
double aspect_;
|
||||
|
||||
double left_;
|
||||
double right_;
|
||||
double bottom_;
|
||||
double top_;
|
||||
|
||||
double zNear_;
|
||||
double zFar_;
|
||||
|
||||
bool perspectiveProjection_;
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
|
||||
inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
|
||||
inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
|
||||
inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
|
||||
inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const Arrays& arr, int mode = POINTS, Scalar color = Scalar::all(255));
|
||||
CV_EXPORTS void render(const Arrays& arr, InputArray indices, int mode = POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
}} // namespace cv::gl
|
||||
|
||||
namespace cv { namespace gpu {
|
||||
|
||||
//! set a CUDA device to use OpenGL interoperability
|
||||
CV_EXPORTS void setGlDevice(int device = 0);
|
||||
|
||||
}}
|
||||
|
||||
namespace cv {
|
||||
|
||||
template <> CV_EXPORTS void Ptr<cv::ogl::Buffer::Impl>::delete_obj();
|
||||
template <> CV_EXPORTS void Ptr<cv::ogl::Texture2D::Impl>::delete_obj();
|
||||
|
||||
namespace gpu
|
||||
{
|
||||
//! set a CUDA device to use OpenGL interoperability
|
||||
CV_EXPORTS void setGlDevice(int device = 0);
|
||||
}
|
||||
} // namespace cv
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
|
||||
@@ -0,0 +1,330 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other GpuMaterials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
||||
#define __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
|
||||
namespace cv
|
||||
{
|
||||
//! Smart pointer for OpenGL buffer memory with reference counting.
|
||||
class CV_EXPORTS GlBuffer
|
||||
{
|
||||
public:
|
||||
enum Usage
|
||||
{
|
||||
ARRAY_BUFFER = 0x8892, // buffer will use for OpenGL arrays (vertices, colors, normals, etc)
|
||||
TEXTURE_BUFFER = 0x88EC // buffer will ise for OpenGL textures
|
||||
};
|
||||
|
||||
//! create empty buffer
|
||||
explicit GlBuffer(Usage usage);
|
||||
|
||||
//! create buffer
|
||||
GlBuffer(int rows, int cols, int type, Usage usage);
|
||||
GlBuffer(Size size, int type, Usage usage);
|
||||
|
||||
//! copy from host/device memory
|
||||
GlBuffer(InputArray mat, Usage usage);
|
||||
|
||||
void create(int rows, int cols, int type, Usage usage);
|
||||
void create(Size size, int type, Usage usage);
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
//! map to host memory
|
||||
Mat mapHost();
|
||||
void unmapHost();
|
||||
|
||||
//! map to device memory
|
||||
gpu::GpuMat mapDevice();
|
||||
void unmapDevice();
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
inline Usage usage() const { return usage_; }
|
||||
|
||||
class Impl;
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
Usage usage_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlBuffer::Impl>::delete_obj();
|
||||
|
||||
//! Smart pointer for OpenGL 2d texture memory with reference counting.
|
||||
class CV_EXPORTS GlTexture
|
||||
{
|
||||
public:
|
||||
//! create empty texture
|
||||
GlTexture();
|
||||
|
||||
//! create texture
|
||||
GlTexture(int rows, int cols, int type);
|
||||
GlTexture(Size size, int type);
|
||||
|
||||
//! copy from host/device memory
|
||||
explicit GlTexture(InputArray mat, bool bgra = true);
|
||||
|
||||
void create(int rows, int cols, int type);
|
||||
void create(Size size, int type);
|
||||
void release();
|
||||
|
||||
//! copy from host/device memory
|
||||
void copyFrom(InputArray mat, bool bgra = true);
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return rows_; }
|
||||
inline int cols() const { return cols_; }
|
||||
inline Size size() const { return Size(cols_, rows_); }
|
||||
inline bool empty() const { return rows_ == 0 || cols_ == 0; }
|
||||
|
||||
inline int type() const { return type_; }
|
||||
inline int depth() const { return CV_MAT_DEPTH(type_); }
|
||||
inline int channels() const { return CV_MAT_CN(type_); }
|
||||
inline int elemSize() const { return CV_ELEM_SIZE(type_); }
|
||||
inline int elemSize1() const { return CV_ELEM_SIZE1(type_); }
|
||||
|
||||
class Impl;
|
||||
private:
|
||||
int rows_;
|
||||
int cols_;
|
||||
int type_;
|
||||
|
||||
Ptr<Impl> impl_;
|
||||
GlBuffer buf_;
|
||||
};
|
||||
|
||||
template <> CV_EXPORTS void Ptr<GlTexture::Impl>::delete_obj();
|
||||
|
||||
//! OpenGL Arrays
|
||||
class CV_EXPORTS GlArrays
|
||||
{
|
||||
public:
|
||||
inline GlArrays()
|
||||
: vertex_(GlBuffer::ARRAY_BUFFER), color_(GlBuffer::ARRAY_BUFFER), bgra_(true), normal_(GlBuffer::ARRAY_BUFFER), texCoord_(GlBuffer::ARRAY_BUFFER)
|
||||
{
|
||||
}
|
||||
|
||||
void setVertexArray(InputArray vertex);
|
||||
inline void resetVertexArray() { vertex_.release(); }
|
||||
|
||||
void setColorArray(InputArray color, bool bgra = true);
|
||||
inline void resetColorArray() { color_.release(); }
|
||||
|
||||
void setNormalArray(InputArray normal);
|
||||
inline void resetNormalArray() { normal_.release(); }
|
||||
|
||||
void setTexCoordArray(InputArray texCoord);
|
||||
inline void resetTexCoordArray() { texCoord_.release(); }
|
||||
|
||||
void bind() const;
|
||||
void unbind() const;
|
||||
|
||||
inline int rows() const { return vertex_.rows(); }
|
||||
inline int cols() const { return vertex_.cols(); }
|
||||
inline Size size() const { return vertex_.size(); }
|
||||
inline bool empty() const { return vertex_.empty(); }
|
||||
|
||||
private:
|
||||
GlBuffer vertex_;
|
||||
GlBuffer color_;
|
||||
bool bgra_;
|
||||
GlBuffer normal_;
|
||||
GlBuffer texCoord_;
|
||||
};
|
||||
|
||||
//! OpenGL Font
|
||||
class CV_EXPORTS GlFont
|
||||
{
|
||||
public:
|
||||
enum Weight
|
||||
{
|
||||
WEIGHT_LIGHT = 300,
|
||||
WEIGHT_NORMAL = 400,
|
||||
WEIGHT_SEMIBOLD = 600,
|
||||
WEIGHT_BOLD = 700,
|
||||
WEIGHT_BLACK = 900
|
||||
};
|
||||
|
||||
enum Style
|
||||
{
|
||||
STYLE_NORMAL = 0,
|
||||
STYLE_ITALIC = 1,
|
||||
STYLE_UNDERLINE = 2
|
||||
};
|
||||
|
||||
static Ptr<GlFont> get(const std::string& family, int height = 12, Weight weight = WEIGHT_NORMAL, Style style = STYLE_NORMAL);
|
||||
|
||||
void draw(const char* str, int len) const;
|
||||
|
||||
inline const std::string& family() const { return family_; }
|
||||
inline int height() const { return height_; }
|
||||
inline Weight weight() const { return weight_; }
|
||||
inline Style style() const { return style_; }
|
||||
|
||||
private:
|
||||
GlFont(const std::string& family, int height, Weight weight, Style style);
|
||||
|
||||
std::string family_;
|
||||
int height_;
|
||||
Weight weight_;
|
||||
Style style_;
|
||||
|
||||
unsigned int base_;
|
||||
|
||||
GlFont(const GlFont&);
|
||||
GlFont& operator =(const GlFont&);
|
||||
};
|
||||
|
||||
//! render functions
|
||||
|
||||
//! render texture rectangle in window
|
||||
CV_EXPORTS void render(const GlTexture& tex,
|
||||
Rect_<double> wndRect = Rect_<double>(0.0, 0.0, 1.0, 1.0),
|
||||
Rect_<double> texRect = Rect_<double>(0.0, 0.0, 1.0, 1.0));
|
||||
|
||||
//! render mode
|
||||
namespace RenderMode {
|
||||
enum {
|
||||
POINTS = 0x0000,
|
||||
LINES = 0x0001,
|
||||
LINE_LOOP = 0x0002,
|
||||
LINE_STRIP = 0x0003,
|
||||
TRIANGLES = 0x0004,
|
||||
TRIANGLE_STRIP = 0x0005,
|
||||
TRIANGLE_FAN = 0x0006,
|
||||
QUADS = 0x0007,
|
||||
QUAD_STRIP = 0x0008,
|
||||
POLYGON = 0x0009
|
||||
};
|
||||
}
|
||||
|
||||
//! render OpenGL arrays
|
||||
CV_EXPORTS void render(const GlArrays& arr, int mode = RenderMode::POINTS, Scalar color = Scalar::all(255));
|
||||
|
||||
CV_EXPORTS void render(const std::string& str, const Ptr<GlFont>& font, Scalar color, Point2d pos);
|
||||
|
||||
//! OpenGL camera
|
||||
class CV_EXPORTS GlCamera
|
||||
{
|
||||
public:
|
||||
GlCamera();
|
||||
|
||||
void lookAt(Point3d eye, Point3d center, Point3d up);
|
||||
void setCameraPos(Point3d pos, double yaw, double pitch, double roll);
|
||||
|
||||
void setScale(Point3d scale);
|
||||
|
||||
void setProjectionMatrix(const Mat& projectionMatrix, bool transpose = true);
|
||||
void setPerspectiveProjection(double fov, double aspect, double zNear, double zFar);
|
||||
void setOrthoProjection(double left, double right, double bottom, double top, double zNear, double zFar);
|
||||
|
||||
void setupProjectionMatrix() const;
|
||||
void setupModelViewMatrix() const;
|
||||
|
||||
private:
|
||||
Point3d eye_;
|
||||
Point3d center_;
|
||||
Point3d up_;
|
||||
|
||||
Point3d pos_;
|
||||
double yaw_;
|
||||
double pitch_;
|
||||
double roll_;
|
||||
|
||||
bool useLookAtParams_;
|
||||
|
||||
Point3d scale_;
|
||||
|
||||
Mat projectionMatrix_;
|
||||
|
||||
double fov_;
|
||||
double aspect_;
|
||||
|
||||
double left_;
|
||||
double right_;
|
||||
double bottom_;
|
||||
double top_;
|
||||
|
||||
double zNear_;
|
||||
double zFar_;
|
||||
|
||||
bool perspectiveProjection_;
|
||||
};
|
||||
|
||||
inline void GlBuffer::create(Size _size, int _type, Usage _usage) { create(_size.height, _size.width, _type, _usage); }
|
||||
inline void GlBuffer::create(int _rows, int _cols, int _type) { create(_rows, _cols, _type, usage()); }
|
||||
inline void GlBuffer::create(Size _size, int _type) { create(_size.height, _size.width, _type, usage()); }
|
||||
inline void GlTexture::create(Size _size, int _type) { create(_size.height, _size.width, _type); }
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
#endif // __OPENCV_OPENGL_INTEROP_DEPRECATED_HPP__
|
||||
@@ -52,7 +52,8 @@ PERF_TEST_P( Size_MatType_CmpType, compareScalar,
|
||||
|
||||
declare.in(src1, src2, WARMUP_RNG).out(dst);
|
||||
|
||||
TEST_CYCLE() cv::compare(src1, src2, dst, cmpType);
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) cv::compare(src1, src2, dst, cmpType);
|
||||
|
||||
SANITY_CHECK(dst);
|
||||
}
|
||||
|
||||
@@ -29,9 +29,9 @@ 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);
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) src.convertTo(dst, depthDst, alpha);
|
||||
|
||||
SANITY_CHECK(dst, alpha == 1.0 ? 1e-12 : 1e-7);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,8 @@ PERF_TEST_P(Size_MatType, Mat_Eye,
|
||||
|
||||
declare.out(diagonalMatrix);
|
||||
|
||||
TEST_CYCLE()
|
||||
int runs = (size.width <= 640) ? 15 : 5;
|
||||
TEST_CYCLE_MULTIRUN(runs)
|
||||
{
|
||||
diagonalMatrix = Mat::eye(size, type);
|
||||
}
|
||||
@@ -38,7 +39,8 @@ PERF_TEST_P(Size_MatType, Mat_Zeros,
|
||||
|
||||
declare.out(zeroMatrix);
|
||||
|
||||
TEST_CYCLE()
|
||||
int runs = (size.width <= 640) ? 15 : 5;
|
||||
TEST_CYCLE_MULTIRUN(runs)
|
||||
{
|
||||
zeroMatrix = Mat::zeros(size, type);
|
||||
}
|
||||
|
||||
@@ -30,7 +30,8 @@ PERF_TEST_P( Size_SrcDepth_DstChannels, merge,
|
||||
}
|
||||
|
||||
Mat dst;
|
||||
TEST_CYCLE() merge( (vector<Mat> &)mv, dst );
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) merge( (vector<Mat> &)mv, dst );
|
||||
|
||||
SANITY_CHECK(dst, 1e-12);
|
||||
}
|
||||
@@ -26,8 +26,8 @@ PERF_TEST_P( Size_Depth_Channels, split,
|
||||
randu(m, 0, 255);
|
||||
|
||||
vector<Mat> mv;
|
||||
|
||||
TEST_CYCLE() split(m, (vector<Mat>&)mv);
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) split(m, (vector<Mat>&)mv);
|
||||
|
||||
SANITY_CHECK(mv, 1e-12);
|
||||
}
|
||||
|
||||
@@ -97,7 +97,8 @@ PERF_TEST_P(Size_MatType, countNonZero, testing::Combine( testing::Values( TYPIC
|
||||
|
||||
declare.in(src, WARMUP_RNG);
|
||||
|
||||
TEST_CYCLE() cnt = countNonZero(src);
|
||||
int runs = (sz.width <= 640) ? 8 : 1;
|
||||
TEST_CYCLE_MULTIRUN(runs) cnt = countNonZero(src);
|
||||
|
||||
SANITY_CHECK(cnt);
|
||||
}
|
||||
|
||||
@@ -324,6 +324,7 @@ void Algorithm::setAlgorithm(const char* parameter, const Ptr<Algorithm>& value)
|
||||
|
||||
|
||||
|
||||
|
||||
int Algorithm::getInt(const string& parameter) const
|
||||
{
|
||||
return get<int>(parameter);
|
||||
@@ -431,6 +432,14 @@ void AlgorithmInfo::write(const Algorithm* algo, FileStorage& fs) const
|
||||
Ptr<Algorithm> nestedAlgo = algo->get<Algorithm>(pname);
|
||||
nestedAlgo->write(fs);
|
||||
}
|
||||
else if( p.type == Param::FLOAT)
|
||||
cv::write(fs, pname, algo->getDouble(pname));
|
||||
else if( p.type == Param::UNSIGNED_INT)
|
||||
cv::write(fs, pname, algo->getInt(pname));//TODO: implement cv::write(, , unsigned int)
|
||||
else if( p.type == Param::UINT64)
|
||||
cv::write(fs, pname, algo->getInt(pname));//TODO: implement cv::write(, , uint64)
|
||||
else if( p.type == Param::UCHAR)
|
||||
cv::write(fs, pname, algo->getInt(pname));
|
||||
else
|
||||
{
|
||||
string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
||||
@@ -490,6 +499,26 @@ void AlgorithmInfo::read(Algorithm* algo, const FileNode& fn) const
|
||||
nestedAlgo->read(n);
|
||||
info->set(algo, pname.c_str(), p.type, &nestedAlgo, true);
|
||||
}
|
||||
else if( p.type == Param::FLOAT )
|
||||
{
|
||||
float val = (float)n;
|
||||
info->set(algo, pname.c_str(), p.type, &val, true);
|
||||
}
|
||||
else if( p.type == Param::UNSIGNED_INT )
|
||||
{
|
||||
unsigned int val = (unsigned int)((int)n);//TODO: implement conversion (unsigned int)FileNode
|
||||
info->set(algo, pname.c_str(), p.type, &val, true);
|
||||
}
|
||||
else if( p.type == Param::UINT64)
|
||||
{
|
||||
uint64 val = (uint64)((int)n);//TODO: implement conversion (uint64)FileNode
|
||||
info->set(algo, pname.c_str(), p.type, &val, true);
|
||||
}
|
||||
else if( p.type == Param::UCHAR)
|
||||
{
|
||||
uchar val = (uchar)((int)n);
|
||||
info->set(algo, pname.c_str(), p.type, &val, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
string msg = format("unknown/unsupported type of '%s' parameter == %d", pname.c_str(), p.type);
|
||||
@@ -512,6 +541,10 @@ union GetSetParam
|
||||
Mat (Algorithm::*get_mat)() const;
|
||||
vector<Mat> (Algorithm::*get_mat_vector)() const;
|
||||
Ptr<Algorithm> (Algorithm::*get_algo)() const;
|
||||
float (Algorithm::*get_float)() const;
|
||||
unsigned int (Algorithm::*get_uint)() const;
|
||||
uint64 (Algorithm::*get_uint64)() const;
|
||||
uchar (Algorithm::*get_uchar)() const;
|
||||
|
||||
void (Algorithm::*set_int)(int);
|
||||
void (Algorithm::*set_bool)(bool);
|
||||
@@ -520,6 +553,10 @@ union GetSetParam
|
||||
void (Algorithm::*set_mat)(const Mat&);
|
||||
void (Algorithm::*set_mat_vector)(const vector<Mat>&);
|
||||
void (Algorithm::*set_algo)(const Ptr<Algorithm>&);
|
||||
void (Algorithm::*set_float)(float);
|
||||
void (Algorithm::*set_uint)(unsigned int);
|
||||
void (Algorithm::*set_uint64)(uint64);
|
||||
void (Algorithm::*set_uchar)(uchar);
|
||||
};
|
||||
|
||||
static string getNameOfType(int argType);
|
||||
@@ -536,6 +573,10 @@ static string getNameOfType(int argType)
|
||||
case Param::MAT: return "cv::Mat";
|
||||
case Param::MAT_VECTOR: return "std::vector<cv::Mat>";
|
||||
case Param::ALGORITHM: return "algorithm";
|
||||
case Param::FLOAT: return "float";
|
||||
case Param::UNSIGNED_INT: return "unsigned int";
|
||||
case Param::UINT64: return "unsigned int64";
|
||||
case Param::UCHAR: return "unsigned char";
|
||||
default: CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
}
|
||||
return "";
|
||||
@@ -547,9 +588,10 @@ static string getErrorMessageForWrongArgumentInSetter(string algoName, string pa
|
||||
+ " method was called for the parameter '" + paramName + "' of the algorithm '" + algoName
|
||||
+"', the parameter has " + getNameOfType(paramType) + " type, ";
|
||||
|
||||
if (paramType == Param::INT || paramType == Param::BOOLEAN || paramType == Param::REAL)
|
||||
if (paramType == Param::INT || paramType == Param::BOOLEAN || paramType == Param::REAL
|
||||
|| paramType == Param::FLOAT || paramType == Param::UNSIGNED_INT || paramType == Param::UINT64 || paramType == Param::UCHAR)
|
||||
{
|
||||
message += "so it should be set by integer, boolean, or double value, ";
|
||||
message += "so it should be set by integer, unsigned integer, uint64, unsigned char, boolean, float or double value, ";
|
||||
}
|
||||
else if (paramType == Param::SHORT)
|
||||
{
|
||||
@@ -569,16 +611,20 @@ static string getErrorMessageForWrongArgumentInGetter(string algoName, string pa
|
||||
|
||||
if (paramType == Param::BOOLEAN)
|
||||
{
|
||||
message += "so it should be get as integer, boolean, or double value, ";
|
||||
message += "so it should be get as integer, unsigned integer, uint64, boolean, unsigned char, float or double value, ";
|
||||
}
|
||||
else if (paramType == Param::INT)
|
||||
else if (paramType == Param::INT || paramType == Param::UNSIGNED_INT || paramType == Param::UINT64 || paramType == Param::UCHAR)
|
||||
{
|
||||
message += "so it should be get as integer or double value, ";
|
||||
message += "so it should be get as integer, unsigned integer, uint64, unsigned char, float or double value, ";
|
||||
}
|
||||
else if (paramType == Param::SHORT)
|
||||
{
|
||||
message += "so it should be get as integer value, ";
|
||||
}
|
||||
else if (paramType == Param::FLOAT || paramType == Param::REAL)
|
||||
{
|
||||
message += "so it should be get as float or double value, ";
|
||||
}
|
||||
message += "but the getter was called to get a " + getNameOfType(argType) + " value";
|
||||
|
||||
return message;
|
||||
@@ -597,9 +643,12 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
GetSetParam f;
|
||||
f.set_int = p->setter;
|
||||
|
||||
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL || argType == Param::SHORT )
|
||||
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL || argType == Param::SHORT
|
||||
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR)
|
||||
{
|
||||
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN || (p->type == Param::SHORT && argType == Param::INT)) )
|
||||
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN
|
||||
|| p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || argType == Param::UCHAR
|
||||
|| (p->type == Param::SHORT && argType == Param::INT)) )
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
@@ -607,9 +656,21 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
|
||||
if( p->type == Param::INT )
|
||||
{
|
||||
bool is_ok = true;
|
||||
int val = argType == Param::INT ? *(const int*)value :
|
||||
argType == Param::BOOLEAN ? (int)*(const bool*)value :
|
||||
saturate_cast<int>(*(const double*)value);
|
||||
argType == Param::BOOLEAN ? (int)*(const bool*)value :
|
||||
argType == Param::REAL ? saturate_cast<int>(*(const double*)value) :
|
||||
argType == Param::FLOAT ? saturate_cast<int>(*(const float*)value) :
|
||||
argType == Param::UNSIGNED_INT ? (int)*(const unsigned int*)value :
|
||||
argType == Param::UINT64 ? (int)*(const uint64*)value :
|
||||
argType == Param::UCHAR ? (int)*(const uchar*)value :
|
||||
(int)(is_ok = false);
|
||||
|
||||
if (!is_ok)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
||||
}
|
||||
|
||||
if( p->setter )
|
||||
(algo->*f.set_int)(val);
|
||||
else
|
||||
@@ -617,6 +678,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
}
|
||||
else if( p->type == Param::SHORT )
|
||||
{
|
||||
CV_DbgAssert(argType == Param::INT);
|
||||
int val = *(const int*)value;
|
||||
if( p->setter )
|
||||
(algo->*f.set_int)(val);
|
||||
@@ -625,24 +687,133 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
}
|
||||
else if( p->type == Param::BOOLEAN )
|
||||
{
|
||||
bool is_ok = true;
|
||||
bool val = argType == Param::INT ? *(const int*)value != 0 :
|
||||
argType == Param::BOOLEAN ? *(const bool*)value :
|
||||
*(const double*)value != 0;
|
||||
argType == Param::REAL ? (*(const double*)value != 0) :
|
||||
argType == Param::FLOAT ? (*(const float*)value != 0) :
|
||||
argType == Param::UNSIGNED_INT ? (*(const unsigned int*)value != 0):
|
||||
argType == Param::UINT64 ? (*(const uint64*)value != 0):
|
||||
argType == Param::UCHAR ? (*(const uchar*)value != 0):
|
||||
(int)(is_ok = false);
|
||||
|
||||
if (!is_ok)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
||||
}
|
||||
|
||||
if( p->setter )
|
||||
(algo->*f.set_bool)(val);
|
||||
else
|
||||
*(bool*)((uchar*)algo + p->offset) = val;
|
||||
}
|
||||
else
|
||||
else if( p->type == Param::REAL )
|
||||
{
|
||||
bool is_ok = true;
|
||||
double val = argType == Param::INT ? (double)*(const int*)value :
|
||||
argType == Param::BOOLEAN ? (double)*(const bool*)value :
|
||||
*(const double*)value;
|
||||
argType == Param::REAL ? (double)(*(const double*)value ) :
|
||||
argType == Param::FLOAT ? (double)(*(const float*)value ) :
|
||||
argType == Param::UNSIGNED_INT ? (double)(*(const unsigned int*)value ) :
|
||||
argType == Param::UINT64 ? (double)(*(const uint64*)value ) :
|
||||
argType == Param::UCHAR ? (double)(*(const uchar*)value ) :
|
||||
(double)(is_ok = false);
|
||||
|
||||
if (!is_ok)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
||||
}
|
||||
if( p->setter )
|
||||
(algo->*f.set_double)(val);
|
||||
else
|
||||
*(double*)((uchar*)algo + p->offset) = val;
|
||||
}
|
||||
else if( p->type == Param::FLOAT )
|
||||
{
|
||||
bool is_ok = true;
|
||||
double val = argType == Param::INT ? (double)*(const int*)value :
|
||||
argType == Param::BOOLEAN ? (double)*(const bool*)value :
|
||||
argType == Param::REAL ? (double)(*(const double*)value ) :
|
||||
argType == Param::FLOAT ? (double)(*(const float*)value ) :
|
||||
argType == Param::UNSIGNED_INT ? (double)(*(const unsigned int*)value ) :
|
||||
argType == Param::UINT64 ? (double)(*(const uint64*)value ) :
|
||||
argType == Param::UCHAR ? (double)(*(const uchar*)value ) :
|
||||
(double)(is_ok = false);
|
||||
|
||||
if (!is_ok)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
||||
}
|
||||
if( p->setter )
|
||||
(algo->*f.set_float)((float)val);
|
||||
else
|
||||
*(float*)((uchar*)algo + p->offset) = (float)val;
|
||||
}
|
||||
else if( p->type == Param::UNSIGNED_INT )
|
||||
{
|
||||
bool is_ok = true;
|
||||
unsigned int val = argType == Param::INT ? (unsigned int)*(const int*)value :
|
||||
argType == Param::BOOLEAN ? (unsigned int)*(const bool*)value :
|
||||
argType == Param::REAL ? saturate_cast<unsigned int>(*(const double*)value ) :
|
||||
argType == Param::FLOAT ? saturate_cast<unsigned int>(*(const float*)value ) :
|
||||
argType == Param::UNSIGNED_INT ? (unsigned int)(*(const unsigned int*)value ) :
|
||||
argType == Param::UINT64 ? (unsigned int)(*(const uint64*)value ) :
|
||||
argType == Param::UCHAR ? (unsigned int)(*(const uchar*)value ) :
|
||||
(int)(is_ok = false);
|
||||
|
||||
if (!is_ok)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
||||
}
|
||||
if( p->setter )
|
||||
(algo->*f.set_uint)(val);
|
||||
else
|
||||
*(unsigned int*)((uchar*)algo + p->offset) = val;
|
||||
}
|
||||
else if( p->type == Param::UINT64 )
|
||||
{
|
||||
bool is_ok = true;
|
||||
uint64 val = argType == Param::INT ? (uint64)*(const int*)value :
|
||||
argType == Param::BOOLEAN ? (uint64)*(const bool*)value :
|
||||
argType == Param::REAL ? saturate_cast<uint64>(*(const double*)value ) :
|
||||
argType == Param::FLOAT ? saturate_cast<uint64>(*(const float*)value ) :
|
||||
argType == Param::UNSIGNED_INT ? (uint64)(*(const unsigned int*)value ) :
|
||||
argType == Param::UINT64 ? (uint64)(*(const uint64*)value ) :
|
||||
argType == Param::UCHAR ? (uint64)(*(const uchar*)value ) :
|
||||
(int)(is_ok = false);
|
||||
|
||||
if (!is_ok)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
||||
}
|
||||
if( p->setter )
|
||||
(algo->*f.set_uint64)(val);
|
||||
else
|
||||
*(uint64*)((uchar*)algo + p->offset) = val;
|
||||
}
|
||||
else if( p->type == Param::UCHAR )
|
||||
{
|
||||
bool is_ok = true;
|
||||
uchar val = argType == Param::INT ? (uchar)*(const int*)value :
|
||||
argType == Param::BOOLEAN ? (uchar)*(const bool*)value :
|
||||
argType == Param::REAL ? saturate_cast<uchar>(*(const double*)value ) :
|
||||
argType == Param::FLOAT ? saturate_cast<uchar>(*(const float*)value ) :
|
||||
argType == Param::UNSIGNED_INT ? (uchar)(*(const unsigned int*)value ) :
|
||||
argType == Param::UINT64 ? (uchar)(*(const uint64*)value ) :
|
||||
argType == Param::UCHAR ? (uchar)(*(const uchar*)value ) :
|
||||
(int)(is_ok = false);
|
||||
|
||||
if (!is_ok)
|
||||
{
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type in the setter");
|
||||
}
|
||||
if( p->setter )
|
||||
(algo->*f.set_uchar)(val);
|
||||
else
|
||||
*(uchar*)((uchar*)algo + p->offset) = val;
|
||||
}
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Wrong parameter type in the setter");
|
||||
}
|
||||
else if( argType == Param::STRING )
|
||||
{
|
||||
@@ -713,11 +884,12 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
GetSetParam f;
|
||||
f.get_int = p->getter;
|
||||
|
||||
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL )
|
||||
if( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL || argType == Param::SHORT
|
||||
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR)
|
||||
{
|
||||
if( p->type == Param::INT )
|
||||
{
|
||||
if (!( argType == Param::INT || argType == Param::REAL ))
|
||||
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
@@ -725,9 +897,20 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
int val = p->getter ? (algo->*f.get_int)() : *(int*)((uchar*)algo + p->offset);
|
||||
|
||||
if( argType == Param::INT )
|
||||
*(int*)value = val;
|
||||
*(int*)value = (int)val;
|
||||
else if ( argType == Param::REAL )
|
||||
*(double*)value = (double)val;
|
||||
else if ( argType == Param::FLOAT)
|
||||
*(float*)value = (float)val;
|
||||
else if ( argType == Param::UNSIGNED_INT )
|
||||
*(unsigned int*)value = (unsigned int)val;
|
||||
else if ( argType == Param::UINT64 )
|
||||
*(uint64*)value = (uint64)val;
|
||||
else if ( argType == Param::UCHAR)
|
||||
*(uchar*)value = (uchar)val;
|
||||
else
|
||||
*(double*)value = val;
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
|
||||
}
|
||||
else if( p->type == Param::SHORT )
|
||||
{
|
||||
@@ -742,7 +925,7 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
}
|
||||
else if( p->type == Param::BOOLEAN )
|
||||
{
|
||||
if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL ))
|
||||
if (!( argType == Param::INT || argType == Param::BOOLEAN || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
@@ -753,20 +936,126 @@ void AlgorithmInfo::get(const Algorithm* algo, const char* parameter, int argTyp
|
||||
*(int*)value = (int)val;
|
||||
else if( argType == Param::BOOLEAN )
|
||||
*(bool*)value = val;
|
||||
else
|
||||
else if ( argType == Param::REAL )
|
||||
*(double*)value = (int)val;
|
||||
else if ( argType == Param::FLOAT)
|
||||
*(float*)value = (float)((int)val);
|
||||
else if ( argType == Param::UNSIGNED_INT )
|
||||
*(unsigned int*)value = (unsigned int)val;
|
||||
else if ( argType == Param::UINT64 )
|
||||
*(uint64*)value = (int)val;
|
||||
else if ( argType == Param::UCHAR)
|
||||
*(uchar*)value = (uchar)val;
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
}
|
||||
else
|
||||
else if( p->type == Param::REAL )
|
||||
{
|
||||
if( argType != Param::REAL )
|
||||
if(!( argType == Param::REAL || argType == Param::FLOAT))
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
double val = p->getter ? (algo->*f.get_double)() : *(double*)((uchar*)algo + p->offset);
|
||||
|
||||
*(double*)value = val;
|
||||
if ( argType == Param::REAL )
|
||||
*(double*)value = val;
|
||||
else if ( argType == Param::FLOAT)
|
||||
*(float*)value = (float)val;
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
}
|
||||
else if( p->type == Param::FLOAT )
|
||||
{
|
||||
if(!( argType == Param::REAL || argType == Param::FLOAT))
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
float val = p->getter ? (algo->*f.get_float)() : *(float*)((uchar*)algo + p->offset);
|
||||
|
||||
if ( argType == Param::REAL )
|
||||
*(double*)value = (double)val;
|
||||
else if ( argType == Param::FLOAT)
|
||||
*(float*)value = (float)val;
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
}
|
||||
else if( p->type == Param::UNSIGNED_INT )
|
||||
{
|
||||
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
unsigned int val = p->getter ? (algo->*f.get_uint)() : *(unsigned int*)((uchar*)algo + p->offset);
|
||||
|
||||
if( argType == Param::INT )
|
||||
*(int*)value = (int)val;
|
||||
else if ( argType == Param::REAL )
|
||||
*(double*)value = (double)val;
|
||||
else if ( argType == Param::FLOAT)
|
||||
*(float*)value = (float)val;
|
||||
else if ( argType == Param::UNSIGNED_INT )
|
||||
*(unsigned int*)value = (unsigned int)val;
|
||||
else if ( argType == Param::UINT64 )
|
||||
*(uint64*)value = (uint64)val;
|
||||
else if ( argType == Param::UCHAR)
|
||||
*(uchar*)value = (uchar)val;
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
}
|
||||
else if( p->type == Param::UINT64 )
|
||||
{
|
||||
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
uint64 val = p->getter ? (algo->*f.get_uint64)() : *(uint64*)((uchar*)algo + p->offset);
|
||||
|
||||
if( argType == Param::INT )
|
||||
*(int*)value = (int)val;
|
||||
else if ( argType == Param::REAL )
|
||||
*(double*)value = (double)val;
|
||||
else if ( argType == Param::FLOAT)
|
||||
*(float*)value = (float)val;
|
||||
else if ( argType == Param::UNSIGNED_INT )
|
||||
*(unsigned int*)value = (unsigned int)val;
|
||||
else if ( argType == Param::UINT64 )
|
||||
*(uint64*)value = (uint64)val;
|
||||
else if ( argType == Param::UCHAR)
|
||||
*(uchar*)value = (uchar)val;
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
}
|
||||
else if( p->type == Param::UCHAR )
|
||||
{
|
||||
if (!( argType == Param::INT || argType == Param::REAL || argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR))
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInGetter(algo->name(), parameter, p->type, argType);
|
||||
CV_Error(CV_StsBadArg, message);
|
||||
}
|
||||
uchar val = p->getter ? (algo->*f.get_uchar)() : *(uchar*)((uchar*)algo + p->offset);
|
||||
|
||||
if( argType == Param::INT )
|
||||
*(int*)value = val;
|
||||
else if ( argType == Param::REAL )
|
||||
*(double*)value = val;
|
||||
else if ( argType == Param::FLOAT)
|
||||
*(float*)value = val;
|
||||
else if ( argType == Param::UNSIGNED_INT )
|
||||
*(unsigned int*)value = val;
|
||||
else if ( argType == Param::UINT64 )
|
||||
*(uint64*)value = val;
|
||||
else if ( argType == Param::UCHAR)
|
||||
*(uchar*)value = val;
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Wrong argument type");
|
||||
|
||||
}
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "Unknown/unsupported parameter type");
|
||||
}
|
||||
else if( argType == Param::STRING )
|
||||
{
|
||||
@@ -852,7 +1141,9 @@ void AlgorithmInfo::addParam_(Algorithm& algo, const char* parameter, int argTyp
|
||||
CV_Assert( argType == Param::INT || argType == Param::BOOLEAN ||
|
||||
argType == Param::REAL || argType == Param::STRING ||
|
||||
argType == Param::MAT || argType == Param::MAT_VECTOR ||
|
||||
argType == Param::ALGORITHM || argType == Param::SHORT );
|
||||
argType == Param::ALGORITHM || argType == Param::SHORT
|
||||
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64
|
||||
|| argType == Param::UCHAR);
|
||||
data->params.add(string(parameter), Param(argType, readOnly,
|
||||
(int)((size_t)value - (size_t)(void*)&algo),
|
||||
getter, setter, help));
|
||||
@@ -939,6 +1230,46 @@ void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
float& value, bool readOnly,
|
||||
float (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(float),
|
||||
const string& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<float>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
unsigned int& value, bool readOnly,
|
||||
unsigned int (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(unsigned int),
|
||||
const string& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<unsigned int>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
uint64& value, bool readOnly,
|
||||
uint64 (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(uint64),
|
||||
const string& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<uint64>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
void AlgorithmInfo::addParam(Algorithm& algo, const char* parameter,
|
||||
uchar& value, bool readOnly,
|
||||
uchar (Algorithm::*getter)(),
|
||||
void (Algorithm::*setter)(uchar),
|
||||
const string& help)
|
||||
{
|
||||
addParam_(algo, parameter, ParamType<uchar>::type, &value, readOnly,
|
||||
(Algorithm::Getter)getter, (Algorithm::Setter)setter, help);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* End of file. */
|
||||
|
||||
@@ -48,8 +48,8 @@
|
||||
#include <cuda_runtime.h>
|
||||
#include <npp.h>
|
||||
|
||||
#define CUDART_MINIMUM_REQUIRED_VERSION 4010
|
||||
#define NPP_MINIMUM_REQUIRED_VERSION 4100
|
||||
#define CUDART_MINIMUM_REQUIRED_VERSION 4020
|
||||
#define NPP_MINIMUM_REQUIRED_VERSION 4200
|
||||
|
||||
#if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION)
|
||||
#error "Insufficient Cuda Runtime library version, please update it."
|
||||
@@ -64,8 +64,108 @@ using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
#ifndef HAVE_CUDA
|
||||
|
||||
#define throw_nogpu CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support")
|
||||
|
||||
#else // HAVE_CUDA
|
||||
|
||||
namespace
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
||||
{
|
||||
if (cudaSuccess != err)
|
||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
}
|
||||
|
||||
inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
|
||||
{
|
||||
if (err < 0)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "NPP API Call Error: " << err;
|
||||
cv::gpu::error(msg.str().c_str(), file, line, func);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
|
||||
//////////////////////////////// Initialization & Info ////////////////////////
|
||||
|
||||
#ifndef HAVE_CUDA
|
||||
|
||||
int cv::gpu::getCudaEnabledDeviceCount() { return 0; }
|
||||
|
||||
void cv::gpu::setDevice(int) { throw_nogpu; }
|
||||
int cv::gpu::getDevice() { throw_nogpu; return 0; }
|
||||
|
||||
void cv::gpu::resetDevice() { throw_nogpu; }
|
||||
|
||||
bool cv::gpu::deviceSupports(FeatureSet) { throw_nogpu; return false; }
|
||||
|
||||
bool cv::gpu::TargetArchs::builtWith(FeatureSet) { throw_nogpu; return false; }
|
||||
bool cv::gpu::TargetArchs::has(int, int) { throw_nogpu; return false; }
|
||||
bool cv::gpu::TargetArchs::hasPtx(int, int) { throw_nogpu; return false; }
|
||||
bool cv::gpu::TargetArchs::hasBin(int, int) { throw_nogpu; return false; }
|
||||
bool cv::gpu::TargetArchs::hasEqualOrLessPtx(int, int) { throw_nogpu; return false; }
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreater(int, int) { throw_nogpu; return false; }
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreaterPtx(int, int) { throw_nogpu; return false; }
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int, int) { throw_nogpu; return false; }
|
||||
|
||||
size_t cv::gpu::DeviceInfo::sharedMemPerBlock() const { throw_nogpu; return 0; }
|
||||
void cv::gpu::DeviceInfo::queryMemory(size_t&, size_t&) const { throw_nogpu; }
|
||||
size_t cv::gpu::DeviceInfo::freeMemory() const { throw_nogpu; return 0; }
|
||||
size_t cv::gpu::DeviceInfo::totalMemory() const { throw_nogpu; return 0; }
|
||||
bool cv::gpu::DeviceInfo::supports(FeatureSet) const { throw_nogpu; return false; }
|
||||
bool cv::gpu::DeviceInfo::isCompatible() const { throw_nogpu; return false; }
|
||||
void cv::gpu::DeviceInfo::query() { throw_nogpu; }
|
||||
|
||||
void cv::gpu::printCudaDeviceInfo(int) { throw_nogpu; }
|
||||
void cv::gpu::printShortCudaDeviceInfo(int) { throw_nogpu; }
|
||||
|
||||
#else // HAVE_CUDA
|
||||
|
||||
int cv::gpu::getCudaEnabledDeviceCount()
|
||||
{
|
||||
int count;
|
||||
cudaError_t error = cudaGetDeviceCount( &count );
|
||||
|
||||
if (error == cudaErrorInsufficientDriver)
|
||||
return -1;
|
||||
|
||||
if (error == cudaErrorNoDevice)
|
||||
return 0;
|
||||
|
||||
cudaSafeCall( error );
|
||||
return count;
|
||||
}
|
||||
|
||||
void cv::gpu::setDevice(int device)
|
||||
{
|
||||
cudaSafeCall( cudaSetDevice( device ) );
|
||||
}
|
||||
|
||||
int cv::gpu::getDevice()
|
||||
{
|
||||
int device;
|
||||
cudaSafeCall( cudaGetDevice( &device ) );
|
||||
return device;
|
||||
}
|
||||
|
||||
void cv::gpu::resetDevice()
|
||||
{
|
||||
cudaSafeCall( cudaDeviceReset() );
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class CudaArch
|
||||
@@ -92,11 +192,9 @@ namespace
|
||||
|
||||
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
|
||||
@@ -149,12 +247,7 @@ namespace
|
||||
|
||||
bool cv::gpu::TargetArchs::builtWith(cv::gpu::FeatureSet feature_set)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return cudaArch.builtWith(feature_set);
|
||||
#else
|
||||
(void)feature_set;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::gpu::TargetArchs::has(int major, int minor)
|
||||
@@ -164,35 +257,17 @@ bool cv::gpu::TargetArchs::has(int major, int minor)
|
||||
|
||||
bool cv::gpu::TargetArchs::hasPtx(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return cudaArch.hasPtx(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::gpu::TargetArchs::hasBin(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return cudaArch.hasBin(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::gpu::TargetArchs::hasEqualOrLessPtx(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return cudaArch.hasEqualOrLessPtx(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreater(int major, int minor)
|
||||
@@ -202,24 +277,12 @@ bool cv::gpu::TargetArchs::hasEqualOrGreater(int major, int minor)
|
||||
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreaterPtx(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return cudaArch.hasEqualOrGreaterPtx(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::gpu::TargetArchs::hasEqualOrGreaterBin(int major, int minor)
|
||||
{
|
||||
#if defined (HAVE_CUDA)
|
||||
return cudaArch.hasEqualOrGreaterBin(major, minor);
|
||||
#else
|
||||
(void)major;
|
||||
(void)minor;
|
||||
return false;
|
||||
#endif
|
||||
}
|
||||
|
||||
bool cv::gpu::deviceSupports(FeatureSet feature_set)
|
||||
@@ -247,108 +310,84 @@ bool cv::gpu::deviceSupports(FeatureSet feature_set)
|
||||
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")
|
||||
|
||||
int cv::gpu::getCudaEnabledDeviceCount() { return 0; }
|
||||
|
||||
void cv::gpu::setDevice(int) { throw_nogpu; }
|
||||
int cv::gpu::getDevice() { throw_nogpu; return 0; }
|
||||
|
||||
void cv::gpu::resetDevice() { throw_nogpu; }
|
||||
|
||||
size_t cv::gpu::DeviceInfo::freeMemory() const { throw_nogpu; return 0; }
|
||||
size_t cv::gpu::DeviceInfo::totalMemory() const { throw_nogpu; return 0; }
|
||||
|
||||
bool cv::gpu::DeviceInfo::supports(cv::gpu::FeatureSet) const { throw_nogpu; return false; }
|
||||
|
||||
bool cv::gpu::DeviceInfo::isCompatible() const { throw_nogpu; return false; }
|
||||
|
||||
void cv::gpu::DeviceInfo::query() { throw_nogpu; }
|
||||
void cv::gpu::DeviceInfo::queryMemory(size_t&, size_t&) const { throw_nogpu; }
|
||||
|
||||
void cv::gpu::printCudaDeviceInfo(int) { throw_nogpu; }
|
||||
void cv::gpu::printShortCudaDeviceInfo(int) { throw_nogpu; }
|
||||
|
||||
#undef throw_nogpu
|
||||
|
||||
#else // HAVE_CUDA
|
||||
|
||||
namespace
|
||||
{
|
||||
#if defined(__GNUC__)
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, __func__)
|
||||
#else /* defined(__CUDACC__) || defined(__MSVC__) */
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__)
|
||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__)
|
||||
#endif
|
||||
|
||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
||||
class DeviceProps
|
||||
{
|
||||
if (cudaSuccess != err)
|
||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
public:
|
||||
DeviceProps();
|
||||
~DeviceProps();
|
||||
|
||||
cudaDeviceProp* get(int devID);
|
||||
|
||||
private:
|
||||
std::vector<cudaDeviceProp*> props_;
|
||||
};
|
||||
|
||||
DeviceProps::DeviceProps()
|
||||
{
|
||||
props_.resize(10, 0);
|
||||
}
|
||||
|
||||
inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
|
||||
DeviceProps::~DeviceProps()
|
||||
{
|
||||
if (err < 0)
|
||||
for (size_t i = 0; i < props_.size(); ++i)
|
||||
{
|
||||
std::ostringstream msg;
|
||||
msg << "NPP API Call Error: " << err;
|
||||
cv::gpu::error(msg.str().c_str(), file, line, func);
|
||||
if (props_[i])
|
||||
delete props_[i];
|
||||
}
|
||||
props_.clear();
|
||||
}
|
||||
|
||||
cudaDeviceProp* DeviceProps::get(int devID)
|
||||
{
|
||||
if (devID >= (int) props_.size())
|
||||
props_.resize(devID + 5, 0);
|
||||
|
||||
if (!props_[devID])
|
||||
{
|
||||
props_[devID] = new cudaDeviceProp;
|
||||
cudaSafeCall( cudaGetDeviceProperties(props_[devID], devID) );
|
||||
}
|
||||
|
||||
return props_[devID];
|
||||
}
|
||||
|
||||
DeviceProps deviceProps;
|
||||
}
|
||||
|
||||
int cv::gpu::getCudaEnabledDeviceCount()
|
||||
size_t cv::gpu::DeviceInfo::sharedMemPerBlock() const
|
||||
{
|
||||
int count;
|
||||
cudaError_t error = cudaGetDeviceCount( &count );
|
||||
|
||||
if (error == cudaErrorInsufficientDriver)
|
||||
return -1;
|
||||
|
||||
if (error == cudaErrorNoDevice)
|
||||
return 0;
|
||||
|
||||
cudaSafeCall(error);
|
||||
return count;
|
||||
return deviceProps.get(device_id_)->sharedMemPerBlock;
|
||||
}
|
||||
|
||||
void cv::gpu::setDevice(int device)
|
||||
void cv::gpu::DeviceInfo::queryMemory(size_t& _totalMemory, size_t& _freeMemory) const
|
||||
{
|
||||
cudaSafeCall( cudaSetDevice( device ) );
|
||||
}
|
||||
int prevDeviceID = getDevice();
|
||||
if (prevDeviceID != device_id_)
|
||||
setDevice(device_id_);
|
||||
|
||||
int cv::gpu::getDevice()
|
||||
{
|
||||
int device;
|
||||
cudaSafeCall( cudaGetDevice( &device ) );
|
||||
return device;
|
||||
}
|
||||
cudaSafeCall( cudaMemGetInfo(&_freeMemory, &_totalMemory) );
|
||||
|
||||
void cv::gpu::resetDevice()
|
||||
{
|
||||
cudaSafeCall( cudaDeviceReset() );
|
||||
if (prevDeviceID != device_id_)
|
||||
setDevice(prevDeviceID);
|
||||
}
|
||||
|
||||
size_t cv::gpu::DeviceInfo::freeMemory() const
|
||||
{
|
||||
size_t free_memory, total_memory;
|
||||
queryMemory(free_memory, total_memory);
|
||||
return free_memory;
|
||||
size_t _totalMemory, _freeMemory;
|
||||
queryMemory(_totalMemory, _freeMemory);
|
||||
return _freeMemory;
|
||||
}
|
||||
|
||||
size_t cv::gpu::DeviceInfo::totalMemory() const
|
||||
{
|
||||
size_t free_memory, total_memory;
|
||||
queryMemory(free_memory, total_memory);
|
||||
return total_memory;
|
||||
size_t _totalMemory, _freeMemory;
|
||||
queryMemory(_totalMemory, _freeMemory);
|
||||
return _totalMemory;
|
||||
}
|
||||
|
||||
bool cv::gpu::DeviceInfo::supports(cv::gpu::FeatureSet feature_set) const
|
||||
bool cv::gpu::DeviceInfo::supports(FeatureSet feature_set) const
|
||||
{
|
||||
int version = majorVersion() * 10 + minorVersion();
|
||||
return version >= feature_set;
|
||||
@@ -370,24 +409,12 @@ bool cv::gpu::DeviceInfo::isCompatible() const
|
||||
|
||||
void cv::gpu::DeviceInfo::query()
|
||||
{
|
||||
cudaDeviceProp prop;
|
||||
cudaSafeCall(cudaGetDeviceProperties(&prop, device_id_));
|
||||
name_ = prop.name;
|
||||
multi_processor_count_ = prop.multiProcessorCount;
|
||||
majorVersion_ = prop.major;
|
||||
minorVersion_ = prop.minor;
|
||||
}
|
||||
const cudaDeviceProp* prop = deviceProps.get(device_id_);
|
||||
|
||||
void cv::gpu::DeviceInfo::queryMemory(size_t& free_memory, size_t& total_memory) const
|
||||
{
|
||||
int prev_device_id = getDevice();
|
||||
if (prev_device_id != device_id_)
|
||||
setDevice(device_id_);
|
||||
|
||||
cudaSafeCall(cudaMemGetInfo(&free_memory, &total_memory));
|
||||
|
||||
if (prev_device_id != device_id_)
|
||||
setDevice(prev_device_id);
|
||||
name_ = prop->name;
|
||||
multi_processor_count_ = prop->multiProcessorCount;
|
||||
majorVersion_ = prop->major;
|
||||
minorVersion_ = prop->minor;
|
||||
}
|
||||
|
||||
namespace
|
||||
@@ -764,6 +791,50 @@ cv::Mat::Mat(const GpuMat& m) : flags(0), dims(0), rows(0), cols(0), data(0), re
|
||||
m.download(*this);
|
||||
}
|
||||
|
||||
void cv::gpu::createContinuous(int rows, int cols, int type, GpuMat& m)
|
||||
{
|
||||
int area = rows * cols;
|
||||
if (m.empty() || m.type() != type || !m.isContinuous() || m.size().area() < area)
|
||||
m.create(1, area, type);
|
||||
|
||||
m.cols = cols;
|
||||
m.rows = rows;
|
||||
m.step = m.elemSize() * cols;
|
||||
m.flags |= Mat::CONTINUOUS_FLAG;
|
||||
}
|
||||
|
||||
void cv::gpu::ensureSizeIsEnough(int rows, int cols, int type, GpuMat& m)
|
||||
{
|
||||
if (m.empty() || m.type() != type || m.data != m.datastart)
|
||||
m.create(rows, cols, type);
|
||||
else
|
||||
{
|
||||
const size_t esz = m.elemSize();
|
||||
const ptrdiff_t delta2 = m.dataend - m.datastart;
|
||||
|
||||
const size_t minstep = m.cols * esz;
|
||||
|
||||
Size wholeSize;
|
||||
wholeSize.height = std::max(static_cast<int>((delta2 - minstep) / m.step + 1), m.rows);
|
||||
wholeSize.width = std::max(static_cast<int>((delta2 - m.step * (wholeSize.height - 1)) / esz), m.cols);
|
||||
|
||||
if (wholeSize.height < rows || wholeSize.width < cols)
|
||||
m.create(rows, cols, type);
|
||||
else
|
||||
{
|
||||
m.cols = cols;
|
||||
m.rows = rows;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GpuMat cv::gpu::allocMatFromBuf(int rows, int cols, int type, GpuMat &mat)
|
||||
{
|
||||
if (!mat.empty() && mat.type() == type && mat.rows >= rows && mat.cols >= cols)
|
||||
return mat(Rect(0, 0, cols, rows));
|
||||
return mat = GpuMat(rows, cols, type);
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
class GpuFuncTable
|
||||
@@ -787,25 +858,25 @@ namespace
|
||||
};
|
||||
}
|
||||
|
||||
#if !defined HAVE_CUDA || defined(CUDA_DISABLER_)
|
||||
#ifndef HAVE_CUDA
|
||||
|
||||
namespace
|
||||
{
|
||||
class EmptyFuncTable : public GpuFuncTable
|
||||
{
|
||||
public:
|
||||
void copy(const Mat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void copy(const GpuMat&, Mat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void copy(const GpuMat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void copy(const Mat&, GpuMat&) const { throw_nogpu; }
|
||||
void copy(const GpuMat&, Mat&) const { throw_nogpu; }
|
||||
void copy(const GpuMat&, GpuMat&) const { throw_nogpu; }
|
||||
|
||||
void copyWithMask(const GpuMat&, GpuMat&, const GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void copyWithMask(const GpuMat&, GpuMat&, const GpuMat&) const { throw_nogpu; }
|
||||
|
||||
void convert(const GpuMat&, GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void convert(const GpuMat&, GpuMat&, double, double) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void convert(const GpuMat&, GpuMat&) const { throw_nogpu; }
|
||||
void convert(const GpuMat&, GpuMat&, double, double) const { throw_nogpu; }
|
||||
|
||||
void setTo(GpuMat&, Scalar, const GpuMat&) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void setTo(GpuMat&, Scalar, const GpuMat&) const { throw_nogpu; }
|
||||
|
||||
void mallocPitch(void**, size_t*, size_t, size_t) const { CV_Error(CV_GpuNotSupported, "The library is compiled without CUDA support"); }
|
||||
void mallocPitch(void**, size_t*, size_t, size_t) const { throw_nogpu; }
|
||||
void free(void*) const {}
|
||||
};
|
||||
|
||||
|
||||
@@ -42,6 +42,10 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if defined _M_IX86 && defined _MSC_VER && _MSC_VER < 1700
|
||||
#pragma float_control(precise, on)
|
||||
#endif
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
@@ -1095,6 +1099,7 @@ double cv::invert( InputArray _src, OutputArray _dst, int method )
|
||||
if( type == CV_32FC1 )
|
||||
{
|
||||
double d = det3(Sf);
|
||||
|
||||
if( d != 0. )
|
||||
{
|
||||
double t[12];
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
#include "opencv2/core/opengl_interop.hpp"
|
||||
#include "opencv2/core/opengl_interop_deprecated.hpp"
|
||||
|
||||
/****************************************************************************************\
|
||||
* [scaled] Identity matrix initialization *
|
||||
@@ -925,9 +926,13 @@ _InputArray::_InputArray(const Mat& m) : flags(MAT), obj((void*)&m) {}
|
||||
_InputArray::_InputArray(const vector<Mat>& vec) : flags(STD_VECTOR_MAT), obj((void*)&vec) {}
|
||||
_InputArray::_InputArray(const double& val) : flags(FIXED_TYPE + FIXED_SIZE + MATX + CV_64F), obj((void*)&val), sz(Size(1,1)) {}
|
||||
_InputArray::_InputArray(const MatExpr& expr) : flags(FIXED_TYPE + FIXED_SIZE + EXPR), obj((void*)&expr) {}
|
||||
_InputArray::_InputArray(const GlBuffer& buf) : flags(FIXED_TYPE + FIXED_SIZE + OPENGL_BUFFER), obj((void*)&buf) {}
|
||||
_InputArray::_InputArray(const GlTexture& tex) : flags(FIXED_TYPE + FIXED_SIZE + OPENGL_TEXTURE), obj((void*)&tex) {}
|
||||
// < Deprecated
|
||||
_InputArray::_InputArray(const GlBuffer&) : flags(0), obj(0) {}
|
||||
_InputArray::_InputArray(const GlTexture&) : flags(0), obj(0) {}
|
||||
// >
|
||||
_InputArray::_InputArray(const gpu::GpuMat& d_mat) : flags(GPU_MAT), obj((void*)&d_mat) {}
|
||||
_InputArray::_InputArray(const ogl::Buffer& buf) : flags(OPENGL_BUFFER), obj((void*)&buf) {}
|
||||
_InputArray::_InputArray(const ogl::Texture2D& tex) : flags(OPENGL_TEXTURE), obj((void*)&tex) {}
|
||||
|
||||
Mat _InputArray::getMat(int i) const
|
||||
{
|
||||
@@ -1069,26 +1074,14 @@ void _InputArray::getMatVector(vector<Mat>& mv) const
|
||||
|
||||
GlBuffer _InputArray::getGlBuffer() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_BUFFER);
|
||||
//if( k == OPENGL_BUFFER )
|
||||
{
|
||||
const GlBuffer* buf = (const GlBuffer*)obj;
|
||||
return *buf;
|
||||
}
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return GlBuffer(GlBuffer::ARRAY_BUFFER);
|
||||
}
|
||||
|
||||
GlTexture _InputArray::getGlTexture() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_TEXTURE);
|
||||
//if( k == OPENGL_TEXTURE )
|
||||
{
|
||||
const GlTexture* tex = (const GlTexture*)obj;
|
||||
return *tex;
|
||||
}
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return GlTexture();
|
||||
}
|
||||
|
||||
gpu::GpuMat _InputArray::getGpuMat() const
|
||||
@@ -1096,11 +1089,29 @@ gpu::GpuMat _InputArray::getGpuMat() const
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == GPU_MAT);
|
||||
//if( k == GPU_MAT )
|
||||
{
|
||||
const gpu::GpuMat* d_mat = (const gpu::GpuMat*)obj;
|
||||
return *d_mat;
|
||||
}
|
||||
|
||||
const gpu::GpuMat* d_mat = (const gpu::GpuMat*)obj;
|
||||
return *d_mat;
|
||||
}
|
||||
|
||||
ogl::Buffer _InputArray::getOGlBuffer() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_BUFFER);
|
||||
|
||||
const ogl::Buffer* gl_buf = (const ogl::Buffer*)obj;
|
||||
return *gl_buf;
|
||||
}
|
||||
|
||||
ogl::Texture2D _InputArray::getOGlTexture2D() const
|
||||
{
|
||||
int k = kind();
|
||||
|
||||
CV_Assert(k == OPENGL_TEXTURE);
|
||||
|
||||
const ogl::Texture2D* gl_tex = (const ogl::Texture2D*)obj;
|
||||
return *gl_tex;
|
||||
}
|
||||
|
||||
int _InputArray::kind() const
|
||||
@@ -1167,14 +1178,14 @@ Size _InputArray::size(int i) const
|
||||
if( k == OPENGL_BUFFER )
|
||||
{
|
||||
CV_Assert( i < 0 );
|
||||
const GlBuffer* buf = (const GlBuffer*)obj;
|
||||
const ogl::Buffer* buf = (const ogl::Buffer*)obj;
|
||||
return buf->size();
|
||||
}
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
{
|
||||
CV_Assert( i < 0 );
|
||||
const GlTexture* tex = (const GlTexture*)obj;
|
||||
const ogl::Texture2D* tex = (const ogl::Texture2D*)obj;
|
||||
return tex->size();
|
||||
}
|
||||
|
||||
@@ -1235,10 +1246,7 @@ int _InputArray::type(int i) const
|
||||
}
|
||||
|
||||
if( k == OPENGL_BUFFER )
|
||||
return ((const GlBuffer*)obj)->type();
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
return ((const GlTexture*)obj)->type();
|
||||
return ((const ogl::Buffer*)obj)->type();
|
||||
|
||||
CV_Assert( k == GPU_MAT );
|
||||
//if( k == GPU_MAT )
|
||||
@@ -1290,10 +1298,10 @@ bool _InputArray::empty() const
|
||||
}
|
||||
|
||||
if( k == OPENGL_BUFFER )
|
||||
return ((const GlBuffer*)obj)->empty();
|
||||
return ((const ogl::Buffer*)obj)->empty();
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
return ((const GlTexture*)obj)->empty();
|
||||
return ((const ogl::Texture2D*)obj)->empty();
|
||||
|
||||
CV_Assert( k == GPU_MAT );
|
||||
//if( k == GPU_MAT )
|
||||
@@ -1308,10 +1316,14 @@ _OutputArray::~_OutputArray() {}
|
||||
_OutputArray::_OutputArray(Mat& m) : _InputArray(m) {}
|
||||
_OutputArray::_OutputArray(vector<Mat>& vec) : _InputArray(vec) {}
|
||||
_OutputArray::_OutputArray(gpu::GpuMat& d_mat) : _InputArray(d_mat) {}
|
||||
_OutputArray::_OutputArray(ogl::Buffer& buf) : _InputArray(buf) {}
|
||||
_OutputArray::_OutputArray(ogl::Texture2D& tex) : _InputArray(tex) {}
|
||||
|
||||
_OutputArray::_OutputArray(const Mat& m) : _InputArray(m) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
_OutputArray::_OutputArray(const vector<Mat>& vec) : _InputArray(vec) {flags |= FIXED_SIZE;}
|
||||
_OutputArray::_OutputArray(const gpu::GpuMat& d_mat) : _InputArray(d_mat) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
_OutputArray::_OutputArray(const ogl::Buffer& buf) : _InputArray(buf) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
_OutputArray::_OutputArray(const ogl::Texture2D& tex) : _InputArray(tex) {flags |= FIXED_SIZE|FIXED_TYPE;}
|
||||
|
||||
|
||||
bool _OutputArray::fixedSize() const
|
||||
@@ -1341,6 +1353,13 @@ void _OutputArray::create(Size _sz, int mtype, int i, bool allowTransposed, int
|
||||
((gpu::GpuMat*)obj)->create(_sz, mtype);
|
||||
return;
|
||||
}
|
||||
if( k == OPENGL_BUFFER && i < 0 && !allowTransposed && fixedDepthMask == 0 )
|
||||
{
|
||||
CV_Assert(!fixedSize() || ((ogl::Buffer*)obj)->size() == _sz);
|
||||
CV_Assert(!fixedType() || ((ogl::Buffer*)obj)->type() == mtype);
|
||||
((ogl::Buffer*)obj)->create(_sz, mtype);
|
||||
return;
|
||||
}
|
||||
int sizes[] = {_sz.height, _sz.width};
|
||||
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
|
||||
}
|
||||
@@ -1362,6 +1381,13 @@ void _OutputArray::create(int rows, int cols, int mtype, int i, bool allowTransp
|
||||
((gpu::GpuMat*)obj)->create(rows, cols, mtype);
|
||||
return;
|
||||
}
|
||||
if( k == OPENGL_BUFFER && i < 0 && !allowTransposed && fixedDepthMask == 0 )
|
||||
{
|
||||
CV_Assert(!fixedSize() || ((ogl::Buffer*)obj)->size() == Size(cols, rows));
|
||||
CV_Assert(!fixedType() || ((ogl::Buffer*)obj)->type() == mtype);
|
||||
((ogl::Buffer*)obj)->create(rows, cols, mtype);
|
||||
return;
|
||||
}
|
||||
int sizes[] = {rows, cols};
|
||||
create(2, sizes, mtype, i, allowTransposed, fixedDepthMask);
|
||||
}
|
||||
@@ -1581,6 +1607,18 @@ void _OutputArray::release() const
|
||||
return;
|
||||
}
|
||||
|
||||
if( k == OPENGL_BUFFER )
|
||||
{
|
||||
((ogl::Buffer*)obj)->release();
|
||||
return;
|
||||
}
|
||||
|
||||
if( k == OPENGL_TEXTURE )
|
||||
{
|
||||
((ogl::Texture2D*)obj)->release();
|
||||
return;
|
||||
}
|
||||
|
||||
if( k == NONE )
|
||||
return;
|
||||
|
||||
@@ -1646,6 +1684,20 @@ gpu::GpuMat& _OutputArray::getGpuMatRef() const
|
||||
return *(gpu::GpuMat*)obj;
|
||||
}
|
||||
|
||||
ogl::Buffer& _OutputArray::getOGlBufferRef() const
|
||||
{
|
||||
int k = kind();
|
||||
CV_Assert( k == OPENGL_BUFFER );
|
||||
return *(ogl::Buffer*)obj;
|
||||
}
|
||||
|
||||
ogl::Texture2D& _OutputArray::getOGlTexture2DRef() const
|
||||
{
|
||||
int k = kind();
|
||||
CV_Assert( k == OPENGL_TEXTURE );
|
||||
return *(ogl::Texture2D*)obj;
|
||||
}
|
||||
|
||||
static _OutputArray _none;
|
||||
OutputArray noArray() { return _none; }
|
||||
|
||||
@@ -3496,7 +3548,7 @@ enum { HASH_SIZE0 = 8 };
|
||||
static inline void copyElem(const uchar* from, uchar* to, size_t elemSize)
|
||||
{
|
||||
size_t i;
|
||||
for( i = 0; (int)i <= (int)(elemSize - sizeof(int)); i += sizeof(int) )
|
||||
for( i = 0; i + sizeof(int) <= elemSize; i += sizeof(int) )
|
||||
*(int*)(to + i) = *(const int*)(from + i);
|
||||
for( ; i < elemSize; i++ )
|
||||
to[i] = from[i];
|
||||
@@ -3505,7 +3557,7 @@ static inline void copyElem(const uchar* from, uchar* to, size_t elemSize)
|
||||
static inline bool isZeroElem(const uchar* data, size_t elemSize)
|
||||
{
|
||||
size_t i;
|
||||
for( i = 0; i <= elemSize - sizeof(int); i += sizeof(int) )
|
||||
for( i = 0; i + sizeof(int) <= elemSize; i += sizeof(int) )
|
||||
if( *(int*)(data + i) != 0 )
|
||||
return false;
|
||||
for( ; i < elemSize; i++ )
|
||||
|
||||
@@ -0,0 +1,331 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "precomp.hpp"
|
||||
#include "opencv2/core/opengl_interop_deprecated.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
CvOpenGlFuncTab::~CvOpenGlFuncTab()
|
||||
{
|
||||
}
|
||||
|
||||
void icvSetOpenGlFuncTab(const CvOpenGlFuncTab*)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlBuffer
|
||||
|
||||
class cv::GlBuffer::Impl
|
||||
{
|
||||
};
|
||||
|
||||
cv::GlBuffer::GlBuffer(Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlBuffer::GlBuffer(int, int, int, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlBuffer::GlBuffer(Size, int, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlBuffer::GlBuffer(InputArray, Usage _usage) : rows_(0), cols_(0), type_(0), usage_(_usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::create(int, int, int, Usage)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::release()
|
||||
{
|
||||
}
|
||||
|
||||
void cv::GlBuffer::copyFrom(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::bind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlBuffer::unbind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
Mat cv::GlBuffer::mapHost()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return Mat();
|
||||
}
|
||||
|
||||
void cv::GlBuffer::unmapHost()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
GpuMat cv::GlBuffer::mapDevice()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return GpuMat();
|
||||
}
|
||||
|
||||
void cv::GlBuffer::unmapDevice()
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
template <> void cv::Ptr<cv::GlBuffer::Impl>::delete_obj()
|
||||
{
|
||||
if (obj) delete obj;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GlTexture
|
||||
|
||||
class cv::GlTexture::Impl
|
||||
{
|
||||
};
|
||||
|
||||
cv::GlTexture::GlTexture() : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlTexture::GlTexture(int, int, int) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlTexture::GlTexture(Size, int) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
cv::GlTexture::GlTexture(InputArray, bool) : rows_(0), cols_(0), type_(0), buf_(GlBuffer::TEXTURE_BUFFER)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::create(int, int, int)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::release()
|
||||
{
|
||||
}
|
||||
|
||||
void cv::GlTexture::copyFrom(InputArray, bool)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::bind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlTexture::unbind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
template <> void cv::Ptr<cv::GlTexture::Impl>::delete_obj()
|
||||
{
|
||||
if (obj) delete obj;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlArrays
|
||||
|
||||
void cv::GlArrays::setVertexArray(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::setColorArray(InputArray, bool)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::setNormalArray(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::setTexCoordArray(InputArray)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::bind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlArrays::unbind() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlFont
|
||||
|
||||
cv::GlFont::GlFont(const string& _family, int _height, Weight _weight, Style _style)
|
||||
: family_(_family), height_(_height), weight_(_weight), style_(_style), base_(0)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlFont::draw(const char*, int) const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
Ptr<GlFont> cv::GlFont::get(const std::string&, int, Weight, Style)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return Ptr<GlFont>();
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Rendering
|
||||
|
||||
void cv::render(const GlTexture&, Rect_<double>, Rect_<double>)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::render(const GlArrays&, int, Scalar)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::render(const string&, const Ptr<GlFont>&, Scalar, Point2d)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// GlCamera
|
||||
|
||||
cv::GlCamera::GlCamera() :
|
||||
eye_(0.0, 0.0, -5.0), center_(0.0, 0.0, 0.0), up_(0.0, 1.0, 0.0),
|
||||
pos_(0.0, 0.0, -5.0), yaw_(0.0), pitch_(0.0), roll_(0.0),
|
||||
useLookAtParams_(false),
|
||||
|
||||
scale_(1.0, 1.0, 1.0),
|
||||
|
||||
projectionMatrix_(),
|
||||
fov_(45.0), aspect_(0.0),
|
||||
left_(0.0), right_(1.0), bottom_(1.0), top_(0.0),
|
||||
zNear_(-1.0), zFar_(1.0),
|
||||
perspectiveProjection_(false)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::lookAt(Point3d, Point3d, Point3d)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setCameraPos(Point3d, double, double, double)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setScale(Point3d)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setProjectionMatrix(const Mat&, bool)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setPerspectiveProjection(double, double, double, double)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setOrthoProjection(double, double, double, double, double, double)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setupProjectionMatrix() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
void cv::GlCamera::setupModelViewMatrix() const
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// Error handling
|
||||
|
||||
bool icvCheckGlError(const char*, const int, const char*)
|
||||
{
|
||||
CV_Error(CV_StsNotImplemented, "This function in deprecated, do not use it");
|
||||
return false;
|
||||
}
|
||||
@@ -305,7 +305,9 @@ int cv::getNumThreads(void)
|
||||
|
||||
#elif defined HAVE_CSTRIPES
|
||||
|
||||
return cv::getNumberOfCPUs();
|
||||
return numThreads > 0
|
||||
? numThreads
|
||||
: cv::getNumberOfCPUs();
|
||||
|
||||
#elif defined HAVE_OPENMP
|
||||
|
||||
@@ -491,4 +493,4 @@ CV_IMPL int cvGetNumThreads()
|
||||
CV_IMPL int cvGetThreadNum()
|
||||
{
|
||||
return cv::getThreadNum();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,7 +419,9 @@ static void fixCCS( Mat& mat, int cols, int flags )
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if defined _MSC_VER && _MSC_VER >= 1700
|
||||
#pragma optimize("", off)
|
||||
#endif
|
||||
static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
{
|
||||
dst.create(src1.rows, src1.cols, src1.type());
|
||||
@@ -439,8 +441,8 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
if( !(flags & CV_DXT_MUL_CONJ) )
|
||||
for( j = 0; j < cols; j += 2 )
|
||||
{
|
||||
double re = (double)a[j]*b[j] - (double)a[j+1]*b[j+1];
|
||||
double im = (double)a[j+1]*b[j] + (double)a[j]*b[j+1];
|
||||
double re = (double)a[j]*(double)b[j] - (double)a[j+1]*(double)b[j+1];
|
||||
double im = (double)a[j+1]*(double)b[j] + (double)a[j]*(double)b[j+1];
|
||||
|
||||
c[j] = (float)re;
|
||||
c[j+1] = (float)im;
|
||||
@@ -448,8 +450,8 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
else
|
||||
for( j = 0; j < cols; j += 2 )
|
||||
{
|
||||
double re = (double)a[j]*b[j] + (double)a[j+1]*b[j+1];
|
||||
double im = (double)a[j+1]*b[j] - (double)a[j]*b[j+1];
|
||||
double re = (double)a[j]*(double)b[j] + (double)a[j+1]*(double)b[j+1];
|
||||
double im = (double)a[j+1]*(double)b[j] - (double)a[j]*(double)b[j+1];
|
||||
|
||||
c[j] = (float)re;
|
||||
c[j+1] = (float)im;
|
||||
@@ -482,6 +484,9 @@ static void mulComplex( const Mat& src1, const Mat& src2, Mat& dst, int flags )
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined _MSC_VER && _MSC_VER >= 1700
|
||||
#pragma optimize("", on)
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -39,4 +39,12 @@ TEST(Core_OutputArraySreate, _1997)
|
||||
Size submatSize = Size(256, 256);
|
||||
|
||||
ASSERT_NO_THROW(local::create( mat(Rect(Point(), submatSize)), submatSize, mat.type() ));
|
||||
}
|
||||
}
|
||||
|
||||
TEST(Core_SaturateCast, NegativeNotClipped)
|
||||
{
|
||||
double d = -1.0;
|
||||
unsigned int val = cv::saturate_cast<unsigned int>(d);
|
||||
|
||||
ASSERT_EQ(0xffffffff, val);
|
||||
}
|
||||
|
||||
@@ -531,7 +531,7 @@ StarAdjuster
|
||||
|
||||
SurfAdjuster
|
||||
------------
|
||||
.. ocv:class:: SurfAdjuster: public AdjusterAdapter
|
||||
.. ocv:class:: SurfAdjuster : public AdjusterAdapter
|
||||
|
||||
:ocv:class:`AdjusterAdapter` for ``SurfFeatureDetector``. ::
|
||||
|
||||
|
||||
@@ -658,6 +658,7 @@ protected:
|
||||
virtual void findBlobs(const Mat &image, const Mat &binaryImage, vector<Center> ¢ers) const;
|
||||
|
||||
Params params;
|
||||
AlgorithmInfo* info() const;
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -130,6 +130,26 @@ CV_INIT_ALGORITHM(GFTTDetector, "Feature2D.GFTT",
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
CV_INIT_ALGORITHM(SimpleBlobDetector, "Feature2D.SimpleBlob",
|
||||
obj.info()->addParam(obj, "thresholdStep", obj.params.thresholdStep);
|
||||
obj.info()->addParam(obj, "minThreshold", obj.params.minThreshold);
|
||||
obj.info()->addParam(obj, "maxThreshold", obj.params.maxThreshold);
|
||||
obj.info()->addParam_(obj, "minRepeatability", (sizeof(size_t) == sizeof(uint64))?Param::UINT64 : Param::UNSIGNED_INT, &obj.params.minRepeatability, false, 0, 0);
|
||||
obj.info()->addParam(obj, "minDistBetweenBlobs", obj.params.minDistBetweenBlobs);
|
||||
obj.info()->addParam(obj, "filterByColor", obj.params.filterByColor);
|
||||
obj.info()->addParam(obj, "blobColor", obj.params.blobColor);
|
||||
obj.info()->addParam(obj, "filterByArea", obj.params.filterByArea);
|
||||
obj.info()->addParam(obj, "maxArea", obj.params.maxArea);
|
||||
obj.info()->addParam(obj, "filterByCircularity", obj.params.filterByCircularity);
|
||||
obj.info()->addParam(obj, "maxCircularity", obj.params.maxCircularity);
|
||||
obj.info()->addParam(obj, "filterByInertia", obj.params.filterByInertia);
|
||||
obj.info()->addParam(obj, "maxInertiaRatio", obj.params.maxInertiaRatio);
|
||||
obj.info()->addParam(obj, "filterByConvexity", obj.params.filterByConvexity);
|
||||
obj.info()->addParam(obj, "maxConvexity", obj.params.maxConvexity);
|
||||
);
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
class CV_EXPORTS HarrisDetector : public GFTTDetector
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -21,7 +21,7 @@ source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs})
|
||||
source_group("Device" FILES ${lib_device_hdrs})
|
||||
source_group("Device\\Detail" FILES ${lib_device_hdrs_detail})
|
||||
|
||||
if (HAVE_CUDA)
|
||||
if(HAVE_CUDA)
|
||||
file(GLOB_RECURSE ncv_srcs "src/nvidia/*.cpp" "src/nvidia/*.h*")
|
||||
file(GLOB_RECURSE ncv_cuda "src/nvidia/*.cu")
|
||||
set(ncv_files ${ncv_srcs} ${ncv_cuda})
|
||||
@@ -104,3 +104,7 @@ ocv_add_accuracy_tests(FILES "Include" ${test_hdrs}
|
||||
FILES "Src" ${test_srcs}
|
||||
${nvidia})
|
||||
ocv_add_perf_tests()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
add_subdirectory(perf4au)
|
||||
endif()
|
||||
|
||||
@@ -271,41 +271,37 @@ This class encapsulates a queue of asynchronous calls. Some functions have overl
|
||||
class CV_EXPORTS Stream
|
||||
{
|
||||
public:
|
||||
Stream();
|
||||
~Stream();
|
||||
Stream();
|
||||
~Stream();
|
||||
|
||||
Stream(const Stream&);
|
||||
Stream& operator=(const Stream&);
|
||||
Stream(const Stream&);
|
||||
Stream& operator=(const Stream&);
|
||||
|
||||
bool queryIfComplete();
|
||||
void waitForCompletion();
|
||||
bool queryIfComplete();
|
||||
void waitForCompletion();
|
||||
|
||||
//! downloads asynchronously.
|
||||
// Warning! cv::Mat must point to page locked memory
|
||||
(i.e. to CudaMem data or to its subMat)
|
||||
void enqueueDownload(const GpuMat& src, CudaMem& dst);
|
||||
void enqueueDownload(const GpuMat& src, Mat& dst);
|
||||
void enqueueDownload(const GpuMat& src, CudaMem& dst);
|
||||
void enqueueDownload(const GpuMat& src, Mat& dst);
|
||||
|
||||
//! uploads asynchronously.
|
||||
// Warning! cv::Mat must point to page locked memory
|
||||
(i.e. to CudaMem data or to its ROI)
|
||||
void enqueueUpload(const CudaMem& src, GpuMat& dst);
|
||||
void enqueueUpload(const Mat& src, GpuMat& dst);
|
||||
void enqueueUpload(const CudaMem& src, GpuMat& dst);
|
||||
void enqueueUpload(const Mat& src, GpuMat& dst);
|
||||
|
||||
void enqueueCopy(const GpuMat& src, GpuMat& dst);
|
||||
void enqueueCopy(const GpuMat& src, GpuMat& dst);
|
||||
|
||||
void enqueueMemSet(const GpuMat& src, Scalar val);
|
||||
void enqueueMemSet(const GpuMat& src, Scalar val, const GpuMat& mask);
|
||||
void enqueueMemSet(const GpuMat& src, Scalar val);
|
||||
void enqueueMemSet(const GpuMat& src, Scalar val, const GpuMat& mask);
|
||||
|
||||
// converts matrix type, ex from float to uchar depending on type
|
||||
void enqueueConvert(const GpuMat& src, GpuMat& dst, int type,
|
||||
double a = 1, double b = 0);
|
||||
void enqueueConvert(const GpuMat& src, GpuMat& dst, int type,
|
||||
double a = 1, double b = 0);
|
||||
|
||||
typedef void (*StreamCallback)(Stream& stream, int status, void* userData);
|
||||
void enqueueHostCallback(StreamCallback callback, void* userData);
|
||||
};
|
||||
|
||||
|
||||
|
||||
gpu::Stream::queryIfComplete
|
||||
--------------------------------
|
||||
----------------------------
|
||||
Returns ``true`` if the current stream queue is finished. Otherwise, it returns false.
|
||||
|
||||
.. ocv:function:: bool gpu::Stream::queryIfComplete()
|
||||
@@ -313,13 +309,73 @@ Returns ``true`` if the current stream queue is finished. Otherwise, it returns
|
||||
|
||||
|
||||
gpu::Stream::waitForCompletion
|
||||
----------------------------------
|
||||
------------------------------
|
||||
Blocks the current CPU thread until all operations in the stream are complete.
|
||||
|
||||
.. ocv:function:: void gpu::Stream::waitForCompletion()
|
||||
|
||||
|
||||
|
||||
gpu::Stream::enqueueDownload
|
||||
----------------------------
|
||||
Copies data from device to host.
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueDownload(const GpuMat& src, CudaMem& dst)
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueDownload(const GpuMat& src, Mat& dst)
|
||||
|
||||
.. note:: ``cv::Mat`` must point to page locked memory (i.e. to ``CudaMem`` data or to its subMat) or must be registered with :ocv:func:`gpu::registerPageLocked` .
|
||||
|
||||
|
||||
|
||||
gpu::Stream::enqueueUpload
|
||||
--------------------------
|
||||
Copies data from host to device.
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueUpload(const CudaMem& src, GpuMat& dst)
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueUpload(const Mat& src, GpuMat& dst)
|
||||
|
||||
.. note:: ``cv::Mat`` must point to page locked memory (i.e. to ``CudaMem`` data or to its subMat) or must be registered with :ocv:func:`gpu::registerPageLocked` .
|
||||
|
||||
|
||||
|
||||
gpu::Stream::enqueueCopy
|
||||
------------------------
|
||||
Copies data from device to device.
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueCopy(const GpuMat& src, GpuMat& dst)
|
||||
|
||||
|
||||
|
||||
gpu::Stream::enqueueMemSet
|
||||
--------------------------
|
||||
Initializes or sets device memory to a value.
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueMemSet( GpuMat& src, Scalar val )
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueMemSet( GpuMat& src, Scalar val, const GpuMat& mask )
|
||||
|
||||
|
||||
|
||||
gpu::Stream::enqueueConvert
|
||||
---------------------------
|
||||
Converts matrix type, ex from float to uchar depending on type.
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueConvert( const GpuMat& src, GpuMat& dst, int dtype, double a=1, double b=0 )
|
||||
|
||||
|
||||
|
||||
gpu::Stream::enqueueHostCallback
|
||||
--------------------------------
|
||||
Adds a callback to be called on the host after all currently enqueued items in the stream have completed.
|
||||
|
||||
.. ocv:function:: void gpu::Stream::enqueueHostCallback(StreamCallback callback, void* userData)
|
||||
|
||||
.. note:: Callbacks must not make any CUDA API calls. Callbacks must not perform any synchronization that may depend on outstanding device work or other callbacks that are not mandated to run earlier. Callbacks without a mandated order (in independent streams) execute in undefined order and may be serialized.
|
||||
|
||||
|
||||
|
||||
gpu::StreamAccessor
|
||||
-------------------
|
||||
.. ocv:struct:: gpu::StreamAccessor
|
||||
|
||||
@@ -640,4 +640,3 @@ Converts matrices obtained via :ocv:func:`gpu::BruteForceMatcher_GPU_base::radiu
|
||||
.. ocv:function:: void gpu::BruteForceMatcher_GPU_base::radiusMatchConvert(const Mat& trainIdx, const Mat& imgIdx, const Mat& distance, const Mat& nMatches, std::vector< std::vector<DMatch> >& matches, bool compactResult = false)
|
||||
|
||||
If ``compactResult`` is ``true`` , the ``matches`` vector does not contain matches for fully masked-out query descriptors.
|
||||
|
||||
|
||||