Merge branch 'master' of git://code.opencv.org/opencv
This commit is contained in:
commit
1017dea332
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.0.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r2.3.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r3.0.1.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r3.0.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.0.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.3.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.0.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.1.1.so
vendored
BIN
3rdparty/lib/armeabi-v7a/libnative_camera_r4.1.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r2.2.0.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r2.2.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r2.3.3.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r2.3.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r3.0.1.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r3.0.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.0.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.0.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.3.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r4.0.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/armeabi/libnative_camera_r4.1.1.so
vendored
BIN
3rdparty/lib/armeabi/libnative_camera_r4.1.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r2.3.3.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r2.3.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r3.0.1.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r3.0.1.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r4.0.3.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r4.0.3.so
vendored
Binary file not shown.
BIN
3rdparty/lib/x86/libnative_camera_r4.1.1.so
vendored
BIN
3rdparty/lib/x86/libnative_camera_r4.1.1.so
vendored
Binary file not shown.
28
3rdparty/libjasper/jpc_qmfb.c
vendored
28
3rdparty/libjasper/jpc_qmfb.c
vendored
@ -94,14 +94,14 @@
|
||||
#define QMFB_SPLITBUFSIZE 4096
|
||||
#define QMFB_JOINBUFSIZE 4096
|
||||
|
||||
int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
int jpc_ft_analyze(int *a, int xstart, int ystart, int width, int height,
|
||||
int stride);
|
||||
int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
|
||||
int stride);
|
||||
|
||||
int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
int jpc_ns_analyze(int *a, int xstart, int ystart, int width, int height,
|
||||
int stride);
|
||||
int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
|
||||
int jpc_ns_synthesize(int *a, int xstart, int ystart, int width,
|
||||
int height, int stride);
|
||||
|
||||
void jpc_ft_fwdlift_row(jpc_fix_t *a, int numcols, int parity);
|
||||
@ -1556,7 +1556,7 @@ void jpc_ft_invlift_colres(jpc_fix_t *a, int numrows, int numcols, int stride,
|
||||
|
||||
}
|
||||
|
||||
int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
int jpc_ft_analyze(int *a, int xstart, int ystart, int width, int height,
|
||||
int stride)
|
||||
{
|
||||
int numrows = height;
|
||||
@ -1568,7 +1568,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
int maxcols;
|
||||
|
||||
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
|
||||
jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity);
|
||||
jpc_ft_fwdlift_colgrp(startptr, numrows, stride, rowparity);
|
||||
@ -1581,7 +1581,7 @@ int jpc_ft_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
rowparity);
|
||||
}
|
||||
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < numrows; ++i) {
|
||||
jpc_qmfb_split_row(startptr, numcols, colparity);
|
||||
jpc_ft_fwdlift_row(startptr, numcols, colparity);
|
||||
@ -1604,7 +1604,7 @@ int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
|
||||
jpc_fix_t *startptr;
|
||||
int i;
|
||||
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < numrows; ++i) {
|
||||
jpc_ft_invlift_row(startptr, numcols, colparity);
|
||||
jpc_qmfb_join_row(startptr, numcols, colparity);
|
||||
@ -1612,7 +1612,7 @@ int jpc_ft_synthesize(int *a, int xstart, int ystart, int width, int height,
|
||||
}
|
||||
|
||||
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
|
||||
jpc_ft_invlift_colgrp(startptr, numrows, stride, rowparity);
|
||||
jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity);
|
||||
@ -3068,7 +3068,7 @@ void jpc_ns_invlift_col(jpc_fix_t *a, int numrows, int stride,
|
||||
|
||||
}
|
||||
|
||||
int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
int jpc_ns_analyze(int *a, int xstart, int ystart, int width, int height,
|
||||
int stride)
|
||||
{
|
||||
|
||||
@ -3081,7 +3081,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
int maxcols;
|
||||
|
||||
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
|
||||
jpc_qmfb_split_colgrp(startptr, numrows, stride, rowparity);
|
||||
jpc_ns_fwdlift_colgrp(startptr, numrows, stride, rowparity);
|
||||
@ -3094,7 +3094,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
rowparity);
|
||||
}
|
||||
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < numrows; ++i) {
|
||||
jpc_qmfb_split_row(startptr, numcols, colparity);
|
||||
jpc_ns_fwdlift_row(startptr, numcols, colparity);
|
||||
@ -3105,7 +3105,7 @@ int jpc_ns_analyze(jpc_fix_t *a, int xstart, int ystart, int width, int height,
|
||||
|
||||
}
|
||||
|
||||
int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
|
||||
int jpc_ns_synthesize(int *a, int xstart, int ystart, int width,
|
||||
int height, int stride)
|
||||
{
|
||||
|
||||
@ -3117,7 +3117,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
|
||||
jpc_fix_t *startptr;
|
||||
int i;
|
||||
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < numrows; ++i) {
|
||||
jpc_ns_invlift_row(startptr, numcols, colparity);
|
||||
jpc_qmfb_join_row(startptr, numcols, colparity);
|
||||
@ -3125,7 +3125,7 @@ int jpc_ns_synthesize(jpc_fix_t *a, int xstart, int ystart, int width,
|
||||
}
|
||||
|
||||
maxcols = (numcols / JPC_QMFB_COLGRPSIZE) * JPC_QMFB_COLGRPSIZE;
|
||||
startptr = &a[0];
|
||||
startptr = (jpc_fix_t*)&a[0];
|
||||
for (i = 0; i < maxcols; i += JPC_QMFB_COLGRPSIZE) {
|
||||
jpc_ns_invlift_colgrp(startptr, numrows, stride, rowparity);
|
||||
jpc_qmfb_join_colgrp(startptr, numrows, stride, rowparity);
|
||||
|
2
3rdparty/openexr/CMakeLists.txt
vendored
2
3rdparty/openexr/CMakeLists.txt
vendored
@ -37,7 +37,7 @@ endif()
|
||||
source_group("Include" FILES ${lib_hdrs} )
|
||||
source_group("Src" FILES ${lib_srcs})
|
||||
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wshadow -Wunused -Wsign-compare -Wundef -Wmissing-declarations -Wuninitialized -Wswitch -Wparentheses -Warray-bounds -Wextra)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4018 /wd4099 /wd4100 /wd4101 /wd4127 /wd4189 /wd4245 /wd4305 /wd4389 /wd4512 /wd4701 /wd4702 /wd4706 /wd4800) # vs2005
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4334) # vs2005 Win64
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4244) # vs2008
|
||||
|
14
3rdparty/tbb/CMakeLists.txt
vendored
14
3rdparty/tbb/CMakeLists.txt
vendored
@ -5,12 +5,18 @@ endif()
|
||||
|
||||
project(tbb)
|
||||
|
||||
# 4.0 update 5 - works fine
|
||||
set(tbb_ver "tbb40_20120613oss")
|
||||
set(tbb_url "http://threadingbuildingblocks.org/uploads/77/187/4.0%20update%205/tbb40_20120613oss_src.tgz")
|
||||
set(tbb_md5 "da01ed74944ec5950cfae3476901a172")
|
||||
# 4.1 - works fine
|
||||
set(tbb_ver "tbb41_20120718oss")
|
||||
set(tbb_url "http://threadingbuildingblocks.org/uploads/77/188/4.1/tbb41_20120718oss_src.tgz")
|
||||
set(tbb_md5 "31b9ec300f3d09da2504d5d882788dd4")
|
||||
set(tbb_version_file "version_string.ver")
|
||||
|
||||
# 4.0 update 5 - works fine
|
||||
#set(tbb_ver "tbb40_20120613oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/uploads/77/187/4.0%20update%205/tbb40_20120613oss_src.tgz")
|
||||
#set(tbb_md5 "da01ed74944ec5950cfae3476901a172")
|
||||
#set(tbb_version_file "version_string.ver")
|
||||
|
||||
# 4.0 update 4 - works fine
|
||||
#set(tbb_ver "tbb40_20120408oss")
|
||||
#set(tbb_url "http://threadingbuildingblocks.org/uploads/77/185/4.0%20update%204/tbb40_20120408oss_src.tgz")
|
||||
|
107
CMakeLists.txt
107
CMakeLists.txt
@ -60,7 +60,7 @@ endif()
|
||||
|
||||
project(OpenCV CXX C)
|
||||
|
||||
include(cmake/OpenCVUtils.cmake REQUIRED)
|
||||
include(cmake/OpenCVUtils.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Break in case of popular CMake configuration mistakes
|
||||
@ -73,7 +73,7 @@ endif()
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect compiler and target platform architecture
|
||||
# ----------------------------------------------------------------------------
|
||||
include(cmake/OpenCVDetectCXXCompiler.cmake REQUIRED)
|
||||
include(cmake/OpenCVDetectCXXCompiler.cmake)
|
||||
|
||||
# Add these standard paths to the search paths for FIND_LIBRARY
|
||||
# to find libraries from these locations first
|
||||
@ -159,7 +159,6 @@ OCV_OPTION(BUILD_FAT_JAVA_LIB "Create fat java wrapper containing the whol
|
||||
OCV_OPTION(BUILD_ANDROID_SERVICE "Build OpenCV Manager for Google Play" OFF IF ANDROID AND ANDROID_USE_STLPORT AND ANDROID_SOURCE_TREE )
|
||||
OCV_OPTION(BUILD_ANDROID_PACKAGE "Build platform-specific package for Google Play" OFF IF ANDROID )
|
||||
|
||||
|
||||
# 3rd party libs
|
||||
OCV_OPTION(BUILD_ZLIB "Build zlib from source" WIN32 OR APPLE )
|
||||
OCV_OPTION(BUILD_TIFF "Build libtiff from source" WIN32 OR ANDROID OR APPLE )
|
||||
@ -168,24 +167,19 @@ OCV_OPTION(BUILD_JPEG "Build libjpeg from source" WIN32 OR AN
|
||||
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 )
|
||||
|
||||
|
||||
# OpenCV installation options
|
||||
# ===================================================
|
||||
OCV_OPTION(INSTALL_C_EXAMPLES "Install C examples" OFF )
|
||||
OCV_OPTION(INSTALL_PYTHON_EXAMPLES "Install Python examples" OFF )
|
||||
OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
|
||||
OCV_OPTION(INSTALL_ANDROID_EXAMPLES "Install Android examples" OFF IF ANDROID )
|
||||
OCV_OPTION(INSTALL_TO_MANGLED_PATHS "Enables mangled install paths, that help with side by side installs." OFF IF (UNIX AND NOT ANDROID AND NOT IOS AND BUILD_SHARED_LIBS) )
|
||||
|
||||
|
||||
if(MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode)
|
||||
set(ENABLE_SOLUTION_FOLDERS0 ON)
|
||||
else()
|
||||
set(ENABLE_SOLUTION_FOLDERS0 OFF)
|
||||
endif()
|
||||
|
||||
# OpenCV build options
|
||||
# ===================================================
|
||||
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" ${ENABLE_SOLUTION_FOLDERS0} IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
|
||||
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_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
@ -196,6 +190,7 @@ OCV_OPTION(ENABLE_SSE3 "Enable SSE3 instructions"
|
||||
OCV_OPTION(ENABLE_SSSE3 "Enable SSSE3 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE41 "Enable SSE4.1 instructions" OFF IF ((CV_ICC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_SSE42 "Enable SSE4.2 instructions" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_AVX "Enable AVX instructions" OFF IF ((MSVC OR CMAKE_COMPILER_IS_GNUCXX) AND (X86 OR X86_64)) )
|
||||
OCV_OPTION(ENABLE_NOISY_WARNINGS "Show all warnings even if they are too noisy" OFF )
|
||||
OCV_OPTION(OPENCV_WARNINGS_ARE_ERRORS "Treat warnings as errors" OFF )
|
||||
|
||||
@ -212,7 +207,7 @@ include(cmake/OpenCVLegacyOptions.cmake OPTIONAL)
|
||||
# ----------------------------------------------------------------------------
|
||||
# Get actual OpenCV version number from sources
|
||||
# ----------------------------------------------------------------------------
|
||||
include(cmake/OpenCVVersion.cmake REQUIRED)
|
||||
include(cmake/OpenCVVersion.cmake)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -223,33 +218,33 @@ include(cmake/OpenCVVersion.cmake REQUIRED)
|
||||
set(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin" CACHE PATH "Output directory for applications" )
|
||||
|
||||
if(ANDROID OR WIN32)
|
||||
set(OPENCV_DOC_INSTALL_PATH doc)
|
||||
set(OPENCV_DOC_INSTALL_PATH doc)
|
||||
elseif(INSTALL_TO_MANGLED_PATHS)
|
||||
set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
|
||||
set(OPENCV_DOC_INSTALL_PATH share/OpenCV-${OPENCV_VERSION}/doc)
|
||||
else()
|
||||
set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
|
||||
set(OPENCV_DOC_INSTALL_PATH share/OpenCV/doc)
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
set(OPENCV_LIB_INSTALL_PATH sdk/native/libs/${ANDROID_NDK_ABI_NAME})
|
||||
set(OPENCV_3P_LIB_INSTALL_PATH sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME})
|
||||
set(OPENCV_CONFIG_INSTALL_PATH sdk/native/jni)
|
||||
set(OPENCV_INCLUDE_INSTALL_PATH sdk/native/jni/include)
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
set(OPENCV_LIB_INSTALL_PATH sdk/native/libs/${ANDROID_NDK_ABI_NAME})
|
||||
set(OPENCV_3P_LIB_INSTALL_PATH sdk/native/3rdparty/libs/${ANDROID_NDK_ABI_NAME})
|
||||
set(OPENCV_CONFIG_INSTALL_PATH sdk/native/jni)
|
||||
set(OPENCV_INCLUDE_INSTALL_PATH sdk/native/jni/include)
|
||||
else()
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib")
|
||||
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
|
||||
set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
|
||||
set(OPENCV_3P_LIB_INSTALL_PATH share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH})
|
||||
set(OPENCV_INCLUDE_INSTALL_PATH include)
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib")
|
||||
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
|
||||
set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
|
||||
set(OPENCV_3P_LIB_INSTALL_PATH share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH})
|
||||
set(OPENCV_INCLUDE_INSTALL_PATH include)
|
||||
|
||||
math(EXPR SIZEOF_VOID_P_BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
if(LIB_SUFFIX AND NOT SIZEOF_VOID_P_BITS EQUAL LIB_SUFFIX)
|
||||
set(OPENCV_CONFIG_INSTALL_PATH lib${LIB_SUFFIX}/cmake/opencv)
|
||||
else()
|
||||
set(OPENCV_CONFIG_INSTALL_PATH share/OpenCV)
|
||||
endif()
|
||||
math(EXPR SIZEOF_VOID_P_BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
|
||||
if(LIB_SUFFIX AND NOT SIZEOF_VOID_P_BITS EQUAL LIB_SUFFIX)
|
||||
set(OPENCV_CONFIG_INSTALL_PATH lib${LIB_SUFFIX}/cmake/opencv)
|
||||
else()
|
||||
set(OPENCV_CONFIG_INSTALL_PATH share/OpenCV)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/${OPENCV_LIB_INSTALL_PATH}")
|
||||
@ -293,7 +288,7 @@ ocv_include_directories(${OPENCV_CONFIG_FILE_INCLUDE_DIR})
|
||||
# don't use FindGit because it requires CMake 2.8.2
|
||||
set(git_names git eg) # eg = easy git
|
||||
# Prefer .cmd variants on Windows unless running in a Makefile in the MSYS shell
|
||||
if(WIN32)
|
||||
if(CMAKE_HOST_WIN32)
|
||||
if(NOT CMAKE_GENERATOR MATCHES "MSYS")
|
||||
set(git_names git.cmd git eg.cmd eg)
|
||||
endif()
|
||||
@ -329,7 +324,7 @@ if(CMAKE_GENERATOR MATCHES "Makefiles|Ninja" AND "${CMAKE_BUILD_TYPE}" STREQUAL
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
include(cmake/OpenCVCompilerOptions.cmake REQUIRED)
|
||||
include(cmake/OpenCVCompilerOptions.cmake)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -337,7 +332,7 @@ include(cmake/OpenCVCompilerOptions.cmake REQUIRED)
|
||||
# Default: dynamic
|
||||
# ----------------------------------------------------------------------------
|
||||
if(MSVC)
|
||||
include(cmake/OpenCVCRTLinkage.cmake REQUIRED)
|
||||
include(cmake/OpenCVCRTLinkage.cmake)
|
||||
endif(MSVC)
|
||||
|
||||
if(WIN32 AND NOT MINGW)
|
||||
@ -370,17 +365,17 @@ if(UNIX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
include(cmake/OpenCVPCHSupport.cmake REQUIRED)
|
||||
include(cmake/OpenCVModule.cmake REQUIRED)
|
||||
include(cmake/OpenCVPCHSupport.cmake)
|
||||
include(cmake/OpenCVModule.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect 3rd-party libraries
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
include(cmake/OpenCVFindLibsGrfmt.cmake REQUIRED)
|
||||
include(cmake/OpenCVFindLibsGUI.cmake REQUIRED)
|
||||
include(cmake/OpenCVFindLibsVideo.cmake REQUIRED)
|
||||
include(cmake/OpenCVFindLibsPerf.cmake REQUIRED)
|
||||
include(cmake/OpenCVFindLibsGrfmt.cmake)
|
||||
include(cmake/OpenCVFindLibsGUI.cmake)
|
||||
include(cmake/OpenCVFindLibsVideo.cmake)
|
||||
include(cmake/OpenCVFindLibsPerf.cmake)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -389,21 +384,23 @@ include(cmake/OpenCVFindLibsPerf.cmake REQUIRED)
|
||||
|
||||
# --- LATEX for pdf documentation ---
|
||||
if(BUILD_DOCS)
|
||||
include(cmake/OpenCVFindLATEX.cmake REQUIRED)
|
||||
include(cmake/OpenCVFindLATEX.cmake)
|
||||
endif(BUILD_DOCS)
|
||||
|
||||
# --- Python Support ---
|
||||
include(cmake/OpenCVDetectPython.cmake REQUIRED)
|
||||
include(cmake/OpenCVDetectPython.cmake)
|
||||
|
||||
# --- Java Support ---
|
||||
include(cmake/OpenCVDetectApacheAnt.cmake)
|
||||
if(ANDROID)
|
||||
include(cmake/OpenCVDetectApacheAnt.cmake REQUIRED)
|
||||
include(cmake/OpenCVDetectAndroidSDK.cmake REQUIRED)
|
||||
include(cmake/OpenCVDetectAndroidSDK.cmake)
|
||||
|
||||
if(NOT ANDROID_TOOLS_Pkg_Revision GREATER 13)
|
||||
message(WARNING "OpenCV requires Android SDK tools revision 14 or newer. Otherwise tests and samples will no be compiled.")
|
||||
endif()
|
||||
endif(ANDROID)
|
||||
elseif(ANT_EXECUTABLE)
|
||||
find_package(JNI)
|
||||
endif()
|
||||
|
||||
if(ANDROID AND ANDROID_EXECUTABLE AND ANT_EXECUTABLE AND (ANT_VERSION VERSION_GREATER 1.7) AND (ANDROID_TOOLS_Pkg_Revision GREATER 13))
|
||||
SET(CAN_BUILD_ANDROID_PROJECTS TRUE)
|
||||
@ -413,7 +410,7 @@ endif()
|
||||
|
||||
# --- OpenCL ---
|
||||
if(WITH_OPENCL)
|
||||
include(cmake/OpenCVDetectOpenCL.cmake REQUIRED)
|
||||
include(cmake/OpenCVDetectOpenCL.cmake)
|
||||
if(OPENCL_FOUND)
|
||||
set(HAVE_OPENCL 1)
|
||||
endif()
|
||||
@ -434,7 +431,7 @@ if(ENABLE_SOLUTION_FOLDERS)
|
||||
endif()
|
||||
|
||||
# Extra OpenCV targets: uninstall, package_source, perf, etc.
|
||||
include(cmake/OpenCVExtraTargets.cmake REQUIRED)
|
||||
include(cmake/OpenCVExtraTargets.cmake)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -475,16 +472,16 @@ endif()
|
||||
ocv_track_build_dependencies()
|
||||
|
||||
# Generate platform-dependent and configuration-dependent headers
|
||||
include(cmake/OpenCVGenHeaders.cmake REQUIRED)
|
||||
include(cmake/OpenCVGenHeaders.cmake)
|
||||
|
||||
# Generate opencv.pc for pkg-config command
|
||||
include(cmake/OpenCVGenPkgconfig.cmake REQUIRED)
|
||||
include(cmake/OpenCVGenPkgconfig.cmake)
|
||||
|
||||
# Generate OpenCV.mk for ndk-build (Android build tool)
|
||||
include(cmake/OpenCVGenAndroidMK.cmake REQUIRED)
|
||||
include(cmake/OpenCVGenAndroidMK.cmake)
|
||||
|
||||
# Generate OpenCVСonfig.cmake and OpenCVConfig-version.cmake for cmake projects
|
||||
include(cmake/OpenCVGenConfig.cmake REQUIRED)
|
||||
include(cmake/OpenCVGenConfig.cmake)
|
||||
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -760,7 +757,7 @@ status(" Use Clp:" HAVE_CLP THEN YES ELSE NO)
|
||||
|
||||
if(HAVE_CUDA)
|
||||
status("")
|
||||
status(" NVIDIA CUDA:" "(ver ${CUDA_VERSION_STRING})")
|
||||
status(" NVIDIA CUDA")
|
||||
|
||||
status(" Use CUFFT:" HAVE_CUFFT THEN YES ELSE NO)
|
||||
status(" Use CUBLAS:" HAVE_CUBLAS THEN YES ELSE NO)
|
||||
@ -774,9 +771,9 @@ status(" Python:")
|
||||
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)
|
||||
status(" Libraries:" HAVE_opencv_python THEN "${PYTHON_LIBRARIES} (ver ${PYTHONLIBS_VERSION_STRING})" ELSE NO)
|
||||
else()
|
||||
status(" Libraries:" HAVE_opencv_python THEN ${PYTHON_LIBRARIES} ELSE NO)
|
||||
status(" Libraries:" HAVE_opencv_python THEN ${PYTHON_LIBRARIES} ELSE NO)
|
||||
endif()
|
||||
status(" numpy:" PYTHON_USE_NUMPY THEN "${PYTHON_NUMPY_INCLUDE_DIR} (ver ${PYTHON_NUMPY_VERSION})" ELSE "NO (Python wrappers can not be generated)")
|
||||
status(" packages path:" PYTHON_EXECUTABLE THEN "${PYTHON_PACKAGES_PATH}" ELSE "-")
|
||||
|
@ -250,6 +250,9 @@ set( CMAKE_SYSTEM_NAME Linux )
|
||||
# this one not so much
|
||||
set( CMAKE_SYSTEM_VERSION 1 )
|
||||
|
||||
# rpath makes low sence for Android
|
||||
set( CMAKE_SKIP_RPATH TRUE CACHE BOOL "If set, runtime paths are not added when using shared libraries." )
|
||||
|
||||
set( ANDROID_SUPPORTED_NDK_VERSIONS ${ANDROID_EXTRA_NDK_VERSIONS} -r8b -r8 -r7c -r7b -r7 -r6b -r6 -r5c -r5b -r5 "" )
|
||||
if(NOT DEFINED ANDROID_NDK_SEARCH_PATHS)
|
||||
if( CMAKE_HOST_WIN32 )
|
||||
@ -471,7 +474,7 @@ elseif( ANDROID_STANDALONE_TOOLCHAIN )
|
||||
set( BUILD_WITH_STANDALONE_TOOLCHAIN True )
|
||||
else()
|
||||
list(GET ANDROID_NDK_SEARCH_PATHS 0 ANDROID_NDK_SEARCH_PATH)
|
||||
message( FATAL_ERROR "Could not find neither Android NDK nor Android standalone toolcahin.
|
||||
message( FATAL_ERROR "Could not find neither Android NDK nor Android standalone toolchain.
|
||||
You should either set an environment variable:
|
||||
export ANDROID_NDK=~/my-android-ndk
|
||||
or
|
||||
@ -770,6 +773,27 @@ You are strongly recommended to switch to another NDK release.
|
||||
" )
|
||||
endif()
|
||||
|
||||
if( NOT _CMAKE_IN_TRY_COMPILE AND X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" )
|
||||
message( WARNING "The x86 system header file from NDK r6 has incorrect definition for ptrdiff_t. You are recommended to upgrade to a newer NDK release or manually patch the header:
|
||||
See https://android.googlesource.com/platform/development.git f907f4f9d4e56ccc8093df6fee54454b8bcab6c2
|
||||
diff --git a/ndk/platforms/android-9/arch-x86/include/machine/_types.h b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
|
||||
index 5e28c64..65892a1 100644
|
||||
--- a/ndk/platforms/android-9/arch-x86/include/machine/_types.h
|
||||
+++ b/ndk/platforms/android-9/arch-x86/include/machine/_types.h
|
||||
@@ -51,7 +51,11 @@ typedef long int ssize_t;
|
||||
#endif
|
||||
#ifndef _PTRDIFF_T
|
||||
#define _PTRDIFF_T
|
||||
-typedef long ptrdiff_t;
|
||||
+# ifdef __ANDROID__
|
||||
+ typedef int ptrdiff_t;
|
||||
+# else
|
||||
+ typedef long ptrdiff_t;
|
||||
+# endif
|
||||
#endif
|
||||
" )
|
||||
endif()
|
||||
|
||||
# setup paths and STL for NDK
|
||||
if( BUILD_WITH_ANDROID_NDK )
|
||||
set( ANDROID_TOOLCHAIN_ROOT "${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/prebuilt/${ANDROID_NDK_HOST_SYSTEM_NAME}" )
|
||||
@ -949,20 +973,6 @@ if( APPLE )
|
||||
mark_as_advanced( CMAKE_INSTALL_NAME_TOOL )
|
||||
endif()
|
||||
|
||||
# flags and definitions
|
||||
remove_definitions( -DANDROID )
|
||||
add_definitions( -DANDROID )
|
||||
|
||||
if(ANDROID_SYSROOT MATCHES "[ ;\"]")
|
||||
set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
|
||||
if( NOT _CMAKE_IN_TRY_COMPILE )
|
||||
# quotes will break try_compile and compiler identification
|
||||
message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.")
|
||||
endif()
|
||||
else()
|
||||
set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
|
||||
endif()
|
||||
|
||||
# Force set compilers because standard identification works badly for us
|
||||
include( CMakeForceCompiler )
|
||||
CMAKE_FORCE_C_COMPILER( "${CMAKE_C_COMPILER}" GNU )
|
||||
@ -983,60 +993,54 @@ set( CMAKE_ASM_COMPILER_FORCED TRUE )
|
||||
set( CMAKE_COMPILER_IS_GNUASM 1)
|
||||
set( CMAKE_ASM_SOURCE_FILE_EXTENSIONS s S asm )
|
||||
|
||||
# NDK flags
|
||||
if( ARMEABI OR ARMEABI_V7A )
|
||||
# NDK also defines -ffunction-sections -funwind-tables but they result in worse OpenCV performance
|
||||
set( _CMAKE_CXX_FLAGS "-fPIC -Wno-psabi" )
|
||||
set( _CMAKE_C_FLAGS "-fPIC -Wno-psabi" )
|
||||
remove_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
|
||||
add_definitions( -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ )
|
||||
# extra arm-specific flags
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
|
||||
elseif( X86 )
|
||||
set( _CMAKE_CXX_FLAGS "-funwind-tables" )
|
||||
set( _CMAKE_C_FLAGS "-funwind-tables" )
|
||||
elseif( MIPS )
|
||||
set( _CMAKE_CXX_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
|
||||
set( _CMAKE_C_FLAGS "-fpic -Wno-psabi -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers" )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" )
|
||||
# flags and definitions
|
||||
remove_definitions( -DANDROID )
|
||||
add_definitions( -DANDROID )
|
||||
|
||||
if(ANDROID_SYSROOT MATCHES "[ ;\"]")
|
||||
set( ANDROID_CXX_FLAGS "--sysroot=\"${ANDROID_SYSROOT}\"" )
|
||||
if( NOT _CMAKE_IN_TRY_COMPILE )
|
||||
# quotes will break try_compile and compiler identification
|
||||
message(WARNING "Your Android system root has non-alphanumeric symbols. It can break compiler features detection and the whole build.")
|
||||
endif()
|
||||
else()
|
||||
set( _CMAKE_CXX_FLAGS "" )
|
||||
set( _CMAKE_C_FLAGS "" )
|
||||
set( ANDROID_CXX_FLAGS "--sysroot=${ANDROID_SYSROOT}" )
|
||||
endif()
|
||||
|
||||
# release and debug flags
|
||||
# NDK flags
|
||||
if( ARMEABI OR ARMEABI_V7A )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__" )
|
||||
if( NOT ANDROID_FORCE_ARM_BUILD AND NOT ARMEABI_V6 )
|
||||
# It is recommended to use the -mthumb compiler flag to force the generation
|
||||
# of 16-bit Thumb-1 instructions (the default being 32-bit ARM ones).
|
||||
# O3 instead of O2/Os in release mode - like cmake sets for desktop gcc
|
||||
set( _CMAKE_CXX_FLAGS_RELEASE "-mthumb -O3" )
|
||||
set( _CMAKE_C_FLAGS_RELEASE "-mthumb -O3" )
|
||||
set( _CMAKE_CXX_FLAGS_DEBUG "-marm -Os -finline-limit=64" )
|
||||
set( _CMAKE_C_FLAGS_DEBUG "-marm -Os -finline-limit=64" )
|
||||
set( ANDROID_CXX_FLAGS_RELEASE "-mthumb" )
|
||||
set( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=64" )
|
||||
else()
|
||||
# always compile ARMEABI_V6 in arm mode; otherwise there is no difference from ARMEABI
|
||||
# O3 instead of O2/Os in release mode - like cmake sets for desktop gcc
|
||||
set( _CMAKE_CXX_FLAGS_RELEASE "-marm -O3 -fstrict-aliasing" )
|
||||
set( _CMAKE_C_FLAGS_RELEASE "-marm -O3 -fstrict-aliasing" )
|
||||
set( _CMAKE_CXX_FLAGS_DEBUG "-marm -O0 -finline-limit=300" )
|
||||
set( _CMAKE_C_FLAGS_DEBUG "-marm -O0 -finline-limit=300" )
|
||||
set( ANDROID_CXX_FLAGS_RELEASE "-marm" )
|
||||
set( ANDROID_CXX_FLAGS_DEBUG "-marm -finline-limit=300" )
|
||||
endif()
|
||||
elseif( X86 )
|
||||
set( _CMAKE_CXX_FLAGS_RELEASE "-O3 -fstrict-aliasing" )
|
||||
set( _CMAKE_C_FLAGS_RELEASE "-O3 -fstrict-aliasing" )
|
||||
set( _CMAKE_CXX_FLAGS_DEBUG "-O0 -finline-limit=300" )
|
||||
set( _CMAKE_C_FLAGS_DEBUG "-O0 -finline-limit=300" )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -funwind-tables" )
|
||||
set( ANDROID_CXX_FLAGS_RELEASE "" )
|
||||
set( ANDROID_CXX_FLAGS_DEBUG "-finline-limit=300" )
|
||||
elseif( MIPS )
|
||||
set( _CMAKE_CXX_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
|
||||
set( _CMAKE_C_FLAGS_RELEASE "-O3 -funswitch-loops -finline-limit=300" )
|
||||
set( _CMAKE_CXX_FLAGS_DEBUG "-O0 -g" )
|
||||
set( _CMAKE_C_FLAGS_DEBUG "-O0 -g" )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fpic -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -frename-registers" )
|
||||
set( ANDROID_CXX_FLAGS_RELEASE "-finline-limit=300 -fno-strict-aliasing" )
|
||||
set( ANDROID_CXX_FLAGS_DEBUG "-finline-functions -fgcse-after-reload -frerun-cse-after-loop" )
|
||||
elseif()
|
||||
set( ANDROID_CXX_FLAGS_RELEASE "" )
|
||||
set( ANDROID_CXX_FLAGS_DEBUG "" )
|
||||
endif()
|
||||
set( _CMAKE_CXX_FLAGS_RELEASE "${_CMAKE_CXX_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
|
||||
set( _CMAKE_C_FLAGS_RELEASE "${_CMAKE_C_FLAGS_RELEASE} -fomit-frame-pointer -DNDEBUG" )
|
||||
set( _CMAKE_CXX_FLAGS_DEBUG "${_CMAKE_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
|
||||
set( _CMAKE_C_FLAGS_DEBUG "${_CMAKE_C_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer -DDEBUG -D_DEBUG" )
|
||||
|
||||
if( NOT X86 )
|
||||
set( ANDROID_CXX_FLAGS "-Wno-psabi ${ANDROID_CXX_FLAGS}" )
|
||||
endif()
|
||||
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fsigned-char" ) # good/necessary when porting desktop libraries
|
||||
set( ANDROID_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} -fomit-frame-pointer" )
|
||||
set( ANDROID_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} -fno-strict-aliasing -fno-omit-frame-pointer" )
|
||||
|
||||
# ABI-specific flags
|
||||
if( ARMEABI_V7A )
|
||||
@ -1052,135 +1056,157 @@ elseif( ARMEABI_V6 )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv6 -mfloat-abi=softfp -mfpu=vfp" )
|
||||
elseif( ARMEABI )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -march=armv5te -mtune=xscale -msoft-float" )
|
||||
elseif( X86 )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" )#sse?
|
||||
endif()
|
||||
|
||||
# STL
|
||||
if( 0 AND EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
|
||||
# use gcc as a C++ linker to avoid automatic picking of libsdtc++
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>")
|
||||
set( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
|
||||
if( EXISTS "${__libstl}" OR EXISTS "${__libsupcxx}" )
|
||||
if( ANDROID_STL MATCHES "gnustl" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
|
||||
set( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
|
||||
else()
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "<CMAKE_CXX_COMPILER> <CMAKE_SHARED_LIBRARY_CXX_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_CXX_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
|
||||
set( CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_CXX_COMPILER> <FLAGS> <CMAKE_CXX_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
|
||||
endif()
|
||||
if ( X86 AND ANDROID_STL MATCHES "gnustl" AND ANDROID_NDK_RELEASE STREQUAL "r6" )
|
||||
# workaround "undefined reference to `__dso_handle'" problem
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${ANDROID_SYSROOT}/usr/lib/crtbegin_so.o\"" )
|
||||
endif()
|
||||
if( EXISTS "${__libstl}" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"")
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"")
|
||||
set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libstl}\"")
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libstl}\"" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libstl}\"" )
|
||||
set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libstl}\"" )
|
||||
endif()
|
||||
if( EXISTS "${__libsupcxx}" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"")
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libsupcxx}\"")
|
||||
set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libsupcxx}\"")
|
||||
set( CMAKE_CXX_CREATE_SHARED_LIBRARY "${CMAKE_CXX_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" )
|
||||
set( CMAKE_CXX_CREATE_SHARED_MODULE "${CMAKE_CXX_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" )
|
||||
set( CMAKE_CXX_LINK_EXECUTABLE "${CMAKE_CXX_LINK_EXECUTABLE} \"${__libsupcxx}\"" )
|
||||
# C objects:
|
||||
set( CMAKE_C_CREATE_SHARED_LIBRARY "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
|
||||
set( CMAKE_C_CREATE_SHARED_MODULE "<CMAKE_C_COMPILER> <CMAKE_SHARED_LIBRARY_C_FLAGS> <LANGUAGE_COMPILE_FLAGS> <LINK_FLAGS> <CMAKE_SHARED_LIBRARY_CREATE_C_FLAGS> <CMAKE_SHARED_LIBRARY_SONAME_C_FLAG><TARGET_SONAME> -o <TARGET> <OBJECTS> <LINK_LIBRARIES>" )
|
||||
set( CMAKE_C_LINK_EXECUTABLE "<CMAKE_C_COMPILER> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> <OBJECTS> -o <TARGET> <LINK_LIBRARIES>" )
|
||||
set( CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"")
|
||||
set( CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE} \"${__libsupcxx}\"")
|
||||
set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"")
|
||||
set( CMAKE_C_CREATE_SHARED_LIBRARY "${CMAKE_C_CREATE_SHARED_LIBRARY} \"${__libsupcxx}\"" )
|
||||
set( CMAKE_C_CREATE_SHARED_MODULE "${CMAKE_C_CREATE_SHARED_MODULE} \"${__libsupcxx}\"" )
|
||||
set( CMAKE_C_LINK_EXECUTABLE "${CMAKE_C_LINK_EXECUTABLE} \"${__libsupcxx}\"" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# variables controlling optional build flags
|
||||
if (ANDROID_NDK_RELEASE STRLESS "r7")
|
||||
# libGLESv2.so in NDK's prior to r7 refers to missing external symbols.
|
||||
# So this flag option is required for all projects using OpenGL from native.
|
||||
__INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON )
|
||||
else()
|
||||
__INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF )
|
||||
endif()
|
||||
__INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
|
||||
__INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON )
|
||||
__INIT_VARIABLE( ANDROID_GOLD_LINKER VALUES ON )
|
||||
__INIT_VARIABLE( ANDROID_NOEXECSTACK VALUES ON )
|
||||
__INIT_VARIABLE( ANDROID_RELRO VALUES ON )
|
||||
|
||||
set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" )
|
||||
set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
|
||||
set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
|
||||
set( ANDROID_GOLD_LINKER ${ANDROID_GOLD_LINKER} CACHE BOOL "Enables gold linker (only avaialble for NDK r8b for ARM and x86 architectures on linux-86 and darwin-x86 hosts)" )
|
||||
set( ANDROID_NOEXECSTACK ${ANDROID_NOEXECSTACK} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" )
|
||||
set( ANDROID_RELRO ${ANDROID_RELRO} CACHE BOOL "Enables RELRO - a memory corruption mitigation technique" )
|
||||
mark_as_advanced( ANDROID_NO_UNDEFINED ANDROID_SO_UNDEFINED ANDROID_FUNCTION_LEVEL_LINKING ANDROID_GOLD_LINKER ANDROID_NOEXECSTACK ANDROID_RELRO )
|
||||
|
||||
# linker flags
|
||||
set( ANDROID_LINKER_FLAGS "" )
|
||||
|
||||
__INIT_VARIABLE( ANDROID_NO_UNDEFINED OBSOLETE_NO_UNDEFINED VALUES ON )
|
||||
set( ANDROID_NO_UNDEFINED ${ANDROID_NO_UNDEFINED} CACHE BOOL "Show all undefined symbols as linker errors" FORCE )
|
||||
mark_as_advanced( ANDROID_NO_UNDEFINED )
|
||||
if( ARMEABI_V7A )
|
||||
# this is *required* to use the following linker flags that routes around
|
||||
# a CPU bug in some Cortex-A8 implementations:
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--fix-cortex-a8" )
|
||||
endif()
|
||||
|
||||
if( ANDROID_NO_UNDEFINED )
|
||||
set( ANDROID_LINKER_FLAGS "-Wl,--no-undefined ${ANDROID_LINKER_FLAGS}" )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--no-undefined" )
|
||||
endif()
|
||||
|
||||
if (ANDROID_NDK_RELEASE STRLESS "r7")
|
||||
# libGLESv2.so in NDK's prior to r7 refers to missing external symbols.
|
||||
# So this flag option is required for all projects using OpenGL from native.
|
||||
__INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES ON )
|
||||
else()
|
||||
__INIT_VARIABLE( ANDROID_SO_UNDEFINED VALUES OFF )
|
||||
endif()
|
||||
|
||||
set( ANDROID_SO_UNDEFINED ${ANDROID_SO_UNDEFINED} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
|
||||
mark_as_advanced( ANDROID_SO_UNDEFINED )
|
||||
if( ANDROID_SO_UNDEFINED )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-allow-shlib-undefined" )
|
||||
endif()
|
||||
|
||||
__INIT_VARIABLE( ANDROID_FUNCTION_LEVEL_LINKING VALUES ON )
|
||||
set( ANDROID_FUNCTION_LEVEL_LINKING ${ANDROID_FUNCTION_LEVEL_LINKING} CACHE BOOL "Allows or disallows undefined symbols in shared libraries" FORCE )
|
||||
mark_as_advanced( ANDROID_FUNCTION_LEVEL_LINKING )
|
||||
if( ANDROID_FUNCTION_LEVEL_LINKING )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
|
||||
set( ANDROID_LINKER_FLAGS "-Wl,--gc-sections ${ANDROID_LINKER_FLAGS}" )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -fdata-sections -ffunction-sections" )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,--gc-sections" )
|
||||
endif()
|
||||
|
||||
if( ARMEABI_V7A )
|
||||
# this is *required* to use the following linker flags that routes around
|
||||
# a CPU bug in some Cortex-A8 implementations:
|
||||
set( ANDROID_LINKER_FLAGS "-Wl,--fix-cortex-a8 ${ANDROID_LINKER_FLAGS}" )
|
||||
if( ANDROID_GOLD_LINKER AND CMAKE_HOST_UNIX AND (ARMEABI OR ARMEABI_V7A OR X86) AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
|
||||
elseif( ANDROID_NDK_RELEASE STREQUAL "r8b" AND ARMEABI AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" AND NOT _CMAKE_IN_TRY_COMPILE )
|
||||
message( WARNING "The default bfd linker from arm GCC 4.6 toolchain can fail with 'unresolvable R_ARM_THM_CALL relocation' error message. See https://code.google.com/p/android/issues/detail?id=35342
|
||||
On Linux and OS X host platform you can workaround this problem using gold linker (default).
|
||||
Rerun cmake with -DANDROID_GOLD_LINKER=ON option.
|
||||
" )
|
||||
endif()
|
||||
|
||||
if( CMAKE_HOST_UNIX AND ANDROID_COMPILER_VERSION VERSION_EQUAL "4.6" AND (ARMEABI_V7A OR X86) )
|
||||
__INIT_VARIABLE( ANDROID_USE_GOLD_LINKER VALUES ON )
|
||||
set( ANDROID_USE_GOLD_LINKER ${ANDROID_USE_GOLD_LINKER} CACHE BOOL "Enables gold linker" FORCE )
|
||||
mark_as_advanced( ANDROID_USE_GOLD_LINKER )
|
||||
if( ANDROID_USE_GOLD_LINKER )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -fuse-ld=gold" )
|
||||
endif()
|
||||
if( ANDROID_NOEXECSTACK )
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS} -Wa,--noexecstack" )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,noexecstack" )
|
||||
endif()
|
||||
|
||||
if( ANDROID_RELRO )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} -Wl,-z,relro -Wl,-z,now" )
|
||||
endif()
|
||||
|
||||
# cache flags
|
||||
set( CMAKE_CXX_FLAGS "${_CMAKE_CXX_FLAGS}" CACHE STRING "c++ flags" )
|
||||
set( CMAKE_C_FLAGS "${_CMAKE_C_FLAGS}" CACHE STRING "c flags" )
|
||||
set( CMAKE_CXX_FLAGS_RELEASE "${_CMAKE_CXX_FLAGS_RELEASE}" CACHE STRING "c++ Release flags" )
|
||||
set( CMAKE_C_FLAGS_RELEASE "${_CMAKE_C_FLAGS_RELEASE}" CACHE STRING "c Release flags" )
|
||||
set( CMAKE_CXX_FLAGS_DEBUG "${_CMAKE_CXX_FLAGS_DEBUG}" CACHE STRING "c++ Debug flags" )
|
||||
set( CMAKE_C_FLAGS_DEBUG "${_CMAKE_C_FLAGS_DEBUG}" CACHE STRING "c Debug flags" )
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "linker flags" )
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "linker flags" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "linker flags" )
|
||||
set( CMAKE_CXX_FLAGS "" CACHE STRING "c++ flags" )
|
||||
set( CMAKE_C_FLAGS "" CACHE STRING "c flags" )
|
||||
set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c++ Release flags" )
|
||||
set( CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "c Release flags" )
|
||||
set( CMAKE_CXX_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c++ Debug flags" )
|
||||
set( CMAKE_C_FLAGS_DEBUG "-O0 -g -DDEBUG -D_DEBUG" CACHE STRING "c Debug flags" )
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags" )
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "-Wl,-z,nocopyreloc" CACHE STRING "executable linker flags" )
|
||||
|
||||
# finish flags
|
||||
set( ANDROID_CXX_FLAGS "${ANDROID_CXX_FLAGS}" CACHE INTERNAL "Extra Android compiler flags" )
|
||||
set( ANDROID_LINKER_FLAGS "${ANDROID_LINKER_FLAGS}" CACHE INTERNAL "Extra Android linker flags" )
|
||||
set( CMAKE_CXX_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_CXX_FLAGS}" )
|
||||
set( CMAKE_C_FLAGS "${ANDROID_CXX_FLAGS} ${CMAKE_C_FLAGS}" )
|
||||
set( CMAKE_CXX_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}" )
|
||||
set( CMAKE_C_FLAGS_RELEASE "${ANDROID_CXX_FLAGS_RELEASE} ${CMAKE_C_FLAGS_RELEASE}" )
|
||||
set( CMAKE_CXX_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}" )
|
||||
set( CMAKE_C_FLAGS_DEBUG "${ANDROID_CXX_FLAGS_DEBUG} ${CMAKE_C_FLAGS_DEBUG}" )
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
|
||||
|
||||
if( MIPS AND BUILD_WITH_ANDROID_NDK AND ANDROID_NDK_RELEASE STREQUAL "r8" )
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
|
||||
else()
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}" )
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS}" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "${ANDROID_LINKER_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}" )
|
||||
set( CMAKE_SHARED_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_SHARED_LINKER_FLAGS}" )
|
||||
set( CMAKE_MODULE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.xsc ${CMAKE_MODULE_LINKER_FLAGS}" )
|
||||
set( CMAKE_EXE_LINKER_FLAGS "-Wl,-T,${ANDROID_NDK}/toolchains/${ANDROID_TOOLCHAIN_NAME}/mipself.x ${CMAKE_EXE_LINKER_FLAGS}" )
|
||||
endif()
|
||||
|
||||
# configure rtti
|
||||
if( DEFINED ANDROID_RTTI AND ANDROID_STL_FORCE_FEATURES )
|
||||
if( ANDROID_RTTI )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frtti" )
|
||||
set( CMAKE_CXX_FLAGS "-frtti ${CMAKE_CXX_FLAGS}" )
|
||||
else()
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti" )
|
||||
set( CMAKE_CXX_FLAGS "-fno-rtti ${CMAKE_CXX_FLAGS}" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# configure exceptios
|
||||
if( DEFINED ANDROID_EXCEPTIONS AND ANDROID_STL_FORCE_FEATURES )
|
||||
if( ANDROID_EXCEPTIONS )
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fexceptions" )
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fexceptions" )
|
||||
set( CMAKE_CXX_FLAGS "-fexceptions ${CMAKE_CXX_FLAGS}" )
|
||||
set( CMAKE_C_FLAGS "-fexceptions ${CMAKE_C_FLAGS}" )
|
||||
else()
|
||||
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions" )
|
||||
set( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fno-exceptions" )
|
||||
set( CMAKE_CXX_FLAGS "-fno-exceptions ${CMAKE_CXX_FLAGS}" )
|
||||
set( CMAKE_C_FLAGS "-fno-exceptions ${CMAKE_C_FLAGS}" )
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# global includes and link directories
|
||||
if( ANDROID_STL_INCLUDE_DIRS )
|
||||
include_directories( SYSTEM ${ANDROID_STL_INCLUDE_DIRS} )
|
||||
endif()
|
||||
include_directories( SYSTEM "${ANDROID_SYSROOT}/usr/include" ${ANDROID_STL_INCLUDE_DIRS} )
|
||||
link_directories( "${CMAKE_INSTALL_PREFIX}/libs/${ANDROID_NDK_ABI_NAME}" )
|
||||
|
||||
|
||||
# set these global flags for cmake client scripts to change behavior
|
||||
set( ANDROID True )
|
||||
set( BUILD_ANDROID True )
|
||||
@ -1242,11 +1268,13 @@ macro( ANDROID_GET_ABI_RAWNAME TOOLCHAIN_FLAG VAR )
|
||||
if( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI" )
|
||||
set( ${VAR} "armeabi" )
|
||||
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "ARMEABI_V7A" )
|
||||
set( ${VAR} "armeabi-v7a" )
|
||||
set( ${VAR} "armeabi-v7a" )
|
||||
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "X86" )
|
||||
set( ${VAR} "x86" )
|
||||
set( ${VAR} "x86" )
|
||||
elseif( "${TOOLCHAIN_FLAG}" STREQUAL "MIPS" )
|
||||
set( ${VAR} "mips" )
|
||||
else()
|
||||
set( ${VAR} "unknown" )
|
||||
set( ${VAR} "unknown" )
|
||||
endif()
|
||||
endmacro()
|
||||
|
||||
@ -1254,10 +1282,22 @@ endmacro()
|
||||
# export toolchain settings for the try_compile() command
|
||||
if( NOT PROJECT_NAME STREQUAL "CMAKE_TRY_COMPILE" )
|
||||
set( __toolchain_config "")
|
||||
foreach( __var NDK_CCACHE ANDROID_ABI ANDROID_FORCE_ARM_BUILD ANDROID_NATIVE_API_LEVEL ANDROID_NO_UNDEFINED
|
||||
ANDROID_SO_UNDEFINED ANDROID_SET_OBSOLETE_VARIABLES LIBRARY_OUTPUT_PATH_ROOT ANDROID_STL
|
||||
ANDROID_STL_FORCE_FEATURES ANDROID_FORBID_SYGWIN ANDROID_NDK ANDROID_STANDALONE_TOOLCHAIN
|
||||
ANDROID_FUNCTION_LEVEL_LINKING ANDROID_USE_GOLD_LINKER )
|
||||
foreach( __var NDK_CCACHE LIBRARY_OUTPUT_PATH_ROOT ANDROID_FORBID_SYGWIN ANDROID_SET_OBSOLETE_VARIABLES
|
||||
ANDROID_NDK
|
||||
ANDROID_STANDALONE_TOOLCHAIN
|
||||
ANDROID_TOOLCHAIN_NAME
|
||||
ANDROID_ABI
|
||||
ANDROID_NATIVE_API_LEVEL
|
||||
ANDROID_STL
|
||||
ANDROID_STL_FORCE_FEATURES
|
||||
ANDROID_FORCE_ARM_BUILD
|
||||
ANDROID_NO_UNDEFINED
|
||||
ANDROID_SO_UNDEFINED
|
||||
ANDROID_FUNCTION_LEVEL_LINKING
|
||||
ANDROID_GOLD_LINKER
|
||||
ANDROID_NOEXECSTACK
|
||||
ANDROID_RELRO
|
||||
)
|
||||
if( DEFINED ${__var} )
|
||||
if( "${__var}" MATCHES " ")
|
||||
set( __toolchain_config "${__toolchain_config}set( ${__var} \"${${__var}}\" CACHE INTERNAL \"\" )\n" )
|
||||
@ -1289,7 +1329,9 @@ endif()
|
||||
# ANDROID_NO_UNDEFINED : ON/OFF
|
||||
# ANDROID_SO_UNDEFINED : OFF/ON (default depends on NDK version)
|
||||
# ANDROID_FUNCTION_LEVEL_LINKING : ON/OFF
|
||||
# ANDROID_USE_GOLD_LINKER : ON/OFF (default depends on NDK version and host & target platforms)
|
||||
# ANDROID_GOLD_LINKER : ON/OFF
|
||||
# ANDROID_NOEXECSTACK : ON/OFF
|
||||
# ANDROID_RELRO : ON/OFF
|
||||
# Variables that takes effect only at first run:
|
||||
# ANDROID_FORCE_ARM_BUILD : ON/OFF
|
||||
# ANDROID_STL : gnustl_static/gnustl_shared/stlport_static/stlport_shared/gabi++_static/gabi++_shared/system_re/system/none
|
||||
|
130
android/scripts/ABI_compat_generator.py
Executable file
130
android/scripts/ABI_compat_generator.py
Executable file
@ -0,0 +1,130 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
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"]);
|
||||
|
||||
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):
|
||||
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)
|
||||
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)
|
||||
|
||||
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 = tmp
|
||||
print("Using Android NDK from PATH (\"%s\")" % ANDROID_NDK_PATH)
|
||||
|
||||
print("Using Android SDK from \"%s\"" % ANDROID_SDK_PATH)
|
||||
|
||||
outputFileName = PROJECT_NAME + ".xml"
|
||||
try:
|
||||
outputFile = open(outputFileName, "w")
|
||||
except:
|
||||
print("Error: Cannot open output file \"%s\" for writing" % outputFileName)
|
||||
|
||||
allJavaClasses = FindClasses(CLASS_PATH, "")
|
||||
if (not allJavaClasses):
|
||||
print("Error: No Java classes found :(")
|
||||
exit(-1)
|
||||
|
||||
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)
|
||||
|
||||
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 = []
|
||||
for inc in SYS_INCLUDES:
|
||||
includes.append(os.path.join(ANDROID_NDK_PATH, inc))
|
||||
|
||||
outputFile.write("<include_paths>\n\tOpenCV-2.4.2-branch/sdk/native/jni/include\n\tOpenCV-2.4.2-branch/sdk/native/jni/include/opencv\n\tOpenCV-2.4.2-branch/sdk/native/jni/include/opencv2\n")
|
||||
|
||||
outputFile.write("\t%s\n</include_paths>\n\n" % "\n\t".join(includes))
|
||||
|
||||
libraries = []
|
||||
for lib in TARGET_LIBS:
|
||||
libraries.append(os.path.join(INSTALL_DIRECTORY, "sdk/native/libs", ARCH, lib))
|
||||
|
||||
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)
|
||||
|
||||
print("done!")
|
17
android/scripts/camera_build.conf
Normal file
17
android/scripts/camera_build.conf
Normal file
@ -0,0 +1,17 @@
|
||||
# make target; arch; API level; Android Source Code Root
|
||||
native_camera_r2.2.0; armeabi; 8; /home/alexander/Projects/AndroidSource/2.2.2
|
||||
native_camera_r2.2.0; armeabi-v7a; 8; /home/alexander/Projects/AndroidSource/2.2.2
|
||||
native_camera_r2.3.3; armeabi; 9; /home/alexander/Projects/AndroidSource/2.3.3
|
||||
native_camera_r2.3.3; armeabi-v7a; 9; /home/alexander/Projects/AndroidSource/2.3.3
|
||||
native_camera_r2.3.3; x86; 9; /home/alexander/Projects/AndroidSource/2.3.3
|
||||
native_camera_r3.0.1; armeabi; 9; /home/alexander/Projects/AndroidSource/3.0.1
|
||||
native_camera_r3.0.1; armeabi-v7a; 9; /home/alexander/Projects/AndroidSource/3.0.1
|
||||
native_camera_r3.0.1; x86; 9; /home/alexander/Projects/AndroidSource/3.0.1
|
||||
native_camera_r4.0.3; armeabi; 14; /home/alexander/Projects/AndroidSource/4.0.3
|
||||
native_camera_r4.0.3; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.0.3
|
||||
native_camera_r4.0.3; x86; 14; /home/alexander/Projects/AndroidSource/4.0.3
|
||||
native_camera_r4.0.0; armeabi; 14; /home/alexander/Projects/AndroidSource/4.0.0
|
||||
native_camera_r4.0.0; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.0.0
|
||||
native_camera_r4.1.1; armeabi; 14; /home/alexander/Projects/AndroidSource/4.1.1
|
||||
native_camera_r4.1.1; armeabi-v7a; 14; /home/alexander/Projects/AndroidSource/4.1.1
|
||||
native_camera_r4.1.1; x86; 14; /home/alexander/Projects/AndroidSource/4.1.1
|
54
android/scripts/cmake_android_all_cameras.py
Executable file
54
android/scripts/cmake_android_all_cameras.py
Executable file
@ -0,0 +1,54 @@
|
||||
#!/usr/bin/python
|
||||
|
||||
import os
|
||||
import sys
|
||||
import shutil
|
||||
|
||||
ScriptHome = os.path.split(sys.argv[0])[0]
|
||||
ConfFile = open(os.path.join(ScriptHome, "camera_build.conf"), "rt")
|
||||
HomeDir = os.getcwd()
|
||||
for s in ConfFile.readlines():
|
||||
s = s[0:s.find("#")]
|
||||
if (not s):
|
||||
continue
|
||||
keys = s.split(";")
|
||||
if (len(keys) < 4):
|
||||
print("Error: invalid config line: \"%s\"" % s)
|
||||
continue
|
||||
MakeTarget = str.strip(keys[0])
|
||||
Arch = str.strip(keys[1])
|
||||
NativeApiLevel = str.strip(keys[2])
|
||||
AndroidTreeRoot = str.strip(keys[3])
|
||||
AndroidTreeRoot = str.strip(AndroidTreeRoot, "\n")
|
||||
print("Building %s for %s" % (MakeTarget, Arch))
|
||||
BuildDir = os.path.join(HomeDir, MakeTarget + "_" + Arch)
|
||||
if (os.path.exists(BuildDir)):
|
||||
shutil.rmtree(BuildDir)
|
||||
try:
|
||||
os.mkdir(BuildDir)
|
||||
except:
|
||||
print("Error: cannot create direcotry \"%s\"" % BuildDir)
|
||||
continue
|
||||
shutil.rmtree(os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"), ignore_errors=True)
|
||||
if (Arch == "x86"):
|
||||
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_x86", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
|
||||
else:
|
||||
shutil.copytree(os.path.join(AndroidTreeRoot, "bin_arm", "system"), os.path.join(AndroidTreeRoot, "out", "target", "product", "generic", "system"))
|
||||
os.chdir(BuildDir)
|
||||
BuildLog = os.path.join(BuildDir, "build.log")
|
||||
CmakeCmdLine = "cmake -DCMAKE_TOOLCHAIN_FILE=../android.toolchain.cmake -DANDROID_SOURCE_TREE=\"%s\" -DANDROID_NATIVE_API_LEVEL=\"%s\" -DANDROID_ABI=\"%s\" -DANDROID_USE_STLPORT=ON ../../ > \"%s\" 2>&1" % (AndroidTreeRoot, NativeApiLevel, Arch, BuildLog)
|
||||
MakeCmdLine = "make %s >> \"%s\" 2>&1" % (MakeTarget, BuildLog);
|
||||
#print(CmakeCmdLine)
|
||||
os.system(CmakeCmdLine)
|
||||
#print(MakeCmdLine)
|
||||
os.system(MakeCmdLine)
|
||||
os.chdir(HomeDir)
|
||||
CameraLib = os.path.join(BuildDir, "lib", Arch, "lib" + MakeTarget + ".so")
|
||||
if (os.path.exists(CameraLib)):
|
||||
try:
|
||||
shutil.copyfile(CameraLib, os.path.join("..", "3rdparty", "lib", Arch, "lib" + MakeTarget + ".so"))
|
||||
print("Building %s for %s\t[OK]" % (MakeTarget, Arch));
|
||||
except:
|
||||
print("Building %s for %s\t[FAILED]" % (MakeTarget, Arch));
|
||||
ConfFile.close()
|
||||
|
@ -5,7 +5,7 @@ Base Loader Callback Interface implementation
|
||||
.. highlight:: java
|
||||
.. class:: BaseLoaderCallback
|
||||
|
||||
Basic implementation of LoaderCallbackInterface. Implementation logic is described by diagram.
|
||||
Basic implementation of LoaderCallbackInterface. Logic of this implementation is well-described by the following scheme:
|
||||
|
||||
.. image:: img/AndroidAppUsageModel.png
|
||||
|
||||
|
@ -11,21 +11,21 @@ String getPackageName()
|
||||
|
||||
.. method:: String getPackageName()
|
||||
|
||||
Get name of a package to be installed
|
||||
Get name of a package to be installed.
|
||||
|
||||
:rtype: String
|
||||
:return: Return package name, i.e. "OpenCV Manager Service" or "OpenCV library"
|
||||
:rtype: string;
|
||||
:return: returns package name, i.e. "OpenCV Manager Service" or "OpenCV library".
|
||||
|
||||
void install()
|
||||
--------------
|
||||
|
||||
.. method:: void install()
|
||||
|
||||
Installation of package is approved
|
||||
Installation of package has been approved.
|
||||
|
||||
void cancel()
|
||||
-------------
|
||||
|
||||
.. method:: void cancel()
|
||||
|
||||
Installation if package was canceled
|
||||
Installation if package has been canceled.
|
||||
|
@ -9,7 +9,7 @@ Introduction
|
||||
|
||||
OpenCV Manager is an Android service targeted to manage OpenCV library binaries on end users devices. It allows sharing the OpenCV dynamic libraries of different versions between applications on the same device. The Manager provides the following benefits\:
|
||||
|
||||
#. Less memory usage. All apps use the same binaries from service and do not keep native libs inside them self;
|
||||
#. Less memory usage. All apps use the same binaries from service and do not keep native libs inside themselves;
|
||||
#. Hardware specific optimizations for all supported platforms;
|
||||
#. Trusted OpenCV library source. All packages with OpenCV are published on Google Play service;
|
||||
#. Regular updates and bug fixes;
|
||||
@ -21,18 +21,18 @@ Usage model for target user
|
||||
|
||||
First OpenCV app\:
|
||||
|
||||
#. User downloads app dependent from OpenCV from Google Play or installs it manually;
|
||||
#. User starts application. Application asks user to install OpenCV Manager;
|
||||
#. User installs OpenCV Manager from Google Play Service;
|
||||
#. User starts application. Application proposes to user to install OpenCV library for target device and runs Google Play;
|
||||
#. User runs app in the third time and gets what he or she wants.
|
||||
#. Any OpenCV-dependent app is installed from Google Play marketplace or manually;
|
||||
#. At the first launch, it suggests installing OpenCV Manager;
|
||||
#. Then OpenCV Manager is downloaded and installed, using Google Play marketplace service.
|
||||
#. When started, the application suggests installing OpenCV library for the target device trough Google Play marketplace;
|
||||
#. After installation is finished, the app may be launched to perform common tasks.
|
||||
|
||||
Next OpenCV app\:
|
||||
|
||||
#. User downloads app dependent from OpenCV from Google Play or installs it manually;
|
||||
#. User starts application.
|
||||
#. If selected version is not installed Manager asks user to install OpenCV library package and runs Google Play;
|
||||
#. User runs app in the second time and gets what he or she wants.
|
||||
#. Any OpenCV-dependent app is installed from Google Play marketplace or manually;
|
||||
#. At the first launch, the app starts as usually;
|
||||
#. If the selected version is not installed, OpenCV Manager suggests installing OpenCV library for the target device trough Google Play marketplace;
|
||||
#. After installation is finished, the app may be launched to perform common tasks.
|
||||
|
||||
OpenCV Manager structure
|
||||
------------------------
|
||||
|
@ -5,32 +5,33 @@ Java OpenCV Loader
|
||||
.. highlight:: java
|
||||
.. Class:: OpenCVLoader
|
||||
|
||||
Helper class provides common initialization methods for OpenCV library
|
||||
Helper class provides common initialization methods for OpenCV library.
|
||||
|
||||
boolean initDebug()
|
||||
-------------------
|
||||
|
||||
.. method:: static boolean initDebug()
|
||||
|
||||
Load and initialize OpenCV library from current application package. Roughly it is analog of system.loadLibrary("opencv_java")
|
||||
Loads and initializes OpenCV library from within current application package. Roughly it is analog of ``system.loadLibrary("opencv_java")``.
|
||||
|
||||
:rtype: boolean
|
||||
:return: Return true if initialization of OpenCV was successful
|
||||
:rtype: boolean;
|
||||
:return: returns true if initialization of OpenCV was successful.
|
||||
|
||||
.. note:: This way is deprecated for production code. It is designed for experimantal and local development purposes only. If you want to publish your app use approach with async initialization
|
||||
.. note:: This method is deprecated for production code. It is designed for experimantal and local development purposes only. If you want to publish your app use approach with async initialization.
|
||||
|
||||
boolean initAsync()
|
||||
-------------------
|
||||
|
||||
.. method:: static boolean initAsync(String Version, Context AppContext, LoaderCallbackInterface Callback)
|
||||
|
||||
Load and initialize OpenCV library using OpenCV Manager service.
|
||||
Loads and initializes OpenCV library using OpenCV Manager service.
|
||||
|
||||
:param Version: OpenCV Library version
|
||||
:param AppContext: Application context for connecting to service
|
||||
:param Callback: Object, that implements LoaderCallbackInterface for handling Connection status. See BaseLoaderCallback.
|
||||
:rtype: boolean
|
||||
:return: Return true if initialization of OpenCV starts successfully
|
||||
:param Version: OpenCV Library version.
|
||||
:param AppContext: application context for connecting to the service.
|
||||
:param Callback: object, that implements LoaderCallbackInterface for handling connection status (see BaseLoaderCallback).
|
||||
|
||||
:rtype: boolean;
|
||||
:return: returns true if initialization of OpenCV starts successfully.
|
||||
|
||||
OpenCV version constants
|
||||
-------------------------
|
||||
|
@ -5,32 +5,32 @@ Loader Callback Interface
|
||||
.. highlight:: java
|
||||
.. class:: LoaderCallbackInterface
|
||||
|
||||
Interface for callback object in case of asynchronous initialization of OpenCV
|
||||
Interface for a callback object in case of asynchronous initialization of OpenCV.
|
||||
|
||||
void onManagerConnected()
|
||||
-------------------------
|
||||
|
||||
.. method:: void onManagerConnected(int status)
|
||||
|
||||
Callback method that is called after OpenCV library initialization
|
||||
Callback method that is called after OpenCV Library initialization.
|
||||
|
||||
:param status: Status of initialization. See Initialization status constants
|
||||
:param status: status of initialization (see Initialization Status Constants).
|
||||
|
||||
void onPackageInstall()
|
||||
-----------------------
|
||||
|
||||
.. method:: void onPackageInstall(InstallCallbackInterface Callback)
|
||||
|
||||
Callback method that is called in case when package installation is needed
|
||||
Callback method that is called in case when package installation is needed.
|
||||
|
||||
:param callback: Answer object with approve and cancel methods and package description
|
||||
:param callback: answer object with approve and cancel methods and package description.
|
||||
|
||||
Initialization status constants
|
||||
-------------------------------
|
||||
|
||||
.. data:: SUCCESS
|
||||
|
||||
OpenCV initialization finished successfully
|
||||
OpenCV initialization finished successfully.
|
||||
|
||||
.. data:: RESTART_REQUIRED
|
||||
|
||||
|
@ -5,25 +5,25 @@ Engine use Cases
|
||||
First application start
|
||||
-----------------------
|
||||
|
||||
There is no OpenCV Manager and OpenCV libraries.
|
||||
There is no OpenCV Manager or OpenCV libraries:
|
||||
|
||||
.. image:: img/NoService.png
|
||||
|
||||
Second application start
|
||||
------------------------
|
||||
|
||||
There is OpenCV Manager service, but there is no OpenCV library.
|
||||
If OpenCV library installation approved\:
|
||||
There is an OpenCV Manager service, but there is no OpenCV library.
|
||||
If OpenCV library installation has been approved\:
|
||||
|
||||
.. image:: img/LibInstallAproved.png
|
||||
|
||||
If OpenCV library installation canceled\:
|
||||
If OpenCV library installation has been canceled\:
|
||||
|
||||
.. image:: img/LibInstallCanceled.png
|
||||
|
||||
Regular application start
|
||||
-------------------------
|
||||
|
||||
OpenCV Manager and OpenCV library has bee already installed.
|
||||
OpenCV Manager and OpenCV library has been already installed.
|
||||
|
||||
.. image:: img/LibInstalled.png
|
@ -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="13"
|
||||
android:versionName="1.3" >
|
||||
android:versionCode="15"
|
||||
android:versionName="1.5" >
|
||||
|
||||
<uses-sdk android:minSdkVersion="8" />
|
||||
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
|
||||
@ -16,13 +16,16 @@
|
||||
<action android:name="org.opencv.engine.BIND"></action>
|
||||
</intent-filter>
|
||||
</service>
|
||||
|
||||
<activity android:name="org.opencv.engine.manager.ManagerActivity" android:label="@string/app_name" >
|
||||
|
||||
<activity
|
||||
android:name="org.opencv.engine.manager.ManagerActivity"
|
||||
android:label="@string/app_name"
|
||||
android:screenOrientation="portrait">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
|
||||
</application>
|
||||
</manifest>
|
@ -20,7 +20,7 @@
|
||||
#define FEATURES_HAS_SSSE3 4L
|
||||
#define FEATURES_HAS_GPU 65536L
|
||||
|
||||
// TODO: Do not forget to add Platrfom name to PackageInfo::PlatformNameMap
|
||||
// TODO: Do not forget to add Platrfom name to PackageInfo::PlatformNameMap
|
||||
// in method PackageInfo::InitPlatformNameMap()
|
||||
#define PLATFORM_UNKNOWN 0L
|
||||
#define PLATFORM_TEGRA 1L
|
||||
|
@ -125,23 +125,23 @@ android::String16 OpenCVEngine::GetLibraryList(android::String16 version)
|
||||
if (!tmp.empty())
|
||||
{
|
||||
tmp += "/libopencvinfo.so";
|
||||
|
||||
|
||||
LOGD("Trying to load info library \"%s\"", tmp.c_str());
|
||||
|
||||
|
||||
void *handle;
|
||||
char* (*info_func)();
|
||||
|
||||
|
||||
handle = dlopen(tmp.c_str(), RTLD_LAZY);
|
||||
if (handle)
|
||||
{
|
||||
const char *error;
|
||||
|
||||
dlerror();
|
||||
|
||||
dlerror();
|
||||
*(void **) (&info_func) = dlsym(handle, "GetLibraryList");
|
||||
if ((error = dlerror()) == NULL)
|
||||
{
|
||||
result = String16((*info_func)());
|
||||
dlclose(handle);
|
||||
dlclose(handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -14,9 +14,9 @@
|
||||
#define CPU_INFO_SSE2_STR "sse2"
|
||||
#define CPU_INFO_SSSE3_STR "ssse3"
|
||||
|
||||
#define CPU_INFO_ARCH_ARMV7_STR "ARMv7"
|
||||
#define CPU_INFO_ARCH_ARMV6_STR "ARMv6"
|
||||
#define CPU_INFO_ARCH_ARMV5_STR "ARMv5"
|
||||
#define CPU_INFO_ARCH_ARMV7_STR "(v7l)"
|
||||
#define CPU_INFO_ARCH_ARMV6_STR "(v6l)"
|
||||
#define CPU_INFO_ARCH_ARMV5_STR "(v5l)"
|
||||
|
||||
#define CPU_INFO_ARCH_X86_STR "x86"
|
||||
|
||||
|
@ -15,14 +15,14 @@ set<string> CommonPackageManager::GetInstalledVersions()
|
||||
{
|
||||
set<string> result;
|
||||
vector<PackageInfo> installed_packages = GetInstalledPackages();
|
||||
|
||||
|
||||
for (vector<PackageInfo>::const_iterator it = installed_packages.begin(); it != installed_packages.end(); ++it)
|
||||
{
|
||||
string version = it->GetVersion();
|
||||
assert(!version.empty());
|
||||
result.insert(version);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -33,12 +33,12 @@ bool CommonPackageManager::CheckVersionInstalled(const std::string& version, int
|
||||
PackageInfo target_package(version, platform, cpu_id);
|
||||
LOGD("GetInstalledPackages() call");
|
||||
vector<PackageInfo> packages = GetInstalledPackages();
|
||||
|
||||
|
||||
for (vector<PackageInfo>::const_iterator it = packages.begin(); it != packages.end(); ++it)
|
||||
{
|
||||
LOGD("Found package: \"%s\"", it->GetFullName().c_str());
|
||||
}
|
||||
|
||||
|
||||
if (!packages.empty())
|
||||
{
|
||||
result = (packages.end() != find(packages.begin(), packages.end(), target_package));
|
||||
@ -60,7 +60,7 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
PackageInfo target_package(version, platform, cpu_id);
|
||||
vector<PackageInfo> all_packages = GetInstalledPackages();
|
||||
vector<PackageInfo> packages;
|
||||
|
||||
|
||||
for (vector<PackageInfo>::iterator it = all_packages.begin(); it != all_packages.end(); ++it)
|
||||
{
|
||||
LOGD("Check version \"%s\" compatibility with \"%s\"\n", version.c_str(), it->GetVersion().c_str());
|
||||
@ -71,10 +71,10 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGD("NOT Compatible");
|
||||
LOGD("NOT Compatible");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!packages.empty())
|
||||
{
|
||||
vector<PackageInfo>::iterator found = find(packages.begin(), packages.end(), target_package);
|
||||
@ -86,13 +86,13 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
{
|
||||
int OptRating = -1;
|
||||
std::vector<std::pair<int, int> >& group = CommonPackageManager::ArmRating;
|
||||
|
||||
|
||||
if ((cpu_id & ARCH_X86) || (cpu_id & ARCH_X64))
|
||||
group = CommonPackageManager::IntelRating;
|
||||
|
||||
|
||||
int HardwareRating = GetHardwareRating(platform, cpu_id, group);
|
||||
LOGD("Current hardware platform %d, %d", platform, cpu_id);
|
||||
|
||||
|
||||
if (-1 == HardwareRating)
|
||||
{
|
||||
LOGE("Cannot calculate rating for current hardware platform!");
|
||||
@ -111,7 +111,7 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if ((-1 != OptRating) && (packages.end() != found))
|
||||
{
|
||||
result = found->GetInstalationPath();
|
||||
@ -123,7 +123,7 @@ string CommonPackageManager::GetPackagePathByVersion(const std::string& version,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -131,22 +131,22 @@ bool CommonPackageManager::IsVersionCompatible(const std::string& target_version
|
||||
{
|
||||
assert (target_version.size() == 3);
|
||||
assert (package_version.size() == 3);
|
||||
|
||||
|
||||
bool result = false;
|
||||
|
||||
|
||||
// major version is the same and minor package version is above or the same as target.
|
||||
if ((package_version[0] == target_version[0]) && (package_version[1] == target_version[1]) && (package_version[2] >= target_version[2]))
|
||||
{
|
||||
result = true;
|
||||
result = true;
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int CommonPackageManager::GetHardwareRating(int platform, int cpu_id, const std::vector<std::pair<int, int> >& group)
|
||||
{
|
||||
int result = -1;
|
||||
|
||||
|
||||
for (size_t i = 0; i < group.size(); i++)
|
||||
{
|
||||
if (group[i] == std::pair<int, int>(platform, cpu_id))
|
||||
@ -162,19 +162,23 @@ int CommonPackageManager::GetHardwareRating(int platform, int cpu_id, const std:
|
||||
std::vector<std::pair<int, int> > CommonPackageManager::InitArmRating()
|
||||
{
|
||||
std::vector<std::pair<int, int> > result;
|
||||
|
||||
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv5));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3d16));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv6 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_VFPv3));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_NEON));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_NEON));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_TEGRA2, ARCH_ARMv7 | FEATURES_HAS_VFPv3));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_UNKNOWN, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_VFPv3d16 | FEATURES_HAS_NEON));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_TEGRA2, ARCH_ARMv7 | FEATURES_HAS_VFPv3d16));
|
||||
result.push_back(std::pair<int, int>(PLATFORM_TEGRA3, ARCH_ARMv7 | FEATURES_HAS_VFPv3 | FEATURES_HAS_NEON));
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
61
android/service/engine/res/layout-small/info.xml
Normal file
61
android/service/engine/res/layout-small/info.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:focusable="false"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/InfoName"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Large Text"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Version: "
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/InfoVersion"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Small Text"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Target hardware: "
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/InfoHardware"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Small Text"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
120
android/service/engine/res/layout-small/main.xml
Normal file
120
android/service/engine/res/layout-small/main.xml
Normal file
@ -0,0 +1,120 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView4"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="About"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:autoLink="web"
|
||||
android:text="OpenCV is Open Computer Vision library. OpenCV Manager provides the best version of the OpenCV for your hardware. See opencv.org for details."
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/EngineVersionCaption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Version: "
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/EngineVersionValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="version"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView3"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Device information"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_marginTop="15dp"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical" >
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/HardwareCaption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hardware: "
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/HardwareValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Hardware"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" >
|
||||
|
||||
<TextView
|
||||
android:id="@+id/OsVersionCaption"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OS version: "
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/OsVersionValue"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Os Specification"
|
||||
android:textAppearance="?android:attr/textAppearanceSmall" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/textView1"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Installed packages"
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" android:layout_marginTop="15dp"/>
|
||||
|
||||
<ListView
|
||||
android:id="@+id/InstalledPackageList"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" android:layout_weight="1">
|
||||
</ListView>
|
||||
|
||||
<Button
|
||||
android:id="@+id/CheckEngineUpdate"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Check for update" />
|
||||
|
||||
</LinearLayout>
|
@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_width="fill_parent"
|
||||
android:layout_height="fill_parent"
|
||||
android:focusable="false"
|
||||
android:orientation="vertical" >
|
||||
|
||||
|
@ -15,7 +15,8 @@
|
||||
android:id="@+id/textView2"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="OpenCV library (www.opencv.org) is used by other applications for image enhancement, panorama stitching, object detection, recognition and tracking and so on. OpenCV Manager provides the best version of the OpenCV for your hardware."
|
||||
android:autoLink="web"
|
||||
android:text="OpenCV library is used by other applications for image enhancement, panorama stitching, object detection, recognition and tracking and so on. OpenCV Manager provides the best version of the OpenCV for your hardware. See opencv.org for details."
|
||||
android:textAppearance="?android:attr/textAppearanceMedium" />
|
||||
|
||||
<LinearLayout
|
||||
|
@ -17,6 +17,7 @@ import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.ServiceConnection;
|
||||
import android.content.pm.PackageInfo;
|
||||
import android.content.pm.PackageManager.NameNotFoundException;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
@ -39,28 +40,37 @@ public class ManagerActivity extends Activity
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.main);
|
||||
|
||||
|
||||
TextView OsVersionView = (TextView)findViewById(R.id.OsVersionValue);
|
||||
OsVersionView.setText(Build.VERSION.CODENAME + " (" + Build.VERSION.RELEASE + "), API " + Build.VERSION.SDK_INT);
|
||||
|
||||
|
||||
try {
|
||||
PackageInfo packageInfo = getPackageManager().getPackageInfo(this.getPackageName(), 0);
|
||||
ManagerVersion = packageInfo.versionName;
|
||||
} catch (NameNotFoundException e) {
|
||||
// TODO Auto-generated catch block
|
||||
ManagerVersion = "N/A";
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
mInstalledPackageView = (ListView)findViewById(R.id.InstalledPackageList);
|
||||
|
||||
|
||||
mMarket = new MarketConnector(this);
|
||||
|
||||
mInstalledPacksAdapter = new SimpleAdapter(
|
||||
|
||||
mInstalledPacksAdapter = new PackageListAdapter(
|
||||
this,
|
||||
mListViewItems,
|
||||
R.layout.info,
|
||||
new String[] {"Name", "Version", "Hardware"},
|
||||
new String[] {"Name", "Version", "Hardware", "Activity"},
|
||||
new int[] {R.id.InfoName,R.id.InfoVersion, R.id.InfoHardware}
|
||||
);
|
||||
|
||||
|
||||
mInstalledPackageView.setAdapter(mInstalledPacksAdapter);
|
||||
|
||||
|
||||
TextView HardwarePlatformView = (TextView)findViewById(R.id.HardwareValue);
|
||||
int Platfrom = HardwareDetector.DetectKnownPlatforms();
|
||||
int CpuId = HardwareDetector.GetCpuID();
|
||||
|
||||
|
||||
if (HardwareDetector.PLATFORM_UNKNOWN != Platfrom)
|
||||
{
|
||||
if (HardwareDetector.PLATFORM_TEGRA == Platfrom)
|
||||
@ -107,7 +117,7 @@ public class ManagerActivity extends Activity
|
||||
HardwarePlatformView.setText("not detected");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
mUpdateEngineButton = (Button)findViewById(R.id.CheckEngineUpdate);
|
||||
mUpdateEngineButton.setOnClickListener(new OnClickListener() {
|
||||
|
||||
@ -119,9 +129,9 @@ public class ManagerActivity extends Activity
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mActionDialog = new AlertDialog.Builder(this).create();
|
||||
|
||||
|
||||
mActionDialog.setTitle("Choose action");
|
||||
mActionDialog.setButton("Update", new DialogInterface.OnClickListener() {
|
||||
|
||||
@ -134,7 +144,7 @@ public class ManagerActivity extends Activity
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mActionDialog.setButton3("Remove", new DialogInterface.OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
@ -143,152 +153,192 @@ public class ManagerActivity extends Activity
|
||||
{
|
||||
Toast toast = Toast.makeText(getApplicationContext(), "Google Play is not avaliable", Toast.LENGTH_SHORT);
|
||||
toast.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mActionDialog.setButton2("Return", new DialogInterface.OnClickListener() {
|
||||
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
// nothing
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
mInstalledPackageView.setOnItemClickListener(new OnItemClickListener() {
|
||||
|
||||
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long id) {
|
||||
|
||||
mInstalledPackageView.setTag(new Integer((int)id));
|
||||
|
||||
mInstalledPackageView.setTag(Integer.valueOf((int)id));
|
||||
mActionDialog.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (!bindService(new Intent("org.opencv.engine.BIND"), mServiceConnection, Context.BIND_AUTO_CREATE))
|
||||
{
|
||||
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
|
||||
EngineVersionView.setText("not avaliable");
|
||||
}
|
||||
|
||||
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(Intent.ACTION_PACKAGE_ADDED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_CHANGED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_INSTALL);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REMOVED);
|
||||
filter.addAction(Intent.ACTION_PACKAGE_REPLACED);
|
||||
|
||||
|
||||
registerReceiver(mPackageChangeReciever, filter);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
unregisterReceiver(mPackageChangeReciever);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
Log.d(TAG, "Filling package list on resume");
|
||||
FillPackageList();
|
||||
}
|
||||
|
||||
|
||||
protected SimpleAdapter mInstalledPacksAdapter;
|
||||
protected ListView mInstalledPackageView;
|
||||
protected Button mUpdateEngineButton;
|
||||
protected PackageInfo[] mInstalledPackageInfo;
|
||||
protected static final ArrayList<HashMap<String,String>> mListViewItems = new ArrayList<HashMap<String,String>>();
|
||||
protected final ArrayList<HashMap<String,String>> mListViewItems = new ArrayList<HashMap<String,String>>();
|
||||
protected static final String TAG = "OpenCV_Manager/Activity";
|
||||
protected MarketConnector mMarket;
|
||||
AlertDialog mActionDialog;
|
||||
|
||||
protected AlertDialog mActionDialog;
|
||||
protected HashMap<String,String> mActivePackageMap = new HashMap<String, String>();
|
||||
protected int ManagerApiLevel = 0;
|
||||
protected String ManagerVersion;
|
||||
|
||||
protected BroadcastReceiver mPackageChangeReciever = new BroadcastReceiver() {
|
||||
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
Log.d("OpenCV Manager/Reciever", "Bradcast message " + intent.getAction() + " reciever");
|
||||
Log.d("OpenCV Manager/Reciever", "Filling package list on broadcast message");
|
||||
FillPackageList();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
protected ServiceConnection mServiceConnection = new ServiceConnection() {
|
||||
|
||||
|
||||
public void onServiceDisconnected(ComponentName name) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void onServiceConnected(ComponentName name, IBinder service) {
|
||||
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
|
||||
OpenCVEngineInterface EngineService = OpenCVEngineInterface.Stub.asInterface(service);
|
||||
try {
|
||||
EngineVersionView.setText("" + EngineService.getEngineVersion());
|
||||
ManagerApiLevel = EngineService.getEngineVersion();
|
||||
} catch (RemoteException e) {
|
||||
EngineVersionView.setText("not avaliable");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
TextView EngineVersionView = (TextView)findViewById(R.id.EngineVersionValue);
|
||||
EngineVersionView.setText(ManagerVersion);
|
||||
|
||||
try {
|
||||
String path = EngineService.getLibPathByVersion("2.4");
|
||||
Log.d(TAG, "2.4 -> " + path);
|
||||
mActivePackageMap.put("24", path);
|
||||
path = EngineService.getLibPathByVersion("2.5");
|
||||
Log.d(TAG, "2.5 -> " + path);
|
||||
mActivePackageMap.put("25", path);
|
||||
} catch (RemoteException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
Log.d(TAG, "Filling package list on service connection");
|
||||
FillPackageList();
|
||||
|
||||
unbindService(mServiceConnection);
|
||||
}
|
||||
};
|
||||
|
||||
protected void FillPackageList()
|
||||
{
|
||||
mInstalledPackageInfo = mMarket.GetInstalledOpenCVPackages();
|
||||
mListViewItems.clear();
|
||||
|
||||
for (int i = 0; i < mInstalledPackageInfo.length; i++)
|
||||
{
|
||||
// Convert to Items for package list view
|
||||
HashMap<String,String> temp = new HashMap<String,String>();
|
||||
temp.put("Name", mMarket.GetApplicationName(mInstalledPackageInfo[i].applicationInfo));
|
||||
synchronized (mListViewItems) {
|
||||
mInstalledPackageInfo = mMarket.GetInstalledOpenCVPackages();
|
||||
mListViewItems.clear();
|
||||
|
||||
int idx = 0;
|
||||
String OpenCVersion = "unknown";
|
||||
String HardwareName = "";
|
||||
StringTokenizer tokenizer = new StringTokenizer(mInstalledPackageInfo[i].packageName, "_");
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
if (idx == 1)
|
||||
{
|
||||
// version of OpenCV
|
||||
OpenCVersion = tokenizer.nextToken().substring(1);
|
||||
}
|
||||
else if (idx >= 2)
|
||||
{
|
||||
// hardware options
|
||||
HardwareName += tokenizer.nextToken() + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenizer.nextToken();
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
temp.put("Version", NormalizeVersion(OpenCVersion, mInstalledPackageInfo[i].versionName));
|
||||
temp.put("Hardware", HardwareName);
|
||||
mListViewItems.add(temp);
|
||||
}
|
||||
|
||||
mInstalledPacksAdapter.notifyDataSetChanged();
|
||||
for (int i = 0; i < mInstalledPackageInfo.length; i++)
|
||||
{
|
||||
// Convert to Items for package list view
|
||||
HashMap<String,String> temp = new HashMap<String,String>();
|
||||
String PublicName = mMarket.GetApplicationName(mInstalledPackageInfo[i].applicationInfo);
|
||||
|
||||
int idx = 0;
|
||||
String OpenCVersion = "unknown";
|
||||
String HardwareName = "";
|
||||
StringTokenizer tokenizer = new StringTokenizer(mInstalledPackageInfo[i].packageName, "_");
|
||||
while (tokenizer.hasMoreTokens())
|
||||
{
|
||||
if (idx == 1)
|
||||
{
|
||||
// version of OpenCV
|
||||
OpenCVersion = tokenizer.nextToken().substring(1);
|
||||
}
|
||||
else if (idx >= 2)
|
||||
{
|
||||
// hardware options
|
||||
HardwareName += tokenizer.nextToken() + " ";
|
||||
}
|
||||
else
|
||||
{
|
||||
tokenizer.nextToken();
|
||||
}
|
||||
idx++;
|
||||
}
|
||||
|
||||
String ActivePackagePath;
|
||||
ActivePackagePath = mActivePackageMap.get(OpenCVersion);
|
||||
Log.d(TAG, OpenCVersion + " -> " + ActivePackagePath);
|
||||
|
||||
if (null != ActivePackagePath && ActivePackagePath.indexOf(mInstalledPackageInfo[i].packageName) >= 0)
|
||||
{
|
||||
temp.put("Activity", "y");
|
||||
PublicName += " (in use)";
|
||||
}
|
||||
else
|
||||
{
|
||||
temp.put("Activity", "n");
|
||||
}
|
||||
|
||||
temp.put("Name", PublicName);
|
||||
temp.put("Version", NormalizeVersion(OpenCVersion, mInstalledPackageInfo[i].versionName));
|
||||
temp.put("Hardware", HardwareName);
|
||||
mListViewItems.add(temp);
|
||||
}
|
||||
|
||||
mInstalledPacksAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected String NormalizeVersion(String OpenCVersion, String PackageVersion)
|
||||
{
|
||||
int dot = PackageVersion.indexOf(".");
|
||||
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
|
||||
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
|
||||
PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1);
|
||||
return OpenCVersion.substring(0, OpenCVersion.length()-1) + "." +
|
||||
OpenCVersion.toCharArray()[OpenCVersion.length()-1] + "." +
|
||||
PackageVersion.substring(0, dot) + " rev " + PackageVersion.substring(dot+1);
|
||||
}
|
||||
|
||||
|
||||
protected String ConvertPackageName(String Name, String Version)
|
||||
{
|
||||
return Name + " rev " + Version;
|
||||
}
|
||||
|
||||
|
||||
protected String JoinIntelFeatures(int features)
|
||||
{
|
||||
// TODO: update if package will be published
|
||||
return "";
|
||||
}
|
||||
|
||||
|
||||
protected String JoinArmFeatures(int features)
|
||||
{
|
||||
// TODO: update if package will be published
|
||||
|
@ -0,0 +1,38 @@
|
||||
package org.opencv.engine.manager;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.SimpleAdapter;
|
||||
|
||||
public class PackageListAdapter extends SimpleAdapter {
|
||||
|
||||
public PackageListAdapter(Context context,
|
||||
List<? extends Map<String, ?>> data, int resource, String[] from,
|
||||
int[] to) {
|
||||
super(context, data, resource, from, to);
|
||||
// TODO Auto-generated constructor stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
View view = super.getView(position, convertView, parent);
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, String> item = (Map<String, String>)getItem(position);
|
||||
Log.d("PackageListAdapter", item.get("Activity"));
|
||||
if (item.get("Activity") == "y")
|
||||
{
|
||||
view.setBackgroundColor(0x50ffffff);
|
||||
}
|
||||
else
|
||||
{
|
||||
view.setBackgroundColor(0xff000000);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
@ -124,35 +124,33 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
|
||||
# SSE3 and further should be disabled under MingW because it generates compiler errors
|
||||
if(NOT MINGW)
|
||||
if(ENABLE_SSE3)
|
||||
add_extra_compiler_option(-msse3)
|
||||
if(ENABLE_AVX)
|
||||
add_extra_compiler_option(-mavx)
|
||||
endif()
|
||||
|
||||
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 402)
|
||||
set(HAVE_GCC43_OR_NEWER 1)
|
||||
endif()
|
||||
if(${CMAKE_OPENCV_GCC_VERSION_NUM} GREATER 401)
|
||||
set(HAVE_GCC42_OR_NEWER 1)
|
||||
endif()
|
||||
# GCC depresses SSEx instructions when -mavx is used. Instead, it generates new AVX instructions or AVX equivalence for all SSEx instructions when needed.
|
||||
if(NOT OPENCV_EXTRA_CXX_FLAGS MATCHES "-mavx")
|
||||
if(ENABLE_SSE3)
|
||||
add_extra_compiler_option(-msse3)
|
||||
endif()
|
||||
|
||||
if(HAVE_GCC42_OR_NEWER OR APPLE)
|
||||
if(ENABLE_SSSE3)
|
||||
add_extra_compiler_option(-mssse3)
|
||||
endif()
|
||||
if(HAVE_GCC43_OR_NEWER OR APPLE)
|
||||
if(ENABLE_SSE41)
|
||||
add_extra_compiler_option(-msse4.1)
|
||||
endif()
|
||||
if(ENABLE_SSE42)
|
||||
add_extra_compiler_option(-msse4.2)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE41)
|
||||
add_extra_compiler_option(-msse4.1)
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE42)
|
||||
add_extra_compiler_option(-msse4.2)
|
||||
endif()
|
||||
endif()
|
||||
endif(NOT MINGW)
|
||||
|
||||
if(X86 OR X86_64)
|
||||
if(NOT APPLE AND CMAKE_SIZEOF_VOID_P EQUAL 4)
|
||||
if(ENABLE_SSE2)
|
||||
if(OPENCV_EXTRA_CXX_FLAGS MATCHES "-m(sse2|avx)")
|
||||
add_extra_compiler_option(-mfpmath=sse)# !! important - be on the same wave with x64 compilers
|
||||
else()
|
||||
add_extra_compiler_option(-mfpmath=387)
|
||||
@ -201,30 +199,35 @@ if(MSVC)
|
||||
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} /Zi")
|
||||
endif()
|
||||
|
||||
if(NOT MSVC64)
|
||||
# 64-bit MSVC compiler uses SSE/SSE2 by default
|
||||
if(ENABLE_SSE)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE")
|
||||
endif()
|
||||
if(ENABLE_SSE2)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2")
|
||||
endif()
|
||||
if(ENABLE_AVX AND NOT MSVC_VERSION LESS 1600)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:AVX")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE3)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3")
|
||||
endif()
|
||||
if(ENABLE_SSE4_1)
|
||||
if(ENABLE_SSE4_1 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE4.1")
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1)
|
||||
if(ENABLE_SSE3 AND CV_ICC AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE3")
|
||||
endif()
|
||||
|
||||
if(NOT MSVC64)
|
||||
# 64-bit MSVC compiler uses SSE/SSE2 by default
|
||||
if(ENABLE_SSE2 AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE2")
|
||||
endif()
|
||||
if(ENABLE_SSE AND NOT OPENCV_EXTRA_FLAGS MATCHES "/arch:")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /arch:SSE")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(ENABLE_SSE OR ENABLE_SSE2 OR ENABLE_SSE3 OR ENABLE_SSE4_1 OR ENABLE_AVX)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /Oi")
|
||||
endif()
|
||||
|
||||
if(X86 OR X86_64)
|
||||
if(CMAKE_SIZEOF_VOID_P EQUAL 4 AND ENABLE_SSE2)
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast")# !! important - be on the same wave with x64 compilers
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS} /fp:fast") # !! important - be on the same wave with x64 compilers
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@ -238,34 +241,34 @@ endif()
|
||||
|
||||
# Add user supplied extra options (optimization, etc...)
|
||||
# ==========================================================
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options")
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options for C sources")
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS}" CACHE INTERNAL "Extra compiler options for C++ sources")
|
||||
set(OPENCV_EXTRA_FLAGS "${OPENCV_EXTRA_FLAGS}" CACHE INTERNAL "Extra compiler options")
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options for C sources")
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS}" CACHE INTERNAL "Extra compiler options for C++ sources")
|
||||
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build")
|
||||
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build")
|
||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags")
|
||||
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build")
|
||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS "${OPENCV_EXTRA_EXE_LINKER_FLAGS}" CACHE INTERNAL "Extra linker flags")
|
||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE "${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}" CACHE INTERNAL "Extra linker flags for Release build")
|
||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build")
|
||||
set(OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG "${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}" CACHE INTERNAL "Extra linker flags for Debug build")
|
||||
|
||||
#combine all "extra" options
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPENCV_EXTRA_FLAGS} ${OPENCV_EXTRA_CXX_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}")
|
||||
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${OPENCV_EXTRA_FLAGS_RELEASE}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${OPENCV_EXTRA_FLAGS_DEBUG}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OPENCV_EXTRA_EXE_LINKER_FLAGS}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_RELEASE}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} ${OPENCV_EXTRA_EXE_LINKER_FLAGS_DEBUG}")
|
||||
|
||||
if(MSVC)
|
||||
# avoid warnings from MSVC about overriding the /W* option
|
||||
# we replace /W3 with /W4 only for C++ files,
|
||||
# since all the 3rd-party libraries OpenCV uses are in C,
|
||||
# and we do not care about their warnings.
|
||||
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
string(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
|
||||
if(NOT ENABLE_NOISY_WARNINGS AND MSVC_VERSION EQUAL 1400)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS /wd4510 /wd4610 /wd4312 /wd4201 /wd4244 /wd4328 /wd4267)
|
||||
@ -274,7 +277,7 @@ if(MSVC)
|
||||
# allow extern "C" functions throw exceptions
|
||||
foreach(flags CMAKE_C_FLAGS CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELEASE CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_DEBUG)
|
||||
string(REPLACE "/EHsc-" "/EHs" ${flags} "${${flags}}")
|
||||
string(REPLACE "/EHsc" "/EHs" ${flags} "${${flags}}")
|
||||
string(REPLACE "/EHsc" "/EHs" ${flags} "${${flags}}")
|
||||
|
||||
string(REPLACE "/Zm1000" "" ${flags} "${${flags}}")
|
||||
endforeach()
|
||||
|
@ -89,8 +89,8 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES amd64.*|x86_64.* OR CMAKE_GENERATOR MATCHES "Visual Studio.*Win64")
|
||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64.*|x86_64.*|AMD64.*" OR CMAKE_GENERATOR MATCHES "Visual Studio.*Win64")
|
||||
set(X86_64 1)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES i686.*|i386.*|x86.*)
|
||||
elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "i686.*|i386.*|x86.*|amd64.*|AMD64.*")
|
||||
set(X86 1)
|
||||
endif()
|
||||
|
@ -56,7 +56,7 @@ else()
|
||||
if(OPENCL_LIB_SEARCH_PATH)
|
||||
find_library(OPENCL_LIBRARY NAMES OpenCL PATHS ${OPENCL_LIB_SEARCH_PATH} NO_DEFAULT_PATH)
|
||||
else()
|
||||
find_library(OPENCL_LIBRARY NAMES OpenCL PATHS ${OPENCL_LIB_SEARCH_PATH} NO_DEFAULT_PATH)
|
||||
find_library(OPENCL_LIBRARY NAMES OpenCL)
|
||||
endif()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
@ -1,4 +1,4 @@
|
||||
if(ANDROID)
|
||||
if(ANDROID AND NOT MIPS)
|
||||
add_subdirectory("${OpenCV_SOURCE_DIR}/3rdparty/tbb")
|
||||
include_directories(SYSTEM ${TBB_INCLUDE_DIRS})
|
||||
set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} tbb)
|
||||
@ -21,11 +21,11 @@ elseif(UNIX AND NOT APPLE)
|
||||
endif()
|
||||
|
||||
if(NOT HAVE_TBB)
|
||||
set(TBB_DEFAULT_INCLUDE_DIRS
|
||||
"/opt/intel/tbb" "/usr/local/include" "/usr/include"
|
||||
"C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB"
|
||||
"C:/Program Files (x86)/tbb/include"
|
||||
"C:/Program Files (x86)/tbb/include"
|
||||
set(TBB_DEFAULT_INCLUDE_DIRS
|
||||
"/opt/intel/tbb" "/usr/local/include" "/usr/include"
|
||||
"C:/Program Files/Intel/TBB" "C:/Program Files (x86)/Intel/TBB"
|
||||
"C:/Program Files (x86)/tbb/include"
|
||||
"C:/Program Files (x86)/tbb/include"
|
||||
"${CMAKE_INSTALL_PREFIX}/include")
|
||||
|
||||
find_path(TBB_INCLUDE_DIRS "tbb/tbb.h" PATHS ${TBB_INCLUDE_DIR} ${TBB_DEFAULT_INCLUDE_DIRS} DOC "The path to TBB headers")
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
# --- TBB ---
|
||||
if(WITH_TBB)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake" REQUIRED)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectTBB.cmake")
|
||||
endif(WITH_TBB)
|
||||
|
||||
# --- IPP ---
|
||||
@ -21,7 +21,7 @@ endif(WITH_IPP)
|
||||
|
||||
# --- CUDA ---
|
||||
if(WITH_CUDA)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCUDA.cmake" REQUIRED)
|
||||
include("${OpenCV_SOURCE_DIR}/cmake/OpenCVDetectCUDA.cmake")
|
||||
endif(WITH_CUDA)
|
||||
|
||||
# --- Eigen ---
|
||||
@ -29,7 +29,8 @@ if(WITH_EIGEN)
|
||||
find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
|
||||
PATHS /usr/local /opt /usr ENV ProgramFiles ENV ProgramW6432
|
||||
PATH_SUFFIXES include/eigen3 include/eigen2 Eigen/include/eigen3 Eigen/include/eigen2
|
||||
DOC "The path to Eigen3/Eigen2 headers")
|
||||
DOC "The path to Eigen3/Eigen2 headers"
|
||||
CMAKE_FIND_ROOT_PATH_BOTH)
|
||||
|
||||
if(EIGEN_INCLUDE_PATH)
|
||||
ocv_include_directories(${EIGEN_INCLUDE_PATH})
|
||||
|
@ -98,7 +98,7 @@ endif(WITH_XIMEA)
|
||||
ocv_clear_vars(HAVE_FFMPEG HAVE_FFMPEG_CODEC HAVE_FFMPEG_FORMAT HAVE_FFMPEG_UTIL HAVE_FFMPEG_SWSCALE HAVE_GENTOO_FFMPEG HAVE_FFMPEG_FFMPEG)
|
||||
if(WITH_FFMPEG)
|
||||
if(WIN32)
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg_version.cmake" REQUIRED)
|
||||
include("${OpenCV_SOURCE_DIR}/3rdparty/ffmpeg/ffmpeg_version.cmake")
|
||||
elseif(UNIX)
|
||||
CHECK_MODULE(libavcodec HAVE_FFMPEG_CODEC)
|
||||
CHECK_MODULE(libavformat HAVE_FFMPEG_FORMAT)
|
||||
|
@ -82,8 +82,8 @@ if(ANDROID)
|
||||
# -------------------------------------------------------------------------------------------
|
||||
set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"${OPENCV_CONFIG_FILE_INCLUDE_DIR}\" \"${OpenCV_SOURCE_DIR}/include\" \"${OpenCV_SOURCE_DIR}/include/opencv\"")
|
||||
set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "\"${OpenCV_SOURCE_DIR}\"")
|
||||
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/lib/\$(TARGET_ARCH_ABI)")
|
||||
set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/3rdparty/lib/\$(TARGET_ARCH_ABI)")
|
||||
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/lib/\$(OPENCV_TARGET_ARCH_ABI)")
|
||||
set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/3rdparty/lib/\$(OPENCV_TARGET_ARCH_ABI)")
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" IMMEDIATE @ONLY)
|
||||
|
||||
@ -92,8 +92,8 @@ if(ANDROID)
|
||||
# -------------------------------------------------------------------------------------------
|
||||
set(OPENCV_INCLUDE_DIRS_CONFIGCMAKE "\"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include/opencv\" \"\$(LOCAL_PATH)/\$(OPENCV_THIS_DIR)/include\"")
|
||||
set(OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE "")
|
||||
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../libs/\$(TARGET_ARCH_ABI)")
|
||||
set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../3rdparty/libs/\$(TARGET_ARCH_ABI)")
|
||||
set(OPENCV_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../libs/\$(OPENCV_TARGET_ARCH_ABI)")
|
||||
set(OPENCV_3RDPARTY_LIBS_DIR_CONFIGCMAKE "\$(OPENCV_THIS_DIR)/../3rdparty/libs/\$(OPENCV_TARGET_ARCH_ABI)")
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" IMMEDIATE @ONLY)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH})
|
||||
|
@ -4,6 +4,7 @@
|
||||
USER_LOCAL_PATH:=$(LOCAL_PATH)
|
||||
LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir)))))
|
||||
|
||||
OPENCV_TARGET_ARCH_ABI:=$(TARGET_ARCH_ABI)
|
||||
OPENCV_THIS_DIR:=$(patsubst $(LOCAL_PATH)\\%,%,$(patsubst $(LOCAL_PATH)/%,%,$(call my-dir)))
|
||||
OPENCV_MK_DIR:=$(dir $(lastword $(MAKEFILE_LIST)))
|
||||
OPENCV_LIBS_DIR:=@OPENCV_LIBS_DIR_CONFIGCMAKE@
|
||||
|
4
doc/_themes/blue/static/default.css_t
vendored
4
doc/_themes/blue/static/default.css_t
vendored
@ -179,6 +179,10 @@ div.body p, div.body dd, div.body li {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
div.toctree-wrapper li, ul.simple li {
|
||||
margin:0;
|
||||
}
|
||||
|
||||
div.body h1,
|
||||
div.body h2,
|
||||
div.body h3,
|
||||
|
@ -31,7 +31,7 @@ doc_signatures_whitelist = [
|
||||
# templates
|
||||
"Matx", "Vec", "SparseMat_", "Scalar_", "Mat_", "Ptr", "Size_", "Point_", "Rect_", "Point3_",
|
||||
"DataType", "detail::RotationWarperBase", "flann::Index_", "CalonderDescriptorExtractor",
|
||||
"gpu::DevMem2D_", "gpu::PtrStep_", "gpu::PtrElemStep_",
|
||||
"gpu::PtrStepSz", "gpu::PtrStep", "gpu::PtrElemStep_",
|
||||
# black boxes
|
||||
"CvArr", "CvFileStorage",
|
||||
# other
|
||||
@ -191,7 +191,7 @@ def process_module(module, path):
|
||||
hdrlist.append(os.path.join(root, filename))
|
||||
|
||||
if module == "gpu":
|
||||
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "devmem2d.hpp"))
|
||||
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "cuda_devptrs.hpp"))
|
||||
hdrlist.append(os.path.join(path, "..", "core", "include", "opencv2", "core", "gpumat.hpp"))
|
||||
|
||||
decls = []
|
||||
|
Binary file not shown.
@ -136,8 +136,6 @@ Additionally, we have to manually add framework dependencies of the opencv frame
|
||||
|
||||
* CoreVideo
|
||||
|
||||
* CoreAnimation
|
||||
|
||||
* QuartzCore
|
||||
|
||||
* UIKit
|
||||
@ -185,8 +183,7 @@ We follow the delegation pattern, which is very common in iOS, to provide access
|
||||
#endif
|
||||
|
||||
Note that we are using C++ here (cv::Mat).
|
||||
Important: You have to rename the view controller's extension .m into .mm, so that the compiler compiles it under the assumption of Objective-C++ (Objective-C and C++ mixed). Then, __cplusplus is defined when the compiler is processing the file for C++ code. Therefore, we put our code within a block where __cpluscplus is defined.
|
||||
|
||||
Important: You have to rename the view controller's extension .m into .mm, so that the compiler compiles it under the assumption of Objective-C++ (Objective-C and C++ mixed). Then, __cplusplus is defined when the compiler is processing the file for C++ code. Therefore, we put our code within a block where __cplusplus is defined.
|
||||
|
||||
|
||||
Basic video processing
|
||||
|
@ -5,7 +5,7 @@ ENDIF()
|
||||
set(the_description "Auxiliary module for Android native camera support")
|
||||
set(OPENCV_MODULE_TYPE STATIC)
|
||||
|
||||
ocv_define_module(androidcamera INTERNAL log dl)
|
||||
ocv_define_module(androidcamera INTERNAL opencv_core log dl)
|
||||
ocv_include_directories("${CMAKE_CURRENT_SOURCE_DIR}/camera_wrapper")
|
||||
|
||||
# Android source tree for native camera
|
||||
|
@ -6,24 +6,25 @@ link_directories("${ANDROID_SOURCE_TREE}/out/target/product/generic/system/lib")
|
||||
|
||||
if (ANDROID_VERSION VERSION_LESS "4.1")
|
||||
INCLUDE_DIRECTORIES(BEFORE
|
||||
${ANDROID_SOURCE_TREE}
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/ui
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/surfaceflinger
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/camera
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/media
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include
|
||||
${ANDROID_SOURCE_TREE}/system/core/include
|
||||
${ANDROID_SOURCE_TREE}/hardware/libhardware/include
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/native/include
|
||||
)
|
||||
${ANDROID_SOURCE_TREE}
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/ui
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/surfaceflinger
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/camera
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include/media
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/include
|
||||
${ANDROID_SOURCE_TREE}/system/core/include
|
||||
${ANDROID_SOURCE_TREE}/hardware/libhardware/include
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/native/include
|
||||
${ANDROID_SOURCE_TREE}/frameworks/base/opengl/include
|
||||
)
|
||||
else()
|
||||
INCLUDE_DIRECTORIES(BEFORE
|
||||
${ANDROID_SOURCE_TREE}
|
||||
${ANDROID_SOURCE_TREE}/frameworks/native/include
|
||||
${ANDROID_SOURCE_TREE}/frameworks/av/include
|
||||
${ANDROID_SOURCE_TREE}/system/core/include
|
||||
${ANDROID_SOURCE_TREE}/hardware/libhardware/include
|
||||
)
|
||||
${ANDROID_SOURCE_TREE}
|
||||
${ANDROID_SOURCE_TREE}/frameworks/native/include
|
||||
${ANDROID_SOURCE_TREE}/frameworks/av/include
|
||||
${ANDROID_SOURCE_TREE}/system/core/include
|
||||
${ANDROID_SOURCE_TREE}/hardware/libhardware/include
|
||||
)
|
||||
endif()
|
||||
|
||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)
|
||||
@ -33,8 +34,8 @@ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE}")
|
||||
SET(CMAKE_C_FLAGS_RELEASE "")
|
||||
SET(CMAKE_CXX_FLAGS_RELEASE "")
|
||||
|
||||
string(REPLACE "-O3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
|
||||
string(REPLACE "-O3" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
|
||||
string(REPLACE "-frtti" "-fno-rtti" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") # because Android libraries are built without rtti
|
||||
|
||||
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Os -fno-strict-aliasing -finline-limit=64 -fuse-cxa-atexit" )
|
||||
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Os -fno-strict-aliasing -finline-limit=64 -fuse-cxa-atexit")
|
||||
@ -58,7 +59,7 @@ SET_TARGET_PROPERTIES(${the_target} PROPERTIES
|
||||
)
|
||||
|
||||
if (NOT (CMAKE_BUILD_TYPE MATCHES "debug"))
|
||||
ADD_CUSTOM_COMMAND( TARGET ${the_target} POST_BUILD COMMAND ${CMAKE_STRIP} "${LIBRARY_OUTPUT_PATH}/lib${the_target}.so" )
|
||||
ADD_CUSTOM_COMMAND( TARGET ${the_target} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${LIBRARY_OUTPUT_PATH}/lib${the_target}.so" )
|
||||
endif()
|
||||
|
||||
|
||||
|
@ -1,8 +1,12 @@
|
||||
#include <dlfcn.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <dirent.h>
|
||||
#include <android/log.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <opencv2/core/version.hpp>
|
||||
#include "camera_activity.hpp"
|
||||
#include "camera_wrapper.h"
|
||||
|
||||
@ -41,6 +45,7 @@ private:
|
||||
static bool isConnectedToLib;
|
||||
|
||||
static std::string getPathLibFolder();
|
||||
static std::string getDefaultPathLibFolder();
|
||||
static CameraActivity::ErrorCode connectToLib();
|
||||
static CameraActivity::ErrorCode getSymbolFromLib(void * libHandle, const char* symbolName, void** ppSymbol);
|
||||
static void fillListWrapperLibs(const string& folderPath, vector<string>& listLibs);
|
||||
@ -55,10 +60,8 @@ private:
|
||||
};
|
||||
|
||||
std::string CameraWrapperConnector::pathLibFolder;
|
||||
#define DEFAULT_WRAPPER_PACKAGE_NAME "com.NativeCamera"
|
||||
#define DEFAULT_PATH_LIB_FOLDER "/data/data/" DEFAULT_WRAPPER_PACKAGE_NAME "/lib/"
|
||||
|
||||
bool CameraWrapperConnector::isConnectedToLib=false;
|
||||
bool CameraWrapperConnector::isConnectedToLib = false;
|
||||
InitCameraConnectC CameraWrapperConnector::pInitCameraC = 0;
|
||||
CloseCameraConnectC CameraWrapperConnector::pCloseCameraC = 0;
|
||||
GetCameraPropertyC CameraWrapperConnector::pGetPropertyC = 0;
|
||||
@ -163,7 +166,13 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib()
|
||||
}
|
||||
|
||||
dlerror();
|
||||
string folderPath=getPathLibFolder();
|
||||
string folderPath = getPathLibFolder();
|
||||
if (folderPath.empty())
|
||||
{
|
||||
LOGD("Trying to find native camera in default OpenCV packages");
|
||||
folderPath = getDefaultPathLibFolder();
|
||||
}
|
||||
|
||||
LOGD("CameraWrapperConnector::connectToLib: folderPath=%s", folderPath.c_str());
|
||||
|
||||
vector<string> listLibs;
|
||||
@ -209,7 +218,7 @@ CameraActivity::ErrorCode CameraWrapperConnector::connectToLib()
|
||||
|
||||
res = getSymbolFromLib(libHandle, SET_CAMERA_PROPERTY_SYMBOL_NAME, (void**)(&pSetProp_C));
|
||||
if (res) return res;
|
||||
\
|
||||
|
||||
res = getSymbolFromLib(libHandle, APPLY_CAMERA_PROPERTIES_SYMBOL_NAME, (void**)(&pApplyProp_C));
|
||||
if (res) return res;
|
||||
|
||||
@ -256,6 +265,31 @@ void CameraWrapperConnector::fillListWrapperLibs(const string& folderPath, vecto
|
||||
}
|
||||
}
|
||||
|
||||
std::string CameraWrapperConnector::getDefaultPathLibFolder()
|
||||
{
|
||||
const string packageList[] = {"tegra3", "armv7a_neon", "armv7a", "armv5", "x86"};
|
||||
for (size_t i = 0; i < 5; i++)
|
||||
{
|
||||
char path[128];
|
||||
sprintf(path, "/data/data/org.opencv.lib_v%d%d_%s/lib/", CV_MAJOR_VERSION, CV_MINOR_VERSION, packageList[i].c_str());
|
||||
LOGD("Trying package \"%s\" (\"%s\")", packageList[i].c_str(), path);
|
||||
|
||||
DIR* dir = opendir(path);
|
||||
if (!dir)
|
||||
{
|
||||
LOGD("Package not found");
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
closedir(dir);
|
||||
return path;
|
||||
}
|
||||
}
|
||||
|
||||
return string();
|
||||
}
|
||||
|
||||
std::string CameraWrapperConnector::getPathLibFolder()
|
||||
{
|
||||
if (!pathLibFolder.empty())
|
||||
@ -267,64 +301,64 @@ std::string CameraWrapperConnector::getPathLibFolder()
|
||||
LOGD("Library name: %s", dl_info.dli_fname);
|
||||
LOGD("Library base address: %p", dl_info.dli_fbase);
|
||||
|
||||
const char* libName=dl_info.dli_fname;
|
||||
while( ((*libName)=='/') || ((*libName)=='.') )
|
||||
libName++;
|
||||
const char* libName=dl_info.dli_fname;
|
||||
while( ((*libName)=='/') || ((*libName)=='.') )
|
||||
libName++;
|
||||
|
||||
char lineBuf[2048];
|
||||
FILE* file = fopen("/proc/self/smaps", "rt");
|
||||
|
||||
if(file)
|
||||
{
|
||||
while (fgets(lineBuf, sizeof lineBuf, file) != NULL)
|
||||
{
|
||||
//verify that line ends with library name
|
||||
int lineLength = strlen(lineBuf);
|
||||
int libNameLength = strlen(libName);
|
||||
while (fgets(lineBuf, sizeof lineBuf, file) != NULL)
|
||||
{
|
||||
//verify that line ends with library name
|
||||
int lineLength = strlen(lineBuf);
|
||||
int libNameLength = strlen(libName);
|
||||
|
||||
//trim end
|
||||
for(int i = lineLength - 1; i >= 0 && isspace(lineBuf[i]); --i)
|
||||
{
|
||||
lineBuf[i] = 0;
|
||||
--lineLength;
|
||||
}
|
||||
//trim end
|
||||
for(int i = lineLength - 1; i >= 0 && isspace(lineBuf[i]); --i)
|
||||
{
|
||||
lineBuf[i] = 0;
|
||||
--lineLength;
|
||||
}
|
||||
|
||||
if (0 != strncmp(lineBuf + lineLength - libNameLength, libName, libNameLength))
|
||||
{
|
||||
//the line does not contain the library name
|
||||
continue;
|
||||
}
|
||||
if (0 != strncmp(lineBuf + lineLength - libNameLength, libName, libNameLength))
|
||||
{
|
||||
//the line does not contain the library name
|
||||
continue;
|
||||
}
|
||||
|
||||
//extract path from smaps line
|
||||
char* pathBegin = strchr(lineBuf, '/');
|
||||
if (0 == pathBegin)
|
||||
{
|
||||
LOGE("Strange error: could not find path beginning in lin \"%s\"", lineBuf);
|
||||
continue;
|
||||
}
|
||||
//extract path from smaps line
|
||||
char* pathBegin = strchr(lineBuf, '/');
|
||||
if (0 == pathBegin)
|
||||
{
|
||||
LOGE("Strange error: could not find path beginning in lin \"%s\"", lineBuf);
|
||||
continue;
|
||||
}
|
||||
|
||||
char* pathEnd = strrchr(pathBegin, '/');
|
||||
pathEnd[1] = 0;
|
||||
char* pathEnd = strrchr(pathBegin, '/');
|
||||
pathEnd[1] = 0;
|
||||
|
||||
LOGD("Libraries folder found: %s", pathBegin);
|
||||
LOGD("Libraries folder found: %s", pathBegin);
|
||||
|
||||
fclose(file);
|
||||
return pathBegin;
|
||||
}
|
||||
fclose(file);
|
||||
LOGE("Could not find library path.");
|
||||
fclose(file);
|
||||
return pathBegin;
|
||||
}
|
||||
fclose(file);
|
||||
LOGE("Could not find library path");
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGE("Could not read /proc/self/smaps");
|
||||
LOGE("Could not read /proc/self/smaps");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGE("Could not get library name and base address.");
|
||||
LOGE("Could not get library name and base address");
|
||||
}
|
||||
|
||||
return DEFAULT_PATH_LIB_FOLDER ;
|
||||
return string();
|
||||
}
|
||||
|
||||
void CameraWrapperConnector::setPathLibFolder(const string& path)
|
||||
@ -387,19 +421,23 @@ void CameraActivity::applyProperties()
|
||||
frameWidth = -1;
|
||||
frameHeight = -1;
|
||||
CameraWrapperConnector::applyProperties(&camera);
|
||||
frameWidth = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEWIDTH);
|
||||
frameHeight = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT);
|
||||
}
|
||||
|
||||
int CameraActivity::getFrameWidth()
|
||||
{
|
||||
if (frameWidth < 0)
|
||||
frameWidth = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEWIDTH);
|
||||
LOGD("CameraActivity::getFrameWidth()");
|
||||
if (frameWidth <= 0)
|
||||
frameWidth = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEWIDTH);
|
||||
return frameWidth;
|
||||
}
|
||||
|
||||
int CameraActivity::getFrameHeight()
|
||||
{
|
||||
if (frameHeight < 0)
|
||||
frameHeight = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT);
|
||||
LOGD("CameraActivity::getFrameHeight()");
|
||||
if (frameHeight <= 0)
|
||||
frameHeight = getProperty(ANDROID_CAMERA_PROPERTY_FRAMEHEIGHT);
|
||||
return frameHeight;
|
||||
}
|
||||
|
||||
|
@ -19,19 +19,19 @@ a unified access to all face recongition algorithms in OpenCV. ::
|
||||
|
||||
// Trains a FaceRecognizer.
|
||||
virtual void train(InputArray src, InputArray labels) = 0;
|
||||
|
||||
|
||||
// Updates a FaceRecognizer.
|
||||
virtual void update(InputArrayOfArrays src, InputArray labels);
|
||||
|
||||
|
||||
// Gets a prediction from a FaceRecognizer.
|
||||
virtual int predict(InputArray src) const = 0;
|
||||
|
||||
|
||||
// Predicts the label and confidence for a given sample.
|
||||
virtual void predict(InputArray src, int &label, double &confidence) const = 0;
|
||||
|
||||
// Serializes this object to a given filename.
|
||||
virtual void save(const string& filename) const;
|
||||
|
||||
|
||||
// Deserializes this object from a given filename.
|
||||
virtual void load(const string& filename);
|
||||
|
||||
@ -58,7 +58,7 @@ I'll go a bit more into detail explaining :ocv:class:`FaceRecognizer`, because i
|
||||
|
||||
Moreover every :ocv:class:`FaceRecognizer` supports the:
|
||||
|
||||
* **Training** of a :ocv:class:`FaceRecognizer` with :ocv:func:`FaceRecognizer::train` on a given set of images (your face database!).
|
||||
* **Training** of a :ocv:class:`FaceRecognizer` with :ocv:func:`FaceRecognizer::train` on a given set of images (your face database!).
|
||||
|
||||
* **Prediction** of a given sample image, that means a face. The image is given as a :ocv:class:`Mat`.
|
||||
|
||||
@ -111,7 +111,7 @@ Since every :ocv:class:`FaceRecognizer` is a :ocv:class:`Algorithm`, you can use
|
||||
.. code-block:: cpp
|
||||
|
||||
// Create a FaceRecognizer:
|
||||
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
|
||||
Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
|
||||
// And here's how to get its name:
|
||||
std::string name = model->name();
|
||||
|
||||
@ -121,7 +121,7 @@ FaceRecognizer::train
|
||||
|
||||
Trains a FaceRecognizer with given data and associated labels.
|
||||
|
||||
.. ocv:function:: void FaceRecognizer::train(InputArray src, InputArray labels)
|
||||
.. ocv:function:: void FaceRecognizer::train( InputArrayOfArrays src, InputArray labels ) = 0
|
||||
|
||||
:param src: The training images, that means the faces you want to learn. The data has to be given as a ``vector<Mat>``.
|
||||
|
||||
@ -166,7 +166,7 @@ FaceRecognizer::update
|
||||
|
||||
Updates a FaceRecognizer with given data and associated labels.
|
||||
|
||||
.. ocv:function:: void FaceRecognizer::update(InputArray src, InputArray labels)
|
||||
.. ocv:function:: void FaceRecognizer::update( InputArrayOfArrays src, InputArray labels )
|
||||
|
||||
:param src: The training images, that means the faces you want to learn. The data has to be given as a ``vector<Mat>``.
|
||||
|
||||
@ -193,7 +193,7 @@ This method updates a (probably trained) :ocv:class:`FaceRecognizer`, but only i
|
||||
//
|
||||
// Now updating the model is as easy as calling:
|
||||
model->update(newImages,newLabels);
|
||||
// This will preserve the old model data and extend the existing model
|
||||
// This will preserve the old model data and extend the existing model
|
||||
// with the new features extracted from newImages!
|
||||
|
||||
Calling update on an Eigenfaces model (see :ocv:func:`createEigenFaceRecognizer`), which doesn't support updating, will throw an error similar to:
|
||||
@ -203,8 +203,8 @@ Calling update on an Eigenfaces model (see :ocv:func:`createEigenFaceRecognizer`
|
||||
OpenCV Error: The function/feature is not implemented (This FaceRecognizer (FaceRecognizer.Eigenfaces) does not support updating, you have to use FaceRecognizer::train to update it.) in update, file /home/philipp/git/opencv/modules/contrib/src/facerec.cpp, line 305
|
||||
terminate called after throwing an instance of 'cv::Exception'
|
||||
|
||||
Please note: The :ocv:class:`FaceRecognizer` does not store your training images, because this would be very memory intense and it's not the responsibility of te :ocv:class:`FaceRecognizer` to do so. The caller is responsible for maintaining the dataset, he want to work with.
|
||||
|
||||
Please note: The :ocv:class:`FaceRecognizer` does not store your training images, because this would be very memory intense and it's not the responsibility of te :ocv:class:`FaceRecognizer` to do so. The caller is responsible for maintaining the dataset, he want to work with.
|
||||
|
||||
FaceRecognizer::predict
|
||||
-----------------------
|
||||
|
||||
|
26
modules/contrib/doc/facerec/src/CMakeLists.txt
Normal file
26
modules/contrib/doc/facerec/src/CMakeLists.txt
Normal file
@ -0,0 +1,26 @@
|
||||
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
|
||||
|
||||
set(name "facerec")
|
||||
project(facerec_cpp_samples)
|
||||
|
||||
#SET(OpenCV_DIR /path/to/your/opencv/installation)
|
||||
|
||||
# packages
|
||||
find_package(OpenCV REQUIRED) # http://opencv.willowgarage.com
|
||||
|
||||
# probably you should loop through the sample files here
|
||||
add_executable(facerec_demo facerec_demo.cpp)
|
||||
target_link_libraries(facerec_demo opencv_core opencv_contrib opencv_imgproc opencv_highgui)
|
||||
|
||||
add_executable(facerec_video facerec_video.cpp)
|
||||
target_link_libraries(facerec_video opencv_contrib opencv_core opencv_imgproc opencv_highgui opencv_objdetect opencv_imgproc)
|
||||
|
||||
add_executable(facerec_eigenfaces facerec_eigenfaces.cpp)
|
||||
target_link_libraries(facerec_eigenfaces opencv_contrib opencv_core opencv_imgproc opencv_highgui)
|
||||
|
||||
add_executable(facerec_fisherfaces facerec_fisherfaces.cpp)
|
||||
target_link_libraries(facerec_fisherfaces opencv_contrib opencv_core opencv_imgproc opencv_highgui)
|
||||
|
||||
add_executable(facerec_lbph facerec_lbph.cpp)
|
||||
target_link_libraries(facerec_lbph opencv_contrib opencv_core opencv_imgproc opencv_highgui)
|
||||
|
@ -14,7 +14,7 @@ Class which provides the main controls to the Gipsa/Listic labs human retina mo
|
||||
|
||||
* periphearal vision for sensitive transient signals detection (motion and events) : the magnocellular pathway.
|
||||
|
||||
The retina can be settled up with various parameters, by default, the retina cancels mean luminance and enforces all details of the visual scene. In order to use your own parameters, you can use at least one time the *write(std::string fs)* method which will write a proper XML file with all default parameters. Then, tweak it on your own and reload them at any time using method *setup(std::string fs)*. These methods update a *cv::Retina::RetinaParameters* member structure that is described hereafter. ::
|
||||
The retina can be settled up with various parameters, by default, the retina cancels mean luminance and enforces all details of the visual scene. In order to use your own parameters, you can use at least one time the *write(std::string fs)* method which will write a proper XML file with all default parameters. Then, tweak it on your own and reload them at any time using method *setup(std::string fs)*. These methods update a *Retina::RetinaParameters* member structure that is described hereafter. ::
|
||||
|
||||
class Retina
|
||||
{
|
||||
@ -25,7 +25,7 @@ The retina can be settled up with various parameters, by default, the retina can
|
||||
// constructors
|
||||
Retina (Size inputSize);
|
||||
Retina (Size inputSize, const bool colorMode, RETINA_COLORSAMPLINGMETHOD colorSamplingMethod=RETINA_COLOR_BAYER, const bool useRetinaLogSampling=false, const double reductionFactor=1.0, const double samplingStrenght=10.0);
|
||||
|
||||
|
||||
// main method for input frame processing
|
||||
void run (const Mat &inputImage);
|
||||
|
||||
@ -38,22 +38,22 @@ The retina can be settled up with various parameters, by default, the retina can
|
||||
void getMagno (Mat &retinaOutput_magno);
|
||||
void getMagno (std::valarray< float > &retinaOutput_magno);
|
||||
const std::valarray< float > & getMagno () const;
|
||||
|
||||
|
||||
// reset retina buffers... equivalent to closing your eyes for some seconds
|
||||
void clearBuffers ();
|
||||
|
||||
|
||||
// retreive input and output buffers sizes
|
||||
Size inputSize ();
|
||||
Size outputSize ();
|
||||
|
||||
|
||||
// setup methods with specific parameters specification of global xml config file loading/write
|
||||
void setup (std::string retinaParameterFile="", const bool applyDefaultSetupOnFailure=true);
|
||||
void setup (cv::FileStorage &fs, const bool applyDefaultSetupOnFailure=true);
|
||||
void setup (FileStorage &fs, const bool applyDefaultSetupOnFailure=true);
|
||||
void setup (RetinaParameters newParameters);
|
||||
struct Retina::RetinaParameters getParameters ();
|
||||
const std::string printSetup ();
|
||||
virtual void write (std::string fs) const;
|
||||
virtual void write (FileStorage &fs) const;
|
||||
virtual void write (FileStorage &fs) const;
|
||||
void setupOPLandIPLParvoChannel (const bool colorMode=true, const bool normaliseOutput=true, const float photoreceptorsLocalAdaptationSensitivity=0.7, const float photoreceptorsTemporalConstant=0.5, const float photoreceptorsSpatialConstant=0.53, const float horizontalCellsGain=0, const float HcellsTemporalConstant=1, const float HcellsSpatialConstant=7, const float ganglionCellsSensitivity=0.7);
|
||||
void setupIPLMagnoChannel (const bool normaliseOutput=true, const float parasolCells_beta=0, const float parasolCells_tau=0, const float parasolCells_k=7, const float amacrinCellsTemporalCutFrequency=1.2, const float V0CompressionParameter=0.95, const float localAdaptintegration_tau=0, const float localAdaptintegration_k=7);
|
||||
void setColorSaturation (const bool saturateColors=true, const float colorSaturationValue=4.0);
|
||||
@ -75,13 +75,13 @@ Class which allows the `Gipsa <http://www.gipsa-lab.inpg.fr>`_ (preliminary work
|
||||
|
||||
* local logarithmic luminance compression allows details to be enhanced even in low light conditions
|
||||
|
||||
Use : this model can be used basically for spatio-temporal video effects but also in the aim of :
|
||||
Use : this model can be used basically for spatio-temporal video effects but also in the aim of :
|
||||
|
||||
* performing texture analysis with enhanced signal to noise ratio and enhanced details robust against input images luminance ranges (check out the parvocellular retina channel output, by using the provided **getParvo** methods)
|
||||
|
||||
* performing motion analysis also taking benefit of the previously cited properties (check out the magnocellular retina channel output, by using the provided **getMagno** methods)
|
||||
|
||||
For more information, refer to the following papers :
|
||||
For more information, refer to the following papers :
|
||||
|
||||
* Benoit A., Caplier A., Durette B., Herault, J., "Using Human Visual System Modeling For Bio-Inspired Low Level Image Processing", Elsevier, Computer Vision and Image Understanding 114 (2010), pp. 758-773. DOI <http://dx.doi.org/10.1016/j.cviu.2010.01.011>
|
||||
|
||||
@ -100,7 +100,7 @@ Demos and experiments !
|
||||
|
||||
Take a look at the C++ examples provided with OpenCV :
|
||||
|
||||
* **samples/cpp/retinademo.cpp** shows how to use the retina module for details enhancement (Parvo channel output) and transient maps observation (Magno channel output). You can play with images, video sequences and webcam video.
|
||||
* **samples/cpp/retinademo.cpp** shows how to use the retina module for details enhancement (Parvo channel output) and transient maps observation (Magno channel output). You can play with images, video sequences and webcam video.
|
||||
Typical uses are (provided your OpenCV installation is situated in folder *OpenCVReleaseFolder*)
|
||||
|
||||
* image processing : **OpenCVReleaseFolder/bin/retinademo -image myPicture.jpg**
|
||||
@ -110,7 +110,7 @@ Take a look at the C++ examples provided with OpenCV :
|
||||
* webcam processing: **OpenCVReleaseFolder/bin/retinademo -video**
|
||||
|
||||
**Note :** This demo generates the file *RetinaDefaultParameters.xml* which contains the default parameters of the retina. Then, rename this as *RetinaSpecificParameters.xml*, adjust the parameters the way you want and reload the program to check the effect.
|
||||
|
||||
|
||||
|
||||
* **samples/cpp/OpenEXRimages_HighDynamicRange_Retina_toneMapping.cpp** shows how to use the retina to perform High Dynamic Range (HDR) luminance compression
|
||||
|
||||
@ -119,13 +119,13 @@ Take a look at the C++ examples provided with OpenCV :
|
||||
Typical use, supposing that you have the OpenEXR image *memorial.exr* (present in the samples/cpp/ folder)
|
||||
|
||||
**OpenCVReleaseFolder/bin/OpenEXRimages_HighDynamicRange_Retina_toneMapping memorial.exr**
|
||||
|
||||
|
||||
Note that some sliders are made available to allow you to play with luminance compression.
|
||||
|
||||
Methods description
|
||||
===================
|
||||
|
||||
Here are detailled the main methods to control the retina model
|
||||
Here are detailled the main methods to control the retina model
|
||||
|
||||
Retina::Retina
|
||||
++++++++++++++
|
||||
@ -148,7 +148,7 @@ Retina::Retina
|
||||
Retina::activateContoursProcessing
|
||||
++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::activateContoursProcessing(const bool activate)
|
||||
.. ocv:function:: void Retina::activateContoursProcessing(const bool activate)
|
||||
|
||||
Activate/desactivate the Parvocellular pathway processing (contours information extraction), by default, it is activated
|
||||
|
||||
@ -157,7 +157,7 @@ Retina::activateContoursProcessing
|
||||
Retina::activateMovingContoursProcessing
|
||||
++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::activateMovingContoursProcessing(const bool activate)
|
||||
.. ocv:function:: void Retina::activateMovingContoursProcessing(const bool activate)
|
||||
|
||||
Activate/desactivate the Magnocellular pathway processing (motion information extraction), by default, it is activated
|
||||
|
||||
@ -166,42 +166,44 @@ Retina::activateMovingContoursProcessing
|
||||
Retina::clearBuffers
|
||||
++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::clearBuffers()
|
||||
.. ocv:function:: void Retina::clearBuffers()
|
||||
|
||||
Clears all retina buffers (equivalent to opening the eyes after a long period of eye close ;o) whatchout the temporal transition occuring just after this method call.
|
||||
|
||||
Retina::getParvo
|
||||
++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::getParvo(Mat & retinaOutput_parvo)
|
||||
.. ocv:function:: void cv::Retina::getParvo(std::valarray< float > & retinaOutput_parvo )
|
||||
.. ocv:function:: void Retina::getParvo( Mat & retinaOutput_parvo )
|
||||
.. ocv:function:: void Retina::getParvo( std::valarray<float> & retinaOutput_parvo )
|
||||
.. ocv:function:: const std::valarray<float> & Retina::getParvo() const
|
||||
|
||||
Accessor of the details channel of the retina (models foveal vision)
|
||||
|
||||
:param retinaOutput_parvo: the output buffer (reallocated if necessary), format can be :
|
||||
|
||||
* a cv::Mat, this output is rescaled for standard 8bits image processing use in OpenCV
|
||||
|
||||
|
||||
* a Mat, this output is rescaled for standard 8bits image processing use in OpenCV
|
||||
|
||||
* a 1D std::valarray Buffer (encoding is R1, R2, ... Rn), this output is the original retina filter model output, without any quantification or rescaling
|
||||
|
||||
Retina::getMagno
|
||||
++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::getMagno(Mat & retinaOutput_magno)
|
||||
.. ocv:function:: void cv::Retina::getMagno(std::valarray< float > & retinaOutput_magno)
|
||||
.. ocv:function:: void Retina::getMagno( Mat & retinaOutput_magno )
|
||||
.. ocv:function:: void Retina::getMagno( std::valarray<float> & retinaOutput_magno )
|
||||
.. ocv:function:: const std::valarray<float> & Retina::getMagno() const
|
||||
|
||||
Accessor of the motion channel of the retina (models peripheral vision)
|
||||
|
||||
:param retinaOutput_magno: the output buffer (reallocated if necessary), format can be :
|
||||
|
||||
* a cv::Mat, this output is rescaled for standard 8bits image processing use in OpenCV
|
||||
|
||||
|
||||
* a Mat, this output is rescaled for standard 8bits image processing use in OpenCV
|
||||
|
||||
* a 1D std::valarray Buffer (encoding is R1, R2, ... Rn), this output is the original retina filter model output, without any quantification or rescaling
|
||||
|
||||
Retina::getParameters
|
||||
+++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: struct Retina::RetinaParameters cv::Retina::getParameters()
|
||||
.. ocv:function:: struct Retina::RetinaParameters Retina::getParameters()
|
||||
|
||||
Retrieve the current parameters values in a *Retina::RetinaParameters* structure
|
||||
|
||||
@ -210,7 +212,7 @@ Retina::getParameters
|
||||
Retina::inputSize
|
||||
+++++++++++++++++
|
||||
|
||||
.. ocv:function:: Size cv::Retina::inputSize()
|
||||
.. ocv:function:: Size Retina::inputSize()
|
||||
|
||||
Retreive retina input buffer size
|
||||
|
||||
@ -219,16 +221,16 @@ Retina::inputSize
|
||||
Retina::outputSize
|
||||
++++++++++++++++++
|
||||
|
||||
.. ocv:function:: Size cv::Retina::outputSize()
|
||||
.. ocv:function:: Size Retina::outputSize()
|
||||
|
||||
Retreive retina output buffer size that can be different from the input if a spatial log transformation is applied
|
||||
Retreive retina output buffer size that can be different from the input if a spatial log transformation is applied
|
||||
|
||||
:return: the retina output buffer size
|
||||
|
||||
Retina::printSetup
|
||||
++++++++++++++++++
|
||||
|
||||
.. ocv:function:: const std::string cv::Retina::printSetup()
|
||||
.. ocv:function:: const std::string Retina::printSetup()
|
||||
|
||||
Outputs a string showing the used parameters setup
|
||||
|
||||
@ -237,16 +239,16 @@ Retina::printSetup
|
||||
Retina::run
|
||||
+++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::run(const Mat & inputImage)
|
||||
.. ocv:function:: void Retina::run(const Mat & inputImage)
|
||||
|
||||
Method which allows retina to be applied on an input image, after run, encapsulated retina module is ready to deliver its outputs using dedicated acccessors, see getParvo and getMagno methods
|
||||
|
||||
:param inputImage: the input cv::Mat image to be processed, can be gray level or BGR coded in any format (from 8bit to 16bits)
|
||||
:param inputImage: the input Mat image to be processed, can be gray level or BGR coded in any format (from 8bit to 16bits)
|
||||
|
||||
Retina::setColorSaturation
|
||||
++++++++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::setColorSaturation(const bool saturateColors = true, const float colorSaturationValue = 4.0 )
|
||||
.. ocv:function:: void Retina::setColorSaturation(const bool saturateColors = true, const float colorSaturationValue = 4.0 )
|
||||
|
||||
Activate color saturation as the final step of the color demultiplexing process -> this saturation is a sigmoide function applied to each channel of the demultiplexed image.
|
||||
|
||||
@ -257,9 +259,9 @@ Retina::setColorSaturation
|
||||
Retina::setup
|
||||
+++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::setup(std::string retinaParameterFile = "", const bool applyDefaultSetupOnFailure = true )
|
||||
.. ocv:function:: void cv::Retina::setup(cv::FileStorage & fs, const bool applyDefaultSetupOnFailure = true )
|
||||
.. ocv:function:: void cv::Retina::setup(RetinaParameters newParameters)
|
||||
.. ocv:function:: void Retina::setup(std::string retinaParameterFile = "", const bool applyDefaultSetupOnFailure = true )
|
||||
.. ocv:function:: void Retina::setup(FileStorage & fs, const bool applyDefaultSetupOnFailure = true )
|
||||
.. ocv:function:: void Retina::setup(RetinaParameters newParameters)
|
||||
|
||||
Try to open an XML retina parameters file to adjust current retina instance setup => if the xml file does not exist, then default setup is applied => warning, Exceptions are thrown if read XML file is not valid
|
||||
|
||||
@ -271,8 +273,8 @@ Retina::setup
|
||||
Retina::write
|
||||
+++++++++++++
|
||||
|
||||
.. ocv:function:: virtual void cv::Retina::write(std::string fs) const
|
||||
.. ocv:function:: virtual void cv::Retina::write(FileStorage & fs) const
|
||||
.. ocv:function:: void Retina::write( std::string fs ) const
|
||||
.. ocv:function:: void Retina::write( FileStorage& fs ) const
|
||||
|
||||
Write xml/yml formated parameters information
|
||||
|
||||
@ -281,7 +283,7 @@ Retina::write
|
||||
Retina::setupIPLMagnoChannel
|
||||
++++++++++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta = 0, const float parasolCells_tau = 0, const float parasolCells_k = 7, const float amacrinCellsTemporalCutFrequency = 1.2, const float V0CompressionParameter = 0.95, const float localAdaptintegration_tau = 0, const float localAdaptintegration_k = 7 )
|
||||
.. ocv:function:: void Retina::setupIPLMagnoChannel(const bool normaliseOutput = true, const float parasolCells_beta = 0, const float parasolCells_tau = 0, const float parasolCells_k = 7, const float amacrinCellsTemporalCutFrequency = 1.2, const float V0CompressionParameter = 0.95, const float localAdaptintegration_tau = 0, const float localAdaptintegration_k = 7 )
|
||||
|
||||
Set parameters values for the Inner Plexiform Layer (IPL) magnocellular channel this channel processes signals output from OPL processing stage in peripheral vision, it allows motion information enhancement. It is decorrelated from the details channel. See reference papers for more details.
|
||||
|
||||
@ -297,7 +299,7 @@ Retina::setupIPLMagnoChannel
|
||||
Retina::setupOPLandIPLParvoChannel
|
||||
++++++++++++++++++++++++++++++++++
|
||||
|
||||
.. ocv:function:: void cv::Retina::setupOPLandIPLParvoChannel(const bool colorMode = true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity = 0.7, const float photoreceptorsTemporalConstant = 0.5, const float photoreceptorsSpatialConstant = 0.53, const float horizontalCellsGain = 0, const float HcellsTemporalConstant = 1, const float HcellsSpatialConstant = 7, const float ganglionCellsSensitivity = 0.7 )
|
||||
.. ocv:function:: void Retina::setupOPLandIPLParvoChannel(const bool colorMode = true, const bool normaliseOutput = true, const float photoreceptorsLocalAdaptationSensitivity = 0.7, const float photoreceptorsTemporalConstant = 0.5, const float photoreceptorsSpatialConstant = 0.53, const float horizontalCellsGain = 0, const float HcellsTemporalConstant = 1, const float HcellsSpatialConstant = 7, const float ganglionCellsSensitivity = 0.7 )
|
||||
|
||||
Setup the OPL and IPL parvo channels (see biologocal model) OPL is referred as Outer Plexiform Layer of the retina, it allows the spatio-temporal filtering which withens the spectrum and reduces spatio-temporal noise while attenuating global luminance (low frequency energy) IPL parvo is the OPL next processing stage, it refers to a part of the Inner Plexiform layer of the retina, it allows high contours sensitivity in foveal vision. See reference papers for more informations.
|
||||
|
||||
@ -315,12 +317,12 @@ Retina::setupOPLandIPLParvoChannel
|
||||
Retina::RetinaParameters
|
||||
========================
|
||||
|
||||
.. ocv:class:: RetinaParameters
|
||||
This structure merges all the parameters that can be adjusted threw the **cv::Retina::setup()**, **cv::Retina::setupOPLandIPLParvoChannel** and **cv::Retina::setupIPLMagnoChannel** setup methods
|
||||
.. ocv:struct:: Retina::RetinaParameters
|
||||
This structure merges all the parameters that can be adjusted threw the **Retina::setup()**, **Retina::setupOPLandIPLParvoChannel** and **Retina::setupIPLMagnoChannel** setup methods
|
||||
Parameters structure for better clarity, check explenations on the comments of methods : setupOPLandIPLParvoChannel and setupIPLMagnoChannel. ::
|
||||
|
||||
class RetinaParameters{
|
||||
struct OPLandIplParvoParameters{ // Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
|
||||
class RetinaParameters{
|
||||
struct OPLandIplParvoParameters{ // Outer Plexiform Layer (OPL) and Inner Plexiform Layer Parvocellular (IplParvo) parameters
|
||||
OPLandIplParvoParameters():colorMode(true),
|
||||
normaliseOutput(true), // specifies if (true) output is rescaled between 0 and 255 of not (false)
|
||||
photoreceptorsLocalAdaptationSensitivity(0.7f), // the photoreceptors sensitivity renage is 0-1 (more log compression effect when value increases)
|
||||
|
@ -222,7 +222,7 @@ protected:
|
||||
void getLikelihoods(const Mat& queryImgDescriptor, const vector<
|
||||
Mat>& testImgDescriptors, vector<IMatch>& matches);
|
||||
|
||||
//procomputed data
|
||||
//precomputed data
|
||||
int (*table)[8];
|
||||
|
||||
//data precision
|
||||
|
@ -345,6 +345,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
|
||||
Mat labels = _local_labels.getMat();
|
||||
// observations in row
|
||||
Mat data = asRowMatrix(_src, CV_64FC1);
|
||||
|
||||
// number of samples
|
||||
int n = data.rows;
|
||||
// assert there are as much samples as labels
|
||||
@ -358,6 +359,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
|
||||
// clip number of components to be valid
|
||||
if((_num_components <= 0) || (_num_components > n))
|
||||
_num_components = n;
|
||||
|
||||
// perform the PCA
|
||||
PCA pca(data, Mat(), CV_PCA_DATA_AS_ROW, _num_components);
|
||||
// copy the PCA results
|
||||
@ -365,7 +367,7 @@ void Eigenfaces::train(InputArrayOfArrays _src, InputArray _local_labels) {
|
||||
_eigenvalues = pca.eigenvalues.clone(); // eigenvalues by row
|
||||
transpose(pca.eigenvectors, _eigenvectors); // eigenvectors by column
|
||||
// store labels for prediction
|
||||
labels.copyTo(_labels);
|
||||
_labels = labels.clone();
|
||||
// save projections
|
||||
for(int sampleIdx = 0; sampleIdx < data.rows; sampleIdx++) {
|
||||
Mat p = subspaceProject(_eigenvectors, _mean, data.row(sampleIdx));
|
||||
@ -481,7 +483,7 @@ void Fisherfaces::train(InputArrayOfArrays src, InputArray _lbls) {
|
||||
// store the total mean vector
|
||||
_mean = pca.mean.reshape(1,1);
|
||||
// store labels
|
||||
labels.copyTo(_labels);
|
||||
_labels = labels.clone();
|
||||
// store the eigenvalues of the discriminants
|
||||
lda.eigenvalues().convertTo(_eigenvalues, CV_64FC1);
|
||||
// Now calculate the projection matrix as pca.eigenvectors * lda.eigenvectors.
|
||||
|
101
modules/core/doc/command_line_parser.rst
Normal file
101
modules/core/doc/command_line_parser.rst
Normal file
@ -0,0 +1,101 @@
|
||||
Command Line Parser
|
||||
===================
|
||||
|
||||
.. highlight:: cpp
|
||||
|
||||
CommandLineParser
|
||||
--------
|
||||
.. ocv:class:: CommandLineParser
|
||||
|
||||
The CommandLineParser class is designed for command line arguments parsing
|
||||
|
||||
|
||||
.. ocv:function:: CommandLineParser::CommandLineParser(int argc, const char * const argv[], const std::string keys)
|
||||
|
||||
:param argc:
|
||||
:param argv:
|
||||
:param keys:
|
||||
|
||||
.. ocv:function:: T CommandLineParser::get<T>(const std::string& name, bool space_delete = true)
|
||||
|
||||
:param name:
|
||||
:param space_delete:
|
||||
|
||||
.. ocv:function:: T CommandLineParser::get<T>(int index, bool space_delete = true)
|
||||
|
||||
:param index:
|
||||
:param space_delete:
|
||||
|
||||
.. ocv:function:: bool CommandLineParser::has(const std::string& name)
|
||||
|
||||
:param name:
|
||||
|
||||
.. ocv:function:: bool CommandLineParser::check()
|
||||
|
||||
|
||||
.. ocv:function:: void CommandLineParser::about(std::string message)
|
||||
|
||||
:param message:
|
||||
|
||||
.. ocv:function:: void CommandLineParser::printMessage()
|
||||
|
||||
.. ocv:function:: void CommandLineParser::printErrors()
|
||||
|
||||
.. ocv:function:: std::string CommandLineParser::getPathToApplication()
|
||||
|
||||
|
||||
The sample below demonstrates how to use CommandLineParser:
|
||||
|
||||
::
|
||||
|
||||
CommandLineParser parser(argc, argv, keys);
|
||||
parser.about("Application name v1.0.0");
|
||||
|
||||
if (parser.has("help"))
|
||||
{
|
||||
parser.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int N = parser.get<int>("N");
|
||||
double fps = parser.get<double>("fps");
|
||||
std::string path = parser.get<std::string>("path");
|
||||
|
||||
use_time_stamp = parser.has("timestamp");
|
||||
|
||||
std::string img1 = parser.get<string>(0);
|
||||
std::string img2 = parser.get<string>(1);
|
||||
|
||||
int repeat = parser.get<int>(2);
|
||||
|
||||
if (!parser.check())
|
||||
{
|
||||
parser.printErrors();
|
||||
return 0;
|
||||
}
|
||||
|
||||
Syntax:
|
||||
|
||||
::
|
||||
|
||||
const std::string keys =
|
||||
"{help h usage ? | | print this message }"
|
||||
"{@image1 | | image1 for compare }"
|
||||
"{@image2 | | image2 for compare }"
|
||||
"{@repeat |1 | number }"
|
||||
"{path |. | path to file }"
|
||||
"{fps | -1.0 | fps for output video }"
|
||||
"{N count |100 | count of objects }"
|
||||
"{ts timestamp | | use time stamp }"
|
||||
;
|
||||
|
||||
Use:
|
||||
|
||||
::
|
||||
|
||||
# ./app -N=200 1.png 2.jpg 19 -ts
|
||||
|
||||
# ./app -fps=aaa
|
||||
ERRORS:
|
||||
Exception: can not convert: [aaa] to [double]
|
||||
|
@ -6,6 +6,7 @@ core. The Core Functionality
|
||||
:maxdepth: 2
|
||||
|
||||
basic_structures
|
||||
command_line_parser
|
||||
old_basic_structures
|
||||
dynamic_structures
|
||||
operations_on_arrays
|
||||
|
@ -384,6 +384,7 @@ Class for iterating pixels on a raster line. ::
|
||||
// move the iterator to the next pixel
|
||||
LineIterator& operator ++();
|
||||
LineIterator operator ++(int);
|
||||
Point pos() const;
|
||||
|
||||
// internal state of the iterator
|
||||
uchar* ptr;
|
||||
@ -394,16 +395,23 @@ Class for iterating pixels on a raster line. ::
|
||||
|
||||
The class ``LineIterator`` is used to get each pixel of a raster line. It can be treated as versatile implementation of the Bresenham algorithm where you can stop at each pixel and do some extra processing, for example, grab pixel values along the line or draw a line with an effect (for example, with XOR operation).
|
||||
|
||||
The number of pixels along the line is stored in ``LineIterator::count`` . ::
|
||||
The number of pixels along the line is stored in ``LineIterator::count`` . The method ``LineIterator::pos`` returns the current position in the image ::
|
||||
|
||||
// grabs pixels along the line (pt1, pt2)
|
||||
// from 8-bit 3-channel image to the buffer
|
||||
LineIterator it(img, pt1, pt2, 8);
|
||||
LineIterator it2 = it;
|
||||
vector<Vec3b> buf(it.count);
|
||||
|
||||
for(int i = 0; i < it.count; i++, ++it)
|
||||
buf[i] = *(const Vec3b)*it;
|
||||
|
||||
|
||||
// alternative way of iterating through the line
|
||||
for(int i = 0; i < it2.count; i++, ++it2)
|
||||
{
|
||||
Vec3b val = img.at<Vec3b>(it2.pos());
|
||||
CV_Assert(buf[i] == val);
|
||||
}
|
||||
|
||||
|
||||
rectangle
|
||||
|
@ -826,7 +826,7 @@ Returns one of array diagonals.
|
||||
The function returns the header, corresponding to a specified diagonal of the input array.
|
||||
|
||||
GetDims
|
||||
---------
|
||||
-------
|
||||
Return number of array dimensions
|
||||
|
||||
.. ocv:cfunction:: int cvGetDims(const CvArr* arr, int* sizes=NULL)
|
||||
@ -847,7 +847,7 @@ The function returns the array dimensionality and the array of dimension sizes.
|
||||
total *= sizes[i];
|
||||
|
||||
GetDimSize
|
||||
------------
|
||||
----------
|
||||
Returns array size along the specified dimension.
|
||||
|
||||
.. ocv:cfunction:: int cvGetDimSize(const CvArr* arr, int index)
|
||||
|
@ -406,8 +406,6 @@ Calculates the covariance matrix of a set of vectors.
|
||||
|
||||
:param ctype: type of the matrixl; it equals 'CV_64F' by default.
|
||||
|
||||
:param cov_mat: output covariance matrix (specific to C syntax).
|
||||
|
||||
:param mean: input or output (depending on the flags) array as the average value of the input vectors.
|
||||
|
||||
:param vects: a set of vectors.
|
||||
@ -545,8 +543,6 @@ Performs the per-element comparison of two arrays or an array and scalar value.
|
||||
* **CMP_LE** ``src1`` is less than or equal to ``src2``.
|
||||
* **CMP_NE** ``src1`` is unequal to ``src2``.
|
||||
|
||||
:param cmp_op: a flag, that specifies correspondence between the arrays (specific to C syntax; for possible values see 'cmpop above).
|
||||
|
||||
The function compares:
|
||||
|
||||
|
||||
@ -1004,7 +1000,7 @@ All of the above improvements have been implemented in :ocv:func:`matchTemplate`
|
||||
|
||||
|
||||
divide
|
||||
----------
|
||||
------
|
||||
Performs per-element division of two arrays or a scalar by an array.
|
||||
|
||||
.. ocv:function:: void divide(InputArray src1, InputArray src2, OutputArray dst, double scale=1, int dtype=-1)
|
||||
@ -1164,7 +1160,7 @@ To extract a channel from a new-style matrix, use
|
||||
|
||||
|
||||
insertImageCOI
|
||||
---------------
|
||||
--------------
|
||||
Copies the selected image channel from a new-style C++ matrix to the old-style C array.
|
||||
|
||||
.. ocv:function:: void insertImageCOI( InputArray coiimg, CvArr* arr, int coi=-1 )
|
||||
@ -1196,7 +1192,7 @@ To insert a channel to a new-style matrix, use
|
||||
|
||||
|
||||
flip
|
||||
--------
|
||||
----
|
||||
Flips a 2D array around vertical, horizontal, or both axes.
|
||||
|
||||
.. ocv:function:: void flip(InputArray src, OutputArray dst, int flipCode)
|
||||
@ -2267,7 +2263,7 @@ The sample below is the function that takes two matrices. The first function sto
|
||||
|
||||
|
||||
PCA::PCA
|
||||
------------
|
||||
--------
|
||||
PCA constructors
|
||||
|
||||
.. ocv:function:: PCA::PCA()
|
||||
@ -2535,7 +2531,7 @@ http://en.wikipedia.org/wiki/Ziggurat_algorithm
|
||||
|
||||
|
||||
RNG::RNG
|
||||
------------
|
||||
--------
|
||||
The constructors
|
||||
|
||||
.. ocv:function:: RNG::RNG()
|
||||
@ -2549,7 +2545,7 @@ These are the RNG constructors. The first form sets the state to some pre-define
|
||||
|
||||
|
||||
RNG::next
|
||||
-------------
|
||||
---------
|
||||
Returns the next random number.
|
||||
|
||||
.. ocv:function:: unsigned RNG::next()
|
||||
@ -2583,7 +2579,7 @@ Each of the methods updates the state using the MWC algorithm and returns the ne
|
||||
|
||||
|
||||
RNG::operator ()
|
||||
--------------------
|
||||
----------------
|
||||
Returns the next random number.
|
||||
|
||||
.. ocv:function:: unsigned RNG::operator ()()
|
||||
@ -2598,7 +2594,7 @@ The methods transform the state using the MWC algorithm and return the next rand
|
||||
|
||||
|
||||
RNG::uniform
|
||||
----------------
|
||||
------------
|
||||
Returns the next random number sampled from the uniform distribution.
|
||||
|
||||
.. ocv:function:: int RNG::uniform(int a, int b)
|
||||
@ -2637,7 +2633,7 @@ The compiler does not take into account the type of the variable to which you as
|
||||
|
||||
|
||||
RNG::gaussian
|
||||
-----------------
|
||||
-------------
|
||||
Returns the next random number sampled from the Gaussian distribution.
|
||||
|
||||
.. ocv:function:: double RNG::gaussian(double sigma)
|
||||
@ -2649,7 +2645,7 @@ The method transforms the state using the MWC algorithm and returns the next ran
|
||||
|
||||
|
||||
RNG::fill
|
||||
-------------
|
||||
---------
|
||||
Fills arrays with random numbers.
|
||||
|
||||
.. ocv:function:: void RNG::fill( InputOutputArray mat, int distType, InputArray a, InputArray b, bool saturateRange=false )
|
||||
@ -2952,7 +2948,7 @@ If ``DECOMP_LU`` or ``DECOMP_CHOLESKY`` method is used, the function returns 1 i
|
||||
|
||||
|
||||
solveCubic
|
||||
--------------
|
||||
----------
|
||||
Finds the real roots of a cubic equation.
|
||||
|
||||
.. ocv:function:: int solveCubic( InputArray coeffs, OutputArray roots )
|
||||
|
@ -221,7 +221,7 @@ CV_EXPORTS void setNumThreads(int nthreads);
|
||||
CV_EXPORTS int getNumThreads();
|
||||
CV_EXPORTS int getThreadNum();
|
||||
|
||||
CV_EXPORTS_W const std::string& getBuildInformation();
|
||||
CV_EXPORTS_W const string& getBuildInformation();
|
||||
|
||||
//! Returns the number of ticks.
|
||||
|
||||
@ -4434,7 +4434,7 @@ protected:
|
||||
|
||||
struct CV_EXPORTS Param
|
||||
{
|
||||
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6 };
|
||||
enum { INT=0, BOOLEAN=1, REAL=2, STRING=3, MAT=4, MAT_VECTOR=5, ALGORITHM=6, FLOAT=7, UNSIGNED_INT=8, UINT64=9 };
|
||||
|
||||
Param();
|
||||
Param(int _type, bool _readonly, int _offset,
|
||||
@ -4505,113 +4505,74 @@ template<> struct ParamType<Algorithm>
|
||||
enum { type = Param::ALGORITHM };
|
||||
};
|
||||
|
||||
template<> struct ParamType<float>
|
||||
{
|
||||
typedef float const_param_type;
|
||||
typedef float member_type;
|
||||
|
||||
enum { type = Param::FLOAT };
|
||||
};
|
||||
|
||||
template<> struct ParamType<unsigned>
|
||||
{
|
||||
typedef unsigned const_param_type;
|
||||
typedef unsigned member_type;
|
||||
|
||||
enum { type = Param::UNSIGNED_INT };
|
||||
};
|
||||
|
||||
template<> struct ParamType<uint64>
|
||||
{
|
||||
typedef uint64 const_param_type;
|
||||
typedef uint64 member_type;
|
||||
|
||||
enum { type = Param::UINT64 };
|
||||
};
|
||||
|
||||
|
||||
// The CommandLineParser class is designed for command line arguments parsing
|
||||
|
||||
/*!
|
||||
"\nThe CommandLineParser class is designed for command line arguments parsing\n"
|
||||
"Keys map: \n"
|
||||
"Before you start to work with CommandLineParser you have to create a map for keys.\n"
|
||||
" It will look like this\n"
|
||||
" const char* keys =\n"
|
||||
" {\n"
|
||||
" { s| string| 123asd |string parameter}\n"
|
||||
" { d| digit | 100 |digit parameter }\n"
|
||||
" { c|noCamera|false |without camera }\n"
|
||||
" { 1| |some text|help }\n"
|
||||
" { 2| |333 |another help }\n"
|
||||
" };\n"
|
||||
"Usage syntax: \n"
|
||||
" \"{\" - start of parameter string.\n"
|
||||
" \"}\" - end of parameter string\n"
|
||||
" \"|\" - separator between short name, full name, default value and help\n"
|
||||
"Supported syntax: \n"
|
||||
" --key1=arg1 <If a key with '--' must has an argument\n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"<If the key with '--' doesn't have any argument, it means that it is a bool key>\n"
|
||||
" -key2=arg2 <If a key with '-' must has an argument \n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"If the key with '-' doesn't have any argument, it means that it is a bool key\n"
|
||||
" key3 <This key can't has any parameter> \n"
|
||||
"Usage: \n"
|
||||
" Imagine that the input parameters are next:\n"
|
||||
" -s=string_value --digit=250 --noCamera lena.jpg 10000\n"
|
||||
" CommandLineParser parser(argc, argv, keys) - create a parser object\n"
|
||||
" parser.get<string>(\"s\" or \"string\") will return you first parameter value\n"
|
||||
" parser.get<string>(\"s\", false or \"string\", false) will return you first parameter value\n"
|
||||
" without spaces in end and begin\n"
|
||||
" parser.get<int>(\"d\" or \"digit\") will return you second parameter value.\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types>\n"
|
||||
" parser.get<bool>(\"c\" or \"noCamera\") will return you true .\n"
|
||||
" If you enter this key in commandline>\n"
|
||||
" It return you false otherwise.\n"
|
||||
" parser.get<string>(\"1\") will return you the first argument without parameter (lena.jpg) \n"
|
||||
" parser.get<int>(\"2\") will return you the second argument without parameter (10000)\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types \n"
|
||||
*/
|
||||
class CV_EXPORTS CommandLineParser
|
||||
{
|
||||
public:
|
||||
public:
|
||||
CommandLineParser(int argc, const char* const argv[], const string& keys);
|
||||
CommandLineParser(const CommandLineParser& parser);
|
||||
CommandLineParser& operator = (const CommandLineParser& parser);
|
||||
|
||||
//! the default constructor
|
||||
CommandLineParser(int argc, const char* const argv[], const char* key_map);
|
||||
string getPathToApplication() const;
|
||||
|
||||
//! get parameter, you can choose: delete spaces in end and begin or not
|
||||
template<typename _Tp>
|
||||
_Tp get(const std::string& name, bool space_delete=true)
|
||||
template <typename T>
|
||||
T get(const string& name, bool space_delete = true) const
|
||||
{
|
||||
if (!has(name))
|
||||
{
|
||||
return _Tp();
|
||||
}
|
||||
std::string str = getString(name);
|
||||
return analyzeValue<_Tp>(str, space_delete);
|
||||
T val = T();
|
||||
getByName(name, space_delete, ParamType<T>::type, (void*)&val);
|
||||
return val;
|
||||
}
|
||||
|
||||
//! print short name, full name, current value and help for all params
|
||||
void printParams();
|
||||
|
||||
protected:
|
||||
std::map<std::string, std::vector<std::string> > data;
|
||||
std::string getString(const std::string& name);
|
||||
|
||||
bool has(const std::string& keys);
|
||||
|
||||
template<typename _Tp>
|
||||
_Tp analyzeValue(const std::string& str, bool space_delete=false);
|
||||
|
||||
template<typename _Tp>
|
||||
static _Tp getData(const std::string& str)
|
||||
template <typename T>
|
||||
T get(int index, bool space_delete = true) const
|
||||
{
|
||||
_Tp res;
|
||||
std::stringstream s1(str);
|
||||
s1 >> res;
|
||||
return res;
|
||||
T val = T();
|
||||
getByIndex(index, space_delete, ParamType<T>::type, (void*)&val);
|
||||
return val;
|
||||
}
|
||||
|
||||
bool has(const string& name) const;
|
||||
|
||||
bool check() const;
|
||||
|
||||
void about(const string& message);
|
||||
|
||||
void printMessage() const;
|
||||
void printErrors() const;
|
||||
|
||||
template<typename _Tp>
|
||||
_Tp fromStringNumber(const std::string& str);//the default conversion function for numbers
|
||||
|
||||
};
|
||||
|
||||
template<> CV_EXPORTS
|
||||
bool CommandLineParser::get<bool>(const std::string& name, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
int CommandLineParser::analyzeValue<int>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
float CommandLineParser::analyzeValue<float>(const std::string& str, bool space_delete);
|
||||
|
||||
template<> CV_EXPORTS
|
||||
double CommandLineParser::analyzeValue<double>(const std::string& str, bool space_delete);
|
||||
protected:
|
||||
void getByName(const string& name, bool space_delete, int type, void* dst) const;
|
||||
void getByIndex(int index, bool space_delete, int type, void* dst) const;
|
||||
|
||||
struct Impl;
|
||||
Impl* impl;
|
||||
};
|
||||
|
||||
/////////////////////////////// Parallel Primitives //////////////////////////////////
|
||||
|
||||
|
@ -104,64 +104,72 @@ CV_INLINE IppiSize ippiSize(int width, int height)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined __SSE2__ || (defined _MSC_VER && _MSC_VER >= 1300)
|
||||
#ifndef IPPI_CALL
|
||||
# define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
#endif
|
||||
|
||||
#if defined __SSE2__ || defined _M_X64 || (defined _M_IX86_FP && _M_IX86_FP >= 2)
|
||||
# include "emmintrin.h"
|
||||
# define CV_SSE 1
|
||||
# define CV_SSE2 1
|
||||
# if defined __SSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include "pmmintrin.h"
|
||||
# define CV_SSE3 1
|
||||
# else
|
||||
# define CV_SSE3 0
|
||||
# endif
|
||||
# if defined __SSSE3__
|
||||
# if defined __SSSE3__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include "tmmintrin.h"
|
||||
# define CV_SSSE3 1
|
||||
# else
|
||||
# define CV_SSSE3 0
|
||||
# endif
|
||||
# if defined __SSE4_1__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <smmintrin.h>
|
||||
# define CV_SSE4_1 1
|
||||
# else
|
||||
# define CV_SSE4_1 0
|
||||
# include <smmintrin.h>
|
||||
# define CV_SSE4_1 1
|
||||
# endif
|
||||
# if defined __SSE4_2__ || (defined _MSC_VER && _MSC_VER >= 1500)
|
||||
# include <nmmintrin.h>
|
||||
# include <nmmintrin.h>
|
||||
# define CV_SSE4_2 1
|
||||
# else
|
||||
# define CV_SSE4_2 0
|
||||
# endif
|
||||
# if defined __AVX__ || (defined _MSC_FULL_VER && _MSC_FULL_VER >= 160040219)
|
||||
# include <immintrin.h>
|
||||
// MS Visual Studio 2010 (2012?) has no macro pre-defined to identify the use of /arch:AVX
|
||||
// See: http://connect.microsoft.com/VisualStudio/feedback/details/605858/arch-avx-should-define-a-predefined-macro-in-x64-and-set-a-unique-value-for-m-ix86-fp-in-win32
|
||||
# include <immintrin.h>
|
||||
# define CV_AVX 1
|
||||
# else
|
||||
# define CV_AVX 0
|
||||
# if defined(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# define __xgetbv() _xgetbv(_XCR_XFEATURE_ENABLED_MASK)
|
||||
# else
|
||||
# define __xgetbv() 0
|
||||
# endif
|
||||
# endif
|
||||
# else
|
||||
# define CV_SSE 0
|
||||
# define CV_SSE2 0
|
||||
# define CV_SSE3 0
|
||||
# define CV_SSSE3 0
|
||||
# define CV_SSE4_1 0
|
||||
# define CV_SSE4_2 0
|
||||
# define CV_AVX 0
|
||||
# endif
|
||||
|
||||
#if defined ANDROID && defined __ARM_NEON__
|
||||
# include "arm_neon.h"
|
||||
# define CV_NEON 1
|
||||
|
||||
# define CPU_HAS_NEON_FEATURE (true)
|
||||
//TODO: make real check using stuff from "cpu-features.h"
|
||||
//((bool)android_getCpuFeatures() & ANDROID_CPU_ARM_FEATURE_NEON)
|
||||
#else
|
||||
# define CV_NEON 0
|
||||
# define CPU_HAS_NEON_FEATURE (false)
|
||||
#endif
|
||||
|
||||
#ifndef IPPI_CALL
|
||||
# define IPPI_CALL(func) CV_Assert((func) >= 0)
|
||||
#ifdef __ARM_NEON__
|
||||
# include <arm_neon.h>
|
||||
# define CV_NEON 1
|
||||
# define CPU_HAS_NEON_FEATURE (true)
|
||||
#endif
|
||||
|
||||
#ifndef CV_SSE
|
||||
# define CV_SSE 0
|
||||
#endif
|
||||
#ifndef CV_SSE2
|
||||
# define CV_SSE2 0
|
||||
#endif
|
||||
#ifndef CV_SSE3
|
||||
# define CV_SSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSSE3
|
||||
# define CV_SSSE3 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_1
|
||||
# define CV_SSE4_1 0
|
||||
#endif
|
||||
#ifndef CV_SSE4_2
|
||||
# define CV_SSE4_2 0
|
||||
#endif
|
||||
#ifndef CV_AVX
|
||||
# define CV_AVX 0
|
||||
#endif
|
||||
#ifndef CV_NEON
|
||||
# define CV_NEON 0
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_TBB
|
||||
|
@ -1,384 +0,0 @@
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
|
||||
namespace {
|
||||
#if 0
|
||||
static void helpParser()
|
||||
{
|
||||
printf("\nThe CommandLineParser class is designed for command line arguments parsing\n"
|
||||
"Keys map: \n"
|
||||
"Before you start to work with CommandLineParser you have to create a map for keys.\n"
|
||||
" It will look like this\n"
|
||||
" const char* keys =\n"
|
||||
" {\n"
|
||||
" { s| string| 123asd |string parameter}\n"
|
||||
" { d| digit | 100 |digit parameter }\n"
|
||||
" { c|noCamera|false |without camera }\n"
|
||||
" { 1| |some text|help }\n"
|
||||
" { 2| |333 |another help }\n"
|
||||
" };\n"
|
||||
"Usage syntax: \n"
|
||||
" \"{\" - start of parameter string.\n"
|
||||
" \"}\" - end of parameter string\n"
|
||||
" \"|\" - separator between short name, full name, default value and help\n"
|
||||
"Supported syntax: \n"
|
||||
" --key1=arg1 <If a key with '--' must has an argument\n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"<If the key with '--' doesn't have any argument, it means that it is a bool key>\n"
|
||||
" -key2=arg2 <If a key with '-' must has an argument \n"
|
||||
" you have to assign it through '=' sign.> \n"
|
||||
"If the key with '-' doesn't have any argument, it means that it is a bool key\n"
|
||||
" key3 <This key can't has any parameter> \n"
|
||||
"Usage: \n"
|
||||
" Imagine that the input parameters are next:\n"
|
||||
" -s=string_value --digit=250 --noCamera lena.jpg 10000\n"
|
||||
" CommandLineParser parser(argc, argv, keys) - create a parser object\n"
|
||||
" parser.get<string>(\"s\" or \"string\") will return you first parameter value\n"
|
||||
" parser.get<string>(\"s\", false or \"string\", false) will return you first parameter value\n"
|
||||
" without spaces in end and begin\n"
|
||||
" parser.get<int>(\"d\" or \"digit\") will return you second parameter value.\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types>\n"
|
||||
" parser.get<bool>(\"c\" or \"noCamera\") will return you true .\n"
|
||||
" If you enter this key in commandline>\n"
|
||||
" It return you false otherwise.\n"
|
||||
" parser.get<string>(\"1\") will return you the first argument without parameter (lena.jpg) \n"
|
||||
" parser.get<int>(\"2\") will return you the second argument without parameter (10000)\n"
|
||||
" It also works with 'unsigned int', 'double', and 'float' types \n"
|
||||
);
|
||||
}
|
||||
#endif
|
||||
|
||||
vector<string> split_string(const string& str, const string& delimiters)
|
||||
{
|
||||
vector<string> res;
|
||||
|
||||
string split_str = str;
|
||||
size_t pos_delim = split_str.find(delimiters);
|
||||
|
||||
while ( pos_delim != string::npos)
|
||||
{
|
||||
if (pos_delim == 0)
|
||||
{
|
||||
res.push_back("");
|
||||
split_str.erase(0, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
res.push_back(split_str.substr(0, pos_delim));
|
||||
split_str.erase(0, pos_delim + 1);
|
||||
}
|
||||
|
||||
pos_delim = split_str.find(delimiters);
|
||||
}
|
||||
|
||||
res.push_back(split_str);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
string del_space(string name)
|
||||
{
|
||||
while ((name.find_first_of(' ') == 0) && (name.length() > 0))
|
||||
name.erase(0, 1);
|
||||
|
||||
while ((name.find_last_of(' ') == (name.length() - 1)) && (name.length() > 0))
|
||||
name.erase(name.end() - 1, name.end());
|
||||
|
||||
return name;
|
||||
}
|
||||
|
||||
}//namespace
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const char* keys)
|
||||
{
|
||||
std::string keys_buffer;
|
||||
std::string values_buffer;
|
||||
std::string buffer;
|
||||
std::string curName;
|
||||
std::vector<string> keysVector;
|
||||
std::vector<string> paramVector;
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
size_t flagPosition;
|
||||
int currentIndex = 1;
|
||||
//bool isFound = false;
|
||||
bool withNoKey = false;
|
||||
bool hasValueThroughEq = false;
|
||||
|
||||
keys_buffer = keys;
|
||||
while (!keys_buffer.empty())
|
||||
{
|
||||
|
||||
flagPosition = keys_buffer.find_first_of('}');
|
||||
flagPosition++;
|
||||
buffer = keys_buffer.substr(0, flagPosition);
|
||||
keys_buffer.erase(0, flagPosition);
|
||||
|
||||
flagPosition = buffer.find('{');
|
||||
if (flagPosition != buffer.npos)
|
||||
buffer.erase(flagPosition, (flagPosition + 1));
|
||||
|
||||
flagPosition = buffer.find('}');
|
||||
if (flagPosition != buffer.npos)
|
||||
buffer.erase(flagPosition);
|
||||
|
||||
paramVector = split_string(buffer, "|");
|
||||
while (paramVector.size() < 4) paramVector.push_back("");
|
||||
|
||||
buffer = paramVector[0];
|
||||
buffer += '|' + paramVector[1];
|
||||
|
||||
//if (buffer == "") CV_ERROR(CV_StsBadArg, "In CommandLineParser need set short and full name");
|
||||
|
||||
paramVector.erase(paramVector.begin(), paramVector.begin() + 2);
|
||||
data[buffer] = paramVector;
|
||||
}
|
||||
|
||||
buffer.clear();
|
||||
keys_buffer.clear();
|
||||
paramVector.clear();
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
if (!argv[i])
|
||||
break;
|
||||
curName = argv[i];
|
||||
if (curName.find('-') == 0 && ((curName[1] < '0') || (curName[1] > '9')))
|
||||
{
|
||||
while (curName.find('-') == 0)
|
||||
curName.erase(curName.begin(), (curName.begin() + 1));
|
||||
}
|
||||
else
|
||||
withNoKey = true;
|
||||
if (curName.find('=') != curName.npos)
|
||||
{
|
||||
hasValueThroughEq = true;
|
||||
buffer = curName;
|
||||
curName.erase(curName.find('='));
|
||||
buffer.erase(0, (buffer.find('=') + 1));
|
||||
}
|
||||
|
||||
values_buffer = del_space(values_buffer);
|
||||
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
keys_buffer = it->first;
|
||||
keysVector = split_string(keys_buffer, "|");
|
||||
|
||||
for (size_t j = 0; j < keysVector.size(); j++) keysVector[j] = del_space(keysVector[j]);
|
||||
|
||||
values_buffer = it->second[0];
|
||||
if (((curName == keysVector[0]) || (curName == keysVector[1])) && hasValueThroughEq)
|
||||
{
|
||||
it->second[0] = buffer;
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasValueThroughEq && ((curName == keysVector[0]) || (curName == keysVector[1]))
|
||||
&& (
|
||||
values_buffer.find("false") != values_buffer.npos ||
|
||||
values_buffer == ""
|
||||
))
|
||||
{
|
||||
it->second[0] = "true";
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!hasValueThroughEq && (values_buffer.find("false") == values_buffer.npos) &&
|
||||
((curName == keysVector[0]) || (curName == keysVector[1])))
|
||||
{
|
||||
it->second[0] = argv[++i];
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (withNoKey)
|
||||
{
|
||||
std::string noKeyStr = it->first;
|
||||
if(atoi(noKeyStr.c_str()) == currentIndex)
|
||||
{
|
||||
it->second[0] = curName;
|
||||
currentIndex++;
|
||||
//isFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
withNoKey = false;
|
||||
hasValueThroughEq = false;
|
||||
//isFound = false;
|
||||
}
|
||||
}
|
||||
|
||||
bool CommandLineParser::has(const std::string& keys)
|
||||
{
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
std::vector<string> keysVector;
|
||||
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
keysVector = split_string(it->first, "|");
|
||||
for (size_t i = 0; i < keysVector.size(); i++) keysVector[i] = del_space(keysVector[i]);
|
||||
|
||||
if (keysVector.size() == 1) keysVector.push_back("");
|
||||
|
||||
if ((del_space(keys).compare(keysVector[0]) == 0) ||
|
||||
(del_space(keys).compare(keysVector[1]) == 0))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string CommandLineParser::getString(const std::string& keys)
|
||||
{
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
std::vector<string> valueVector;
|
||||
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
valueVector = split_string(it->first, "|");
|
||||
for (size_t i = 0; i < valueVector.size(); i++) valueVector[i] = del_space(valueVector[i]);
|
||||
|
||||
if (valueVector.size() == 1) valueVector.push_back("");
|
||||
|
||||
if ((del_space(keys).compare(valueVector[0]) == 0) ||
|
||||
(del_space(keys).compare(valueVector[1]) == 0))
|
||||
return it->second[0];
|
||||
}
|
||||
return string();
|
||||
}
|
||||
|
||||
template<typename _Tp>
|
||||
_Tp CommandLineParser::fromStringNumber(const std::string& str)//the default conversion function for numbers
|
||||
{
|
||||
return getData<_Tp>(str);
|
||||
}
|
||||
|
||||
void CommandLineParser::printParams()
|
||||
{
|
||||
int col_p = 30;
|
||||
int col_d = 50;
|
||||
|
||||
std::map<std::string, std::vector<std::string> >::iterator it;
|
||||
std::vector<string> keysVector;
|
||||
std::string buf;
|
||||
for(it = data.begin(); it != data.end(); it++)
|
||||
{
|
||||
keysVector = split_string(it->first, "|");
|
||||
for (size_t i = 0; i < keysVector.size(); i++) keysVector[i] = del_space(keysVector[i]);
|
||||
|
||||
cout << " ";
|
||||
buf = "";
|
||||
if (keysVector[0] != "")
|
||||
{
|
||||
buf = "-" + keysVector[0];
|
||||
if (keysVector[1] != "") buf += ", --" + keysVector[1];
|
||||
}
|
||||
else if (keysVector[1] != "") buf += "--" + keysVector[1];
|
||||
if (del_space(it->second[0]) != "") buf += "=[" + del_space(it->second[0]) + "]";
|
||||
|
||||
cout << setw(col_p-2) << left << buf;
|
||||
|
||||
if ((int)buf.length() > col_p-2)
|
||||
{
|
||||
cout << endl << " ";
|
||||
cout << setw(col_p-2) << left << " ";
|
||||
}
|
||||
|
||||
buf = "";
|
||||
if (del_space(it->second[1]) != "") buf += del_space(it->second[1]);
|
||||
|
||||
for(;;)
|
||||
{
|
||||
bool tr = ((int)buf.length() > col_d-2) ? true: false;
|
||||
std::string::size_type pos = 0;
|
||||
|
||||
if (tr)
|
||||
{
|
||||
pos = buf.find_first_of(' ');
|
||||
for(;;)
|
||||
{
|
||||
if (buf.find_first_of(' ', pos + 1 ) < (std::string::size_type)(col_d-2) &&
|
||||
buf.find_first_of(' ', pos + 1 ) != std::string::npos)
|
||||
pos = buf.find_first_of(' ', pos + 1);
|
||||
else
|
||||
break;
|
||||
}
|
||||
pos++;
|
||||
cout << setw(col_d-2) << left << buf.substr(0, pos) << endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
cout << setw(col_d-2) << left << buf<< endl;
|
||||
break;
|
||||
}
|
||||
|
||||
buf.erase(0, pos);
|
||||
cout << " ";
|
||||
cout << setw(col_p-2) << left << " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<>
|
||||
bool CommandLineParser::get<bool>(const std::string& name, bool space_delete)
|
||||
{
|
||||
std::string str_buf = getString(name);
|
||||
|
||||
if (space_delete && str_buf != "")
|
||||
{
|
||||
str_buf = del_space(str_buf);
|
||||
}
|
||||
|
||||
if (str_buf == "true")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
template<>
|
||||
std::string CommandLineParser::analyzeValue<std::string>(const std::string& str, bool space_delete)
|
||||
{
|
||||
if (space_delete)
|
||||
{
|
||||
return del_space(str);
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
template<>
|
||||
int CommandLineParser::analyzeValue<int>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<int>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
unsigned int CommandLineParser::analyzeValue<unsigned int>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<unsigned int>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
uint64 CommandLineParser::analyzeValue<uint64>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<uint64>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
float CommandLineParser::analyzeValue<float>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<float>(str);
|
||||
}
|
||||
|
||||
template<>
|
||||
double CommandLineParser::analyzeValue<double>(const std::string& str, bool /*space_delete*/)
|
||||
{
|
||||
return fromStringNumber<double>(str);
|
||||
}
|
507
modules/core/src/command_line_parser.cpp
Normal file
507
modules/core/src/command_line_parser.cpp
Normal file
@ -0,0 +1,507 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
|
||||
struct CommandLineParserParams
|
||||
{
|
||||
public:
|
||||
string help_message;
|
||||
string def_value;
|
||||
vector<string> keys;
|
||||
int number;
|
||||
};
|
||||
|
||||
|
||||
struct CommandLineParser::Impl
|
||||
{
|
||||
bool error;
|
||||
string error_message;
|
||||
string about_message;
|
||||
|
||||
string path_to_app;
|
||||
string app_name;
|
||||
|
||||
vector<CommandLineParserParams> data;
|
||||
|
||||
vector<string> split_range_string(const string& str, char fs, char ss) const;
|
||||
vector<string> split_string(const string& str, char symbol = ' ', bool create_empty_item = false) const;
|
||||
string cat_string(const string& str) const;
|
||||
|
||||
void apply_params(const string& key, const string& value);
|
||||
void apply_params(int i, string value);
|
||||
|
||||
void sort_params();
|
||||
int refcount;
|
||||
};
|
||||
|
||||
|
||||
static string get_type_name(int type)
|
||||
{
|
||||
if( type == Param::INT )
|
||||
return "int";
|
||||
if( type == Param::UNSIGNED_INT )
|
||||
return "unsigned";
|
||||
if( type == Param::UINT64 )
|
||||
return "unsigned long long";
|
||||
if( type == Param::FLOAT )
|
||||
return "float";
|
||||
if( type == Param::REAL )
|
||||
return "double";
|
||||
if( type == Param::STRING )
|
||||
return "string";
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
static void from_str(const string& str, int type, void* dst)
|
||||
{
|
||||
std::stringstream ss(str);
|
||||
if( type == Param::INT )
|
||||
ss >> *(int*)dst;
|
||||
else if( type == Param::UNSIGNED_INT )
|
||||
ss >> *(unsigned*)dst;
|
||||
else if( type == Param::UINT64 )
|
||||
ss >> *(uint64*)dst;
|
||||
else if( type == Param::FLOAT )
|
||||
ss >> *(float*)dst;
|
||||
else if( type == Param::REAL )
|
||||
ss >> *(double*)dst;
|
||||
else if( type == Param::STRING )
|
||||
ss >> *(string*)dst;
|
||||
else
|
||||
CV_Error(CV_StsBadArg, "unknown/unsupported parameter type");
|
||||
|
||||
if (ss.fail())
|
||||
{
|
||||
string err_msg = "can not convert: [" + str +
|
||||
+ "] to [" + get_type_name(type) + "]";
|
||||
|
||||
CV_Error(CV_StsBadArg, err_msg);
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::getByName(const string& name, bool space_delete, int type, void* dst) const
|
||||
{
|
||||
try
|
||||
{
|
||||
for (size_t i = 0; i < impl->data.size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
||||
{
|
||||
if (name.compare(impl->data[i].keys[j]) == 0)
|
||||
{
|
||||
string v = impl->data[i].def_value;
|
||||
if (space_delete)
|
||||
v = impl->cat_string(v);
|
||||
from_str(v, type, dst);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
impl->error = true;
|
||||
impl->error_message += "Unknown parametes " + name + "\n";
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
impl->error = true;
|
||||
impl->error_message += "Exception: " + string(e.what()) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void CommandLineParser::getByIndex(int index, bool space_delete, int type, void* dst) const
|
||||
{
|
||||
try
|
||||
{
|
||||
for (size_t i = 0; i < impl->data.size(); i++)
|
||||
{
|
||||
if (impl->data[i].number == index)
|
||||
{
|
||||
string v = impl->data[i].def_value;
|
||||
if (space_delete == true) v = impl->cat_string(v);
|
||||
from_str(v, type, dst);
|
||||
return;
|
||||
}
|
||||
}
|
||||
impl->error = true;
|
||||
impl->error_message += "Unknown parametes #" + format("%d", index) + "\n";
|
||||
}
|
||||
catch(std::exception & e)
|
||||
{
|
||||
impl->error = true;
|
||||
impl->error_message += "Exception: " + string(e.what()) + "\n";
|
||||
}
|
||||
}
|
||||
|
||||
static bool cmp_params(const CommandLineParserParams & p1, const CommandLineParserParams & p2)
|
||||
{
|
||||
if (p1.number > p2.number)
|
||||
return false;
|
||||
|
||||
if (p1.number == -1 && p2.number == -1)
|
||||
{
|
||||
if (p1.keys[0].compare(p2.keys[0]) > 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
CommandLineParser::CommandLineParser(int argc, const char* const argv[], const string& keys)
|
||||
{
|
||||
impl = new Impl;
|
||||
impl->refcount = 1;
|
||||
|
||||
// path to application
|
||||
size_t pos_s = string(argv[0]).find_last_of("/\\");
|
||||
if (pos_s == string::npos)
|
||||
{
|
||||
impl->path_to_app = "";
|
||||
impl->app_name = string(argv[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
impl->path_to_app = string(argv[0]).substr(0, pos_s);
|
||||
impl->app_name = string(argv[0]).substr(pos_s + 1, string(argv[0]).length() - pos_s);
|
||||
}
|
||||
|
||||
impl->error = false;
|
||||
impl->error_message = "";
|
||||
|
||||
// parse keys
|
||||
vector<string> k = impl->split_range_string(keys, '{', '}');
|
||||
|
||||
int jj = 0;
|
||||
for (size_t i = 0; i < k.size(); i++)
|
||||
{
|
||||
vector<string> l = impl->split_string(k[i], '|', true);
|
||||
CommandLineParserParams p;
|
||||
p.keys = impl->split_string(l[0]);
|
||||
p.def_value = l[1];
|
||||
p.help_message = impl->cat_string(l[2]);
|
||||
p.number = -1;
|
||||
if (p.keys[0][0] == '@')
|
||||
{
|
||||
p.number = jj;
|
||||
jj++;
|
||||
}
|
||||
|
||||
impl->data.push_back(p);
|
||||
}
|
||||
|
||||
// parse argv
|
||||
jj = 0;
|
||||
for (int i = 1; i < argc; i++)
|
||||
{
|
||||
string s = string(argv[i]);
|
||||
|
||||
if (s.find('=') != string::npos && s.find('=') < s.length())
|
||||
{
|
||||
vector<string> k_v = impl->split_string(s, '=', true);
|
||||
for (int h = 0; h < 2; h++)
|
||||
{
|
||||
if (k_v[0][0] == '-')
|
||||
k_v[0] = k_v[0].substr(1, k_v[0].length() -1);
|
||||
}
|
||||
impl->apply_params(k_v[0], k_v[1]);
|
||||
}
|
||||
else if (s.length() > 1 && s[0] == '-')
|
||||
{
|
||||
for (int h = 0; h < 2; h++)
|
||||
{
|
||||
if (s[0] == '-')
|
||||
s = s.substr(1, s.length() - 1);
|
||||
}
|
||||
impl->apply_params(s, "true");
|
||||
}
|
||||
else if (s[0] != '-')
|
||||
{
|
||||
impl->apply_params(jj, s);
|
||||
jj++;
|
||||
}
|
||||
}
|
||||
|
||||
impl->sort_params();
|
||||
}
|
||||
|
||||
|
||||
CommandLineParser::CommandLineParser(const CommandLineParser& parser)
|
||||
{
|
||||
impl = parser.impl;
|
||||
CV_XADD(&impl->refcount, 1);
|
||||
}
|
||||
|
||||
CommandLineParser& CommandLineParser::operator = (const CommandLineParser& parser)
|
||||
{
|
||||
if( this != &parser )
|
||||
{
|
||||
if(CV_XADD(&impl->refcount, -1) == 1)
|
||||
delete impl;
|
||||
impl = parser.impl;
|
||||
CV_XADD(&impl->refcount, 1);
|
||||
}
|
||||
return *this;
|
||||
}
|
||||
|
||||
void CommandLineParser::about(const string& message)
|
||||
{
|
||||
impl->about_message = message;
|
||||
}
|
||||
|
||||
void CommandLineParser::Impl::apply_params(const string& key, const string& value)
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
for (size_t k = 0; k < data[i].keys.size(); k++)
|
||||
{
|
||||
if (key.compare(data[i].keys[k]) == 0)
|
||||
{
|
||||
data[i].def_value = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::Impl::apply_params(int i, string value)
|
||||
{
|
||||
for (size_t j = 0; j < data.size(); j++)
|
||||
{
|
||||
if (data[j].number == i)
|
||||
{
|
||||
data[j].def_value = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::Impl::sort_params()
|
||||
{
|
||||
for (size_t i = 0; i < data.size(); i++)
|
||||
{
|
||||
sort(data[i].keys.begin(), data[i].keys.end());
|
||||
}
|
||||
|
||||
sort (data.begin(), data.end(), cmp_params);
|
||||
}
|
||||
|
||||
string CommandLineParser::Impl::cat_string(const string& str) const
|
||||
{
|
||||
int left = 0, right = (int)str.length();
|
||||
while( left <= right && str[left] == ' ' )
|
||||
left++;
|
||||
while( right > left && str[right-1] == ' ' )
|
||||
right--;
|
||||
return left >= right ? string("") : str.substr(left, right-left);
|
||||
}
|
||||
|
||||
string CommandLineParser::getPathToApplication() const
|
||||
{
|
||||
return impl->path_to_app;
|
||||
}
|
||||
|
||||
bool CommandLineParser::has(const string& name) const
|
||||
{
|
||||
for (size_t i = 0; i < impl->data.size(); i++)
|
||||
{
|
||||
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
||||
{
|
||||
if (name.compare(impl->data[i].keys[j]) == 0 && string("true").compare(impl->data[i].def_value) == 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CommandLineParser::check() const
|
||||
{
|
||||
return impl->error == false;
|
||||
}
|
||||
|
||||
void CommandLineParser::printErrors() const
|
||||
{
|
||||
if (impl->error)
|
||||
{
|
||||
std::cout << std::endl << "ERRORS:" << std::endl << impl->error_message << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
void CommandLineParser::printMessage() const
|
||||
{
|
||||
if (impl->about_message != "")
|
||||
std::cout << impl->about_message << std::endl;
|
||||
|
||||
std::cout << "Usage: " << impl->app_name << " [params] ";
|
||||
|
||||
for (size_t i = 0; i < impl->data.size(); i++)
|
||||
{
|
||||
if (impl->data[i].number > -1)
|
||||
{
|
||||
string name = impl->data[i].keys[0].substr(1, impl->data[i].keys[0].length() - 1);
|
||||
std::cout << name << " ";
|
||||
}
|
||||
}
|
||||
|
||||
std::cout << std::endl << std::endl;
|
||||
|
||||
for (size_t i = 0; i < impl->data.size(); i++)
|
||||
{
|
||||
if (impl->data[i].number == -1)
|
||||
{
|
||||
std::cout << "\t";
|
||||
for (size_t j = 0; j < impl->data[i].keys.size(); j++)
|
||||
{
|
||||
string k = impl->data[i].keys[j];
|
||||
if (k.length() > 1)
|
||||
{
|
||||
std::cout << "--";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "-";
|
||||
}
|
||||
std::cout << k;
|
||||
|
||||
if (j != impl->data[i].keys.size() - 1)
|
||||
{
|
||||
std::cout << ", ";
|
||||
}
|
||||
}
|
||||
string dv = impl->cat_string(impl->data[i].def_value);
|
||||
if (dv.compare("") != 0)
|
||||
{
|
||||
std::cout << " (value:" << dv << ")";
|
||||
}
|
||||
std::cout << std::endl << "\t\t" << impl->data[i].help_message << std::endl;
|
||||
}
|
||||
}
|
||||
std::cout << std::endl;
|
||||
|
||||
for (size_t i = 0; i < impl->data.size(); i++)
|
||||
{
|
||||
if (impl->data[i].number != -1)
|
||||
{
|
||||
std::cout << "\t";
|
||||
string k = impl->data[i].keys[0];
|
||||
k = k.substr(1, k.length() - 1);
|
||||
|
||||
std::cout << k;
|
||||
|
||||
string dv = impl->cat_string(impl->data[i].def_value);
|
||||
if (dv.compare("") != 0)
|
||||
{
|
||||
std::cout << " (value:" << dv << ")";
|
||||
}
|
||||
std::cout << std::endl << "\t\t" << impl->data[i].help_message << std::endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vector<string> CommandLineParser::Impl::split_range_string(const string& _str, char fs, char ss) const
|
||||
{
|
||||
string str = _str;
|
||||
vector<string> vec;
|
||||
string word = "";
|
||||
bool begin = false;
|
||||
|
||||
while (!str.empty())
|
||||
{
|
||||
if (str[0] == fs)
|
||||
{
|
||||
if (begin == true)
|
||||
{
|
||||
CV_Error(CV_StsParseError,
|
||||
string("error in split_range_string(")
|
||||
+ str
|
||||
+ string(", ")
|
||||
+ string(1, fs)
|
||||
+ string(", ")
|
||||
+ string(1, ss)
|
||||
+ string(")")
|
||||
);
|
||||
}
|
||||
begin = true;
|
||||
word = "";
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
||||
if (str[0] == ss)
|
||||
{
|
||||
if (begin == false)
|
||||
{
|
||||
CV_Error(CV_StsParseError,
|
||||
string("error in split_range_string(")
|
||||
+ str
|
||||
+ string(", ")
|
||||
+ string(1, fs)
|
||||
+ string(", ")
|
||||
+ string(1, ss)
|
||||
+ string(")")
|
||||
);
|
||||
}
|
||||
begin = false;
|
||||
vec.push_back(word);
|
||||
}
|
||||
|
||||
if (begin == true)
|
||||
{
|
||||
word += str[0];
|
||||
}
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
||||
if (begin == true)
|
||||
{
|
||||
CV_Error(CV_StsParseError,
|
||||
string("error in split_range_string(")
|
||||
+ str
|
||||
+ string(", ")
|
||||
+ string(1, fs)
|
||||
+ string(", ")
|
||||
+ string(1, ss)
|
||||
+ string(")")
|
||||
);
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
vector<string> CommandLineParser::Impl::split_string(const string& _str, char symbol, bool create_empty_item) const
|
||||
{
|
||||
string str = _str;
|
||||
vector<string> vec;
|
||||
string word = "";
|
||||
|
||||
while (!str.empty())
|
||||
{
|
||||
if (str[0] == symbol)
|
||||
{
|
||||
if (!word.empty() || create_empty_item)
|
||||
{
|
||||
vec.push_back(word);
|
||||
word = "";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
word += str[0];
|
||||
}
|
||||
str = str.substr(1, str.length() - 1);
|
||||
}
|
||||
|
||||
if (word != "" || create_empty_item)
|
||||
{
|
||||
vec.push_back(word);
|
||||
}
|
||||
|
||||
return vec;
|
||||
}
|
||||
|
||||
}
|
@ -774,7 +774,7 @@ bool CV_OperationsTest::TestTemplateMat()
|
||||
Mat m2 = Mat::zeros(10, 10, CV_8UC3);
|
||||
m1.copyTo(m2.row(1));
|
||||
}
|
||||
catch(const Exception& e)
|
||||
catch(const Exception&)
|
||||
{
|
||||
badarg_catched = true;
|
||||
}
|
||||
@ -958,6 +958,10 @@ bool CV_OperationsTest::operations1()
|
||||
if( !(minidx[0] == 31 && minidx[1] == 0 && maxidx[0] == 12 && maxidx[1] == 0 &&
|
||||
minval == -7 && maxval == 12))
|
||||
throw test_excep();
|
||||
|
||||
Matx33f b(1.f, 2.f, 3.f, 4.f, 5.f, 6.f, 7.f, 8.f, 9.f), c;
|
||||
add(Mat::zeros(3, 3, CV_32F), b, c);
|
||||
CV_Assert( norm(b, c, CV_C) == 0 );
|
||||
}
|
||||
catch(const test_excep&)
|
||||
{
|
||||
|
@ -264,7 +264,7 @@ public:
|
||||
bool useProvidedKeypoints=false ) const = 0;
|
||||
|
||||
// Create feature detector and descriptor extractor by name.
|
||||
static Ptr<Feature2D> create( const string& name );
|
||||
CV_WRAP static Ptr<Feature2D> create( const string& name );
|
||||
};
|
||||
|
||||
/*!
|
||||
|
@ -1182,7 +1182,7 @@ BriskScaleSpace::refine3D(const int layer, const int x_layer, const int y_layer,
|
||||
const int center = thisLayer.getAgastScore(x_layer, y_layer, 1);
|
||||
|
||||
// check and get above maximum:
|
||||
float delta_x_above, delta_y_above;
|
||||
float delta_x_above = 0, delta_y_above = 0;
|
||||
float max_above = getScoreMaxAbove(layer, x_layer, y_layer, center, ismax, delta_x_above, delta_y_above);
|
||||
|
||||
if (!ismax)
|
||||
|
@ -44,6 +44,11 @@
|
||||
|
||||
using namespace cv;
|
||||
|
||||
Ptr<Feature2D> Feature2D::create( const string& feature2DType )
|
||||
{
|
||||
return Algorithm::create<Feature2D>("Feature2D." + feature2DType);
|
||||
}
|
||||
|
||||
/////////////////////// AlgorithmInfo for various detector & descriptors ////////////////////////////
|
||||
|
||||
/* NOTE!!!
|
||||
|
@ -818,23 +818,23 @@ Performs linear blending of two images.
|
||||
:param result: Destination image.
|
||||
|
||||
:param stream: Stream for the asynchronous version.
|
||||
|
||||
|
||||
|
||||
|
||||
gpu::bilateralFilter
|
||||
-------------------
|
||||
--------------------
|
||||
Performs bilateral filtering of passed image
|
||||
|
||||
.. ocv:function:: void gpu::bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode, Stream& stream = Stream::Null());
|
||||
|
||||
.. ocv:function:: void gpu::bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial, int borderMode, Stream& stream = Stream::Null())
|
||||
|
||||
:param src: Source image. Supports only (channles != 2 && depth() != CV_8S && depth() != CV_32S && depth() != CV_64F).
|
||||
|
||||
:param dst: Destination imagwe.
|
||||
|
||||
:param kernel_size: Kernel window size.
|
||||
|
||||
:param sigma_color: Filter sigma in the color space.
|
||||
|
||||
:param sigma_spatial: Filter sigma in the coordinate space.
|
||||
:param sigma_color: Filter sigma in the color space.
|
||||
|
||||
:param sigma_spatial: Filter sigma in the coordinate space.
|
||||
|
||||
:param borderMode: Border type. See :ocv:func:`borderInterpolate` for details. ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
|
||||
|
||||
@ -843,24 +843,24 @@ Performs bilateral filtering of passed image
|
||||
.. seealso::
|
||||
|
||||
:ocv:func:`bilateralFilter`,
|
||||
|
||||
|
||||
|
||||
|
||||
gpu::nonLocalMeans
|
||||
-------------------
|
||||
Performs pure non local means denoising without any simplification, and thus it is not fast.
|
||||
|
||||
.. ocv:function:: void nonLocalMeans(const GpuMat& src, GpuMat& dst, float h, int search_widow_size = 11, int block_size = 7, int borderMode = BORDER_DEFAULT, Stream& s = Stream::Null());
|
||||
|
||||
.. ocv:function:: void nonLocalMeans(const GpuMat& src, GpuMat& dst, float h, int search_widow_size = 11, int block_size = 7, int borderMode = BORDER_DEFAULT, Stream& s = Stream::Null())
|
||||
|
||||
:param src: Source image. Supports only CV_8UC1, CV_8UC3.
|
||||
|
||||
:param dst: Destination imagwe.
|
||||
|
||||
:param h: Filter sigma regulating filter strength for color.
|
||||
|
||||
:param h: Filter sigma regulating filter strength for color.
|
||||
|
||||
:param search_widow_size: Size of search window.
|
||||
|
||||
:param block_size: Size of block used for computing weights.
|
||||
|
||||
:param block_size: Size of block used for computing weights.
|
||||
|
||||
:param borderMode: Border type. See :ocv:func:`borderInterpolate` for details. ``BORDER_REFLECT101`` , ``BORDER_REPLICATE`` , ``BORDER_CONSTANT`` , ``BORDER_REFLECT`` and ``BORDER_WRAP`` are supported for now.
|
||||
|
||||
:param stream: Stream for the asynchronous version.
|
||||
@ -868,7 +868,7 @@ Performs pure non local means denoising without any simplification, and thus it
|
||||
.. seealso::
|
||||
|
||||
:ocv:func:`fastNlMeansDenoising`
|
||||
|
||||
|
||||
gpu::alphaComp
|
||||
-------------------
|
||||
Composites two images using alpha opacity values contained in each image.
|
||||
|
@ -770,11 +770,11 @@ CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat
|
||||
GpuMat& result, Stream& stream = Stream::Null());
|
||||
|
||||
//! Performa bilateral filtering of passsed image
|
||||
CV_EXPORTS void bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial,
|
||||
CV_EXPORTS void bilateralFilter(const GpuMat& src, GpuMat& dst, int kernel_size, float sigma_color, float sigma_spatial,
|
||||
int borderMode = BORDER_DEFAULT, Stream& stream = Stream::Null());
|
||||
|
||||
//! Brute force non-local means algorith (slow but universal)
|
||||
CV_EXPORTS void nonLocalMeans(const GpuMat& src, GpuMat& dst, float h,
|
||||
CV_EXPORTS void nonLocalMeans(const GpuMat& src, GpuMat& dst, float h,
|
||||
int search_widow_size = 11, int block_size = 7, int borderMode = BORDER_DEFAULT, Stream& s = Stream::Null());
|
||||
|
||||
|
||||
@ -854,6 +854,38 @@ CV_EXPORTS void HoughCircles(const GpuMat& src, GpuMat& circles, int method, flo
|
||||
CV_EXPORTS void HoughCircles(const GpuMat& src, GpuMat& circles, HoughCirclesBuf& buf, int method, float dp, float minDist, int cannyThreshold, int votesThreshold, int minRadius, int maxRadius, int maxCircles = 4096);
|
||||
CV_EXPORTS void HoughCirclesDownload(const GpuMat& d_circles, OutputArray h_circles);
|
||||
|
||||
//! finds arbitrary template in the grayscale image using Generalized Hough Transform
|
||||
//! Ballard, D.H. (1981). Generalizing the Hough transform to detect arbitrary shapes. Pattern Recognition 13 (2): 111-122.
|
||||
//! Guil, N., González-Linares, J.M. and Zapata, E.L. (1999). Bidimensional shape detection using an invariant approach. Pattern Recognition 32 (6): 1025-1038.
|
||||
class CV_EXPORTS GeneralizedHough_GPU : public Algorithm
|
||||
{
|
||||
public:
|
||||
static Ptr<GeneralizedHough_GPU> create(int method);
|
||||
|
||||
virtual ~GeneralizedHough_GPU();
|
||||
|
||||
//! set template to search
|
||||
void setTemplate(const GpuMat& templ, int cannyThreshold = 100, Point templCenter = Point(-1, -1));
|
||||
void setTemplate(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, Point templCenter = Point(-1, -1));
|
||||
|
||||
//! find template on image
|
||||
void detect(const GpuMat& image, GpuMat& positions, int cannyThreshold = 100);
|
||||
void detect(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, GpuMat& positions);
|
||||
|
||||
void download(const GpuMat& d_positions, OutputArray h_positions, OutputArray h_votes = noArray());
|
||||
|
||||
void release();
|
||||
|
||||
protected:
|
||||
virtual void setTemplateImpl(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, Point templCenter) = 0;
|
||||
virtual void detectImpl(const GpuMat& edges, const GpuMat& dx, const GpuMat& dy, GpuMat& positions) = 0;
|
||||
virtual void releaseImpl() = 0;
|
||||
|
||||
private:
|
||||
GpuMat edges_;
|
||||
CannyBuf cannyBuf_;
|
||||
};
|
||||
|
||||
////////////////////////////// Matrix reductions //////////////////////////////
|
||||
|
||||
//! computes mean value and standard deviation of all or selected array elements
|
||||
|
@ -73,20 +73,32 @@ void printCudaInfo()
|
||||
|
||||
int main(int argc, char** argv)
|
||||
{
|
||||
CommandLineParser cmd(argc, (const char**) argv,
|
||||
"{ print_info_only | print_info_only | false | Print information about system and exit }"
|
||||
"{ device | device | 0 | Device on which tests will be executed }"
|
||||
"{ cpu | cpu | false | Run tests on cpu }"
|
||||
);
|
||||
const std::string keys =
|
||||
"{ h help ? | | Print help}"
|
||||
"{ i info | | Print information about system and exit }"
|
||||
"{ device | 0 | Device on which tests will be executed }"
|
||||
"{ cpu | | Run tests on cpu }"
|
||||
;
|
||||
|
||||
CommandLineParser cmd(argc, (const char**) argv, keys);
|
||||
|
||||
if (cmd.has("help"))
|
||||
{
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
printOsInfo();
|
||||
printCudaInfo();
|
||||
|
||||
if (cmd.get<bool>("print_info_only"))
|
||||
|
||||
if (cmd.has("info"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
bool cpu = cmd.get<bool>("cpu");
|
||||
bool cpu = cmd.has("cpu");
|
||||
#ifndef HAVE_CUDA
|
||||
cpu = true;
|
||||
#endif
|
||||
|
@ -1713,4 +1713,98 @@ PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles, Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// GeneralizedHough
|
||||
|
||||
CV_FLAGS(GHMethod, cv::GHT_POSITION, cv::GHT_SCALE, cv::GHT_ROTATION);
|
||||
|
||||
DEF_PARAM_TEST(Method_Sz, GHMethod, cv::Size);
|
||||
|
||||
PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough, Combine(
|
||||
Values(GHMethod(cv::GHT_POSITION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE), GHMethod(cv::GHT_POSITION | cv::GHT_ROTATION), GHMethod(cv::GHT_POSITION | cv::GHT_SCALE | cv::GHT_ROTATION)),
|
||||
GPU_TYPICAL_MAT_SIZES))
|
||||
{
|
||||
declare.time(10);
|
||||
|
||||
const int method = GET_PARAM(0);
|
||||
const cv::Size imageSize = GET_PARAM(1);
|
||||
|
||||
const cv::Mat templ = readImage("cv/shared/templ.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(templ.empty());
|
||||
|
||||
cv::Mat image(imageSize, CV_8UC1, cv::Scalar::all(0));
|
||||
|
||||
cv::RNG rng(123456789);
|
||||
const int objCount = rng.uniform(5, 15);
|
||||
for (int i = 0; i < objCount; ++i)
|
||||
{
|
||||
double scale = rng.uniform(0.7, 1.3);
|
||||
bool rotate = 1 == rng.uniform(0, 2);
|
||||
|
||||
cv::Mat obj;
|
||||
cv::resize(templ, obj, cv::Size(), scale, scale);
|
||||
if (rotate)
|
||||
obj = obj.t();
|
||||
|
||||
cv::Point pos;
|
||||
|
||||
pos.x = rng.uniform(0, image.cols - obj.cols);
|
||||
pos.y = rng.uniform(0, image.rows - obj.rows);
|
||||
|
||||
cv::Mat roi = image(cv::Rect(pos, obj.size()));
|
||||
cv::add(roi, obj, roi);
|
||||
}
|
||||
|
||||
cv::Mat edges;
|
||||
cv::Canny(image, edges, 50, 100);
|
||||
|
||||
cv::Mat dx, dy;
|
||||
cv::Sobel(image, dx, CV_32F, 1, 0);
|
||||
cv::Sobel(image, dy, CV_32F, 0, 1);
|
||||
|
||||
if (runOnGpu)
|
||||
{
|
||||
cv::gpu::GpuMat d_edges(edges);
|
||||
cv::gpu::GpuMat d_dx(dx);
|
||||
cv::gpu::GpuMat d_dy(dy);
|
||||
cv::gpu::GpuMat d_position;
|
||||
|
||||
cv::Ptr<cv::gpu::GeneralizedHough_GPU> d_hough = cv::gpu::GeneralizedHough_GPU::create(method);
|
||||
if (method & cv::GHT_ROTATION)
|
||||
{
|
||||
d_hough->set("maxAngle", 90.0);
|
||||
d_hough->set("angleStep", 2.0);
|
||||
}
|
||||
|
||||
d_hough->setTemplate(cv::gpu::GpuMat(templ));
|
||||
|
||||
d_hough->detect(d_edges, d_dx, d_dy, d_position);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
d_hough->detect(d_edges, d_dx, d_dy, d_position);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cv::Mat positions;
|
||||
|
||||
cv::Ptr<cv::GeneralizedHough> hough = cv::GeneralizedHough::create(method);
|
||||
if (method & cv::GHT_ROTATION)
|
||||
{
|
||||
hough->set("maxAngle", 90.0);
|
||||
hough->set("angleStep", 2.0);
|
||||
}
|
||||
|
||||
hough->setTemplate(templ);
|
||||
|
||||
hough->detect(edges, dx, dy, positions);
|
||||
|
||||
TEST_CYCLE()
|
||||
{
|
||||
hough->detect(edges, dx, dy, positions);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -777,6 +777,7 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a
|
||||
cap >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
cap.release();
|
||||
cap.open(inputFile);
|
||||
cap >> frame;
|
||||
}
|
||||
@ -814,6 +815,7 @@ PERF_TEST_P(Video_Cn_MaxFeatures, Video_GMG, Combine(Values("gpu/video/768x576.a
|
||||
cap >> frame;
|
||||
if (frame.empty())
|
||||
{
|
||||
cap.release();
|
||||
cap.open(inputFile);
|
||||
cap >> frame;
|
||||
}
|
||||
|
@ -251,8 +251,7 @@ void cv::gpu::MOG2_GPU::operator()(const GpuMat& frame, GpuMat& fgmask, float le
|
||||
learningRate = learningRate >= 0.0f && nframes_ > 1 ? learningRate : 1.0f / std::min(2 * nframes_, history);
|
||||
CV_Assert(learningRate >= 0.0f);
|
||||
|
||||
if (learningRate > 0.0f)
|
||||
mog2_gpu(frame, frame.channels(), fgmask, bgmodelUsedModes_, weight_, variance_, mean_, learningRate, -learningRate * fCT, bShadowDetection, StreamAccessor::getStream(stream));
|
||||
mog2_gpu(frame, frame.channels(), fgmask, bgmodelUsedModes_, weight_, variance_, mean_, learningRate, -learningRate * fCT, bShadowDetection, StreamAccessor::getStream(stream));
|
||||
}
|
||||
|
||||
void cv::gpu::MOG2_GPU::getBackgroundImage(GpuMat& backgroundImage, Stream& stream) const
|
||||
|
@ -89,20 +89,45 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
const int yStart = blockIdx.y * (BLOCK_DIM_Y * PATCH_PER_BLOCK) + threadIdx.y;
|
||||
|
||||
//Upper halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(brd.at_low(yStart - (HALO_SIZE - j) * BLOCK_DIM_Y, src_col, src.step));
|
||||
if (blockIdx.y > 0)
|
||||
{
|
||||
//Upper halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(src(yStart - (HALO_SIZE - j) * BLOCK_DIM_Y, x));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Upper halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(brd.at_low(yStart - (HALO_SIZE - j) * BLOCK_DIM_Y, src_col, src.step));
|
||||
}
|
||||
|
||||
//Main data
|
||||
#pragma unroll
|
||||
for (int j = 0; j < PATCH_PER_BLOCK; ++j)
|
||||
smem[threadIdx.y + HALO_SIZE * BLOCK_DIM_Y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(brd.at_high(yStart + j * BLOCK_DIM_Y, src_col, src.step));
|
||||
if (blockIdx.y + 2 < gridDim.y)
|
||||
{
|
||||
//Main data
|
||||
#pragma unroll
|
||||
for (int j = 0; j < PATCH_PER_BLOCK; ++j)
|
||||
smem[threadIdx.y + HALO_SIZE * BLOCK_DIM_Y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(src(yStart + j * BLOCK_DIM_Y, x));
|
||||
|
||||
//Lower halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y + (PATCH_PER_BLOCK + HALO_SIZE) * BLOCK_DIM_Y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(brd.at_high(yStart + (PATCH_PER_BLOCK + j) * BLOCK_DIM_Y, src_col, src.step));
|
||||
//Lower halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y + (PATCH_PER_BLOCK + HALO_SIZE) * BLOCK_DIM_Y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(src(yStart + (PATCH_PER_BLOCK + j) * BLOCK_DIM_Y, x));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Main data
|
||||
#pragma unroll
|
||||
for (int j = 0; j < PATCH_PER_BLOCK; ++j)
|
||||
smem[threadIdx.y + HALO_SIZE * BLOCK_DIM_Y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(brd.at_high(yStart + j * BLOCK_DIM_Y, src_col, src.step));
|
||||
|
||||
//Lower halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y + (PATCH_PER_BLOCK + HALO_SIZE) * BLOCK_DIM_Y + j * BLOCK_DIM_Y][threadIdx.x] = saturate_cast<sum_t>(brd.at_high(yStart + (PATCH_PER_BLOCK + j) * BLOCK_DIM_Y, src_col, src.step));
|
||||
}
|
||||
|
||||
__syncthreads();
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -40,7 +40,7 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "internal_shared.hpp"
|
||||
#include "opencv2/gpu/device/common.hpp"
|
||||
#include "opencv2/gpu/device/border_interpolate.hpp"
|
||||
#include "opencv2/gpu/device/vec_traits.hpp"
|
||||
#include "opencv2/gpu/device/vec_math.hpp"
|
||||
@ -50,57 +50,104 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
namespace imgproc
|
||||
{
|
||||
template <typename T, typename B> __global__ void pyrDown(const PtrStep<T> src, PtrStep<T> dst, const B b, int dst_cols)
|
||||
template <typename T, typename B> __global__ void pyrDown(const PtrStepSz<T> src, PtrStep<T> dst, const B b, int dst_cols)
|
||||
{
|
||||
typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type value_type;
|
||||
typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type work_t;
|
||||
|
||||
__shared__ work_t smem[256 + 4];
|
||||
|
||||
const int x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
const int y = blockIdx.y;
|
||||
|
||||
__shared__ value_type smem[256 + 4];
|
||||
const int src_y = 2 * y;
|
||||
|
||||
value_type sum;
|
||||
|
||||
const int src_y = 2*y;
|
||||
|
||||
sum = VecTraits<value_type>::all(0);
|
||||
|
||||
sum = sum + 0.0625f * b.at(src_y - 2, x, src.data, src.step);
|
||||
sum = sum + 0.25f * b.at(src_y - 1, x, src.data, src.step);
|
||||
sum = sum + 0.375f * b.at(src_y , x, src.data, src.step);
|
||||
sum = sum + 0.25f * b.at(src_y + 1, x, src.data, src.step);
|
||||
sum = sum + 0.0625f * b.at(src_y + 2, x, src.data, src.step);
|
||||
|
||||
smem[2 + threadIdx.x] = sum;
|
||||
|
||||
if (threadIdx.x < 2)
|
||||
if (src_y >= 2 && src_y < src.rows - 2 && x >= 2 && x < src.cols - 2)
|
||||
{
|
||||
const int left_x = x - 2;
|
||||
{
|
||||
work_t sum;
|
||||
|
||||
sum = VecTraits<value_type>::all(0);
|
||||
sum = 0.0625f * src(src_y - 2, x);
|
||||
sum = sum + 0.25f * src(src_y - 1, x);
|
||||
sum = sum + 0.375f * src(src_y , x);
|
||||
sum = sum + 0.25f * src(src_y + 1, x);
|
||||
sum = sum + 0.0625f * src(src_y + 2, x);
|
||||
|
||||
sum = sum + 0.0625f * b.at(src_y - 2, left_x, src.data, src.step);
|
||||
sum = sum + 0.25f * b.at(src_y - 1, left_x, src.data, src.step);
|
||||
sum = sum + 0.375f * b.at(src_y , left_x, src.data, src.step);
|
||||
sum = sum + 0.25f * b.at(src_y + 1, left_x, src.data, src.step);
|
||||
sum = sum + 0.0625f * b.at(src_y + 2, left_x, src.data, src.step);
|
||||
smem[2 + threadIdx.x] = sum;
|
||||
}
|
||||
|
||||
smem[threadIdx.x] = sum;
|
||||
if (threadIdx.x < 2)
|
||||
{
|
||||
const int left_x = x - 2;
|
||||
|
||||
work_t sum;
|
||||
|
||||
sum = 0.0625f * src(src_y - 2, left_x);
|
||||
sum = sum + 0.25f * src(src_y - 1, left_x);
|
||||
sum = sum + 0.375f * src(src_y , left_x);
|
||||
sum = sum + 0.25f * src(src_y + 1, left_x);
|
||||
sum = sum + 0.0625f * src(src_y + 2, left_x);
|
||||
|
||||
smem[threadIdx.x] = sum;
|
||||
}
|
||||
|
||||
if (threadIdx.x > 253)
|
||||
{
|
||||
const int right_x = x + 2;
|
||||
|
||||
work_t sum;
|
||||
|
||||
sum = 0.0625f * src(src_y - 2, right_x);
|
||||
sum = sum + 0.25f * src(src_y - 1, right_x);
|
||||
sum = sum + 0.375f * src(src_y , right_x);
|
||||
sum = sum + 0.25f * src(src_y + 1, right_x);
|
||||
sum = sum + 0.0625f * src(src_y + 2, right_x);
|
||||
|
||||
smem[4 + threadIdx.x] = sum;
|
||||
}
|
||||
}
|
||||
|
||||
if (threadIdx.x > 253)
|
||||
else
|
||||
{
|
||||
const int right_x = x + 2;
|
||||
{
|
||||
work_t sum;
|
||||
|
||||
sum = VecTraits<value_type>::all(0);
|
||||
sum = 0.0625f * src(b.idx_row_low (src_y - 2), b.idx_col_high(x));
|
||||
sum = sum + 0.25f * src(b.idx_row_low (src_y - 1), b.idx_col_high(x));
|
||||
sum = sum + 0.375f * src(src_y , b.idx_col_high(x));
|
||||
sum = sum + 0.25f * src(b.idx_row_high(src_y + 1), b.idx_col_high(x));
|
||||
sum = sum + 0.0625f * src(b.idx_row_high(src_y + 2), b.idx_col_high(x));
|
||||
|
||||
sum = sum + 0.0625f * b.at(src_y - 2, right_x, src.data, src.step);
|
||||
sum = sum + 0.25f * b.at(src_y - 1, right_x, src.data, src.step);
|
||||
sum = sum + 0.375f * b.at(src_y , right_x, src.data, src.step);
|
||||
sum = sum + 0.25f * b.at(src_y + 1, right_x, src.data, src.step);
|
||||
sum = sum + 0.0625f * b.at(src_y + 2, right_x, src.data, src.step);
|
||||
smem[2 + threadIdx.x] = sum;
|
||||
}
|
||||
|
||||
smem[4 + threadIdx.x] = sum;
|
||||
if (threadIdx.x < 2)
|
||||
{
|
||||
const int left_x = x - 2;
|
||||
|
||||
work_t sum;
|
||||
|
||||
sum = 0.0625f * src(b.idx_row_low (src_y - 2), b.idx_col(left_x));
|
||||
sum = sum + 0.25f * src(b.idx_row_low (src_y - 1), b.idx_col(left_x));
|
||||
sum = sum + 0.375f * src(src_y , b.idx_col(left_x));
|
||||
sum = sum + 0.25f * src(b.idx_row_high(src_y + 1), b.idx_col(left_x));
|
||||
sum = sum + 0.0625f * src(b.idx_row_high(src_y + 2), b.idx_col(left_x));
|
||||
|
||||
smem[threadIdx.x] = sum;
|
||||
}
|
||||
|
||||
if (threadIdx.x > 253)
|
||||
{
|
||||
const int right_x = x + 2;
|
||||
|
||||
work_t sum;
|
||||
|
||||
sum = 0.0625f * src(b.idx_row_low (src_y - 2), b.idx_col_high(right_x));
|
||||
sum = sum + 0.25f * src(b.idx_row_low (src_y - 1), b.idx_col_high(right_x));
|
||||
sum = sum + 0.375f * src(src_y , b.idx_col_high(right_x));
|
||||
sum = sum + 0.25f * src(b.idx_row_high(src_y + 1), b.idx_col_high(right_x));
|
||||
sum = sum + 0.0625f * src(b.idx_row_high(src_y + 2), b.idx_col_high(right_x));
|
||||
|
||||
smem[4 + threadIdx.x] = sum;
|
||||
}
|
||||
}
|
||||
|
||||
__syncthreads();
|
||||
@ -109,9 +156,9 @@ namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
const int tid2 = threadIdx.x * 2;
|
||||
|
||||
sum = VecTraits<value_type>::all(0);
|
||||
work_t sum;
|
||||
|
||||
sum = sum + 0.0625f * smem[2 + tid2 - 2];
|
||||
sum = 0.0625f * smem[2 + tid2 - 2];
|
||||
sum = sum + 0.25f * smem[2 + tid2 - 1];
|
||||
sum = sum + 0.375f * smem[2 + tid2 ];
|
||||
sum = sum + 0.25f * smem[2 + tid2 + 1];
|
||||
|
@ -89,20 +89,45 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
const int xStart = blockIdx.x * (PATCH_PER_BLOCK * BLOCK_DIM_X) + threadIdx.x;
|
||||
|
||||
//Load left halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + j * BLOCK_DIM_X] = saturate_cast<sum_t>(brd.at_low(xStart - (HALO_SIZE - j) * BLOCK_DIM_X, src_row));
|
||||
if (blockIdx.x > 0)
|
||||
{
|
||||
//Load left halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + j * BLOCK_DIM_X] = saturate_cast<sum_t>(src_row[xStart - (HALO_SIZE - j) * BLOCK_DIM_X]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Load left halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + j * BLOCK_DIM_X] = saturate_cast<sum_t>(brd.at_low(xStart - (HALO_SIZE - j) * BLOCK_DIM_X, src_row));
|
||||
}
|
||||
|
||||
//Load main data
|
||||
#pragma unroll
|
||||
for (int j = 0; j < PATCH_PER_BLOCK; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + HALO_SIZE * BLOCK_DIM_X + j * BLOCK_DIM_X] = saturate_cast<sum_t>(brd.at_high(xStart + j * BLOCK_DIM_X, src_row));
|
||||
if (blockIdx.x + 2 < gridDim.x)
|
||||
{
|
||||
//Load main data
|
||||
#pragma unroll
|
||||
for (int j = 0; j < PATCH_PER_BLOCK; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + HALO_SIZE * BLOCK_DIM_X + j * BLOCK_DIM_X] = saturate_cast<sum_t>(src_row[xStart + j * BLOCK_DIM_X]);
|
||||
|
||||
//Load right halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + (PATCH_PER_BLOCK + HALO_SIZE) * BLOCK_DIM_X + j * BLOCK_DIM_X] = saturate_cast<sum_t>(brd.at_high(xStart + (PATCH_PER_BLOCK + j) * BLOCK_DIM_X, src_row));
|
||||
//Load right halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + (PATCH_PER_BLOCK + HALO_SIZE) * BLOCK_DIM_X + j * BLOCK_DIM_X] = saturate_cast<sum_t>(src_row[xStart + (PATCH_PER_BLOCK + j) * BLOCK_DIM_X]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//Load main data
|
||||
#pragma unroll
|
||||
for (int j = 0; j < PATCH_PER_BLOCK; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + HALO_SIZE * BLOCK_DIM_X + j * BLOCK_DIM_X] = saturate_cast<sum_t>(brd.at_high(xStart + j * BLOCK_DIM_X, src_row));
|
||||
|
||||
//Load right halo
|
||||
#pragma unroll
|
||||
for (int j = 0; j < HALO_SIZE; ++j)
|
||||
smem[threadIdx.y][threadIdx.x + (PATCH_PER_BLOCK + HALO_SIZE) * BLOCK_DIM_X + j * BLOCK_DIM_X] = saturate_cast<sum_t>(brd.at_high(xStart + (PATCH_PER_BLOCK + j) * BLOCK_DIM_X, src_row));
|
||||
}
|
||||
|
||||
__syncthreads();
|
||||
|
||||
|
@ -576,8 +576,10 @@ namespace
|
||||
else if (iterations > 1 && countNonZero(_kernel) == _kernel.rows * _kernel.cols)
|
||||
{
|
||||
anchor = Point(anchor.x * iterations, anchor.y * iterations);
|
||||
kernel = getStructuringElement(MORPH_RECT, Size(ksize.width + iterations * (ksize.width - 1),
|
||||
ksize.height + iterations * (ksize.height - 1)), anchor);
|
||||
kernel = getStructuringElement(MORPH_RECT,
|
||||
Size(ksize.width + (iterations - 1) * (ksize.width - 1),
|
||||
ksize.height + (iterations - 1) * (ksize.height - 1)),
|
||||
anchor);
|
||||
iterations = 1;
|
||||
}
|
||||
else
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1140,6 +1140,12 @@ namespace cv { namespace gpu { namespace device
|
||||
int sector = __float2int_rd(h);
|
||||
h -= sector;
|
||||
|
||||
if ( (unsigned)sector >= 6u )
|
||||
{
|
||||
sector = 0;
|
||||
h = 0.f;
|
||||
}
|
||||
|
||||
float tab[4];
|
||||
tab[0] = v;
|
||||
tab[1] = v * (1.f - s);
|
||||
|
@ -118,17 +118,28 @@ int main(int argc, char** argv)
|
||||
{
|
||||
try
|
||||
{
|
||||
CommandLineParser cmd(argc, (const char**)argv,
|
||||
"{ print_info_only | print_info_only | false | Print information about system and exit }"
|
||||
"{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }"
|
||||
"{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"
|
||||
);
|
||||
const std::string keys =
|
||||
"{ h help ? | | Print help}"
|
||||
"{ i info | | Print information about system and exit }"
|
||||
"{ device | -1 | Device on which tests will be executed (-1 means all devices) }"
|
||||
"{ nvtest_output_level | compact | NVidia test verbosity level (none, compact, full) }"
|
||||
;
|
||||
|
||||
CommandLineParser cmd(argc, (const char**)argv, keys);
|
||||
|
||||
if (cmd.has("help"))
|
||||
{
|
||||
cmd.printMessage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
printOsInfo();
|
||||
printCudaInfo();
|
||||
|
||||
if (cmd.get<bool>("print_info_only"))
|
||||
if (cmd.has("info"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
int device = cmd.get<int>("device");
|
||||
if (device < 0)
|
||||
|
@ -1,8 +1,6 @@
|
||||
#ifndef __main_test_nvidia_h__
|
||||
#define __main_test_nvidia_h__
|
||||
|
||||
#include <string>
|
||||
|
||||
enum OutputLevel
|
||||
{
|
||||
OutputLevelNone,
|
||||
|
256
modules/gpu/test/test_hough.cpp
Normal file
256
modules/gpu/test/test_hough.cpp
Normal file
@ -0,0 +1,256 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// Intel License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000, Intel Corporation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of Intel Corporation may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
namespace {
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// HoughLines
|
||||
|
||||
PARAM_TEST_CASE(HoughLines, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
||||
{
|
||||
static void generateLines(cv::Mat& img)
|
||||
{
|
||||
img.setTo(cv::Scalar::all(0));
|
||||
|
||||
cv::line(img, cv::Point(20, 0), cv::Point(20, img.rows), cv::Scalar::all(255));
|
||||
cv::line(img, cv::Point(0, 50), cv::Point(img.cols, 50), cv::Scalar::all(255));
|
||||
cv::line(img, cv::Point(0, 0), cv::Point(img.cols, img.rows), cv::Scalar::all(255));
|
||||
cv::line(img, cv::Point(img.cols, 0), cv::Point(0, img.rows), cv::Scalar::all(255));
|
||||
}
|
||||
|
||||
static void drawLines(cv::Mat& dst, const std::vector<cv::Vec2f>& lines)
|
||||
{
|
||||
dst.setTo(cv::Scalar::all(0));
|
||||
|
||||
for (size_t i = 0; i < lines.size(); ++i)
|
||||
{
|
||||
float rho = lines[i][0], theta = lines[i][1];
|
||||
cv::Point pt1, pt2;
|
||||
double a = std::cos(theta), b = std::sin(theta);
|
||||
double x0 = a*rho, y0 = b*rho;
|
||||
pt1.x = cvRound(x0 + 1000*(-b));
|
||||
pt1.y = cvRound(y0 + 1000*(a));
|
||||
pt2.x = cvRound(x0 - 1000*(-b));
|
||||
pt2.y = cvRound(y0 - 1000*(a));
|
||||
cv::line(dst, pt1, pt2, cv::Scalar::all(255));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(HoughLines, Accuracy)
|
||||
{
|
||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const cv::Size size = GET_PARAM(1);
|
||||
const bool useRoi = GET_PARAM(2);
|
||||
|
||||
const float rho = 1.0f;
|
||||
const float theta = 1.5f * CV_PI / 180.0f;
|
||||
const int threshold = 100;
|
||||
|
||||
cv::Mat src(size, CV_8UC1);
|
||||
generateLines(src);
|
||||
|
||||
cv::gpu::GpuMat d_lines;
|
||||
cv::gpu::HoughLines(loadMat(src, useRoi), d_lines, rho, theta, threshold);
|
||||
|
||||
std::vector<cv::Vec2f> lines;
|
||||
cv::gpu::HoughLinesDownload(d_lines, lines);
|
||||
|
||||
cv::Mat dst(size, CV_8UC1);
|
||||
drawLines(dst, lines);
|
||||
|
||||
ASSERT_MAT_NEAR(src, dst, 0.0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughLines, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// HoughCircles
|
||||
|
||||
PARAM_TEST_CASE(HoughCircles, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
||||
{
|
||||
static void drawCircles(cv::Mat& dst, const std::vector<cv::Vec3f>& circles, bool fill)
|
||||
{
|
||||
dst.setTo(cv::Scalar::all(0));
|
||||
|
||||
for (size_t i = 0; i < circles.size(); ++i)
|
||||
cv::circle(dst, cv::Point2f(circles[i][0], circles[i][1]), (int)circles[i][2], cv::Scalar::all(255), fill ? -1 : 1);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(HoughCircles, Accuracy)
|
||||
{
|
||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const cv::Size size = GET_PARAM(1);
|
||||
const bool useRoi = GET_PARAM(2);
|
||||
|
||||
const float dp = 2.0f;
|
||||
const float minDist = 10.0f;
|
||||
const int minRadius = 10;
|
||||
const int maxRadius = 20;
|
||||
const int cannyThreshold = 100;
|
||||
const int votesThreshold = 20;
|
||||
|
||||
std::vector<cv::Vec3f> circles_gold(4);
|
||||
circles_gold[0] = cv::Vec3i(20, 20, minRadius);
|
||||
circles_gold[1] = cv::Vec3i(90, 87, minRadius + 3);
|
||||
circles_gold[2] = cv::Vec3i(30, 70, minRadius + 8);
|
||||
circles_gold[3] = cv::Vec3i(80, 10, maxRadius);
|
||||
|
||||
cv::Mat src(size, CV_8UC1);
|
||||
drawCircles(src, circles_gold, true);
|
||||
|
||||
cv::gpu::GpuMat d_circles;
|
||||
cv::gpu::HoughCircles(loadMat(src, useRoi), d_circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
|
||||
|
||||
std::vector<cv::Vec3f> circles;
|
||||
cv::gpu::HoughCirclesDownload(d_circles, circles);
|
||||
|
||||
ASSERT_FALSE(circles.empty());
|
||||
|
||||
for (size_t i = 0; i < circles.size(); ++i)
|
||||
{
|
||||
cv::Vec3f cur = circles[i];
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (size_t j = 0; j < circles_gold.size(); ++j)
|
||||
{
|
||||
cv::Vec3f gold = circles_gold[j];
|
||||
|
||||
if (std::fabs(cur[0] - gold[0]) < minDist && std::fabs(cur[1] - gold[1]) < minDist && std::fabs(cur[2] - gold[2]) < minDist)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_TRUE(found);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughCircles, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// GeneralizedHough
|
||||
|
||||
PARAM_TEST_CASE(GeneralizedHough, cv::gpu::DeviceInfo, UseRoi)
|
||||
{
|
||||
};
|
||||
|
||||
TEST_P(GeneralizedHough, POSITION)
|
||||
{
|
||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const bool useRoi = GET_PARAM(1);
|
||||
|
||||
cv::Mat templ = readImage("../cv/shared/templ.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(templ.empty());
|
||||
|
||||
cv::Point templCenter(templ.cols / 2, templ.rows / 2);
|
||||
|
||||
const size_t gold_count = 3;
|
||||
cv::Point pos_gold[gold_count];
|
||||
pos_gold[0] = cv::Point(templCenter.x + 10, templCenter.y + 10);
|
||||
pos_gold[1] = cv::Point(2 * templCenter.x + 40, templCenter.y + 10);
|
||||
pos_gold[2] = cv::Point(2 * templCenter.x + 40, 2 * templCenter.y + 40);
|
||||
|
||||
cv::Mat image(templ.rows * 3, templ.cols * 3, CV_8UC1, cv::Scalar::all(0));
|
||||
for (size_t i = 0; i < gold_count; ++i)
|
||||
{
|
||||
cv::Rect rec(pos_gold[i].x - templCenter.x, pos_gold[i].y - templCenter.y, templ.cols, templ.rows);
|
||||
cv::Mat imageROI = image(rec);
|
||||
templ.copyTo(imageROI);
|
||||
}
|
||||
|
||||
cv::Ptr<cv::gpu::GeneralizedHough_GPU> hough = cv::gpu::GeneralizedHough_GPU::create(cv::GHT_POSITION);
|
||||
hough->set("votesThreshold", 200);
|
||||
|
||||
hough->setTemplate(loadMat(templ, useRoi));
|
||||
|
||||
cv::gpu::GpuMat d_pos;
|
||||
hough->detect(loadMat(image, useRoi), d_pos);
|
||||
|
||||
std::vector<cv::Vec4f> pos;
|
||||
hough->download(d_pos, pos);
|
||||
|
||||
ASSERT_EQ(gold_count, pos.size());
|
||||
|
||||
for (size_t i = 0; i < gold_count; ++i)
|
||||
{
|
||||
cv::Point gold = pos_gold[i];
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (size_t j = 0; j < pos.size(); ++j)
|
||||
{
|
||||
cv::Point2f p(pos[j][0], pos[j][1]);
|
||||
|
||||
if (::fabs(p.x - gold.x) < 2 && ::fabs(p.y - gold.y) < 2)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_TRUE(found);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, GeneralizedHough, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // HAVE_CUDA
|
@ -1126,142 +1126,6 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CornerMinEigen, testing::Combine(
|
||||
testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)),
|
||||
testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7))));
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// HoughLines
|
||||
|
||||
PARAM_TEST_CASE(HoughLines, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
||||
{
|
||||
static void generateLines(cv::Mat& img)
|
||||
{
|
||||
img.setTo(cv::Scalar::all(0));
|
||||
|
||||
cv::line(img, cv::Point(20, 0), cv::Point(20, img.rows), cv::Scalar::all(255));
|
||||
cv::line(img, cv::Point(0, 50), cv::Point(img.cols, 50), cv::Scalar::all(255));
|
||||
cv::line(img, cv::Point(0, 0), cv::Point(img.cols, img.rows), cv::Scalar::all(255));
|
||||
cv::line(img, cv::Point(img.cols, 0), cv::Point(0, img.rows), cv::Scalar::all(255));
|
||||
}
|
||||
|
||||
static void drawLines(cv::Mat& dst, const std::vector<cv::Vec2f>& lines)
|
||||
{
|
||||
dst.setTo(cv::Scalar::all(0));
|
||||
|
||||
for (size_t i = 0; i < lines.size(); ++i)
|
||||
{
|
||||
float rho = lines[i][0], theta = lines[i][1];
|
||||
cv::Point pt1, pt2;
|
||||
double a = std::cos(theta), b = std::sin(theta);
|
||||
double x0 = a*rho, y0 = b*rho;
|
||||
pt1.x = cvRound(x0 + 1000*(-b));
|
||||
pt1.y = cvRound(y0 + 1000*(a));
|
||||
pt2.x = cvRound(x0 - 1000*(-b));
|
||||
pt2.y = cvRound(y0 - 1000*(a));
|
||||
cv::line(dst, pt1, pt2, cv::Scalar::all(255));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(HoughLines, Accuracy)
|
||||
{
|
||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const cv::Size size = GET_PARAM(1);
|
||||
const bool useRoi = GET_PARAM(2);
|
||||
|
||||
const float rho = 1.0f;
|
||||
const float theta = 1.5f * CV_PI / 180.0f;
|
||||
const int threshold = 100;
|
||||
|
||||
cv::Mat src(size, CV_8UC1);
|
||||
generateLines(src);
|
||||
|
||||
cv::gpu::GpuMat d_lines;
|
||||
cv::gpu::HoughLines(loadMat(src, useRoi), d_lines, rho, theta, threshold);
|
||||
|
||||
std::vector<cv::Vec2f> lines;
|
||||
cv::gpu::HoughLinesDownload(d_lines, lines);
|
||||
|
||||
cv::Mat dst(size, CV_8UC1);
|
||||
drawLines(dst, lines);
|
||||
|
||||
ASSERT_MAT_NEAR(src, dst, 0.0);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughLines, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// HoughCircles
|
||||
|
||||
PARAM_TEST_CASE(HoughCircles, cv::gpu::DeviceInfo, cv::Size, UseRoi)
|
||||
{
|
||||
static void drawCircles(cv::Mat& dst, const std::vector<cv::Vec3f>& circles, bool fill)
|
||||
{
|
||||
dst.setTo(cv::Scalar::all(0));
|
||||
|
||||
for (size_t i = 0; i < circles.size(); ++i)
|
||||
cv::circle(dst, cv::Point2f(circles[i][0], circles[i][1]), (int)circles[i][2], cv::Scalar::all(255), fill ? -1 : 1);
|
||||
}
|
||||
};
|
||||
|
||||
TEST_P(HoughCircles, Accuracy)
|
||||
{
|
||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
const cv::Size size = GET_PARAM(1);
|
||||
const bool useRoi = GET_PARAM(2);
|
||||
|
||||
const float dp = 2.0f;
|
||||
const float minDist = 10.0f;
|
||||
const int minRadius = 10;
|
||||
const int maxRadius = 20;
|
||||
const int cannyThreshold = 100;
|
||||
const int votesThreshold = 20;
|
||||
|
||||
std::vector<cv::Vec3f> circles_gold(4);
|
||||
circles_gold[0] = cv::Vec3i(20, 20, minRadius);
|
||||
circles_gold[1] = cv::Vec3i(90, 87, minRadius + 3);
|
||||
circles_gold[2] = cv::Vec3i(30, 70, minRadius + 8);
|
||||
circles_gold[3] = cv::Vec3i(80, 10, maxRadius);
|
||||
|
||||
cv::Mat src(size, CV_8UC1);
|
||||
drawCircles(src, circles_gold, true);
|
||||
|
||||
cv::gpu::GpuMat d_circles;
|
||||
cv::gpu::HoughCircles(loadMat(src, useRoi), d_circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
|
||||
|
||||
std::vector<cv::Vec3f> circles;
|
||||
cv::gpu::HoughCirclesDownload(d_circles, circles);
|
||||
|
||||
ASSERT_FALSE(circles.empty());
|
||||
|
||||
for (size_t i = 0; i < circles.size(); ++i)
|
||||
{
|
||||
cv::Vec3f cur = circles[i];
|
||||
|
||||
bool found = false;
|
||||
|
||||
for (size_t j = 0; j < circles_gold.size(); ++j)
|
||||
{
|
||||
cv::Vec3f gold = circles_gold[j];
|
||||
|
||||
if (std::fabs(cur[0] - gold[0]) < minDist && std::fabs(cur[1] - gold[1]) < minDist && std::fabs(cur[2] - gold[2]) < minDist)
|
||||
{
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ASSERT_TRUE(found);
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughCircles, testing::Combine(
|
||||
ALL_DEVICES,
|
||||
DIFFERENT_SIZES,
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
} // namespace
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
|
@ -41,13 +41,13 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
OutputLevel nvidiaTestOutputLevel = OutputLevelCompact;
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
using namespace cvtest;
|
||||
using namespace testing;
|
||||
|
||||
OutputLevel nvidiaTestOutputLevel = OutputLevelCompact;
|
||||
|
||||
struct NVidiaTest : TestWithParam<cv::gpu::DeviceInfo>
|
||||
{
|
||||
cv::gpu::DeviceInfo devInfo;
|
||||
|
@ -61,24 +61,24 @@
|
||||
|
||||
#include "cvconfig.h"
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/video/video.hpp"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
|
||||
#include "utility.hpp"
|
||||
#include "interpolation.hpp"
|
||||
#include "main_test_nvidia.h"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
#include <cuda.h>
|
||||
#include <cuda_runtime.h>
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/video/video.hpp"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
#include "opencv2/legacy/legacy.hpp"
|
||||
|
||||
#include "utility.hpp"
|
||||
#include "interpolation.hpp"
|
||||
#include "main_test_nvidia.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -41,6 +41,8 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#ifdef HAVE_CUDA
|
||||
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
@ -418,3 +420,5 @@ void showDiff(InputArray gold_, InputArray actual_, double eps)
|
||||
|
||||
waitKey();
|
||||
}
|
||||
|
||||
#endif // HAVE_CUDA
|
||||
|
@ -42,14 +42,6 @@
|
||||
#ifndef __OPENCV_TEST_UTILITY_HPP__
|
||||
#define __OPENCV_TEST_UTILITY_HPP__
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/highgui/highgui.hpp"
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/ts/ts.hpp"
|
||||
#include "opencv2/ts/ts_perf.hpp"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// random generators
|
||||
|
||||
|
@ -176,6 +176,7 @@ enum
|
||||
IMWRITE_JPEG_QUALITY =1,
|
||||
IMWRITE_PNG_COMPRESSION =16,
|
||||
IMWRITE_PNG_STRATEGY =17,
|
||||
IMWRITE_PNG_BILEVEL =18,
|
||||
IMWRITE_PNG_STRATEGY_DEFAULT =0,
|
||||
IMWRITE_PNG_STRATEGY_FILTERED =1,
|
||||
IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2,
|
||||
|
@ -217,6 +217,7 @@ enum
|
||||
CV_IMWRITE_JPEG_QUALITY =1,
|
||||
CV_IMWRITE_PNG_COMPRESSION =16,
|
||||
CV_IMWRITE_PNG_STRATEGY =17,
|
||||
CV_IMWRITE_PNG_BILEVEL =18,
|
||||
CV_IMWRITE_PNG_STRATEGY_DEFAULT =0,
|
||||
CV_IMWRITE_PNG_STRATEGY_FILTERED =1,
|
||||
CV_IMWRITE_PNG_STRATEGY_HUFFMAN_ONLY =2,
|
||||
|
@ -448,13 +448,15 @@ VideoCapture::~VideoCapture()
|
||||
|
||||
bool VideoCapture::open(const string& filename)
|
||||
{
|
||||
cap = cvCreateFileCapture(filename.c_str());
|
||||
if (!isOpened())
|
||||
cap = cvCreateFileCapture(filename.c_str());
|
||||
return isOpened();
|
||||
}
|
||||
|
||||
bool VideoCapture::open(int device)
|
||||
{
|
||||
cap = cvCreateCameraCapture(device);
|
||||
if (!isOpened())
|
||||
cap = cvCreateCameraCapture(device);
|
||||
return isOpened();
|
||||
}
|
||||
|
||||
|
@ -203,6 +203,7 @@ CvCapture_Android::CvCapture_Android(int cameraId)
|
||||
m_frameFormat = noformat;
|
||||
|
||||
//try connect to camera
|
||||
LOGD("CvCapture_Android::CvCapture_Android(%i)", cameraId);
|
||||
m_activity = new HighguiAndroidCameraActivity(this);
|
||||
|
||||
if (m_activity == 0) return;
|
||||
@ -328,7 +329,7 @@ bool CvCapture_Android::setProperty( int propIdx, double propValue )
|
||||
break;
|
||||
default:
|
||||
CV_Error( CV_StsOutOfRange, "Failed attempt to SET unsupported camera property." );
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
if (propIdx != CV_CAP_PROP_AUTOGRAB) {// property for highgui class CvCapture_Android only
|
||||
@ -353,10 +354,10 @@ bool CvCapture_Android::grabFrame()
|
||||
{
|
||||
m_activity->applyProperties();
|
||||
m_CameraParamsChanged = false;
|
||||
m_dataState= CVCAPTURE_ANDROID_STATE_NO_FRAME;//we will wait new frame
|
||||
m_dataState = CVCAPTURE_ANDROID_STATE_NO_FRAME;//we will wait new frame
|
||||
}
|
||||
|
||||
if (m_dataState!=CVCAPTURE_ANDROID_STATE_HAS_NEW_FRAME_UNGRABBED)
|
||||
if (m_dataState != CVCAPTURE_ANDROID_STATE_HAS_NEW_FRAME_UNGRABBED)
|
||||
{
|
||||
m_waitingNextFrame = true;
|
||||
pthread_cond_wait(&m_nextFrameCond, &m_nextFrameMutex);
|
||||
|
@ -183,7 +183,7 @@ bool CvCapture_GStreamer::grabFrame()
|
||||
IplImage * CvCapture_GStreamer::retrieveFrame(int)
|
||||
{
|
||||
if(!buffer)
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
if(!frame) {
|
||||
gint height, width;
|
||||
@ -193,7 +193,7 @@ IplImage * CvCapture_GStreamer::retrieveFrame(int)
|
||||
|
||||
if(!gst_structure_get_int(structure, "width", &width) ||
|
||||
!gst_structure_get_int(structure, "height", &height))
|
||||
return false;
|
||||
return 0;
|
||||
|
||||
frame = cvCreateImageHeader(cvSize(width, height), IPL_DEPTH_8U, 3);
|
||||
gst_caps_unref(buff_caps);
|
||||
@ -572,7 +572,7 @@ CvVideoWriter* cvCreateVideoWriter_GStreamer(const char* filename, int fourcc, d
|
||||
return wrt;
|
||||
|
||||
delete wrt;
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
void CvCapture_GStreamer::close()
|
||||
@ -746,5 +746,5 @@ CvCapture* cvCreateCapture_GStreamer(int type, const char* filename )
|
||||
return capture;
|
||||
|
||||
delete capture;
|
||||
return false;
|
||||
return 0;
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user