+++ /dev/null
-set(name "gpu")
-
-set(the_target "opencv_${name}")
-project(${the_target})
-
-set(DEPS "opencv_core" "opencv_imgproc" "opencv_objdetect" "opencv_features2d" "opencv_flann" "opencv_calib3d") #"opencv_features2d" "opencv_flann" "opencv_objdetect" - only headers needed
-set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} opencv_gpu)
-
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/src/cuda"
- "${CMAKE_CURRENT_SOURCE_DIR}/src"
- "${CMAKE_CURRENT_BINARY_DIR}")
-
-file(GLOB lib_srcs "src/*.cpp")
-file(GLOB lib_int_hdrs "src/*.h*")
-file(GLOB lib_cuda "src/cuda/*.cu*")
-file(GLOB lib_cuda_hdrs "src/cuda/*.h*")
-source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs})
-source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs})
-
-file(GLOB lib_hdrs "include/opencv2/${name}/*.h*")
-source_group("Include" FILES ${lib_hdrs})
-
-#file(GLOB lib_device_hdrs "include/opencv2/${name}/device/*.h*")
-file(GLOB lib_device_hdrs "src/opencv2/gpu/device/*.h*")
-source_group("Device" FILES ${lib_device_hdrs})
-
-if (HAVE_CUDA)
- file(GLOB_RECURSE ncv_srcs "src/nvidia/*.cpp")
- file(GLOB_RECURSE ncv_cuda "src/nvidia/*.cu")
- file(GLOB_RECURSE ncv_hdrs "src/nvidia/*.hpp" "src/nvidia/*.h")
-
- source_group("Src\\NVidia" FILES ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda})
- include_directories("src/nvidia/core" "src/nvidia/NPP_staging")
-endif()
-
-if (HAVE_CUDA)
- get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH)
- set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp})
- find_package(NPP 3.2.16 REQUIRED)
- message(STATUS "NPP detected: " ${NPP_VERSION})
-
- include_directories(${CUDA_INCLUDE_DIRS} ${CUDA_NPP_INCLUDES})
-
- if (UNIX OR APPLE)
- set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-fPIC;")
- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" "-fPIC")
- endif()
-
- #set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-keep")
- #set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/EHsc-;")
-
- string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
-
- if(MSVC)
- #string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- #string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- #string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4211 /wd4201 /wd4100 /wd4505 /wd4408")
-
- string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
- endif()
-
- if (OPENCV_BUILD_SHARED_LIB)
- set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-DCVAPI_EXPORTS")
- endif()
-
- CUDA_COMPILE(cuda_objs ${lib_cuda} ${ncv_cuda})
- #CUDA_BUILD_CLEAN_TARGET()
-endif()
-
-foreach(d ${DEPS})
- if(${d} MATCHES "opencv_")
- string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d})
- include_directories("${d_dir}/include")
- endif()
-endforeach()
-
-add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs} ${lib_device_hdrs} ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda} ${cuda_objs})
-
-if(PCHSupport_FOUND)
- set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp)
- if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*")
- if(${CMAKE_GENERATOR} MATCHES "Visual*")
- set(${the_target}_pch "src/precomp.cpp")
- endif()
- add_native_precompiled_header(${the_target} ${pch_header})
- elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles")
- add_precompiled_header(${the_target} ${pch_header})
- endif()
-endif()
-
-# For dynamic link numbering convenions
-set_target_properties(${the_target} PROPERTIES
- VERSION ${OPENCV_VERSION}
- SOVERSION ${OPENCV_SOVERSION}
- OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}"
- )
-
-if(ENABLE_SOLUTION_FOLDERS)
- set_target_properties(${the_target} PROPERTIES FOLDER "modules")
-endif()
-
-if (OPENCV_BUILD_SHARED_LIB)
- if (MSVC)
- set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
- else()
- add_definitions(-DCVAPI_EXPORTS)
- endif()
-endif()
-
-# Additional target properties
-set_target_properties(${the_target} PROPERTIES
- DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
- ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
- INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
- )
-
-# Add the required libraries for linking:
-target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} )
-
-if (HAVE_CUDA)
- target_link_libraries(${the_target} ${CUDA_LIBRARIES} ${CUDA_NPP_LIBRARIES})
- CUDA_ADD_CUFFT_TO_TARGET(${the_target})
-endif()
-
-if(MSVC)
- if(CMAKE_CROSSCOMPILING)
- set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
- endif()
-
- set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc")
-endif()
-
-# Dependencies of this target:
-add_dependencies(${the_target} ${DEPS})
-
-install(TARGETS ${the_target}
- RUNTIME DESTINATION bin COMPONENT main
- LIBRARY DESTINATION lib COMPONENT main
- ARCHIVE DESTINATION lib COMPONENT main)
-
-install(FILES ${lib_hdrs}
- DESTINATION include/opencv2/${name}
- COMPONENT main)
-
-install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp
- DESTINATION include/opencv2/${name}
- COMPONENT main)
-
-#install(FILES ${lib_device_hdrs}
-# DESTINATION include/opencv2/${name}/device
-# COMPONENT main)
-
-
-################################################################################################################
-################################ GPU Module Tests #####################################################
-################################################################################################################
-
-# Test files processing is in the separated directory to avoid 'Src' source
-# filter creation in Visual Studio
-if(BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test)
- set(the_test_target "opencv_test_${name}")
-
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/test"
- "${CMAKE_CURRENT_BINARY_DIR}")
-
- set(test_deps opencv_${name} opencv_ts opencv_highgui opencv_calib3d ${DEPS})
- foreach(d ${test_deps})
- if(${d} MATCHES "opencv_")
- if(${d} MATCHES "opencv_lapack")
- else()
- string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d})
- include_directories("${d_dir}/include")
- endif()
- endif()
- endforeach()
-
- file(GLOB test_srcs "test/*.cpp")
- file(GLOB test_hdrs "test/*.h*")
-
- source_group("Src" FILES ${test_hdrs} ${test_srcs})
- if(HAVE_CUDA)
- include_directories(${CUDA_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/NPP_staging)
-
- file(GLOB nvidia "test/nvidia/*.cpp" "test/nvidia/*.h*")
- source_group("Src\\NVidia" FILES ${nvidia})
- endif()
-
-
- add_executable(${the_test_target} ${test_srcs} ${test_hdrs} ${nvidia})
-
- if(PCHSupport_FOUND)
- set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/test/test_precomp.hpp)
- if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*")
- if(${CMAKE_GENERATOR} MATCHES "Visual*")
- set(${the_test_target}_pch "test/test_precomp.cpp")
- endif()
- add_native_precompiled_header(${the_test_target} ${pch_header})
- elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles")
- add_precompiled_header(${the_test_target} ${pch_header})
- endif()
- endif()
-
- # Additional target properties
- set_target_properties(${the_test_target} PROPERTIES
- DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
- )
-
- if(ENABLE_SOLUTION_FOLDERS)
- set_target_properties(${the_test_target} PROPERTIES FOLDER "tests")
- endif()
-
- add_dependencies(${the_test_target} ${test_deps})
-
- # Add the required libraries for linking:
- target_link_libraries(${the_test_target} ${OPENCV_LINKER_LIBS} ${test_deps})
-
- enable_testing()
- get_target_property(LOC ${the_test_target} LOCATION)
- add_test(${the_test_target} "${LOC}")
-
- if(WIN32)
- install(TARGETS ${the_test_target} RUNTIME DESTINATION bin COMPONENT main)
- endif()
-endif()
+++ /dev/null
-set(name "gpu")
-
-set(the_target "opencv_${name}")
-project(${the_target})
-
-set(DEPS "opencv_core" "opencv_imgproc" "opencv_objdetect" "opencv_features2d" "opencv_flann" "opencv_calib3d") #"opencv_features2d" "opencv_flann" "opencv_objdetect" - only headers needed
-set(OPENCV_LINKER_LIBS ${OPENCV_LINKER_LIBS} opencv_gpu)
-
-include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/src/cuda"
- "${CMAKE_CURRENT_SOURCE_DIR}/src"
- "${CMAKE_CURRENT_BINARY_DIR}")
-
-file(GLOB lib_srcs "src/*.cpp")
-file(GLOB lib_int_hdrs "src/*.h*")
-file(GLOB lib_cuda "src/cuda/*.cu*")
-file(GLOB lib_cuda_hdrs "src/cuda/*.h*")
-source_group("Src\\Host" FILES ${lib_srcs} ${lib_int_hdrs})
-source_group("Src\\Cuda" FILES ${lib_cuda} ${lib_cuda_hdrs})
-
-file(GLOB lib_hdrs "include/opencv2/${name}/*.h*")
-source_group("Include" FILES ${lib_hdrs})
-
-#file(GLOB lib_device_hdrs "include/opencv2/${name}/device/*.h*")
-file(GLOB lib_device_hdrs "src/opencv2/gpu/device/*.h*")
-source_group("Device" FILES ${lib_device_hdrs})
-
-if (HAVE_CUDA)
- file(GLOB_RECURSE ncv_srcs "src/nvidia/*.cpp")
- file(GLOB_RECURSE ncv_cuda "src/nvidia/*.cu")
- file(GLOB_RECURSE ncv_hdrs "src/nvidia/*.hpp" "src/nvidia/*.h")
-
- source_group("Src\\NVidia" FILES ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda})
- include_directories("src/nvidia/core" "src/nvidia/NPP_staging")
-endif()
-
-if (HAVE_CUDA)
- #get_filename_component(_path_to_findnpp "${CMAKE_CURRENT_LIST_FILE}" PATH)
- #set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${_path_to_findnpp})
- #find_package(NPP 3.2.16 REQUIRED)
- #message(STATUS "NPP detected: " ${NPP_VERSION})
-
- include_directories(${CUDA_INCLUDE_DIRS})
-
- if (UNIX OR APPLE)
- set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-fPIC;")
- #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}" "-fPIC")
- endif()
-
- #set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-keep")
- #set (CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;/EHsc-;")
-
- string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
-
- if(MSVC)
- #string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- #string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- #string(REPLACE "/W4" "/W3" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4211 /wd4201 /wd4100 /wd4505 /wd4408")
-
- string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
- string(REPLACE "/EHsc-" "/EHs" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
- endif()
-
- if (OPENCV_BUILD_SHARED_LIB)
- set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} "-Xcompiler;-DCVAPI_EXPORTS")
- endif()
-
- CUDA_COMPILE(cuda_objs ${lib_cuda} ${ncv_cuda})
- #CUDA_BUILD_CLEAN_TARGET()
-endif()
-
-foreach(d ${DEPS})
- if(${d} MATCHES "opencv_")
- string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d})
- include_directories("${d_dir}/include")
- endif()
-endforeach()
-
-add_library(${the_target} ${lib_srcs} ${lib_hdrs} ${lib_int_hdrs} ${lib_cuda} ${lib_cuda_hdrs} ${lib_device_hdrs} ${ncv_srcs} ${ncv_hdrs} ${ncv_cuda} ${cuda_objs})
-
-if(PCHSupport_FOUND)
- set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/src/precomp.hpp)
- if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*")
- if(${CMAKE_GENERATOR} MATCHES "Visual*")
- set(${the_target}_pch "src/precomp.cpp")
- endif()
- add_native_precompiled_header(${the_target} ${pch_header})
- elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles")
- add_precompiled_header(${the_target} ${pch_header})
- endif()
-endif()
-
-# For dynamic link numbering convenions
-set_target_properties(${the_target} PROPERTIES
- VERSION ${OPENCV_VERSION}
- SOVERSION ${OPENCV_SOVERSION}
- OUTPUT_NAME "${the_target}${OPENCV_DLLVERSION}"
- )
-
-if(ENABLE_SOLUTION_FOLDERS)
- set_target_properties(${the_target} PROPERTIES FOLDER "modules")
-endif()
-
-if (OPENCV_BUILD_SHARED_LIB)
- if (MSVC)
- set_target_properties(${the_target} PROPERTIES DEFINE_SYMBOL CVAPI_EXPORTS)
- else()
- add_definitions(-DCVAPI_EXPORTS)
- endif()
-endif()
-
-# Additional target properties
-set_target_properties(${the_target} PROPERTIES
- DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
- ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
- INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
- )
-
-# Add the required libraries for linking:
-target_link_libraries(${the_target} ${OPENCV_LINKER_LIBS} ${IPP_LIBS} ${DEPS} )
-
-if (HAVE_CUDA)
- target_link_libraries(${the_target} ${CUDA_LIBRARIES})
- CUDA_ADD_CUFFT_TO_TARGET(${the_target})
-
- unset(CUDA_npp_LIBRARY CACHE)
- find_cuda_helper_libs(npp)
- target_link_libraries(${the_target} ${CUDA_npp_LIBRARY})
-endif()
-
-if(MSVC)
- if(CMAKE_CROSSCOMPILING)
- set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:secchk")
- endif()
-
- set_target_properties(${the_target} PROPERTIES LINK_FLAGS "/NODEFAULTLIB:libc")
-endif()
-
-# Dependencies of this target:
-add_dependencies(${the_target} ${DEPS})
-
-install(TARGETS ${the_target}
- RUNTIME DESTINATION bin COMPONENT main
- LIBRARY DESTINATION lib COMPONENT main
- ARCHIVE DESTINATION lib COMPONENT main)
-
-install(FILES ${lib_hdrs}
- DESTINATION include/opencv2/${name}
- COMPONENT main)
-
-install(FILES src/nvidia/NPP_staging/NPP_staging.hpp src/nvidia/core/NCV.hpp
- DESTINATION include/opencv2/${name}
- COMPONENT main)
-
-#install(FILES ${lib_device_hdrs}
-# DESTINATION include/opencv2/${name}/device
-# COMPONENT main)
-
-
-################################################################################################################
-################################ GPU Module Tests #####################################################
-################################################################################################################
-
-# Test files processing is in the separated directory to avoid 'Src' source
-# filter creation in Visual Studio
-if(BUILD_TESTS AND EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/test)
- set(the_test_target "opencv_test_${name}")
-
- include_directories("${CMAKE_CURRENT_SOURCE_DIR}/include"
- "${CMAKE_CURRENT_SOURCE_DIR}/test"
- "${CMAKE_CURRENT_BINARY_DIR}")
-
- set(test_deps opencv_${name} opencv_ts opencv_highgui opencv_calib3d ${DEPS})
- foreach(d ${test_deps})
- if(${d} MATCHES "opencv_")
- if(${d} MATCHES "opencv_lapack")
- else()
- string(REPLACE "opencv_" "${CMAKE_CURRENT_SOURCE_DIR}/../" d_dir ${d})
- include_directories("${d_dir}/include")
- endif()
- endif()
- endforeach()
-
- file(GLOB test_srcs "test/*.cpp")
- file(GLOB test_hdrs "test/*.h*")
-
- source_group("Src" FILES ${test_hdrs} ${test_srcs})
- if(HAVE_CUDA)
- include_directories(${CUDA_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/core ${CMAKE_SOURCE_DIR}/modules/gpu/src/nvidia/NPP_staging)
-
- file(GLOB nvidia "test/nvidia/*.cpp" "test/nvidia/*.h*")
- source_group("Src\\NVidia" FILES ${nvidia})
- endif()
-
-
- add_executable(${the_test_target} ${test_srcs} ${test_hdrs} ${nvidia})
-
- if(PCHSupport_FOUND)
- set(pch_header ${CMAKE_CURRENT_SOURCE_DIR}/test/test_precomp.hpp)
- if(${CMAKE_GENERATOR} MATCHES "Visual*" OR ${CMAKE_GENERATOR} MATCHES "Xcode*")
- if(${CMAKE_GENERATOR} MATCHES "Visual*")
- set(${the_test_target}_pch "test/test_precomp.cpp")
- endif()
- add_native_precompiled_header(${the_test_target} ${pch_header})
- elseif(CMAKE_COMPILER_IS_GNUCXX AND ${CMAKE_GENERATOR} MATCHES ".*Makefiles")
- add_precompiled_header(${the_test_target} ${pch_header})
- endif()
- endif()
-
- # Additional target properties
- set_target_properties(${the_test_target} PROPERTIES
- DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin/"
- )
-
- if(ENABLE_SOLUTION_FOLDERS)
- set_target_properties(${the_test_target} PROPERTIES FOLDER "tests")
- endif()
-
- add_dependencies(${the_test_target} ${test_deps})
-
- # Add the required libraries for linking:
- target_link_libraries(${the_test_target} ${OPENCV_LINKER_LIBS} ${test_deps})
-
- enable_testing()
- get_target_property(LOC ${the_test_target} LOCATION)
- add_test(${the_test_target} "${LOC}")
-
- if(WIN32)
- install(TARGETS ${the_test_target} RUNTIME DESTINATION bin COMPONENT main)
- endif()
-endif()
+++ /dev/null
-###############################################################################\r
-#\r
-# FindNPP.cmake\r
-#\r
-# CUDA_NPP_LIBRARY_ROOT_DIR -- Path to the NPP dorectory.\r
-# CUDA_NPP_INCLUDES -- NPP Include directories.\r
-# CUDA_NPP_LIBRARIES -- NPP libraries.\r
-# NPP_VERSION -- NPP version in format "major.minor.build".\r
-#\r
-# If not found automatically, please set CUDA_NPP_LIBRARY_ROOT_DIR \r
-# in CMake or set enviroment varivabe $CUDA_NPP_ROOT\r
-#\r
-# Author: Anatoly Baksheev, Itseez Ltd.\r
-# \r
-# The MIT License\r
-#\r
-# License for the specific language governing rights and limitations under\r
-# Permission is hereby granted, free of charge, to any person obtaining a\r
-# copy of this software and associated documentation files (the "Software"),\r
-# to deal in the Software without restriction, including without limitation\r
-# the rights to use, copy, modify, merge, publish, distribute, sublicense,\r
-# and/or sell copies of the Software, and to permit persons to whom the\r
-# Software is furnished to do so, subject to the following conditions:\r
-#\r
-# The above copyright notice and this permission notice shall be included\r
-# in all copies or substantial portions of the Software.\r
-#\r
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS\r
-# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r
-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL\r
-# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r
-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r
-# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER\r
-# DEALINGS IN THE SOFTWARE.\r
-#\r
-###############################################################################\r
-\r
-cmake_policy(PUSH)\r
-cmake_minimum_required(VERSION 2.8.0)\r
-cmake_policy(POP)\r
-\r
-if(NOT "${CUDA_NPP_LIBRARY_ROOT_DIR}" STREQUAL "${CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL}")\r
- unset(CUDA_NPP_INCLUDES CACHE)\r
- unset(CUDA_NPP_LIBRARIES CACHE) \r
-endif()\r
-\r
-if(CMAKE_SIZEOF_VOID_P EQUAL 4) \r
- if (UNIX OR APPLE)\r
- set(NPP_SUFFIX "32") \r
- else()\r
- set(NPP_SUFFIX "-mt")\r
- endif()\r
-else(CMAKE_SIZEOF_VOID_P EQUAL 4)\r
- if (UNIX OR APPLE)\r
- set(NPP_SUFFIX "64") \r
- else()\r
- set(NPP_SUFFIX "-mt-x64") \r
- endif()\r
-endif(CMAKE_SIZEOF_VOID_P EQUAL 4)\r
-\r
-if(NOT CUDA_NPP_LIBRARY_ROOT_DIR OR CUDA_NPP_LIBRARY_ROOT_DIR STREQUAL "")\r
- unset(CUDA_NPP_LIBRARY_ROOT_DIR CACHE) \r
- find_path(CUDA_NPP_LIBRARY_ROOT_DIR "common/npp/include/npp.h" PATHS ENV CUDA_NPP_ROOT DOC "NPP root directory.") \r
- MESSAGE(STATUS "NPP root directory: " ${CUDA_NPP_LIBRARY_ROOT_DIR})\r
-endif()\r
-\r
-# Search includes in our own paths.\r
-find_path(CUDA_NPP_INCLUDES npp.h PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}/common/npp/include")\r
-# Search default search paths, after we search our own set of paths.\r
-find_path(CUDA_NPP_INCLUDES device_functions.h)\r
-mark_as_advanced(CUDA_NPP_INCLUDES)\r
-\r
-# Find NPP library\r
-find_library(CUDA_NPP_LIBRARIES\r
- NAMES "npp" "npp${NPP_SUFFIX}" "libnpp${NPP_SUFFIX}"\r
- PATHS "${CUDA_NPP_LIBRARY_ROOT_DIR}" \r
- PATH_SUFFIXES "common/lib" "common/npp/lib"\r
- DOC "NPP library" \r
- ) \r
-\r
-# Search default search paths, after we search our own set of paths.\r
-find_library(CUDA_NPP_LIBRARIES NAMES npp${NPP_SUFFIX} libnpp${NPP_SUFFIX} DOC "NPP library")\r
-mark_as_advanced(CUDA_NPP_LIBRARIES)\r
-\r
-if(EXISTS ${CUDA_NPP_INCLUDES}/nppversion.h)\r
- file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_major REGEX "#define NPP_VERSION_MAJOR.*")\r
- file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_minor REGEX "#define NPP_VERSION_MINOR.*")\r
- file( STRINGS ${CUDA_NPP_INCLUDES}/nppversion.h npp_build REGEX "#define NPP_VERSION_BUILD.*")\r
-\r
- string( REGEX REPLACE "#define NPP_VERSION_MAJOR[ \t]+|//.*" "" npp_major ${npp_major})\r
- string( REGEX REPLACE "#define NPP_VERSION_MINOR[ \t]+|//.*" "" npp_minor ${npp_minor})\r
- string( REGEX REPLACE "#define NPP_VERSION_BUILD[ \t]+|//.*" "" npp_build ${npp_build})\r
-\r
- string( REGEX MATCH "[0-9]+" npp_major ${npp_major} ) \r
- string( REGEX MATCH "[0-9]+" npp_minor ${npp_minor} ) \r
- string( REGEX MATCH "[0-9]+" npp_build ${npp_build} ) \r
- set( NPP_VERSION "${npp_major}.${npp_minor}.${npp_build}") \r
-endif()\r
-\r
-if(NOT EXISTS ${CUDA_NPP_LIBRARIES} OR NOT EXISTS ${CUDA_NPP_INCLUDES}/npp.h)\r
- set(CUDA_NPP_FOUND FALSE) \r
- message(FATAL_ERROR "NPP headers/libraries are not found. Please specify CUDA_NPP_LIBRARY_ROOT_DIR in CMake or set $CUDA_NPP_ROOT.") \r
-endif()\r
-\r
-include( FindPackageHandleStandardArgs ) \r
-find_package_handle_standard_args( NPP \r
- REQUIRED_VARS \r
- CUDA_NPP_INCLUDES \r
- CUDA_NPP_LIBRARIES \r
- #Need cmake 2.8.3 to uncomment this. \r
- #VERSION_VAR \r
- NPP_VERSION)\r
-\r
-if(APPLE)\r
- # We need to add the path to cudart to the linker using rpath, since the library name for the cuda libraries is prepended with @rpath.\r
- get_filename_component(_cuda_path_to_npp "${CUDA_NPP_LIBRARIES}" PATH)\r
- if(_cuda_path_to_npp)\r
- list(APPEND CUDA_NPP_LIBRARIES "-Wl,-rpath,${_cuda_path_to_npp}")\r
- endif()\r
-endif()\r
-\r
-set(CUDA_NPP_FOUND TRUE)\r
-set(CUDA_NPP_LIBRARY_ROOT_DIR_INTERNAL "${CUDA_NPP_LIBRARY_ROOT_DIR}" CACHE INTERNAL "This is the value of the last time CUDA_NPP_LIBRARY_ROOT_DIR was set successfully." FORCE)\r
-\r
-\r
\r
// converts matrix type, ex from float to uchar depending on type\r
void enqueueConvert(const GpuMat& src, GpuMat& dst, int type, double a = 1, double b = 0);\r
+\r
+ static Stream& Null();\r
+\r
+ operator bool() const;\r
+\r
private:\r
void create();\r
void release();\r
+\r
struct Impl;\r
Impl *impl;\r
+\r
friend struct StreamAccessor;\r
+ \r
+ explicit Stream(Impl* impl);\r
};\r
\r
\r
\r
//! transposes the matrix\r
//! supports matrix with element size = 1, 4 and 8 bytes (CV_8UC1, CV_8UC4, CV_16UC2, CV_32FC1, etc)\r
- CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst);\r
+ CV_EXPORTS void transpose(const GpuMat& src1, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
//! reverses the order of the rows, columns or both in a matrix\r
//! supports CV_8UC1, CV_8UC4 types\r
- CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode);\r
+ CV_EXPORTS void flip(const GpuMat& a, GpuMat& b, int flipCode, Stream& stream = Stream::Null());\r
\r
//! transforms 8-bit unsigned integers using lookup table: dst(i)=lut(src(i))\r
//! destination array will have the depth type as lut and the same channels number as source\r
//! supports CV_8UC1, CV_8UC3 types\r
- CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst);\r
+ CV_EXPORTS void LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
//! makes multi-channel array out of several single-channel arrays\r
- CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst);\r
+ CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
//! makes multi-channel array out of several single-channel arrays\r
- CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst);\r
-\r
- //! makes multi-channel array out of several single-channel arrays (async version)\r
- CV_EXPORTS void merge(const GpuMat* src, size_t n, GpuMat& dst, const Stream& stream);\r
-\r
- //! makes multi-channel array out of several single-channel arrays (async version)\r
- CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, const Stream& stream);\r
+ CV_EXPORTS void merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
//! copies each plane of a multi-channel array to a dedicated array\r
- CV_EXPORTS void split(const GpuMat& src, GpuMat* dst);\r
+ CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, Stream& stream = Stream::Null());\r
\r
//! copies each plane of a multi-channel array to a dedicated array\r
- CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst);\r
-\r
- //! copies each plane of a multi-channel array to a dedicated array (async version)\r
- CV_EXPORTS void split(const GpuMat& src, GpuMat* dst, const Stream& stream);\r
-\r
- //! copies each plane of a multi-channel array to a dedicated array (async version)\r
- CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, const Stream& stream);\r
+ CV_EXPORTS void split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream = Stream::Null());\r
\r
//! computes magnitude of complex (x(i).re, x(i).im) vector\r
//! supports only CV_32FC2 type\r
- CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude);\r
+ CV_EXPORTS void magnitude(const GpuMat& x, GpuMat& magnitude, Stream& stream = Stream::Null());\r
\r
//! computes squared magnitude of complex (x(i).re, x(i).im) vector\r
//! supports only CV_32FC2 type\r
- CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude);\r
+ CV_EXPORTS void magnitudeSqr(const GpuMat& x, GpuMat& magnitude, Stream& stream = Stream::Null());\r
\r
//! computes magnitude of each (x(i), y(i)) vector\r
//! supports only floating-point source\r
- CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);\r
- //! async version\r
- CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);\r
+ CV_EXPORTS void magnitude(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());\r
\r
//! computes squared magnitude of each (x(i), y(i)) vector\r
//! supports only floating-point source\r
- CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude);\r
- //! async version\r
- CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, const Stream& stream);\r
+ CV_EXPORTS void magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, Stream& stream = Stream::Null());\r
\r
//! computes angle (angle(i)) of each (x(i), y(i)) vector\r
//! supports only floating-point source\r
- CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false);\r
- //! async version\r
- CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, const Stream& stream);\r
+ CV_EXPORTS void phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());\r
\r
//! converts Cartesian coordinates to polar\r
//! supports only floating-point source\r
- CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false);\r
- //! async version\r
- CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees, const Stream& stream);\r
+ CV_EXPORTS void cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& magnitude, GpuMat& angle, bool angleInDegrees = false, Stream& stream = Stream::Null());\r
\r
//! converts polar coordinates to Cartesian\r
//! supports only floating-point source\r
- CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false);\r
- //! async version\r
- CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, const Stream& stream);\r
+ CV_EXPORTS void polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees = false, Stream& stream = Stream::Null());\r
\r
\r
//////////////////////////// Per-element operations ////////////////////////////////////\r
\r
//! adds one matrix to another (c = a + b)\r
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types\r
- CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c);\r
+ CV_EXPORTS void add(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());\r
//! adds scalar to a matrix (c = a + s)\r
//! supports CV_32FC1 and CV_32FC2 type\r
- CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c);\r
+ CV_EXPORTS void add(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());\r
\r
//! subtracts one matrix from another (c = a - b)\r
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types\r
- CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c);\r
+ CV_EXPORTS void subtract(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());\r
//! subtracts scalar from a matrix (c = a - s)\r
//! supports CV_32FC1 and CV_32FC2 type\r
- CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c);\r
+ CV_EXPORTS void subtract(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());\r
\r
//! computes element-wise product of the two arrays (c = a * b)\r
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types\r
- CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c);\r
+ CV_EXPORTS void multiply(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());\r
//! multiplies matrix to a scalar (c = a * s)\r
//! supports CV_32FC1 and CV_32FC2 type\r
- CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c);\r
+ CV_EXPORTS void multiply(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());\r
\r
//! computes element-wise quotient of the two arrays (c = a / b)\r
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types\r
- CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c);\r
+ CV_EXPORTS void divide(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());\r
//! computes element-wise quotient of matrix and scalar (c = a / s)\r
//! supports CV_32FC1 and CV_32FC2 type\r
- CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c);\r
+ CV_EXPORTS void divide(const GpuMat& a, const Scalar& sc, GpuMat& c, Stream& stream = Stream::Null());\r
\r
//! computes exponent of each matrix element (b = e**a)\r
//! supports only CV_32FC1 type\r
- CV_EXPORTS void exp(const GpuMat& a, GpuMat& b);\r
+ CV_EXPORTS void exp(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());\r
\r
//! computes natural logarithm of absolute value of each matrix element: b = log(abs(a))\r
//! supports only CV_32FC1 type\r
- CV_EXPORTS void log(const GpuMat& a, GpuMat& b);\r
+ CV_EXPORTS void log(const GpuMat& a, GpuMat& b, Stream& stream = Stream::Null());\r
\r
//! computes element-wise absolute difference of two arrays (c = abs(a - b))\r
//! supports CV_8UC1, CV_8UC4, CV_32SC1, CV_32FC1 types\r
- CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c);\r
+ CV_EXPORTS void absdiff(const GpuMat& a, const GpuMat& b, GpuMat& c, Stream& stream = Stream::Null());\r
//! computes element-wise absolute difference of array and scalar (c = abs(a - s))\r
//! supports only CV_32FC1 type\r
- CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c);\r
+ CV_EXPORTS void absdiff(const GpuMat& a, const Scalar& s, GpuMat& c, Stream& stream = Stream::Null());\r
\r
//! compares elements of two arrays (c = a <cmpop> b)\r
//! supports CV_8UC4, CV_32FC1 types\r
- CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop);\r
+ CV_EXPORTS void compare(const GpuMat& a, const GpuMat& b, GpuMat& c, int cmpop, Stream& stream = Stream::Null());\r
\r
//! performs per-elements bit-wise inversion\r
- CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat());\r
- //! async version\r
- CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, const Stream& stream);\r
+ CV_EXPORTS void bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());\r
\r
//! calculates per-element bit-wise disjunction of two arrays\r
- CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());\r
- //! async version\r
- CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);\r
+ CV_EXPORTS void bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());\r
\r
//! calculates per-element bit-wise conjunction of two arrays\r
- CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());\r
- //! async version\r
- CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);\r
+ CV_EXPORTS void bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());\r
\r
//! calculates per-element bit-wise "exclusive or" operation\r
- CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat());\r
- //! async version\r
- CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream);\r
+ CV_EXPORTS void bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask=GpuMat(), Stream& stream = Stream::Null());\r
\r
//! computes per-element minimum of two arrays (dst = min(src1, src2))\r
- CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);\r
- //! Async version\r
- CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);\r
+ CV_EXPORTS void min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
//! computes per-element minimum of array and scalar (dst = min(src1, src2))\r
- CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst);\r
- //! Async version\r
- CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);\r
+ CV_EXPORTS void min(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
//! computes per-element maximum of two arrays (dst = max(src1, src2))\r
- CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst);\r
- //! Async version\r
- CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream);\r
+ CV_EXPORTS void max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
//! computes per-element maximum of array and scalar (dst = max(src1, src2))\r
- CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst);\r
- //! Async version\r
- CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream);\r
+ CV_EXPORTS void max(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
\r
////////////////////////////// Image processing //////////////////////////////\r
//! Does coloring of disparity image: [0..ndisp) -> [0..240, 1, 1] in HSV.\r
//! Supported types of input disparity: CV_8U, CV_16S.\r
//! Output disparity has CV_8UC4 type in BGRA format (alpha = 255).\r
- CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp);\r
- //! async version\r
- CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, const Stream& stream);\r
+ CV_EXPORTS void drawColorDisp(const GpuMat& src_disp, GpuMat& dst_disp, int ndisp, Stream& stream = Stream::Null());\r
\r
//! Reprojects disparity image to 3D space.\r
//! Supports CV_8U and CV_16S types of input disparity.\r
//! The output is a 4-channel floating-point (CV_32FC4) matrix.\r
//! Each element of this matrix will contain the 3D coordinates of the point (x,y,z,1), computed from the disparity map.\r
//! Q is the 4x4 perspective transformation matrix that can be obtained with cvStereoRectify.\r
- CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q);\r
- //! async version\r
- CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream);\r
+ CV_EXPORTS void reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, Stream& stream = Stream::Null());\r
\r
//! converts image from one color space to another\r
- CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0);\r
- //! async version\r
- CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream);\r
+ CV_EXPORTS void cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn = 0, Stream& stream = Stream::Null());\r
\r
//! applies fixed threshold to the image\r
- CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type);\r
- //! async version\r
- CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type, const Stream& stream);\r
+ CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());\r
\r
//! resizes the image\r
//! Supports INTER_NEAREST, INTER_LINEAR\r
//! supports CV_8UC1, CV_8UC4 types\r
- CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR);\r
+ CV_EXPORTS void resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx=0, double fy=0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());\r
\r
//! warps the image using affine transformation\r
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC\r
- CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);\r
+ CV_EXPORTS void warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());\r
\r
//! warps the image using perspective transformation\r
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC\r
- CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR);\r
+ CV_EXPORTS void warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags = INTER_LINEAR, Stream& stream = Stream::Null());\r
\r
//! rotate 8bit single or four channel image\r
//! Supports INTER_NEAREST, INTER_LINEAR, INTER_CUBIC\r
//! supports CV_8UC1, CV_8UC4 types\r
- CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR);\r
+ CV_EXPORTS void rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift = 0, double yShift = 0, int interpolation = INTER_LINEAR, Stream& stream = Stream::Null());\r
\r
//! copies 2D array to a larger destination array and pads borders with user-specifiable constant\r
//! supports CV_8UC1, CV_8UC4, CV_32SC1 and CV_32FC1 types\r
- CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar());\r
+ CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value = Scalar(), Stream& stream = Stream::Null());\r
\r
//! computes the integral image\r
//! sum will have CV_32S type, but will contain unsigned int values\r
//! supports only CV_8UC1 source type\r
- CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum);\r
+ CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, Stream& stream = Stream::Null());\r
\r
//! buffered version\r
- CV_EXPORTS void integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer);\r
+ CV_EXPORTS void integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, Stream& stream = Stream::Null());\r
\r
//! computes the integral image and integral for the squared image\r
//! sum will have CV_32S type, sqsum - CV32F type\r
//! supports only CV_8UC1 source type\r
- CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum);\r
+ CV_EXPORTS void integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum, Stream& stream = Stream::Null());\r
\r
//! computes squared integral image\r
//! result matrix will have 64F type, but will contain 64U values\r
//! supports source images of 8UC1 type only\r
- CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum);\r
+ CV_EXPORTS void sqrIntegral(const GpuMat& src, GpuMat& sqsum, Stream& stream = Stream::Null());\r
\r
//! computes vertical sum, supports only CV_32FC1 images\r
CV_EXPORTS void columnSum(const GpuMat& src, GpuMat& sum);\r
//! computes the standard deviation of integral images\r
//! supports only CV_32SC1 source type and CV_32FC1 sqr type\r
//! output will have CV_32FC1 type\r
- CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect);\r
-\r
- // applies Canny edge detector and produces the edge map\r
- // disabled until fix crash\r
- //CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, double threshold1, double threshold2, int apertureSize = 3);\r
- //CV_EXPORTS void Canny(const GpuMat& image, GpuMat& edges, GpuMat& buffer, double threshold1, double threshold2, int apertureSize = 3);\r
- //CV_EXPORTS void Canny(const GpuMat& srcDx, const GpuMat& srcDy, GpuMat& edges, double threshold1, double threshold2, int apertureSize = 3);\r
- //CV_EXPORTS void Canny(const GpuMat& srcDx, const GpuMat& srcDy, GpuMat& edges, GpuMat& buffer, double threshold1, double threshold2, int apertureSize = 3);\r
+ CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect, Stream& stream = Stream::Null());\r
\r
//! computes Harris cornerness criteria at each image pixel\r
CV_EXPORTS void cornerHarris(const GpuMat& src, GpuMat& dst, int blockSize, int ksize, double k, int borderType=BORDER_REFLECT101);\r
//! performs linear blending of two images\r
//! to avoid accuracy errors sum of weigths shouldn't be very close to zero\r
CV_EXPORTS void blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2, \r
- GpuMat& result);\r
+ GpuMat& result, Stream& stream = Stream::Null());\r
\r
////////////////////////////// Matrix reductions //////////////////////////////\r
\r
///////////////////////////// Calibration 3D //////////////////////////////////\r
\r
CV_EXPORTS void transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,\r
- GpuMat& dst);\r
-\r
- CV_EXPORTS void transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,\r
- GpuMat& dst, const Stream& stream);\r
+ GpuMat& dst, Stream& stream = Stream::Null());\r
\r
CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,\r
- const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst);\r
-\r
- CV_EXPORTS void projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,\r
- const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst,\r
- const Stream& stream);\r
+ const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, \r
+ Stream& stream = Stream::Null());\r
\r
CV_EXPORTS void solvePnPRansac(const Mat& object, const Mat& image, const Mat& camera_mat,\r
const Mat& dist_coef, Mat& rvec, Mat& tvec, bool use_extrinsic_guess=false,\r
public:\r
BaseRowFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}\r
virtual ~BaseRowFilter_GPU() {}\r
- virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;\r
int ksize, anchor;\r
};\r
\r
public:\r
BaseColumnFilter_GPU(int ksize_, int anchor_) : ksize(ksize_), anchor(anchor_) {}\r
virtual ~BaseColumnFilter_GPU() {}\r
- virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;\r
int ksize, anchor;\r
};\r
\r
public:\r
BaseFilter_GPU(const Size& ksize_, const Point& anchor_) : ksize(ksize_), anchor(anchor_) {}\r
virtual ~BaseFilter_GPU() {}\r
- virtual void operator()(const GpuMat& src, GpuMat& dst) = 0;\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& stream = Stream::Null()) = 0;\r
Size ksize;\r
Point anchor;\r
};\r
public:\r
virtual ~FilterEngine_GPU() {}\r
\r
- virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1)) = 0;\r
+ virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1), Stream& stream = Stream::Null()) = 0;\r
};\r
\r
//! returns the non-separable filter engine with the specified filter\r
\r
//! smooths the image using the normalized box filter\r
//! supports CV_8UC1, CV_8UC4 types\r
- CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1));\r
+ CV_EXPORTS void boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null());\r
\r
//! a synonym for normalized box filter\r
- static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1)) { boxFilter(src, dst, -1, ksize, anchor); }\r
+ static inline void blur(const GpuMat& src, GpuMat& dst, Size ksize, Point anchor = Point(-1,-1), Stream& stream = Stream::Null()) { boxFilter(src, dst, -1, ksize, anchor, stream); }\r
\r
//! erodes the image (applies the local minimum operator)\r
- CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);\r
+ CV_EXPORTS void erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());\r
\r
//! dilates the image (applies the local maximum operator)\r
- CV_EXPORTS void dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);\r
+ CV_EXPORTS void dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());\r
\r
//! applies an advanced morphological operation to the image\r
- CV_EXPORTS void morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1);\r
+ CV_EXPORTS void morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor = Point(-1, -1), int iterations = 1, Stream& stream = Stream::Null());\r
\r
//! applies non-separable 2D linear filter to the image\r
- CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1));\r
+ CV_EXPORTS void filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor=Point(-1,-1), Stream& stream = Stream::Null());\r
\r
//! applies separable 2D linear filter to the image\r
CV_EXPORTS void sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY,\r
- Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);\r
+ Point anchor = Point(-1,-1), int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());\r
\r
//! applies generalized Sobel operator to the image\r
CV_EXPORTS void Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize = 3, double scale = 1,\r
- int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);\r
+ int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());\r
\r
//! applies the vertical or horizontal Scharr operator to the image\r
CV_EXPORTS void Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale = 1,\r
- int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);\r
+ int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());\r
\r
//! smooths the image using Gaussian filter.\r
CV_EXPORTS void GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2 = 0,\r
- int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1);\r
+ int rowBorderType = BORDER_DEFAULT, int columnBorderType = -1, Stream& stream = Stream::Null());\r
\r
//! applies Laplacian operator to the image\r
//! supports only ksize = 1 and ksize = 3\r
- CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1);\r
+ CV_EXPORTS void Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize = 1, double scale = 1, Stream& stream = Stream::Null());\r
\r
//////////////////////////////// Image Labeling ////////////////////////////////\r
\r
//!performs labeling via graph cuts\r
- CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf);\r
+ CV_EXPORTS void graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf, Stream& stream = Stream::Null());\r
\r
////////////////////////////////// Histograms //////////////////////////////////\r
\r
//! Calculates histogram with evenly distributed bins for signle channel source.\r
//! Supports CV_8UC1, CV_16UC1 and CV_16SC1 source types.\r
//! Output hist will have one row and histSize cols and CV_32SC1 type.\r
- CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel);\r
+ CV_EXPORTS void histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, Stream& stream = Stream::Null());\r
//! Calculates histogram with evenly distributed bins for four-channel source.\r
//! All channels of source are processed separately.\r
//! Supports CV_8UC4, CV_16UC4 and CV_16SC4 source types.\r
//! Output hist[i] will have one row and histSize[i] cols and CV_32SC1 type.\r
- CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4]);\r
+ CV_EXPORTS void histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream = Stream::Null());\r
//! Calculates histogram with bins determined by levels array.\r
//! levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.\r
//! Supports CV_8UC1, CV_16UC1, CV_16SC1 and CV_32FC1 source types.\r
//! Output hist will have one row and (levels.cols-1) cols and CV_32SC1 type.\r
- CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels);\r
+ CV_EXPORTS void histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, Stream& stream = Stream::Null());\r
//! Calculates histogram with bins determined by levels array.\r
//! All levels must have one row and CV_32SC1 type if source has integer type or CV_32FC1 otherwise.\r
//! All channels of source are processed separately.\r
//! Supports CV_8UC4, CV_16UC4, CV_16SC4 and CV_32FC4 source types.\r
//! Output hist[i] will have one row and (levels[i].cols-1) cols and CV_32SC1 type.\r
- CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]);\r
+ CV_EXPORTS void histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], Stream& stream = Stream::Null());\r
\r
//////////////////////////////// StereoBM_GPU ////////////////////////////////\r
\r
\r
//! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair\r
//! Output disparity has CV_8U type.\r
- void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity);\r
-\r
- //! async version\r
- void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, const Stream & stream);\r
+ void operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());\r
\r
//! Some heuristics that tries to estmate\r
// if current GPU will be faster than CPU in this algorithm.\r
\r
//! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,\r
//! if disparity is empty output type will be CV_16S else output type will be disparity.type().\r
- void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);\r
-\r
- //! async version\r
- void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);\r
+ void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());\r
\r
\r
//! version for user specified data term\r
- void operator()(const GpuMat& data, GpuMat& disparity);\r
- void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream);\r
+ void operator()(const GpuMat& data, GpuMat& disparity, Stream& stream = Stream::Null());\r
\r
int ndisp;\r
\r
\r
/////////////////////////// StereoConstantSpaceBP ///////////////////////////\r
// "A Constant-Space Belief Propagation Algorithm for Stereo Matching"\r
- // Qingxiong Yang, Liang Wang�, Narendra Ahuja\r
+ // Qingxiong Yang, Liang Wang, Narendra Ahuja\r
// http://vision.ai.uiuc.edu/~qyang6/\r
\r
class CV_EXPORTS StereoConstantSpaceBP\r
\r
//! the stereo correspondence operator. Finds the disparity for the specified rectified stereo pair,\r
//! if disparity is empty output type will be CV_16S else output type will be disparity.type().\r
- void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity);\r
-\r
- //! async version\r
- void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream);\r
+ void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream = Stream::Null());\r
\r
int ndisp;\r
\r
\r
//! the disparity map refinement operator. Refine disparity map using joint bilateral filtering given a single color image.\r
//! disparity must have CV_8U or CV_16S type, image must have CV_8UC1 or CV_8UC3 type.\r
- void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst);\r
-\r
- //! async version\r
- void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream);\r
+ void operator()(const GpuMat& disparity, const GpuMat& image, GpuMat& dst, Stream& stream = Stream::Null());\r
\r
private:\r
int ndisp;\r
// distance.at<float>(0, queryIdx) will contain distance\r
void matchSingle(const GpuMat& queryDescs, const GpuMat& trainDescs,\r
GpuMat& trainIdx, GpuMat& distance,\r
- const GpuMat& mask = GpuMat());\r
+ const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());\r
\r
// Download trainIdx and distance to CPU vector with DMatch\r
static void matchDownload(const GpuMat& trainIdx, const GpuMat& distance, std::vector<DMatch>& matches);\r
// distance.at<float>(0, queryIdx) will contain distance\r
void matchCollection(const GpuMat& queryDescs, const GpuMat& trainCollection,\r
GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance,\r
- const GpuMat& maskCollection);\r
+ const GpuMat& maskCollection, Stream& stream = Stream::Null());\r
\r
// Download trainIdx, imgIdx and distance to CPU vector with DMatch\r
static void matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx, const GpuMat& distance,\r
// allDist.at<float>(queryIdx, trainIdx) will contain FLT_MAX, if trainIdx is one from k best,\r
// otherwise it will contain distance between queryIdx and trainIdx descriptors\r
void knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,\r
- GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat());\r
+ GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());\r
\r
// Download trainIdx and distance to CPU vector with DMatch\r
// compactResult is used when mask is not empty. If compactResult is false matches\r
// Matches doesn't sorted.\r
void radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,\r
GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance,\r
- const GpuMat& mask = GpuMat());\r
+ const GpuMat& mask = GpuMat(), Stream& stream = Stream::Null());\r
\r
// Download trainIdx, nMatches and distance to CPU vector with DMatch.\r
// matches will be sorted in increasing order of distances.\r
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::transpose(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::flip(const GpuMat&, GpuMat&, int) { throw_nogpu(); }\r
-void cv::gpu::LUT(const GpuMat&, const Mat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::exp(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::log(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::magnitude(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::magnitudeSqr(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::magnitudeSqr(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::magnitudeSqr(const GpuMat&, const GpuMat&, GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::phase(const GpuMat&, const GpuMat&, GpuMat&, bool) { throw_nogpu(); }\r
-void cv::gpu::phase(const GpuMat&, const GpuMat&, GpuMat&, bool, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::cartToPolar(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool) { throw_nogpu(); }\r
-void cv::gpu::cartToPolar(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::polarToCart(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool) { throw_nogpu(); }\r
-void cv::gpu::polarToCart(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, const Stream&) { throw_nogpu(); }\r
+void cv::gpu::transpose(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::flip(const GpuMat&, GpuMat&, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::LUT(const GpuMat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::exp(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::log(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::magnitude(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::magnitudeSqr(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::magnitudeSqr(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::phase(const GpuMat&, const GpuMat&, GpuMat&, bool, Stream&) { throw_nogpu(); }\r
+void cv::gpu::cartToPolar(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, Stream&) { throw_nogpu(); }\r
+void cv::gpu::polarToCart(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, bool, Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
////////////////////////////////////////////////////////////////////////\r
// transpose\r
\r
-void cv::gpu::transpose(const GpuMat& src, GpuMat& dst)\r
+void cv::gpu::transpose(const GpuMat& src, GpuMat& dst, Stream& s)\r
{\r
CV_Assert(src.elemSize() == 1 || src.elemSize() == 4 || src.elemSize() == 8);\r
\r
dst.create( src.cols, src.rows, src.type() );\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
if (src.elemSize() == 1)\r
{\r
+ NppStreamHandler h(stream);\r
+\r
NppiSize sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
}\r
else if (src.elemSize() == 4)\r
{\r
+ NppStStreamHandler h(stream);\r
+\r
NcvSize32u sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
}\r
else // if (src.elemSize() == 8)\r
{\r
+ NppStStreamHandler h(stream);\r
+\r
NcvSize32u sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
dst.ptr<Ncv64u>(), dst.step, sz) ); \r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
// flip\r
\r
-void cv::gpu::flip(const GpuMat& src, GpuMat& dst, int flipCode)\r
+void cv::gpu::flip(const GpuMat& src, GpuMat& dst, int flipCode, Stream& s)\r
{\r
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC4);\r
\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
if (src.type() == CV_8UC1)\r
{\r
nppSafeCall( nppiMirror_8u_C1R(src.ptr<Npp8u>(), src.step,\r
(flipCode == 0 ? NPP_HORIZONTAL_AXIS : (flipCode > 0 ? NPP_VERTICAL_AXIS : NPP_BOTH_AXIS))) );\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
// LUT\r
\r
-void cv::gpu::LUT(const GpuMat& src, const Mat& lut, GpuMat& dst)\r
+void cv::gpu::LUT(const GpuMat& src, const Mat& lut, GpuMat& dst, Stream& s)\r
{\r
class LevelsInit\r
{\r
Mat nppLut;\r
lut.convertTo(nppLut, CV_32S);\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
if (src.type() == CV_8UC1)\r
{\r
nppSafeCall( nppiLUT_Linear_8u_C1R(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, nppLut.ptr<Npp32s>(), lvls.pLevels, 256) );\r
nppSafeCall( nppiLUT_Linear_8u_C3R(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, pValues3, lvls.pLevels3, lvls.nValues3) );\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
// exp\r
\r
-void cv::gpu::exp(const GpuMat& src, GpuMat& dst)\r
+void cv::gpu::exp(const GpuMat& src, GpuMat& dst, Stream& s)\r
{\r
CV_Assert(src.type() == CV_32FC1);\r
\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiExp_32f_C1R(src.ptr<Npp32f>(), src.step, dst.ptr<Npp32f>(), dst.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
// log\r
\r
-void cv::gpu::log(const GpuMat& src, GpuMat& dst)\r
+void cv::gpu::log(const GpuMat& src, GpuMat& dst, Stream& s)\r
{\r
CV_Assert(src.type() == CV_32FC1);\r
\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiLn_32f_C1R(src.ptr<Npp32f>(), src.step, dst.ptr<Npp32f>(), dst.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
{\r
typedef NppStatus (*nppMagnitude_t)(const Npp32fc* pSrc, int nSrcStep, Npp32f* pDst, int nDstStep, NppiSize oSizeROI);\r
\r
- inline void npp_magnitude(const GpuMat& src, GpuMat& dst, nppMagnitude_t func)\r
+ inline void npp_magnitude(const GpuMat& src, GpuMat& dst, nppMagnitude_t func, cudaStream_t stream)\r
{\r
CV_Assert(src.type() == CV_32FC2);\r
\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<Npp32fc>(), src.step, dst.ptr<Npp32f>(), dst.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
}\r
\r
-void cv::gpu::magnitude(const GpuMat& src, GpuMat& dst)\r
+void cv::gpu::magnitude(const GpuMat& src, GpuMat& dst, Stream& stream)\r
{\r
- ::npp_magnitude(src, dst, nppiMagnitude_32fc32f_C1R);\r
+ ::npp_magnitude(src, dst, nppiMagnitude_32fc32f_C1R, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::magnitudeSqr(const GpuMat& src, GpuMat& dst)\r
+void cv::gpu::magnitudeSqr(const GpuMat& src, GpuMat& dst, Stream& stream)\r
{\r
- ::npp_magnitude(src, dst, nppiMagnitudeSqr_32fc32f_C1R);\r
+ ::npp_magnitude(src, dst, nppiMagnitudeSqr_32fc32f_C1R, StreamAccessor::getStream(stream));\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
}\r
}\r
\r
-void cv::gpu::magnitude(const GpuMat& x, const GpuMat& y, GpuMat& dst)\r
-{\r
- ::cartToPolar_caller(x, y, &dst, false, 0, false, 0);\r
-}\r
-\r
-void cv::gpu::magnitude(const GpuMat& x, const GpuMat& y, GpuMat& dst, const Stream& stream)\r
+void cv::gpu::magnitude(const GpuMat& x, const GpuMat& y, GpuMat& dst, Stream& stream)\r
{\r
::cartToPolar_caller(x, y, &dst, false, 0, false, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& dst)\r
-{\r
- ::cartToPolar_caller(x, y, &dst, true, 0, false, 0);\r
-}\r
-\r
-void cv::gpu::magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& dst, const Stream& stream)\r
+void cv::gpu::magnitudeSqr(const GpuMat& x, const GpuMat& y, GpuMat& dst, Stream& stream)\r
{\r
::cartToPolar_caller(x, y, &dst, true, 0, false, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees)\r
-{\r
- ::cartToPolar_caller(x, y, 0, false, &angle, angleInDegrees, 0);\r
-}\r
-\r
-void cv::gpu::phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, const Stream& stream)\r
+void cv::gpu::phase(const GpuMat& x, const GpuMat& y, GpuMat& angle, bool angleInDegrees, Stream& stream)\r
{\r
::cartToPolar_caller(x, y, 0, false, &angle, angleInDegrees, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& mag, GpuMat& angle, bool angleInDegrees)\r
-{\r
- ::cartToPolar_caller(x, y, &mag, false, &angle, angleInDegrees, 0);\r
-}\r
-\r
-void cv::gpu::cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& mag, GpuMat& angle, bool angleInDegrees, const Stream& stream)\r
+void cv::gpu::cartToPolar(const GpuMat& x, const GpuMat& y, GpuMat& mag, GpuMat& angle, bool angleInDegrees, Stream& stream)\r
{\r
::cartToPolar_caller(x, y, &mag, false, &angle, angleInDegrees, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees)\r
-{\r
- ::polarToCart_caller(magnitude, angle, x, y, angleInDegrees, 0);\r
-}\r
-\r
-void cv::gpu::polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, const Stream& stream)\r
+void cv::gpu::polarToCart(const GpuMat& magnitude, const GpuMat& angle, GpuMat& x, GpuMat& y, bool angleInDegrees, Stream& stream)\r
{\r
::polarToCart_caller(magnitude, angle, x, y, angleInDegrees, StreamAccessor::getStream(stream));\r
}\r
cv::gpu::DisparityBilateralFilter::DisparityBilateralFilter(int, int, int) { throw_nogpu(); }\r
cv::gpu::DisparityBilateralFilter::DisparityBilateralFilter(int, int, int, float, float, float) { throw_nogpu(); }\r
\r
-void cv::gpu::DisparityBilateralFilter::operator()(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
void cv::gpu::DisparityBilateralFilter::operator()(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
template <typename T>\r
void bilateral_filter_operator(int ndisp, int radius, int iters, float edge_threshold,float max_disc_threshold, \r
GpuMat& table_color, GpuMat& table_space, \r
- const GpuMat& disp, const GpuMat& img, GpuMat& dst, cudaStream_t stream)\r
+ const GpuMat& disp, const GpuMat& img, GpuMat& dst, Stream& stream)\r
{\r
short edge_disc = max<short>(short(1), short(ndisp * edge_threshold + 0.5));\r
short max_disc = short(ndisp * max_disc_threshold + 0.5);\r
bf::load_constants(table_color.ptr<float>(), table_space, ndisp, radius, edge_disc, max_disc);\r
\r
if (&dst != &disp)\r
- disp.copyTo(dst);\r
+ {\r
+ if (stream)\r
+ stream.enqueueCopy(disp, dst);\r
+ else\r
+ disp.copyTo(dst);\r
+ }\r
\r
- bf::bilateral_filter_gpu((DevMem2D_<T>)dst, img, img.channels(), iters, stream);\r
+ bf::bilateral_filter_gpu((DevMem2D_<T>)dst, img, img.channels(), iters, StreamAccessor::getStream(stream));\r
}\r
\r
typedef void (*bilateral_filter_operator_t)(int ndisp, int radius, int iters, float edge_threshold, float max_disc_threshold, \r
GpuMat& table_color, GpuMat& table_space, \r
- const GpuMat& disp, const GpuMat& img, GpuMat& dst, cudaStream_t stream);\r
+ const GpuMat& disp, const GpuMat& img, GpuMat& dst, Stream& stream);\r
\r
const bilateral_filter_operator_t operators[] = \r
{bilateral_filter_operator<unsigned char>, 0, 0, bilateral_filter_operator<short>, 0, 0, 0, 0};\r
calc_space_weighted_filter(table_space, radius * 2 + 1, radius + 1.0f);\r
}\r
\r
-void cv::gpu::DisparityBilateralFilter::operator()(const GpuMat& disp, const GpuMat& img, GpuMat& dst)\r
-{\r
- CV_DbgAssert(0 < ndisp && 0 < radius && 0 < iters);\r
- CV_Assert(disp.rows == img.rows && disp.cols == img.cols && (disp.type() == CV_8U || disp.type() == CV_16S) && (img.type() == CV_8UC1 || img.type() == CV_8UC3));\r
- operators[disp.type()](ndisp, radius, iters, edge_threshold, max_disc_threshold, table_color, table_space, disp, img, dst, 0);\r
-}\r
-\r
void cv::gpu::DisparityBilateralFilter::operator()(const GpuMat& disp, const GpuMat& img, GpuMat& dst, Stream& stream)\r
{\r
CV_DbgAssert(0 < ndisp && 0 < radius && 0 < iters);\r
CV_Assert(disp.rows == img.rows && disp.cols == img.cols && (disp.type() == CV_8U || disp.type() == CV_16S) && (img.type() == CV_8UC1 || img.type() == CV_8UC3));\r
- operators[disp.type()](ndisp, radius, iters, edge_threshold, max_disc_threshold, table_color, table_space, disp, img, dst, StreamAccessor::getStream(stream));\r
+ operators[disp.type()](ndisp, radius, iters, edge_threshold, max_disc_threshold, table_color, table_space, disp, img, dst, stream);\r
}\r
\r
#endif /* !defined (HAVE_CUDA) */\r
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::blendLinear(const GpuMat&, const GpuMat&, const GpuMat&, const GpuMat&, \r
- GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::blendLinear(const GpuMat&, const GpuMat&, const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
\r
#else\r
\r
{\r
template <typename T>\r
void blendLinearCaller(int rows, int cols, int cn, const PtrStep_<T> img1, const PtrStep_<T> img2, \r
- const PtrStep_<float> weights1, const PtrStep_<float> weights2, PtrStep_<T> result);\r
+ const PtrStep_<float> weights1, const PtrStep_<float> weights2, PtrStep_<T> result, cudaStream_t stream);\r
\r
void blendLinearCaller8UC4(int rows, int cols, const PtrStep img1, const PtrStep img2, \r
- const PtrStepf weights1, const PtrStepf weights2, PtrStep result);\r
+ const PtrStepf weights1, const PtrStepf weights2, PtrStep result, cudaStream_t stream);\r
}}\r
\r
void cv::gpu::blendLinear(const GpuMat& img1, const GpuMat& img2, const GpuMat& weights1, const GpuMat& weights2, \r
- GpuMat& result)\r
+ GpuMat& result, Stream& stream)\r
{\r
CV_Assert(img1.size() == img2.size());\r
CV_Assert(img1.type() == img2.type());\r
{\r
case CV_8U:\r
if (cn != 4)\r
- blendLinearCaller<uchar>(size.height, size.width, cn, img1, img2, weights1, weights2, result);\r
+ blendLinearCaller<uchar>(size.height, size.width, cn, img1, img2, weights1, weights2, result, StreamAccessor::getStream(stream));\r
else\r
- blendLinearCaller8UC4(size.height, size.width, img1, img2, weights1, weights2, result);\r
+ blendLinearCaller8UC4(size.height, size.width, img1, img2, weights1, weights2, result, StreamAccessor::getStream(stream));\r
break;\r
case CV_32F:\r
- blendLinearCaller<float>(size.height, size.width, cn, img1, img2, weights1, weights2, result);\r
+ blendLinearCaller<float>(size.height, size.width, cn, img1, img2, weights1, weights2, result, StreamAccessor::getStream(stream));\r
break;\r
default:\r
CV_Error(CV_StsUnsupportedFormat, "bad image depth in linear blending function");\r
void cv::gpu::BruteForceMatcher_GPU_base::clear() { throw_nogpu(); }\r
bool cv::gpu::BruteForceMatcher_GPU_base::empty() const { throw_nogpu(); return true; }\r
bool cv::gpu::BruteForceMatcher_GPU_base::isMaskSupported() const { throw_nogpu(); return true; }\r
-void cv::gpu::BruteForceMatcher_GPU_base::matchSingle(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::BruteForceMatcher_GPU_base::matchSingle(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::matchDownload(const GpuMat&, const GpuMat&, vector<DMatch>&) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::match(const GpuMat&, const GpuMat&, vector<DMatch>&, const GpuMat&) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::makeGpuCollection(GpuMat&, GpuMat&, const vector<GpuMat>&) { throw_nogpu(); }\r
-void cv::gpu::BruteForceMatcher_GPU_base::matchCollection(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::BruteForceMatcher_GPU_base::matchCollection(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::matchDownload(const GpuMat&, const GpuMat&, const GpuMat&, std::vector<DMatch>&) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::match(const GpuMat&, std::vector<DMatch>&, const std::vector<GpuMat>&) { throw_nogpu(); }\r
-void cv::gpu::BruteForceMatcher_GPU_base::knnMatch(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, int, const GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::BruteForceMatcher_GPU_base::knnMatch(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, int, const GpuMat&, Stream&) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::knnMatchDownload(const GpuMat&, const GpuMat&, std::vector< std::vector<DMatch> >&, bool) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::knnMatch(const GpuMat&, const GpuMat&, std::vector< std::vector<DMatch> >&, int, const GpuMat&, bool) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::knnMatch(const GpuMat&, std::vector< std::vector<DMatch> >&, int, const std::vector<GpuMat>&, bool) { throw_nogpu(); }\r
-void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, float, const GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, float, const GpuMat&, Stream&) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::radiusMatchDownload(const GpuMat&, const GpuMat&, const GpuMat&, std::vector< std::vector<DMatch> >&, bool) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat&, const GpuMat&, std::vector< std::vector<DMatch> >&, float, const GpuMat&, bool) { throw_nogpu(); }\r
void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat&, std::vector< std::vector<DMatch> >&, float, const std::vector<GpuMat>&, bool) { throw_nogpu(); }\r
template <typename T>\r
void matchSingleL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs,\r
const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12);\r
+ bool cc_12, cudaStream_t stream);\r
template <typename T>\r
void matchSingleL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs,\r
const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12);\r
+ bool cc_12, cudaStream_t stream);\r
template <typename T>\r
void matchSingleHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, \r
const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12);\r
+ bool cc_12, cudaStream_t stream);\r
template <typename T>\r
void matchCollectionL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainCollection,\r
const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12);\r
+ bool cc_12, cudaStream_t stream);\r
template <typename T>\r
void matchCollectionL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainCollection,\r
const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12);\r
+ bool cc_12, cudaStream_t stream);\r
template <typename T>\r
void matchCollectionHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainCollection, \r
const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance,\r
- bool cc_12);\r
+ bool cc_12, cudaStream_t stream);\r
\r
template <typename T>\r
void knnMatchL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
template <typename T>\r
void knnMatchL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
template <typename T>\r
void knnMatchHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
\r
template <typename T>\r
void radiusMatchL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
template <typename T>\r
void radiusMatchL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
template <typename T>\r
void radiusMatchHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
}}}\r
\r
namespace\r
// Match\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::matchSingle(const GpuMat& queryDescs, const GpuMat& trainDescs,\r
- GpuMat& trainIdx, GpuMat& distance, const GpuMat& mask)\r
+ GpuMat& trainIdx, GpuMat& distance, const GpuMat& mask, Stream& stream)\r
{\r
if (queryDescs.empty() || trainDescs.empty())\r
return;\r
\r
typedef void (*match_caller_t)(const DevMem2D& queryDescs, const DevMem2D& trainDescs,\r
const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12);\r
+ bool cc_12, cudaStream_t stream);\r
\r
static const match_caller_t match_callers[3][8] =\r
{\r
\r
// For single train there is no need to save imgIdx, so we just save imgIdx to trainIdx.\r
// trainIdx store after imgIdx, so we doesn't lose it value.\r
- func(queryDescs, trainDescs, mask, trainIdx, trainIdx, distance, cc_12);\r
+ func(queryDescs, trainDescs, mask, trainIdx, trainIdx, distance, cc_12, StreamAccessor::getStream(stream));\r
}\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::matchDownload(const GpuMat& trainIdx, const GpuMat& distance,\r
}\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::matchCollection(const GpuMat& queryDescs, const GpuMat& trainCollection,\r
- GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, const GpuMat& maskCollection)\r
+ GpuMat& trainIdx, GpuMat& imgIdx, GpuMat& distance, const GpuMat& maskCollection, Stream& stream)\r
{\r
if (queryDescs.empty() || trainCollection.empty())\r
return;\r
\r
typedef void (*match_caller_t)(const DevMem2D& queryDescs, const DevMem2D& trainCollection,\r
const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx,\r
- const DevMem2Df& distance, bool cc_12);\r
+ const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
\r
static const match_caller_t match_callers[3][8] =\r
{\r
\r
bool cc_12 = TargetArchs::builtWith(FEATURE_SET_COMPUTE_12) && DeviceInfo().supports(FEATURE_SET_COMPUTE_12);\r
\r
- func(queryDescs, trainCollection, maskCollection, trainIdx, imgIdx, distance, cc_12);\r
+ func(queryDescs, trainCollection, maskCollection, trainIdx, imgIdx, distance, cc_12, StreamAccessor::getStream(stream));\r
}\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::matchDownload(const GpuMat& trainIdx, const GpuMat& imgIdx,\r
// KnnMatch\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::knnMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,\r
- GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask)\r
+ GpuMat& trainIdx, GpuMat& distance, GpuMat& allDist, int k, const GpuMat& mask, Stream& stream)\r
{\r
if (queryDescs.empty() || trainDescs.empty())\r
return;\r
using namespace cv::gpu::bfmatcher;\r
\r
typedef void (*match_caller_t)(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
\r
static const match_caller_t match_callers[3][8] =\r
{\r
const int nTrain = trainDescs.rows;\r
\r
trainIdx.create(nQuery, k, CV_32S);\r
- trainIdx.setTo(Scalar::all(-1));\r
distance.create(nQuery, k, CV_32F);\r
-\r
ensureSizeIsEnough(nQuery, nTrain, CV_32FC1, allDist);\r
- allDist.setTo(Scalar::all(numeric_limits<float>::max()));\r
+\r
+ if (stream)\r
+ {\r
+ stream.enqueueMemSet(trainIdx, Scalar::all(-1));\r
+ stream.enqueueMemSet(allDist, Scalar::all(numeric_limits<float>::max()));\r
+ }\r
+ else\r
+ {\r
+ trainIdx.setTo(Scalar::all(-1));\r
+ allDist.setTo(Scalar::all(numeric_limits<float>::max()));\r
+ }\r
\r
match_caller_t func = match_callers[distType][queryDescs.depth()];\r
CV_Assert(func != 0);\r
\r
- func(queryDescs, trainDescs, k, mask, trainIdx, distance, allDist);\r
+ func(queryDescs, trainDescs, k, mask, trainIdx, distance, allDist, StreamAccessor::getStream(stream));\r
}\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::knnMatchDownload(const GpuMat& trainIdx, const GpuMat& distance,\r
// RadiusMatch\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::radiusMatch(const GpuMat& queryDescs, const GpuMat& trainDescs,\r
- GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance, const GpuMat& mask)\r
+ GpuMat& trainIdx, GpuMat& nMatches, GpuMat& distance, float maxDistance, const GpuMat& mask, Stream& stream)\r
{\r
if (queryDescs.empty() || trainDescs.empty())\r
return;\r
using namespace cv::gpu::bfmatcher;\r
\r
typedef void (*radiusMatch_caller_t)(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
\r
static const radiusMatch_caller_t radiusMatch_callers[3][8] =\r
{\r
CV_Assert(trainIdx.empty() || (trainIdx.rows == nQuery && trainIdx.size() == distance.size()));\r
\r
ensureSizeIsEnough(1, nQuery, CV_32SC1, nMatches);\r
- nMatches.setTo(Scalar::all(0));\r
if (trainIdx.empty())\r
{\r
trainIdx.create(nQuery, nTrain, CV_32SC1);\r
distance.create(nQuery, nTrain, CV_32FC1);\r
}\r
\r
+ if (stream)\r
+ stream.enqueueMemSet(nMatches, Scalar::all(0));\r
+ else\r
+ nMatches.setTo(Scalar::all(0));\r
+\r
radiusMatch_caller_t func = radiusMatch_callers[distType][queryDescs.depth()];\r
CV_Assert(func != 0);\r
\r
- func(queryDescs, trainDescs, maxDistance, mask, trainIdx, nMatches.ptr<unsigned int>(), distance);\r
+ func(queryDescs, trainDescs, maxDistance, mask, trainIdx, nMatches.ptr<unsigned int>(), distance, StreamAccessor::getStream(stream));\r
}\r
\r
void cv::gpu::BruteForceMatcher_GPU_base::radiusMatchDownload(const GpuMat& trainIdx, const GpuMat& nMatches,\r
#if !defined(HAVE_CUDA)
-void cv::gpu::transformPoints(const GpuMat&, const Mat&, const Mat&,
- GpuMat&) { throw_nogpu(); }
+void cv::gpu::transformPoints(const GpuMat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }
-void cv::gpu::transformPoints(const GpuMat&, const Mat&, const Mat&,
- GpuMat&, const Stream&) { throw_nogpu(); }
+void cv::gpu::projectPoints(const GpuMat&, const Mat&, const Mat&, const Mat&, const Mat&, GpuMat&, Stream&) { throw_nogpu(); }
-void cv::gpu::projectPoints(const GpuMat&, const Mat&, const Mat&,
- const Mat&, const Mat&, GpuMat&) { throw_nogpu(); }
-
-void cv::gpu::projectPoints(const GpuMat&, const Mat&, const Mat&,
- const Mat&, const Mat&, GpuMat&, const Stream&) { throw_nogpu(); }
-
-void cv::gpu::solvePnPRansac(const Mat&, const Mat&, const Mat&, const Mat&, \r
- Mat&, Mat&, bool, int, float, int, vector<int>*) { throw_nogpu(); }
+void cv::gpu::solvePnPRansac(const Mat&, const Mat&, const Mat&, const Mat&, Mat&, Mat&, bool, int, float, int, vector<int>*) { throw_nogpu(); }
#else
namespace cv { namespace gpu { namespace transform_points
{
- void call(const DevMem2D_<float3> src, const float* rot, const float* transl,
- DevMem2D_<float3> dst, cudaStream_t stream);
+ void call(const DevMem2D_<float3> src, const float* rot, const float* transl, DevMem2D_<float3> dst, cudaStream_t stream);
}}}
namespace
{
- void transformPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec,
- GpuMat& dst, cudaStream_t stream)
+ void transformPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec, GpuMat& dst, cudaStream_t stream)
{
CV_Assert(src.rows == 1 && src.cols > 0 && src.type() == CV_32FC3);
CV_Assert(rvec.size() == Size(3, 1) && rvec.type() == CV_32F);
}
}
-void cv::gpu::transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
- GpuMat& dst)
-{
- ::transformPointsCaller(src, rvec, tvec, dst, 0);
-}
-
-void cv::gpu::transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
- GpuMat& dst, const Stream& stream)
+void cv::gpu::transformPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, GpuMat& dst, Stream& stream)
{
::transformPointsCaller(src, rvec, tvec, dst, StreamAccessor::getStream(stream));
}
namespace cv { namespace gpu { namespace project_points
{
- void call(const DevMem2D_<float3> src, const float* rot, const float* transl,
- const float* proj, DevMem2D_<float2> dst, cudaStream_t stream);
+ void call(const DevMem2D_<float3> src, const float* rot, const float* transl, const float* proj, DevMem2D_<float2> dst, cudaStream_t stream);
}}}
namespace
{
- void projectPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec,
- const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst,
- cudaStream_t stream)
+ void projectPointsCaller(const GpuMat& src, const Mat& rvec, const Mat& tvec, const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, cudaStream_t stream)
{
CV_Assert(src.rows == 1 && src.cols > 0 && src.type() == CV_32FC3);
CV_Assert(rvec.size() == Size(3, 1) && rvec.type() == CV_32F);
Rodrigues(rvec, rot);
dst.create(src.size(), CV_32FC2);
- project_points::call(src, rot.ptr<float>(), tvec.ptr<float>(),
- camera_mat.ptr<float>(), dst,stream);
+ project_points::call(src, rot.ptr<float>(), tvec.ptr<float>(), camera_mat.ptr<float>(), dst,stream);
}
}
-void cv::gpu::projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
- const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst)
-{
- ::projectPointsCaller(src, rvec, tvec, camera_mat, dist_coef, dst, 0);
-}
-
-void cv::gpu::projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec,
- const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst,
- const Stream& stream)
+void cv::gpu::projectPoints(const GpuMat& src, const Mat& rvec, const Mat& tvec, const Mat& camera_mat, const Mat& dist_coef, GpuMat& dst, Stream& stream)
{
::projectPointsCaller(src, rvec, tvec, camera_mat, dist_coef, dst, StreamAccessor::getStream(stream));
}
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::cvtColor(const GpuMat&, GpuMat&, int, int) { throw_nogpu(); }\r
-void cv::gpu::cvtColor(const GpuMat&, GpuMat&, int, int, const Stream&) { throw_nogpu(); }\r
+void cv::gpu::cvtColor(const GpuMat&, GpuMat&, int, int, Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
}\r
}\r
\r
-void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn)\r
-{\r
- cvtColor_caller(src, dst, code, dcn, 0);\r
-}\r
-\r
-void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, const Stream& stream)\r
+void cv::gpu::cvtColor(const GpuMat& src, GpuMat& dst, int code, int dcn, Stream& stream)\r
{\r
cvtColor_caller(src, dst, code, dcn, StreamAccessor::getStream(stream));\r
}\r
\r
template <typename T>\r
void blendLinearCaller(int rows, int cols, int cn, const PtrStep_<T> img1, const PtrStep_<T> img2, \r
- const PtrStepf weights1, const PtrStepf weights2, PtrStep_<T> result)\r
+ const PtrStepf weights1, const PtrStepf weights2, PtrStep_<T> result, cudaStream_t stream)\r
{\r
dim3 threads(16, 16);\r
dim3 grid(divUp(cols * cn, threads.x), divUp(rows, threads.y));\r
\r
- blendLinearKernel<<<grid, threads>>>(rows, cols * cn, cn, img1, img2, weights1, weights2, result);\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ blendLinearKernel<<<grid, threads, 0, stream>>>(rows, cols * cn, cn, img1, img2, weights1, weights2, result);\r
+ cudaSafeCall( cudaGetLastError() );\r
+\r
+ if (stream == 0)\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
template void blendLinearCaller<uchar>(int, int, int, const PtrStep, const PtrStep, \r
- const PtrStepf, const PtrStepf, PtrStep);\r
+ const PtrStepf, const PtrStepf, PtrStep, cudaStream_t stream);\r
template void blendLinearCaller<float>(int, int, int, const PtrStepf, const PtrStepf, \r
- const PtrStepf, const PtrStepf, PtrStepf);\r
+ const PtrStepf, const PtrStepf, PtrStepf, cudaStream_t stream);\r
\r
\r
__global__ void blendLinearKernel8UC4(int rows, int cols, const PtrStep img1, const PtrStep img2,\r
\r
\r
void blendLinearCaller8UC4(int rows, int cols, const PtrStep img1, const PtrStep img2, \r
- const PtrStepf weights1, const PtrStepf weights2, PtrStep result)\r
+ const PtrStepf weights1, const PtrStepf weights2, PtrStep result, cudaStream_t stream)\r
{\r
dim3 threads(16, 16);\r
dim3 grid(divUp(cols, threads.x), divUp(rows, threads.y));\r
\r
- blendLinearKernel8UC4<<<grid, threads>>>(rows, cols, img1, img2, weights1, weights2, result);\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ blendLinearKernel8UC4<<<grid, threads, 0, stream>>>(rows, cols, img1, img2, weights1, weights2, result);\r
+ cudaSafeCall( cudaGetLastError() );\r
+\r
+ if (stream == 0)\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
}}
\ No newline at end of file
\r
template <int BLOCK_DIM_X, int BLOCK_DIM_Y, typename Dist, typename T, typename Train, typename Mask>\r
void matchSimple_caller(const DevMem2D_<T>& queryDescs, const Train& train, \r
- const Mask& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance)\r
+ const Mask& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, cudaStream_t stream)\r
{\r
StaticAssert<BLOCK_DIM_Y <= 64>::check(); // blockDimY vals must reduce by warp\r
\r
dim3 threads(BLOCK_DIM_X, BLOCK_DIM_Y, 1);\r
\r
match<BLOCK_DIM_X, BLOCK_DIM_Y, ReduceDescCalculatorSimple<BLOCK_DIM_X, T>, Dist, T>\r
- <<<grid, threads>>>(queryDescs, train, mask, trainIdx.data, imgIdx.data, distance.data);\r
+ <<<grid, threads, 0, stream>>>(queryDescs, train, mask, trainIdx.data, imgIdx.data, distance.data);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
template <int BLOCK_DIM_X, int BLOCK_DIM_Y, int MAX_DESCRIPTORS_LEN, bool DESC_LEN_EQ_MAX_LEN, typename Dist, typename T, typename Train, typename Mask>\r
void matchCached_caller(const DevMem2D_<T>& queryDescs, const Train& train, \r
- const Mask& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance)\r
+ const Mask& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, cudaStream_t stream)\r
{\r
StaticAssert<BLOCK_DIM_Y <= 64>::check(); // blockDimY vals must reduce by warp\r
StaticAssert<BLOCK_DIM_X * BLOCK_DIM_Y >= MAX_DESCRIPTORS_LEN>::check(); // block size must be greter than descriptors length\r
dim3 threads(BLOCK_DIM_X, BLOCK_DIM_Y, 1);\r
\r
match<BLOCK_DIM_X, BLOCK_DIM_Y, ReduceDescCalculatorCached<BLOCK_DIM_X, MAX_DESCRIPTORS_LEN, DESC_LEN_EQ_MAX_LEN, T, typename Dist::ValueType>, Dist, T>\r
- <<<grid, threads>>>(queryDescs, train, mask, trainIdx.data, imgIdx.data, distance.data);\r
+ <<<grid, threads, 0, stream>>>(queryDescs, train, mask, trainIdx.data, imgIdx.data, distance.data);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
template <typename Dist, typename T, typename Train, typename Mask>\r
void matchDispatcher(const DevMem2D_<T>& queryDescs, const Train& train, \r
const Mask& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance,\r
- bool cc_12)\r
+ bool cc_12, cudaStream_t stream)\r
{\r
if (queryDescs.cols < 64)\r
- matchCached_caller<16, 16, 64, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance);\r
+ matchCached_caller<16, 16, 64, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
else if (queryDescs.cols == 64)\r
- matchCached_caller<16, 16, 64, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance);\r
+ matchCached_caller<16, 16, 64, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
else if (queryDescs.cols < 128)\r
- matchCached_caller<16, 16, 128, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance);\r
+ matchCached_caller<16, 16, 128, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
else if (queryDescs.cols == 128)\r
- matchCached_caller<16, 16, 128, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance);\r
+ matchCached_caller<16, 16, 128, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
else if (queryDescs.cols < 256)\r
- matchCached_caller<16, 16, 256, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance);\r
+ matchCached_caller<16, 16, 256, false, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
else if (queryDescs.cols == 256 && cc_12)\r
- matchCached_caller<16, 16, 256, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance);\r
+ matchCached_caller<16, 16, 256, true, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
else\r
- matchSimple_caller<16, 16, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance);\r
-\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ matchSimple_caller<16, 16, Dist>(queryDescs, train, mask, trainIdx, imgIdx, distance, stream);\r
}\r
\r
template <typename T>\r
void matchSingleL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, \r
const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance,\r
- bool cc_12)\r
+ bool cc_12, cudaStream_t stream)\r
{\r
SingleTrain<T> train((DevMem2D_<T>)trainDescs);\r
if (mask.data)\r
{\r
SingleMask m(mask);\r
- matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, m, trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, m, trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
else\r
{\r
- matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
}\r
\r
- template void matchSingleL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
+ template void matchSingleL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
\r
template <typename T>\r
void matchSingleL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, \r
const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12)\r
+ bool cc_12, cudaStream_t stream)\r
{\r
SingleTrain<T> train((DevMem2D_<T>)trainDescs);\r
if (mask.data)\r
{\r
SingleMask m(mask);\r
- matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, m, trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, m, trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
else\r
{\r
- matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
}\r
\r
- template void matchSingleL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
+ template void matchSingleL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
\r
template <typename T>\r
void matchSingleHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, \r
const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, \r
- bool cc_12)\r
+ bool cc_12, cudaStream_t stream)\r
{\r
SingleTrain<T> train((DevMem2D_<T>)trainDescs);\r
if (mask.data)\r
{\r
SingleMask m(mask);\r
- matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, m, trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, m, trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
else\r
{\r
- matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
}\r
\r
- template void matchSingleHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchSingleHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
+ template void matchSingleHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchSingleHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
\r
template <typename T>\r
void matchCollectionL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainCollection, \r
const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, \r
- const DevMem2Df& distance, bool cc_12)\r
+ const DevMem2Df& distance, bool cc_12, cudaStream_t stream)\r
{\r
TrainCollection<T> train((DevMem2D_<T>*)trainCollection.ptr(), trainCollection.cols, queryDescs.cols);\r
if (maskCollection.data)\r
{\r
MaskCollection mask(maskCollection.data);\r
- matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, mask, trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, mask, trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
else\r
{\r
- matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
}\r
\r
- template void matchCollectionL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
+ template void matchCollectionL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
\r
template <typename T>\r
void matchCollectionL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainCollection, \r
const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, \r
- const DevMem2Df& distance, bool cc_12)\r
+ const DevMem2Df& distance, bool cc_12, cudaStream_t stream)\r
{\r
TrainCollection<T> train((DevMem2D_<T>*)trainCollection.ptr(), trainCollection.cols, queryDescs.cols);\r
if (maskCollection.data)\r
{\r
MaskCollection mask(maskCollection.data);\r
- matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, mask, trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, mask, trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
else\r
{\r
- matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
}\r
\r
- template void matchCollectionL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
+ template void matchCollectionL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
\r
template <typename T>\r
void matchCollectionHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainCollection, \r
const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, \r
- const DevMem2Df& distance, bool cc_12)\r
+ const DevMem2Df& distance, bool cc_12, cudaStream_t stream)\r
{\r
TrainCollection<T> train((DevMem2D_<T>*)trainCollection.ptr(), trainCollection.cols, queryDescs.cols);\r
if (maskCollection.data)\r
{\r
MaskCollection mask(maskCollection.data);\r
- matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, mask, trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, mask, trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
else\r
{\r
- matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12);\r
+ matchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, train, WithOutMask(), trainIdx, imgIdx, distance, cc_12, stream);\r
}\r
}\r
\r
- template void matchCollectionHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
- template void matchCollectionHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12);\r
+ template void matchCollectionHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
+ template void matchCollectionHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainCollection, const DevMem2D_<PtrStep>& maskCollection, const DevMem2Di& trainIdx, const DevMem2Di& imgIdx, const DevMem2Df& distance, bool cc_12, cudaStream_t stream);\r
\r
///////////////////////////////////////////////////////////////////////////////////\r
//////////////////////////////////// Knn Match ////////////////////////////////////\r
\r
template <int BLOCK_DIM_X, int BLOCK_DIM_Y, typename Dist, typename T, typename Mask>\r
void calcDistance_caller(const DevMem2D_<T>& queryDescs, const DevMem2D_<T>& trainDescs, \r
- const Mask& mask, const DevMem2Df& distance)\r
+ const Mask& mask, const DevMem2Df& distance, cudaStream_t stream)\r
{\r
dim3 threads(BLOCK_DIM_X, BLOCK_DIM_Y, 1);\r
dim3 grid(queryDescs.rows, divUp(trainDescs.rows, BLOCK_DIM_Y), 1);\r
\r
- calcDistance<BLOCK_DIM_X, BLOCK_DIM_Y, Dist, T><<<grid, threads>>>(\r
+ calcDistance<BLOCK_DIM_X, BLOCK_DIM_Y, Dist, T><<<grid, threads, 0, stream>>>(\r
queryDescs, trainDescs, mask, distance);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
// find knn match kernel caller\r
\r
template <int BLOCK_SIZE>\r
- void findKnnMatch_caller(int knn, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist)\r
+ void findKnnMatch_caller(int knn, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream)\r
{\r
dim3 threads(BLOCK_SIZE, 1, 1);\r
dim3 grid(trainIdx.rows, 1, 1);\r
\r
for (int i = 0; i < knn; ++i)\r
{\r
- findBestMatch<BLOCK_SIZE><<<grid, threads>>>(allDist, i, trainIdx, distance);\r
+ findBestMatch<BLOCK_SIZE><<<grid, threads, 0, stream>>>(allDist, i, trainIdx, distance);\r
cudaSafeCall( cudaGetLastError() );\r
}\r
- \r
- cudaSafeCall( cudaThreadSynchronize() );\r
+\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
// knn match caller\r
\r
template <typename Dist, typename T, typename Mask>\r
- void calcDistanceDispatcher(const DevMem2D_<T>& queryDescs, const DevMem2D_<T>& trainDescs, const Mask& mask, const DevMem2Df& allDist)\r
+ void calcDistanceDispatcher(const DevMem2D_<T>& queryDescs, const DevMem2D_<T>& trainDescs, const Mask& mask, const DevMem2Df& allDist, cudaStream_t stream)\r
{\r
- calcDistance_caller<16, 16, Dist>(queryDescs, trainDescs, mask, allDist);\r
+ calcDistance_caller<16, 16, Dist>(queryDescs, trainDescs, mask, allDist, stream);\r
}\r
\r
- void findKnnMatchDispatcher(int knn, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist)\r
+ void findKnnMatchDispatcher(int knn, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream)\r
{\r
- findKnnMatch_caller<256>(knn, trainIdx, distance, allDist);\r
+ findKnnMatch_caller<256>(knn, trainIdx, distance, allDist, stream);\r
}\r
\r
template <typename T>\r
void knnMatchL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist)\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream)\r
{\r
if (mask.data)\r
{\r
- calcDistanceDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, SingleMask(mask), allDist);\r
+ calcDistanceDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, SingleMask(mask), allDist, stream);\r
}\r
else\r
{\r
- calcDistanceDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, WithOutMask(), allDist);\r
+ calcDistanceDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, WithOutMask(), allDist, stream);\r
}\r
\r
- findKnnMatchDispatcher(knn, trainIdx, distance, allDist);\r
+ findKnnMatchDispatcher(knn, trainIdx, distance, allDist, stream);\r
}\r
\r
- template void knnMatchL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
+ template void knnMatchL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
\r
template <typename T>\r
void knnMatchL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist)\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream)\r
{\r
if (mask.data)\r
{\r
calcDistanceDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- SingleMask(mask), allDist);\r
+ SingleMask(mask), allDist, stream);\r
}\r
else\r
{\r
calcDistanceDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- WithOutMask(), allDist);\r
+ WithOutMask(), allDist, stream);\r
}\r
\r
- findKnnMatchDispatcher(knn, trainIdx, distance, allDist);\r
+ findKnnMatchDispatcher(knn, trainIdx, distance, allDist, stream);\r
}\r
\r
- template void knnMatchL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
+ template void knnMatchL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
\r
template <typename T>\r
void knnMatchHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist)\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream)\r
{\r
if (mask.data)\r
{\r
calcDistanceDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- SingleMask(mask), allDist);\r
+ SingleMask(mask), allDist, stream);\r
}\r
else\r
{\r
calcDistanceDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- WithOutMask(), allDist);\r
+ WithOutMask(), allDist, stream);\r
}\r
\r
- findKnnMatchDispatcher(knn, trainIdx, distance, allDist);\r
+ findKnnMatchDispatcher(knn, trainIdx, distance, allDist, stream);\r
}\r
\r
- template void knnMatchHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
- template void knnMatchHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist);\r
+ template void knnMatchHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
+ template void knnMatchHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, int knn, const DevMem2D& mask, const DevMem2Di& trainIdx, const DevMem2Df& distance, const DevMem2Df& allDist, cudaStream_t stream);\r
\r
///////////////////////////////////////////////////////////////////////////////////\r
/////////////////////////////////// Radius Match //////////////////////////////////\r
template <int BLOCK_DIM_X, int BLOCK_DIM_Y, typename Dist, typename T, typename Mask>\r
void radiusMatch_caller(const DevMem2D_<T>& queryDescs, const DevMem2D_<T>& trainDescs, \r
float maxDistance, const Mask& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, \r
- const DevMem2Df& distance)\r
+ const DevMem2Df& distance, cudaStream_t stream)\r
{\r
dim3 threads(BLOCK_DIM_X, BLOCK_DIM_Y, 1);\r
dim3 grid(queryDescs.rows, divUp(trainDescs.rows, BLOCK_DIM_Y), 1);\r
\r
- radiusMatch<BLOCK_DIM_X, BLOCK_DIM_Y, Dist, T><<<grid, threads>>>(\r
+ radiusMatch<BLOCK_DIM_X, BLOCK_DIM_Y, Dist, T><<<grid, threads, 0, stream>>>(\r
queryDescs, trainDescs, maxDistance, mask, trainIdx, nMatches, distance);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
///////////////////////////////////////////////////////////////////////////////\r
template <typename Dist, typename T, typename Mask>\r
void radiusMatchDispatcher(const DevMem2D_<T>& queryDescs, const DevMem2D_<T>& trainDescs, \r
float maxDistance, const Mask& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, \r
- const DevMem2Df& distance)\r
+ const DevMem2Df& distance, cudaStream_t stream)\r
{\r
radiusMatch_caller<16, 16, Dist>(queryDescs, trainDescs, maxDistance, mask, \r
- trainIdx, nMatches, distance);\r
+ trainIdx, nMatches, distance, stream);\r
}\r
\r
template <typename T>\r
void radiusMatchL1_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance)\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream)\r
{\r
if (mask.data)\r
{\r
radiusMatchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- maxDistance, SingleMask(mask), trainIdx, nMatches, distance);\r
+ maxDistance, SingleMask(mask), trainIdx, nMatches, distance, stream);\r
}\r
else\r
{\r
radiusMatchDispatcher< L1Dist<T> >((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- maxDistance, WithOutMask(), trainIdx, nMatches, distance);\r
+ maxDistance, WithOutMask(), trainIdx, nMatches, distance, stream);\r
}\r
}\r
\r
- template void radiusMatchL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
+ template void radiusMatchL1_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL1_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL1_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL1_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL1_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL1_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
\r
template <typename T>\r
void radiusMatchL2_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance)\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream)\r
{\r
if (mask.data)\r
{\r
radiusMatchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- maxDistance, SingleMask(mask), trainIdx, nMatches, distance);\r
+ maxDistance, SingleMask(mask), trainIdx, nMatches, distance, stream);\r
}\r
else\r
{\r
radiusMatchDispatcher<L2Dist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- maxDistance, WithOutMask(), trainIdx, nMatches, distance);\r
+ maxDistance, WithOutMask(), trainIdx, nMatches, distance, stream);\r
}\r
}\r
\r
- template void radiusMatchL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
+ template void radiusMatchL2_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL2_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL2_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL2_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL2_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchL2_gpu<float >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
\r
template <typename T>\r
void radiusMatchHamming_gpu(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance,\r
- const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance)\r
+ const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream)\r
{\r
if (mask.data)\r
{\r
radiusMatchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- maxDistance, SingleMask(mask), trainIdx, nMatches, distance);\r
+ maxDistance, SingleMask(mask), trainIdx, nMatches, distance, stream);\r
}\r
else\r
{\r
radiusMatchDispatcher<HammingDist>((DevMem2D_<T>)queryDescs, (DevMem2D_<T>)trainDescs, \r
- maxDistance, WithOutMask(), trainIdx, nMatches, distance);\r
+ maxDistance, WithOutMask(), trainIdx, nMatches, distance, stream);\r
}\r
}\r
\r
- template void radiusMatchHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
- template void radiusMatchHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance);\r
+ template void radiusMatchHamming_gpu<uchar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchHamming_gpu<schar >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchHamming_gpu<ushort>(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchHamming_gpu<short >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
+ template void radiusMatchHamming_gpu<int >(const DevMem2D& queryDescs, const DevMem2D& trainDescs, float maxDistance, const DevMem2D& mask, const DevMem2Di& trainIdx, unsigned int* nMatches, const DevMem2Df& distance, cudaStream_t stream);\r
}}}\r
computeHypothesisScoresKernel<<<grid, threads, smem_size>>>(
num_points, object, image, dist_threshold, hypothesis_scores);
- cudaSafeCall(cudaThreadSynchronize());
+ cudaSafeCall( cudaGetLastError() );
+
+ cudaSafeCall( cudaDeviceSynchronize() );
}
} // namespace solvepnp_ransac
};\r
\r
template <typename T1, typename T2>\r
- inline void compare_ne(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst)\r
+ inline void compare_ne(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst, cudaStream_t stream)\r
{\r
NotEqual<T1, T2> op;\r
- transform(static_cast< DevMem2D_<T1> >(src1), static_cast< DevMem2D_<T2> >(src2), dst, op, 0);\r
+ transform(static_cast< DevMem2D_<T1> >(src1), static_cast< DevMem2D_<T2> >(src2), dst, op, stream);\r
}\r
\r
- void compare_ne_8uc4(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst)\r
+ void compare_ne_8uc4(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst, cudaStream_t stream)\r
{\r
- compare_ne<uint, uint>(src1, src2, dst);\r
+ compare_ne<uint, uint>(src1, src2, dst, stream);\r
}\r
- void compare_ne_32f(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst)\r
+ void compare_ne_32f(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst, cudaStream_t stream)\r
{\r
- compare_ne<float, float>(src1, src2, dst);\r
+ compare_ne<float, float>(src1, src2, dst, stream);\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0) \r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0) \r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0) \r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0) \r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
typedef typename SmemType<T>::smem_t smem_t;\r
\r
__shared__ smem_t smem[BLOCK_DIM_Y * BLOCK_DIM_X * 3];\r
- \r
- const int x = BLOCK_DIM_X * blockIdx.x + threadIdx.x;\r
- const int y = BLOCK_DIM_Y * blockIdx.y + threadIdx.y;\r
+\r
+ const int x = BLOCK_DIM_X * blockIdx.x + threadIdx.x;\r
+ const int y = BLOCK_DIM_Y * blockIdx.y + threadIdx.y;\r
\r
smem_t* sDataRow = smem + threadIdx.y * BLOCK_DIM_X * 3;\r
\r
namespace cv { namespace gpu { namespace filters\r
{\r
template <int ksize, typename T, typename D, template<typename> class B>\r
- void linearRowFilter_caller(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor)\r
+ void linearRowFilter_caller(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream)\r
{\r
dim3 threads(BLOCK_DIM_X, BLOCK_DIM_Y);\r
dim3 grid(divUp(src.cols, BLOCK_DIM_X), divUp(src.rows, BLOCK_DIM_Y));\r
"try bigger image or another border extrapolation mode", __FILE__, __LINE__);\r
}\r
\r
- filter_krnls::linearRowFilter<ksize, T, D><<<grid, threads>>>(src, dst, anchor, b);\r
+ filter_krnls::linearRowFilter<ksize, T, D><<<grid, threads, 0, stream>>>(src, dst, anchor, b);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template <typename T, typename D>\r
- void linearRowFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type)\r
+ void linearRowFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream)\r
{\r
- typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor);\r
+ typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream);\r
static const caller_t callers[3][17] = \r
{\r
{\r
linearRowFilter_caller<14, T, D, BrdRowReflect101>,\r
linearRowFilter_caller<15, T, D, BrdRowReflect101>, \r
linearRowFilter_caller<16, T, D, BrdRowReflect101>,\r
- }, \r
+ },\r
{\r
0, \r
linearRowFilter_caller<1 , T, D, BrdRowReplicate>, \r
linearRowFilter_caller<14, T, D, BrdRowReplicate>,\r
linearRowFilter_caller<15, T, D, BrdRowReplicate>, \r
linearRowFilter_caller<16, T, D, BrdRowReplicate>,\r
- }, \r
+ },\r
{\r
0, \r
linearRowFilter_caller<1 , T, D, BrdRowConstant>, \r
\r
loadLinearKernel(kernel, ksize);\r
\r
- callers[brd_type][ksize]((DevMem2D_<T>)src, (DevMem2D_<D>)dst, anchor);\r
+ callers[brd_type][ksize]((DevMem2D_<T>)src, (DevMem2D_<D>)dst, anchor, stream);\r
}\r
\r
- template void linearRowFilter_gpu<uchar , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearRowFilter_gpu<uchar4, float4>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearRowFilter_gpu<short , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);;\r
- template void linearRowFilter_gpu<short2, float2>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearRowFilter_gpu<int , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearRowFilter_gpu<float , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
+ template void linearRowFilter_gpu<uchar , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearRowFilter_gpu<uchar4, float4>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearRowFilter_gpu<short , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearRowFilter_gpu<short2, float2>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearRowFilter_gpu<int , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearRowFilter_gpu<float , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
}}}\r
\r
namespace filter_krnls\r
__global__ void linearColumnFilter(const DevMem2D_<T> src, PtrStep_<D> dst, int anchor, const B b)\r
{\r
__shared__ T smem[BLOCK_DIM_Y * BLOCK_DIM_X * 3];\r
- \r
- const int x = BLOCK_DIM_X * blockIdx.x + threadIdx.x;\r
- const int y = BLOCK_DIM_Y * blockIdx.y + threadIdx.y;\r
+\r
+ const int x = BLOCK_DIM_X * blockIdx.x + threadIdx.x;\r
+ const int y = BLOCK_DIM_Y * blockIdx.y + threadIdx.y;\r
\r
T* sDataColumn = smem + threadIdx.x;\r
\r
namespace cv { namespace gpu { namespace filters\r
{\r
template <int ksize, typename T, typename D, template<typename> class B>\r
- void linearColumnFilter_caller(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor)\r
+ void linearColumnFilter_caller(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream)\r
{\r
dim3 threads(BLOCK_DIM_X, BLOCK_DIM_Y);\r
dim3 grid(divUp(src.cols, BLOCK_DIM_X), divUp(src.rows, BLOCK_DIM_Y));\r
"try bigger image or another border extrapolation mode", __FILE__, __LINE__);\r
}\r
\r
- filter_krnls::linearColumnFilter<ksize, T, D><<<grid, threads>>>(src, dst, anchor, b);\r
+ filter_krnls::linearColumnFilter<ksize, T, D><<<grid, threads, 0, stream>>>(src, dst, anchor, b);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template <typename T, typename D>\r
- void linearColumnFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type)\r
+ void linearColumnFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream)\r
{\r
- typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor);\r
+ typedef void (*caller_t)(const DevMem2D_<T>& src, const DevMem2D_<D>& dst, int anchor, cudaStream_t stream);\r
static const caller_t callers[3][17] = \r
{\r
{\r
linearColumnFilter_caller<14, T, D, BrdColReflect101>, \r
linearColumnFilter_caller<15, T, D, BrdColReflect101>, \r
linearColumnFilter_caller<16, T, D, BrdColReflect101>, \r
- }, \r
+ },\r
{\r
0, \r
linearColumnFilter_caller<1 , T, D, BrdColReplicate>, \r
linearColumnFilter_caller<14, T, D, BrdColReplicate>, \r
linearColumnFilter_caller<15, T, D, BrdColReplicate>, \r
linearColumnFilter_caller<16, T, D, BrdColReplicate>, \r
- }, \r
+ },\r
{\r
0, \r
linearColumnFilter_caller<1 , T, D, BrdColConstant>, \r
\r
loadLinearKernel(kernel, ksize);\r
\r
- callers[brd_type][ksize]((DevMem2D_<T>)src, (DevMem2D_<D>)dst, anchor);\r
+ callers[brd_type][ksize]((DevMem2D_<T>)src, (DevMem2D_<D>)dst, anchor, stream);\r
}\r
\r
- template void linearColumnFilter_gpu<float , uchar >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearColumnFilter_gpu<float4, uchar4>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearColumnFilter_gpu<float , short >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearColumnFilter_gpu<float2, short2>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearColumnFilter_gpu<float , int >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
- template void linearColumnFilter_gpu<float , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
+ template void linearColumnFilter_gpu<float , uchar >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearColumnFilter_gpu<float4, uchar4>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearColumnFilter_gpu<float , short >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearColumnFilter_gpu<float2, short2>(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearColumnFilter_gpu<float , int >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
+ template void linearColumnFilter_gpu<float , float >(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
}}}\r
\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
cudaSafeCall( cudaMemcpyToSymbol(bf_krnls::ctable_space, &table_space.data, sizeof(table_space.data)) );\r
size_t table_space_step = table_space.step / sizeof(float);\r
cudaSafeCall( cudaMemcpyToSymbol(bf_krnls::ctable_space_step, &table_space_step, sizeof(size_t)) );\r
- \r
+\r
cudaSafeCall( cudaMemcpyToSymbol(bf_krnls::cndisp, &ndisp, sizeof(int)) );\r
cudaSafeCall( cudaMemcpyToSymbol(bf_krnls::cradius, &radius, sizeof(int)) );\r
- \r
+\r
cudaSafeCall( cudaMemcpyToSymbol(bf_krnls::cedge_disc, &edge_disc, sizeof(short)) );\r
cudaSafeCall( cudaMemcpyToSymbol(bf_krnls::cmax_disc, &max_disc, sizeof(short)) );\r
}\r
break;\r
default:\r
cv::gpu::error("Unsupported channels count", __FILE__, __LINE__);\r
- } \r
+ }\r
\r
if (stream != 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
void bilateral_filter_gpu(const DevMem2D& disp, const DevMem2D& img, int channels, int iters, cudaStream_t stream)\r
img_block_width, grad, qangle, scale, block_hists);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
block_hists, coefs, free_coef, threshold, labels);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//----------------------------------------------------------------------------\r
img_block_width, win_block_stride_x, win_block_stride_y, block_hists, descriptors);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
img_block_width, win_block_stride_x, win_block_stride_y, block_hists, descriptors);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//----------------------------------------------------------------------------\r
compute_gradients_8UC4_kernel<nthreads, 0><<<gdim, bdim>>>(height, width, img, angle_scale, grad, qangle);\r
\r
cudaSafeCall( cudaGetLastError() );\r
- cudaSafeCall(cudaThreadSynchronize());\r
+\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template <int nthreads, int correct_gamma>\r
compute_gradients_8UC1_kernel<nthreads, 0><<<gdim, bdim>>>(height, width, img, angle_scale, grad, qangle);\r
\r
cudaSafeCall( cudaGetLastError() );\r
- cudaSafeCall(cudaThreadSynchronize());\r
+\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
\r
resize_for_hog_kernel<<<grid, threads>>>(sx, sy, (DevMem2D_<T>)dst, colOfs);\r
cudaSafeCall( cudaGetLastError() );\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
+\r
cudaSafeCall( cudaUnbindTexture(tex) );\r
}\r
\r
remap_1c<<<grid, threads>>>(xmap.data, ymap.data, xmap.step, dst.data, dst.step, dst.cols, dst.rows);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() ); \r
+ cudaSafeCall( cudaDeviceSynchronize() ); \r
cudaSafeCall( cudaUnbindTexture(tex_remap) );\r
}\r
\r
remap_3c<<<grid, threads>>>(src.data, src.step, xmap.data, ymap.data, xmap.step, dst.data, dst.step, dst.cols, dst.rows);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() ); \r
+ cudaSafeCall( cudaDeviceSynchronize() ); \r
}\r
\r
/////////////////////////////////// MeanShiftfiltering ///////////////////////////////////////////////\r
meanshift_kernel<<< grid, threads >>>( dst.data, dst.step, dst.cols, dst.rows, sp, sr, maxIter, eps );\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
cudaSafeCall( cudaUnbindTexture( tex_meanshift ) ); \r
}\r
extern "C" void meanShiftProc_gpu(const DevMem2D& src, DevMem2D dstr, DevMem2D dstsp, int sp, int sr, int maxIter, float eps) \r
meanshiftproc_kernel<<< grid, threads >>>( dstr.data, dstr.step, dstsp.data, dstsp.step, dstr.cols, dstr.rows, sp, sr, maxIter, eps );\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
cudaSafeCall( cudaUnbindTexture( tex_meanshift ) ); \r
}\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() ); \r
+ cudaSafeCall( cudaDeviceSynchronize() ); \r
}\r
\r
void drawColorDisp_gpu(const DevMem2D_<short>& src, const DevMem2D& dst, int ndisp, const cudaStream_t& stream)\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
/////////////////////////////////// reprojectImageTo3D ///////////////////////////////////////////////\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
void reprojectImageTo3D_gpu(const DevMem2D& disp, const DevMem2Df& xyzw, const float* q, const cudaStream_t& stream)\r
extractCovData_kernel<<<grid, threads>>>(Dx.cols, Dx.rows, Dx, Dy, dst);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
/////////////////////////////////////////// Corner Harris /////////////////////////////////////////////////\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
+\r
cudaSafeCall(cudaUnbindTexture(harrisDxTex));\r
cudaSafeCall(cudaUnbindTexture(harrisDyTex));\r
}\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
+\r
cudaSafeCall(cudaUnbindTexture(minEigenValDxTex));\r
cudaSafeCall(cudaUnbindTexture(minEigenValDyTex));\r
}\r
column_sumKernel_32F<<<grid, threads>>>(src.cols, src.rows, src, dst);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//////////////////////////////////////////////////////////////////////////\r
mulSpectrumsKernel<<<grid, threads>>>(a, b, c);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//////////////////////////////////////////////////////////////////////////\r
mulSpectrumsKernel_CONJ<<<grid, threads>>>(a, b, c);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//////////////////////////////////////////////////////////////////////////\r
mulAndScaleSpectrumsKernel<<<grid, threads>>>(a, b, scale, c);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//////////////////////////////////////////////////////////////////////////\r
mulAndScaleSpectrumsKernel_CONJ<<<grid, threads>>>(a, b, scale, c);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
/////////////////////////////////////////////////////////////////////////\r
dim3 grid(divUp(cols, threads.x), divUp(rows, threads.y));\r
\r
downsampleKernel<<<grid, threads>>>(src, rows, cols, k, dst);\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaGetLastError() );\r
+\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template void downsampleCaller(const PtrStep src, int rows, int cols, int k, PtrStep dst);\r
#include "opencv2/gpu/devmem2d.hpp"\r
#include "safe_call.hpp"\r
#include "cuda_runtime.h"\r
+#include "npp.h"\r
+#include "NPP_staging.hpp"\r
\r
namespace cv\r
{\r
cudaSafeCall( cudaGetTextureReference(&tex, name) ); \r
cudaSafeCall( cudaUnbindTexture(tex) );\r
}\r
+\r
+ class NppStreamHandler\r
+ {\r
+ public:\r
+ inline explicit NppStreamHandler(cudaStream_t newStream = 0)\r
+ {\r
+ oldStream = nppGetStream();\r
+ nppSetStream(newStream);\r
+ }\r
+\r
+ inline ~NppStreamHandler()\r
+ {\r
+ nppSetStream(oldStream);\r
+ }\r
+\r
+ private:\r
+ cudaStream_t oldStream;\r
+ };\r
+\r
+ class NppStStreamHandler\r
+ {\r
+ public:\r
+ inline explicit NppStStreamHandler(cudaStream_t newStream = 0)\r
+ {\r
+ oldStream = nppStSetActiveCUDAstream(newStream);\r
+ }\r
+\r
+ inline ~NppStStreamHandler()\r
+ {\r
+ nppStSetActiveCUDAstream(oldStream);\r
+ }\r
+\r
+ private:\r
+ cudaStream_t oldStream;\r
+ };\r
}\r
}\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
w, h, (float)templ_sum / (w * h), image_sum, result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
image_sum_r, image_sum_g, result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
image_sum_r, image_sum_g, image_sum_b, result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
image_sum, image_sqsum, result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
result);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
void cartToPolar_gpu(const DevMem2Df& x, const DevMem2Df& y, const DevMem2Df& mag, bool magSqr, const DevMem2Df& angle, bool angleInDegrees, cudaStream_t stream)\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
void polarToCart_gpu(const DevMem2Df& mag, const DevMem2Df& angle, const DevMem2Df& x, const DevMem2Df& y, bool angleInDegrees, cudaStream_t stream)\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall ( cudaThreadSynchronize() ); \r
+ cudaSafeCall ( cudaDeviceSynchronize() );\r
}\r
\r
void copy_to_with_mask(const DevMem2D& mat_src, DevMem2D mat_dst, int depth, const DevMem2D& mask, int channels, const cudaStream_t & stream)\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall ( cudaThreadSynchronize() );\r
+ cudaSafeCall ( cudaDeviceSynchronize() );\r
}\r
\r
template void set_to_gpu<uchar >(const DevMem2D& mat, const uchar* scalar, const DevMem2D& mask, int channels, cudaStream_t stream);\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall ( cudaThreadSynchronize() );\r
+ cudaSafeCall ( cudaDeviceSynchronize() );\r
}\r
\r
template void set_to_gpu<uchar >(const DevMem2D& mat, const uchar* scalar, int channels, cudaStream_t stream);\r
minMaxKernel<256, T, Mask8U><<<grid, threads>>>(src, Mask8U(mask), minval_buf, maxval_buf);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
T minval_, maxval_;\r
- cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
- cudaSafeCall(cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
+ cudaSafeCall( cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
+ cudaSafeCall( cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
*minval = minval_;\r
*maxval = maxval_;\r
} \r
minMaxKernel<256, T, MaskTrue><<<grid, threads>>>(src, MaskTrue(), minval_buf, maxval_buf);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
T minval_, maxval_;\r
- cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
- cudaSafeCall(cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
+ cudaSafeCall( cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
+ cudaSafeCall( cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
*minval = minval_;\r
*maxval = maxval_;\r
} \r
minMaxPass2Kernel<256, T><<<1, 256>>>(minval_buf, maxval_buf, grid.x * grid.y);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
\r
T minval_, maxval_;\r
- cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
- cudaSafeCall(cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
+ cudaSafeCall( cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
+ cudaSafeCall( cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
*minval = minval_;\r
*maxval = maxval_;\r
}\r
minMaxPass2Kernel<256, T><<<1, 256>>>(minval_buf, maxval_buf, grid.x * grid.y);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
T minval_, maxval_;\r
- cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
- cudaSafeCall(cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
+ cudaSafeCall( cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
+ cudaSafeCall( cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
*minval = minval_;\r
*maxval = maxval_;\r
}\r
minloc_buf, maxloc_buf);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
T minval_, maxval_;\r
- cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
- cudaSafeCall(cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
+ cudaSafeCall( cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
+ cudaSafeCall( cudaMemcpy(&maxval_, maxval_buf, sizeof(T), cudaMemcpyDeviceToHost) );\r
*minval = minval_;\r
*maxval = maxval_;\r
\r
uint minloc_, maxloc_;\r
- cudaSafeCall(cudaMemcpy(&minloc_, minloc_buf, sizeof(int), cudaMemcpyDeviceToHost));\r
- cudaSafeCall(cudaMemcpy(&maxloc_, maxloc_buf, sizeof(int), cudaMemcpyDeviceToHost));\r
+ cudaSafeCall( cudaMemcpy(&minloc_, minloc_buf, sizeof(int), cudaMemcpyDeviceToHost) );\r
+ cudaSafeCall( cudaMemcpy(&maxloc_, maxloc_buf, sizeof(int), cudaMemcpyDeviceToHost) );\r
minloc[1] = minloc_ / src.cols; minloc[0] = minloc_ - minloc[1] * src.cols;\r
maxloc[1] = maxloc_ / src.cols; maxloc[0] = maxloc_ - maxloc[1] * src.cols;\r
}\r
minloc_buf, maxloc_buf);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
T minval_, maxval_;\r
cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
minMaxLocPass2Kernel<256, T><<<1, 256>>>(minval_buf, maxval_buf, minloc_buf, maxloc_buf, grid.x * grid.y);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
T minval_, maxval_;\r
cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
minMaxLocPass2Kernel<256, T><<<1, 256>>>(minval_buf, maxval_buf, minloc_buf, maxloc_buf, grid.x * grid.y);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
T minval_, maxval_;\r
cudaSafeCall(cudaMemcpy(&minval_, minval_buf, sizeof(T), cudaMemcpyDeviceToHost));\r
countNonZeroKernel<256, T><<<grid, threads>>>(src, count_buf);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
uint count;\r
cudaSafeCall(cudaMemcpy(&count, count_buf, sizeof(int), cudaMemcpyDeviceToHost));\r
countNonZeroPass2Kernel<256, T><<<1, 256>>>(count_buf, grid.x * grid.y);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
uint count;\r
cudaSafeCall(cudaMemcpy(&count, count_buf, sizeof(int), cudaMemcpyDeviceToHost));\r
\r
break;\r
}\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
R result[4] = {0, 0, 0, 0};\r
cudaSafeCall(cudaMemcpy(&result, buf.ptr(0), sizeof(R) * cn, cudaMemcpyDeviceToHost));\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
R result[4] = {0, 0, 0, 0};\r
cudaSafeCall(cudaMemcpy(&result, buf.ptr(0), sizeof(R) * cn, cudaMemcpyDeviceToHost));\r
\r
break;\r
}\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
R result[4] = {0, 0, 0, 0};\r
cudaSafeCall(cudaMemcpy(result, buf.ptr(0), sizeof(R) * cn, cudaMemcpyDeviceToHost));\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
R result[4] = {0, 0, 0, 0};\r
cudaSafeCall(cudaMemcpy(result, buf.ptr(0), sizeof(R) * cn, cudaMemcpyDeviceToHost));\r
\r
break;\r
}\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
R result[4] = {0, 0, 0, 0};\r
cudaSafeCall(cudaMemcpy(result, buf.ptr(0), sizeof(R) * cn, cudaMemcpyDeviceToHost));\r
}\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
R result[4] = {0, 0, 0, 0};\r
cudaSafeCall(cudaMemcpy(result, buf.ptr(0), sizeof(R) * cn, cudaMemcpyDeviceToHost));\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall(cudaThreadSynchronize());\r
+ cudaSafeCall(cudaDeviceSynchronize());\r
}\r
\r
\r
\r
//See above: #define COL_SSD_SIZE (BLOCK_W + 2 * RADIUS)\r
ssd[0] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 0 * (BLOCK_W + 2 * RADIUS));\r
- __syncthreads();\r
+ __syncthreads();\r
ssd[1] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 1 * (BLOCK_W + 2 * RADIUS));\r
- __syncthreads();\r
+ __syncthreads();\r
ssd[2] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 2 * (BLOCK_W + 2 * RADIUS));\r
- __syncthreads();\r
+ __syncthreads();\r
ssd[3] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 3 * (BLOCK_W + 2 * RADIUS));\r
- __syncthreads();\r
+ __syncthreads();\r
ssd[4] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 4 * (BLOCK_W + 2 * RADIUS));\r
- __syncthreads();\r
+ __syncthreads();\r
ssd[5] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 5 * (BLOCK_W + 2 * RADIUS));\r
- __syncthreads();\r
+ __syncthreads();\r
ssd[6] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 6 * (BLOCK_W + 2 * RADIUS));\r
- __syncthreads();\r
+ __syncthreads();\r
ssd[7] = CalcSSD<RADIUS>(col_ssd_cache, col_ssd + 7 * (BLOCK_W + 2 * RADIUS));\r
\r
int mssd = min(min(min(ssd[0], ssd[1]), min(ssd[4], ssd[5])), min(min(ssd[2], ssd[3]), min(ssd[6], ssd[7])));\r
stereoKernel<RADIUS><<<grid, threads, smem_size, stream>>>(left.data, right.data, left.step, disp, maxdisp);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- if (stream == 0) \r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
};\r
\r
typedef void (*kernel_caller_t)(const DevMem2D& left, const DevMem2D& right, const DevMem2D& disp, int maxdisp, cudaStream_t & stream);\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0) \r
- cudaSafeCall( cudaThreadSynchronize() ); \r
+ cudaSafeCall( cudaDeviceSynchronize() ); \r
\r
cudaSafeCall( cudaUnbindTexture (texForSobel ) );\r
}\r
textureness_kernel<<<grid, threads, smem_size, stream>>>(disp, winsz, avgTexturenessThreshold);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- if (stream == 0) \r
- cudaSafeCall( cudaThreadSynchronize() ); \r
- cudaSafeCall( cudaUnbindTexture (texForTF) );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
+ cudaSafeCall( cudaUnbindTexture (texForTF) );\r
}\r
\r
}}}\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
template <> void comp_data_gpu<uchar, float>(const DevMem2D& left, const DevMem2D& right, const DevMem2D& data, cudaStream_t stream)\r
{\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template <> void comp_data_gpu<uchar3, short>(const DevMem2D& left, const DevMem2D& right, const DevMem2D& data, cudaStream_t stream)\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
template <> void comp_data_gpu<uchar3, float>(const DevMem2D& left, const DevMem2D& right, const DevMem2D& data, cudaStream_t stream)\r
{\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template <> void comp_data_gpu<uchar4, short>(const DevMem2D& left, const DevMem2D& right, const DevMem2D& data, cudaStream_t stream)\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
template <> void comp_data_gpu<uchar4, float>(const DevMem2D& left, const DevMem2D& right, const DevMem2D& data, cudaStream_t stream)\r
{\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
///////////////////////////////////////////////////////////////\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template void data_step_down_gpu<short>(int dst_cols, int dst_rows, int src_rows, const DevMem2D& src, const DevMem2D& dst, cudaStream_t stream);\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template void level_up_messages_gpu<short>(int dst_idx, int dst_cols, int dst_rows, int src_rows, DevMem2D* mus, DevMem2D* mds, DevMem2D* mls, DevMem2D* mrs, cudaStream_t stream);\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
}\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template void output_gpu<short>(const DevMem2D& u, const DevMem2D& d, const DevMem2D& l, const DevMem2D& r, const DevMem2D& data, const DevMem2D_<short>& disp, cudaStream_t stream);\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
dim3 threads(32, 8, 1);\r
dim3 grid(1, 1, 1);\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template void init_data_cost(int rows, int cols, short* disp_selected_pyr, short* data_cost_selected, size_t msg_step,\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template void compute_data_cost(const short* disp_selected_pyr, short* data_cost, size_t msg_step1, size_t msg_step2,\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template void compute_disp(const short* u, const short* d, const short* l, const short* r, const short* data_cost_selected, const short* disp_selected, size_t msg_step, \r
icvCalcLayerDetAndTrace<<<grid, threads>>>(det, trace);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
icvInterpolateKeypoint<<<grid, threads>>>(det, maxPosBuffer, featureX, featureY, featureLaplacian, featureSize, featureHessian, featureCounter);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
icvCalcOrientation<<<grid, threads>>>(featureX, featureY, featureSize, featureDir);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
compute_descriptors64<<<dim3(nFeatures, 16, 1), dim3(6, 6, 1)>>>(descriptors, featureX, featureY, featureSize, featureDir);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
normalize_descriptors<64><<<dim3(nFeatures, 1, 1), dim3(64, 1, 1)>>>(descriptors);\r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
else\r
{\r
compute_descriptors128<<<dim3(nFeatures, 16, 1), dim3(6, 6, 1)>>>(descriptors, featureX, featureY, featureSize, featureDir); \r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
normalize_descriptors<128><<<dim3(nFeatures, 1, 1), dim3(128, 1, 1)>>>(descriptors); \r
cudaSafeCall( cudaGetLastError() );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
}\r
}}}\r
void cv::gpu::Stream::enqueueMemSet(GpuMat& /*src*/, Scalar /*val*/) { throw_nogpu(); }\r
void cv::gpu::Stream::enqueueMemSet(GpuMat& /*src*/, Scalar /*val*/, const GpuMat& /*mask*/) { throw_nogpu(); }\r
void cv::gpu::Stream::enqueueConvert(const GpuMat& /*src*/, GpuMat& /*dst*/, int /*type*/, double /*a*/, double /*b*/) { throw_nogpu(); }\r
+Stream& cv::gpu::Stream::Null() { throw_nogpu(); static Stream s; return s; }\r
+cv::gpu::Stream::operator bool() const { throw_nogpu(); return false; }\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
}\r
}\r
\r
-CV_EXPORTS cudaStream_t cv::gpu::StreamAccessor::getStream(const Stream& stream) { return stream.impl->stream; };\r
+CV_EXPORTS cudaStream_t cv::gpu::StreamAccessor::getStream(const Stream& stream) { return stream.impl ? stream.impl->stream : 0; };\r
\r
void cv::gpu::Stream::create()\r
{\r
void cv::gpu::Stream::enqueueUpload(const Mat& src, GpuMat& dst) { devcopy(src, dst, impl->stream, cudaMemcpyHostToDevice); }\r
void cv::gpu::Stream::enqueueCopy(const GpuMat& src, GpuMat& dst) { devcopy(src, dst, impl->stream, cudaMemcpyDeviceToDevice); }\r
\r
-void cv::gpu::Stream::enqueueMemSet(GpuMat& src, Scalar val)\r
+void cv::gpu::Stream::enqueueMemSet(GpuMat& src, Scalar s)\r
{\r
CV_Assert((src.depth() != CV_64F) || \r
(TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE)));\r
\r
+ if (s[0] == 0.0 && s[1] == 0.0 && s[2] == 0.0 && s[3] == 0.0)\r
+ {\r
+ cudaSafeCall( cudaMemset2DAsync(src.data, src.step, 0, src.cols * src.elemSize(), src.rows, impl->stream) );\r
+ return;\r
+ }\r
+ if (src.depth() == CV_8U)\r
+ {\r
+ int cn = src.channels();\r
+\r
+ if (cn == 1 || (cn == 2 && s[0] == s[1]) || (cn == 3 && s[0] == s[1] && s[0] == s[2]) || (cn == 4 && s[0] == s[1] && s[0] == s[2] && s[0] == s[3]))\r
+ {\r
+ int val = saturate_cast<uchar>(s[0]);\r
+ cudaSafeCall( cudaMemset2DAsync(src.data, src.step, val, src.cols * src.elemSize(), src.rows, impl->stream) );\r
+ return;\r
+ }\r
+ }\r
+\r
typedef void (*set_caller_t)(GpuMat& src, const Scalar& s, cudaStream_t stream);\r
static const set_caller_t set_callers[] =\r
{\r
kernelSet<uchar>, kernelSet<schar>, kernelSet<ushort>, kernelSet<short>,\r
kernelSet<int>, kernelSet<float>, kernelSet<double>\r
};\r
- set_callers[src.depth()](src, val, impl->stream);\r
+ set_callers[src.depth()](src, s, impl->stream);\r
}\r
\r
void cv::gpu::Stream::enqueueMemSet(GpuMat& src, Scalar val, const GpuMat& mask)\r
matrix_operations::convert_gpu(psrc->reshape(1), sdepth, dst.reshape(1), ddepth, alpha, beta, impl->stream);\r
}\r
\r
+cv::gpu::Stream::operator bool() const\r
+{\r
+ return impl && impl->stream;\r
+}\r
+\r
+cv::gpu::Stream::Stream(Impl* impl_) : impl(impl_) {}\r
+\r
+cv::gpu::Stream& cv::gpu::Stream::Null()\r
+{\r
+ static Stream s((Impl*)0);\r
+ return s;\r
+}\r
\r
#endif /* !defined (HAVE_CUDA) */\r
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::add(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::add(const GpuMat&, const Scalar&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::subtract(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::subtract(const GpuMat&, const Scalar&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::multiply(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::multiply(const GpuMat&, const Scalar&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::divide(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::divide(const GpuMat&, const Scalar&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::absdiff(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::absdiff(const GpuMat&, const Scalar&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::compare(const GpuMat&, const GpuMat&, GpuMat&, int) { throw_nogpu(); }\r
-void cv::gpu::bitwise_not(const GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::bitwise_not(const GpuMat&, GpuMat&, const GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::bitwise_or(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::bitwise_or(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::bitwise_and(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::bitwise_and(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::bitwise_xor(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::bitwise_xor(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::min(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::min(const GpuMat&, const GpuMat&, GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::min(const GpuMat&, double, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::min(const GpuMat&, double, GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::max(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::max(const GpuMat&, const GpuMat&, GpuMat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::max(const GpuMat&, double, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::max(const GpuMat&, double, GpuMat&, const Stream&) { throw_nogpu(); }\r
-double cv::gpu::threshold(const GpuMat&, GpuMat&, double, double, int) {throw_nogpu(); return 0.0;}\r
-double cv::gpu::threshold(const GpuMat&, GpuMat&, double, double, int, const Stream&) {throw_nogpu(); return 0.0;}\r
+void cv::gpu::add(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::add(const GpuMat&, const Scalar&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::subtract(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::subtract(const GpuMat&, const Scalar&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::multiply(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::multiply(const GpuMat&, const Scalar&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::divide(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::divide(const GpuMat&, const Scalar&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::absdiff(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::absdiff(const GpuMat&, const Scalar&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::compare(const GpuMat&, const GpuMat&, GpuMat&, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::bitwise_not(const GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::bitwise_or(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::bitwise_and(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::bitwise_xor(const GpuMat&, const GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::min(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::min(const GpuMat&, double, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::max(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::max(const GpuMat&, double, GpuMat&, Stream&) { throw_nogpu(); }\r
+double cv::gpu::threshold(const GpuMat&, GpuMat&, double, double, int, Stream&) {throw_nogpu(); return 0.0;}\r
\r
#else\r
\r
\r
void nppArithmCaller(const GpuMat& src1, const GpuMat& src2, GpuMat& dst,\r
npp_arithm_8u_t npp_func_8uc1, npp_arithm_8u_t npp_func_8uc4,\r
- npp_arithm_32s_t npp_func_32sc1, npp_arithm_32f_t npp_func_32fc1)\r
+ npp_arithm_32s_t npp_func_32sc1, npp_arithm_32f_t npp_func_32fc1, cudaStream_t stream)\r
{\r
CV_DbgAssert(src1.size() == src2.size() && src1.type() == src2.type());\r
CV_Assert(src1.type() == CV_8UC1 || src1.type() == CV_8UC4 || src1.type() == CV_32SC1 || src1.type() == CV_32FC1);\r
sz.width = src1.cols;\r
sz.height = src1.rows;\r
\r
+ NppStreamHandler h(stream);\r
+\r
switch (src1.type())\r
{\r
case CV_8UC1:\r
CV_Assert(!"Unsupported source type");\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template<int SCN> struct NppArithmScalarFunc;\r
\r
template<typename NppArithmScalarFunc<1>::func_ptr func> struct NppArithmScalar<1, func>\r
{\r
- static void calc(const GpuMat& src, const Scalar& sc, GpuMat& dst)\r
+ static void calc(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream)\r
{\r
dst.create(src.size(), src.type());\r
\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<Npp32f>(), src.step, (Npp32f)sc[0], dst.ptr<Npp32f>(), dst.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
template<typename NppArithmScalarFunc<2>::func_ptr func> struct NppArithmScalar<2, func>\r
{\r
- static void calc(const GpuMat& src, const Scalar& sc, GpuMat& dst)\r
+ static void calc(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream)\r
{\r
dst.create(src.size(), src.type());\r
\r
nValue.re = (Npp32f)sc[0];\r
nValue.im = (Npp32f)sc[1];\r
\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<Npp32fc>(), src.step, nValue, dst.ptr<Npp32fc>(), dst.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
}\r
\r
-void cv::gpu::add(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)\r
+void cv::gpu::add(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream)\r
{\r
- nppArithmCaller(src1, src2, dst, nppiAdd_8u_C1RSfs, nppiAdd_8u_C4RSfs, nppiAdd_32s_C1R, nppiAdd_32f_C1R);\r
+ nppArithmCaller(src1, src2, dst, nppiAdd_8u_C1RSfs, nppiAdd_8u_C4RSfs, nppiAdd_32s_C1R, nppiAdd_32f_C1R, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::subtract(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)\r
+void cv::gpu::subtract(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream)\r
{\r
- nppArithmCaller(src2, src1, dst, nppiSub_8u_C1RSfs, nppiSub_8u_C4RSfs, nppiSub_32s_C1R, nppiSub_32f_C1R);\r
+ nppArithmCaller(src2, src1, dst, nppiSub_8u_C1RSfs, nppiSub_8u_C4RSfs, nppiSub_32s_C1R, nppiSub_32f_C1R, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::multiply(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)\r
+void cv::gpu::multiply(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream)\r
{\r
- nppArithmCaller(src1, src2, dst, nppiMul_8u_C1RSfs, nppiMul_8u_C4RSfs, nppiMul_32s_C1R, nppiMul_32f_C1R);\r
+ nppArithmCaller(src1, src2, dst, nppiMul_8u_C1RSfs, nppiMul_8u_C4RSfs, nppiMul_32s_C1R, nppiMul_32f_C1R, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::divide(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)\r
+void cv::gpu::divide(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream)\r
{\r
- nppArithmCaller(src2, src1, dst, nppiDiv_8u_C1RSfs, nppiDiv_8u_C4RSfs, nppiDiv_32s_C1R, nppiDiv_32f_C1R);\r
+ nppArithmCaller(src2, src1, dst, nppiDiv_8u_C1RSfs, nppiDiv_8u_C4RSfs, nppiDiv_32s_C1R, nppiDiv_32f_C1R, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::add(const GpuMat& src, const Scalar& sc, GpuMat& dst)\r
+void cv::gpu::add(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stream& stream)\r
{\r
- typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);\r
+ typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream);\r
static const caller_t callers[] = {0, NppArithmScalar<1, nppiAddC_32f_C1R>::calc, NppArithmScalar<2, nppiAddC_32fc_C1R>::calc};\r
\r
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);\r
\r
- callers[src.channels()](src, sc, dst);\r
+ callers[src.channels()](src, sc, dst, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::subtract(const GpuMat& src, const Scalar& sc, GpuMat& dst)\r
+void cv::gpu::subtract(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stream& stream)\r
{\r
- typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);\r
+ typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream);\r
static const caller_t callers[] = {0, NppArithmScalar<1, nppiSubC_32f_C1R>::calc, NppArithmScalar<2, nppiSubC_32fc_C1R>::calc};\r
\r
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);\r
\r
- callers[src.channels()](src, sc, dst);\r
+ callers[src.channels()](src, sc, dst, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::multiply(const GpuMat& src, const Scalar& sc, GpuMat& dst)\r
+void cv::gpu::multiply(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stream& stream)\r
{\r
- typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);\r
+ typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream);\r
static const caller_t callers[] = {0, NppArithmScalar<1, nppiMulC_32f_C1R>::calc, NppArithmScalar<2, nppiMulC_32fc_C1R>::calc};\r
\r
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);\r
\r
- callers[src.channels()](src, sc, dst);\r
+ callers[src.channels()](src, sc, dst, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::divide(const GpuMat& src, const Scalar& sc, GpuMat& dst)\r
+void cv::gpu::divide(const GpuMat& src, const Scalar& sc, GpuMat& dst, Stream& stream)\r
{\r
- typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst);\r
+ typedef void (*caller_t)(const GpuMat& src, const Scalar& sc, GpuMat& dst, cudaStream_t stream);\r
static const caller_t callers[] = {0, NppArithmScalar<1, nppiDivC_32f_C1R>::calc, NppArithmScalar<2, nppiDivC_32fc_C1R>::calc};\r
\r
CV_Assert(src.type() == CV_32FC1 || src.type() == CV_32FC2);\r
\r
- callers[src.channels()](src, sc, dst);\r
+ callers[src.channels()](src, sc, dst, StreamAccessor::getStream(stream));\r
}\r
\r
\r
//////////////////////////////////////////////////////////////////////////////\r
// Absolute difference\r
\r
-void cv::gpu::absdiff(const GpuMat& src1, const GpuMat& src2, GpuMat& dst)\r
+void cv::gpu::absdiff(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& s)\r
{\r
CV_DbgAssert(src1.size() == src2.size() && src1.type() == src2.type());\r
\r
sz.width = src1.cols;\r
sz.height = src1.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
switch (src1.type())\r
{\r
case CV_8UC1:\r
CV_Assert(!"Unsupported source type");\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
-void cv::gpu::absdiff(const GpuMat& src, const Scalar& s, GpuMat& dst)\r
+void cv::gpu::absdiff(const GpuMat& src1, const Scalar& src2, GpuMat& dst, Stream& s)\r
{\r
- CV_Assert(src.type() == CV_32FC1);\r
+ CV_Assert(src1.type() == CV_32FC1);\r
\r
- dst.create( src.size(), src.type() );\r
+ dst.create( src1.size(), src1.type() );\r
\r
NppiSize sz;\r
- sz.width = src.cols;\r
- sz.height = src.rows;\r
+ sz.width = src1.cols;\r
+ sz.height = src1.rows;\r
+\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
\r
- nppSafeCall( nppiAbsDiffC_32f_C1R(src.ptr<Npp32f>(), src.step, dst.ptr<Npp32f>(), dst.step, sz, (Npp32f)s[0]) );\r
+ nppSafeCall( nppiAbsDiffC_32f_C1R(src1.ptr<Npp32f>(), src1.step, dst.ptr<Npp32f>(), dst.step, sz, (Npp32f)src2[0]) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
\r
namespace cv { namespace gpu { namespace mathfunc\r
{\r
- void compare_ne_8uc4(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst);\r
- void compare_ne_32f(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst);\r
+ void compare_ne_8uc4(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst, cudaStream_t stream);\r
+ void compare_ne_32f(const DevMem2D& src1, const DevMem2D& src2, const DevMem2D& dst, cudaStream_t stream);\r
}}}\r
\r
-void cv::gpu::compare(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, int cmpop)\r
+void cv::gpu::compare(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, int cmpop, Stream& s)\r
{\r
CV_DbgAssert(src1.size() == src2.size() && src1.type() == src2.type());\r
\r
sz.width = src1.cols;\r
sz.height = src1.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
if (src1.type() == CV_8UC4)\r
{\r
if (cmpop != CMP_NE)\r
{\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiCompare_8u_C4R(src1.ptr<Npp8u>(), src1.step,\r
src2.ptr<Npp8u>(), src2.step,\r
dst.ptr<Npp8u>(), dst.step, sz, nppCmpOp[cmpop]) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
else\r
{\r
- mathfunc::compare_ne_8uc4(src1, src2, dst);\r
+ mathfunc::compare_ne_8uc4(src1, src2, dst, stream);\r
}\r
}\r
else\r
{\r
if (cmpop != CMP_NE)\r
{\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiCompare_32f_C1R(src1.ptr<Npp32f>(), src1.step,\r
src2.ptr<Npp32f>(), src2.step,\r
dst.ptr<Npp8u>(), dst.step, sz, nppCmpOp[cmpop]) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
else\r
{\r
- mathfunc::compare_ne_32f(src1, src2, dst);\r
+ mathfunc::compare_ne_32f(src1, src2, dst, stream);\r
}\r
}\r
}\r
}\r
\r
\r
-void cv::gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask)\r
-{\r
- if (mask.empty())\r
- ::bitwiseNotCaller(src, dst, 0);\r
- else\r
- ::bitwiseNotCaller(src, dst, mask, 0);\r
-}\r
-\r
-\r
-void cv::gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, const Stream& stream)\r
+void cv::gpu::bitwise_not(const GpuMat& src, GpuMat& dst, const GpuMat& mask, Stream& stream)\r
{\r
if (mask.empty())\r
::bitwiseNotCaller(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
\r
-void cv::gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask)\r
-{\r
- if (mask.empty())\r
- ::bitwiseOrCaller(src1, src2, dst, 0);\r
- else\r
- ::bitwiseOrCaller(src1, src2, dst, mask, 0);\r
-}\r
-\r
-\r
-void cv::gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream)\r
+void cv::gpu::bitwise_or(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, Stream& stream)\r
{\r
if (mask.empty())\r
::bitwiseOrCaller(src1, src2, dst, StreamAccessor::getStream(stream));\r
}\r
\r
\r
-void cv::gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask)\r
-{\r
- if (mask.empty())\r
- ::bitwiseAndCaller(src1, src2, dst, 0);\r
- else\r
- ::bitwiseAndCaller(src1, src2, dst, mask, 0);\r
-}\r
-\r
-\r
-void cv::gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream)\r
+void cv::gpu::bitwise_and(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, Stream& stream)\r
{\r
if (mask.empty())\r
::bitwiseAndCaller(src1, src2, dst, StreamAccessor::getStream(stream));\r
}\r
\r
\r
-void cv::gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask)\r
-{\r
- if (mask.empty())\r
- ::bitwiseXorCaller(src1, src2, dst, 0);\r
- else\r
- ::bitwiseXorCaller(src1, src2, dst, mask, 0);\r
-}\r
-\r
-\r
-void cv::gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, const Stream& stream)\r
+void cv::gpu::bitwise_xor(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const GpuMat& mask, Stream& stream)\r
{\r
if (mask.empty())\r
::bitwiseXorCaller(src1, src2, dst, StreamAccessor::getStream(stream));\r
}\r
}\r
\r
-void cv::gpu::min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst) \r
-{\r
- CV_Assert(src1.size() == src2.size() && src1.type() == src2.type());\r
- CV_Assert((src1.depth() != CV_64F) || \r
- (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE)));\r
-\r
- typedef void (*func_t)(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, cudaStream_t stream);\r
- static const func_t funcs[] = \r
- {\r
- min_caller<uchar>, min_caller<schar>, min_caller<ushort>, min_caller<short>, min_caller<int>, \r
- min_caller<float>, min_caller<double>\r
- };\r
- funcs[src1.depth()](src1, src2, dst, 0);\r
-}\r
-\r
-void cv::gpu::min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream) \r
+void cv::gpu::min(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream) \r
{ \r
CV_Assert(src1.size() == src2.size() && src1.type() == src2.type());\r
CV_Assert((src1.depth() != CV_64F) || \r
};\r
funcs[src1.depth()](src1, src2, dst, StreamAccessor::getStream(stream));\r
}\r
-\r
-void cv::gpu::min(const GpuMat& src1, double src2, GpuMat& dst) \r
-{\r
- CV_Assert((src1.depth() != CV_64F) || \r
- (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE)));\r
-\r
- typedef void (*func_t)(const GpuMat& src1, double src2, GpuMat& dst, cudaStream_t stream);\r
- static const func_t funcs[] = \r
- {\r
- min_caller<uchar>, min_caller<schar>, min_caller<ushort>, min_caller<short>, min_caller<int>, \r
- min_caller<float>, min_caller<double>\r
- };\r
- funcs[src1.depth()](src1, src2, dst, 0);\r
-}\r
-\r
-void cv::gpu::min(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream) \r
+void cv::gpu::min(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream) \r
{\r
CV_Assert((src1.depth() != CV_64F) || \r
(TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE)));\r
funcs[src1.depth()](src1, src2, dst, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst) \r
-{ \r
- CV_Assert(src1.size() == src2.size() && src1.type() == src2.type());\r
- CV_Assert((src1.depth() != CV_64F) || \r
- (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE)));\r
-\r
- typedef void (*func_t)(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, cudaStream_t stream);\r
- static const func_t funcs[] = \r
- {\r
- max_caller<uchar>, max_caller<schar>, max_caller<ushort>, max_caller<short>, max_caller<int>, \r
- max_caller<float>, max_caller<double>\r
- };\r
- funcs[src1.depth()](src1, src2, dst, 0);\r
-}\r
-\r
-void cv::gpu::max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, const Stream& stream) \r
+void cv::gpu::max(const GpuMat& src1, const GpuMat& src2, GpuMat& dst, Stream& stream) \r
{ \r
CV_Assert(src1.size() == src2.size() && src1.type() == src2.type());\r
CV_Assert((src1.depth() != CV_64F) || \r
funcs[src1.depth()](src1, src2, dst, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::max(const GpuMat& src1, double src2, GpuMat& dst) \r
-{\r
- CV_Assert((src1.depth() != CV_64F) || \r
- (TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE)));\r
-\r
- typedef void (*func_t)(const GpuMat& src1, double src2, GpuMat& dst, cudaStream_t stream);\r
- static const func_t funcs[] = \r
- {\r
- max_caller<uchar>, max_caller<schar>, max_caller<ushort>, max_caller<short>, max_caller<int>, \r
- max_caller<float>, max_caller<double>\r
- };\r
- funcs[src1.depth()](src1, src2, dst, 0);\r
-}\r
-\r
-void cv::gpu::max(const GpuMat& src1, double src2, GpuMat& dst, const Stream& stream) \r
+void cv::gpu::max(const GpuMat& src1, double src2, GpuMat& dst, Stream& stream) \r
{\r
CV_Assert((src1.depth() != CV_64F) || \r
(TargetArchs::builtWith(NATIVE_DOUBLE) && DeviceInfo().supports(NATIVE_DOUBLE)));\r
}\r
}\r
\r
-double cv::gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxVal, int type)\r
+double cv::gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxVal, int type, Stream& s)\r
{\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
if (src.type() == CV_32FC1 && type == THRESH_TRUNC)\r
{\r
+ NppStreamHandler h(stream);\r
+\r
dst.create(src.size(), src.type());\r
\r
NppiSize sz;\r
nppSafeCall( nppiThreshold_32f_C1R(src.ptr<Npp32f>(), src.step,\r
dst.ptr<Npp32f>(), dst.step, sz, static_cast<Npp32f>(thresh), NPP_CMP_GREATER) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
else\r
{\r
maxVal = cvRound(maxVal);\r
}\r
\r
- callers[src.depth()](src, dst, thresh, maxVal, type, 0);\r
- }\r
-\r
- return thresh;\r
-}\r
-\r
-double cv::gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxVal, int type, const Stream& stream)\r
-{\r
- typedef void (*caller_t)(const GpuMat& src, GpuMat& dst, double thresh, double maxVal, int type, \r
- cudaStream_t stream);\r
-\r
- static const caller_t callers[] = \r
- {\r
- threshold_caller<unsigned char>, threshold_caller<signed char>, \r
- threshold_caller<unsigned short>, threshold_caller<short>, \r
- threshold_caller<int>, threshold_caller<float>, threshold_caller<double>\r
- };\r
-\r
- CV_Assert(src.channels() == 1 && src.depth() <= CV_64F);\r
- CV_Assert(type <= THRESH_TOZERO_INV);\r
-\r
- dst.create(src.size(), src.type());\r
-\r
- if (src.depth() != CV_32F)\r
- {\r
- thresh = cvFloor(thresh);\r
- maxVal = cvRound(maxVal);\r
+ callers[src.depth()](src, dst, thresh, maxVal, type, stream);\r
}\r
\r
- callers[src.depth()](src, dst, thresh, maxVal, type, StreamAccessor::getStream(stream));\r
return thresh;\r
}\r
\r
Ptr<BaseFilter_GPU> cv::gpu::getMaxFilter_GPU(int, int, const Size&, Point) { throw_nogpu(); return Ptr<BaseFilter_GPU>(0); }\r
Ptr<BaseFilter_GPU> cv::gpu::getMinFilter_GPU(int, int, const Size&, Point) { throw_nogpu(); return Ptr<BaseFilter_GPU>(0); }\r
\r
-void cv::gpu::boxFilter(const GpuMat&, GpuMat&, int, Size, Point) { throw_nogpu(); }\r
-void cv::gpu::erode( const GpuMat&, GpuMat&, const Mat&, Point, int) { throw_nogpu(); }\r
-void cv::gpu::dilate( const GpuMat&, GpuMat&, const Mat&, Point, int) { throw_nogpu(); }\r
-void cv::gpu::morphologyEx( const GpuMat&, GpuMat&, int, const Mat&, Point, int) { throw_nogpu(); }\r
-void cv::gpu::filter2D(const GpuMat&, GpuMat&, int, const Mat&, Point) { throw_nogpu(); }\r
-void cv::gpu::sepFilter2D(const GpuMat&, GpuMat&, int, const Mat&, const Mat&, Point, int, int) { throw_nogpu(); }\r
-void cv::gpu::Sobel(const GpuMat&, GpuMat&, int, int, int, int, double, int, int) { throw_nogpu(); }\r
-void cv::gpu::Scharr(const GpuMat&, GpuMat&, int, int, int, double, int, int) { throw_nogpu(); }\r
-void cv::gpu::GaussianBlur(const GpuMat&, GpuMat&, Size, double, double, int, int) { throw_nogpu(); }\r
-void cv::gpu::Laplacian(const GpuMat&, GpuMat&, int, int, double) { throw_nogpu(); }\r
+void cv::gpu::boxFilter(const GpuMat&, GpuMat&, int, Size, Point, Stream&) { throw_nogpu(); }\r
+void cv::gpu::erode( const GpuMat&, GpuMat&, const Mat&, Point, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::dilate( const GpuMat&, GpuMat&, const Mat&, Point, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::morphologyEx( const GpuMat&, GpuMat&, int, const Mat&, Point, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::filter2D(const GpuMat&, GpuMat&, int, const Mat&, Point, Stream&) { throw_nogpu(); }\r
+void cv::gpu::sepFilter2D(const GpuMat&, GpuMat&, int, const Mat&, const Mat&, Point, int, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::Sobel(const GpuMat&, GpuMat&, int, int, int, int, double, int, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::Scharr(const GpuMat&, GpuMat&, int, int, int, double, int, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::GaussianBlur(const GpuMat&, GpuMat&, Size, double, double, int, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::Laplacian(const GpuMat&, GpuMat&, int, int, double, Stream&) { throw_nogpu(); }\r
\r
#else\r
\r
filter2D(filter2D_), srcType(srcType_), dstType(dstType_)\r
{}\r
\r
- virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1))\r
+ virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1), Stream& stream = Stream::Null())\r
{\r
CV_Assert(src.type() == srcType);\r
\r
Size src_size = src.size();\r
\r
dst.create(src_size, dstType);\r
- dst = Scalar(0.0);\r
+\r
+ if (stream)\r
+ stream.enqueueMemSet(dst, Scalar::all(0.0));\r
+ else\r
+ dst.setTo(Scalar::all(0.0));\r
\r
normalizeROI(roi, filter2D->ksize, filter2D->anchor, src_size);\r
\r
GpuMat srcROI = src(roi);\r
GpuMat dstROI = dst(roi);\r
\r
- (*filter2D)(srcROI, dstROI);\r
+ (*filter2D)(srcROI, dstROI, stream);\r
}\r
\r
Ptr<BaseFilter_GPU> filter2D;\r
anchor = Point(rowFilter->anchor, columnFilter->anchor);\r
}\r
\r
- virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1))\r
+ virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1), Stream& stream = Stream::Null())\r
{\r
CV_Assert(src.type() == srcType);\r
\r
Size src_size = src.size();\r
\r
dst.create(src_size, dstType);\r
- dst = Scalar(0.0);\r
dstBuf.create(src_size, bufType);\r
- dstBuf = Scalar(0.0);\r
+\r
+ if (stream)\r
+ {\r
+ stream.enqueueMemSet(dst, Scalar::all(0));\r
+ stream.enqueueMemSet(dstBuf, Scalar::all(0));\r
+ }\r
+ else\r
+ {\r
+ dst = Scalar(0.0);\r
+ dstBuf = Scalar(0.0);\r
+ }\r
\r
normalizeROI(roi, ksize, anchor, src_size);\r
\r
GpuMat dstROI = dst(roi);\r
GpuMat dstBufROI = dstBuf(roi);\r
\r
- (*rowFilter)(srcROI, dstBufROI);\r
- (*columnFilter)(dstBufROI, dstROI);\r
+ (*rowFilter)(srcROI, dstBufROI, stream);\r
+ (*columnFilter)(dstBufROI, dstROI, stream);\r
}\r
\r
Ptr<BaseRowFilter_GPU> rowFilter;\r
public:\r
NppRowSumFilter(int ksize_, int anchor_) : BaseRowFilter_GPU(ksize_, anchor_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiSumWindowRow_8u32f_C1R(src.ptr<Npp8u>(), src.step, dst.ptr<Npp32f>(), dst.step, sz, ksize, anchor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
}\r
public:\r
NppColumnSumFilter(int ksize_, int anchor_) : BaseColumnFilter_GPU(ksize_, anchor_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiSumWindowColumn_8u32f_C1R(src.ptr<Npp8u>(), src.step, dst.ptr<Npp32f>(), dst.step, sz, ksize, anchor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
}\r
public:\r
NPPBoxFilter(const Size& ksize_, const Point& anchor_, nppFilterBox_t func_) : BaseFilter_GPU(ksize_, anchor_), func(func_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
NppiPoint oAnchor;\r
oAnchor.x = anchor.x;\r
oAnchor.y = anchor.y;\r
+\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
\r
nppSafeCall( func(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, oKernelSize, oAnchor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
nppFilterBox_t func;\r
return createFilter2D_GPU(boxFilter, srcType, dstType);\r
}\r
\r
-void cv::gpu::boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor)\r
+void cv::gpu::boxFilter(const GpuMat& src, GpuMat& dst, int ddepth, Size ksize, Point anchor, Stream& stream)\r
{\r
int sdepth = src.depth(), cn = src.channels();\r
if( ddepth < 0 )\r
dst.create(src.size(), CV_MAKETYPE(ddepth, cn));\r
\r
Ptr<FilterEngine_GPU> f = createBoxFilter_GPU(src.type(), dst.type(), ksize, anchor);\r
- f->apply(src, dst);\r
+ f->apply(src, dst, Rect(0,0,-1,-1), stream);\r
}\r
\r
////////////////////////////////////////////////////////////////////////////////////////////////////\r
NPPMorphFilter(const Size& ksize_, const Point& anchor_, const GpuMat& kernel_, nppMorfFilter_t func_) : \r
BaseFilter_GPU(ksize_, anchor_), kernel(kernel_), func(func_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
oAnchor.x = anchor.x;\r
oAnchor.y = anchor.y;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, kernel.ptr<Npp8u>(), oKernelSize, oAnchor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
GpuMat kernel;\r
MorphologyFilterEngine_GPU(const Ptr<BaseFilter_GPU>& filter2D_, int type, int iters_) : \r
Filter2DEngine_GPU(filter2D_, type, type), iters(iters_) {}\r
\r
- virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1))\r
+ virtual void apply(const GpuMat& src, GpuMat& dst, Rect roi = Rect(0,0,-1,-1), Stream& stream = Stream::Null())\r
{\r
if (iters > 1)\r
morfBuf.create(src.size(), src.type());\r
\r
- Filter2DEngine_GPU::apply(src, dst);\r
+ Filter2DEngine_GPU::apply(src, dst, roi, stream);\r
for(int i = 1; i < iters; ++i)\r
{\r
dst.swap(morfBuf);\r
- Filter2DEngine_GPU::apply(morfBuf, dst);\r
+ Filter2DEngine_GPU::apply(morfBuf, dst, roi, stream);\r
}\r
}\r
\r
\r
namespace\r
{\r
- void morphOp(int op, const GpuMat& src, GpuMat& dst, const Mat& _kernel, Point anchor, int iterations)\r
+ void morphOp(int op, const GpuMat& src, GpuMat& dst, const Mat& _kernel, Point anchor, int iterations, Stream& stream)\r
{\r
Mat kernel;\r
Size ksize = _kernel.data ? _kernel.size() : Size(3, 3);\r
\r
if (iterations == 0 || _kernel.rows * _kernel.cols == 1)\r
{\r
- src.copyTo(dst);\r
+ if (stream)\r
+ stream.enqueueCopy(src, dst);\r
+ else\r
+ src.copyTo(dst);\r
return;\r
}\r
\r
\r
Ptr<FilterEngine_GPU> f = createMorphologyFilter_GPU(op, src.type(), kernel, anchor, iterations);\r
\r
- f->apply(src, dst);\r
+ f->apply(src, dst, Rect(0,0,-1,-1), stream);\r
}\r
}\r
\r
-void cv::gpu::erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor, int iterations)\r
+void cv::gpu::erode( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor, int iterations, Stream& stream)\r
{\r
- morphOp(MORPH_ERODE, src, dst, kernel, anchor, iterations);\r
+ morphOp(MORPH_ERODE, src, dst, kernel, anchor, iterations, stream);\r
}\r
\r
-void cv::gpu::dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor, int iterations)\r
+void cv::gpu::dilate( const GpuMat& src, GpuMat& dst, const Mat& kernel, Point anchor, int iterations, Stream& stream)\r
{\r
- morphOp(MORPH_DILATE, src, dst, kernel, anchor, iterations);\r
+ morphOp(MORPH_DILATE, src, dst, kernel, anchor, iterations, stream);\r
}\r
\r
-void cv::gpu::morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor, int iterations)\r
+void cv::gpu::morphologyEx( const GpuMat& src, GpuMat& dst, int op, const Mat& kernel, Point anchor, int iterations, Stream& stream)\r
{\r
GpuMat temp;\r
switch( op )\r
{\r
- case MORPH_ERODE: erode( src, dst, kernel, anchor, iterations); break; \r
- case MORPH_DILATE: dilate( src, dst, kernel, anchor, iterations); break; \r
+ case MORPH_ERODE: erode( src, dst, kernel, anchor, iterations, stream); break;\r
+ case MORPH_DILATE: dilate( src, dst, kernel, anchor, iterations, stream); break;\r
case MORPH_OPEN:\r
- erode( src, temp, kernel, anchor, iterations);\r
- dilate( temp, dst, kernel, anchor, iterations);\r
+ erode( src, temp, kernel, anchor, iterations, stream);\r
+ dilate( temp, dst, kernel, anchor, iterations, stream);\r
break;\r
case CV_MOP_CLOSE:\r
- dilate( src, temp, kernel, anchor, iterations);\r
- erode( temp, dst, kernel, anchor, iterations);\r
+ dilate( src, temp, kernel, anchor, iterations, stream);\r
+ erode( temp, dst, kernel, anchor, iterations, stream);\r
break;\r
case CV_MOP_GRADIENT:\r
- erode( src, temp, kernel, anchor, iterations);\r
- dilate( src, dst, kernel, anchor, iterations); \r
- subtract(dst, temp, dst);\r
+ erode( src, temp, kernel, anchor, iterations, stream);\r
+ dilate( src, dst, kernel, anchor, iterations, stream);\r
+ subtract(dst, temp, dst, stream);\r
break;\r
case CV_MOP_TOPHAT:\r
- erode( src, dst, kernel, anchor, iterations);\r
- dilate( dst, temp, kernel, anchor, iterations); \r
- subtract(src, temp, dst);\r
+ erode( src, dst, kernel, anchor, iterations, stream);\r
+ dilate( dst, temp, kernel, anchor, iterations, stream);\r
+ subtract(src, temp, dst, stream);\r
break;\r
case CV_MOP_BLACKHAT:\r
- dilate( src, dst, kernel, anchor, iterations);\r
- erode( dst, temp, kernel, anchor, iterations);\r
- subtract(temp, src, dst);\r
+ dilate( src, dst, kernel, anchor, iterations, stream);\r
+ erode( dst, temp, kernel, anchor, iterations, stream);\r
+ subtract(temp, src, dst, stream);\r
break;\r
default:\r
CV_Error( CV_StsBadArg, "unknown morphological operation" );\r
NPPLinearFilter(const Size& ksize_, const Point& anchor_, const GpuMat& kernel_, Npp32s nDivisor_, nppFilter2D_t func_) : \r
BaseFilter_GPU(ksize_, anchor_), kernel(kernel_), nDivisor(nDivisor_), func(func_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
NppiPoint oAnchor;\r
oAnchor.x = anchor.x;\r
oAnchor.y = anchor.y;\r
+\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
\r
nppSafeCall( func(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, \r
kernel.ptr<Npp32s>(), oKernelSize, oAnchor, nDivisor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
GpuMat kernel;\r
return createFilter2D_GPU(linearFilter, srcType, dstType);\r
}\r
\r
-void cv::gpu::filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor)\r
+void cv::gpu::filter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernel, Point anchor, Stream& stream)\r
{\r
if( ddepth < 0 )\r
ddepth = src.depth();\r
dst.create(src.size(), CV_MAKETYPE(ddepth, src.channels()));\r
\r
Ptr<FilterEngine_GPU> f = createLinearFilter_GPU(src.type(), dst.type(), kernel, anchor);\r
- f->apply(src, dst);\r
+ f->apply(src, dst, Rect(0, 0, -1, -1), stream);\r
}\r
\r
////////////////////////////////////////////////////////////////////////////////////////////////////\r
namespace cv { namespace gpu { namespace filters\r
{\r
template <typename T, typename D>\r
- void linearRowFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
+ void linearRowFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
\r
template <typename T, typename D>\r
- void linearColumnFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
+ void linearColumnFilter_gpu(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
}}}\r
\r
namespace\r
typedef NppStatus (*nppFilter1D_t)(const Npp8u * pSrc, Npp32s nSrcStep, Npp8u * pDst, Npp32s nDstStep, NppiSize oROI, \r
const Npp32s * pKernel, Npp32s nMaskSize, Npp32s nAnchor, Npp32s nDivisor);\r
\r
- typedef void (*gpuFilter1D_t)(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type);\r
+ typedef void (*gpuFilter1D_t)(const DevMem2D& src, const DevMem2D& dst, const float kernel[], int ksize, int anchor, int brd_type, cudaStream_t stream);\r
\r
class NppLinearRowFilter : public BaseRowFilter_GPU\r
{\r
NppLinearRowFilter(int ksize_, int anchor_, const GpuMat& kernel_, Npp32s nDivisor_, nppFilter1D_t func_) : \r
BaseRowFilter_GPU(ksize_, anchor_), kernel(kernel_), nDivisor(nDivisor_), func(func_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, kernel.ptr<Npp32s>(), ksize, anchor, nDivisor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
GpuMat kernel;\r
GpuLinearRowFilter(int ksize_, int anchor_, const Mat& kernel_, gpuFilter1D_t func_, int brd_type_) : \r
BaseRowFilter_GPU(ksize_, anchor_), kernel(kernel_), func(func_), brd_type(brd_type_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
- func(src, dst, kernel.ptr<float>(), ksize, anchor, brd_type);\r
+ func(src, dst, kernel.ptr<float>(), ksize, anchor, brd_type, StreamAccessor::getStream(s));\r
}\r
\r
Mat kernel;\r
NppLinearColumnFilter(int ksize_, int anchor_, const GpuMat& kernel_, Npp32s nDivisor_, nppFilter1D_t func_) : \r
BaseColumnFilter_GPU(ksize_, anchor_), kernel(kernel_), nDivisor(nDivisor_), func(func_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, kernel.ptr<Npp32s>(), ksize, anchor, nDivisor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
GpuMat kernel;\r
GpuLinearColumnFilter(int ksize_, int anchor_, const Mat& kernel_, gpuFilter1D_t func_, int brd_type_) : \r
BaseColumnFilter_GPU(ksize_, anchor_), kernel(kernel_), func(func_), brd_type(brd_type_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
- func(src, dst, kernel.ptr<float>(), ksize, anchor, brd_type);\r
+ func(src, dst, kernel.ptr<float>(), ksize, anchor, brd_type, StreamAccessor::getStream(s));\r
}\r
\r
Mat kernel;\r
return createSeparableFilter_GPU(rowFilter, columnFilter, srcType, bufType, dstType);\r
}\r
\r
-void cv::gpu::sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor, int rowBorderType, int columnBorderType)\r
+void cv::gpu::sepFilter2D(const GpuMat& src, GpuMat& dst, int ddepth, const Mat& kernelX, const Mat& kernelY, Point anchor, int rowBorderType, int columnBorderType,\r
+ Stream& stream)\r
{\r
if( ddepth < 0 )\r
ddepth = src.depth();\r
dst.create(src.size(), CV_MAKETYPE(ddepth, src.channels()));\r
\r
Ptr<FilterEngine_GPU> f = createSeparableLinearFilter_GPU(src.type(), dst.type(), kernelX, kernelY, anchor, rowBorderType, columnBorderType);\r
- f->apply(src, dst, Rect(0, 0, src.cols, src.rows));\r
+ f->apply(src, dst, Rect(0, 0, src.cols, src.rows), stream);\r
}\r
\r
////////////////////////////////////////////////////////////////////////////////////////////////////\r
return createSeparableLinearFilter_GPU(srcType, dstType, kx, ky, Point(-1,-1), rowBorderType, columnBorderType);\r
}\r
\r
-void cv::gpu::Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize, double scale, int rowBorderType, int columnBorderType)\r
+void cv::gpu::Sobel(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, int ksize, double scale, int rowBorderType, int columnBorderType, Stream& stream)\r
{\r
Mat kx, ky;\r
getDerivKernels(kx, ky, dx, dy, ksize, false, CV_32F);\r
ky *= scale;\r
}\r
\r
- sepFilter2D(src, dst, ddepth, kx, ky, Point(-1,-1), rowBorderType, columnBorderType);\r
+ sepFilter2D(src, dst, ddepth, kx, ky, Point(-1,-1), rowBorderType, columnBorderType, stream);\r
}\r
\r
-void cv::gpu::Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale, int rowBorderType, int columnBorderType)\r
+void cv::gpu::Scharr(const GpuMat& src, GpuMat& dst, int ddepth, int dx, int dy, double scale, int rowBorderType, int columnBorderType, Stream& stream)\r
{\r
Mat kx, ky;\r
getDerivKernels(kx, ky, dx, dy, -1, false, CV_32F);\r
ky *= scale;\r
}\r
\r
- sepFilter2D(src, dst, ddepth, kx, ky, Point(-1,-1), rowBorderType, columnBorderType);\r
+ sepFilter2D(src, dst, ddepth, kx, ky, Point(-1,-1), rowBorderType, columnBorderType, stream);\r
}\r
\r
-void cv::gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize, double scale)\r
+void cv::gpu::Laplacian(const GpuMat& src, GpuMat& dst, int ddepth, int ksize, double scale, Stream& stream)\r
{\r
CV_Assert(ksize == 1 || ksize == 3);\r
\r
if (scale != 1)\r
kernel *= scale;\r
\r
- filter2D(src, dst, ddepth, kernel, Point(-1,-1));\r
+ filter2D(src, dst, ddepth, kernel, Point(-1,-1), stream);\r
}\r
\r
////////////////////////////////////////////////////////////////////////////////////////////////////\r
return createSeparableLinearFilter_GPU(type, type, kx, ky, Point(-1,-1), rowBorderType, columnBorderType);\r
}\r
\r
-void cv::gpu::GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2, int rowBorderType, int columnBorderType)\r
+void cv::gpu::GaussianBlur(const GpuMat& src, GpuMat& dst, Size ksize, double sigma1, double sigma2, int rowBorderType, int columnBorderType, Stream& stream)\r
{\r
if (ksize.width == 1 && ksize.height == 1)\r
{\r
dst.create(src.size(), src.type());\r
\r
Ptr<FilterEngine_GPU> f = createGaussianFilter_GPU(src.type(), ksize, sigma1, sigma2, rowBorderType, columnBorderType);\r
- f->apply(src, dst, Rect(0, 0, src.cols, src.rows));\r
+ f->apply(src, dst, Rect(0, 0, src.cols, src.rows), stream);\r
}\r
\r
////////////////////////////////////////////////////////////////////////////////////////////////////\r
public:\r
NPPRankFilter(const Size& ksize_, const Point& anchor_, nppFilterRank_t func_) : BaseFilter_GPU(ksize_, anchor_), func(func_) {}\r
\r
- virtual void operator()(const GpuMat& src, GpuMat& dst)\r
+ virtual void operator()(const GpuMat& src, GpuMat& dst, Stream& s = Stream::Null())\r
{\r
NppiSize sz;\r
sz.width = src.cols;\r
NppiPoint oAnchor;\r
oAnchor.x = anchor.x;\r
oAnchor.y = anchor.y;\r
+\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
\r
nppSafeCall( func(src.ptr<Npp8u>(), src.step, dst.ptr<Npp8u>(), dst.step, sz, oKernelSize, oAnchor) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
nppFilterRank_t func;\r
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::graphcut(GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::graphcut(GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
-void cv::gpu::graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf)\r
+void cv::gpu::graphcut(GpuMat& terminals, GpuMat& leftTransp, GpuMat& rightTransp, GpuMat& top, GpuMat& bottom, GpuMat& labels, GpuMat& buf, Stream& s)\r
{\r
Size src_size = terminals.size();\r
CV_Assert(terminals.type() == CV_32S);\r
if ((size_t)bufsz > buf.cols * buf.rows * buf.elemSize())\r
buf.create(1, bufsz, CV_8U);\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiGraphcut_32s8u(terminals.ptr<Npp32s>(), leftTransp.ptr<Npp32s>(), rightTransp.ptr<Npp32s>(), top.ptr<Npp32s>(), bottom.ptr<Npp32s>(),\r
terminals.step, leftTransp.step, sznpp, labels.ptr<Npp8u>(), labels.step, buf.ptr<Npp8u>()) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
\r
#endif /* !defined (HAVE_CUDA) */\r
\r
-\r
-\r
-\r
-\r
-\r
void cv::gpu::remap(const GpuMat&, GpuMat&, const GpuMat&, const GpuMat&){ throw_nogpu(); }\r
void cv::gpu::meanShiftFiltering(const GpuMat&, GpuMat&, int, int, TermCriteria) { throw_nogpu(); }\r
void cv::gpu::meanShiftProc(const GpuMat&, GpuMat&, GpuMat&, int, int, TermCriteria) { throw_nogpu(); }\r
-void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int) { throw_nogpu(); }\r
-void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::reprojectImageTo3D(const GpuMat&, GpuMat&, const Mat&) { throw_nogpu(); }\r
-void cv::gpu::reprojectImageTo3D(const GpuMat&, GpuMat&, const Mat&, const Stream&) { throw_nogpu(); }\r
-void cv::gpu::resize(const GpuMat&, GpuMat&, Size, double, double, int) { throw_nogpu(); }\r
-void cv::gpu::copyMakeBorder(const GpuMat&, GpuMat&, int, int, int, int, const Scalar&) { throw_nogpu(); }\r
-void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_nogpu(); }\r
-void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int) { throw_nogpu(); }\r
-void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int) { throw_nogpu(); }\r
-void cv::gpu::integral(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::integralBuffered(const GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::integral(const GpuMat&, GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::sqrIntegral(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
+void cv::gpu::drawColorDisp(const GpuMat&, GpuMat&, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::reprojectImageTo3D(const GpuMat&, GpuMat&, const Mat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::resize(const GpuMat&, GpuMat&, Size, double, double, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::copyMakeBorder(const GpuMat&, GpuMat&, int, int, int, int, const Scalar&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::warpAffine(const GpuMat&, GpuMat&, const Mat&, Size, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::warpPerspective(const GpuMat&, GpuMat&, const Mat&, Size, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::rotate(const GpuMat&, GpuMat&, Size, double, double, double, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::integral(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::integralBuffered(const GpuMat&, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::integral(const GpuMat&, GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::sqrIntegral(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
void cv::gpu::columnSum(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::rectStdDev(const GpuMat&, const GpuMat&, GpuMat&, const Rect&) { throw_nogpu(); }\r
-//void cv::gpu::Canny(const GpuMat&, GpuMat&, double, double, int) { throw_nogpu(); }\r
-//void cv::gpu::Canny(const GpuMat&, GpuMat&, GpuMat&, double, double, int) { throw_nogpu(); }\r
-//void cv::gpu::Canny(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, double, double, int) { throw_nogpu(); }\r
-//void cv::gpu::Canny(const GpuMat&, const GpuMat&, GpuMat&, GpuMat&, GpuMat&, double, double, int) { throw_nogpu(); }\r
+void cv::gpu::rectStdDev(const GpuMat&, const GpuMat&, GpuMat&, const Rect&, Stream&) { throw_nogpu(); }\r
void cv::gpu::evenLevels(GpuMat&, int, int, int) { throw_nogpu(); }\r
-void cv::gpu::histEven(const GpuMat&, GpuMat&, int, int, int) { throw_nogpu(); }\r
-void cv::gpu::histEven(const GpuMat&, GpuMat*, int*, int*, int*) { throw_nogpu(); }\r
-void cv::gpu::histRange(const GpuMat&, GpuMat&, const GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::histRange(const GpuMat&, GpuMat*, const GpuMat*) { throw_nogpu(); }\r
+void cv::gpu::histEven(const GpuMat&, GpuMat&, int, int, int, Stream&) { throw_nogpu(); }\r
+void cv::gpu::histEven(const GpuMat&, GpuMat*, int*, int*, int*, Stream&) { throw_nogpu(); }\r
+void cv::gpu::histRange(const GpuMat&, GpuMat&, const GpuMat&, Stream&) { throw_nogpu(); }\r
+void cv::gpu::histRange(const GpuMat&, GpuMat*, const GpuMat*, Stream&) { throw_nogpu(); }\r
void cv::gpu::cornerHarris(const GpuMat&, GpuMat&, int, int, double, int) { throw_nogpu(); }\r
void cv::gpu::cornerMinEigenVal(const GpuMat&, GpuMat&, int, int, int) { throw_nogpu(); }\r
void cv::gpu::mulSpectrums(const GpuMat&, const GpuMat&, GpuMat&, int, bool) { throw_nogpu(); }\r
const drawColorDisp_caller_t drawColorDisp_callers[] = {drawColorDisp_caller<unsigned char>, 0, 0, drawColorDisp_caller<short>, 0, 0, 0, 0};\r
}\r
\r
-void cv::gpu::drawColorDisp(const GpuMat& src, GpuMat& dst, int ndisp)\r
-{\r
- CV_Assert(src.type() == CV_8U || src.type() == CV_16S);\r
-\r
- drawColorDisp_callers[src.type()](src, dst, ndisp, 0);\r
-}\r
-\r
-void cv::gpu::drawColorDisp(const GpuMat& src, GpuMat& dst, int ndisp, const Stream& stream)\r
+void cv::gpu::drawColorDisp(const GpuMat& src, GpuMat& dst, int ndisp, Stream& stream)\r
{\r
CV_Assert(src.type() == CV_8U || src.type() == CV_16S);\r
\r
const reprojectImageTo3D_caller_t reprojectImageTo3D_callers[] = {reprojectImageTo3D_caller<unsigned char>, 0, 0, reprojectImageTo3D_caller<short>, 0, 0, 0, 0};\r
}\r
\r
-void cv::gpu::reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q)\r
-{\r
- CV_Assert((disp.type() == CV_8U || disp.type() == CV_16S) && Q.type() == CV_32F && Q.rows == 4 && Q.cols == 4);\r
-\r
- reprojectImageTo3D_callers[disp.type()](disp, xyzw, Q, 0);\r
-}\r
-\r
-void cv::gpu::reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, const Stream& stream)\r
+void cv::gpu::reprojectImageTo3D(const GpuMat& disp, GpuMat& xyzw, const Mat& Q, Stream& stream)\r
{\r
CV_Assert((disp.type() == CV_8U || disp.type() == CV_16S) && Q.type() == CV_32F && Q.rows == 4 && Q.cols == 4);\r
\r
////////////////////////////////////////////////////////////////////////\r
// resize\r
\r
-void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, double fy, int interpolation)\r
+void cv::gpu::resize(const GpuMat& src, GpuMat& dst, Size dsize, double fx, double fy, int interpolation, Stream& s)\r
{\r
static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR/*, NPPI_INTER_CUBIC, 0, NPPI_INTER_LANCZOS*/};\r
\r
dstsz.width = dst.cols;\r
dstsz.height = dst.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
if (src.type() == CV_8UC1)\r
{\r
nppSafeCall( nppiResize_8u_C1R(src.ptr<Npp8u>(), srcsz, src.step, srcrect,\r
dst.ptr<Npp8u>(), dst.step, dstsz, fx, fy, npp_inter[interpolation]) );\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
// copyMakeBorder\r
\r
-void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value)\r
+void cv::gpu::copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, const Scalar& value, Stream& s)\r
{\r
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_8UC4 || src.type() == CV_32SC1 || src.type() == CV_32FC1);\r
\r
dstsz.width = dst.cols;\r
dstsz.height = dst.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
switch (src.type())\r
{\r
case CV_8UC1:\r
CV_Assert(!"Unsupported source type");\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
\r
void nppWarpCaller(const GpuMat& src, GpuMat& dst, double coeffs[][3], const Size& dsize, int flags,\r
npp_warp_8u_t npp_warp_8u[][2], npp_warp_16u_t npp_warp_16u[][2],\r
- npp_warp_32s_t npp_warp_32s[][2], npp_warp_32f_t npp_warp_32f[][2])\r
+ npp_warp_32s_t npp_warp_32s[][2], npp_warp_32f_t npp_warp_32f[][2], cudaStream_t stream)\r
{\r
static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC};\r
\r
\r
int warpInd = (flags & WARP_INVERSE_MAP) >> 4;\r
\r
+ NppStreamHandler h(stream);\r
+\r
switch (src.depth())\r
{\r
case CV_8U:\r
CV_Assert(!"Unsupported source type");\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
}\r
\r
-void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags)\r
+void cv::gpu::warpAffine(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, Stream& s)\r
{\r
static npp_warp_8u_t npp_warpAffine_8u[][2] =\r
{\r
Mat coeffsMat(2, 3, CV_64F, (void*)coeffs);\r
M.convertTo(coeffsMat, coeffsMat.type());\r
\r
- nppWarpCaller(src, dst, coeffs, dsize, flags, npp_warpAffine_8u, npp_warpAffine_16u, npp_warpAffine_32s, npp_warpAffine_32f);\r
+ nppWarpCaller(src, dst, coeffs, dsize, flags, npp_warpAffine_8u, npp_warpAffine_16u, npp_warpAffine_32s, npp_warpAffine_32f, StreamAccessor::getStream(s));\r
}\r
\r
-void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags)\r
+void cv::gpu::warpPerspective(const GpuMat& src, GpuMat& dst, const Mat& M, Size dsize, int flags, Stream& s)\r
{\r
static npp_warp_8u_t npp_warpPerspective_8u[][2] =\r
{\r
Mat coeffsMat(3, 3, CV_64F, (void*)coeffs);\r
M.convertTo(coeffsMat, coeffsMat.type());\r
\r
- nppWarpCaller(src, dst, coeffs, dsize, flags, npp_warpPerspective_8u, npp_warpPerspective_16u, npp_warpPerspective_32s, npp_warpPerspective_32f);\r
+ nppWarpCaller(src, dst, coeffs, dsize, flags, npp_warpPerspective_8u, npp_warpPerspective_16u, npp_warpPerspective_32s, npp_warpPerspective_32f, StreamAccessor::getStream(s));\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
// rotate\r
\r
-void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift, double yShift, int interpolation)\r
+void cv::gpu::rotate(const GpuMat& src, GpuMat& dst, Size dsize, double angle, double xShift, double yShift, int interpolation, Stream& s)\r
{\r
static const int npp_inter[] = {NPPI_INTER_NN, NPPI_INTER_LINEAR, NPPI_INTER_CUBIC};\r
\r
dstroi.height = dst.rows;\r
dstroi.width = dst.cols;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
if (src.type() == CV_8UC1)\r
{\r
nppSafeCall( nppiRotate_8u_C1R(src.ptr<Npp8u>(), srcsz, src.step, srcroi,\r
dst.ptr<Npp8u>(), dst.step, dstroi, angle, xShift, yShift, npp_inter[interpolation]) );\r
}\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
// integral\r
\r
-void cv::gpu::integral(const GpuMat& src, GpuMat& sum)\r
+void cv::gpu::integral(const GpuMat& src, GpuMat& sum, Stream& s)\r
{\r
GpuMat buffer;\r
- integralBuffered(src, sum, buffer);\r
+ integralBuffered(src, sum, buffer, s);\r
}\r
\r
-void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer)\r
+void cv::gpu::integralBuffered(const GpuMat& src, GpuMat& sum, GpuMat& buffer, Stream& s)\r
{\r
CV_Assert(src.type() == CV_8UC1);\r
\r
nppSafeCall( nppiStIntegralGetSize_8u32u(roiSize, &bufSize, prop) );\r
ensureSizeIsEnough(1, bufSize, CV_8UC1, buffer);\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStStreamHandler h(stream);\r
+\r
nppSafeCall( nppiStIntegral_8u32u_C1R(const_cast<Ncv8u*>(src.ptr<Ncv8u>()), src.step, \r
sum.ptr<Ncv32u>(), sum.step, roiSize, buffer.ptr<Ncv8u>(), bufSize, prop) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
-void cv::gpu::integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum)\r
+void cv::gpu::integral(const GpuMat& src, GpuMat& sum, GpuMat& sqsum, Stream& s)\r
{\r
CV_Assert(src.type() == CV_8UC1);\r
\r
- int w = src.cols + 1, h = src.rows + 1;\r
+ int width = src.cols + 1, height = src.rows + 1;\r
\r
- sum.create(h, w, CV_32S);\r
- sqsum.create(h, w, CV_32F);\r
+ sum.create(height, width, CV_32S);\r
+ sqsum.create(height, width, CV_32F);\r
\r
NppiSize sz;\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiSqrIntegral_8u32s32f_C1R(const_cast<Npp8u*>(src.ptr<Npp8u>()), src.step, sum.ptr<Npp32s>(),\r
- sum.step, sqsum.ptr<Npp32f>(), sqsum.step, sz, 0, 0.0f, h) );\r
+ sum.step, sqsum.ptr<Npp32f>(), sqsum.step, sz, 0, 0.0f, height) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//////////////////////////////////////////////////////////////////////////////\r
// sqrIntegral\r
\r
-void cv::gpu::sqrIntegral(const GpuMat& src, GpuMat& sqsum)\r
+void cv::gpu::sqrIntegral(const GpuMat& src, GpuMat& sqsum, Stream& s)\r
{\r
CV_Assert(src.type() == CV_8U);\r
\r
nppSafeCall(nppiStSqrIntegralGetSize_8u64u(roiSize, &bufSize, prop)); \r
GpuMat buf(1, bufSize, CV_8U);\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStStreamHandler h(stream);\r
+\r
sqsum.create(src.rows + 1, src.cols + 1, CV_64F);\r
nppSafeCall(nppiStSqrIntegral_8u64u_C1R(const_cast<Ncv8u*>(src.ptr<Ncv8u>(0)), src.step, \r
sqsum.ptr<Ncv64u>(0), sqsum.step, roiSize, buf.ptr<Ncv8u>(0), bufSize, prop));\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
//////////////////////////////////////////////////////////////////////////////\r
imgproc::columnSum_32F(src, dst);\r
}\r
\r
-void cv::gpu::rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect)\r
+void cv::gpu::rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, const Rect& rect, Stream& s)\r
{\r
CV_Assert(src.type() == CV_32SC1 && sqr.type() == CV_32FC1);\r
\r
nppRect.x = rect.x;\r
nppRect.y = rect.y;\r
\r
+ cudaStream_t stream = StreamAccessor::getStream(s);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( nppiRectStdDev_32s32f_C1R(src.ptr<Npp32s>(), src.step, sqr.ptr<Npp32f>(), sqr.step,\r
dst.ptr<Npp32f>(), dst.step, sz, nppRect) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
-////////////////////////////////////////////////////////////////////////\r
-// Canny\r
-\r
-//void cv::gpu::Canny(const GpuMat& image, GpuMat& edges, double threshold1, double threshold2, int apertureSize)\r
-//{\r
-// CV_Assert(!"disabled until fix crash");\r
-//\r
-// GpuMat srcDx, srcDy;\r
-//\r
-// Sobel(image, srcDx, CV_32F, 1, 0, apertureSize);\r
-// Sobel(image, srcDy, CV_32F, 0, 1, apertureSize);\r
-//\r
-// GpuMat buf;\r
-//\r
-// Canny(srcDx, srcDy, edges, buf, threshold1, threshold2, apertureSize);\r
-//}\r
-//\r
-//void cv::gpu::Canny(const GpuMat& image, GpuMat& edges, GpuMat& buf, double threshold1, double threshold2, int apertureSize)\r
-//{\r
-// CV_Assert(!"disabled until fix crash");\r
-//\r
-// GpuMat srcDx, srcDy;\r
-//\r
-// Sobel(image, srcDx, CV_32F, 1, 0, apertureSize);\r
-// Sobel(image, srcDy, CV_32F, 0, 1, apertureSize);\r
-//\r
-// Canny(srcDx, srcDy, edges, buf, threshold1, threshold2, apertureSize);\r
-//}\r
-//\r
-//void cv::gpu::Canny(const GpuMat& srcDx, const GpuMat& srcDy, GpuMat& edges, double threshold1, double threshold2, int apertureSize)\r
-//{\r
-// CV_Assert(!"disabled until fix crash");\r
-//\r
-// GpuMat buf;\r
-// Canny(srcDx, srcDy, edges, buf, threshold1, threshold2, apertureSize);\r
-//}\r
-//\r
-//void cv::gpu::Canny(const GpuMat& srcDx, const GpuMat& srcDy, GpuMat& edges, GpuMat& buf, double threshold1, double threshold2, int apertureSize)\r
-//{\r
-// CV_Assert(!"disabled until fix crash");\r
-// CV_Assert(srcDx.type() == CV_32FC1 && srcDy.type() == CV_32FC1 && srcDx.size() == srcDy.size());\r
-//\r
-// edges.create(srcDx.size(), CV_8UC1);\r
-//\r
-// NppiSize sz;\r
-// sz.height = srcDx.rows;\r
-// sz.width = srcDx.cols;\r
-//\r
-// int bufsz;\r
-// nppSafeCall( nppiCannyGetBufferSize(sz, &bufsz) );\r
-// ensureSizeIsEnough(1, bufsz, CV_8UC1, buf);\r
-//\r
-// nppSafeCall( nppiCanny_32f8u_C1R(srcDx.ptr<Npp32f>(), srcDx.step, srcDy.ptr<Npp32f>(), srcDy.step,\r
-// edges.ptr<Npp8u>(), edges.step, sz, (Npp32f)threshold1, (Npp32f)threshold2, buf.ptr<Npp8u>()) );\r
-//\r
-// cudaSafeCall( cudaThreadSynchronize() );\r
-//}\r
\r
////////////////////////////////////////////////////////////////////////\r
// Histogram\r
{\r
typedef typename NppHistogramEvenFuncC1<SDEPTH>::src_t src_t;\r
\r
- static void hist(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel)\r
+ static void hist(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, cudaStream_t stream)\r
{\r
int levels = histSize + 1;\r
hist.create(1, histSize, CV_32S);\r
\r
get_buf_size(sz, levels, &buf_size);\r
buffer.create(1, buf_size, CV_8U);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<src_t>(), src.step, sz, hist.ptr<Npp32s>(), levels,\r
lowerLevel, upperLevel, buffer.ptr<Npp8u>()) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
template<int SDEPTH, typename NppHistogramEvenFuncC4<SDEPTH>::func_ptr func, get_buf_size_c4_t get_buf_size>\r
{\r
typedef typename NppHistogramEvenFuncC4<SDEPTH>::src_t src_t;\r
\r
- static void hist(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4])\r
+ static void hist(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], cudaStream_t stream)\r
{\r
int levels[] = {histSize[0] + 1, histSize[1] + 1, histSize[2] + 1, histSize[3] + 1};\r
hist[0].create(1, histSize[0], CV_32S);\r
\r
get_buf_size(sz, levels, &buf_size);\r
buffer.create(1, buf_size, CV_8U);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<src_t>(), src.step, sz, pHist, levels, lowerLevel, upperLevel, buffer.ptr<Npp8u>()) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
\r
typedef typename NppHistogramRangeFuncC1<SDEPTH>::level_t level_t;\r
enum {LEVEL_TYPE_CODE=NppHistogramRangeFuncC1<SDEPTH>::LEVEL_TYPE_CODE};\r
\r
- static void hist(const GpuMat& src, GpuMat& hist, const GpuMat& levels)\r
+ static void hist(const GpuMat& src, GpuMat& hist, const GpuMat& levels, cudaStream_t stream)\r
{\r
CV_Assert(levels.type() == LEVEL_TYPE_CODE && levels.rows == 1);\r
\r
\r
get_buf_size(sz, levels.cols, &buf_size);\r
buffer.create(1, buf_size, CV_8U);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<src_t>(), src.step, sz, hist.ptr<Npp32s>(), levels.ptr<level_t>(), levels.cols, buffer.ptr<Npp8u>()) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
template<int SDEPTH, typename NppHistogramRangeFuncC4<SDEPTH>::func_ptr func, get_buf_size_c4_t get_buf_size>\r
typedef typename NppHistogramRangeFuncC1<SDEPTH>::level_t level_t;\r
enum {LEVEL_TYPE_CODE=NppHistogramRangeFuncC1<SDEPTH>::LEVEL_TYPE_CODE};\r
\r
- static void hist(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4])\r
+ static void hist(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], cudaStream_t stream)\r
{\r
CV_Assert(levels[0].type() == LEVEL_TYPE_CODE && levels[0].rows == 1);\r
CV_Assert(levels[1].type() == LEVEL_TYPE_CODE && levels[1].rows == 1);\r
\r
get_buf_size(sz, nLevels, &buf_size);\r
buffer.create(1, buf_size, CV_8U);\r
+\r
+ NppStreamHandler h(stream);\r
+\r
nppSafeCall( func(src.ptr<src_t>(), src.step, sz, pHist, pLevels, nLevels, buffer.ptr<Npp8u>()) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ if (stream == 0)\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
}\r
levels.upload(host_levels);\r
}\r
\r
-void cv::gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel)\r
+void cv::gpu::histEven(const GpuMat& src, GpuMat& hist, int histSize, int lowerLevel, int upperLevel, Stream& stream)\r
{\r
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_16UC1 || src.type() == CV_16SC1 );\r
\r
- typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, int levels, int lowerLevel, int upperLevel);\r
+ typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, int levels, int lowerLevel, int upperLevel, cudaStream_t stream);\r
static const hist_t hist_callers[] =\r
{\r
NppHistogramEvenC1<CV_8U , nppiHistogramEven_8u_C1R , nppiHistogramEvenGetBufferSize_8u_C1R >::hist,\r
NppHistogramEvenC1<CV_16S, nppiHistogramEven_16s_C1R, nppiHistogramEvenGetBufferSize_16s_C1R>::hist\r
};\r
\r
- hist_callers[src.depth()](src, hist, histSize, lowerLevel, upperLevel);\r
+ hist_callers[src.depth()](src, hist, histSize, lowerLevel, upperLevel, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4])\r
+void cv::gpu::histEven(const GpuMat& src, GpuMat hist[4], int histSize[4], int lowerLevel[4], int upperLevel[4], Stream& stream)\r
{\r
CV_Assert(src.type() == CV_8UC4 || src.type() == CV_16UC4 || src.type() == CV_16SC4 );\r
\r
- typedef void (*hist_t)(const GpuMat& src, GpuMat hist[4], int levels[4], int lowerLevel[4], int upperLevel[4]);\r
+ typedef void (*hist_t)(const GpuMat& src, GpuMat hist[4], int levels[4], int lowerLevel[4], int upperLevel[4], cudaStream_t stream);\r
static const hist_t hist_callers[] =\r
{\r
NppHistogramEvenC4<CV_8U , nppiHistogramEven_8u_C4R , nppiHistogramEvenGetBufferSize_8u_C4R >::hist,\r
NppHistogramEvenC4<CV_16S, nppiHistogramEven_16s_C4R, nppiHistogramEvenGetBufferSize_16s_C4R>::hist\r
};\r
\r
- hist_callers[src.depth()](src, hist, histSize, lowerLevel, upperLevel);\r
+ hist_callers[src.depth()](src, hist, histSize, lowerLevel, upperLevel, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels)\r
+void cv::gpu::histRange(const GpuMat& src, GpuMat& hist, const GpuMat& levels, Stream& stream)\r
{\r
CV_Assert(src.type() == CV_8UC1 || src.type() == CV_16UC1 || src.type() == CV_16SC1 || src.type() == CV_32FC1);\r
\r
- typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, const GpuMat& levels);\r
+ typedef void (*hist_t)(const GpuMat& src, GpuMat& hist, const GpuMat& levels, cudaStream_t stream);\r
static const hist_t hist_callers[] =\r
{\r
NppHistogramRangeC1<CV_8U , nppiHistogramRange_8u_C1R , nppiHistogramRangeGetBufferSize_8u_C1R >::hist,\r
NppHistogramRangeC1<CV_32F, nppiHistogramRange_32f_C1R, nppiHistogramRangeGetBufferSize_32f_C1R>::hist\r
};\r
\r
- hist_callers[src.depth()](src, hist, levels);\r
+ hist_callers[src.depth()](src, hist, levels, StreamAccessor::getStream(stream));\r
}\r
\r
-void cv::gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4])\r
+void cv::gpu::histRange(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], Stream& stream)\r
{\r
CV_Assert(src.type() == CV_8UC4 || src.type() == CV_16UC4 || src.type() == CV_16SC4 || src.type() == CV_32FC4);\r
\r
- typedef void (*hist_t)(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4]);\r
+ typedef void (*hist_t)(const GpuMat& src, GpuMat hist[4], const GpuMat levels[4], cudaStream_t stream);\r
static const hist_t hist_callers[] =\r
{\r
NppHistogramRangeC4<CV_8U , nppiHistogramRange_8u_C4R , nppiHistogramRangeGetBufferSize_8u_C4R >::hist,\r
NppHistogramRangeC4<CV_32F, nppiHistogramRange_32f_C4R, nppiHistogramRangeGetBufferSize_32f_C4R>::hist\r
};\r
\r
- hist_callers[src.depth()](src, hist, levels);\r
+ hist_callers[src.depth()](src, hist, levels, StreamAccessor::getStream(stream));\r
}\r
\r
////////////////////////////////////////////////////////////////////////\r
CV_DbgAssert(!this->empty());\r
m.create(size(), type());\r
cudaSafeCall( cudaMemcpy2D(m.data, m.step, data, step, cols * elemSize(), rows, cudaMemcpyDeviceToDevice) );\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
void cv::gpu::GpuMat::copyTo( GpuMat& mat, const GpuMat& mask ) const\r
sz.height = src.rows;\r
nppSafeCall( func(src.ptr<src_t>(), src.step, dst.ptr<dst_t>(), dst.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
template<int DDEPTH, typename NppConvertFunc<CV_32F, DDEPTH>::func_ptr func> struct NppCvt<CV_32F, DDEPTH, func>\r
sz.height = src.rows;\r
nppSafeCall( func(src.ptr<Npp32f>(), src.step, dst.ptr<dst_t>(), dst.step, sz, NPP_RND_NEAR) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
\r
Scalar_<src_t> nppS = s;\r
nppSafeCall( func(nppS.val, src.ptr<src_t>(), src.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
template<int SDEPTH, typename NppSetFunc<SDEPTH, 1>::func_ptr func> struct NppSet<SDEPTH, 1, func>\r
Scalar_<src_t> nppS = s;\r
nppSafeCall( func(nppS[0], src.ptr<src_t>(), src.step, sz) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
\r
Scalar_<src_t> nppS = s;\r
nppSafeCall( func(nppS.val, src.ptr<src_t>(), src.step, sz, mask.ptr<Npp8u>(), mask.step) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
template<int SDEPTH, typename NppSetMaskFunc<SDEPTH, 1>::func_ptr func> struct NppSetMask<SDEPTH, 1, func>\r
Scalar_<src_t> nppS = s;\r
nppSafeCall( func(nppS[0], src.ptr<src_t>(), src.step, sz, mask.ptr<Npp8u>(), mask.step) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
};\r
\r
{\r
{NppSet<CV_8U, 1, nppiSet_8u_C1R>::set,kernelSet<uchar>,kernelSet<uchar>,NppSet<CV_8U, 4, nppiSet_8u_C4R>::set},\r
{kernelSet<schar>,kernelSet<schar>,kernelSet<schar>,kernelSet<schar>},\r
- {NppSet<CV_16U, 1, nppiSet_16u_C1R>::set,kernelSet<ushort>,kernelSet<ushort>,NppSet<CV_16U, 4, nppiSet_16u_C4R>::set},\r
- {NppSet<CV_16S, 1, nppiSet_16s_C1R>::set,kernelSet<short>,kernelSet<short>,NppSet<CV_16S, 4, nppiSet_16s_C4R>::set},\r
+ {NppSet<CV_16U, 1, nppiSet_16u_C1R>::set,NppSet<CV_16U, 2, nppiSet_16u_C2R>::set,kernelSet<ushort>,NppSet<CV_16U, 4, nppiSet_16u_C4R>::set},\r
+ {NppSet<CV_16S, 1, nppiSet_16s_C1R>::set,NppSet<CV_16S, 2, nppiSet_16s_C2R>::set,kernelSet<short>,NppSet<CV_16S, 4, nppiSet_16s_C4R>::set},\r
{NppSet<CV_32S, 1, nppiSet_32s_C1R>::set,kernelSet<int>,kernelSet<int>,NppSet<CV_32S, 4, nppiSet_32s_C4R>::set},\r
{NppSet<CV_32F, 1, nppiSet_32f_C1R>::set,kernelSet<float>,kernelSet<float>,NppSet<CV_32F, 4, nppiSet_32f_C4R>::set},\r
{kernelSet<double>,kernelSet<double>,kernelSet<double>,kernelSet<double>},\r
sz.width = src.cols;\r
sz.height = src.rows;\r
\r
-#if NPP_VERSION_MAJOR >= 4\r
-\r
DeviceBuffer dbuf(2);\r
\r
nppSafeCall( nppiMean_StdDev_8u_C1R(src.ptr<Npp8u>(), src.step, sz, dbuf, (double*)dbuf + 1) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
double* ptrs[2] = {mean.val, stddev.val};\r
dbuf.download(ptrs);\r
-\r
-#else\r
- \r
- nppSafeCall( nppiMean_StdDev_8u_C1R(src.ptr<Npp8u>(), src.step, sz, mean.val, stddev.val) );\r
-\r
- cudaSafeCall( cudaThreadSynchronize() );\r
-\r
-#endif\r
}\r
\r
\r
int funcIdx = normType >> 1;\r
\r
double retVal;\r
- \r
-#if NPP_VERSION_MAJOR >= 4\r
\r
DeviceBuffer dbuf;\r
\r
nppSafeCall( npp_norm_diff_func[funcIdx](src1.ptr<Npp8u>(), src1.step, src2.ptr<Npp8u>(), src2.step, sz, dbuf) );\r
\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
\r
dbuf.download(&retVal);\r
\r
-#else\r
-\r
- nppSafeCall( npp_norm_diff_func[funcIdx](src1.ptr<Npp8u>(), src1.step, src2.ptr<Npp8u>(), src2.step, sz, &retVal) );\r
-\r
- cudaSafeCall( cudaThreadSynchronize() );\r
-\r
-#endif \r
-\r
return retVal;\r
}\r
\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() ); \r
+ cudaSafeCall( cudaDeviceSynchronize() ); \r
}\r
\r
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() ); \r
+ cudaSafeCall( cudaDeviceSynchronize() ); \r
}\r
};\r
template<> struct TransformDispatcher<true>\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() );\r
+ cudaSafeCall( cudaDeviceSynchronize() );\r
}\r
\r
template <typename T1, typename T2, typename D, typename BinOp, typename Mask>\r
cudaSafeCall( cudaGetLastError() );\r
\r
if (stream == 0)\r
- cudaSafeCall( cudaThreadSynchronize() ); \r
+ cudaSafeCall( cudaDeviceSynchronize() ); \r
}\r
};\r
\r
#include "nvidia/NPP_staging/NPP_staging.hpp"\r
#include "nvidia/NCVHaarObjectDetection.hpp"\r
\r
-#define CUDART_MINIMUM_REQUIRED_VERSION 3020\r
-#define NPP_MINIMUM_REQUIRED_VERSION 3216\r
+#define CUDART_MINIMUM_REQUIRED_VERSION 4000\r
+#define NPP_MINIMUM_REQUIRED_VERSION 4000\r
\r
#if (CUDART_VERSION < CUDART_MINIMUM_REQUIRED_VERSION)\r
#error "Insufficient Cuda Runtime library version, please update it."\r
\r
#if !defined (HAVE_CUDA)\r
\r
-void cv::gpu::merge(const GpuMat* /*src*/, size_t /*count*/, GpuMat& /*dst*/) { throw_nogpu(); }\r
-void cv::gpu::merge(const vector<GpuMat>& /*src*/, GpuMat& /*dst*/) { throw_nogpu(); }\r
-void cv::gpu::merge(const GpuMat* /*src*/, size_t /*count*/, GpuMat& /*dst*/, const Stream& /*stream*/) { throw_nogpu(); }\r
-void cv::gpu::merge(const vector<GpuMat>& /*src*/, GpuMat& /*dst*/, const Stream& /*stream*/) { throw_nogpu(); }\r
-void cv::gpu::split(const GpuMat& /*src*/, GpuMat* /*dst*/) { throw_nogpu(); }\r
-void cv::gpu::split(const GpuMat& /*src*/, vector<GpuMat>& /*dst*/) { throw_nogpu(); }\r
-void cv::gpu::split(const GpuMat& /*src*/, GpuMat* /*dst*/, const Stream& /*stream*/) { throw_nogpu(); }\r
-void cv::gpu::split(const GpuMat& /*src*/, vector<GpuMat>& /*dst*/, const Stream& /*stream*/) { throw_nogpu(); }\r
+void cv::gpu::merge(const GpuMat* /*src*/, size_t /*count*/, GpuMat& /*dst*/, Stream& /*stream*/) { throw_nogpu(); }\r
+void cv::gpu::merge(const vector<GpuMat>& /*src*/, GpuMat& /*dst*/, Stream& /*stream*/) { throw_nogpu(); }\r
+void cv::gpu::split(const GpuMat& /*src*/, GpuMat* /*dst*/, Stream& /*stream*/) { throw_nogpu(); }\r
+void cv::gpu::split(const GpuMat& /*src*/, vector<GpuMat>& /*dst*/, Stream& /*stream*/) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
}}}\r
\r
\r
-void cv::gpu::merge(const GpuMat* src, size_t n, GpuMat& dst) \r
-{ \r
- split_merge::merge(src, n, dst, 0);\r
-}\r
-\r
-\r
-void cv::gpu::merge(const vector<GpuMat>& src, GpuMat& dst) \r
-{\r
- split_merge::merge(&src[0], src.size(), dst, 0);\r
-}\r
-\r
-\r
-void cv::gpu::merge(const GpuMat* src, size_t n, GpuMat& dst, const Stream& stream) \r
+void cv::gpu::merge(const GpuMat* src, size_t n, GpuMat& dst, Stream& stream) \r
{ \r
split_merge::merge(src, n, dst, StreamAccessor::getStream(stream));\r
}\r
\r
\r
-void cv::gpu::merge(const vector<GpuMat>& src, GpuMat& dst, const Stream& stream) \r
+void cv::gpu::merge(const vector<GpuMat>& src, GpuMat& dst, Stream& stream) \r
{\r
split_merge::merge(&src[0], src.size(), dst, StreamAccessor::getStream(stream));\r
}\r
\r
\r
-void cv::gpu::split(const GpuMat& src, GpuMat* dst) \r
-{\r
- split_merge::split(src, dst, 0);\r
-}\r
-\r
-\r
-void cv::gpu::split(const GpuMat& src, vector<GpuMat>& dst) \r
-{\r
- dst.resize(src.channels());\r
- if(src.channels() > 0)\r
- split_merge::split(src, &dst[0], 0);\r
-}\r
-\r
-\r
-void cv::gpu::split(const GpuMat& src, GpuMat* dst, const Stream& stream) \r
+void cv::gpu::split(const GpuMat& src, GpuMat* dst, Stream& stream) \r
{\r
split_merge::split(src, dst, StreamAccessor::getStream(stream));\r
}\r
\r
\r
-void cv::gpu::split(const GpuMat& src, vector<GpuMat>& dst, const Stream& stream) \r
+void cv::gpu::split(const GpuMat& src, vector<GpuMat>& dst, Stream& stream) \r
{\r
dst.resize(src.channels());\r
if(src.channels() > 0)\r
cv::gpu::StereoBM_GPU::StereoBM_GPU(int, int, int) { throw_nogpu(); }\r
\r
bool cv::gpu::StereoBM_GPU::checkIfGpuCallReasonable() { throw_nogpu(); return false; }\r
-void cv::gpu::StereoBM_GPU::operator() ( const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
-void cv::gpu::StereoBM_GPU::operator() ( const GpuMat&, const GpuMat&, GpuMat&, const Stream&) { throw_nogpu(); }\r
+void cv::gpu::StereoBM_GPU::operator() ( const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
\r
bm::postfilter_textureness(le_for_bm, winSize, avergeTexThreshold, disparity, stream);\r
}\r
\r
-\r
-void cv::gpu::StereoBM_GPU::operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity)\r
-{\r
- ::stereo_bm_gpu_operator(minSSD, leBuf, riBuf, preset, ndisp, winSize, avergeTexThreshold, left, right, disparity, 0);\r
-}\r
-\r
-void cv::gpu::StereoBM_GPU::operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, const Stream& stream)\r
+void cv::gpu::StereoBM_GPU::operator() ( const GpuMat& left, const GpuMat& right, GpuMat& disparity, Stream& stream)\r
{\r
::stereo_bm_gpu_operator(minSSD, leBuf, riBuf, preset, ndisp, winSize, avergeTexThreshold, left, right, disparity, StreamAccessor::getStream(stream));\r
}\r
cv::gpu::StereoBeliefPropagation::StereoBeliefPropagation(int, int, int, int) { throw_nogpu(); }\r
cv::gpu::StereoBeliefPropagation::StereoBeliefPropagation(int, int, int, float, float, float, float, int) { throw_nogpu(); }\r
\r
-void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
\r
-void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat&, GpuMat&) { throw_nogpu(); }\r
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
CV_Assert(rthis.msg_type == CV_32F || (1 << (rthis.levels - 1)) * scale * rthis.max_data_term < numeric_limits<short>::max());\r
}\r
\r
- void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disp, cudaStream_t stream)\r
+ void operator()(const GpuMat& left, const GpuMat& right, GpuMat& disp, Stream& stream)\r
{\r
typedef void (*comp_data_t)(const DevMem2D& left, const DevMem2D& right, const DevMem2D& data, cudaStream_t stream);\r
static const comp_data_t comp_data_callers[2][5] = \r
const int min_image_dim_size = 2;\r
CV_Assert(min(lowest_cols, lowest_rows) > min_image_dim_size);\r
\r
- init();\r
+ init(stream);\r
\r
datas[0].create(rows * rthis.ndisp, cols, rthis.msg_type);\r
\r
- comp_data_callers[rthis.msg_type == CV_32F][left.channels()](left, right, datas[0], stream);\r
+ comp_data_callers[rthis.msg_type == CV_32F][left.channels()](left, right, datas[0], StreamAccessor::getStream(stream));\r
\r
calcBP(disp, stream);\r
}\r
\r
- void operator()(const GpuMat& data, GpuMat& disp, cudaStream_t stream)\r
+ void operator()(const GpuMat& data, GpuMat& disp, Stream& stream)\r
{\r
CV_Assert((data.type() == rthis.msg_type) && (data.rows % rthis.ndisp == 0));\r
\r
const int min_image_dim_size = 2;\r
CV_Assert(min(lowest_cols, lowest_rows) > min_image_dim_size);\r
\r
- init();\r
+ init(stream);\r
\r
datas[0] = data;\r
\r
calcBP(disp, stream);\r
}\r
private:\r
- void init()\r
+ void init(Stream& stream)\r
{\r
u.create(rows * rthis.ndisp, cols, rthis.msg_type);\r
d.create(rows * rthis.ndisp, cols, rthis.msg_type);\r
if (rthis.levels & 1)\r
{\r
//can clear less area\r
- u = zero;\r
- d = zero;\r
- l = zero;\r
- r = zero;\r
+ if (stream)\r
+ {\r
+ stream.enqueueMemSet(u, zero);\r
+ stream.enqueueMemSet(d, zero);\r
+ stream.enqueueMemSet(l, zero);\r
+ stream.enqueueMemSet(r, zero);\r
+ }\r
+ else\r
+ {\r
+ u.setTo(zero);\r
+ d.setTo(zero);\r
+ l.setTo(zero);\r
+ r.setTo(zero);\r
+ }\r
}\r
\r
if (rthis.levels > 1)\r
\r
if ((rthis.levels & 1) == 0)\r
{\r
- u2 = zero;\r
- d2 = zero;\r
- l2 = zero;\r
- r2 = zero;\r
+ if (stream)\r
+ {\r
+ stream.enqueueMemSet(u2, zero);\r
+ stream.enqueueMemSet(d2, zero);\r
+ stream.enqueueMemSet(l2, zero);\r
+ stream.enqueueMemSet(r2, zero);\r
+ }\r
+ else\r
+ {\r
+ u2.setTo(zero);\r
+ d2.setTo(zero);\r
+ l2.setTo(zero);\r
+ r2.setTo(zero);\r
+ }\r
}\r
}\r
\r
rows_all[0] = rows;\r
}\r
\r
- void calcBP(GpuMat& disp, cudaStream_t stream)\r
+ void calcBP(GpuMat& disp, Stream& stream)\r
{\r
using namespace cv::gpu::bp;\r
\r
\r
const int funcIdx = rthis.msg_type == CV_32F;\r
\r
+ cudaStream_t cudaStream = StreamAccessor::getStream(stream);\r
+\r
for (int i = 1; i < rthis.levels; ++i)\r
{\r
cols_all[i] = (cols_all[i-1] + 1) / 2;\r
\r
datas[i].create(rows_all[i] * rthis.ndisp, cols_all[i], rthis.msg_type);\r
\r
- data_step_down_callers[funcIdx](cols_all[i], rows_all[i], rows_all[i-1], datas[i-1], datas[i], stream);\r
+ data_step_down_callers[funcIdx](cols_all[i], rows_all[i], rows_all[i-1], datas[i-1], datas[i], cudaStream);\r
}\r
\r
DevMem2D mus[] = {u, u2};\r
{\r
// for lower level we have already computed messages by setting to zero\r
if (i != rthis.levels - 1)\r
- level_up_messages_callers[funcIdx](mem_idx, cols_all[i], rows_all[i], rows_all[i+1], mus, mds, mls, mrs, stream);\r
+ level_up_messages_callers[funcIdx](mem_idx, cols_all[i], rows_all[i], rows_all[i+1], mus, mds, mls, mrs, cudaStream);\r
\r
- calc_all_iterations_callers[funcIdx](cols_all[i], rows_all[i], rthis.iters, mus[mem_idx], mds[mem_idx], mls[mem_idx], mrs[mem_idx], datas[i], stream);\r
+ calc_all_iterations_callers[funcIdx](cols_all[i], rows_all[i], rthis.iters, mus[mem_idx], mds[mem_idx], mls[mem_idx], mrs[mem_idx], datas[i], cudaStream);\r
\r
mem_idx = (mem_idx + 1) & 1;\r
}\r
disp.create(rows, cols, CV_16S);\r
\r
out = ((disp.type() == CV_16S) ? disp : (out.create(rows, cols, CV_16S), out));\r
- out = zero;\r
\r
- output_callers[funcIdx](u, d, l, r, datas.front(), out, stream);\r
+ if (stream)\r
+ stream.enqueueMemSet(out, zero);\r
+ else\r
+ out.setTo(zero);\r
+\r
+ output_callers[funcIdx](u, d, l, r, datas.front(), out, cudaStream);\r
\r
if (disp.type() != CV_16S)\r
- out.convertTo(disp, disp.type());\r
+ {\r
+ if (stream)\r
+ stream.enqueueConvert(out, disp, disp.type());\r
+ else\r
+ out.convertTo(disp, disp.type());\r
+ } \r
}\r
\r
StereoBeliefPropagation& rthis;\r
};\r
}\r
\r
-void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& left, const GpuMat& right, GpuMat& disp)\r
-{\r
- ::StereoBeliefPropagationImpl impl(*this, u, d, l, r, u2, d2, l2, r2, datas, out);\r
- impl(left, right, disp, 0);\r
-}\r
-\r
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& left, const GpuMat& right, GpuMat& disp, Stream& stream)\r
{\r
::StereoBeliefPropagationImpl impl(*this, u, d, l, r, u2, d2, l2, r2, datas, out);\r
- impl(left, right, disp, StreamAccessor::getStream(stream));\r
-}\r
-\r
-void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disp)\r
-{\r
- ::StereoBeliefPropagationImpl impl(*this, u, d, l, r, u2, d2, l2, r2, datas, out);\r
- impl(data, disp, 0);\r
+ impl(left, right, disp, stream);\r
}\r
\r
void cv::gpu::StereoBeliefPropagation::operator()(const GpuMat& data, GpuMat& disp, Stream& stream)\r
{\r
::StereoBeliefPropagationImpl impl(*this, u, d, l, r, u2, d2, l2, r2, datas, out);\r
- impl(data, disp, StreamAccessor::getStream(stream));\r
+ impl(data, disp, stream);\r
}\r
\r
#endif /* !defined (HAVE_CUDA) */\r
cv::gpu::StereoConstantSpaceBP::StereoConstantSpaceBP(int, int, int, int, int) { throw_nogpu(); }\r
cv::gpu::StereoConstantSpaceBP::StereoConstantSpaceBP(int, int, int, int, float, float, float, float, int, int) { throw_nogpu(); }\r
\r
-void cv::gpu::StereoConstantSpaceBP::operator()(const GpuMat&, const GpuMat&, GpuMat&) { throw_nogpu(); }\r
void cv::gpu::StereoConstantSpaceBP::operator()(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_nogpu(); }\r
\r
#else /* !defined (HAVE_CUDA) */\r
template<class T>\r
static void csbp_operator(StereoConstantSpaceBP& rthis, GpuMat u[2], GpuMat d[2], GpuMat l[2], GpuMat r[2],\r
GpuMat disp_selected_pyr[2], GpuMat& data_cost, GpuMat& data_cost_selected,\r
- GpuMat& temp, GpuMat& out, const GpuMat& left, const GpuMat& right, GpuMat& disp, cudaStream_t stream)\r
+ GpuMat& temp, GpuMat& out, const GpuMat& left, const GpuMat& right, GpuMat& disp, Stream& stream)\r
{\r
CV_DbgAssert(0 < rthis.ndisp && 0 < rthis.iters && 0 < rthis.levels && 0 < rthis.nr_plane\r
&& left.rows == right.rows && left.cols == right.cols && left.type() == right.type());\r
\r
const Scalar zero = Scalar::all(0);\r
\r
+ cudaStream_t cudaStream = StreamAccessor::getStream(stream);\r
+\r
////////////////////////////////////////////////////////////////////////////////////////////\r
// Init\r
\r
csbp::load_constants(rthis.ndisp, rthis.max_data_term, rthis.data_weight,\r
rthis.max_disc_term, rthis.disc_single_jump, rthis.min_disp_th, left, right, temp);\r
\r
- l[0] = zero;\r
- d[0] = zero;\r
- r[0] = zero;\r
- u[0] = zero;\r
-\r
- l[1] = zero;\r
- d[1] = zero;\r
- r[1] = zero;\r
- u[1] = zero;\r
-\r
- data_cost = zero;\r
- data_cost_selected = zero;\r
+ if (stream)\r
+ {\r
+ stream.enqueueMemSet(l[0], zero);\r
+ stream.enqueueMemSet(d[0], zero);\r
+ stream.enqueueMemSet(r[0], zero);\r
+ stream.enqueueMemSet(u[0], zero);\r
+ \r
+ stream.enqueueMemSet(l[1], zero);\r
+ stream.enqueueMemSet(d[1], zero);\r
+ stream.enqueueMemSet(r[1], zero);\r
+ stream.enqueueMemSet(u[1], zero);\r
+\r
+ stream.enqueueMemSet(data_cost, zero);\r
+ stream.enqueueMemSet(data_cost_selected, zero);\r
+ }\r
+ else\r
+ {\r
+ l[0].setTo(zero);\r
+ d[0].setTo(zero);\r
+ r[0].setTo(zero);\r
+ u[0].setTo(zero);\r
+\r
+ l[1].setTo(zero);\r
+ d[1].setTo(zero);\r
+ r[1].setTo(zero);\r
+ u[1].setTo(zero);\r
+\r
+ data_cost.setTo(zero);\r
+ data_cost_selected.setTo(zero);\r
+ }\r
\r
int cur_idx = 0;\r
\r
if (i == levels - 1)\r
{\r
csbp::init_data_cost(left.rows, left.cols, disp_selected_pyr[cur_idx].ptr<T>(), data_cost_selected.ptr<T>(),\r
- step_pyr[i], rows_pyr[i], cols_pyr[i], i, nr_plane_pyr[i], rthis.ndisp, left.channels(), rthis.use_local_init_data_cost, stream);\r
+ step_pyr[i], rows_pyr[i], cols_pyr[i], i, nr_plane_pyr[i], rthis.ndisp, left.channels(), rthis.use_local_init_data_cost, cudaStream);\r
}\r
else\r
{\r
csbp::compute_data_cost(disp_selected_pyr[cur_idx].ptr<T>(), data_cost.ptr<T>(), step_pyr[i], step_pyr[i+1],\r
- left.rows, left.cols, rows_pyr[i], cols_pyr[i], rows_pyr[i+1], i, nr_plane_pyr[i+1], left.channels(), stream);\r
+ left.rows, left.cols, rows_pyr[i], cols_pyr[i], rows_pyr[i+1], i, nr_plane_pyr[i+1], left.channels(), cudaStream);\r
\r
int new_idx = (cur_idx + 1) & 1;\r
\r
u[cur_idx].ptr<T>(), d[cur_idx].ptr<T>(), l[cur_idx].ptr<T>(), r[cur_idx].ptr<T>(),\r
disp_selected_pyr[new_idx].ptr<T>(), disp_selected_pyr[cur_idx].ptr<T>(),\r
data_cost_selected.ptr<T>(), data_cost.ptr<T>(), step_pyr[i], step_pyr[i+1], rows_pyr[i],\r
- cols_pyr[i], nr_plane_pyr[i], rows_pyr[i+1], cols_pyr[i+1], nr_plane_pyr[i+1], stream);\r
+ cols_pyr[i], nr_plane_pyr[i], rows_pyr[i+1], cols_pyr[i+1], nr_plane_pyr[i+1], cudaStream);\r
\r
cur_idx = new_idx;\r
}\r
\r
csbp::calc_all_iterations(u[cur_idx].ptr<T>(), d[cur_idx].ptr<T>(), l[cur_idx].ptr<T>(), r[cur_idx].ptr<T>(),\r
data_cost_selected.ptr<T>(), disp_selected_pyr[cur_idx].ptr<T>(), step_pyr[i],\r
- rows_pyr[i], cols_pyr[i], nr_plane_pyr[i], rthis.iters, stream);\r
+ rows_pyr[i], cols_pyr[i], nr_plane_pyr[i], rthis.iters, cudaStream);\r
}\r
\r
if (disp.empty())\r
disp.create(rows, cols, CV_16S);\r
\r
out = ((disp.type() == CV_16S) ? disp : (out.create(rows, cols, CV_16S), out));\r
- out = zero;\r
+\r
+ if (stream)\r
+ stream.enqueueMemSet(out, zero);\r
+ else\r
+ out.setTo(zero);\r
\r
csbp::compute_disp(u[cur_idx].ptr<T>(), d[cur_idx].ptr<T>(), l[cur_idx].ptr<T>(), r[cur_idx].ptr<T>(),\r
- data_cost_selected.ptr<T>(), disp_selected_pyr[cur_idx].ptr<T>(), step_pyr[0], out, nr_plane_pyr[0], stream);\r
+ data_cost_selected.ptr<T>(), disp_selected_pyr[cur_idx].ptr<T>(), step_pyr[0], out, nr_plane_pyr[0], cudaStream);\r
\r
if (disp.type() != CV_16S)\r
- out.convertTo(disp, disp.type());\r
+ {\r
+ if (stream)\r
+ stream.enqueueConvert(out, disp, disp.type());\r
+ else\r
+ out.convertTo(disp, disp.type());\r
+ }\r
}\r
\r
\r
typedef void (*csbp_operator_t)(StereoConstantSpaceBP& rthis, GpuMat u[2], GpuMat d[2], GpuMat l[2], GpuMat r[2],\r
GpuMat disp_selected_pyr[2], GpuMat& data_cost, GpuMat& data_cost_selected,\r
- GpuMat& temp, GpuMat& out, const GpuMat& left, const GpuMat& right, GpuMat& disp, cudaStream_t stream);\r
+ GpuMat& temp, GpuMat& out, const GpuMat& left, const GpuMat& right, GpuMat& disp, Stream& stream);\r
\r
const static csbp_operator_t operators[] = {0, 0, 0, csbp_operator<short>, 0, csbp_operator<float>, 0, 0};\r
\r
-void cv::gpu::StereoConstantSpaceBP::operator()(const GpuMat& left, const GpuMat& right, GpuMat& disp)\r
-{\r
- CV_Assert(msg_type == CV_32F || msg_type == CV_16S);\r
- operators[msg_type](*this, u, d, l, r, disp_selected_pyr, data_cost, data_cost_selected, temp, out, left, right, disp, 0);\r
-}\r
-\r
void cv::gpu::StereoConstantSpaceBP::operator()(const GpuMat& left, const GpuMat& right, GpuMat& disp, Stream& stream)\r
{\r
CV_Assert(msg_type == CV_32F || msg_type == CV_16S);\r
- operators[msg_type](*this, u, d, l, r, disp_selected_pyr, data_cost, data_cost_selected, temp, out, left, right, disp, StreamAccessor::getStream(stream));\r
+ operators[msg_type](*this, u, d, l, r, disp_selected_pyr, data_cost, data_cost_selected, temp, out, left, right, disp, stream);\r
}\r
\r
#endif /* !defined (HAVE_CUDA) */\r