merge with origin
12
3rdparty/libtiff/tif_config.h.cmakein
vendored
@ -54,7 +54,7 @@
|
||||
|
||||
/* Native cpu byte order: 1 if big-endian (Motorola) or 0 if little-endian
|
||||
(Intel) */
|
||||
#define HOST_BIGENDIAN 0
|
||||
#define HOST_BIGENDIAN @WORDS_BIGENDIAN@
|
||||
|
||||
/* Set the native cpu bit order (FILLORDER_LSB2MSB or FILLORDER_MSB2LSB) */
|
||||
#define HOST_FILLORDER FILLORDER_LSB2MSB
|
||||
@ -156,15 +156,7 @@
|
||||
|
||||
/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
|
||||
significant byte first (like Motorola and SPARC, unlike Intel). */
|
||||
#if defined AC_APPLE_UNIVERSAL_BUILD
|
||||
# if defined __BIG_ENDIAN__
|
||||
# define WORDS_BIGENDIAN 1
|
||||
# endif
|
||||
#else
|
||||
# ifndef WORDS_BIGENDIAN
|
||||
/* # undef WORDS_BIGENDIAN */
|
||||
# endif
|
||||
#endif
|
||||
#cmakedefine WORDS_BIGENDIAN 1
|
||||
|
||||
/* Support Deflate compression */
|
||||
#define ZIP_SUPPORT 1
|
||||
|
@ -128,6 +128,7 @@ OCV_OPTION(WITH_1394 "Include IEEE1394 support" ON
|
||||
OCV_OPTION(WITH_AVFOUNDATION "Use AVFoundation for Video I/O" ON IF IOS)
|
||||
OCV_OPTION(WITH_CARBON "Use Carbon for UI instead of Cocoa" OFF IF APPLE )
|
||||
OCV_OPTION(WITH_CUDA "Include NVidia Cuda Runtime support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT IOS) )
|
||||
OCV_OPTION(WITH_VTK "Include VTK library support (and build opencv_viz module eiher)" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_CUFFT "Include NVidia Cuda Fast Fourier Transform (FFT) library support" ON IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT IOS) )
|
||||
OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BLAS) library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT IOS) )
|
||||
OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" OFF IF (CMAKE_VERSION VERSION_GREATER "2.8" AND NOT ANDROID AND NOT IOS AND NOT APPLE) )
|
||||
@ -141,7 +142,7 @@ OCV_OPTION(WITH_IPP "Include Intel IPP support" OFF
|
||||
OCV_OPTION(WITH_JASPER "Include JPEG2K support" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_JPEG "Include JPEG support" ON)
|
||||
OCV_OPTION(WITH_OPENEXR "Include ILM support via OpenEXR" ON IF (NOT IOS) )
|
||||
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID AND NOT APPLE) )
|
||||
OCV_OPTION(WITH_OPENGL "Include OpenGL support" OFF IF (NOT ANDROID) )
|
||||
OCV_OPTION(WITH_OPENNI "Include OpenNI support" OFF IF (NOT ANDROID AND NOT IOS) )
|
||||
OCV_OPTION(WITH_PNG "Include PNG support" ON)
|
||||
OCV_OPTION(WITH_PVAPI "Include Prosilica GigE support" ON IF (NOT ANDROID AND NOT IOS) )
|
||||
@ -197,7 +198,7 @@ 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_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) )
|
||||
|
||||
OCV_OPTION(INSTALL_TESTS "Install accuracy and performance test binaries and test data" OFF)
|
||||
|
||||
# OpenCV build options
|
||||
# ===================================================
|
||||
@ -205,6 +206,7 @@ OCV_OPTION(ENABLE_DYNAMIC_CUDA "Enabled dynamic CUDA linkage"
|
||||
OCV_OPTION(ENABLE_PRECOMPILED_HEADERS "Use precompiled headers" ON IF (NOT IOS) )
|
||||
OCV_OPTION(ENABLE_SOLUTION_FOLDERS "Solution folder in Visual Studio or in other IDEs" (MSVC_IDE OR CMAKE_GENERATOR MATCHES Xcode) IF (CMAKE_VERSION VERSION_GREATER "2.8.0") )
|
||||
OCV_OPTION(ENABLE_PROFILING "Enable profiling in the GCC compiler (Add flags: -g -pg)" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_COVERAGE "Enable coverage collection with GCov" OFF IF CMAKE_COMPILER_IS_GNUCXX )
|
||||
OCV_OPTION(ENABLE_OMIT_FRAME_POINTER "Enable -fomit-frame-pointer for GCC" ON IF CMAKE_COMPILER_IS_GNUCXX AND NOT (APPLE AND CMAKE_COMPILER_IS_CLANGCXX) )
|
||||
OCV_OPTION(ENABLE_POWERPC "Enable PowerPC for GCC" ON IF (CMAKE_COMPILER_IS_GNUCXX AND CMAKE_SYSTEM_PROCESSOR MATCHES powerpc.*) )
|
||||
OCV_OPTION(ENABLE_FAST_MATH "Enable -ffast-math (not recommended for GCC 4.6.x)" OFF IF (CMAKE_COMPILER_IS_GNUCXX AND (X86 OR X86_64)) )
|
||||
@ -268,13 +270,27 @@ if(WIN32)
|
||||
message(STATUS "Can't detect runtime and/or arch")
|
||||
set(OpenCV_INSTALL_BINARIES_PREFIX "")
|
||||
endif()
|
||||
elseif(ANDROID)
|
||||
set(OpenCV_INSTALL_BINARIES_PREFIX "sdk/native/")
|
||||
else()
|
||||
set(OpenCV_INSTALL_BINARIES_PREFIX "")
|
||||
endif()
|
||||
|
||||
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples")
|
||||
if(ANDROID)
|
||||
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples/${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
set(OPENCV_SAMPLES_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}samples")
|
||||
endif()
|
||||
|
||||
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin")
|
||||
if(ANDROID)
|
||||
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin/${ANDROID_NDK_ABI_NAME}")
|
||||
else()
|
||||
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin")
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_TEST_INSTALL_PATH)
|
||||
set(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
endif()
|
||||
|
||||
if(ANDROID)
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib/${ANDROID_NDK_ABI_NAME}")
|
||||
@ -283,6 +299,7 @@ if(ANDROID)
|
||||
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(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native)
|
||||
else()
|
||||
set(LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/lib")
|
||||
set(3P_LIBRARY_OUTPUT_PATH "${OpenCV_BINARY_DIR}/3rdparty/lib${LIB_SUFFIX}")
|
||||
@ -293,9 +310,11 @@ else()
|
||||
set(OPENCV_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}lib${LIB_SUFFIX}")
|
||||
endif()
|
||||
set(OPENCV_3P_LIB_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}staticlib${LIB_SUFFIX}")
|
||||
set(OPENCV_SAMPLES_SRC_INSTALL_PATH samples/native)
|
||||
else()
|
||||
set(OPENCV_LIB_INSTALL_PATH lib${LIB_SUFFIX})
|
||||
set(OPENCV_3P_LIB_INSTALL_PATH share/OpenCV/3rdparty/${OPENCV_LIB_INSTALL_PATH})
|
||||
set(OPENCV_SAMPLES_SRC_INSTALL_PATH share/OpenCV/samples)
|
||||
endif()
|
||||
set(OPENCV_INCLUDE_INSTALL_PATH "include")
|
||||
|
||||
@ -426,6 +445,12 @@ endif()
|
||||
include(cmake/OpenCVPCHSupport.cmake)
|
||||
include(cmake/OpenCVModule.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect endianness of build platform
|
||||
# ----------------------------------------------------------------------------
|
||||
include(TestBigEndian)
|
||||
test_big_endian(WORDS_BIGENDIAN)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Detect 3rd-party libraries
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -471,6 +496,9 @@ if(WITH_OPENCL)
|
||||
include(cmake/OpenCVDetectOpenCL.cmake)
|
||||
endif()
|
||||
|
||||
# --- VTK support ---
|
||||
include(cmake/OpenCVDetectVTK.cmake)
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Add CUDA libraries (needed for apps/tools, samples)
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -558,6 +586,49 @@ include(cmake/OpenCVGenConfig.cmake)
|
||||
# Generate Info.plist for the IOS framework
|
||||
include(cmake/OpenCVGenInfoPlist.cmake)
|
||||
|
||||
# Generate environment setup file
|
||||
if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX)
|
||||
if(ANDROID)
|
||||
get_filename_component(TEST_PATH ${OPENCV_TEST_INSTALL_PATH} DIRECTORY)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_run_all_tests_android.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT tests)
|
||||
else()
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_testing.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/opencv_testing.sh"
|
||||
DESTINATION /etc/profile.d/ COMPONENT tests)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/cmake/templates/opencv_run_all_tests_unix.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(PROGRAMS "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_README_FILE)
|
||||
if(ANDROID)
|
||||
set(OPENCV_README_FILE ${CMAKE_CURRENT_SOURCE_DIR}/platforms/android/README.android)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_LICENSE_FILE)
|
||||
set(OPENCV_LICENSE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE)
|
||||
endif()
|
||||
|
||||
# for UNIX it does not make sense as LICENSE and readme will be part of the package automatically
|
||||
if(ANDROID OR NOT UNIX)
|
||||
install(FILES ${OPENCV_LICENSE_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT libs)
|
||||
if(OPENCV_README_FILE)
|
||||
install(FILES ${OPENCV_README_FILE}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ
|
||||
DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT libs)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
# Summary:
|
||||
# ----------------------------------------------------------------------------
|
||||
@ -705,6 +776,7 @@ else()
|
||||
endif()
|
||||
|
||||
status(" OpenGL support:" HAVE_OPENGL THEN "YES (${OPENGL_LIBRARIES})" ELSE NO)
|
||||
status(" VTK support:" HAVE_VTK THEN "YES (ver ${VTK_VERSION})" ELSE NO)
|
||||
|
||||
# ========================== MEDIA IO ==========================
|
||||
status("")
|
||||
|
@ -1,5 +1,7 @@
|
||||
### OpenCV: Open Source Computer Vision Library
|
||||
|
||||
[](https://www.gittip.com/OpenCV/)
|
||||
|
||||
#### Resources
|
||||
|
||||
* Homepage: <http://opencv.org>
|
||||
@ -18,6 +20,3 @@ Summary of guidelines:
|
||||
* Include tests and documentation;
|
||||
* Clean up "oops" commits before submitting;
|
||||
* Follow the coding style guide.
|
||||
|
||||
[](https://www.gittip.com/OpenCV/)
|
||||
[](https://www.paypal.com/cgi-bin/webscr?item_name=Donation+to+OpenCV&cmd=_donations&business=accountant%40opencv.org)
|
@ -187,6 +187,11 @@ if(CMAKE_COMPILER_IS_GNUCXX)
|
||||
add_extra_compiler_option(-ffunction-sections)
|
||||
endif()
|
||||
|
||||
if(ENABLE_COVERAGE)
|
||||
set(OPENCV_EXTRA_C_FLAGS "${OPENCV_EXTRA_C_FLAGS} --coverage")
|
||||
set(OPENCV_EXTRA_CXX_FLAGS "${OPENCV_EXTRA_CXX_FLAGS} --coverage")
|
||||
endif()
|
||||
|
||||
set(OPENCV_EXTRA_FLAGS_RELEASE "${OPENCV_EXTRA_FLAGS_RELEASE} -DNDEBUG")
|
||||
set(OPENCV_EXTRA_FLAGS_DEBUG "${OPENCV_EXTRA_FLAGS_DEBUG} -O0 -DDEBUG -D_DEBUG")
|
||||
endif()
|
||||
|
@ -180,7 +180,7 @@ unset(__android_project_chain CACHE)
|
||||
# add_android_project(target_name ${path} NATIVE_DEPS opencv_core LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11)
|
||||
macro(add_android_project target path)
|
||||
# parse arguments
|
||||
set(android_proj_arglist NATIVE_DEPS LIBRARY_DEPS SDK_TARGET IGNORE_JAVA IGNORE_MANIFEST)
|
||||
set(android_proj_arglist NATIVE_DEPS LIBRARY_DEPS SDK_TARGET IGNORE_JAVA IGNORE_MANIFEST EMBED_CUDA FORCE_EMBED_OPENCV)
|
||||
set(__varname "android_proj_")
|
||||
foreach(v ${android_proj_arglist})
|
||||
set(${__varname}${v} "")
|
||||
@ -303,6 +303,46 @@ macro(add_android_project target path)
|
||||
add_custom_command(TARGET ${JNI_LIB_NAME} POST_BUILD COMMAND ${CMAKE_STRIP} --strip-unneeded "${android_proj_jni_location}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# copy opencv_java, tbb if it is shared and dynamicuda if present if FORCE_EMBED_OPENCV flag is set
|
||||
if(android_proj_FORCE_EMBED_OPENCV)
|
||||
set(native_deps ${android_proj_NATIVE_DEPS})
|
||||
# filter out gpu module as it is always static library on Android
|
||||
list(REMOVE_ITEM native_deps "opencv_gpu")
|
||||
if(ENABLE_DYNAMIC_CUDA)
|
||||
list(APPEND native_deps "opencv_dynamicuda")
|
||||
endif()
|
||||
foreach(lib ${native_deps})
|
||||
get_property(f TARGET ${lib} PROPERTY LOCATION)
|
||||
get_filename_component(f_name ${f} NAME)
|
||||
add_custom_command(
|
||||
OUTPUT "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f_name}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${f}" "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f_name}"
|
||||
DEPENDS "${lib}" VERBATIM
|
||||
COMMENT "Embedding ${f}")
|
||||
list(APPEND android_proj_file_deps "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f_name}")
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# copy all needed CUDA libs to project if EMBED_CUDA flag is present
|
||||
if(android_proj_EMBED_CUDA)
|
||||
set(android_proj_culibs ${CUDA_npp_LIBRARY} ${CUDA_LIBRARIES})
|
||||
if(HAVE_CUFFT)
|
||||
list(INSERT android_proj_culibs 0 ${CUDA_cufft_LIBRARY})
|
||||
endif()
|
||||
if(HAVE_CUBLAS)
|
||||
list(INSERT android_proj_culibs 0 ${CUDA_cublas_LIBRARY})
|
||||
endif()
|
||||
foreach(lib ${android_proj_culibs})
|
||||
get_filename_component(f "${lib}" NAME)
|
||||
add_custom_command(
|
||||
OUTPUT "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f}"
|
||||
COMMAND ${CMAKE_COMMAND} -E copy "${lib}" "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f}"
|
||||
DEPENDS "${lib}" VERBATIM
|
||||
COMMENT "Embedding ${f}")
|
||||
list(APPEND android_proj_file_deps "${android_proj_bin_dir}/libs/${ANDROID_NDK_ABI_NAME}/${f}")
|
||||
endforeach()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# build java part
|
||||
@ -365,7 +405,7 @@ macro(add_android_project target path)
|
||||
endif()
|
||||
install(CODE "EXECUTE_PROCESS(COMMAND ${ANDROID_EXECUTABLE} --silent update project --path . --target \"${android_proj_sdk_target}\" --name \"${target}\" ${inst_lib_opt}
|
||||
WORKING_DIRECTORY \"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/samples/${sample_dir}\"
|
||||
)" COMPONENT dev)
|
||||
)" COMPONENT samples)
|
||||
#empty 'gen'
|
||||
install(CODE "MAKE_DIRECTORY(\"\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/samples/${sample_dir}/gen\")" COMPONENT samples)
|
||||
endif()
|
||||
|
@ -180,6 +180,9 @@ if(CUDA_FOUND)
|
||||
# we remove -Wsign-promo as it generates warnings under linux
|
||||
string(REPLACE "-Wsign-promo" "" ${var} "${${var}}")
|
||||
|
||||
# we remove -Wno-sign-promo as it generates warnings under linux
|
||||
string(REPLACE "-Wno-sign-promo" "" ${var} "${${var}}")
|
||||
|
||||
# we remove -Wno-delete-non-virtual-dtor because it's used for C++ compiler
|
||||
# but NVCC uses C compiler by default
|
||||
string(REPLACE "-Wno-delete-non-virtual-dtor" "" ${var} "${${var}}")
|
||||
|
26
cmake/OpenCVDetectVTK.cmake
Normal file
@ -0,0 +1,26 @@
|
||||
if(NOT WITH_VTK OR ANDROID OR IOS)
|
||||
return()
|
||||
endif()
|
||||
|
||||
if (HAVE_QT5)
|
||||
message(STATUS "VTK is disabled because OpenCV is linked with Q5. Some VTK disributives are compiled with Q4 and therefore can't be linked together Qt5.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
find_package(VTK 6.0 QUIET COMPONENTS vtkRenderingCore vtkInteractionWidgets vtkInteractionStyle vtkIOLegacy vtkIOPLY vtkRenderingFreeType vtkRenderingLOD vtkFiltersTexture vtkIOExport NO_MODULE)
|
||||
|
||||
if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
|
||||
find_package(VTK 5.10 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
|
||||
endif()
|
||||
|
||||
if(NOT DEFINED VTK_FOUND OR NOT VTK_FOUND)
|
||||
find_package(VTK 5.8 QUIET COMPONENTS vtkCommon vtkFiltering vtkRendering vtkWidgets vtkImaging NO_MODULE)
|
||||
endif()
|
||||
|
||||
if(VTK_FOUND)
|
||||
set(HAVE_VTK ON)
|
||||
message(STATUS "Found VTK ver. ${VTK_VERSION} (usefile: ${VTK_USE_FILE})")
|
||||
else()
|
||||
set(HAVE_VTK OFF)
|
||||
message(STATUS "VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or set $VTK_DIR enviroment variable to VTK install subdirectory with VTKConfig.cmake file (for windows)")
|
||||
endif()
|
@ -4,7 +4,7 @@
|
||||
CONFIGURE_FILE(
|
||||
"${OpenCV_SOURCE_DIR}/cmake/templates/cmake_uninstall.cmake.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
|
||||
IMMEDIATE @ONLY)
|
||||
@ONLY)
|
||||
|
||||
ADD_CUSTOM_TARGET(uninstall "${CMAKE_COMMAND}" -P "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake")
|
||||
if(ENABLE_SOLUTION_FOLDERS)
|
||||
|
@ -163,9 +163,16 @@ function(set_ipp_new_libraries _LATEST_VERSION)
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCV}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPI}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPS}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX}
|
||||
PARENT_SCOPE)
|
||||
${IPP_LIB_PREFIX}${IPP_PREFIX}${IPPCORE}${IPP_SUFFIX}${IPP_LIB_SUFFIX})
|
||||
|
||||
if (UNIX)
|
||||
set(IPP_LIBRARIES
|
||||
${IPP_LIBRARIES}
|
||||
${IPP_LIB_PREFIX}irc${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
${IPP_LIB_PREFIX}imf${CMAKE_SHARED_LIBRARY_SUFFIX}
|
||||
${IPP_LIB_PREFIX}svml${CMAKE_SHARED_LIBRARY_SUFFIX})
|
||||
endif()
|
||||
set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE)
|
||||
return()
|
||||
|
||||
endfunction()
|
||||
@ -208,19 +215,39 @@ function(set_ipp_variables _LATEST_VERSION)
|
||||
set(IPP_INCLUDE_DIRS ${IPP_ROOT_DIR}/include PARENT_SCOPE)
|
||||
|
||||
if (APPLE)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib PARENT_SCOPE)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib)
|
||||
elseif (IPP_X64)
|
||||
if(NOT EXISTS ${IPP_ROOT_DIR}/lib/intel64)
|
||||
message(SEND_ERROR "IPP EM64T libraries not found")
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/intel64 PARENT_SCOPE)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/intel64)
|
||||
else()
|
||||
if(NOT EXISTS ${IPP_ROOT_DIR}/lib/ia32)
|
||||
message(SEND_ERROR "IPP IA32 libraries not found")
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/ia32 PARENT_SCOPE)
|
||||
set(IPP_LIBRARY_DIRS ${IPP_ROOT_DIR}/lib/ia32)
|
||||
endif()
|
||||
|
||||
if (UNIX)
|
||||
get_filename_component(INTEL_COMPILER_LIBRARY_DIR ${IPP_ROOT_DIR}/../lib REALPATH)
|
||||
if (IPP_X64)
|
||||
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/intel64)
|
||||
message(SEND_ERROR "Intel compiler EM64T libraries not found")
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIRS
|
||||
${IPP_LIBRARY_DIRS}
|
||||
${INTEL_COMPILER_LIBRARY_DIR}/intel64)
|
||||
else()
|
||||
if(NOT EXISTS ${INTEL_COMPILER_LIBRARY_DIR}/ia32)
|
||||
message(SEND_ERROR "Intel compiler IA32 libraries not found")
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIRS
|
||||
${IPP_LIBRARY_DIRS}
|
||||
${INTEL_COMPILER_LIBRARY_DIR}/ia32)
|
||||
endif()
|
||||
endif()
|
||||
set(IPP_LIBRARY_DIRS ${IPP_LIBRARY_DIRS} PARENT_SCOPE)
|
||||
|
||||
# set IPP_LIBRARIES variable (7.x or 8.x lib names)
|
||||
set_ipp_new_libraries(${_LATEST_VERSION})
|
||||
set(IPP_LIBRARIES ${IPP_LIBRARIES} PARENT_SCOPE)
|
||||
|
@ -59,6 +59,24 @@ if(ANDROID)
|
||||
ocv_list_filterout(OPENCV_EXTRA_COMPONENTS_CONFIGMAKE "libcu")
|
||||
ocv_list_filterout(OPENCV_EXTRA_COMPONENTS_CONFIGMAKE "libnpp")
|
||||
|
||||
if(HAVE_CUDA)
|
||||
# CUDA runtime libraries and are required always
|
||||
set(culibs ${CUDA_LIBRARIES})
|
||||
|
||||
# right now NPP is requared always too
|
||||
list(INSERT culibs 0 ${CUDA_npp_LIBRARY})
|
||||
|
||||
if(HAVE_CUFFT)
|
||||
list(INSERT culibs 0 ${CUDA_cufft_LIBRARY})
|
||||
endif()
|
||||
|
||||
if(HAVE_CUBLAS)
|
||||
list(INSERT culibs 0 ${CUDA_cublas_LIBRARY})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
ocv_convert_to_lib_name(CUDA_RUNTIME_LIBS_CONFIGMAKE ${culibs})
|
||||
|
||||
# split 3rdparty libs and modules
|
||||
foreach(mod ${OPENCV_MODULES_CONFIGMAKE})
|
||||
if(NOT mod MATCHES "^opencv_.+$")
|
||||
@ -69,6 +87,10 @@ if(ANDROID)
|
||||
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE})
|
||||
endif()
|
||||
|
||||
if(ENABLE_DYNAMIC_CUDA)
|
||||
set(OPENCV_DYNAMICUDA_MODULE_CONFIGMAKE "dynamicuda")
|
||||
endif()
|
||||
|
||||
# GPU module enabled separately
|
||||
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE "opencv_gpu")
|
||||
list(REMOVE_ITEM OPENCV_MODULES_CONFIGMAKE "opencv_dynamicuda")
|
||||
@ -84,6 +106,7 @@ if(ANDROID)
|
||||
string(REPLACE ";" " " ${lst} "${${lst}}")
|
||||
endforeach()
|
||||
string(REPLACE "opencv_" "" OPENCV_MODULES_CONFIGMAKE "${OPENCV_MODULES_CONFIGMAKE}")
|
||||
string(REPLACE ";" " " CUDA_RUNTIME_LIBS_CONFIGMAKE "${CUDA_RUNTIME_LIBS_CONFIGMAKE}")
|
||||
|
||||
# prepare 3rd-party component list without TBB for armeabi and mips platforms. TBB is useless there.
|
||||
set(OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE_NO_TBB ${OPENCV_3RDPARTY_COMPONENTS_CONFIGMAKE})
|
||||
@ -105,7 +128,7 @@ if(ANDROID)
|
||||
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)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/OpenCV.mk" @ONLY)
|
||||
|
||||
# -------------------------------------------------------------------------------------------
|
||||
# Part 2/2: ${BIN_DIR}/unix-install/OpenCV.mk -> For use with "make install"
|
||||
@ -115,6 +138,6 @@ if(ANDROID)
|
||||
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)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCV.mk.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk" @ONLY)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/OpenCV.mk DESTINATION ${OPENCV_CONFIG_INSTALL_PATH} COMPONENT dev)
|
||||
endif(ANDROID)
|
||||
|
@ -83,9 +83,9 @@ endif()
|
||||
|
||||
export(TARGETS ${OpenCVModules_TARGETS} FILE "${CMAKE_BINARY_DIR}/OpenCVModules${modules_file_suffix}.cmake")
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig.cmake" @ONLY)
|
||||
#support for version checking when finding opencv. find_package(OpenCV 2.3.1 EXACT) should now work.
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/OpenCVConfig-version.cmake" @ONLY)
|
||||
|
||||
# --------------------------------------------------------------------------------------------
|
||||
# Part 2/3: ${BIN_DIR}/unix-install/OpenCVConfig.cmake -> For use *with* "make install"
|
||||
@ -98,8 +98,8 @@ if(INSTALL_TO_MANGLED_PATHS)
|
||||
set(OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE "\"\${OpenCV_INSTALL_PATH}/${OpenCV_3RDPARTY_LIB_DIRS_CONFIGCMAKE}\"")
|
||||
endif()
|
||||
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig.cmake" @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/unix-install/OpenCVConfig-version.cmake" @ONLY)
|
||||
|
||||
if(UNIX) # ANDROID configuration is created here also
|
||||
#http://www.vtk.org/Wiki/CMake/Tutorials/Packaging reference
|
||||
@ -131,8 +131,8 @@ if(WIN32)
|
||||
set(OpenCV2_INCLUDE_DIRS_CONFIGCMAKE "\"\"")
|
||||
|
||||
exec_program(mkdir ARGS "-p \"${CMAKE_BINARY_DIR}/win-install/\"" OUTPUT_VARIABLE RET_VAL)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" IMMEDIATE @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" IMMEDIATE @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" @ONLY)
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/OpenCVConfig-version.cmake.in" "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig-version.cmake" @ONLY)
|
||||
if(BUILD_SHARED_LIBS)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/win-install/OpenCVConfig.cmake" DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" COMPONENT dev)
|
||||
install(EXPORT OpenCVModules DESTINATION "${OpenCV_INSTALL_BINARIES_PREFIX}lib" FILE OpenCVModules${modules_file_suffix}.cmake COMPONENT dev)
|
||||
|
@ -78,7 +78,7 @@ else()
|
||||
endif()
|
||||
configure_file("${OpenCV_SOURCE_DIR}/cmake/templates/opencv-XXX.pc.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME}"
|
||||
@ONLY IMMEDIATE)
|
||||
@ONLY)
|
||||
|
||||
if(UNIX AND NOT ANDROID)
|
||||
install(FILES ${CMAKE_BINARY_DIR}/unix-install/${OPENCV_PC_FILE_NAME} DESTINATION ${OPENCV_LIB_INSTALL_PATH}/pkgconfig COMPONENT dev)
|
||||
|
@ -135,13 +135,13 @@ macro(ocv_add_module _name)
|
||||
|
||||
# parse list of dependencies
|
||||
if("${ARGV1}" STREQUAL "INTERNAL" OR "${ARGV1}" STREQUAL "BINDINGS")
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The cathegory of the module")
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "${ARGV1}" CACHE INTERNAL "The category of the module")
|
||||
set(__ocv_argn__ ${ARGN})
|
||||
list(REMOVE_AT __ocv_argn__ 0)
|
||||
ocv_add_dependencies(${the_module} ${__ocv_argn__})
|
||||
unset(__ocv_argn__)
|
||||
else()
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "PUBLIC" CACHE INTERNAL "The cathegory of the module")
|
||||
set(OPENCV_MODULE_${the_module}_CLASS "PUBLIC" CACHE INTERNAL "The category of the module")
|
||||
ocv_add_dependencies(${the_module} ${ARGN})
|
||||
if(BUILD_${the_module})
|
||||
set(OPENCV_MODULES_PUBLIC ${OPENCV_MODULES_PUBLIC} "${the_module}" CACHE INTERNAL "List of OpenCV modules marked for export")
|
||||
@ -711,6 +711,9 @@ function(ocv_add_perf_tests)
|
||||
else(OCV_DEPENDENCIES_FOUND)
|
||||
# TODO: warn about unsatisfied dependencies
|
||||
endif(OCV_DEPENDENCIES_FOUND)
|
||||
if(INSTALL_TESTS)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -764,6 +767,10 @@ function(ocv_add_accuracy_tests)
|
||||
else(OCV_DEPENDENCIES_FOUND)
|
||||
# TODO: warn about unsatisfied dependencies
|
||||
endif(OCV_DEPENDENCIES_FOUND)
|
||||
|
||||
if(INSTALL_TESTS)
|
||||
install(TARGETS ${the_target} RUNTIME DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
@ -804,7 +811,7 @@ function(ocv_add_samples)
|
||||
if(INSTALL_C_EXAMPLES AND NOT WIN32 AND EXISTS "${samples_path}")
|
||||
file(GLOB sample_files "${samples_path}/*")
|
||||
install(FILES ${sample_files}
|
||||
DESTINATION share/OpenCV/samples/${module_id}
|
||||
DESTINATION ${OPENCV_SAMPLES_SRC_INSTALL_PATH}/${module_id}
|
||||
PERMISSIONS OWNER_READ GROUP_READ WORLD_READ COMPONENT samples)
|
||||
endif()
|
||||
endfunction()
|
||||
|
@ -2,24 +2,29 @@ if(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
|
||||
set(CPACK_set_DESTDIR "on")
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
set(CPACK_PACKAGE_DESCRIPTION "Open Computer Vision Library")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenCV")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Open Computer Vision Library")
|
||||
set(CPACK_PACKAGE_DESCRIPTION
|
||||
"OpenCV (Open Source Computer Vision Library) is an open source computer vision
|
||||
and machine learning software library. OpenCV was built to provide a common
|
||||
infrastructure for computer vision applications and to accelerate the use of
|
||||
machine perception in the commercial products. Being a BSD-licensed product,
|
||||
OpenCV makes it easy for businesses to utilize and modify the code.")
|
||||
set(CPACK_PACKAGE_VENDOR "OpenCV Foundation")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
|
||||
set(CPACK_PACKAGE_CONTACT "admin@opencv.org")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENCV_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${OPENCV_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${OPENCV_VERSION_PATCH}")
|
||||
set(CPACK_PACKAGE_VERSION "${OPENCV_VCSVERSION}")
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${OPENCV_VERSION_MAJOR}")
|
||||
set(CPACK_PACKAGE_VERSION_MINOR "${OPENCV_VERSION_MINOR}")
|
||||
set(CPACK_PACKAGE_VERSION_PATCH "${OPENCV_VERSION_PATCH}")
|
||||
|
||||
#arch
|
||||
if(X86)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "i386")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "i686")
|
||||
elseif(X86_64)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "amd64")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "amd64")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "x86_64")
|
||||
elseif(ARM)
|
||||
set(CPACK_DEBIAN_ARCHITECTURE "armhf")
|
||||
set(CPACK_RPM_PACKAGE_ARCHITECTURE "armhf")
|
||||
@ -41,11 +46,16 @@ set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENCV_VCSVERSION}-$
|
||||
|
||||
#rpm options
|
||||
set(CPACK_RPM_COMPONENT_INSTALL TRUE)
|
||||
set(CPACK_RPM_PACKAGE_LICENSE ${CPACK_RESOURCE_FILE_LICENSE})
|
||||
set(CPACK_RPM_PACKAGE_SUMMARY ${CPACK_PACKAGE_DESCRIPTION_SUMMARY})
|
||||
set(CPACK_RPM_PACKAGE_DESCRIPTION ${CPACK_PACKAGE_DESCRIPTION})
|
||||
set(CPACK_RPM_PACKAGE_URL "http://opencv.org")
|
||||
set(CPACK_RPM_PACKAGE_LICENSE "BSD")
|
||||
|
||||
#deb options
|
||||
set(CPACK_DEB_COMPONENT_INSTALL TRUE)
|
||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "extra")
|
||||
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "libs")
|
||||
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "http://opencv.org")
|
||||
|
||||
#depencencies
|
||||
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS TRUE)
|
||||
@ -54,25 +64,36 @@ set(CPACK_COMPONENT_dev_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_docs_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_java_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_python_DEPENDS libs)
|
||||
set(CPACK_COMPONENT_tests_DEPENDS libs)
|
||||
|
||||
if(HAVE_CUDA)
|
||||
string(REPLACE "." "-" cuda_version_suffix ${CUDA_VERSION})
|
||||
set(CPACK_DEB_libs_PACKAGE_DEPENDS "cuda-core-libs-${cuda_version_suffix}, cuda-extra-libs-${cuda_version_suffix}")
|
||||
set(CPACK_COMPONENT_dev_DEPENDS libs)
|
||||
set(CPACK_DEB_dev_PACKAGE_DEPENDS "cuda-headers-${cuda_version_suffix}")
|
||||
endif()
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
set(CPACK_COMPONENT_libs_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}")
|
||||
set(CPACK_COMPONENT_libs_DESCRIPTION "Open Computer Vision Library")
|
||||
|
||||
set(CPACK_COMPONENT_python_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-python")
|
||||
set(CPACK_COMPONENT_python_DESCRIPTION "Python bindings for Open Computer Vision Library")
|
||||
set(CPACK_COMPONENT_python_DESCRIPTION "Python bindings for Open Source Computer Vision Library")
|
||||
|
||||
set(CPACK_COMPONENT_java_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-java")
|
||||
set(CPACK_COMPONENT_java_DESCRIPTION "Java bindings for Open Computer Vision Library")
|
||||
set(CPACK_COMPONENT_java_DESCRIPTION "Java bindings for Open Source Computer Vision Library")
|
||||
|
||||
set(CPACK_COMPONENT_dev_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-dev")
|
||||
set(CPACK_COMPONENT_dev_DESCRIPTION "Development files for Open Computer Vision Library")
|
||||
set(CPACK_COMPONENT_dev_DESCRIPTION "Development files for Open Source Computer Vision Library")
|
||||
|
||||
set(CPACK_COMPONENT_docs_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-docs")
|
||||
set(CPACK_COMPONENT_docs_DESCRIPTION "Documentation for Open Computer Vision Library")
|
||||
set(CPACK_COMPONENT_docs_DESCRIPTION "Documentation for Open Source Computer Vision Library")
|
||||
|
||||
set(CPACK_COMPONENT_samples_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-samples")
|
||||
set(CPACK_COMPONENT_samples_DESCRIPTION "Samples for Open Computer Vision Library")
|
||||
set(CPACK_COMPONENT_samples_DESCRIPTION "Samples for Open Source Computer Vision Library")
|
||||
|
||||
set(CPACK_COMPONENT_tests_DISPLAY_NAME "lib${CMAKE_PROJECT_NAME}-tests")
|
||||
set(CPACK_COMPONENT_tests_DESCRIPTION "Accuracy and performance tests for Open Source Computer Vision Library")
|
||||
endif(NOT OPENCV_CUSTOM_PACKAGE_INFO)
|
||||
|
||||
if(NOT OPENCV_CUSTOM_PACKAGE_LAYOUT)
|
||||
|
@ -448,6 +448,20 @@ macro(ocv_convert_to_full_paths VAR)
|
||||
endmacro()
|
||||
|
||||
|
||||
# convert list of paths to libraries names without lib prefix
|
||||
macro(ocv_convert_to_lib_name var)
|
||||
set(__tmp "")
|
||||
foreach(path ${ARGN})
|
||||
get_filename_component(__tmp_name "${path}" NAME_WE)
|
||||
string(REGEX REPLACE "^lib" "" __tmp_name ${__tmp_name})
|
||||
list(APPEND __tmp "${__tmp_name}")
|
||||
endforeach()
|
||||
set(${var} ${__tmp})
|
||||
unset(__tmp)
|
||||
unset(__tmp_name)
|
||||
endmacro()
|
||||
|
||||
|
||||
# add install command
|
||||
function(ocv_install_target)
|
||||
install(TARGETS ${ARGN})
|
||||
|
@ -2,6 +2,13 @@
|
||||
# you might need to define NDK_USE_CYGPATH=1 before calling the ndk-build
|
||||
|
||||
USER_LOCAL_PATH:=$(LOCAL_PATH)
|
||||
|
||||
USER_LOCAL_C_INCLUDES:=$(LOCAL_C_INCLUDES)
|
||||
USER_LOCAL_CFLAGS:=$(LOCAL_CFLAGS)
|
||||
USER_LOCAL_STATIC_LIBRARIES:=$(LOCAL_STATIC_LIBRARIES)
|
||||
USER_LOCAL_SHARED_LIBRARIES:=$(LOCAL_SHARED_LIBRARIES)
|
||||
USER_LOCAL_LDLIBS:=$(LOCAL_LDLIBS)
|
||||
|
||||
LOCAL_PATH:=$(subst ?,,$(firstword ?$(subst \, ,$(subst /, ,$(call my-dir)))))
|
||||
|
||||
OPENCV_TARGET_ARCH_ABI:=$(TARGET_ARCH_ABI)
|
||||
@ -13,7 +20,7 @@ OPENCV_BASEDIR:=@OPENCV_BASE_INCLUDE_DIR_CONFIGCMAKE@
|
||||
OPENCV_LOCAL_C_INCLUDES:=@OPENCV_INCLUDE_DIRS_CONFIGCMAKE@
|
||||
OPENCV_MODULES:=@OPENCV_MODULES_CONFIGMAKE@
|
||||
|
||||
OPENCV_HAVE_GPU_MODULE=@OPENCV_HAVE_GPU_MODULE_CONFIGMAKE@
|
||||
OPENCV_HAVE_GPU_MODULE:=@OPENCV_HAVE_GPU_MODULE_CONFIGMAKE@
|
||||
OPENCV_USE_GPU_MODULE:=
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
@ -22,9 +29,12 @@ ifeq ($(TARGET_ARCH_ABI),armeabi-v7a)
|
||||
OPENCV_USE_GPU_MODULE:=on
|
||||
endif
|
||||
endif
|
||||
OPENCV_DYNAMICUDA_MODULE:=@OPENCV_DYNAMICUDA_MODULE_CONFIGMAKE@
|
||||
else
|
||||
OPENCV_DYNAMICUDA_MODULE:=
|
||||
endif
|
||||
|
||||
CUDA_RUNTIME_LIBS:=cufft npps nppi nppc cudart
|
||||
CUDA_RUNTIME_LIBS:=@CUDA_RUNTIME_LIBS_CONFIGMAKE@
|
||||
|
||||
ifeq ($(OPENCV_LIB_TYPE),)
|
||||
OPENCV_LIB_TYPE:=@OPENCV_LIBTYPE_CONFIGMAKE@
|
||||
@ -60,7 +70,7 @@ else
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq (${OPENCV_CAMERA_MODULES},on)
|
||||
ifeq ($(OPENCV_CAMERA_MODULES),on)
|
||||
ifeq ($(TARGET_ARCH_ABI),armeabi)
|
||||
OPENCV_CAMERA_MODULES:=@OPENCV_CAMERA_LIBS_ARMEABI_CONFIGCMAKE@
|
||||
endif
|
||||
@ -91,6 +101,13 @@ define add_opencv_module
|
||||
include $(PREBUILT_$(OPENCV_LIB_TYPE)_LIBRARY)
|
||||
endef
|
||||
|
||||
define add_cuda_module
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:=$1
|
||||
LOCAL_SRC_FILES:=$(CUDA_TOOLKIT_DIR)/targets/armv7-linux-androideabi/lib/lib$1.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
endef
|
||||
|
||||
define add_opencv_3rdparty_component
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_MODULE:=$1
|
||||
@ -108,6 +125,17 @@ endef
|
||||
ifeq ($(OPENCV_MK_$(OPENCV_TARGET_ARCH_ABI)_ALREADY_INCLUDED),)
|
||||
ifeq ($(OPENCV_INSTALL_MODULES),on)
|
||||
$(foreach module,$(OPENCV_LIBS),$(eval $(call add_opencv_module,$(module))))
|
||||
ifneq ($(OPENCV_DYNAMICUDA_MODULE),)
|
||||
ifeq ($(OPENCV_LIB_TYPE),SHARED)
|
||||
$(eval $(call add_opencv_module,$(OPENCV_DYNAMICUDA_MODULE)))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
ifeq ($(OPENCV_USE_GPU_MODULE),on)
|
||||
ifeq ($(INSTALL_CUDA_LIBRARIES),on)
|
||||
$(foreach module,$(CUDA_RUNTIME_LIBS),$(eval $(call add_cuda_module,$(module))))
|
||||
endif
|
||||
endif
|
||||
|
||||
$(foreach module,$(OPENCV_3RDPARTY_COMPONENTS),$(eval $(call add_opencv_3rdparty_component,$(module))))
|
||||
@ -136,6 +164,13 @@ ifeq ($(OPENCV_LOCAL_CFLAGS),)
|
||||
endif
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
LOCAL_C_INCLUDES:=$(USER_LOCAL_C_INCLUDES)
|
||||
LOCAL_CFLAGS:=$(USER_LOCAL_CFLAGS)
|
||||
LOCAL_STATIC_LIBRARIES:=$(USER_LOCAL_STATIC_LIBRARIES)
|
||||
LOCAL_SHARED_LIBRARIES:=$(USER_LOCAL_SHARED_LIBRARIES)
|
||||
LOCAL_LDLIBS:=$(USER_LOCAL_LDLIBS)
|
||||
|
||||
LOCAL_C_INCLUDES += $(OPENCV_LOCAL_C_INCLUDES)
|
||||
LOCAL_CFLAGS += $(OPENCV_LOCAL_CFLAGS)
|
||||
|
||||
@ -145,6 +180,11 @@ endif
|
||||
|
||||
ifeq ($(OPENCV_INSTALL_MODULES),on)
|
||||
LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(foreach mod, $(OPENCV_LIBS), opencv_$(mod))
|
||||
ifeq ($(OPENCV_LIB_TYPE),SHARED)
|
||||
ifneq ($(OPENCV_DYNAMICUDA_MODULE),)
|
||||
LOCAL_$(OPENCV_LIB_TYPE)_LIBRARIES += $(OPENCV_DYNAMICUDA_MODULE)
|
||||
endif
|
||||
endif
|
||||
else
|
||||
LOCAL_LDLIBS += -L$(call host-path,$(LOCAL_PATH)/$(OPENCV_LIBS_DIR)) $(foreach lib, $(OPENCV_LIBS), -lopencv_$(lib))
|
||||
endif
|
||||
@ -156,8 +196,12 @@ endif
|
||||
LOCAL_LDLIBS += $(foreach lib,$(OPENCV_EXTRA_COMPONENTS), -l$(lib))
|
||||
|
||||
ifeq ($(OPENCV_USE_GPU_MODULE),on)
|
||||
ifeq ($(INSTALL_CUDA_LIBRARIES),on)
|
||||
LOCAL_SHARED_LIBRARIES += $(foreach mod, $(CUDA_RUNTIME_LIBS), $(mod))
|
||||
else
|
||||
LOCAL_LDLIBS += -L$(CUDA_TOOLKIT_DIR)/targets/armv7-linux-androideabi/lib $(foreach lib, $(CUDA_RUNTIME_LIBS), -l$(lib))
|
||||
endif
|
||||
LOCAL_STATIC_LIBRARIES+=libopencv_gpu
|
||||
LOCAL_LDLIBS += -L$(CUDA_TOOLKIT_DIR)/lib $(foreach lib, $(CUDA_RUNTIME_LIBS), -l$(lib))
|
||||
endif
|
||||
|
||||
#restore the LOCAL_PATH
|
||||
|
@ -161,6 +161,6 @@
|
||||
/* Xine video library */
|
||||
#cmakedefine HAVE_XINE
|
||||
|
||||
/* Define to 1 if your processor stores words with the most significant byte
|
||||
/* Define if your processor stores words with the most significant byte
|
||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
#cmakedefine WORDS_BIGENDIAN
|
||||
|
51
cmake/templates/opencv_run_all_tests_android.sh.in
Normal file
@ -0,0 +1,51 @@
|
||||
#!/bin/sh
|
||||
|
||||
BASE_DIR=`dirname $0`
|
||||
OPENCV_TEST_PATH=$BASE_DIR/@TEST_PATH@
|
||||
OPENCV_TEST_DATA_PATH=$BASE_DIR/sdk/etc/testdata/
|
||||
|
||||
if [ $# -ne 1 ]; then
|
||||
echo "Device architecture is not preset in command line"
|
||||
echo "Tests are available for architectures: `ls -m ${OPENCV_TEST_PATH}`"
|
||||
echo "Usage: $0 <target_device_arch>"
|
||||
return 1
|
||||
else
|
||||
TARGET_ARCH=$1
|
||||
fi
|
||||
|
||||
if [ -z `which adb` ]; then
|
||||
echo "adb command was not found in PATH"
|
||||
return 1
|
||||
fi
|
||||
|
||||
adb push $OPENCV_TEST_DATA_PATH /sdcard/opencv_testdata
|
||||
|
||||
adb shell "mkdir -p /data/local/tmp/opencv_test"
|
||||
SUMMARY_STATUS=0
|
||||
for t in "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_test_* "$OPENCV_TEST_PATH/$TARGET_ARCH/"opencv_perf_*;
|
||||
do
|
||||
test_name=`basename "$t"`
|
||||
report="$test_name-`date --rfc-3339=date`.xml"
|
||||
adb push $t /data/local/tmp/opencv_test/
|
||||
adb shell "export OPENCV_TEST_DATA_PATH=/sdcard/opencv_testdata && /data/local/tmp/opencv_test/$test_name --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:/data/local/tmp/opencv_test/$report"
|
||||
adb pull "/data/local/tmp/opencv_test/$report" $report
|
||||
TEST_STATUS=0
|
||||
if [ -e $report ]; then
|
||||
if [ `grep -c "<fail" $report` -ne 0 ]; then
|
||||
TEST_STATUS=2
|
||||
fi
|
||||
else
|
||||
TEST_STATUS=3
|
||||
fi
|
||||
if [ $TEST_STATUS -ne 0 ]; then
|
||||
SUMMARY_STATUS=$TEST_STATUS
|
||||
fi
|
||||
done
|
||||
|
||||
if [ $SUMMARY_STATUS -eq 0 ]; then
|
||||
echo "All OpenCV tests finished successfully"
|
||||
else
|
||||
echo "OpenCV tests finished with status $SUMMARY_STATUS"
|
||||
fi
|
||||
|
||||
return $SUMMARY_STATUS
|
25
cmake/templates/opencv_run_all_tests_unix.sh.in
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
||||
|
||||
SUMMARY_STATUS=0
|
||||
for t in "$OPENCV_TEST_PATH/"opencv_test_* "$OPENCV_TEST_PATH/"opencv_perf_*;
|
||||
do
|
||||
report="`basename "$t"`-`date --rfc-3339=date`.xml"
|
||||
"$t" --perf_min_samples=1 --perf_force_samples=1 --gtest_output=xml:"$report"
|
||||
TEST_STATUS=$?
|
||||
if [ $TEST_STATUS -ne 0 ]; then
|
||||
SUMMARY_STATUS=$TEST_STATUS
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f /tmp/__opencv_temp.*
|
||||
|
||||
if [ $SUMMARY_STATUS -eq 0 ]; then
|
||||
echo "All OpenCV tests finished successfully"
|
||||
else
|
||||
echo "OpenCV tests finished with status $SUMMARY_STATUS"
|
||||
fi
|
||||
|
||||
return $SUMMARY_STATUS
|
2
cmake/templates/opencv_testing.sh.in
Normal file
@ -0,0 +1,2 @@
|
||||
# Environment setup for OpenCV testing
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
@ -8,3 +8,15 @@ elseif(NOT WIN32)
|
||||
install(FILES ${HAAR_CASCADES} DESTINATION share/OpenCV/haarcascades COMPONENT libs)
|
||||
install(FILES ${LBP_CASCADES} DESTINATION share/OpenCV/lbpcascades COMPONENT libs)
|
||||
endif()
|
||||
|
||||
if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH)
|
||||
if(ANDROID)
|
||||
install(DIRECTORY ${OPENCV_TEST_DATA_PATH} DESTINATION sdk/etc/testdata COMPONENT tests)
|
||||
elseif(NOT WIN32)
|
||||
# CPack does not set correct permissions by default, so we do it explicitly.
|
||||
install(DIRECTORY ${OPENCV_TEST_DATA_PATH}
|
||||
DIRECTORY_PERMISSIONS OWNER_WRITE OWNER_READ OWNER_EXECUTE
|
||||
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
|
||||
DESTINATION share/OpenCV/testdata COMPONENT tests)
|
||||
endif()
|
||||
endif()
|
@ -44,7 +44,7 @@ master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = u'OpenCV'
|
||||
copyright = u'2011-2013, opencv dev team'
|
||||
copyright = u'2011-2014, opencv dev team'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
|
BIN
doc/tutorials/images/viz.jpg
Normal file
After Width: | Height: | Size: 31 KiB |
@ -85,7 +85,7 @@ d. **method=CV\_TM\_CCORR\_NORMED**
|
||||
|
||||
.. math::
|
||||
|
||||
R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I'(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}
|
||||
R(x,y)= \frac{\sum_{x',y'} (T(x',y') \cdot I(x+x',y+y'))}{\sqrt{\sum_{x',y'}T(x',y')^2 \cdot \sum_{x',y'} I(x+x',y+y')^2}}
|
||||
|
||||
|
||||
e. **method=CV\_TM\_CCOEFF**
|
||||
|
@ -382,7 +382,7 @@ result.
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback);
|
||||
}
|
||||
|
||||
#. Defines that your activity implements ``CvViewFrameListener2`` interface and fix activity related
|
||||
#. Defines that your activity implements ``CvCameraViewListener2`` interface and fix activity related
|
||||
errors by defining missed methods. For this activity define ``onCreate``, ``onDestroy`` and
|
||||
``onPause`` and implement them according code snippet bellow. Fix errors by adding requited
|
||||
imports.
|
||||
@ -432,7 +432,7 @@ result.
|
||||
Lets discuss some most important steps. Every Android application with UI must implement Activity
|
||||
and View. By the first steps we create blank activity and default view layout. The simplest
|
||||
OpenCV-centric application must implement OpenCV initialization, create its own view to show
|
||||
preview from camera and implements ``CvViewFrameListener2`` interface to get frames from camera and
|
||||
preview from camera and implements ``CvCameraViewListener2`` interface to get frames from camera and
|
||||
process it.
|
||||
|
||||
First of all we create our application view using xml layout. Our layout consists of the only
|
||||
|
@ -25,29 +25,34 @@ Let's use a simple program such as DisplayImage.cpp shown below.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
#include <stdio.h>
|
||||
#include <opencv2/opencv.hpp>
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv;
|
||||
|
||||
int main( int argc, char** argv )
|
||||
{
|
||||
Mat image;
|
||||
image = imread( argv[1], 1 );
|
||||
int main(int argc, char** argv )
|
||||
{
|
||||
if ( argc != 2 )
|
||||
{
|
||||
printf("usage: DisplayImage.out <Image_Path>\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if( argc != 2 || !image.data )
|
||||
{
|
||||
printf( "No image data \n" );
|
||||
return -1;
|
||||
}
|
||||
Mat image;
|
||||
image = imread( argv[1], 1 );
|
||||
|
||||
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
|
||||
imshow( "Display Image", image );
|
||||
if ( !image.data )
|
||||
{
|
||||
printf("No image data \n");
|
||||
return -1;
|
||||
}
|
||||
namedWindow("Display Image", CV_WINDOW_AUTOSIZE );
|
||||
imshow("Display Image", image);
|
||||
|
||||
waitKey(0);
|
||||
waitKey(0);
|
||||
|
||||
return 0;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
Create a CMake file
|
||||
---------------------
|
||||
|
@ -100,7 +100,7 @@ Explanation
|
||||
imshow( imageName, image );
|
||||
imshow( "Gray image", gray_image );
|
||||
|
||||
#. Add add the *waitKey(0)* function call for the program to wait forever for an user key press.
|
||||
#. Add the *waitKey(0)* function call for the program to wait forever for an user key press.
|
||||
|
||||
|
||||
Result
|
||||
|
@ -186,6 +186,21 @@ As always, we would be happy to hear your comments and receive your contribution
|
||||
:width: 80pt
|
||||
:alt: gpu icon
|
||||
|
||||
* :ref:`Table-Of-Content-Viz`
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
=========== =======================================================
|
||||
|Viz| These tutorials show how to use Viz module effectively.
|
||||
|
||||
=========== =======================================================
|
||||
|
||||
.. |Viz| image:: images/viz.jpg
|
||||
:height: 80pt
|
||||
:width: 80pt
|
||||
:alt: viz icon
|
||||
|
||||
* :ref:`Table-Of-Content-General`
|
||||
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
@ -221,4 +236,5 @@ As always, we would be happy to hear your comments and receive your contribution
|
||||
gpu/table_of_content_gpu/table_of_content_gpu
|
||||
contrib/table_of_content_contrib/table_of_content_contrib
|
||||
ios/table_of_content_ios/table_of_content_ios
|
||||
viz/table_of_content_viz/table_of_content_viz
|
||||
general/table_of_content_general/table_of_content_general
|
||||
|
159
doc/tutorials/viz/creating_widgets/creating_widgets.rst
Normal file
@ -0,0 +1,159 @@
|
||||
.. _creating_widgets:
|
||||
|
||||
Creating Widgets
|
||||
****************
|
||||
|
||||
Goal
|
||||
====
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Create your own widgets using WidgetAccessor and VTK.
|
||||
* Show your widget in the visualization window.
|
||||
|
||||
Code
|
||||
====
|
||||
|
||||
You can download the code from :download:`here <../../../../samples/cpp/tutorial_code/viz/creating_widgets.cpp>`.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <opencv2/viz/vizcore.hpp>
|
||||
#include <opencv2/viz/widget_accessor.hpp>
|
||||
#include <iostream>
|
||||
|
||||
#include <vtkPoints.h>
|
||||
#include <vtkTriangle.h>
|
||||
#include <vtkCellArray.h>
|
||||
#include <vtkPolyData.h>
|
||||
#include <vtkPolyDataMapper.h>
|
||||
#include <vtkIdList.h>
|
||||
#include <vtkActor.h>
|
||||
#include <vtkProp.h>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @class WTriangle
|
||||
* @brief Defining our own 3D Triangle widget
|
||||
*/
|
||||
class WTriangle : public viz::Widget3D
|
||||
{
|
||||
public:
|
||||
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
||||
};
|
||||
|
||||
/**
|
||||
* @function WTriangle::WTriangle
|
||||
*/
|
||||
WTriangle::WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color)
|
||||
{
|
||||
// Create a triangle
|
||||
vtkSmartPointer<vtkPoints> points = vtkSmartPointer<vtkPoints>::New();
|
||||
points->InsertNextPoint(pt1.x, pt1.y, pt1.z);
|
||||
points->InsertNextPoint(pt2.x, pt2.y, pt2.z);
|
||||
points->InsertNextPoint(pt3.x, pt3.y, pt3.z);
|
||||
|
||||
vtkSmartPointer<vtkTriangle> triangle = vtkSmartPointer<vtkTriangle>::New();
|
||||
triangle->GetPointIds()->SetId(0,0);
|
||||
triangle->GetPointIds()->SetId(1,1);
|
||||
triangle->GetPointIds()->SetId(2,2);
|
||||
|
||||
vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New();
|
||||
cells->InsertNextCell(triangle);
|
||||
|
||||
// Create a polydata object
|
||||
vtkSmartPointer<vtkPolyData> polyData = vtkSmartPointer<vtkPolyData>::New();
|
||||
|
||||
// Add the geometry and topology to the polydata
|
||||
polyData->SetPoints(points);
|
||||
polyData->SetPolys(cells);
|
||||
|
||||
// Create mapper and actor
|
||||
vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
|
||||
#if VTK_MAJOR_VERSION <= 5
|
||||
mapper->SetInput(polyData);
|
||||
#else
|
||||
mapper->SetInputData(polyData);
|
||||
#endif
|
||||
|
||||
vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
|
||||
actor->SetMapper(mapper);
|
||||
|
||||
// Store this actor in the widget in order that visualizer can access it
|
||||
viz::WidgetAccessor::setProp(*this, actor);
|
||||
|
||||
// Set the color of the widget. This has to be called after WidgetAccessor.
|
||||
setColor(color);
|
||||
}
|
||||
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Creating Widgets");
|
||||
|
||||
/// Create a triangle widget
|
||||
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
||||
|
||||
/// Show widget in the visualizer window
|
||||
myWindow.showWidget("TRIANGLE", tw);
|
||||
|
||||
/// Start event loop
|
||||
myWindow.spin();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Explanation
|
||||
===========
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
* Extend Widget3D class to create a new 3D widget.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
class WTriangle : public viz::Widget3D
|
||||
{
|
||||
public:
|
||||
WTriangle(const Point3f &pt1, const Point3f &pt2, const Point3f &pt3, const viz::Color & color = viz::Color::white());
|
||||
};
|
||||
|
||||
* Assign a VTK actor to the widget.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// Store this actor in the widget in order that visualizer can access it
|
||||
viz::WidgetAccessor::setProp(*this, actor);
|
||||
|
||||
* Set color of the widget.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
// Set the color of the widget. This has to be called after WidgetAccessor.
|
||||
setColor(color);
|
||||
|
||||
* Construct a triangle widget and display it in the window.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Create a triangle widget
|
||||
WTriangle tw(Point3f(0.0,0.0,0.0), Point3f(1.0,1.0,1.0), Point3f(0.0,1.0,0.0), viz::Color::red());
|
||||
|
||||
/// Show widget in the visualizer window
|
||||
myWindow.showWidget("TRIANGLE", tw);
|
||||
|
||||
Results
|
||||
=======
|
||||
|
||||
Here is the result of the program.
|
||||
|
||||
.. image:: images/red_triangle.png
|
||||
:alt: Creating Widgets
|
||||
:align: center
|
BIN
doc/tutorials/viz/creating_widgets/images/red_triangle.png
Normal file
After Width: | Height: | Size: 10 KiB |
BIN
doc/tutorials/viz/launching_viz/images/window_demo.png
Normal file
After Width: | Height: | Size: 7.3 KiB |
118
doc/tutorials/viz/launching_viz/launching_viz.rst
Normal file
@ -0,0 +1,118 @@
|
||||
.. _launching_viz:
|
||||
|
||||
Launching Viz
|
||||
*************
|
||||
|
||||
Goal
|
||||
====
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Open a visualization window.
|
||||
* Access a window by its name.
|
||||
* Start event loop.
|
||||
* Start event loop for a given amount of time.
|
||||
|
||||
Code
|
||||
====
|
||||
|
||||
You can download the code from :download:`here <../../../../samples/cpp/tutorial_code/viz/launching_viz.cpp>`.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <opencv2/viz/vizcore.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Viz Demo");
|
||||
|
||||
/// Start event loop
|
||||
myWindow.spin();
|
||||
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
cout << "First event loop is over" << endl;
|
||||
|
||||
/// Access window via its name
|
||||
viz::Viz3d sameWindow = viz::getWindowByName("Viz Demo");
|
||||
|
||||
/// Start event loop
|
||||
sameWindow.spin();
|
||||
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
cout << "Second event loop is over" << endl;
|
||||
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
/// Start event loop once for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
while(!sameWindow.wasStopped())
|
||||
{
|
||||
/// Interact with window
|
||||
|
||||
/// Event loop for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
}
|
||||
|
||||
/// Once more event loop is stopped
|
||||
cout << "Last event loop is over" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
Explanation
|
||||
===========
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
* Create a window.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Viz Demo");
|
||||
|
||||
* Start event loop. This event loop will run until user terminates it by pressing **e**, **E**, **q**, **Q**.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Start event loop
|
||||
myWindow.spin();
|
||||
|
||||
* Access same window via its name. Since windows are implicitly shared, **sameWindow** is exactly the same with **myWindow**. If the name does not exist, a new window is created.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Access window via its name
|
||||
viz::Viz3d sameWindow = viz::get("Viz Demo");
|
||||
|
||||
* Start a controlled event loop. Once it starts, **wasStopped** is set to false. Inside the while loop, in each iteration, **spinOnce** is called to prevent event loop from completely stopping. Inside the while loop, user can execute other statements including those which interact with the window.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Event loop is over when pressed q, Q, e, E
|
||||
/// Start event loop once for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
while(!sameWindow.wasStopped())
|
||||
{
|
||||
/// Interact with window
|
||||
|
||||
/// Event loop for 1 millisecond
|
||||
sameWindow.spinOnce(1, true);
|
||||
}
|
||||
|
||||
Results
|
||||
=======
|
||||
|
||||
Here is the result of the program.
|
||||
|
||||
.. image:: images/window_demo.png
|
||||
:alt: Launching Viz
|
||||
:align: center
|
BIN
doc/tutorials/viz/table_of_content_viz/images/facedetect.jpg
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
doc/tutorials/viz/table_of_content_viz/images/image_effects.png
Normal file
After Width: | Height: | Size: 29 KiB |
BIN
doc/tutorials/viz/table_of_content_viz/images/intro.png
Normal file
After Width: | Height: | Size: 2.5 KiB |
@ -0,0 +1,94 @@
|
||||
.. _Table-Of-Content-Viz:
|
||||
|
||||
**OpenCV Viz**
|
||||
-----------------------------------------------------------
|
||||
|
||||
.. include:: ../../definitions/tocDefinitions.rst
|
||||
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
================== ===============================================================================
|
||||
|VizLaunchingViz| **Title:** :ref:`launching_viz`
|
||||
|
||||
*Compatibility:* > OpenCV 3.0.0
|
||||
|
||||
*Author:* Ozan Tonkal
|
||||
|
||||
You will learn how to launch a viz window.
|
||||
|
||||
================== ===============================================================================
|
||||
|
||||
.. |VizLaunchingViz| image:: ../launching_viz/images/window_demo.png
|
||||
:height: 120pt
|
||||
:width: 90pt
|
||||
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
================ ============================================================================
|
||||
|WidgetPose| **Title:** :ref:`widget_pose`
|
||||
|
||||
*Compatibility:* > OpenCV 3.0.0
|
||||
|
||||
*Author:* Ozan Tonkal
|
||||
|
||||
You will learn how to change pose of a widget.
|
||||
|
||||
================ ============================================================================
|
||||
|
||||
.. |WidgetPose| image:: ../widget_pose/images/widgetpose.png
|
||||
:height: 90pt
|
||||
:width: 90pt
|
||||
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
================== ============================================================================
|
||||
|Transformations| **Title:** :ref:`transformations`
|
||||
|
||||
*Compatibility:* > OpenCV 3.0.0
|
||||
|
||||
*Author:* Ozan Tonkal
|
||||
|
||||
You will learn how to transform between global and camera frames.
|
||||
|
||||
================== ============================================================================
|
||||
|
||||
.. |Transformations| image:: ../transformations/images/global_view_point.png
|
||||
:height: 120pt
|
||||
:width: 90pt
|
||||
|
||||
+
|
||||
.. tabularcolumns:: m{100pt} m{300pt}
|
||||
.. cssclass:: toctableopencv
|
||||
|
||||
================== ============================================================================
|
||||
|CreatingWidgets| **Title:** :ref:`creating_widgets`
|
||||
|
||||
*Compatibility:* > OpenCV 3.0.0
|
||||
|
||||
*Author:* Ozan Tonkal
|
||||
|
||||
You will learn how to create your own widgets.
|
||||
|
||||
================== ============================================================================
|
||||
|
||||
.. |CreatingWidgets| image:: ../creating_widgets/images/red_triangle.png
|
||||
:height: 120pt
|
||||
:width: 90pt
|
||||
|
||||
.. raw:: latex
|
||||
|
||||
\pagebreak
|
||||
|
||||
.. toctree::
|
||||
:hidden:
|
||||
|
||||
../launching_viz/launching_viz
|
||||
../widget_pose/widget_pose
|
||||
../transformations/transformations
|
||||
../creating_widgets/creating_widgets
|
BIN
doc/tutorials/viz/transformations/images/camera_view_point.png
Normal file
After Width: | Height: | Size: 18 KiB |
BIN
doc/tutorials/viz/transformations/images/global_view_point.png
Normal file
After Width: | Height: | Size: 13 KiB |
202
doc/tutorials/viz/transformations/transformations.rst
Normal file
@ -0,0 +1,202 @@
|
||||
.. _transformations:
|
||||
|
||||
Transformations
|
||||
***************
|
||||
|
||||
Goal
|
||||
====
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* How to use makeTransformToGlobal to compute pose
|
||||
* How to use makeCameraPose and Viz3d::setViewerPose
|
||||
* How to visualize camera position by axes and by viewing frustum
|
||||
|
||||
Code
|
||||
====
|
||||
|
||||
You can download the code from :download:`here <../../../../samples/cpp/tutorial_code/viz/transformations.cpp>`.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <opencv2/viz/vizcore.hpp>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @function cvcloud_load
|
||||
* @brief load bunny.ply
|
||||
*/
|
||||
Mat cvcloud_load()
|
||||
{
|
||||
Mat cloud(1, 1889, CV_32FC3);
|
||||
ifstream ifs("bunny.ply");
|
||||
|
||||
string str;
|
||||
for(size_t i = 0; i < 12; ++i)
|
||||
getline(ifs, str);
|
||||
|
||||
Point3f* data = cloud.ptr<cv::Point3f>();
|
||||
float dummy1, dummy2;
|
||||
for(size_t i = 0; i < 1889; ++i)
|
||||
ifs >> data[i].x >> data[i].y >> data[i].z >> dummy1 >> dummy2;
|
||||
|
||||
cloud *= 5.0f;
|
||||
return cloud;
|
||||
}
|
||||
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main(int argn, char **argv)
|
||||
{
|
||||
if (argn < 2)
|
||||
{
|
||||
cout << "Usage: " << endl << "./transformations [ G | C ]" << endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
bool camera_pov = (argv[1][0] == 'C');
|
||||
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Coordinate Frame");
|
||||
|
||||
/// Add coordinate axes
|
||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||
|
||||
/// Let's assume camera has the following properties
|
||||
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
||||
|
||||
/// We can get the pose of the cam using makeCameraPose
|
||||
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
||||
|
||||
/// We can get the transformation matrix from camera coordinate system to global using
|
||||
/// - makeTransformToGlobal. We need the axes of the camera
|
||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
||||
|
||||
/// Create a cloud widget.
|
||||
Mat bunny_cloud = cvcloud_load();
|
||||
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
||||
|
||||
/// Pose of the widget in camera frame
|
||||
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
||||
/// Pose of the widget in global frame
|
||||
Affine3f cloud_pose_global = transform * cloud_pose;
|
||||
|
||||
/// Visualize camera frame
|
||||
if (!camera_pov)
|
||||
{
|
||||
viz::WCameraPosition cpw(0.5); // Coordinate axes
|
||||
viz::WCameraPosition cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum
|
||||
myWindow.showWidget("CPW", cpw, cam_pose);
|
||||
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
||||
}
|
||||
|
||||
/// Visualize widget
|
||||
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
||||
|
||||
/// Set the viewer pose to that of camera
|
||||
if (camera_pov)
|
||||
myWindow.setViewerPose(cam_pose);
|
||||
|
||||
/// Start event loop.
|
||||
myWindow.spin();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Explanation
|
||||
===========
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
* Create a visualization window.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Transformations");
|
||||
|
||||
* Get camera pose from camera position, camera focal point and y direction.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Let's assume camera has the following properties
|
||||
Point3f cam_pos(3.0f,3.0f,3.0f), cam_focal_point(3.0f,3.0f,2.0f), cam_y_dir(-1.0f,0.0f,0.0f);
|
||||
|
||||
/// We can get the pose of the cam using makeCameraPose
|
||||
Affine3f cam_pose = viz::makeCameraPose(cam_pos, cam_focal_point, cam_y_dir);
|
||||
|
||||
* Obtain transform matrix knowing the axes of camera coordinate system.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// We can get the transformation matrix from camera coordinate system to global using
|
||||
/// - makeTransformToGlobal. We need the axes of the camera
|
||||
Affine3f transform = viz::makeTransformToGlobal(Vec3f(0.0f,-1.0f,0.0f), Vec3f(-1.0f,0.0f,0.0f), Vec3f(0.0f,0.0f,-1.0f), cam_pos);
|
||||
|
||||
* Create a cloud widget from bunny.ply file
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Create a cloud widget.
|
||||
Mat bunny_cloud = cvcloud_load();
|
||||
viz::WCloud cloud_widget(bunny_cloud, viz::Color::green());
|
||||
|
||||
* Given the pose in camera coordinate system, estimate the global pose.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Pose of the widget in camera frame
|
||||
Affine3f cloud_pose = Affine3f().translate(Vec3f(0.0f,0.0f,3.0f));
|
||||
/// Pose of the widget in global frame
|
||||
Affine3f cloud_pose_global = transform * cloud_pose;
|
||||
|
||||
* If the view point is set to be global, visualize camera coordinate frame and viewing frustum.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Visualize camera frame
|
||||
if (!camera_pov)
|
||||
{
|
||||
viz::WCameraPosition cpw(0.5); // Coordinate axes
|
||||
viz::WCameraPosition cpw_frustum(Vec2f(0.889484, 0.523599)); // Camera frustum
|
||||
myWindow.showWidget("CPW", cpw, cam_pose);
|
||||
myWindow.showWidget("CPW_FRUSTUM", cpw_frustum, cam_pose);
|
||||
}
|
||||
|
||||
* Visualize the cloud widget with the estimated global pose
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Visualize widget
|
||||
myWindow.showWidget("bunny", cloud_widget, cloud_pose_global);
|
||||
|
||||
* If the view point is set to be camera's, set viewer pose to **cam_pose**.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Set the viewer pose to that of camera
|
||||
if (camera_pov)
|
||||
myWindow.setViewerPose(cam_pose);
|
||||
|
||||
Results
|
||||
=======
|
||||
|
||||
#. Here is the result from the camera point of view.
|
||||
|
||||
.. image:: images/camera_view_point.png
|
||||
:alt: Camera Viewpoint
|
||||
:align: center
|
||||
|
||||
#. Here is the result from global point of view.
|
||||
|
||||
.. image:: images/global_view_point.png
|
||||
:alt: Global Viewpoint
|
||||
:align: center
|
BIN
doc/tutorials/viz/widget_pose/images/widgetpose.png
Normal file
After Width: | Height: | Size: 40 KiB |
162
doc/tutorials/viz/widget_pose/widget_pose.rst
Normal file
@ -0,0 +1,162 @@
|
||||
.. _widget_pose:
|
||||
|
||||
Pose of a widget
|
||||
****************
|
||||
|
||||
Goal
|
||||
====
|
||||
|
||||
In this tutorial you will learn how to
|
||||
|
||||
.. container:: enumeratevisibleitemswithsquare
|
||||
|
||||
* Add widgets to the visualization window
|
||||
* Use Affine3 to set pose of a widget
|
||||
* Rotating and translating a widget along an axis
|
||||
|
||||
Code
|
||||
====
|
||||
|
||||
You can download the code from :download:`here <../../../../samples/cpp/tutorial_code/viz/widget_pose.cpp>`.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
#include <opencv2/viz/vizcore.hpp>
|
||||
#include <opencv2/calib3d/calib3d.hpp>
|
||||
#include <iostream>
|
||||
|
||||
using namespace cv;
|
||||
using namespace std;
|
||||
|
||||
/**
|
||||
* @function main
|
||||
*/
|
||||
int main()
|
||||
{
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Coordinate Frame");
|
||||
|
||||
/// Add coordinate axes
|
||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||
|
||||
/// Add line to represent (1,1,1) axis
|
||||
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
||||
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||
myWindow.showWidget("Line Widget", axis);
|
||||
|
||||
/// Construct a cube widget
|
||||
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
||||
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||
|
||||
/// Display widget (update if already displayed)
|
||||
myWindow.showWidget("Cube Widget", cube_widget);
|
||||
|
||||
/// Rodrigues vector
|
||||
Mat rot_vec = Mat::zeros(1,3,CV_32F);
|
||||
float translation_phase = 0.0, translation = 0.0;
|
||||
while(!myWindow.wasStopped())
|
||||
{
|
||||
/* Rotation using rodrigues */
|
||||
/// Rotate around (1,1,1)
|
||||
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
||||
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
||||
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
||||
|
||||
/// Shift on (1,1,1)
|
||||
translation_phase += CV_PI * 0.01f;
|
||||
translation = sin(translation_phase);
|
||||
|
||||
Mat rot_mat;
|
||||
Rodrigues(rot_vec, rot_mat);
|
||||
|
||||
/// Construct pose
|
||||
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
||||
|
||||
myWindow.setWidgetPose("Cube Widget", pose);
|
||||
|
||||
myWindow.spinOnce(1, true);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Explanation
|
||||
===========
|
||||
|
||||
Here is the general structure of the program:
|
||||
|
||||
* Create a visualization window.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Create a window
|
||||
viz::Viz3d myWindow("Coordinate Frame");
|
||||
|
||||
* Show coordinate axes in the window using CoordinateSystemWidget.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Add coordinate axes
|
||||
myWindow.showWidget("Coordinate Widget", viz::WCoordinateSystem());
|
||||
|
||||
* Display a line representing the axis (1,1,1).
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Add line to represent (1,1,1) axis
|
||||
viz::WLine axis(Point3f(-1.0f,-1.0f,-1.0f), Point3f(1.0f,1.0f,1.0f));
|
||||
axis.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||
myWindow.showWidget("Line Widget", axis);
|
||||
|
||||
* Construct a cube.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Construct a cube widget
|
||||
viz::WCube cube_widget(Point3f(0.5,0.5,0.0), Point3f(0.0,0.0,-0.5), true, viz::Color::blue());
|
||||
cube_widget.setRenderingProperty(viz::LINE_WIDTH, 4.0);
|
||||
myWindow.showWidget("Cube Widget", cube_widget);
|
||||
|
||||
* Create rotation matrix from rodrigues vector
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Rotate around (1,1,1)
|
||||
rot_vec.at<float>(0,0) += CV_PI * 0.01f;
|
||||
rot_vec.at<float>(0,1) += CV_PI * 0.01f;
|
||||
rot_vec.at<float>(0,2) += CV_PI * 0.01f;
|
||||
|
||||
...
|
||||
|
||||
Mat rot_mat;
|
||||
Rodrigues(rot_vec, rot_mat);
|
||||
|
||||
* Use Affine3f to set pose of the cube.
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
/// Construct pose
|
||||
Affine3f pose(rot_mat, Vec3f(translation, translation, translation));
|
||||
myWindow.setWidgetPose("Cube Widget", pose);
|
||||
|
||||
* Animate the rotation using wasStopped and spinOnce
|
||||
|
||||
.. code-block:: cpp
|
||||
|
||||
while(!myWindow.wasStopped())
|
||||
{
|
||||
...
|
||||
|
||||
myWindow.spinOnce(1, true);
|
||||
}
|
||||
|
||||
Results
|
||||
=======
|
||||
|
||||
Here is the result of the program.
|
||||
|
||||
.. raw:: html
|
||||
|
||||
<div align="center">
|
||||
<iframe width="420" height="315" src="https://www.youtube.com/embed/22HKMN657U0" frameborder="0" allowfullscreen></iframe>
|
||||
</div>
|
@ -115,7 +115,7 @@ void computeProjectiveMatrix( const Mat& ksi, Mat& Rt )
|
||||
{
|
||||
CV_Assert( ksi.size() == Size(1,6) && ksi.type() == CV_64FC1 );
|
||||
|
||||
#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3
|
||||
#if defined(HAVE_EIGEN) && EIGEN_WORLD_VERSION == 3 && (!defined _MSC_VER || !defined _M_X64 || _MSC_VER > 1500)
|
||||
const double* ksi_ptr = reinterpret_cast<const double*>(ksi.ptr(0));
|
||||
Eigen::Matrix<double,4,4> twist, g;
|
||||
twist << 0., -ksi_ptr[2], ksi_ptr[1], ksi_ptr[3],
|
||||
|
@ -25,7 +25,7 @@ endif()
|
||||
|
||||
if(HAVE_CUDA)
|
||||
ocv_include_directories("${OpenCV_SOURCE_DIR}/modules/gpu/include")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wshadow)
|
||||
endif()
|
||||
|
||||
file(GLOB lib_cuda_hdrs "include/opencv2/${name}/cuda/*.hpp" "include/opencv2/${name}/cuda/*.h")
|
||||
|
@ -1355,7 +1355,7 @@ The method copies the matrix data to another matrix. Before copying the data, th
|
||||
|
||||
so that the destination matrix is reallocated if needed. While ``m.copyTo(m);`` works flawlessly, the function does not handle the case of a partial overlap between the source and the destination matrices.
|
||||
|
||||
When the operation mask is specified, and the ``Mat::create`` call shown above reallocated the matrix, the newly allocated matrix is initialized with all zeros before copying the data.
|
||||
When the operation mask is specified, if the ``Mat::create`` call shown above reallocates the matrix, the newly allocated matrix is initialized with all zeros before copying the data.
|
||||
|
||||
.. _Mat::convertTo:
|
||||
|
||||
|
509
modules/core/include/opencv2/core/affine.hpp
Normal file
@ -0,0 +1,509 @@
|
||||
/*M///////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
|
||||
//
|
||||
// By downloading, copying, installing or using the software you agree to this license.
|
||||
// If you do not agree to this license, do not download, install,
|
||||
// copy or use the software.
|
||||
//
|
||||
//
|
||||
// License Agreement
|
||||
// For Open Source Computer Vision Library
|
||||
//
|
||||
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
|
||||
// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
|
||||
// Copyright (C) 2013, OpenCV Foundation, all rights reserved.
|
||||
// Third party copyrights are property of their respective owners.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without modification,
|
||||
// are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistribution's of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistribution's in binary form must reproduce the above copyright notice,
|
||||
// this list of conditions and the following disclaimer in the documentation
|
||||
// and/or other materials provided with the distribution.
|
||||
//
|
||||
// * The name of the copyright holders may not be used to endorse or promote products
|
||||
// derived from this software without specific prior written permission.
|
||||
//
|
||||
// This software is provided by the copyright holders and contributors "as is" and
|
||||
// any express or implied warranties, including, but not limited to, the implied
|
||||
// warranties of merchantability and fitness for a particular purpose are disclaimed.
|
||||
// In no event shall the Intel Corporation or contributors be liable for any direct,
|
||||
// indirect, incidental, special, exemplary, or consequential damages
|
||||
// (including, but not limited to, procurement of substitute goods or services;
|
||||
// loss of use, data, or profits; or business interruption) however caused
|
||||
// and on any theory of liability, whether in contract, strict liability,
|
||||
// or tort (including negligence or otherwise) arising in any way out of
|
||||
// the use of this software, even if advised of the possibility of such damage.
|
||||
//
|
||||
//M*/
|
||||
|
||||
#ifndef __OPENCV_CORE_AFFINE3_HPP__
|
||||
#define __OPENCV_CORE_AFFINE3_HPP__
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
namespace cv
|
||||
{
|
||||
template<typename T>
|
||||
class Affine3
|
||||
{
|
||||
public:
|
||||
typedef T float_type;
|
||||
typedef Matx<float_type, 3, 3> Mat3;
|
||||
typedef Matx<float_type, 4, 4> Mat4;
|
||||
typedef Vec<float_type, 3> Vec3;
|
||||
|
||||
Affine3();
|
||||
|
||||
//Augmented affine matrix
|
||||
Affine3(const Mat4& affine);
|
||||
|
||||
//Rotation matrix
|
||||
Affine3(const Mat3& R, const Vec3& t = Vec3::all(0));
|
||||
|
||||
//Rodrigues vector
|
||||
Affine3(const Vec3& rvec, const Vec3& t = Vec3::all(0));
|
||||
|
||||
//Combines all contructors above. Supports 4x4, 4x3, 3x3, 1x3, 3x1 sizes of data matrix
|
||||
explicit Affine3(const Mat& data, const Vec3& t = Vec3::all(0));
|
||||
|
||||
//From 16th element array
|
||||
explicit Affine3(const float_type* vals);
|
||||
|
||||
static Affine3 Identity();
|
||||
|
||||
//Rotation matrix
|
||||
void rotation(const Mat3& R);
|
||||
|
||||
//Rodrigues vector
|
||||
void rotation(const Vec3& rvec);
|
||||
|
||||
//Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
|
||||
void rotation(const Mat& data);
|
||||
|
||||
void linear(const Mat3& L);
|
||||
void translation(const Vec3& t);
|
||||
|
||||
Mat3 rotation() const;
|
||||
Mat3 linear() const;
|
||||
Vec3 translation() const;
|
||||
|
||||
//Rodrigues vector
|
||||
Vec3 rvec() const;
|
||||
|
||||
Affine3 inv(int method = cv::DECOMP_SVD) const;
|
||||
|
||||
// a.rotate(R) is equivalent to Affine(R, 0) * a;
|
||||
Affine3 rotate(const Mat3& R) const;
|
||||
|
||||
// a.rotate(R) is equivalent to Affine(rvec, 0) * a;
|
||||
Affine3 rotate(const Vec3& rvec) const;
|
||||
|
||||
// a.translate(t) is equivalent to Affine(E, t) * a;
|
||||
Affine3 translate(const Vec3& t) const;
|
||||
|
||||
// a.concatenate(affine) is equivalent to affine * a;
|
||||
Affine3 concatenate(const Affine3& affine) const;
|
||||
|
||||
template <typename Y> operator Affine3<Y>() const;
|
||||
|
||||
template <typename Y> Affine3<Y> cast() const;
|
||||
|
||||
Mat4 matrix;
|
||||
|
||||
#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
|
||||
Affine3(const Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine);
|
||||
Affine3(const Eigen::Transform<T, 3, Eigen::Affine>& affine);
|
||||
operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>() const;
|
||||
operator Eigen::Transform<T, 3, Eigen::Affine>() const;
|
||||
#endif
|
||||
};
|
||||
|
||||
template<typename T> static
|
||||
Affine3<T> operator*(const Affine3<T>& affine1, const Affine3<T>& affine2);
|
||||
|
||||
template<typename T, typename V> static
|
||||
V operator*(const Affine3<T>& affine, const V& vector);
|
||||
|
||||
typedef Affine3<float> Affine3f;
|
||||
typedef Affine3<double> Affine3d;
|
||||
|
||||
static Vec3f operator*(const Affine3f& affine, const Vec3f& vector);
|
||||
static Vec3d operator*(const Affine3d& affine, const Vec3d& vector);
|
||||
|
||||
template<typename _Tp> class DataType< Affine3<_Tp> >
|
||||
{
|
||||
public:
|
||||
typedef Affine3<_Tp> value_type;
|
||||
typedef Affine3<typename DataType<_Tp>::work_type> work_type;
|
||||
typedef _Tp channel_type;
|
||||
|
||||
enum { generic_type = 0,
|
||||
depth = DataType<channel_type>::depth,
|
||||
channels = 16,
|
||||
fmt = DataType<channel_type>::fmt + ((channels - 1) << 8),
|
||||
type = CV_MAKETYPE(depth, channels)
|
||||
};
|
||||
|
||||
typedef Vec<channel_type, channels> vec_type;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////
|
||||
/// Implementaiton
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3()
|
||||
: matrix(Mat4::eye())
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Mat4& affine)
|
||||
: matrix(affine)
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Mat3& R, const Vec3& t)
|
||||
{
|
||||
rotation(R);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Vec3& _rvec, const Vec3& t)
|
||||
{
|
||||
rotation(_rvec);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const cv::Mat& data, const Vec3& t)
|
||||
{
|
||||
CV_Assert(data.type() == cv::DataType<T>::type);
|
||||
|
||||
if (data.cols == 4 && data.rows == 4)
|
||||
{
|
||||
data.copyTo(matrix);
|
||||
return;
|
||||
}
|
||||
else if (data.cols == 4 && data.rows == 3)
|
||||
{
|
||||
rotation(data(Rect(0, 0, 3, 3)));
|
||||
translation(data(Rect(3, 0, 1, 3)));
|
||||
return;
|
||||
}
|
||||
|
||||
rotation(data);
|
||||
translation(t);
|
||||
matrix.val[12] = matrix.val[13] = matrix.val[14] = 0;
|
||||
matrix.val[15] = 1;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const float_type* vals) : matrix(vals)
|
||||
{}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::Identity()
|
||||
{
|
||||
return Affine3<T>(cv::Affine3<T>::Mat4::eye());
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const Mat3& R)
|
||||
{
|
||||
linear(R);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const Vec3& _rvec)
|
||||
{
|
||||
double rx = _rvec[0], ry = _rvec[1], rz = _rvec[2];
|
||||
double theta = std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||
|
||||
if (theta < DBL_EPSILON)
|
||||
rotation(Mat3::eye());
|
||||
else
|
||||
{
|
||||
const double I[] = { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
|
||||
|
||||
double c = std::cos(theta);
|
||||
double s = std::sin(theta);
|
||||
double c1 = 1. - c;
|
||||
double itheta = theta ? 1./theta : 0.;
|
||||
|
||||
rx *= itheta; ry *= itheta; rz *= itheta;
|
||||
|
||||
double rrt[] = { rx*rx, rx*ry, rx*rz, rx*ry, ry*ry, ry*rz, rx*rz, ry*rz, rz*rz };
|
||||
double _r_x_[] = { 0, -rz, ry, rz, 0, -rx, -ry, rx, 0 };
|
||||
Mat3 R;
|
||||
|
||||
// R = cos(theta)*I + (1 - cos(theta))*r*rT + sin(theta)*[r_x]
|
||||
// where [r_x] is [0 -rz ry; rz 0 -rx; -ry rx 0]
|
||||
for(int k = 0; k < 9; ++k)
|
||||
R.val[k] = static_cast<float_type>(c*I[k] + c1*rrt[k] + s*_r_x_[k]);
|
||||
|
||||
rotation(R);
|
||||
}
|
||||
}
|
||||
|
||||
//Combines rotation methods above. Suports 3x3, 1x3, 3x1 sizes of data matrix;
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::rotation(const cv::Mat& data)
|
||||
{
|
||||
CV_Assert(data.type() == cv::DataType<T>::type);
|
||||
|
||||
if (data.cols == 3 && data.rows == 3)
|
||||
{
|
||||
Mat3 R;
|
||||
data.copyTo(R);
|
||||
rotation(R);
|
||||
}
|
||||
else if ((data.cols == 3 && data.rows == 1) || (data.cols == 1 && data.rows == 3))
|
||||
{
|
||||
Vec3 _rvec;
|
||||
data.reshape(1, 3).copyTo(_rvec);
|
||||
rotation(_rvec);
|
||||
}
|
||||
else
|
||||
CV_Assert(!"Input marix can be 3x3, 1x3 or 3x1");
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::linear(const Mat3& L)
|
||||
{
|
||||
matrix.val[0] = L.val[0]; matrix.val[1] = L.val[1]; matrix.val[ 2] = L.val[2];
|
||||
matrix.val[4] = L.val[3]; matrix.val[5] = L.val[4]; matrix.val[ 6] = L.val[5];
|
||||
matrix.val[8] = L.val[6]; matrix.val[9] = L.val[7]; matrix.val[10] = L.val[8];
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
void cv::Affine3<T>::translation(const Vec3& t)
|
||||
{
|
||||
matrix.val[3] = t[0]; matrix.val[7] = t[1]; matrix.val[11] = t[2];
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Mat3 cv::Affine3<T>::rotation() const
|
||||
{
|
||||
return linear();
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Mat3 cv::Affine3<T>::linear() const
|
||||
{
|
||||
typename cv::Affine3<T>::Mat3 R;
|
||||
R.val[0] = matrix.val[0]; R.val[1] = matrix.val[1]; R.val[2] = matrix.val[ 2];
|
||||
R.val[3] = matrix.val[4]; R.val[4] = matrix.val[5]; R.val[5] = matrix.val[ 6];
|
||||
R.val[6] = matrix.val[8]; R.val[7] = matrix.val[9]; R.val[8] = matrix.val[10];
|
||||
return R;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Vec3 cv::Affine3<T>::translation() const
|
||||
{
|
||||
return Vec3(matrix.val[3], matrix.val[7], matrix.val[11]);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
typename cv::Affine3<T>::Vec3 cv::Affine3<T>::rvec() const
|
||||
{
|
||||
cv::Vec3d w;
|
||||
cv::Matx33d u, vt, R = rotation();
|
||||
cv::SVD::compute(R, w, u, vt, cv::SVD::FULL_UV + cv::SVD::MODIFY_A);
|
||||
R = u * vt;
|
||||
|
||||
double rx = R.val[7] - R.val[5];
|
||||
double ry = R.val[2] - R.val[6];
|
||||
double rz = R.val[3] - R.val[1];
|
||||
|
||||
double s = std::sqrt((rx*rx + ry*ry + rz*rz)*0.25);
|
||||
double c = (R.val[0] + R.val[4] + R.val[8] - 1) * 0.5;
|
||||
c = c > 1.0 ? 1.0 : c < -1.0 ? -1.0 : c;
|
||||
double theta = acos(c);
|
||||
|
||||
if( s < 1e-5 )
|
||||
{
|
||||
if( c > 0 )
|
||||
rx = ry = rz = 0;
|
||||
else
|
||||
{
|
||||
double t;
|
||||
t = (R.val[0] + 1) * 0.5;
|
||||
rx = std::sqrt(std::max(t, 0.0));
|
||||
t = (R.val[4] + 1) * 0.5;
|
||||
ry = std::sqrt(std::max(t, 0.0)) * (R.val[1] < 0 ? -1.0 : 1.0);
|
||||
t = (R.val[8] + 1) * 0.5;
|
||||
rz = std::sqrt(std::max(t, 0.0)) * (R.val[2] < 0 ? -1.0 : 1.0);
|
||||
|
||||
if( fabs(rx) < fabs(ry) && fabs(rx) < fabs(rz) && (R.val[5] > 0) != (ry*rz > 0) )
|
||||
rz = -rz;
|
||||
theta /= std::sqrt(rx*rx + ry*ry + rz*rz);
|
||||
rx *= theta;
|
||||
ry *= theta;
|
||||
rz *= theta;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
double vth = 1/(2*s);
|
||||
vth *= theta;
|
||||
rx *= vth; ry *= vth; rz *= vth;
|
||||
}
|
||||
|
||||
return cv::Vec3d(rx, ry, rz);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::inv(int method) const
|
||||
{
|
||||
return matrix.inv(method);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::rotate(const Mat3& R) const
|
||||
{
|
||||
Mat3 Lc = linear();
|
||||
Vec3 tc = translation();
|
||||
Mat4 result;
|
||||
result.val[12] = result.val[13] = result.val[14] = 0;
|
||||
result.val[15] = 1;
|
||||
|
||||
for(int j = 0; j < 3; ++j)
|
||||
{
|
||||
for(int i = 0; i < 3; ++i)
|
||||
{
|
||||
float_type value = 0;
|
||||
for(int k = 0; k < 3; ++k)
|
||||
value += R(j, k) * Lc(k, i);
|
||||
result(j, i) = value;
|
||||
}
|
||||
|
||||
result(j, 3) = R.row(j).dot(tc.t());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::rotate(const Vec3& _rvec) const
|
||||
{
|
||||
return rotate(Affine3f(_rvec).rotation());
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::translate(const Vec3& t) const
|
||||
{
|
||||
Mat4 m = matrix;
|
||||
m.val[ 3] += t[0];
|
||||
m.val[ 7] += t[1];
|
||||
m.val[11] += t[2];
|
||||
return m;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::Affine3<T>::concatenate(const Affine3<T>& affine) const
|
||||
{
|
||||
return (*this).rotate(affine.rotation()).translate(affine.translation());
|
||||
}
|
||||
|
||||
template<typename T> template <typename Y> inline
|
||||
cv::Affine3<T>::operator Affine3<Y>() const
|
||||
{
|
||||
return Affine3<Y>(matrix);
|
||||
}
|
||||
|
||||
template<typename T> template <typename Y> inline
|
||||
cv::Affine3<Y> cv::Affine3<T>::cast() const
|
||||
{
|
||||
return Affine3<Y>(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T> cv::operator*(const cv::Affine3<T>& affine1, const cv::Affine3<T>& affine2)
|
||||
{
|
||||
return affine2.concatenate(affine1);
|
||||
}
|
||||
|
||||
template<typename T, typename V> inline
|
||||
V cv::operator*(const cv::Affine3<T>& affine, const V& v)
|
||||
{
|
||||
const typename Affine3<T>::Mat4& m = affine.matrix;
|
||||
|
||||
V r;
|
||||
r.x = m.val[0] * v.x + m.val[1] * v.y + m.val[ 2] * v.z + m.val[ 3];
|
||||
r.y = m.val[4] * v.x + m.val[5] * v.y + m.val[ 6] * v.z + m.val[ 7];
|
||||
r.z = m.val[8] * v.x + m.val[9] * v.y + m.val[10] * v.z + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline
|
||||
cv::Vec3f cv::operator*(const cv::Affine3f& affine, const cv::Vec3f& v)
|
||||
{
|
||||
const cv::Matx44f& m = affine.matrix;
|
||||
cv::Vec3f r;
|
||||
r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3];
|
||||
r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7];
|
||||
r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
static inline
|
||||
cv::Vec3d cv::operator*(const cv::Affine3d& affine, const cv::Vec3d& v)
|
||||
{
|
||||
const cv::Matx44d& m = affine.matrix;
|
||||
cv::Vec3d r;
|
||||
r.val[0] = m.val[0] * v[0] + m.val[1] * v[1] + m.val[ 2] * v[2] + m.val[ 3];
|
||||
r.val[1] = m.val[4] * v[0] + m.val[5] * v[1] + m.val[ 6] * v[2] + m.val[ 7];
|
||||
r.val[2] = m.val[8] * v[0] + m.val[9] * v[1] + m.val[10] * v[2] + m.val[11];
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>& affine)
|
||||
{
|
||||
cv::Mat(4, 4, cv::DataType<T>::type, affine.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::Affine3(const Eigen::Transform<T, 3, Eigen::Affine>& affine)
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> a = affine;
|
||||
cv::Mat(4, 4, cv::DataType<T>::type, a.matrix().data()).copyTo(matrix);
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>() const
|
||||
{
|
||||
Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)> r;
|
||||
cv::Mat hdr(4, 4, cv::DataType<T>::type, r.matrix().data());
|
||||
cv::Mat(matrix, false).copyTo(hdr);
|
||||
return r;
|
||||
}
|
||||
|
||||
template<typename T> inline
|
||||
cv::Affine3<T>::operator Eigen::Transform<T, 3, Eigen::Affine>() const
|
||||
{
|
||||
return this->operator Eigen::Transform<T, 3, Eigen::Affine, (Eigen::RowMajor)>();
|
||||
}
|
||||
|
||||
#endif /* defined EIGEN_WORLD_VERSION && defined EIGEN_GEOMETRY_MODULE_H */
|
||||
|
||||
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __OPENCV_CORE_AFFINE3_HPP__ */
|
@ -892,6 +892,7 @@ public:
|
||||
typedef Point_<int> Point2i;
|
||||
typedef Point2i Point;
|
||||
typedef Size_<int> Size2i;
|
||||
typedef Size_<double> Size2d;
|
||||
typedef Size2i Size;
|
||||
typedef Rect_<int> Rect;
|
||||
typedef Point_<float> Point2f;
|
||||
|
@ -245,7 +245,7 @@ enum {
|
||||
CV_StsVecLengthErr= -28, /* incorrect vector length */
|
||||
CV_StsFilterStructContentErr= -29, /* incorr. filter structure content */
|
||||
CV_StsKernelStructContentErr= -30, /* incorr. transform kernel content */
|
||||
CV_StsFilterOffsetErr= -31, /* incorrect filter ofset value */
|
||||
CV_StsFilterOffsetErr= -31, /* incorrect filter offset value */
|
||||
CV_StsBadSize= -201, /* the input/output structure size is incorrect */
|
||||
CV_StsDivByZero= -202, /* division by zero */
|
||||
CV_StsInplaceNotSupported= -203, /* in-place operation is not supported */
|
||||
|
@ -47,22 +47,27 @@
|
||||
#include "gl_core_3_1.hpp"
|
||||
|
||||
#ifdef HAVE_OPENGL
|
||||
#if defined(__APPLE__)
|
||||
#include <mach-o/dyld.h>
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <dlfcn.h>
|
||||
|
||||
static void* AppleGLGetProcAddress (const char* name)
|
||||
{
|
||||
static const struct mach_header* image = 0;
|
||||
if (!image)
|
||||
image = NSAddImage("/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL", NSADDIMAGE_OPTION_RETURN_ON_ERROR);
|
||||
static bool initialized = false;
|
||||
static void * handle = NULL;
|
||||
if (!handle)
|
||||
{
|
||||
if (!initialized)
|
||||
{
|
||||
initialized = true;
|
||||
const char * const path = "/System/Library/Frameworks/OpenGL.framework/Versions/Current/OpenGL";
|
||||
|
||||
// prepend a '_' for the Unix C symbol mangling convention
|
||||
std::string symbolName = "_";
|
||||
symbolName += std::string(name);
|
||||
|
||||
NSSymbol symbol = image ? NSLookupSymbolInImage(image, &symbolName[0], NSLOOKUPSYMBOLINIMAGE_OPTION_BIND | NSLOOKUPSYMBOLINIMAGE_OPTION_RETURN_ON_ERROR) : 0;
|
||||
|
||||
return symbol ? NSAddressOfSymbol(symbol) : 0;
|
||||
handle = dlopen(path, RTLD_LAZY | RTLD_GLOBAL);
|
||||
}
|
||||
if (!handle)
|
||||
return NULL;
|
||||
}
|
||||
return dlsym(handle, name);
|
||||
}
|
||||
#endif // __APPLE__
|
||||
|
||||
|
@ -2392,16 +2392,14 @@ TYPED_TEST_P(Core_CheckRange, Negative)
|
||||
double min_bound = 4.5;
|
||||
double max_bound = 16.0;
|
||||
|
||||
TypeParam data[] = {5, 10, 15, 4, 10 ,2, 8, 12, 14};
|
||||
TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14};
|
||||
cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data);
|
||||
|
||||
cv::Point* bad_pt = new cv::Point(0, 0);
|
||||
cv::Point bad_pt(0, 0);
|
||||
|
||||
ASSERT_FALSE(checkRange(src, true, bad_pt, min_bound, max_bound));
|
||||
ASSERT_EQ(bad_pt->x,0);
|
||||
ASSERT_EQ(bad_pt->y,1);
|
||||
|
||||
delete bad_pt;
|
||||
ASSERT_FALSE(checkRange(src, true, &bad_pt, min_bound, max_bound));
|
||||
ASSERT_EQ(bad_pt.x, 0);
|
||||
ASSERT_EQ(bad_pt.y, 1);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(Core_CheckRange, Positive)
|
||||
@ -2409,16 +2407,14 @@ TYPED_TEST_P(Core_CheckRange, Positive)
|
||||
double min_bound = -1;
|
||||
double max_bound = 16.0;
|
||||
|
||||
TypeParam data[] = {5, 10, 15, 4, 10 ,2, 8, 12, 14};
|
||||
TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14};
|
||||
cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data);
|
||||
|
||||
cv::Point* bad_pt = new cv::Point(0, 0);
|
||||
cv::Point bad_pt(0, 0);
|
||||
|
||||
ASSERT_TRUE(checkRange(src, true, bad_pt, min_bound, max_bound));
|
||||
ASSERT_EQ(bad_pt->x,0);
|
||||
ASSERT_EQ(bad_pt->y,0);
|
||||
|
||||
delete bad_pt;
|
||||
ASSERT_TRUE(checkRange(src, true, &bad_pt, min_bound, max_bound));
|
||||
ASSERT_EQ(bad_pt.x, 0);
|
||||
ASSERT_EQ(bad_pt.y, 0);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(Core_CheckRange, Bounds)
|
||||
@ -2426,16 +2422,14 @@ TYPED_TEST_P(Core_CheckRange, Bounds)
|
||||
double min_bound = 24.5;
|
||||
double max_bound = 1.0;
|
||||
|
||||
TypeParam data[] = {5, 10, 15, 4, 10 ,2, 8, 12, 14};
|
||||
TypeParam data[] = {5, 10, 15, 4, 10, 2, 8, 12, 14};
|
||||
cv::Mat src = cv::Mat(3,3, cv::DataDepth<TypeParam>::value, data);
|
||||
|
||||
cv::Point* bad_pt = new cv::Point(0, 0);
|
||||
cv::Point bad_pt(0, 0);
|
||||
|
||||
ASSERT_FALSE(checkRange(src, true, bad_pt, min_bound, max_bound));
|
||||
ASSERT_EQ(bad_pt->x,0);
|
||||
ASSERT_EQ(bad_pt->y,0);
|
||||
|
||||
delete bad_pt;
|
||||
ASSERT_FALSE(checkRange(src, true, &bad_pt, min_bound, max_bound));
|
||||
ASSERT_EQ(bad_pt.x, 0);
|
||||
ASSERT_EQ(bad_pt.y, 0);
|
||||
}
|
||||
|
||||
TYPED_TEST_P(Core_CheckRange, Zero)
|
||||
|
@ -129,15 +129,20 @@ public:
|
||||
|
||||
#if defined(USE_CUDA)
|
||||
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, CV_Func)
|
||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, CV_Func)
|
||||
// Disable NPP for this file
|
||||
//#define USE_NPP
|
||||
#undef USE_NPP
|
||||
|
||||
#define cudaSafeCall(expr) ___cudaSafeCall(expr, __FILE__, __LINE__, CV_Func)
|
||||
inline void ___cudaSafeCall(cudaError_t err, const char *file, const int line, const char *func = "")
|
||||
{
|
||||
if (cudaSuccess != err)
|
||||
cv::gpu::error(cudaGetErrorString(err), file, line, func);
|
||||
}
|
||||
|
||||
#ifdef USE_NPP
|
||||
|
||||
#define nppSafeCall(expr) ___nppSafeCall(expr, __FILE__, __LINE__, CV_Func)
|
||||
inline void ___nppSafeCall(int err, const char *file, const int line, const char *func = "")
|
||||
{
|
||||
if (err < 0)
|
||||
@ -148,6 +153,8 @@ inline void ___nppSafeCall(int err, const char *file, const int line, const char
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
void copyToWithMask_gpu(PtrStepSzb src, PtrStepSzb dst, size_t elemSize1, int cn, PtrStepSzb mask, bool colorMask, cudaStream_t stream);
|
||||
@ -173,6 +180,8 @@ template <typename T> void kernelSetCaller(GpuMat& src, Scalar s, const GpuMat&
|
||||
cv::gpu::device::set_to_gpu(src, sf.val, mask, src.channels(), stream);
|
||||
}
|
||||
|
||||
#ifdef USE_NPP
|
||||
|
||||
template<int n> struct NPPTypeTraits;
|
||||
template<> struct NPPTypeTraits<CV_8U> { typedef Npp8u npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_8S> { typedef Npp8s npp_type; };
|
||||
@ -182,9 +191,13 @@ template<> struct NPPTypeTraits<CV_32S> { typedef Npp32s npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_32F> { typedef Npp32f npp_type; };
|
||||
template<> struct NPPTypeTraits<CV_64F> { typedef Npp64f npp_type; };
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Convert
|
||||
|
||||
#ifdef USE_NPP
|
||||
|
||||
template<int SDEPTH, int DDEPTH> struct NppConvertFunc
|
||||
{
|
||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||
@ -232,9 +245,13 @@ template<int DDEPTH, typename NppConvertFunc<CV_32F, DDEPTH>::func_ptr func> str
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// Set
|
||||
|
||||
#ifdef USE_NPP
|
||||
|
||||
template<int SDEPTH, int SCN> struct NppSetFunc
|
||||
{
|
||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||
@ -339,9 +356,13 @@ template<int SDEPTH, typename NppSetMaskFunc<SDEPTH, 1>::func_ptr func> struct N
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// CopyMasked
|
||||
|
||||
#ifdef USE_NPP
|
||||
|
||||
template<int SDEPTH> struct NppCopyMaskedFunc
|
||||
{
|
||||
typedef typename NPPTypeTraits<SDEPTH>::npp_type src_t;
|
||||
@ -365,6 +386,8 @@ template<int SDEPTH, typename NppCopyMaskedFunc<SDEPTH>::func_ptr func> struct N
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
template <typename T> static inline bool isAligned(const T* ptr, size_t size)
|
||||
{
|
||||
return reinterpret_cast<size_t>(ptr) % size == 0;
|
||||
@ -877,6 +900,8 @@ public:
|
||||
}
|
||||
|
||||
typedef void (*func_t)(const GpuMat& src, GpuMat& dst, const GpuMat& mask, cudaStream_t stream);
|
||||
|
||||
#ifdef USE_NPP
|
||||
static const func_t funcs[7][4] =
|
||||
{
|
||||
/* 8U */ {NppCopyMasked<CV_8U , nppiCopy_8u_C1MR >::call, cv::gpu::device::copyWithMask, NppCopyMasked<CV_8U , nppiCopy_8u_C3MR >::call, NppCopyMasked<CV_8U , nppiCopy_8u_C4MR >::call},
|
||||
@ -889,6 +914,9 @@ public:
|
||||
};
|
||||
|
||||
const func_t func = mask.channels() == src.channels() ? funcs[src.depth()][src.channels() - 1] : cv::gpu::device::copyWithMask;
|
||||
#else
|
||||
const func_t func = cv::gpu::device::copyWithMask;
|
||||
#endif
|
||||
|
||||
func(src, dst, mask, 0);
|
||||
}
|
||||
@ -896,6 +924,8 @@ public:
|
||||
void convert(const GpuMat& src, GpuMat& dst) const
|
||||
{
|
||||
typedef void (*func_t)(const GpuMat& src, GpuMat& dst);
|
||||
|
||||
#ifdef USE_NPP
|
||||
static const func_t funcs[7][7][4] =
|
||||
{
|
||||
{
|
||||
@ -962,6 +992,7 @@ public:
|
||||
/* 64F -> 64F */ {0,0,0,0}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
CV_Assert(src.depth() <= CV_64F && src.channels() <= 4);
|
||||
CV_Assert(dst.depth() <= CV_64F);
|
||||
@ -980,8 +1011,12 @@ public:
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef USE_NPP
|
||||
const func_t func = funcs[src.depth()][dst.depth()][src.channels() - 1];
|
||||
CV_DbgAssert(func != 0);
|
||||
#else
|
||||
const func_t func = cv::gpu::device::convertTo;
|
||||
#endif
|
||||
|
||||
func(src, dst);
|
||||
}
|
||||
@ -1023,6 +1058,8 @@ public:
|
||||
}
|
||||
|
||||
typedef void (*func_t)(GpuMat& src, Scalar s);
|
||||
|
||||
#ifdef USE_NPP
|
||||
static const func_t funcs[7][4] =
|
||||
{
|
||||
{NppSet<CV_8U , 1, nppiSet_8u_C1R >::call, cv::gpu::device::setTo , cv::gpu::device::setTo , NppSet<CV_8U , 4, nppiSet_8u_C4R >::call},
|
||||
@ -1033,6 +1070,7 @@ public:
|
||||
{NppSet<CV_32F, 1, nppiSet_32f_C1R>::call, cv::gpu::device::setTo , cv::gpu::device::setTo , NppSet<CV_32F, 4, nppiSet_32f_C4R>::call},
|
||||
{cv::gpu::device::setTo , cv::gpu::device::setTo , cv::gpu::device::setTo , cv::gpu::device::setTo }
|
||||
};
|
||||
#endif
|
||||
|
||||
CV_Assert(m.depth() <= CV_64F && m.channels() <= 4);
|
||||
|
||||
@ -1042,14 +1080,22 @@ public:
|
||||
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
#ifdef USE_NPP
|
||||
const func_t func = funcs[m.depth()][m.channels() - 1];
|
||||
#else
|
||||
const func_t func = cv::gpu::device::setTo;
|
||||
#endif
|
||||
|
||||
if (stream)
|
||||
cv::gpu::device::setTo(m, s, stream);
|
||||
else
|
||||
funcs[m.depth()][m.channels() - 1](m, s);
|
||||
func(m, s);
|
||||
}
|
||||
else
|
||||
{
|
||||
typedef void (*func_t)(GpuMat& src, Scalar s, const GpuMat& mask);
|
||||
|
||||
#ifdef USE_NPP
|
||||
static const func_t funcs[7][4] =
|
||||
{
|
||||
{NppSetMask<CV_8U , 1, nppiSet_8u_C1MR >::call, cv::gpu::device::setTo, cv::gpu::device::setTo, NppSetMask<CV_8U , 4, nppiSet_8u_C4MR >::call},
|
||||
@ -1060,6 +1106,7 @@ public:
|
||||
{NppSetMask<CV_32F, 1, nppiSet_32f_C1MR>::call, cv::gpu::device::setTo, cv::gpu::device::setTo, NppSetMask<CV_32F, 4, nppiSet_32f_C4MR>::call},
|
||||
{cv::gpu::device::setTo , cv::gpu::device::setTo, cv::gpu::device::setTo, cv::gpu::device::setTo }
|
||||
};
|
||||
#endif
|
||||
|
||||
CV_Assert(m.depth() <= CV_64F && m.channels() <= 4);
|
||||
|
||||
@ -1069,10 +1116,16 @@ public:
|
||||
CV_Error(CV_StsUnsupportedFormat, "The device doesn't support double");
|
||||
}
|
||||
|
||||
#ifdef USE_NPP
|
||||
const func_t func = funcs[m.depth()][m.channels() - 1];
|
||||
#else
|
||||
const func_t func = cv::gpu::device::setTo;
|
||||
#endif
|
||||
|
||||
if (stream)
|
||||
cv::gpu::device::setTo(m, s, mask, stream);
|
||||
else
|
||||
funcs[m.depth()][m.channels() - 1](m, s, mask);
|
||||
func(m, s, mask);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM,
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// StereoBeliefPropagation
|
||||
|
||||
PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation,
|
||||
PERF_TEST_P(ImagePair, DISABLED_Calib3D_StereoBeliefPropagation,
|
||||
Values(pair_string("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png")))
|
||||
{
|
||||
declare.time(300.0);
|
||||
|
@ -851,6 +851,8 @@ PERF_TEST_P(Sz_Depth_Cn, ImgProc_BlendLinear,
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef HAVE_CUFFT
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// Convolve
|
||||
|
||||
@ -1085,6 +1087,8 @@ PERF_TEST_P(Sz_Flags, ImgProc_Dft,
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////
|
||||
// CornerHarris
|
||||
|
||||
@ -1538,7 +1542,7 @@ CV_ENUM(AlphaOp, ALPHA_OVER, ALPHA_IN, ALPHA_OUT, ALPHA_ATOP, ALPHA_XOR, ALPHA_P
|
||||
|
||||
DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, AlphaOp);
|
||||
|
||||
PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp,
|
||||
PERF_TEST_P(Sz_Type_Op, DISABLED_ImgProc_AlphaComp,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(CV_8UC4, CV_16UC4, CV_32SC4, CV_32FC4),
|
||||
AlphaOp::all()))
|
||||
@ -1559,7 +1563,14 @@ PERF_TEST_P(Sz_Type_Op, ImgProc_AlphaComp,
|
||||
|
||||
TEST_CYCLE() cv::gpu::alphaComp(d_img1, d_img2, dst, alpha_op);
|
||||
|
||||
GPU_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
|
||||
if (CV_MAT_DEPTH(type) < CV_32F)
|
||||
{
|
||||
GPU_SANITY_CHECK(dst, 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
GPU_SANITY_CHECK(dst, 1e-3, ERROR_RELATIVE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1825,7 +1836,7 @@ CV_FLAGS(GHMethod, GHT_POSITION, GHT_SCALE, GHT_ROTATION)
|
||||
|
||||
DEF_PARAM_TEST(Method_Sz, GHMethod, cv::Size);
|
||||
|
||||
PERF_TEST_P(Method_Sz, ImgProc_GeneralizedHough,
|
||||
PERF_TEST_P(Method_Sz, DISABLED_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))
|
||||
{
|
||||
|
@ -42,8 +42,6 @@
|
||||
|
||||
#if !defined CUDA_DISABLER
|
||||
|
||||
#include <utility>
|
||||
#include <algorithm>//std::swap
|
||||
#include "opencv2/gpu/device/common.hpp"
|
||||
#include "opencv2/gpu/device/emulation.hpp"
|
||||
#include "opencv2/gpu/device/transform.hpp"
|
||||
@ -239,30 +237,35 @@ namespace canny
|
||||
{
|
||||
__device__ int counter = 0;
|
||||
|
||||
__global__ void edgesHysteresisLocalKernel(PtrStepSzi map, ushort2* st)
|
||||
__device__ __forceinline__ bool checkIdx(int y, int x, int rows, int cols)
|
||||
{
|
||||
return (y >= 0) && (y < rows) && (x >= 0) && (x < cols);
|
||||
}
|
||||
|
||||
__global__ void edgesHysteresisLocalKernel(PtrStepSzi map, short2* st)
|
||||
{
|
||||
__shared__ volatile int smem[18][18];
|
||||
|
||||
const int x = blockIdx.x * blockDim.x + threadIdx.x;
|
||||
const int y = blockIdx.y * blockDim.y + threadIdx.y;
|
||||
|
||||
smem[threadIdx.y + 1][threadIdx.x + 1] = x < map.cols && y < map.rows ? map(y, x) : 0;
|
||||
smem[threadIdx.y + 1][threadIdx.x + 1] = checkIdx(y, x, map.rows, map.cols) ? map(y, x) : 0;
|
||||
if (threadIdx.y == 0)
|
||||
smem[0][threadIdx.x + 1] = y > 0 ? map(y - 1, x) : 0;
|
||||
smem[0][threadIdx.x + 1] = checkIdx(y - 1, x, map.rows, map.cols) ? map(y - 1, x) : 0;
|
||||
if (threadIdx.y == blockDim.y - 1)
|
||||
smem[blockDim.y + 1][threadIdx.x + 1] = y + 1 < map.rows ? map(y + 1, x) : 0;
|
||||
smem[blockDim.y + 1][threadIdx.x + 1] = checkIdx(y + 1, x, map.rows, map.cols) ? map(y + 1, x) : 0;
|
||||
if (threadIdx.x == 0)
|
||||
smem[threadIdx.y + 1][0] = x > 0 ? map(y, x - 1) : 0;
|
||||
smem[threadIdx.y + 1][0] = checkIdx(y, x - 1, map.rows, map.cols) ? map(y, x - 1) : 0;
|
||||
if (threadIdx.x == blockDim.x - 1)
|
||||
smem[threadIdx.y + 1][blockDim.x + 1] = x + 1 < map.cols ? map(y, x + 1) : 0;
|
||||
smem[threadIdx.y + 1][blockDim.x + 1] = checkIdx(y, x + 1, map.rows, map.cols) ? map(y, x + 1) : 0;
|
||||
if (threadIdx.x == 0 && threadIdx.y == 0)
|
||||
smem[0][0] = y > 0 && x > 0 ? map(y - 1, x - 1) : 0;
|
||||
smem[0][0] = checkIdx(y - 1, x - 1, map.rows, map.cols) ? map(y - 1, x - 1) : 0;
|
||||
if (threadIdx.x == blockDim.x - 1 && threadIdx.y == 0)
|
||||
smem[0][blockDim.x + 1] = y > 0 && x + 1 < map.cols ? map(y - 1, x + 1) : 0;
|
||||
smem[0][blockDim.x + 1] = checkIdx(y - 1, x + 1, map.rows, map.cols) ? map(y - 1, x + 1) : 0;
|
||||
if (threadIdx.x == 0 && threadIdx.y == blockDim.y - 1)
|
||||
smem[blockDim.y + 1][0] = y + 1 < map.rows && x > 0 ? map(y + 1, x - 1) : 0;
|
||||
smem[blockDim.y + 1][0] = checkIdx(y + 1, x - 1, map.rows, map.cols) ? map(y + 1, x - 1) : 0;
|
||||
if (threadIdx.x == blockDim.x - 1 && threadIdx.y == blockDim.y - 1)
|
||||
smem[blockDim.y + 1][blockDim.x + 1] = y + 1 < map.rows && x + 1 < map.cols ? map(y + 1, x + 1) : 0;
|
||||
smem[blockDim.y + 1][blockDim.x + 1] = checkIdx(y + 1, x + 1, map.rows, map.cols) ? map(y + 1, x + 1) : 0;
|
||||
|
||||
__syncthreads();
|
||||
|
||||
@ -290,8 +293,12 @@ namespace canny
|
||||
n += smem[threadIdx.y + 2][threadIdx.x + 2] == 2;
|
||||
}
|
||||
|
||||
__syncthreads();
|
||||
|
||||
if (n > 0)
|
||||
smem[threadIdx.y + 1][threadIdx.x + 1] = 2;
|
||||
|
||||
__syncthreads();
|
||||
}
|
||||
|
||||
const int e = smem[threadIdx.y + 1][threadIdx.x + 1];
|
||||
@ -317,11 +324,11 @@ namespace canny
|
||||
if (n > 0)
|
||||
{
|
||||
const int ind = ::atomicAdd(&counter, 1);
|
||||
st[ind] = make_ushort2(x, y);
|
||||
st[ind] = make_short2(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
void edgesHysteresisLocal(PtrStepSzi map, ushort2* st1)
|
||||
void edgesHysteresisLocal(PtrStepSzi map, short2* st1)
|
||||
{
|
||||
void* counter_ptr;
|
||||
cudaSafeCall( cudaGetSymbolAddress(&counter_ptr, counter) );
|
||||
@ -345,13 +352,13 @@ namespace canny
|
||||
__constant__ int c_dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
|
||||
__constant__ int c_dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
|
||||
|
||||
__global__ void edgesHysteresisGlobalKernel(PtrStepSzi map, ushort2* st1, ushort2* st2, const int count)
|
||||
__global__ void edgesHysteresisGlobalKernel(PtrStepSzi map, short2* st1, short2* st2, const int count)
|
||||
{
|
||||
const int stack_size = 512;
|
||||
|
||||
__shared__ int s_counter;
|
||||
__shared__ int s_ind;
|
||||
__shared__ ushort2 s_st[stack_size];
|
||||
__shared__ short2 s_st[stack_size];
|
||||
|
||||
if (threadIdx.x == 0)
|
||||
s_counter = 0;
|
||||
@ -363,14 +370,14 @@ namespace canny
|
||||
if (ind >= count)
|
||||
return;
|
||||
|
||||
ushort2 pos = st1[ind];
|
||||
short2 pos = st1[ind];
|
||||
|
||||
if (threadIdx.x < 8)
|
||||
{
|
||||
pos.x += c_dx[threadIdx.x];
|
||||
pos.y += c_dy[threadIdx.x];
|
||||
|
||||
if (pos.x > 0 && pos.x < map.cols && pos.y > 0 && pos.y < map.rows && map(pos.y, pos.x) == 1)
|
||||
if (pos.x > 0 && pos.x < map.cols - 1 && pos.y > 0 && pos.y < map.rows - 1 && map(pos.y, pos.x) == 1)
|
||||
{
|
||||
map(pos.y, pos.x) = 2;
|
||||
|
||||
@ -402,7 +409,7 @@ namespace canny
|
||||
pos.x += c_dx[threadIdx.x & 7];
|
||||
pos.y += c_dy[threadIdx.x & 7];
|
||||
|
||||
if (pos.x > 0 && pos.x < map.cols && pos.y > 0 && pos.y < map.rows && map(pos.y, pos.x) == 1)
|
||||
if (pos.x > 0 && pos.x < map.cols - 1 && pos.y > 0 && pos.y < map.rows - 1 && map(pos.y, pos.x) == 1)
|
||||
{
|
||||
map(pos.y, pos.x) = 2;
|
||||
|
||||
@ -419,8 +426,10 @@ namespace canny
|
||||
{
|
||||
if (threadIdx.x == 0)
|
||||
{
|
||||
ind = ::atomicAdd(&counter, s_counter);
|
||||
s_ind = ind - s_counter;
|
||||
s_ind = ::atomicAdd(&counter, s_counter);
|
||||
|
||||
if (s_ind + s_counter > map.cols * map.rows)
|
||||
s_counter = 0;
|
||||
}
|
||||
|
||||
__syncthreads();
|
||||
@ -432,7 +441,7 @@ namespace canny
|
||||
}
|
||||
}
|
||||
|
||||
void edgesHysteresisGlobal(PtrStepSzi map, ushort2* st1, ushort2* st2)
|
||||
void edgesHysteresisGlobal(PtrStepSzi map, short2* st1, short2* st2)
|
||||
{
|
||||
void* counter_ptr;
|
||||
cudaSafeCall( cudaGetSymbolAddress(&counter_ptr, canny::counter) );
|
||||
@ -454,7 +463,12 @@ namespace canny
|
||||
|
||||
cudaSafeCall( cudaMemcpy(&count, counter_ptr, sizeof(int), cudaMemcpyDeviceToHost) );
|
||||
|
||||
std::swap(st1, st2);
|
||||
count = min(count, map.cols * map.rows);
|
||||
|
||||
//std::swap(st1, st2);
|
||||
short2* tmp = st1;
|
||||
st1 = st2;
|
||||
st2 = tmp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,6 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#define CUDA_DISABLER
|
||||
|
||||
#if !defined CUDA_DISABLER
|
||||
|
||||
#include <thrust/device_ptr.h>
|
||||
|
@ -266,7 +266,7 @@ namespace cv { namespace gpu { namespace device
|
||||
__device__ __forceinline__ int calcDist(const uchar2& a, const uchar2& b) { return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y); }
|
||||
__device__ __forceinline__ int calcDist(const uchar3& a, const uchar3& b) { return (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) + (a.z-b.z)*(a.z-b.z); }
|
||||
|
||||
template <class T> struct FastNonLocalMenas
|
||||
template <class T> struct FastNonLocalMeans
|
||||
{
|
||||
enum
|
||||
{
|
||||
@ -290,7 +290,7 @@ namespace cv { namespace gpu { namespace device
|
||||
int block_window;
|
||||
float minus_h2_inv;
|
||||
|
||||
FastNonLocalMenas(int search_window_, int block_window_, float h) : search_radius(search_window_/2), block_radius(block_window_/2),
|
||||
FastNonLocalMeans(int search_window_, int block_window_, float h) : search_radius(search_window_/2), block_radius(block_window_/2),
|
||||
search_window(search_window_), block_window(block_window_), minus_h2_inv(-1.f/(h * h * VecTraits<T>::cn)) {}
|
||||
|
||||
PtrStep<T> src;
|
||||
@ -394,7 +394,7 @@ namespace cv { namespace gpu { namespace device
|
||||
}
|
||||
}
|
||||
|
||||
__device__ __forceinline__ void convolve_window(int i, int j, const int* dist_sums, PtrStepi& col_sums, PtrStepi& up_col_sums, T& dst) const
|
||||
__device__ __forceinline__ void convolve_window(int i, int j, const int* dist_sums, T& dst) const
|
||||
{
|
||||
typedef typename TypeVec<float, VecTraits<T>::cn>::vec_type sum_type;
|
||||
|
||||
@ -471,18 +471,18 @@ namespace cv { namespace gpu { namespace device
|
||||
|
||||
__syncthreads();
|
||||
|
||||
convolve_window(i, j, dist_sums, col_sums, up_col_sums, dst(i, j));
|
||||
convolve_window(i, j, dist_sums, dst(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
template<typename T>
|
||||
__global__ void fast_nlm_kernel(const FastNonLocalMenas<T> fnlm, PtrStepSz<T> dst) { fnlm(dst); }
|
||||
__global__ void fast_nlm_kernel(const FastNonLocalMeans<T> fnlm, PtrStepSz<T> dst) { fnlm(dst); }
|
||||
|
||||
void nln_fast_get_buffer_size(const PtrStepSzb& src, int search_window, int block_window, int& buffer_cols, int& buffer_rows)
|
||||
{
|
||||
typedef FastNonLocalMenas<uchar> FNLM;
|
||||
typedef FastNonLocalMeans<uchar> FNLM;
|
||||
dim3 grid(divUp(src.cols, FNLM::TILE_COLS), divUp(src.rows, FNLM::TILE_ROWS));
|
||||
|
||||
buffer_cols = search_window * search_window * grid.y;
|
||||
@ -493,7 +493,7 @@ namespace cv { namespace gpu { namespace device
|
||||
void nlm_fast_gpu(const PtrStepSzb& src, PtrStepSzb dst, PtrStepi buffer,
|
||||
int search_window, int block_window, float h, cudaStream_t stream)
|
||||
{
|
||||
typedef FastNonLocalMenas<T> FNLM;
|
||||
typedef FastNonLocalMeans<T> FNLM;
|
||||
FNLM fnlm(search_window, block_window, h);
|
||||
|
||||
fnlm.src = (PtrStepSz<T>)src;
|
||||
|
@ -40,8 +40,6 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#define CUDA_DISABLER
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
@ -244,6 +244,10 @@ void cv::gpu::reprojectImageTo3D(const GpuMat& disp, GpuMat& xyz, const Mat& Q,
|
||||
////////////////////////////////////////////////////////////////////////
|
||||
// copyMakeBorder
|
||||
|
||||
// Disable NPP for this file
|
||||
//#define USE_NPP
|
||||
#undef USE_NPP
|
||||
|
||||
namespace cv { namespace gpu { namespace device
|
||||
{
|
||||
namespace imgproc
|
||||
@ -279,6 +283,7 @@ void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom
|
||||
|
||||
cudaStream_t stream = StreamAccessor::getStream(s);
|
||||
|
||||
#ifdef USE_NPP
|
||||
if (borderType == BORDER_CONSTANT && (src.type() == CV_8UC1 || src.type() == CV_8UC4 || src.type() == CV_32SC1 || src.type() == CV_32FC1))
|
||||
{
|
||||
NppiSize srcsz;
|
||||
@ -328,6 +333,7 @@ void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom
|
||||
cudaSafeCall( cudaDeviceSynchronize() );
|
||||
}
|
||||
else
|
||||
#endif
|
||||
{
|
||||
typedef void (*caller_t)(const PtrStepSzb& src, const PtrStepSzb& dst, int top, int left, int borderType, const Scalar& value, cudaStream_t stream);
|
||||
static const caller_t callers[6][4] =
|
||||
@ -1485,6 +1491,8 @@ void cv::gpu::convolve(const GpuMat& image, const GpuMat& templ, GpuMat& result,
|
||||
|
||||
void cv::gpu::CannyBuf::create(const Size& image_size, int apperture_size)
|
||||
{
|
||||
CV_Assert(image_size.width < std::numeric_limits<short>::max() && image_size.height < std::numeric_limits<short>::max());
|
||||
|
||||
if (apperture_size > 0)
|
||||
{
|
||||
ensureSizeIsEnough(image_size, CV_32SC1, dx);
|
||||
@ -1500,8 +1508,8 @@ void cv::gpu::CannyBuf::create(const Size& image_size, int apperture_size)
|
||||
ensureSizeIsEnough(image_size, CV_32FC1, mag);
|
||||
ensureSizeIsEnough(image_size, CV_32SC1, map);
|
||||
|
||||
ensureSizeIsEnough(1, image_size.area(), CV_16UC2, st1);
|
||||
ensureSizeIsEnough(1, image_size.area(), CV_16UC2, st2);
|
||||
ensureSizeIsEnough(1, image_size.area(), CV_16SC2, st1);
|
||||
ensureSizeIsEnough(1, image_size.area(), CV_16SC2, st2);
|
||||
}
|
||||
|
||||
void cv::gpu::CannyBuf::release()
|
||||
@ -1521,9 +1529,9 @@ namespace canny
|
||||
|
||||
void calcMap(PtrStepSzi dx, PtrStepSzi dy, PtrStepSzf mag, PtrStepSzi map, float low_thresh, float high_thresh);
|
||||
|
||||
void edgesHysteresisLocal(PtrStepSzi map, ushort2* st1);
|
||||
void edgesHysteresisLocal(PtrStepSzi map, short2* st1);
|
||||
|
||||
void edgesHysteresisGlobal(PtrStepSzi map, ushort2* st1, ushort2* st2);
|
||||
void edgesHysteresisGlobal(PtrStepSzi map, short2* st1, short2* st2);
|
||||
|
||||
void getEdges(PtrStepSzi map, PtrStepSzb dst);
|
||||
}
|
||||
@ -1537,9 +1545,9 @@ namespace
|
||||
buf.map.setTo(Scalar::all(0));
|
||||
calcMap(dx, dy, buf.mag, buf.map, low_thresh, high_thresh);
|
||||
|
||||
edgesHysteresisLocal(buf.map, buf.st1.ptr<ushort2>());
|
||||
edgesHysteresisLocal(buf.map, buf.st1.ptr<short2>());
|
||||
|
||||
edgesHysteresisGlobal(buf.map, buf.st1.ptr<ushort2>(), buf.st2.ptr<ushort2>());
|
||||
edgesHysteresisGlobal(buf.map, buf.st1.ptr<short2>(), buf.st2.ptr<short2>());
|
||||
|
||||
getEdges(buf.map, dst);
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ bool TestHaarCascadeLoader::process()
|
||||
NCV_SET_SKIP_COND(this->allocatorGPU.get()->isCounting());
|
||||
NCV_SKIP_COND_BEGIN
|
||||
|
||||
const std::string testNvbinName = "test.nvbin";
|
||||
const std::string testNvbinName = cv::tempfile("test.nvbin");
|
||||
ncvStat = ncvHaarLoadFromFile_host(this->cascadeName, haar, h_HaarStages, h_HaarNodes, h_HaarFeatures);
|
||||
ncvAssertReturn(ncvStat == NCV_SUCCESS, false);
|
||||
|
||||
|
@ -715,7 +715,7 @@ GPU_TEST_P(CvtColor, BGR2YCrCb)
|
||||
cv::Mat dst_gold;
|
||||
cv::cvtColor(src, dst_gold, cv::COLOR_BGR2YCrCb);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 1.0);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, RGB2YCrCb)
|
||||
@ -728,7 +728,7 @@ GPU_TEST_P(CvtColor, RGB2YCrCb)
|
||||
cv::Mat dst_gold;
|
||||
cv::cvtColor(src, dst_gold, cv::COLOR_RGB2YCrCb);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 1.0);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, BGR2YCrCb4)
|
||||
@ -749,7 +749,7 @@ GPU_TEST_P(CvtColor, BGR2YCrCb4)
|
||||
cv::split(h_dst, channels);
|
||||
cv::merge(channels, 3, h_dst);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1.0);
|
||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, RGBA2YCrCb4)
|
||||
@ -771,7 +771,7 @@ GPU_TEST_P(CvtColor, RGBA2YCrCb4)
|
||||
cv::split(h_dst, channels);
|
||||
cv::merge(channels, 3, h_dst);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, h_dst, 1.0);
|
||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, YCrCb2BGR)
|
||||
|
@ -3582,7 +3582,7 @@ GPU_TEST_P(Normalize, WithOutMask)
|
||||
cv::Mat dst_gold;
|
||||
cv::normalize(src, dst_gold, alpha, beta, norm_type, type);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 1.0);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, type < CV_32F ? 1.0 : 1e-4);
|
||||
}
|
||||
|
||||
GPU_TEST_P(Normalize, WithMask)
|
||||
@ -3598,7 +3598,7 @@ GPU_TEST_P(Normalize, WithMask)
|
||||
dst_gold.setTo(cv::Scalar::all(0));
|
||||
cv::normalize(src, dst_gold, alpha, beta, norm_type, type, mask);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 1.0);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, type < CV_32F ? 1.0 : 1e-4);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_Core, Normalize, testing::Combine(
|
||||
|
@ -114,6 +114,7 @@ GPU_TEST_P(BruteForceNonLocalMeans, Regression)
|
||||
|
||||
cv::Mat bgr = readImage("denoising/lena_noised_gaussian_sigma=20_multi_0.png", cv::IMREAD_COLOR);
|
||||
ASSERT_FALSE(bgr.empty());
|
||||
cv::resize(bgr, bgr, cv::Size(256, 256));
|
||||
|
||||
cv::Mat gray;
|
||||
cv::cvtColor(bgr, gray, CV_BGR2GRAY);
|
||||
@ -130,6 +131,8 @@ GPU_TEST_P(BruteForceNonLocalMeans, Regression)
|
||||
cv::Mat bgr_gold = readImage("denoising/nlm_denoised_lena_bgr.png", cv::IMREAD_COLOR);
|
||||
cv::Mat gray_gold = readImage("denoising/nlm_denoised_lena_gray.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(bgr_gold.empty() || gray_gold.empty());
|
||||
cv::resize(bgr_gold, bgr_gold, cv::Size(256, 256));
|
||||
cv::resize(gray_gold, gray_gold, cv::Size(256, 256));
|
||||
|
||||
EXPECT_MAT_NEAR(bgr_gold, dbgr, 1e-4);
|
||||
EXPECT_MAT_NEAR(gray_gold, dgray, 1e-4);
|
||||
|
@ -281,7 +281,7 @@ GPU_TEST_P(ConvertTo, WithOutScaling)
|
||||
cv::Mat dst_gold;
|
||||
src.convertTo(dst_gold, depth2);
|
||||
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 1.0);
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth2 < CV_32F ? 1.0 : 1e-4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -189,7 +189,7 @@ PARAM_TEST_CASE(GeneralizedHough, cv::gpu::DeviceInfo, UseRoi)
|
||||
{
|
||||
};
|
||||
|
||||
GPU_TEST_P(GeneralizedHough, DISABLED_POSITION)
|
||||
GPU_TEST_P(GeneralizedHough, POSITION)
|
||||
{
|
||||
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
|
||||
cv::gpu::setDevice(devInfo.deviceID());
|
||||
|
@ -563,6 +563,8 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, testing::Combine(
|
||||
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
|
||||
WHOLE_SUBMAT));
|
||||
|
||||
#ifdef HAVE_CUFFT
|
||||
|
||||
////////////////////////////////////////////////////////
|
||||
// Convolve
|
||||
|
||||
@ -1090,6 +1092,8 @@ GPU_TEST_P(Dft, R2CThenC2R)
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Dft, ALL_DEVICES);
|
||||
|
||||
#endif
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// CornerHarris
|
||||
|
||||
|
@ -483,13 +483,15 @@ GPU_TEST_P(OpticalFlowBM, Accuracy)
|
||||
|
||||
cv::Mat frame0 = readImage("opticalflow/rubberwhale1.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame0.empty());
|
||||
cv::resize(frame0, frame0, cv::Size(), 0.5, 0.5);
|
||||
|
||||
cv::Mat frame1 = readImage("opticalflow/rubberwhale2.png", cv::IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(frame1.empty());
|
||||
cv::resize(frame1, frame1, cv::Size(), 0.5, 0.5);
|
||||
|
||||
cv::Size block_size(16, 16);
|
||||
cv::Size block_size(8, 8);
|
||||
cv::Size shift_size(1, 1);
|
||||
cv::Size max_range(16, 16);
|
||||
cv::Size max_range(8, 8);
|
||||
|
||||
cv::gpu::GpuMat d_velx, d_vely, buf;
|
||||
cv::gpu::calcOpticalFlowBM(loadMat(frame0), loadMat(frame1),
|
||||
|
@ -278,8 +278,20 @@
|
||||
{
|
||||
self.captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
|
||||
|
||||
if ([self.captureVideoPreviewLayer isOrientationSupported]) {
|
||||
[self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation];
|
||||
if ([self.captureVideoPreviewLayer respondsToSelector:@selector(connection)])
|
||||
{
|
||||
if ([self.captureVideoPreviewLayer.connection isVideoOrientationSupported])
|
||||
{
|
||||
[self.captureVideoPreviewLayer.connection setVideoOrientation:self.defaultAVCaptureVideoOrientation];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Deprecated in 6.0; here for backward compatibility
|
||||
if ([self.captureVideoPreviewLayer isOrientationSupported])
|
||||
{
|
||||
[self.captureVideoPreviewLayer setOrientation:self.defaultAVCaptureVideoOrientation];
|
||||
}
|
||||
}
|
||||
|
||||
if (parentView != nil) {
|
||||
@ -290,9 +302,6 @@
|
||||
NSLog(@"[Camera] created AVCaptureVideoPreviewLayer");
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
- (void)setDesiredCameraPosition:(AVCaptureDevicePosition)desiredPosition;
|
||||
{
|
||||
for (AVCaptureDevice *device in [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]) {
|
||||
|
@ -111,18 +111,21 @@ bool TiffDecoder::readHeader()
|
||||
bool result = false;
|
||||
|
||||
close();
|
||||
TIFF* tif = TIFFOpen( m_filename.c_str(), "rb" );
|
||||
// TIFFOpen() mode flags are different to fopen(). A 'b' in mode "rb" has no effect when reading.
|
||||
// http://www.remotesensing.org/libtiff/man/TIFFOpen.3tiff.html
|
||||
TIFF* tif = TIFFOpen( m_filename.c_str(), "r" );
|
||||
|
||||
if( tif )
|
||||
{
|
||||
int wdth = 0, hght = 0, photometric = 0;
|
||||
uint32 wdth = 0, hght = 0;
|
||||
uint16 photometric = 0;
|
||||
m_tif = tif;
|
||||
|
||||
if( TIFFGetField( tif, TIFFTAG_IMAGEWIDTH, &wdth ) &&
|
||||
TIFFGetField( tif, TIFFTAG_IMAGELENGTH, &hght ) &&
|
||||
TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric ))
|
||||
{
|
||||
int bpp=8, ncn = photometric > 1 ? 3 : 1;
|
||||
uint16 bpp=8, ncn = photometric > 1 ? 3 : 1;
|
||||
TIFFGetField( tif, TIFFTAG_BITSPERSAMPLE, &bpp );
|
||||
TIFFGetField( tif, TIFFTAG_SAMPLESPERPIXEL, &ncn );
|
||||
|
||||
@ -175,12 +178,12 @@ bool TiffDecoder::readData( Mat& img )
|
||||
if( m_tif && m_width && m_height )
|
||||
{
|
||||
TIFF* tif = (TIFF*)m_tif;
|
||||
int tile_width0 = m_width, tile_height0 = 0;
|
||||
uint32 tile_width0 = m_width, tile_height0 = 0;
|
||||
int x, y, i;
|
||||
int is_tiled = TIFFIsTiled(tif);
|
||||
int photometric;
|
||||
uint16 photometric;
|
||||
TIFFGetField( tif, TIFFTAG_PHOTOMETRIC, &photometric );
|
||||
int bpp = 8, ncn = photometric > 1 ? 3 : 1;
|
||||
uint16 bpp = 8, ncn = photometric > 1 ? 3 : 1;
|
||||
TIFFGetField( tif, TIFFTAG_BITSPERSAMPLE, &bpp );
|
||||
TIFFGetField( tif, TIFFTAG_SAMPLESPERPIXEL, &ncn );
|
||||
const int bitsPerByte = 8;
|
||||
|
@ -88,7 +88,7 @@ public:
|
||||
stringstream s;
|
||||
s << tag;
|
||||
|
||||
const string filename = "output_"+s.str()+".avi";
|
||||
const string filename = tempfile((s.str()+".avi").c_str());
|
||||
|
||||
try
|
||||
{
|
||||
|
@ -408,8 +408,8 @@ TEST(Highgui_Tiff, decode_tile16384x16384)
|
||||
|
||||
try
|
||||
{
|
||||
cv::imread(file3);
|
||||
EXPECT_NO_THROW(cv::imread(file4));
|
||||
cv::imread(file3, CV_LOAD_IMAGE_UNCHANGED);
|
||||
EXPECT_NO_THROW(cv::imread(file4, CV_LOAD_IMAGE_UNCHANGED));
|
||||
}
|
||||
catch(const std::bad_alloc&)
|
||||
{
|
||||
@ -420,6 +420,53 @@ TEST(Highgui_Tiff, decode_tile16384x16384)
|
||||
remove(file4.c_str());
|
||||
}
|
||||
|
||||
class CV_GrfmtReadTifTiledWithNotFullTiles: public cvtest::BaseTest
|
||||
{
|
||||
// see issue #2601 "16-bit Grayscale TIFF Load Failures Due to Buffer Underflow and Endianness"
|
||||
|
||||
// Setup data for two minimal 16-bit grayscale TIFF files in both endian formats
|
||||
uchar tiff_sample_data[2][86] = { {
|
||||
// Little endian
|
||||
0x49, 0x49, 0x2a, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xad, 0xde, 0xef, 0xbe, 0x06, 0x00, 0x00, 0x01,
|
||||
0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x01, 0x01, 0x03, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x10, 0x00,
|
||||
0x00, 0x00, 0x06, 0x01, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01,
|
||||
0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x17, 0x01, 0x04, 0x00, 0x01, 0x00,
|
||||
0x00, 0x00, 0x04, 0x00, 0x00, 0x00 }, {
|
||||
// Big endian
|
||||
0x4d, 0x4d, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x0c, 0xde, 0xad, 0xbe, 0xef, 0x00, 0x06, 0x01, 0x00,
|
||||
0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x00, 0x01, 0x01, 0x00, 0x03, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x02, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x10,
|
||||
0x00, 0x00, 0x01, 0x06, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x00, 0x01, 0x11,
|
||||
0x00, 0x04, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x01, 0x17, 0x00, 0x04, 0x00, 0x00,
|
||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x04 }
|
||||
};
|
||||
|
||||
// Test imread() for both a little endian TIFF and big endian TIFF
|
||||
for (int i = 0; i < 2; i++)
|
||||
{
|
||||
string filename = cv::tempfile(".tiff");
|
||||
|
||||
// Write sample TIFF file
|
||||
FILE* fp = fopen(filename.c_str(), "wb");
|
||||
ASSERT_TRUE(fp != NULL);
|
||||
ASSERT_EQ((size_t)1, fwrite(tiff_sample_data, 86, 1, fp));
|
||||
fclose(fp);
|
||||
|
||||
Mat img = imread(filename, CV_LOAD_IMAGE_UNCHANGED);
|
||||
|
||||
EXPECT_EQ(1, img.rows);
|
||||
EXPECT_EQ(2, img.cols);
|
||||
EXPECT_EQ(CV_16U, img.type());
|
||||
EXPECT_EQ(sizeof(ushort), img.elemSize());
|
||||
EXPECT_EQ(1, img.channels());
|
||||
EXPECT_EQ(0xDEAD, img.at<ushort>(0,0));
|
||||
EXPECT_EQ(0xBEEF, img.at<ushort>(0,1));
|
||||
|
||||
remove(filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
class CV_GrfmtReadTifTiledWithNotFullTiles: public cvtest::BaseTest
|
||||
{
|
||||
public:
|
||||
|
@ -332,9 +332,7 @@ void CV_HighGuiTest::VideoTest(const string& dir, const cvtest::VideoFormat& fmt
|
||||
}
|
||||
}
|
||||
|
||||
printf("Before saved release for %s\n", tmp_name.c_str());
|
||||
cvReleaseCapture( &saved );
|
||||
printf("After release\n");
|
||||
|
||||
ts->printf(ts->LOG, "end test function : ImagesVideo \n");
|
||||
}
|
||||
|
@ -49,8 +49,8 @@ namespace
|
||||
class CLAHE_CalcLut_Body : public cv::ParallelLoopBody
|
||||
{
|
||||
public:
|
||||
CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int tilesY, int clipLimit, float lutScale) :
|
||||
src_(src), lut_(lut), tileSize_(tileSize), tilesX_(tilesX), tilesY_(tilesY), clipLimit_(clipLimit), lutScale_(lutScale)
|
||||
CLAHE_CalcLut_Body(const cv::Mat& src, cv::Mat& lut, cv::Size tileSize, int tilesX, int clipLimit, float lutScale) :
|
||||
src_(src), lut_(lut), tileSize_(tileSize), tilesX_(tilesX), clipLimit_(clipLimit), lutScale_(lutScale)
|
||||
{
|
||||
}
|
||||
|
||||
@ -62,7 +62,6 @@ namespace
|
||||
|
||||
cv::Size tileSize_;
|
||||
int tilesX_;
|
||||
int tilesY_;
|
||||
int clipLimit_;
|
||||
float lutScale_;
|
||||
};
|
||||
@ -293,7 +292,7 @@ namespace
|
||||
clipLimit = std::max(clipLimit, 1);
|
||||
}
|
||||
|
||||
CLAHE_CalcLut_Body calcLutBody(srcForLut, lut_, tileSize, tilesX_, tilesY_, clipLimit, lutScale);
|
||||
CLAHE_CalcLut_Body calcLutBody(srcForLut, lut_, tileSize, tilesX_, clipLimit, lutScale);
|
||||
cv::parallel_for_(cv::Range(0, tilesX_ * tilesY_), calcLutBody);
|
||||
|
||||
CLAHE_Interpolation_Body interpolationBody(src, dst, lut_, tileSize, tilesX_, tilesY_);
|
||||
|
@ -3214,7 +3214,7 @@ struct YUV420p2RGB888Invoker : ParallelLoopBody
|
||||
const int rangeBegin = range.start * 2;
|
||||
const int rangeEnd = range.end * 2;
|
||||
|
||||
size_t uvsteps[2] = {width/2, stride - width/2};
|
||||
int uvsteps[2] = {width/2, stride - width/2};
|
||||
int usIdx = ustepIdx, vsIdx = vstepIdx;
|
||||
|
||||
const uchar* y1 = my1 + rangeBegin * stride;
|
||||
@ -3282,7 +3282,7 @@ struct YUV420p2RGBA8888Invoker : ParallelLoopBody
|
||||
int rangeBegin = range.start * 2;
|
||||
int rangeEnd = range.end * 2;
|
||||
|
||||
size_t uvsteps[2] = {width/2, stride - width/2};
|
||||
int uvsteps[2] = {width/2, stride - width/2};
|
||||
int usIdx = ustepIdx, vsIdx = vstepIdx;
|
||||
|
||||
const uchar* y1 = my1 + rangeBegin * stride;
|
||||
|
@ -41,7 +41,7 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
|
||||
|
@ -1217,8 +1217,13 @@ public:
|
||||
alpha(_alpha), _beta(__beta), ssize(_ssize), dsize(_dsize),
|
||||
ksize(_ksize), xmin(_xmin), xmax(_xmax)
|
||||
{
|
||||
CV_Assert(ksize <= MAX_ESIZE);
|
||||
}
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
virtual void operator() (const Range& range) const
|
||||
{
|
||||
int dy, cn = src.channels();
|
||||
@ -1267,6 +1272,9 @@ public:
|
||||
vresize( (const WT**)rows, (T*)(dst.data + dst.step*dy), beta, dsize.width );
|
||||
}
|
||||
}
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
private:
|
||||
Mat src;
|
||||
@ -1274,7 +1282,9 @@ private:
|
||||
const int* xofs, *yofs;
|
||||
const AT* alpha, *_beta;
|
||||
Size ssize, dsize;
|
||||
int ksize, xmin, xmax;
|
||||
const int ksize, xmin, xmax;
|
||||
|
||||
resizeGeneric_Invoker& operator = (const resizeGeneric_Invoker&);
|
||||
};
|
||||
|
||||
template<class HResize, class VResize>
|
||||
|
@ -197,6 +197,10 @@ static void icvContourMoments( CvSeq* contour, CvMoments* moments )
|
||||
\****************************************************************************************/
|
||||
|
||||
template<typename T, typename WT, typename MT>
|
||||
#if defined __GNUC__ && __GNUC__ == 4 && __GNUC_MINOR__ >= 5 && __GNUC_MINOR__ < 9
|
||||
// Workaround for http://gcc.gnu.org/bugzilla/show_bug.cgi?id=60196
|
||||
__attribute__((optimize("no-tree-vectorize")))
|
||||
#endif
|
||||
static void momentsInTile( const cv::Mat& img, double* moments )
|
||||
{
|
||||
cv::Size size = img.size();
|
||||
|
@ -718,7 +718,7 @@ void cv::boxFilter( InputArray _src, OutputArray _dst, int ddepth,
|
||||
ddepth = sdepth;
|
||||
_dst.create( src.size(), CV_MAKETYPE(ddepth, cn) );
|
||||
Mat dst = _dst.getMat();
|
||||
if( borderType != BORDER_CONSTANT && normalize )
|
||||
if( borderType != BORDER_CONSTANT && normalize && (borderType & BORDER_ISOLATED) != 0 )
|
||||
{
|
||||
if( src.rows == 1 )
|
||||
ksize.height = 1;
|
||||
|
@ -1225,7 +1225,7 @@ CV_FitLineTest::CV_FitLineTest()
|
||||
max_noise = 0.05;
|
||||
}
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
@ -1301,7 +1301,7 @@ void CV_FitLineTest::generate_point_set( void* pointsSet )
|
||||
}
|
||||
}
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
@ -1329,7 +1329,7 @@ void CV_FitLineTest::run_func()
|
||||
cv::fitLine(cv::cvarrToMat(points), (cv::Vec6f&)line[0], dist_type, 0, reps, aeps);
|
||||
}
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
@ -1412,7 +1412,7 @@ _exit_:
|
||||
return code;
|
||||
}
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
@ -1886,3 +1886,35 @@ protected:
|
||||
};
|
||||
|
||||
TEST(Imgproc_Filtering, supportedFormats) { CV_FilterSupportedFormatsTest test; test.safe_run(); }
|
||||
|
||||
TEST(Imgproc_Blur, borderTypes)
|
||||
{
|
||||
Size kernelSize(3, 3);
|
||||
|
||||
/// ksize > src_roi.size()
|
||||
Mat src(3, 3, CV_8UC1, cv::Scalar::all(255)), dst;
|
||||
Mat src_roi = src(Rect(1, 1, 1, 1));
|
||||
src_roi.setTo(cv::Scalar::all(0));
|
||||
|
||||
// should work like !BORDER_ISOLATED
|
||||
blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_REPLICATE);
|
||||
EXPECT_EQ(227, dst.at<uchar>(0, 0));
|
||||
|
||||
// should work like BORDER_ISOLATED
|
||||
blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_REPLICATE | BORDER_ISOLATED);
|
||||
EXPECT_EQ(0, dst.at<uchar>(0, 0));
|
||||
|
||||
/// ksize <= src_roi.size()
|
||||
src = Mat(5, 5, CV_8UC1, cv::Scalar(255));
|
||||
src_roi = src(Rect(1, 1, 3, 3));
|
||||
src_roi.setTo(0);
|
||||
src.at<uchar>(2, 2) = 255;
|
||||
|
||||
// should work like !BORDER_ISOLATED
|
||||
blur(src_roi, dst, kernelSize, Point(-1, -1), BORDER_REPLICATE);
|
||||
Mat expected_dst =
|
||||
(Mat_<uchar>(3, 3) << 170, 113, 170, 113, 28, 113, 170, 113, 170);
|
||||
EXPECT_EQ(expected_dst.type(), dst.type());
|
||||
EXPECT_EQ(expected_dst.size(), dst.size());
|
||||
EXPECT_DOUBLE_EQ(0.0, cvtest::norm(expected_dst, dst, NORM_INF));
|
||||
}
|
||||
|
@ -266,7 +266,7 @@ if(ANDROID)
|
||||
else(ANDROID)
|
||||
set(JAR_NAME opencv-${LIB_NAME_SUFIX}.jar)
|
||||
set(JAR_FILE "${OpenCV_BINARY_DIR}/bin/${JAR_NAME}")
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build.xml.in" "${OpenCV_BINARY_DIR}/build.xml" IMMEDIATE @ONLY)
|
||||
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/build.xml.in" "${OpenCV_BINARY_DIR}/build.xml" @ONLY)
|
||||
list(APPEND step3_depends "${OpenCV_BINARY_DIR}/build.xml")
|
||||
|
||||
add_custom_command(OUTPUT "${JAR_FILE}" "${JAR_FILE}.dephelper"
|
||||
|
@ -329,7 +329,10 @@ JNIEXPORT jstring JNICALL Java_org_opencv_highgui_VideoCapture_n_1getSupportedPr
|
||||
VideoCapture* me = (VideoCapture*) self; //TODO: check for NULL
|
||||
union {double prop; const char* name;} u;
|
||||
u.prop = me->get(CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING);
|
||||
return env->NewStringUTF(u.name);
|
||||
// VideoCapture::get can return 0.0 or -1.0 if it doesn't support
|
||||
// CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING
|
||||
if (u.prop != 0.0 && u.prop != -1.0)
|
||||
return env->NewStringUTF(u.name);
|
||||
} catch(const std::exception &e) {
|
||||
throwJavaException(env, &e, method_name);
|
||||
} catch (...) {
|
||||
|
@ -48,7 +48,17 @@ public class OpenCVLoader
|
||||
*/
|
||||
public static boolean initDebug()
|
||||
{
|
||||
return StaticHelper.initOpenCV();
|
||||
return StaticHelper.initOpenCV(false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads and initializes OpenCV library from current application package. Roughly, it's an analog of system.loadLibrary("opencv_java").
|
||||
* @param InitCuda load and initialize CUDA runtime libraries.
|
||||
* @return Returns true is initialization of OpenCV was successful.
|
||||
*/
|
||||
public static boolean initDebug(boolean InitCuda)
|
||||
{
|
||||
return StaticHelper.initOpenCV(InitCuda);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -7,11 +7,21 @@ import android.util.Log;
|
||||
|
||||
class StaticHelper {
|
||||
|
||||
public static boolean initOpenCV()
|
||||
public static boolean initOpenCV(boolean InitCuda)
|
||||
{
|
||||
boolean result;
|
||||
String libs = "";
|
||||
|
||||
if(InitCuda)
|
||||
{
|
||||
loadLibrary("cudart");
|
||||
loadLibrary("nppc");
|
||||
loadLibrary("nppi");
|
||||
loadLibrary("npps");
|
||||
loadLibrary("cufft");
|
||||
loadLibrary("cublas");
|
||||
}
|
||||
|
||||
Log.d(TAG, "Trying to get library list");
|
||||
|
||||
try
|
||||
@ -52,7 +62,7 @@ class StaticHelper {
|
||||
try
|
||||
{
|
||||
System.loadLibrary(Name);
|
||||
Log.d(TAG, "OpenCV libs init was ok!");
|
||||
Log.d(TAG, "Library " + Name + " loaded");
|
||||
}
|
||||
catch(UnsatisfiedLinkError e)
|
||||
{
|
||||
|
@ -87,7 +87,6 @@ public class TermCriteria {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (this == null) return "null";
|
||||
return "{ type: " + type + ", maxCount: " + maxCount + ", epsilon: " + epsilon + "}";
|
||||
}
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ CV_INLINE int _icvRemoveShadowGMM(float* data, int nD,
|
||||
//IEEE Trans. on Pattern Analysis and Machine Intelligence, vol.26, no.5, pages 651-656, 2004
|
||||
//http://www.zoranz.net/Publications/zivkovic2004PAMI.pdf
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
|
||||
#endif
|
||||
@ -608,7 +608,7 @@ CV_INLINE int _icvUpdateGMM(float* data, int nD,
|
||||
return bBackground;
|
||||
}
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
@ -200,6 +200,7 @@ void RFace::CalculateError(FaceData * lpFaceData)
|
||||
void RFace::CreateFace(void * lpData)
|
||||
{
|
||||
FaceData Data;
|
||||
memset(&Data, 0, sizeof(FaceData));
|
||||
|
||||
double Error = MAX_ERROR;
|
||||
double CurError = MAX_ERROR;
|
||||
|
@ -163,7 +163,7 @@ icvLMedS( int *points1, int *points2, int numPoints, CvMatrix3 * fundamentalMatr
|
||||
/*===========================================================================*/
|
||||
/*===========================================================================*/
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic push
|
||||
# pragma GCC diagnostic ignored "-Warray-bounds"
|
||||
#endif
|
||||
@ -328,7 +328,7 @@ icvCubic( double a2, double a1, double a0, double *squares )
|
||||
return CV_NO_ERR;
|
||||
} /* icvCubic */
|
||||
|
||||
#if (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
#if defined(__GNUC__) && (__GNUC__ == 4) && (__GNUC_MINOR__ == 8)
|
||||
# pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
|
@ -3,10 +3,10 @@ if(BUILD_ANDROID_PACKAGE)
|
||||
endif()
|
||||
|
||||
set(the_description "Functionality with possible limitations on the use")
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef)
|
||||
if (ENABLE_DYNAMIC_CUDA)
|
||||
set(HAVE_CUDA FALSE)
|
||||
ocv_warnings_disable(CMAKE_CXX_FLAGS -Wundef -Wshadow)
|
||||
if(ENABLE_DYNAMIC_CUDA)
|
||||
add_definitions(-DDYNAMIC_CUDA_SUPPORT)
|
||||
ocv_define_module(nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_ocl)
|
||||
else()
|
||||
ocv_define_module(nonfree opencv_imgproc opencv_features2d opencv_calib3d OPTIONAL opencv_gpu opencv_ocl)
|
||||
endif()
|
||||
endif()
|
||||
|
@ -43,11 +43,7 @@
|
||||
#ifndef __OPENCV_NONFREE_GPU_HPP__
|
||||
#define __OPENCV_NONFREE_GPU_HPP__
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
|
||||
namespace cv { namespace gpu {
|
||||
|
||||
@ -129,6 +125,4 @@ public:
|
||||
|
||||
} // namespace cv
|
||||
|
||||
#endif // defined(HAVE_OPENCV_GPU)
|
||||
|
||||
#endif // __OPENCV_NONFREE_GPU_HPP__
|
||||
|
@ -42,7 +42,9 @@
|
||||
|
||||
#include "perf_precomp.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA)
|
||||
#include "cvconfig.h"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
|
||||
#include "opencv2/ts/gpu_perf.hpp"
|
||||
|
||||
|
@ -4,6 +4,9 @@
|
||||
static const char * impls[] = {
|
||||
#ifdef HAVE_CUDA
|
||||
"cuda",
|
||||
#endif
|
||||
#ifdef HAVE_OPENCL
|
||||
"ocl",
|
||||
#endif
|
||||
"plain"
|
||||
};
|
||||
|
@ -57,55 +57,68 @@ typedef perf::TestBaseWithParam<std::string> OCL_SURF;
|
||||
"cv/detectors_descriptors_evaluation/images_datasets/leuven/img1.png",\
|
||||
"stitching/a3.png"
|
||||
|
||||
PERF_TEST_P(OCL_SURF, DISABLED_with_data_transfer, testing::Values(SURF_IMAGES))
|
||||
#define OCL_TEST_CYCLE() for( ; startTimer(), next(); cv::ocl::finish(), stopTimer())
|
||||
|
||||
PERF_TEST_P(OCL_SURF, with_data_transfer, testing::Values(SURF_IMAGES))
|
||||
{
|
||||
string filename = getDataPath(GetParam());
|
||||
Mat img = imread(filename, IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
SURF_OCL d_surf;
|
||||
oclMat d_keypoints;
|
||||
oclMat d_descriptors;
|
||||
Mat cpu_kp;
|
||||
Mat cpu_dp;
|
||||
Mat src = imread(filename, IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(src.empty());
|
||||
|
||||
Mat cpu_kp, cpu_dp;
|
||||
declare.time(60);
|
||||
|
||||
TEST_CYCLE()
|
||||
if (getSelectedImpl() == "ocl")
|
||||
{
|
||||
oclMat d_src(img);
|
||||
SURF_OCL d_surf;
|
||||
oclMat d_keypoints, d_descriptors;
|
||||
|
||||
d_surf(d_src, oclMat(), d_keypoints, d_descriptors);
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
oclMat d_src(src);
|
||||
|
||||
d_keypoints.download(cpu_kp);
|
||||
d_descriptors.download(cpu_dp);
|
||||
d_surf(d_src, oclMat(), d_keypoints, d_descriptors);
|
||||
|
||||
d_keypoints.download(cpu_kp);
|
||||
d_descriptors.download(cpu_dp);
|
||||
}
|
||||
}
|
||||
else if (getSelectedImpl() == "plain")
|
||||
{
|
||||
cv::SURF surf;
|
||||
std::vector<cv::KeyPoint> kp;
|
||||
|
||||
TEST_CYCLE() surf(src, Mat(), kp, cpu_dp);
|
||||
}
|
||||
|
||||
SANITY_CHECK(cpu_kp, 1);
|
||||
SANITY_CHECK(cpu_dp, 1);
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
PERF_TEST_P(OCL_SURF, DISABLED_without_data_transfer, testing::Values(SURF_IMAGES))
|
||||
PERF_TEST_P(OCL_SURF, without_data_transfer, testing::Values(SURF_IMAGES))
|
||||
{
|
||||
string filename = getDataPath(GetParam());
|
||||
Mat img = imread(filename, IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(img.empty());
|
||||
|
||||
SURF_OCL d_surf;
|
||||
oclMat d_keypoints;
|
||||
oclMat d_descriptors;
|
||||
oclMat d_src(img);
|
||||
Mat src = imread(filename, IMREAD_GRAYSCALE);
|
||||
ASSERT_FALSE(src.empty());
|
||||
|
||||
Mat cpu_kp, cpu_dp;
|
||||
declare.time(60);
|
||||
|
||||
TEST_CYCLE() d_surf(d_src, oclMat(), d_keypoints, d_descriptors);
|
||||
if (getSelectedImpl() == "ocl")
|
||||
{
|
||||
SURF_OCL d_surf;
|
||||
oclMat d_keypoints, d_descriptors, d_src(src);
|
||||
|
||||
Mat cpu_kp;
|
||||
Mat cpu_dp;
|
||||
d_keypoints.download(cpu_kp);
|
||||
d_descriptors.download(cpu_dp);
|
||||
SANITY_CHECK(cpu_kp, 1);
|
||||
SANITY_CHECK(cpu_dp, 1);
|
||||
OCL_TEST_CYCLE() d_surf(d_src, oclMat(), d_keypoints, d_descriptors);
|
||||
}
|
||||
else if (getSelectedImpl() == "plain")
|
||||
{
|
||||
cv::SURF surf;
|
||||
std::vector<cv::KeyPoint> kp;
|
||||
|
||||
TEST_CYCLE() surf(src, Mat(), kp, cpu_dp);
|
||||
}
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
||||
#endif // HAVE_OPENCV_OCL
|
@ -42,7 +42,7 @@
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
|
||||
#include "opencv2/gpu/device/common.hpp"
|
||||
#include "opencv2/gpu/device/limits.hpp"
|
||||
|
@ -51,17 +51,14 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/core/internal.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#include "opencv2/nonfree/gpu.hpp"
|
||||
#include "opencv2/nonfree/gpu.hpp"
|
||||
|
||||
#if defined(HAVE_CUDA)
|
||||
#include "opencv2/gpu/stream_accessor.hpp"
|
||||
#include "opencv2/gpu/device/common.hpp"
|
||||
|
||||
static inline void throw_nogpu() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); }
|
||||
#else
|
||||
static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); }
|
||||
#endif
|
||||
#if defined(HAVE_CUDA) && defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
#include "opencv2/gpu/stream_accessor.hpp"
|
||||
#include "opencv2/gpu/device/common.hpp"
|
||||
static inline void throw_nogpu() { CV_Error(CV_StsNotImplemented, "The called functionality is disabled for current build or platform"); }
|
||||
#else
|
||||
static inline void throw_nogpu() { CV_Error(CV_GpuNotSupported, "The library is compiled without GPU support"); }
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCV_OCL
|
||||
|
@ -42,12 +42,10 @@
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
|
||||
using namespace cv;
|
||||
using namespace cv::gpu;
|
||||
|
||||
#if !defined (HAVE_CUDA)
|
||||
#if !defined (HAVE_CUDA) || !defined(HAVE_OPENCV_GPU) || defined(DYNAMIC_CUDA_SUPPORT)
|
||||
|
||||
cv::gpu::SURF_GPU::SURF_GPU() { throw_nogpu(); }
|
||||
cv::gpu::SURF_GPU::SURF_GPU(double, int, int, bool, float, bool) { throw_nogpu(); }
|
||||
@ -421,5 +419,3 @@ void cv::gpu::SURF_GPU::releaseMemory()
|
||||
}
|
||||
|
||||
#endif // !defined (HAVE_CUDA)
|
||||
|
||||
#endif // defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
|
@ -42,7 +42,9 @@
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA)
|
||||
#include "cvconfig.h"
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && defined(HAVE_CUDA) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
|
||||
using namespace cvtest;
|
||||
|
||||
|
@ -95,10 +95,11 @@ typedef perf::TestBaseWithParam<OCL_Cascade_Image_MinSize_t> OCL_Cascade_Image_M
|
||||
|
||||
PERF_TEST_P( OCL_Cascade_Image_MinSize, CascadeClassifier,
|
||||
testing::Combine(
|
||||
testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml") ),
|
||||
testing::Values( string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt.xml"),
|
||||
string("cv/cascadeandhog/cascades/haarcascade_frontalface_alt2.xml") ),
|
||||
testing::Values( string("cv/shared/lena.png"),
|
||||
string("cv/cascadeandhog/images/bttf301.png"),
|
||||
string("cv/cascadeandhog/images/class57.png") ),
|
||||
string("cv/cascadeandhog/images/bttf301.png")/*,
|
||||
string("cv/cascadeandhog/images/class57.png")*/ ),
|
||||
testing::Values(30, 64, 90) ) )
|
||||
{
|
||||
const string cascasePath = get<0>(GetParam());
|
||||
|
@ -106,4 +106,108 @@ PERF_TEST_P(KNNFixture, KNN,
|
||||
}else
|
||||
OCL_PERF_ELSE
|
||||
SANITY_CHECK(best_label);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef TestBaseWithParam<tuple<int> > SVMFixture;
|
||||
|
||||
// code is based on: samples\cpp\tutorial_code\ml\non_linear_svms\non_linear_svms.cpp
|
||||
PERF_TEST_P(SVMFixture, DISABLED_SVM,
|
||||
testing::Values(50, 100))
|
||||
{
|
||||
|
||||
const int NTRAINING_SAMPLES = get<0>(GetParam()); // Number of training samples per class
|
||||
|
||||
#define FRAC_LINEAR_SEP 0.9f // Fraction of samples which compose the linear separable part
|
||||
|
||||
const int WIDTH = 512, HEIGHT = 512;
|
||||
|
||||
Mat trainData(2*NTRAINING_SAMPLES, 2, CV_32FC1);
|
||||
Mat labels (2*NTRAINING_SAMPLES, 1, CV_32FC1);
|
||||
|
||||
RNG rng(100); // Random value generation class
|
||||
|
||||
// Set up the linearly separable part of the training data
|
||||
int nLinearSamples = (int) (FRAC_LINEAR_SEP * NTRAINING_SAMPLES);
|
||||
|
||||
// Generate random points for the class 1
|
||||
Mat trainClass = trainData.rowRange(0, nLinearSamples);
|
||||
// The x coordinate of the points is in [0, 0.4)
|
||||
Mat c = trainClass.colRange(0, 1);
|
||||
rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(0.4 * WIDTH));
|
||||
// The y coordinate of the points is in [0, 1)
|
||||
c = trainClass.colRange(1,2);
|
||||
rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(HEIGHT));
|
||||
|
||||
// Generate random points for the class 2
|
||||
trainClass = trainData.rowRange(2*NTRAINING_SAMPLES-nLinearSamples, 2*NTRAINING_SAMPLES);
|
||||
// The x coordinate of the points is in [0.6, 1]
|
||||
c = trainClass.colRange(0 , 1);
|
||||
rng.fill(c, RNG::UNIFORM, Scalar(0.6*WIDTH), Scalar(WIDTH));
|
||||
// The y coordinate of the points is in [0, 1)
|
||||
c = trainClass.colRange(1,2);
|
||||
rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(HEIGHT));
|
||||
|
||||
//------------------ Set up the non-linearly separable part of the training data ---------------
|
||||
|
||||
// Generate random points for the classes 1 and 2
|
||||
trainClass = trainData.rowRange( nLinearSamples, 2*NTRAINING_SAMPLES-nLinearSamples);
|
||||
// The x coordinate of the points is in [0.4, 0.6)
|
||||
c = trainClass.colRange(0,1);
|
||||
rng.fill(c, RNG::UNIFORM, Scalar(0.4*WIDTH), Scalar(0.6*WIDTH));
|
||||
// The y coordinate of the points is in [0, 1)
|
||||
c = trainClass.colRange(1,2);
|
||||
rng.fill(c, RNG::UNIFORM, Scalar(1), Scalar(HEIGHT));
|
||||
|
||||
//------------------------- Set up the labels for the classes ---------------------------------
|
||||
labels.rowRange( 0, NTRAINING_SAMPLES).setTo(1); // Class 1
|
||||
labels.rowRange(NTRAINING_SAMPLES, 2*NTRAINING_SAMPLES).setTo(2); // Class 2
|
||||
|
||||
//------------------------ Set up the support vector machines parameters --------------------
|
||||
CvSVMParams params;
|
||||
params.svm_type = SVM::C_SVC;
|
||||
params.C = 0.1;
|
||||
params.kernel_type = SVM::LINEAR;
|
||||
params.term_crit = TermCriteria(CV_TERMCRIT_ITER, (int)1e7, 1e-6);
|
||||
|
||||
Mat dst = Mat::zeros(HEIGHT, WIDTH, CV_8UC1);
|
||||
|
||||
Mat samples(WIDTH*HEIGHT, 2, CV_32FC1);
|
||||
int k = 0;
|
||||
for (int i = 0; i < HEIGHT; ++i)
|
||||
{
|
||||
for (int j = 0; j < WIDTH; ++j)
|
||||
{
|
||||
samples.at<float>(k, 0) = (float)i;
|
||||
samples.at<float>(k, 0) = (float)j;
|
||||
k++;
|
||||
}
|
||||
}
|
||||
Mat results(WIDTH*HEIGHT, 1, CV_32FC1);
|
||||
|
||||
CvMat samples_ = samples;
|
||||
CvMat results_ = results;
|
||||
|
||||
if(RUN_PLAIN_IMPL)
|
||||
{
|
||||
CvSVM svm;
|
||||
svm.train(trainData, labels, Mat(), Mat(), params);
|
||||
TEST_CYCLE()
|
||||
{
|
||||
svm.predict(&samples_, &results_);
|
||||
}
|
||||
}
|
||||
else if(RUN_OCL_IMPL)
|
||||
{
|
||||
CvSVM_OCL svm;
|
||||
svm.train(trainData, labels, Mat(), Mat(), params);
|
||||
OCL_TEST_CYCLE()
|
||||
{
|
||||
svm.predict(&samples_, &results_);
|
||||
}
|
||||
}
|
||||
else
|
||||
OCL_PERF_ELSE
|
||||
|
||||
SANITY_CHECK_NOTHING();
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ __kernel void arithm_pow(__global VT * src, int src_step, int src_offset,
|
||||
int dst_index = mad24(y, dst_step, x + dst_offset);
|
||||
|
||||
VT src_data = src[src_index];
|
||||
VT tmp = src_data > 0 ? exp(p * log(src_data)) : (src_data == 0 ? 0 : exp(p * log(fabs(src_data))));
|
||||
VT tmp = src_data > (VT)0 ? (VT)exp(p * log(src_data)) : (src_data == (VT)0 ? (VT)0 : (VT)exp(p * log(fabs(src_data))));
|
||||
|
||||
dst[dst_index] = tmp;
|
||||
}
|
||||
|