mirror of
https://github.com/opencv/opencv.git
synced 2026-07-24 12:53:04 +04:00
Compare commits
43 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b4845d8c9f | |||
| ea51396731 | |||
| aa82f921cc | |||
| 2da7eae2c4 | |||
| 25159d8e81 | |||
| f40ffe4763 | |||
| 116311b7b4 | |||
| f1ef3a4865 | |||
| 9997aa8187 | |||
| f15b42018c | |||
| f9e9ae85bd | |||
| a49beb7c73 | |||
| 51dff5b9e8 | |||
| 826fc00374 | |||
| c10692deff | |||
| daa7b9ce5f | |||
| 1ab02631b0 | |||
| 3e755b2290 | |||
| f15a167df4 | |||
| f6367a2ea5 | |||
| 5f88e2b496 | |||
| 2c7cf52e3b | |||
| b7c5083a87 | |||
| d5d88efd5d | |||
| 6cb7a7be18 | |||
| cdea6b532f | |||
| d01e3529a6 | |||
| 7c13d3277c | |||
| 345b3b0bdd | |||
| a65d7d4dd3 | |||
| 5e986f3347 | |||
| 27a8bb471b | |||
| 7868733002 | |||
| 469aef2e5e | |||
| 5e00fc6afe | |||
| 5170f0b5da | |||
| dc2dbb4173 | |||
| 79e4f7eb78 | |||
| cc73c7000f | |||
| 8bb26fa5de | |||
| 48612d7c58 | |||
| 8ba84f4b47 | |||
| bc653add74 |
+53
-12
@@ -268,13 +268,24 @@ 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()
|
||||
|
||||
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()
|
||||
|
||||
set(OPENCV_BIN_INSTALL_PATH "${OpenCV_INSTALL_BINARIES_PREFIX}bin")
|
||||
if(NOT OPENCV_TEST_INSTALL_PATH)
|
||||
set(OPENCV_TEST_INSTALL_PATH "${OPENCV_BIN_INSTALL_PATH}")
|
||||
endif()
|
||||
@@ -565,16 +576,46 @@ include(cmake/OpenCVGenConfig.cmake)
|
||||
include(cmake/OpenCVGenInfoPlist.cmake)
|
||||
|
||||
# Generate environment setup file
|
||||
if(INSTALL_TESTS AND OPENCV_TEST_DATA_PATH AND UNIX AND NOT ANDROID)
|
||||
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.sh.in"
|
||||
"${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh" @ONLY)
|
||||
install(FILES "${CMAKE_BINARY_DIR}/unix-install/opencv_run_all_tests.sh"
|
||||
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ OWNER_EXECUTE GROUP_EXECUTE WORLD_EXECUTE
|
||||
DESTINATION ${OPENCV_TEST_INSTALL_PATH} COMPONENT tests)
|
||||
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()
|
||||
|
||||
# ----------------------------------------------------------------------------
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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})
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
|
||||
OPENCV_TEST_PATH=@OPENCV_TEST_INSTALL_PATH@
|
||||
OPENCV_TEST_PATH=@CMAKE_INSTALL_PREFIX@/@OPENCV_TEST_INSTALL_PATH@
|
||||
export OPENCV_TEST_DATA_PATH=@CMAKE_INSTALL_PREFIX@/share/OpenCV/testdata
|
||||
|
||||
SUMMARY_STATUS=0
|
||||
+5
-1
@@ -13,6 +13,10 @@ 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)
|
||||
install(DIRECTORY ${OPENCV_TEST_DATA_PATH} DESTINATION share/OpenCV/testdata COMPONENT tests)
|
||||
# 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()
|
||||
@@ -1,37 +0,0 @@
|
||||
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) 2008-2011, Willow Garage Inc., all rights reserved.
|
||||
Third party copyrights are property of their respective owners.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright notice,
|
||||
this list of conditions and the following disclaimer in the documentation
|
||||
and/or other materials provided with the distribution.
|
||||
|
||||
* 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.
|
||||
@@ -48,10 +48,10 @@ The structure of package contents looks as follows:
|
||||
|
||||
::
|
||||
|
||||
OpenCV-2.4.8.1-android-sdk
|
||||
OpenCV-2.4.8.2-android-sdk
|
||||
|_ apk
|
||||
| |_ OpenCV_2.4.8.1_binary_pack_armv7a.apk
|
||||
| |_ OpenCV_2.4.8.1_Manager_2.17_XXX.apk
|
||||
| |_ OpenCV_2.4.8.2_binary_pack_armv7a.apk
|
||||
| |_ OpenCV_2.4.8.2_Manager_2.17_XXX.apk
|
||||
|
|
||||
|_ doc
|
||||
|_ samples
|
||||
@@ -66,7 +66,7 @@ The structure of package contents looks as follows:
|
||||
| |_ armeabi-v7a
|
||||
| |_ x86
|
||||
|
|
||||
|_ license.txt
|
||||
|_ LICENSE
|
||||
|_ README.android
|
||||
|
||||
* :file:`sdk` folder contains OpenCV API and libraries for Android:
|
||||
@@ -157,10 +157,10 @@ Get the OpenCV4Android SDK
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
unzip ~/Downloads/OpenCV-2.4.8.1-android-sdk.zip
|
||||
unzip ~/Downloads/OpenCV-2.4.8.2-android-sdk.zip
|
||||
|
||||
.. |opencv_android_bin_pack| replace:: :file:`OpenCV-2.4.8.1-android-sdk.zip`
|
||||
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.8.1/OpenCV-2.4.8.1-android-sdk.zip/download
|
||||
.. |opencv_android_bin_pack| replace:: :file:`OpenCV-2.4.8.2-android-sdk.zip`
|
||||
.. _opencv_android_bin_pack_url: http://sourceforge.net/projects/opencvlibrary/files/opencv-android/2.4.8.2/OpenCV-2.4.8.2-android-sdk.zip/download
|
||||
.. |opencv_android_bin_pack_url| replace:: |opencv_android_bin_pack|
|
||||
.. |seven_zip| replace:: 7-Zip
|
||||
.. _seven_zip: http://www.7-zip.org/
|
||||
@@ -295,7 +295,7 @@ Well, running samples from Eclipse is very simple:
|
||||
.. code-block:: sh
|
||||
:linenos:
|
||||
|
||||
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.8.1_Manager_2.17_armv7a-neon.apk
|
||||
<Android SDK path>/platform-tools/adb install <OpenCV4Android SDK path>/apk/OpenCV_2.4.8.2_Manager_2.17_armv7a-neon.apk
|
||||
|
||||
.. note:: ``armeabi``, ``armv7a-neon``, ``arm7a-neon-android8``, ``mips`` and ``x86`` stand for
|
||||
platform targets:
|
||||
|
||||
@@ -55,14 +55,14 @@ Manager to access OpenCV libraries externally installed in the target system.
|
||||
:guilabel:`File -> Import -> Existing project in your workspace`.
|
||||
|
||||
Press :guilabel:`Browse` button and locate OpenCV4Android SDK
|
||||
(:file:`OpenCV-2.4.8.1-android-sdk/sdk`).
|
||||
(:file:`OpenCV-2.4.8.2-android-sdk/sdk`).
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency0.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. In application project add a reference to the OpenCV Java SDK in
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.8.1``.
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.8.2``.
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency1.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
@@ -128,27 +128,27 @@ described above.
|
||||
#. Add the OpenCV library project to your workspace the same way as for the async initialization
|
||||
above. Use menu :guilabel:`File -> Import -> Existing project in your workspace`,
|
||||
press :guilabel:`Browse` button and select OpenCV SDK path
|
||||
(:file:`OpenCV-2.4.8.1-android-sdk/sdk`).
|
||||
(:file:`OpenCV-2.4.8.2-android-sdk/sdk`).
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency0.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. In the application project add a reference to the OpenCV4Android SDK in
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.8.1``;
|
||||
:guilabel:`Project -> Properties -> Android -> Library -> Add` select ``OpenCV Library - 2.4.8.2``;
|
||||
|
||||
.. image:: images/eclipse_opencv_dependency1.png
|
||||
:alt: Add dependency from OpenCV library
|
||||
:align: center
|
||||
|
||||
#. If your application project **doesn't have a JNI part**, just copy the corresponding OpenCV
|
||||
native libs from :file:`<OpenCV-2.4.8.1-android-sdk>/sdk/native/libs/<target_arch>` to your
|
||||
native libs from :file:`<OpenCV-2.4.8.2-android-sdk>/sdk/native/libs/<target_arch>` to your
|
||||
project directory to folder :file:`libs/<target_arch>`.
|
||||
|
||||
In case of the application project **with a JNI part**, instead of manual libraries copying you
|
||||
need to modify your ``Android.mk`` file:
|
||||
add the following two code lines after the ``"include $(CLEAR_VARS)"`` and before
|
||||
``"include path_to_OpenCV-2.4.8.1-android-sdk/sdk/native/jni/OpenCV.mk"``
|
||||
``"include path_to_OpenCV-2.4.8.2-android-sdk/sdk/native/jni/OpenCV.mk"``
|
||||
|
||||
.. code-block:: make
|
||||
:linenos:
|
||||
@@ -221,7 +221,7 @@ taken:
|
||||
|
||||
.. code-block:: make
|
||||
|
||||
include C:\Work\OpenCV4Android\OpenCV-2.4.8.1-android-sdk\sdk\native\jni\OpenCV.mk
|
||||
include C:\Work\OpenCV4Android\OpenCV-2.4.8.2-android-sdk\sdk\native\jni\OpenCV.mk
|
||||
|
||||
Should be inserted into the :file:`jni/Android.mk` file **after** this line:
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ Required Packages
|
||||
* CMake 2.6 or higher;
|
||||
* Git;
|
||||
* GTK+2.x or higher, including headers (libgtk2.0-dev);
|
||||
* pkgconfig;
|
||||
* pkg-config;
|
||||
* Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy);
|
||||
* ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev;
|
||||
* [optional] libdc1394 2.x;
|
||||
|
||||
@@ -2401,7 +2401,7 @@ template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const SparseMat& m)
|
||||
if( m.type() == DataType<_Tp>::type )
|
||||
*this = (const SparseMat_<_Tp>&)m;
|
||||
else
|
||||
m.convertTo(this, DataType<_Tp>::type);
|
||||
m.convertTo(*this, DataType<_Tp>::type);
|
||||
}
|
||||
|
||||
template<typename _Tp> inline SparseMat_<_Tp>::SparseMat_(const SparseMat_<_Tp>& m)
|
||||
|
||||
@@ -50,7 +50,7 @@
|
||||
#define CV_VERSION_EPOCH 2
|
||||
#define CV_VERSION_MAJOR 4
|
||||
#define CV_VERSION_MINOR 8
|
||||
#define CV_VERSION_REVISION 1
|
||||
#define CV_VERSION_REVISION 2
|
||||
|
||||
#define CVAUX_STR_EXP(__A) #__A
|
||||
#define CVAUX_STR(__A) CVAUX_STR_EXP(__A)
|
||||
|
||||
@@ -647,7 +647,7 @@ void AlgorithmInfo::set(Algorithm* algo, const char* parameter, int argType, con
|
||||
|| argType == Param::FLOAT || argType == Param::UNSIGNED_INT || argType == Param::UINT64 || argType == Param::UCHAR)
|
||||
{
|
||||
if ( !( p->type == Param::INT || p->type == Param::REAL || p->type == Param::BOOLEAN
|
||||
|| p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || argType == Param::UCHAR
|
||||
|| p->type == Param::UNSIGNED_INT || p->type == Param::UINT64 || p->type == Param::FLOAT || p->type == Param::UCHAR
|
||||
|| (p->type == Param::SHORT && argType == Param::INT)) )
|
||||
{
|
||||
string message = getErrorMessageForWrongArgumentInSetter(algo->name(), parameter, p->type, argType);
|
||||
|
||||
@@ -1272,8 +1272,8 @@ static void arithm_op(InputArray _src1, InputArray _src2, OutputArray _dst,
|
||||
bool haveScalar = false, swapped12 = false;
|
||||
int depth2 = src2.depth();
|
||||
if( src1.size != src2.size || src1.channels() != src2.channels() ||
|
||||
((kind1 == _InputArray::MATX || kind2 == _InputArray::MATX) &&
|
||||
src1.cols == 1 && src2.rows == 4) )
|
||||
(kind1 == _InputArray::MATX && (src1.size() == Size(1,4) || src1.size() == Size(1,1))) ||
|
||||
(kind2 == _InputArray::MATX && (src2.size() == Size(1,4) || src2.size() == Size(1,1))) )
|
||||
{
|
||||
if( checkScalar(src1, src2.type(), kind1, kind2) )
|
||||
{
|
||||
|
||||
@@ -620,11 +620,19 @@ void cv::gpu::GpuMat::copyTo(GpuMat& m) const
|
||||
void cv::gpu::GpuMat::copyTo(GpuMat& mat, const GpuMat& mask) const
|
||||
{
|
||||
if (mask.empty())
|
||||
{
|
||||
copyTo(mat);
|
||||
}
|
||||
else
|
||||
{
|
||||
uchar* data0 = mat.data;
|
||||
|
||||
mat.create(size(), type());
|
||||
|
||||
// do not leave dst uninitialized
|
||||
if (mat.data != data0)
|
||||
mat.setTo(Scalar::all(0));
|
||||
|
||||
gpuFuncTable()->copyWithMask(*this, mat, mask);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -129,12 +129,14 @@ template<typename T> struct OpMax
|
||||
|
||||
inline Size getContinuousSize( const Mat& m1, int widthScale=1 )
|
||||
{
|
||||
CV_Assert(m1.dims <= 2);
|
||||
return m1.isContinuous() ? Size(m1.cols*m1.rows*widthScale, 1) :
|
||||
Size(m1.cols*widthScale, m1.rows);
|
||||
}
|
||||
|
||||
inline Size getContinuousSize( const Mat& m1, const Mat& m2, int widthScale=1 )
|
||||
{
|
||||
CV_Assert(m1.dims <= 2 && m1.size() == m2.size());
|
||||
return (m1.flags & m2.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
||||
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
||||
}
|
||||
@@ -142,6 +144,7 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2, int widthScale=1 )
|
||||
inline Size getContinuousSize( const Mat& m1, const Mat& m2,
|
||||
const Mat& m3, int widthScale=1 )
|
||||
{
|
||||
CV_Assert(m1.dims <= 2 && m1.size() == m2.size() && m1.size() == m3.size());
|
||||
return (m1.flags & m2.flags & m3.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
||||
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
||||
}
|
||||
@@ -150,6 +153,7 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2,
|
||||
const Mat& m3, const Mat& m4,
|
||||
int widthScale=1 )
|
||||
{
|
||||
CV_Assert(m1.dims <= 2 && m1.size() == m2.size() && m1.size() == m3.size() && m1.size() == m4.size());
|
||||
return (m1.flags & m2.flags & m3.flags & m4.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
||||
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
||||
}
|
||||
@@ -158,6 +162,7 @@ inline Size getContinuousSize( const Mat& m1, const Mat& m2,
|
||||
const Mat& m3, const Mat& m4,
|
||||
const Mat& m5, int widthScale=1 )
|
||||
{
|
||||
CV_Assert(m1.dims <= 2 && m1.size() == m2.size() && m1.size() == m3.size() && m1.size() == m4.size() && m1.size() == m5.size());
|
||||
return (m1.flags & m2.flags & m3.flags & m4.flags & m5.flags & Mat::CONTINUOUS_FLAG) != 0 ?
|
||||
Size(m1.cols*m1.rows*widthScale, 1) : Size(m1.cols*widthScale, m1.rows);
|
||||
}
|
||||
|
||||
@@ -1129,17 +1129,24 @@ public:
|
||||
}
|
||||
}
|
||||
};
|
||||
static TLSContainerStorage tlsContainerStorage;
|
||||
|
||||
// This is a wrapper function that will ensure 'tlsContainerStorage' is constructed on first use.
|
||||
// For more information: http://www.parashift.com/c++-faq/static-init-order-on-first-use.html
|
||||
static TLSContainerStorage& getTLSContainerStorage()
|
||||
{
|
||||
static TLSContainerStorage *tlsContainerStorage = new TLSContainerStorage();
|
||||
return *tlsContainerStorage;
|
||||
}
|
||||
|
||||
TLSDataContainer::TLSDataContainer()
|
||||
: key_(-1)
|
||||
{
|
||||
key_ = tlsContainerStorage.allocateKey(this);
|
||||
key_ = getTLSContainerStorage().allocateKey(this);
|
||||
}
|
||||
|
||||
TLSDataContainer::~TLSDataContainer()
|
||||
{
|
||||
tlsContainerStorage.releaseKey(key_, this);
|
||||
getTLSContainerStorage().releaseKey(key_, this);
|
||||
key_ = -1;
|
||||
}
|
||||
|
||||
@@ -1164,7 +1171,7 @@ TLSStorage::~TLSStorage()
|
||||
void*& data = tlsData_[i];
|
||||
if (data)
|
||||
{
|
||||
tlsContainerStorage.destroyData(i, data);
|
||||
getTLSContainerStorage().destroyData(i, data);
|
||||
data = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1564,3 +1564,19 @@ TEST(Core_round, CvRound)
|
||||
ASSERT_EQ(-2, cvRound(-2.5));
|
||||
ASSERT_EQ(-4, cvRound(-3.5));
|
||||
}
|
||||
|
||||
|
||||
typedef testing::TestWithParam<Size> Mul1;
|
||||
|
||||
TEST_P(Mul1, One)
|
||||
{
|
||||
Size size = GetParam();
|
||||
cv::Mat src(size, CV_32FC1, cv::Scalar::all(2)), dst,
|
||||
ref_dst(size, CV_32FC1, cv::Scalar::all(6));
|
||||
|
||||
cv::multiply(3, src, dst);
|
||||
|
||||
ASSERT_EQ(0, cv::norm(dst, ref_dst, cv::NORM_INF));
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Arithm, Mul1, testing::Values(Size(2, 2), Size(1, 1)));
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -414,12 +414,6 @@ public:
|
||||
|
||||
void loadIndex(FILE* stream)
|
||||
{
|
||||
load_value(stream, branching_);
|
||||
load_value(stream, trees_);
|
||||
load_value(stream, centers_init_);
|
||||
load_value(stream, leaf_size_);
|
||||
load_value(stream, memoryCounter);
|
||||
|
||||
free_elements();
|
||||
|
||||
if (root!=NULL) {
|
||||
@@ -430,6 +424,12 @@ public:
|
||||
delete[] indices;
|
||||
}
|
||||
|
||||
load_value(stream, branching_);
|
||||
load_value(stream, trees_);
|
||||
load_value(stream, centers_init_);
|
||||
load_value(stream, leaf_size_);
|
||||
load_value(stream, memoryCounter);
|
||||
|
||||
indices = new int*[trees_];
|
||||
root = new NodePtr[trees_];
|
||||
for (int i=0; i<trees_; ++i) {
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -672,7 +672,7 @@ PERF_TEST_P(Sz, ImgProc_ColumnSum,
|
||||
|
||||
DEF_PARAM_TEST(Image_AppertureSz_L2gradient, string, int, bool);
|
||||
|
||||
PERF_TEST_P(Image_AppertureSz_L2gradient, DISABLED_ImgProc_Canny,
|
||||
PERF_TEST_P(Image_AppertureSz_L2gradient, ImgProc_Canny,
|
||||
Combine(Values("perf/800x600.png", "perf/1280x1024.png", "perf/1680x1050.png"),
|
||||
Values(3, 5),
|
||||
Bool()))
|
||||
@@ -1542,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()))
|
||||
@@ -1563,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
|
||||
{
|
||||
@@ -1777,7 +1784,7 @@ PERF_TEST_P(Image, ImgProc_HoughLinesP,
|
||||
|
||||
DEF_PARAM_TEST(Sz_Dp_MinDist, cv::Size, float, float);
|
||||
|
||||
PERF_TEST_P(Sz_Dp_MinDist, DISABLED_ImgProc_HoughCircles,
|
||||
PERF_TEST_P(Sz_Dp_MinDist, ImgProc_HoughCircles,
|
||||
Combine(GPU_TYPICAL_MAT_SIZES,
|
||||
Values(1.0f, 2.0f, 4.0f),
|
||||
Values(1.0f)))
|
||||
|
||||
@@ -239,30 +239,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();
|
||||
|
||||
@@ -317,11 +322,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 +350,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 +368,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 +407,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 +424,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 +439,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,6 +461,8 @@ namespace canny
|
||||
|
||||
cudaSafeCall( cudaMemcpy(&count, counter_ptr, sizeof(int), cudaMemcpyDeviceToHost) );
|
||||
|
||||
count = min(count, map.cols * map.rows);
|
||||
|
||||
std::swap(st1, st2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#define CUDA_DISABLER
|
||||
|
||||
#if !defined CUDA_DISABLER
|
||||
|
||||
#include <thrust/device_ptr.h>
|
||||
|
||||
@@ -40,8 +40,6 @@
|
||||
//
|
||||
//M*/
|
||||
|
||||
#define CUDA_DISABLER
|
||||
|
||||
#include "precomp.hpp"
|
||||
|
||||
using namespace std;
|
||||
|
||||
@@ -1491,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);
|
||||
@@ -1506,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()
|
||||
@@ -1527,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);
|
||||
}
|
||||
@@ -1543,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);
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -840,7 +840,7 @@ GPU_TEST_P(CvtColor, YCrCb42RGBA)
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, DISABLED_BGR2HSV)
|
||||
GPU_TEST_P(CvtColor, BGR2HSV)
|
||||
{
|
||||
if (depth == CV_16U)
|
||||
return;
|
||||
@@ -856,7 +856,7 @@ GPU_TEST_P(CvtColor, DISABLED_BGR2HSV)
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, DISABLED_RGB2HSV)
|
||||
GPU_TEST_P(CvtColor, RGB2HSV)
|
||||
{
|
||||
if (depth == CV_16U)
|
||||
return;
|
||||
@@ -872,7 +872,7 @@ GPU_TEST_P(CvtColor, DISABLED_RGB2HSV)
|
||||
EXPECT_MAT_NEAR(dst_gold, dst, depth == CV_32F ? 1e-2 : 1);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, DISABLED_RGB2HSV4)
|
||||
GPU_TEST_P(CvtColor, RGB2HSV4)
|
||||
{
|
||||
if (depth == CV_16U)
|
||||
return;
|
||||
@@ -896,7 +896,7 @@ GPU_TEST_P(CvtColor, DISABLED_RGB2HSV4)
|
||||
EXPECT_MAT_NEAR(dst_gold, h_dst, depth == CV_32F ? 1e-2 : 1);
|
||||
}
|
||||
|
||||
GPU_TEST_P(CvtColor, DISABLED_RGBA2HSV4)
|
||||
GPU_TEST_P(CvtColor, RGBA2HSV4)
|
||||
{
|
||||
if (depth == CV_16U)
|
||||
return;
|
||||
|
||||
@@ -422,7 +422,7 @@ PARAM_TEST_CASE(Subtract_Array, cv::gpu::DeviceInfo, cv::Size, std::pair<MatDept
|
||||
}
|
||||
};
|
||||
|
||||
GPU_TEST_P(Subtract_Array, DISABLED_Accuracy)
|
||||
GPU_TEST_P(Subtract_Array, Accuracy)
|
||||
{
|
||||
cv::Mat mat1 = randomMat(size, stype);
|
||||
cv::Mat mat2 = randomMat(size, stype);
|
||||
@@ -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());
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -57,6 +57,14 @@
|
||||
#include <assert.h>
|
||||
|
||||
#if defined WIN32 || defined WINCE
|
||||
#if !defined _WIN32_WINNT
|
||||
#ifdef HAVE_MSMF
|
||||
#define _WIN32_WINNT 0x0600 // Windows Vista
|
||||
#else
|
||||
#define _WIN32_WINNT 0x0500 // Windows 2000
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#include <windows.h>
|
||||
#undef small
|
||||
#undef min
|
||||
|
||||
@@ -43,27 +43,11 @@
|
||||
|
||||
#if defined WIN32 || defined _WIN32
|
||||
|
||||
#define COMPILE_MULTIMON_STUBS // Required for multi-monitor support
|
||||
#ifndef _MULTIMON_USE_SECURE_CRT
|
||||
# define _MULTIMON_USE_SECURE_CRT 0 // some MinGW platforms have no strncpy_s
|
||||
#endif
|
||||
|
||||
#if defined SM_CMONITORS && !defined MONITOR_DEFAULTTONEAREST
|
||||
# define MONITOR_DEFAULTTONULL 0x00000000
|
||||
# define MONITOR_DEFAULTTOPRIMARY 0x00000001
|
||||
# define MONITOR_DEFAULTTONEAREST 0x00000002
|
||||
# define MONITORINFOF_PRIMARY 0x00000001
|
||||
#endif
|
||||
#ifndef __inout
|
||||
# define __inout
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||
#endif
|
||||
|
||||
#include <commctrl.h>
|
||||
#include <winuser.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
@@ -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 + "}";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ 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)
|
||||
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"
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
set(the_description "Images stitching")
|
||||
if (ENABLE_DYNAMIC_CUDA)
|
||||
if(ENABLE_DYNAMIC_CUDA)
|
||||
add_definitions(-DDYNAMIC_CUDA_SUPPORT)
|
||||
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_nonfree)
|
||||
else()
|
||||
ocv_define_module(stitching opencv_imgproc opencv_features2d opencv_calib3d opencv_objdetect OPTIONAL opencv_gpu opencv_nonfree)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
@@ -44,11 +44,12 @@
|
||||
#define __OPENCV_STITCHING_MATCHERS_HPP__
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
|
||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_NONFREE)
|
||||
#include "opencv2/nonfree/gpu.hpp"
|
||||
#endif
|
||||
|
||||
@@ -104,7 +105,7 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_NONFREE)
|
||||
class CV_EXPORTS SurfFeaturesFinderGpu : public FeaturesFinder
|
||||
{
|
||||
public:
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
|
||||
#include <set>
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
@@ -227,7 +227,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder
|
||||
{
|
||||
public:
|
||||
@@ -251,7 +250,6 @@ private:
|
||||
float terminal_cost_;
|
||||
float bad_region_penalty_;
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace cv
|
||||
|
||||
@@ -44,11 +44,8 @@
|
||||
#define __OPENCV_STITCHING_WARPERS_HPP__
|
||||
|
||||
#include "opencv2/core/core.hpp"
|
||||
#include "opencv2/core/gpumat.hpp"
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/opencv_modules.hpp"
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
# include "opencv2/gpu/gpu.hpp"
|
||||
#endif
|
||||
|
||||
namespace cv {
|
||||
namespace detail {
|
||||
@@ -331,7 +328,6 @@ public:
|
||||
};
|
||||
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
class CV_EXPORTS PlaneWarperGpu : public PlaneWarper
|
||||
{
|
||||
public:
|
||||
@@ -448,7 +444,6 @@ public:
|
||||
private:
|
||||
gpu::GpuMat d_xmap_, d_ymap_, d_src_, d_dst_;
|
||||
};
|
||||
#endif
|
||||
|
||||
|
||||
struct SphericalPortraitProjector : ProjectorBase
|
||||
|
||||
@@ -145,7 +145,6 @@ public:
|
||||
|
||||
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
class PlaneWarperGpu: public WarperCreator
|
||||
{
|
||||
public:
|
||||
@@ -165,7 +164,6 @@ class SphericalWarperGpu: public WarperCreator
|
||||
public:
|
||||
Ptr<detail::RotationWarper> create(float scale) const { return new detail::SphericalWarperGpu(scale); }
|
||||
};
|
||||
#endif
|
||||
|
||||
} // namespace cv
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ Rect FeatherBlender::createWeightMaps(const vector<Mat> &masks, const vector<Poi
|
||||
MultiBandBlender::MultiBandBlender(int try_gpu, int num_bands, int weight_type)
|
||||
{
|
||||
setNumBands(num_bands);
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
can_use_gpu_ = try_gpu && gpu::getCudaEnabledDeviceCount();
|
||||
#else
|
||||
(void)try_gpu;
|
||||
@@ -491,7 +491,7 @@ void createLaplacePyr(const Mat &img, int num_levels, vector<Mat> &pyr)
|
||||
|
||||
void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
|
||||
{
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
pyr.resize(num_levels + 1);
|
||||
|
||||
vector<gpu::GpuMat> gpu_pyr(num_levels + 1);
|
||||
@@ -512,6 +512,7 @@ void createLaplacePyrGpu(const Mat &img, int num_levels, vector<Mat> &pyr)
|
||||
(void)img;
|
||||
(void)num_levels;
|
||||
(void)pyr;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -531,7 +532,7 @@ void restoreImageFromLaplacePyr(vector<Mat> &pyr)
|
||||
|
||||
void restoreImageFromLaplacePyrGpu(vector<Mat> &pyr)
|
||||
{
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
if (pyr.empty())
|
||||
return;
|
||||
|
||||
@@ -549,6 +550,7 @@ void restoreImageFromLaplacePyrGpu(vector<Mat> &pyr)
|
||||
gpu_pyr[0].download(pyr[0]);
|
||||
#else
|
||||
(void)pyr;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -45,10 +45,7 @@
|
||||
using namespace std;
|
||||
using namespace cv;
|
||||
using namespace cv::detail;
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
using namespace cv::gpu;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_OPENCV_NONFREE
|
||||
#include "opencv2/nonfree/nonfree.hpp"
|
||||
@@ -129,7 +126,7 @@ private:
|
||||
float match_conf_;
|
||||
};
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
class GpuMatcher : public FeaturesMatcher
|
||||
{
|
||||
public:
|
||||
@@ -204,7 +201,7 @@ void CpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &feat
|
||||
LOG("1->2 & 2->1 matches: " << matches_info.matches.size() << endl);
|
||||
}
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
void GpuMatcher::match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo& matches_info)
|
||||
{
|
||||
matches_info.matches.clear();
|
||||
@@ -432,7 +429,7 @@ void OrbFeaturesFinder::find(const Mat &image, ImageFeatures &features)
|
||||
}
|
||||
}
|
||||
|
||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
SurfFeaturesFinderGpu::SurfFeaturesFinderGpu(double hess_thresh, int num_octaves, int num_layers,
|
||||
int num_octaves_descr, int num_layers_descr)
|
||||
{
|
||||
@@ -478,6 +475,29 @@ void SurfFeaturesFinderGpu::collectGarbage()
|
||||
keypoints_.release();
|
||||
descriptors_.release();
|
||||
}
|
||||
#elif defined(HAVE_OPENCV_NONFREE)
|
||||
SurfFeaturesFinderGpu::SurfFeaturesFinderGpu(double hess_thresh, int num_octaves, int num_layers,
|
||||
int num_octaves_descr, int num_layers_descr)
|
||||
{
|
||||
(void)hess_thresh;
|
||||
(void)num_octaves;
|
||||
(void)num_layers;
|
||||
(void)num_octaves_descr;
|
||||
(void)num_layers_descr;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
}
|
||||
|
||||
|
||||
void SurfFeaturesFinderGpu::find(const Mat &image, ImageFeatures &features)
|
||||
{
|
||||
(void)image;
|
||||
(void)features;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
}
|
||||
|
||||
void SurfFeaturesFinderGpu::collectGarbage()
|
||||
{
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -533,7 +553,7 @@ void FeaturesMatcher::operator ()(const vector<ImageFeatures> &features, vector<
|
||||
|
||||
BestOf2NearestMatcher::BestOf2NearestMatcher(bool try_use_gpu, float match_conf, int num_matches_thresh1, int num_matches_thresh2)
|
||||
{
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
if (try_use_gpu && getCudaEnabledDeviceCount() > 0)
|
||||
impl_ = new GpuMatcher(match_conf);
|
||||
else
|
||||
|
||||
@@ -68,7 +68,7 @@
|
||||
#include "opencv2/imgproc/imgproc.hpp"
|
||||
#include "opencv2/features2d/features2d.hpp"
|
||||
#include "opencv2/calib3d/calib3d.hpp"
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
#include "opencv2/gpu/gpu.hpp"
|
||||
|
||||
#ifdef HAVE_OPENCV_NONFREE
|
||||
|
||||
@@ -1318,7 +1318,7 @@ void GraphCutSeamFinder::find(const vector<Mat> &src, const vector<Point> &corne
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
void GraphCutSeamFinderGpu::find(const vector<Mat> &src, const vector<Point> &corners,
|
||||
vector<Mat> &masks)
|
||||
{
|
||||
@@ -1642,6 +1642,62 @@ void GraphCutSeamFinderGpu::setGraphWeightsColorGrad(
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
void GraphCutSeamFinderGpu::find(const vector<Mat> &src, const vector<Point> &corners,
|
||||
vector<Mat> &masks)
|
||||
{
|
||||
(void)src;
|
||||
(void)corners;
|
||||
(void)masks;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
}
|
||||
|
||||
|
||||
void GraphCutSeamFinderGpu::findInPair(size_t first, size_t second, Rect roi)
|
||||
{
|
||||
(void)first;
|
||||
(void)second;
|
||||
(void)roi;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
}
|
||||
|
||||
|
||||
void GraphCutSeamFinderGpu::setGraphWeightsColor(const Mat &img1, const Mat &img2, const Mat &mask1, const Mat &mask2,
|
||||
Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)
|
||||
{
|
||||
(void)img1;
|
||||
(void)img2;
|
||||
(void)mask1;
|
||||
(void)mask2;
|
||||
(void)terminals;
|
||||
(void)leftT;
|
||||
(void)rightT;
|
||||
(void)top;
|
||||
(void)bottom;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
}
|
||||
|
||||
|
||||
void GraphCutSeamFinderGpu::setGraphWeightsColorGrad(
|
||||
const Mat &img1, const Mat &img2, const Mat &dx1, const Mat &dx2,
|
||||
const Mat &dy1, const Mat &dy2, const Mat &mask1, const Mat &mask2,
|
||||
Mat &terminals, Mat &leftT, Mat &rightT, Mat &top, Mat &bottom)
|
||||
{
|
||||
(void)img1;
|
||||
(void)img2;
|
||||
(void)dx1;
|
||||
(void)dx2;
|
||||
(void)dy1;
|
||||
(void)dy2;
|
||||
(void)mask1;
|
||||
(void)mask2;
|
||||
(void)terminals;
|
||||
(void)leftT;
|
||||
(void)rightT;
|
||||
(void)top;
|
||||
(void)bottom;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
}
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
|
||||
@@ -58,7 +58,7 @@ Stitcher Stitcher::createDefault(bool try_use_gpu)
|
||||
stitcher.setFeaturesMatcher(new detail::BestOf2NearestMatcher(try_use_gpu));
|
||||
stitcher.setBundleAdjuster(new detail::BundleAdjusterRay());
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
if (try_use_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||
{
|
||||
#if defined(HAVE_OPENCV_NONFREE)
|
||||
|
||||
@@ -212,7 +212,7 @@ void SphericalWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_b
|
||||
}
|
||||
|
||||
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(DYNAMIC_CUDA_SUPPORT)
|
||||
Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
|
||||
{
|
||||
return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32F), xmap, ymap);
|
||||
@@ -294,6 +294,96 @@ Point CylindricalWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat
|
||||
gpu::remap(src, dst, d_xmap_, d_ymap_, interp_mode, border_mode);
|
||||
return dst_roi.tl();
|
||||
}
|
||||
#else
|
||||
Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
|
||||
{
|
||||
return buildMaps(src_size, K, R, Mat::zeros(3, 1, CV_32F), xmap, ymap);
|
||||
}
|
||||
|
||||
Rect PlaneWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, const Mat &T, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
|
||||
{
|
||||
(void)src_size;
|
||||
(void)K;
|
||||
(void)R;
|
||||
(void)T;
|
||||
(void)xmap;
|
||||
(void)ymap;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
return Rect();
|
||||
}
|
||||
|
||||
Point PlaneWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,
|
||||
gpu::GpuMat &dst)
|
||||
{
|
||||
return warp(src, K, R, Mat::zeros(3, 1, CV_32F), interp_mode, border_mode, dst);
|
||||
}
|
||||
|
||||
|
||||
Point PlaneWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, const Mat &T, int interp_mode, int border_mode,
|
||||
gpu::GpuMat &dst)
|
||||
{
|
||||
(void)src;
|
||||
(void)K;
|
||||
(void)R;
|
||||
(void)T;
|
||||
(void)interp_mode;
|
||||
(void)border_mode;
|
||||
(void)dst;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
return Point();
|
||||
}
|
||||
|
||||
|
||||
Rect SphericalWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
|
||||
{
|
||||
(void)src_size;
|
||||
(void)K;
|
||||
(void)R;
|
||||
(void)xmap;
|
||||
(void)ymap;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
return Rect();
|
||||
}
|
||||
|
||||
|
||||
Point SphericalWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,
|
||||
gpu::GpuMat &dst)
|
||||
{
|
||||
(void)src;
|
||||
(void)K;
|
||||
(void)R;
|
||||
(void)interp_mode;
|
||||
(void)border_mode;
|
||||
(void)dst;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
return Point();
|
||||
}
|
||||
|
||||
|
||||
Rect CylindricalWarperGpu::buildMaps(Size src_size, const Mat &K, const Mat &R, gpu::GpuMat &xmap, gpu::GpuMat &ymap)
|
||||
{
|
||||
(void)src_size;
|
||||
(void)K;
|
||||
(void)R;
|
||||
(void)xmap;
|
||||
(void)ymap;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
return Rect();
|
||||
}
|
||||
|
||||
|
||||
Point CylindricalWarperGpu::warp(const gpu::GpuMat &src, const Mat &K, const Mat &R, int interp_mode, int border_mode,
|
||||
gpu::GpuMat &dst)
|
||||
{
|
||||
(void)src;
|
||||
(void)K;
|
||||
(void)R;
|
||||
(void)interp_mode;
|
||||
(void)border_mode;
|
||||
(void)dst;
|
||||
CV_Error(CV_StsNotImplemented, "CUDA optimization is unavailable");
|
||||
return Point();
|
||||
}
|
||||
#endif
|
||||
|
||||
void SphericalPortraitWarper::detectResultRoi(Size src_size, Point &dst_tl, Point &dst_br)
|
||||
|
||||
+2
-1
@@ -21,6 +21,7 @@ public class CvNativeActivity extends Activity {
|
||||
System.loadLibrary("native_activity");
|
||||
Intent intent = new Intent(CvNativeActivity.this, android.app.NativeActivity.class);
|
||||
CvNativeActivity.this.startActivity(intent);
|
||||
CvNativeActivity.this.finish();
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
@@ -34,7 +35,7 @@ public class CvNativeActivity extends Activity {
|
||||
Log.i(TAG, "Instantiated new " + this.getClass());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
set(sample example-tutorial-4-cuda)
|
||||
|
||||
ocv_check_dependencies(opencv_core opencv_java opencv_gpu)
|
||||
ocv_check_dependencies(opencv_core opencv_features2d opencv_java opencv_gpu)
|
||||
|
||||
if (OCV_DEPENDENCIES_FOUND)
|
||||
if(BUILD_FAT_JAVA_LIB)
|
||||
set(native_deps opencv_java opencv_gpu)
|
||||
else()
|
||||
set(native_deps opencv_gpu)
|
||||
set(native_deps opencv_core opencv_features2d opencv_java opencv_gpu)
|
||||
endif()
|
||||
|
||||
add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11 ${ANDROID_SDK_TARGET} NATIVE_DEPS ${native_deps})
|
||||
add_android_project(${sample} "${CMAKE_CURRENT_SOURCE_DIR}" LIBRARY_DEPS ${OpenCV_BINARY_DIR} SDK_TARGET 11 ${ANDROID_SDK_TARGET} NATIVE_DEPS ${native_deps} EMBED_CUDA ON FORCE_EMBED_OPENCV ON)
|
||||
|
||||
if(TARGET ${sample})
|
||||
add_dependencies(opencv_android_examples ${sample})
|
||||
endif()
|
||||
|
||||
@@ -2,6 +2,8 @@ LOCAL_PATH := $(call my-dir)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
|
||||
INSTALL_CUDA_LIBRARIES:=on
|
||||
OPENCV_INSTALL_MODULES:=on
|
||||
CUDA_TOOLKIT_DIR=$(CUDA_TOOLKIT_ROOT)
|
||||
include ../../sdk/native/jni/OpenCV.mk
|
||||
|
||||
|
||||
+26
-24
@@ -49,29 +49,6 @@ public class Tutorial4Activity extends Activity implements CvCameraViewListener2
|
||||
{
|
||||
Log.i(TAG, "OpenCV loaded successfully");
|
||||
|
||||
// Check CUDA support
|
||||
if (Gpu.getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
Log.e(TAG, "No CUDA capable device found!");
|
||||
AlertDialog InitFailedDialog = new AlertDialog.Builder(Tutorial4Activity.this).create();
|
||||
InitFailedDialog.setTitle("OpenCV CUDA error");
|
||||
InitFailedDialog.setMessage("CUDA compatible device was not found!");
|
||||
InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button
|
||||
InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
|
||||
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Tutorial4Activity.this.finish();
|
||||
}
|
||||
});
|
||||
InitFailedDialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load native library after(!) OpenCV initialization
|
||||
Log.i(TAG, "Found CUDA capable device!");
|
||||
System.loadLibrary("cuda_sample");
|
||||
mOpenCvCameraView.enableView();
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
{
|
||||
@@ -120,7 +97,32 @@ public class Tutorial4Activity extends Activity implements CvCameraViewListener2
|
||||
public void onResume()
|
||||
{
|
||||
super.onResume();
|
||||
OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_8, this, mLoaderCallback);
|
||||
if (OpenCVLoader.initDebug(true))
|
||||
{
|
||||
// Check CUDA support
|
||||
if (Gpu.getCudaEnabledDeviceCount() <= 0)
|
||||
{
|
||||
Log.e(TAG, "No CUDA capable device found!");
|
||||
AlertDialog InitFailedDialog = new AlertDialog.Builder(Tutorial4Activity.this).create();
|
||||
InitFailedDialog.setTitle("OpenCV CUDA error");
|
||||
InitFailedDialog.setMessage("CUDA compatible device was not found!");
|
||||
InitFailedDialog.setCancelable(false); // This blocks the 'BACK' button
|
||||
InitFailedDialog.setButton(AlertDialog.BUTTON_POSITIVE, "OK", new OnClickListener() {
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
Tutorial4Activity.this.finish();
|
||||
}
|
||||
});
|
||||
InitFailedDialog.show();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load native library after(!) OpenCV initialization
|
||||
Log.i(TAG, "Found CUDA capable device!");
|
||||
System.loadLibrary("cuda_sample");
|
||||
mOpenCvCameraView.enableView();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void onDestroy() {
|
||||
|
||||
@@ -33,7 +33,7 @@ int main( int /*argc*/, char** /*argv*/ )
|
||||
{
|
||||
int k, clusterCount = rng.uniform(2, MAX_CLUSTERS+1);
|
||||
int i, sampleCount = rng.uniform(1, 1001);
|
||||
Mat points(sampleCount, 1, CV_32FC2), labels;
|
||||
Mat points(sampleCount, 2, CV_32F), labels;
|
||||
|
||||
clusterCount = MIN(clusterCount, sampleCount);
|
||||
Mat centers(clusterCount, 1, points.type());
|
||||
|
||||
@@ -355,7 +355,7 @@ int main(int argc, char* argv[])
|
||||
Ptr<FeaturesFinder> finder;
|
||||
if (features_type == "surf")
|
||||
{
|
||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_NONFREE) && defined(HAVE_OPENCV_GPU)
|
||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||
finder = new SurfFeaturesFinderGpu();
|
||||
else
|
||||
@@ -543,7 +543,7 @@ int main(int argc, char* argv[])
|
||||
// Warp images and their masks
|
||||
|
||||
Ptr<WarperCreator> warper_creator;
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU)
|
||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||
{
|
||||
if (warp_type == "plane") warper_creator = new cv::PlaneWarperGpu();
|
||||
@@ -608,7 +608,7 @@ int main(int argc, char* argv[])
|
||||
seam_finder = new detail::VoronoiSeamFinder();
|
||||
else if (seam_find_type == "gc_color")
|
||||
{
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU)
|
||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR);
|
||||
else
|
||||
@@ -617,7 +617,7 @@ int main(int argc, char* argv[])
|
||||
}
|
||||
else if (seam_find_type == "gc_colorgrad")
|
||||
{
|
||||
#if defined(HAVE_OPENCV_GPU) && !defined(ANDROID)
|
||||
#if defined(HAVE_OPENCV_GPU)
|
||||
if (try_gpu && gpu::getCudaEnabledDeviceCount() > 0)
|
||||
seam_finder = new detail::GraphCutSeamFinderGpu(GraphCutSeamFinderBase::COST_COLOR_GRAD);
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user