Merge branch 'gpu-tests'

This commit is contained in:
Vladislav Vinogradov 2012-08-20 11:29:40 +04:00
commit 3956e42507
57 changed files with 5056 additions and 7741 deletions

View File

@ -509,8 +509,6 @@ endmacro()
macro(ocv_add_precompiled_headers the_target)
if("${the_target}" MATCHES "^opencv_test_.*$")
SET(pch_path "test/test_")
elseif("${the_target}" MATCHES "opencv_perf_gpu_cpu")
SET(pch_path "perf_cpu/perf_cpu_")
elseif("${the_target}" MATCHES "^opencv_perf_.*$")
SET(pch_path "perf/perf_")
else()

View File

@ -111,43 +111,3 @@ ocv_add_accuracy_tests(FILES "Include" ${test_hdrs}
FILES "Src" ${test_srcs}
${nvidia})
ocv_add_perf_tests()
set(perf_cpu_path "${CMAKE_CURRENT_SOURCE_DIR}/perf_cpu")
if(BUILD_PERF_TESTS AND EXISTS "${perf_cpu_path}")
# opencv_highgui is required for imread/imwrite
set(perf_deps ${the_module} opencv_ts opencv_highgui opencv_imgproc opencv_calib3d opencv_objdetect opencv_video opencv_nonfree)
ocv_check_dependencies(${perf_deps})
if(OCV_DEPENDENCIES_FOUND)
set(the_target "opencv_perf_gpu_cpu")
ocv_module_include_directories(${perf_deps} "${perf_cpu_path}")
if(NOT OPENCV_PERF_${the_module}_CPU_SOURCES)
file(GLOB perf_srcs "${perf_cpu_path}/*.cpp")
file(GLOB perf_hdrs "${perf_cpu_path}/*.hpp" "${perf_cpu_path}/*.h")
source_group("Src" FILES ${perf_srcs})
source_group("Include" FILES ${perf_hdrs})
set(OPENCV_PERF_${the_module}_CPU_SOURCES ${perf_srcs} ${perf_hdrs})
endif()
add_executable(${the_target} ${OPENCV_PERF_${the_module}_CPU_SOURCES})
target_link_libraries(${the_target} ${OPENCV_MODULE_${the_module}_DEPS} ${perf_deps} ${OPENCV_LINKER_LIBS})
# Additional target properties
set_target_properties(${the_target} PROPERTIES
DEBUG_POSTFIX "${OPENCV_DEBUG_POSTFIX}"
RUNTIME_OUTPUT_DIRECTORY "${EXECUTABLE_OUTPUT_PATH}"
)
if(ENABLE_SOLUTION_FOLDERS)
set_target_properties(${the_target} PROPERTIES FOLDER "tests performance")
endif()
ocv_add_precompiled_headers(${the_target})
else(OCV_DEPENDENCIES_FOUND)
#TODO: warn about unsatisfied dependencies
endif(OCV_DEPENDENCIES_FOUND)
endif()

View File

@ -1,255 +1,234 @@
import sys, re
spaces = '[\s]*'
symbols = '[\s\w\d,.=:|]*'
symbols = '[\s\w\d,.:|]*'
def pattern1(prefix, test):
return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + '\)' + spaces)
return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + '\)' + spaces)
def pattern2(prefix, test, cvtype):
return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + cvtype + symbols + '\)' + spaces)
def pattern2(prefix, test, param1):
return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + '\)' + spaces)
def pattern3(prefix, test, cvtype, param1):
return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + cvtype + symbols + param1 + symbols + '\)' + spaces)
def pattern3(prefix, test, param1, param2):
return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + param2 + symbols + '\)' + spaces)
def pattern4(prefix, test, cvtype, param1, param2):
return re.compile(spaces + 'perf::' + prefix + '/' + test + '::' + '\(' + symbols + cvtype + symbols + param1 + symbols + param2 + symbols + '\)' + spaces)
def pattern4(prefix, test, param1, param2, param3):
return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + param2 + symbols + param3 + symbols + '\)' + spaces)
def pattern5(prefix, test, param1, param2, param3, param5):
return re.compile(spaces + prefix + '_' + test + '::' + symbols + '::' + '\(' + symbols + param1 + symbols + param2 + symbols + param3 + symbols + param4 + symbols + '\)' + spaces)
npp_patterns = [
##############################################################
# Core
# Core/Add_Mat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Add_Mat', '8U'),
pattern2('Core', 'Add_Mat', '16U'),
pattern2('Core', 'Add_Mat', '32F'),
# Core/Add_Scalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Add_Scalar', '8U'),
pattern2('Core', 'Add_Scalar', '16U'),
pattern2('Core', 'Add_Scalar', '32F'),
# Core/Subtract_Mat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Subtract_Mat', '8U'),
pattern2('Core', 'Subtract_Mat', '16U'),
pattern2('Core', 'Subtract_Mat', '32F'),
# Core/Subtract_Scalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Subtract_Scalar', '8U'),
pattern2('Core', 'Subtract_Scalar', '16U'),
pattern2('Core', 'Subtract_Scalar', '32F'),
# Core/Multiply_Mat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Multiply_Mat', '8U'),
pattern2('Core', 'Multiply_Mat', '16U'),
pattern2('Core', 'Multiply_Mat', '32F'),
# Core/Multiply_Scalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Multiply_Scalar', '8U'),
pattern2('Core', 'Multiply_Scalar', '16U'),
pattern2('Core', 'Multiply_Scalar', '32F'),
# Core/Divide_Mat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Divide_Mat', '8U'),
pattern2('Core', 'Divide_Mat', '16U'),
pattern2('Core', 'Divide_Mat', '32F'),
# Core/Divide_Scalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'Divide_Scalar', '8U'),
pattern2('Core', 'Divide_Scalar', '16U'),
pattern2('Core', 'Divide_Scalar', '32F'),
# Core/AbsDiff_Mat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'AbsDiff_Mat', '8U'),
pattern2('Core', 'AbsDiff_Mat', '16U'),
pattern2('Core', 'AbsDiff_Mat', '32F'),
# Core/AbsDiff_Scalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'AbsDiff_Scalar', '8U'),
pattern2('Core', 'AbsDiff_Scalar', '16U'),
pattern2('Core', 'AbsDiff_Scalar', '32F'),
# Core/Abs
# Core_AddMat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'AddMat', '8U'),
pattern2('Core', 'AddMat', '16U'),
pattern2('Core', 'AddMat', '32F'),
# Core_AddScalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'AddScalar', '8U'),
pattern2('Core', 'AddScalar', '16U'),
pattern2('Core', 'AddScalar', '32F'),
# Core_SubtractMat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'SubtractMat', '8U'),
pattern2('Core', 'SubtractMat', '16U'),
pattern2('Core', 'SubtractMat', '32F'),
# Core_SubtractScalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'SubtractScalar', '8U'),
pattern2('Core', 'SubtractScalar', '16U'),
pattern2('Core', 'SubtractScalar', '32F'),
# Core_MultiplyMat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'MultiplyMat', '8U'),
pattern2('Core', 'MultiplyMat', '16U'),
pattern2('Core', 'MultiplyMat', '32F'),
# Core_MultiplyScalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'MultiplyScalar', '8U'),
pattern2('Core', 'MultiplyScalar', '16U'),
pattern2('Core', 'MultiplyScalar', '32F'),
# Core_DivideMat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'DivideMat', '8U'),
pattern2('Core', 'DivideMat', '16U'),
pattern2('Core', 'DivideMat', '32F'),
# Core_Divide_Scalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'DivideScalar', '8U'),
pattern2('Core', 'DivideScalar', '16U'),
pattern2('Core', 'DivideScalar', '32F'),
# Core_AbsDiff_Mat (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'AbsDiffMat', '8U'),
pattern2('Core', 'AbsDiffMat', '16U'),
pattern2('Core', 'AbsDiffMat', '32F'),
# Core_AbsDiffScalar (CV_8U | CV_16U | CV_32F)
pattern2('Core', 'AbsDiffScalar', '8U'),
pattern2('Core', 'AbsDiffScalar', '16U'),
pattern2('Core', 'AbsDiffScalar', '32F'),
# Core_Abs
pattern1('Core', 'Abs'),
# Core/Sqr
# Core_Sqr
pattern1('Core', 'Sqr'),
# Core/Sqrt
# Core_Sqrt
pattern1('Core', 'Sqrt'),
# Core/Log
# Core_Log
pattern1('Core', 'Log'),
# Core/Exp
# Core_Exp
pattern1('Core', 'Exp'),
# Core/Bitwise_And_Scalar
pattern1('Core', 'Bitwise_And_Scalar'),
# Core_BitwiseAndScalar
pattern1('Core', 'BitwiseAndScalar'),
# Core/Bitwise_Or_Scalar
pattern1('Core', 'Bitwise_Or_Scalar'),
# Core_BitwiseOrScalar
pattern1('Core', 'BitwiseOrScalar'),
# Core/Bitwise_Xor_Scalar
pattern1('Core', 'Bitwise_Xor_Scalar'),
# Core_BitwiseXorScalar
pattern1('Core', 'BitwiseXorScalar'),
# Core/RShift
# Core_RShift
pattern1('Core', 'RShift'),
# Core/LShift
# Core_LShift
pattern1('Core', 'LShift'),
# Core/Transpose
# Core_Transpose
pattern1('Core', 'Transpose'),
# Core/Flip
# Core_Flip
pattern1('Core', 'Flip'),
# Core/LUT_OneChannel
pattern1('Core', 'LUT_OneChannel'),
# Core_LutOneChannel
pattern1('Core', 'LutOneChannel'),
# Core/LUT_MultiChannel
pattern1('Core', 'LUT_MultiChannel'),
# Core_LutMultiChannel
pattern1('Core', 'LutMultiChannel'),
# Core/Magnitude_Complex
pattern1('Core', 'Magnitude_Complex'),
# Core_MagnitudeComplex
pattern1('Core', 'MagnitudeComplex'),
# Core/Magnitude_Sqr_Complex
pattern1('Core', 'Magnitude_Sqr_Complex'),
# Core_MagnitudeSqrComplex
pattern1('Core', 'MagnitudeSqrComplex'),
# Core/MeanStdDev
# Core_MeanStdDev
pattern1('Core', 'MeanStdDev'),
# Core/NormDiff
# Core_NormDiff
pattern1('Core', 'NormDiff'),
##############################################################
# Filters
# Filters/Blur
# Filters_Blur
pattern1('Filters', 'Blur'),
# Filters/Erode
# Filters_Erode
pattern1('Filters', 'Erode'),
# Filters/Dilate
# Filters_Dilate
pattern1('Filters', 'Dilate'),
# Filters/MorphologyEx
# Filters_MorphologyEx
pattern1('Filters', 'MorphologyEx'),
##############################################################
# ImgProc
# ImgProc/Resize (8UC1 | 8UC4, INTER_NEAREST | INTER_LINEAR)
pattern3('ImgProc', 'Resize', '8UC1', 'INTER_NEAREST'),
pattern3('ImgProc', 'Resize', '8UC4', 'INTER_NEAREST'),
pattern3('ImgProc', 'Resize', '8UC1', 'INTER_LINEAR'),
pattern3('ImgProc', 'Resize', '8UC4', 'INTER_LINEAR'),
# ImgProc/Resize (8UC4, INTER_CUBIC)
pattern3('ImgProc', 'Resize', '8UC4', 'INTER_CUBIC'),
# ImgProc/WarpAffine (8UC1 | 8UC3 | 8UC4 | 32FC1 | 32FC3 | 32FC4, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT)
pattern4('ImgProc', 'WarpAffine', '8UC1', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC1', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC1', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC3', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC3', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC3', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC4', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC4', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8UC4', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC1', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC1', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC1', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC3', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC3', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC3', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC4', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC4', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32FC4', 'INTER_CUBIC', 'BORDER_CONSTANT'),
# ImgProc/WarpPerspective (8UC1 | 8UC3 | 8UC4 | 32FC1 | 32FC3 | 32FC4, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT)
pattern4('ImgProc', 'WarpPerspective', '8UC1', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC1', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC1', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC3', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC3', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC3', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC4', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC4', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8UC4', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC1', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC1', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC1', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC3', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC3', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC3', 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC4', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC4', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32FC4', 'INTER_CUBIC', 'BORDER_CONSTANT'),
# ImgProc/CopyMakeBorder (8UC1 | 8UC4 | 32SC1 | 32FC1, BORDER_CONSTANT)
pattern3('ImgProc', 'CopyMakeBorder', '8UC1', 'BORDER_CONSTANT'),
pattern3('ImgProc', 'CopyMakeBorder', '8UC4', 'BORDER_CONSTANT'),
pattern3('ImgProc', 'CopyMakeBorder', '32SC1', 'BORDER_CONSTANT'),
pattern3('ImgProc', 'CopyMakeBorder', '32FC1', 'BORDER_CONSTANT'),
# ImgProc/Threshold (32F, THRESH_TRUNC)
# ImgProc_Resize (8U, 1 | 4, INTER_NEAREST | INTER_LINEAR)
pattern4('ImgProc', 'Resize', '8U', '1', 'INTER_NEAREST'),
pattern4('ImgProc', 'Resize', '8U', '4', 'INTER_NEAREST'),
pattern4('ImgProc', 'Resize', '8U', '1', 'INTER_LINEAR'),
pattern4('ImgProc', 'Resize', '8U', '4', 'INTER_LINEAR'),
# ImgProc_Resize (8U, 4, INTER_CUBIC)
pattern4('ImgProc', 'Resize', '8U', '4', 'INTER_CUBIC'),
# ImgProc_WarpAffine (8U | 32F, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT)
pattern4('ImgProc', 'WarpAffine', '8U' , 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8U' , 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '8U' , 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32F', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32F', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpAffine', '32F', 'INTER_CUBIC', 'BORDER_CONSTANT'),
# ImgProc_WarpPerspective (8U | 32F, INTER_NEAREST | INTER_LINEAR | INTER_CUBIC, BORDER_CONSTANT)
pattern4('ImgProc', 'WarpPerspective', '8U' , 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8U' , 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '8U' , 'INTER_CUBIC', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32F', 'INTER_NEAREST', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32F', 'INTER_LINEAR', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'WarpPerspective', '32F', 'INTER_CUBIC', 'BORDER_CONSTANT'),
# ImgProc_CopyMakeBorder (8UC1 | 8UC4 | 32SC1 | 32FC1, BORDER_CONSTANT)
pattern4('ImgProc', 'CopyMakeBorder', '8U' , '1', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'CopyMakeBorder', '8U' , '4', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'CopyMakeBorder', '32S', '1', 'BORDER_CONSTANT'),
pattern4('ImgProc', 'CopyMakeBorder', '32F', '1', 'BORDER_CONSTANT'),
# ImgProc_Threshold (32F, THRESH_TRUNC)
pattern3('ImgProc', 'Threshold', '32F', 'THRESH_TRUNC'),
# ImgProc/Integral_Sqr
pattern1('ImgProc', 'Integral_Sqr'),
# ImgProc_IntegralSqr
pattern1('ImgProc', 'IntegralSqr'),
# ImgProc/HistEven_OneChannel
pattern1('ImgProc', 'HistEven_OneChannel'),
# ImgProc_HistEven_OneChannel
pattern1('ImgProc', 'HistEvenOneChannel'),
# ImgProc/HistEven_FourChannel
pattern1('ImgProc', 'HistEven_FourChannel'),
# ImgProc_HistEven_FourChannel
pattern1('ImgProc', 'HistEvenFourChannel'),
# ImgProc/Rotate
# ImgProc_Rotate
pattern1('ImgProc', 'Rotate'),
# ImgProc/SwapChannels
# ImgProc_SwapChannels
pattern1('ImgProc', 'SwapChannels'),
# ImgProc/AlphaComp
# ImgProc_AlphaComp
pattern1('ImgProc', 'AlphaComp'),
# ImgProc/ImagePyramid_build
pattern1('ImgProc', 'ImagePyramid_build'),
# ImgProc_ImagePyramidBuild
pattern1('ImgProc', 'ImagePyramidBuild'),
# ImgProc_ImagePyramid_getLayer
pattern1('ImgProc', 'ImagePyramidGetLayer'),
# ImgProc/ImagePyramid_getLayer
pattern1('ImgProc', 'ImagePyramid_getLayer'),
##############################################################
# MatOp
# MatOp/SetTo (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4)
pattern2('MatOp', 'SetTo', '8UC4'),
pattern2('MatOp', 'SetTo', '16UC1'),
pattern2('MatOp', 'SetTo', '16UC4'),
pattern2('MatOp', 'SetTo', '32FC1'),
pattern2('MatOp', 'SetTo', '32FC4'),
# MatOp/SetToMasked (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4)
pattern2('MatOp', 'SetToMasked', '8UC4'),
pattern2('MatOp', 'SetToMasked', '16UC1'),
pattern2('MatOp', 'SetToMasked', '16UC4'),
pattern2('MatOp', 'SetToMasked', '32FC1'),
pattern2('MatOp', 'SetToMasked', '32FC4'),
# MatOp/CopyToMasked (8UC1 | 8UC3 |8UC4 | 16UC1 | 16UC3 | 16UC4 | 32FC1 | 32FC3 | 32FC4)
pattern2('MatOp', 'CopyToMasked', '8UC1'),
pattern2('MatOp', 'CopyToMasked', '8UC3'),
pattern2('MatOp', 'CopyToMasked', '8UC4'),
pattern2('MatOp', 'CopyToMasked', '16UC1'),
pattern2('MatOp', 'CopyToMasked', '16UC3'),
pattern2('MatOp', 'CopyToMasked', '16UC4'),
pattern2('MatOp', 'CopyToMasked', '32FC1'),
pattern2('MatOp', 'CopyToMasked', '32FC3'),
pattern2('MatOp', 'CopyToMasked', '32FC4'),
# MatOp_SetTo (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4)
pattern3('MatOp', 'SetTo', '8U' , '4'),
pattern3('MatOp', 'SetTo', '16U', '1'),
pattern3('MatOp', 'SetTo', '16U', '4'),
pattern3('MatOp', 'SetTo', '32F', '1'),
pattern3('MatOp', 'SetTo', '32F', '4'),
# MatOp_SetToMasked (8UC4 | 16UC1 | 16UC4 | 32FC1 | 32FC4)
pattern3('MatOp', 'SetToMasked', '8U' , '4'),
pattern3('MatOp', 'SetToMasked', '16U', '1'),
pattern3('MatOp', 'SetToMasked', '16U', '4'),
pattern3('MatOp', 'SetToMasked', '32F', '1'),
pattern3('MatOp', 'SetToMasked', '32F', '4'),
# MatOp_CopyToMasked (8UC1 | 8UC3 |8UC4 | 16UC1 | 16UC3 | 16UC4 | 32FC1 | 32FC3 | 32FC4)
pattern3('MatOp', 'CopyToMasked', '8U' , '1'),
pattern3('MatOp', 'CopyToMasked', '8U' , '3'),
pattern3('MatOp', 'CopyToMasked', '8U' , '4'),
pattern3('MatOp', 'CopyToMasked', '16U', '1'),
pattern3('MatOp', 'CopyToMasked', '16U', '3'),
pattern3('MatOp', 'CopyToMasked', '16U', '4'),
pattern3('MatOp', 'CopyToMasked', '32F', '1'),
pattern3('MatOp', 'CopyToMasked', '32F', '3'),
pattern3('MatOp', 'CopyToMasked', '32F', '4'),
]
cublasPattern = pattern1('Core', 'GEMM')
@ -260,7 +239,7 @@ if __name__ == "__main__":
inputFile = open(sys.argv[1], 'r')
lines = inputFile.readlines()
inputFile.close()
for i in range(len(lines)):
if cublasPattern.match(lines[i]):

125
modules/gpu/perf/main.cpp Normal file
View File

@ -0,0 +1,125 @@
#include "perf_precomp.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
void printOsInfo()
{
#if defined _WIN32
# if defined _WIN64
cout << "OS: Windows x64 \n" << endl;
# else
cout << "OS: Windows x32 \n" << endl;
# endif
#elif defined linux
# if defined _LP64
cout << "OS: Linux x64 \n" << endl;
# else
cout << "OS: Linux x32 \n" << endl;
# endif
#elif defined __APPLE__
# if defined _LP64
cout << "OS: Apple x64 \n" << endl;
# else
cout << "OS: Apple x32 \n" << endl;
# endif
#endif
}
void printCudaInfo()
{
#ifndef HAVE_CUDA
cout << "OpenCV was built without CUDA support \n" << endl;
#else
int driver;
cudaDriverGetVersion(&driver);
cout << "CUDA Driver version: " << driver << '\n';
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n';
cout << endl;
cout << "GPU module was compiled for the following GPU archs:" << endl;
cout << " BIN: " << CUDA_ARCH_BIN << '\n';
cout << " PTX: " << CUDA_ARCH_PTX << '\n';
cout << endl;
int deviceCount = getCudaEnabledDeviceCount();
cout << "CUDA device count: " << deviceCount << '\n';
cout << endl;
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
cout << "Device [" << i << "] \n";
cout << "\t Name: " << info.name() << '\n';
cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n';
cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\n';
cout << "\t Total memory: " << static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0) << " Mb \n";
cout << "\t Free memory: " << static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n";
if (!info.isCompatible())
cout << "\t !!! This device is NOT compatible with current GPU module build \n";
cout << endl;
}
#endif
}
int main(int argc, char** argv)
{
CommandLineParser cmd(argc, (const char**) argv,
"{ print_info_only | print_info_only | false | Print information about system and exit }"
"{ device | device | 0 | Device on which tests will be executed }"
"{ cpu | cpu | false | Run tests on cpu }"
);
printOsInfo();
printCudaInfo();
if (cmd.get<bool>("print_info_only"))
return 0;
int device = cmd.get<int>("device");
bool cpu = cmd.get<bool>("cpu");
#ifndef HAVE_CUDA
cpu = true;
#endif
if (cpu)
{
runOnGpu = false;
cout << "Run tests on CPU \n" << endl;
}
else
{
runOnGpu = true;
if (device < 0 || device >= getCudaEnabledDeviceCount())
{
cerr << "Incorrect device index - " << device << endl;
return -1;
}
DeviceInfo info(device);
if (!info.isCompatible())
{
cerr << "Device " << device << " [" << info.name() << "] is NOT compatible with current GPU module build" << endl;
return -1;
}
setDevice(device);
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
}
InitGoogleTest(&argc, argv);
perf::TestBase::Init(argc, argv);
return RUN_ALL_TESTS();
}

View File

@ -1,219 +1,263 @@
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
using namespace std;
using namespace testing;
namespace {
//////////////////////////////////////////////////////////////////////
// StereoBM
GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo)
typedef pair<string, string> pair_string;
DEF_PARAM_TEST_1(ImagePair, pair_string);
PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(make_pair<string, string>("gpu/perf/aloe.jpg", "gpu/perf/aloeR.jpg")))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img_l_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
cv::Mat img_r_host = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_r_host.empty());
cv::gpu::StereoBM_GPU bm(0, 256);
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
cv::gpu::GpuMat dst;
bm(img_l, img_r, dst);
declare.time(5.0);
TEST_CYCLE()
const cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(imgLeft.empty());
const cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(imgRight.empty());
const int preset = 0;
const int ndisp = 256;
if (runOnGpu)
{
bm(img_l, img_r, dst);
cv::gpu::StereoBM_GPU d_bm(preset, ndisp);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_bm(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
{
d_bm(d_imgLeft, d_imgRight, d_dst);
}
}
else
{
cv::StereoBM bm(preset, ndisp);
cv::Mat dst;
bm(imgLeft, imgRight, dst);
TEST_CYCLE()
{
bm(imgLeft, imgRight, dst);
}
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// StereoBeliefPropagation
GPU_PERF_TEST_1(StereoBeliefPropagation, cv::gpu::DeviceInfo)
PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(make_pair<string, string>("gpu/stereobp/aloe-L.png", "gpu/stereobp/aloe-R.png")))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img_l_host = readImage("gpu/stereobp/aloe-L.png");
ASSERT_FALSE(img_l_host.empty());
cv::Mat img_r_host = readImage("gpu/stereobp/aloe-R.png");
ASSERT_FALSE(img_r_host.empty());
cv::gpu::StereoBeliefPropagation bp(64);
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
cv::gpu::GpuMat dst;
bp(img_l, img_r, dst);
declare.time(10.0);
TEST_CYCLE()
const cv::Mat imgLeft = readImage(GetParam().first);
ASSERT_FALSE(imgLeft.empty());
const cv::Mat imgRight = readImage(GetParam().second);
ASSERT_FALSE(imgRight.empty());
const int ndisp = 64;
if (runOnGpu)
{
bp(img_l, img_r, dst);
cv::gpu::StereoBeliefPropagation d_bp(ndisp);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_bp(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
{
d_bp(d_imgLeft, d_imgRight, d_dst);
}
}
else
{
FAIL();
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBeliefPropagation, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// StereoConstantSpaceBP
GPU_PERF_TEST_1(StereoConstantSpaceBP, cv::gpu::DeviceInfo)
PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(make_pair<string, string>("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-R.png")))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img_l_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l_host.empty());
cv::Mat img_r_host = readImage("gpu/stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_r_host.empty());
cv::gpu::StereoConstantSpaceBP csbp(128);
cv::gpu::GpuMat img_l(img_l_host);
cv::gpu::GpuMat img_r(img_r_host);
cv::gpu::GpuMat dst;
csbp(img_l, img_r, dst);
declare.time(10.0);
TEST_CYCLE()
const cv::Mat imgLeft = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(imgLeft.empty());
const cv::Mat imgRight = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(imgRight.empty());
const int ndisp = 128;
if (runOnGpu)
{
csbp(img_l, img_r, dst);
cv::gpu::StereoConstantSpaceBP d_csbp(ndisp);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_csbp(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
{
d_csbp(d_imgLeft, d_imgRight, d_dst);
}
}
else
{
FAIL();
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// DisparityBilateralFilter
GPU_PERF_TEST_1(DisparityBilateralFilter, cv::gpu::DeviceInfo)
PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(make_pair<string, string>("gpu/stereobm/aloe-L.png", "gpu/stereobm/aloe-disp.png")))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
const cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::Mat img_host = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
const cv::Mat disp = readImage(GetParam().second, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(disp.empty());
cv::Mat disp_host = readImage("gpu/stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(disp_host.empty());
const int ndisp = 128;
cv::gpu::DisparityBilateralFilter f(128);
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat disp(disp_host);
cv::gpu::GpuMat dst;
f(disp, img, dst);
TEST_CYCLE()
if (runOnGpu)
{
f(disp, img, dst);
cv::gpu::DisparityBilateralFilter d_filter(ndisp);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_disp(disp);
cv::gpu::GpuMat d_dst;
d_filter(d_disp, d_img, d_dst);
TEST_CYCLE()
{
d_filter(d_disp, d_img, d_dst);
}
}
else
{
FAIL();
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, DisparityBilateralFilter, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// TransformPoints
IMPLEMENT_PARAM_CLASS(Count, int)
DEF_PARAM_TEST_1(Count, int);
GPU_PERF_TEST(TransformPoints, cv::gpu::DeviceInfo, Count)
PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const int count = GetParam();
int count = GET_PARAM(1);
cv::Mat src(1, count, CV_32FC3);
fillRandom(src, -100, 100);
cv::Mat src_host(1, count, CV_32FC3);
fill(src_host, -100, 100);
const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
cv::gpu::GpuMat src(src_host);
cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
cv::gpu::GpuMat dst;
cv::gpu::transformPoints(src, rvec, tvec, dst);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::transformPoints(src, rvec, tvec, dst);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
TEST_CYCLE()
{
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
}
}
else
{
FAIL();
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, TransformPoints, testing::Combine(
ALL_DEVICES,
testing::Values<Count>(5000, 10000, 20000)));
//////////////////////////////////////////////////////////////////////
// ProjectPoints
GPU_PERF_TEST(ProjectPoints, cv::gpu::DeviceInfo, Count)
PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const int count = GetParam();
int count = GET_PARAM(1);
cv::Mat src(1, count, CV_32FC3);
fillRandom(src, -100, 100);
cv::Mat src_host(1, count, CV_32FC3);
fill(src_host, -100, 100);
const cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
const cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
const cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1);
cv::gpu::GpuMat src(src_host);
cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1);
cv::gpu::GpuMat dst;
cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), dst);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(), dst);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
TEST_CYCLE()
{
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
}
}
else
{
cv::Mat dst;
cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
TEST_CYCLE()
{
cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
}
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::Combine(
ALL_DEVICES,
testing::Values<Count>(5000, 10000, 20000)));
//////////////////////////////////////////////////////////////////////
// SolvePnPRansac
GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count)
PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(10.0);
int count = GET_PARAM(1);
const int count = GetParam();
cv::Mat object(1, count, CV_32FC3);
fill(object, -100, 100);
fillRandom(object, -100, 100);
cv::Mat camera_mat(3, 3, CV_32FC1);
fill(camera_mat, 0.5, 1);
fillRandom(camera_mat, 0.5, 1);
camera_mat.at<float>(0, 1) = 0.f;
camera_mat.at<float>(1, 0) = 0.f;
camera_mat.at<float>(2, 0) = 0.f;
camera_mat.at<float>(2, 1) = 0.f;
cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0));
const cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0));
std::vector<cv::Point2f> image_vec;
cv::Mat rvec_gold(1, 3, CV_32FC1);
fill(rvec_gold, 0, 1);
fillRandom(rvec_gold, 0, 1);
cv::Mat tvec_gold(1, 3, CV_32FC1);
fill(tvec_gold, 0, 1);
fillRandom(tvec_gold, 0, 1);
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec);
cv::Mat image(1, count, CV_32FC2, &image_vec[0]);
@ -221,82 +265,92 @@ GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count)
cv::Mat rvec;
cv::Mat tvec;
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
declare.time(3.0);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
TEST_CYCLE()
{
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
}
}
else
{
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
TEST_CYCLE()
{
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
}
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::Combine(
ALL_DEVICES,
testing::Values<Count>(5000, 10000, 20000)));
//////////////////////////////////////////////////////////////////////
// ReprojectImageTo3D
GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth)
PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const cv::Size size = GET_PARAM(0);
const int depth = GET_PARAM(1);
cv::Size size = GET_PARAM(1);
int depth = GET_PARAM(2);
cv::Mat src_host(size, depth);
fill(src_host, 5.0, 30.0);
cv::Mat src(size, depth);
fillRandom(src, 5.0, 30.0);
cv::Mat Q(4, 4, CV_32FC1);
fill(Q, 0.1, 1.0);
fillRandom(Q, 0.1, 1.0);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::reprojectImageTo3D(src, dst, Q);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::reprojectImageTo3D(src, dst, Q);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
TEST_CYCLE()
{
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
}
}
else
{
cv::Mat dst;
cv::reprojectImageTo3D(src, dst, Q);
TEST_CYCLE()
{
cv::reprojectImageTo3D(src, dst, Q);
}
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, ReprojectImageTo3D, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values<MatDepth>(CV_8U, CV_16S)));
//////////////////////////////////////////////////////////////////////
// DrawColorDisp
GPU_PERF_TEST(DrawColorDisp, cv::gpu::DeviceInfo, cv::Size, MatDepth)
PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16S)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const cv::Size size = GET_PARAM(0);
const int type = GET_PARAM(1);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fillRandom(src, 0, 255);
cv::Mat src_host(size, type);
fill(src_host, 0, 255);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::drawColorDisp(src, dst, 255);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::drawColorDisp(src, dst, 255);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::drawColorDisp(d_src, d_dst, 255);
TEST_CYCLE()
{
cv::gpu::drawColorDisp(d_src, d_dst, 255);
}
}
else
{
FAIL();
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, DrawColorDisp, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16S))));
#endif
} // namespace

File diff suppressed because it is too large Load Diff

View File

@ -1,209 +1,278 @@
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
using namespace std;
using namespace testing;
namespace {
//////////////////////////////////////////////////////////////////////
// SURF
GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo)
DEF_PARAM_TEST_1(Image, string);
PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.jpg"))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
declare.time(50.0);
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::gpu::SURF_GPU surf;
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat keypoints, descriptors;
surf(img, cv::gpu::GpuMat(), keypoints, descriptors);
declare.time(2.0);
TEST_CYCLE()
if (runOnGpu)
{
surf(img, cv::gpu::GpuMat(), keypoints, descriptors);
cv::gpu::SURF_GPU d_surf;
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints, d_descriptors;
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
TEST_CYCLE()
{
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
}
else
{
cv::SURF surf;
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
surf(img, cv::noArray(), keypoints, descriptors);
TEST_CYCLE()
{
keypoints.clear();
surf(img, cv::noArray(), keypoints, descriptors);
}
}
}
INSTANTIATE_TEST_CASE_P(Features2D, SURF, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// FAST
GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo)
PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.jpg"))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
cv::gpu::FAST_GPU fast(20);
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat keypoints;
fast(img, cv::gpu::GpuMat(), keypoints);
TEST_CYCLE()
if (runOnGpu)
{
fast(img, cv::gpu::GpuMat(), keypoints);
cv::gpu::FAST_GPU d_fast(20);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints;
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
TEST_CYCLE()
{
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
}
}
else
{
std::vector<cv::KeyPoint> keypoints;
cv::FAST(img, keypoints, 20);
TEST_CYCLE()
{
keypoints.clear();
cv::FAST(img, keypoints, 20);
}
}
}
INSTANTIATE_TEST_CASE_P(Features2D, FAST, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// ORB
GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo)
PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.jpg"))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::Mat img_host = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
cv::gpu::ORB_GPU orb(4000);
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat keypoints, descriptors;
TEST_CYCLE()
if (runOnGpu)
{
orb(img, cv::gpu::GpuMat(), keypoints, descriptors);
cv::gpu::ORB_GPU d_orb(4000);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints, d_descriptors;
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
TEST_CYCLE()
{
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
}
else
{
cv::ORB orb(4000);
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
orb(img, cv::noArray(), keypoints, descriptors);
TEST_CYCLE()
{
keypoints.clear();
orb(img, cv::noArray(), keypoints, descriptors);
}
}
}
INSTANTIATE_TEST_CASE_P(Features2D, ORB, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// BFMatch
DEF_PARAM_TEST(DescSize_Norm, int, NormType);
PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))))
{
declare.time(20.0);
int desc_size = GET_PARAM(0);
int normType = GET_PARAM(1);
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
cv::Mat query(3000, desc_size, type);
fillRandom(query);
cv::Mat train(3000, desc_size, type);
fillRandom(train);
if (runOnGpu)
{
cv::gpu::BFMatcher_GPU d_matcher(normType);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_distance;
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
TEST_CYCLE()
{
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
}
}
else
{
cv::BFMatcher matcher(normType);
std::vector<cv::DMatch> matches;
matcher.match(query, train, matches);
TEST_CYCLE()
{
matcher.match(query, train, matches);
}
}
}
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_match
// BFKnnMatch
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
DEF_PARAM_TEST(DescSize_K_Norm, int, int, NormType);
GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, DescriptorSize, NormType)
PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine(
Values(64, 128, 256),
Values(2, 3),
Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(30.0);
int desc_size = GET_PARAM(1);
int desc_size = GET_PARAM(0);
int k = GET_PARAM(1);
int normType = GET_PARAM(2);
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
cv::Mat query_host(3000, desc_size, type);
fill(query_host, 0.0, 10.0);
cv::Mat query(3000, desc_size, type);
fillRandom(query);
cv::Mat train_host(3000, desc_size, type);
fill(train_host, 0.0, 10.0);
cv::Mat train(3000, desc_size, type);
fillRandom(train);
cv::gpu::BFMatcher_GPU matcher(normType);
cv::gpu::GpuMat query(query_host);
cv::gpu::GpuMat train(train_host);
cv::gpu::GpuMat trainIdx, distance;
matcher.matchSingle(query, train, trainIdx, distance);
declare.time(3.0);
TEST_CYCLE()
if (runOnGpu)
{
matcher.matchSingle(query, train, trainIdx, distance);
cv::gpu::BFMatcher_GPU d_matcher(normType);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist;
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
TEST_CYCLE()
{
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
}
}
else
{
cv::BFMatcher matcher(normType);
std::vector< std::vector<cv::DMatch> > matches;
matcher.knnMatch(query, train, matches, k);
TEST_CYCLE()
{
matcher.knnMatch(query, train, matches, k);
}
}
}
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_knnMatch
// BFRadiusMatch
IMPLEMENT_PARAM_CLASS(K, int)
GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, DescriptorSize, K, NormType)
PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256), Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(30.0);
int desc_size = GET_PARAM(1);
int k = GET_PARAM(2);
int normType = GET_PARAM(3);
int desc_size = GET_PARAM(0);
int normType = GET_PARAM(1);
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
cv::Mat query_host(3000, desc_size, type);
fill(query_host, 0.0, 10.0);
cv::Mat query(3000, desc_size, type);
fillRandom(query, 0.0, 1.0);
cv::Mat train_host(3000, desc_size, type);
fill(train_host, 0.0, 10.0);
cv::Mat train(3000, desc_size, type);
fillRandom(train, 0.0, 1.0);
cv::gpu::BFMatcher_GPU matcher(normType);
cv::gpu::GpuMat query(query_host);
cv::gpu::GpuMat train(train_host);
cv::gpu::GpuMat trainIdx, distance, allDist;
matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k);
declare.time(3.0);
TEST_CYCLE()
if (runOnGpu)
{
matcher.knnMatchSingle(query, train, trainIdx, distance, allDist, k);
cv::gpu::BFMatcher_GPU d_matcher(normType);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance;
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
TEST_CYCLE()
{
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
}
}
else
{
cv::BFMatcher matcher(normType);
std::vector< std::vector<cv::DMatch> > matches;
matcher.radiusMatch(query, train, matches, 2.0);
TEST_CYCLE()
{
matcher.radiusMatch(query, train, matches, 2.0);
}
}
}
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(K(2), K(3)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_radiusMatch
GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, DescriptorSize, NormType)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
int desc_size = GET_PARAM(1);
int normType = GET_PARAM(2);
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
cv::Mat query_host(3000, desc_size, type);
fill(query_host, 0.0, 1.0);
cv::Mat train_host(3000, desc_size, type);
fill(train_host, 0.0, 1.0);
cv::gpu::BFMatcher_GPU matcher(normType);
cv::gpu::GpuMat query(query_host);
cv::gpu::GpuMat train(train_host);
cv::gpu::GpuMat trainIdx, nMatches, distance;
matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0);
declare.time(3.0);
TEST_CYCLE()
{
matcher.radiusMatchSingle(query, train, trainIdx, distance, nMatches, 2.0);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
#endif
} // namespace

View File

@ -1,308 +1,379 @@
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
using namespace std;
using namespace testing;
namespace {
//////////////////////////////////////////////////////////////////////
// Blur
IMPLEMENT_PARAM_CLASS(KernelSize, int)
DEF_PARAM_TEST(Sz_Type_KernelSz, cv::Size, MatType, int);
GPU_PERF_TEST(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), Values(3, 5, 7)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int ksize = GET_PARAM(2);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::blur(src, dst, cv::Size(ksize, ksize));
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::blur(src, dst, cv::Size(ksize, ksize));
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
TEST_CYCLE()
{
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
}
}
else
{
cv::Mat dst;
cv::blur(src, dst, cv::Size(ksize, ksize));
TEST_CYCLE()
{
cv::blur(src, dst, cv::Size(ksize, ksize));
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, Blur, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7))));
//////////////////////////////////////////////////////////////////////
// Sobel
GPU_PERF_TEST(Sobel, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int ksize = GET_PARAM(2);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat buf;
cv::gpu::Sobel(src, dst, -1, 1, 1, buf, ksize);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::Sobel(src, dst, -1, 1, 1, buf, ksize);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
TEST_CYCLE()
{
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
}
}
else
{
cv::Mat dst;
cv::Sobel(src, dst, -1, 1, 1, ksize);
TEST_CYCLE()
{
cv::Sobel(src, dst, -1, 1, 1, ksize);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, Sobel, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
//////////////////////////////////////////////////////////////////////
// Scharr
GPU_PERF_TEST(Scharr, cv::gpu::DeviceInfo, cv::Size, MatType)
PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat buf;
cv::gpu::Scharr(src, dst, -1, 1, 0, buf);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::Scharr(src, dst, -1, 1, 0, buf);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
TEST_CYCLE()
{
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
}
}
else
{
cv::Mat dst;
cv::Scharr(src, dst, -1, 1, 0);
TEST_CYCLE()
{
cv::Scharr(src, dst, -1, 1, 0);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, Scharr, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1))));
//////////////////////////////////////////////////////////////////////
// GaussianBlur
GPU_PERF_TEST(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1), Values(3, 5, 7, 9, 11, 13, 15)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int ksize = GET_PARAM(2);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat buf;
cv::gpu::GaussianBlur(src, dst, cv::Size(ksize, ksize), buf, 0.5);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::GaussianBlur(src, dst, cv::Size(ksize, ksize), buf, 0.5);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
TEST_CYCLE()
{
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
}
}
else
{
cv::Mat dst;
cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
TEST_CYCLE()
{
cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, GaussianBlur, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
//////////////////////////////////////////////////////////////////////
// Laplacian
GPU_PERF_TEST(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(1, 3)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int ksize = GET_PARAM(2);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::Laplacian(src, dst, -1, ksize);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::Laplacian(src, dst, -1, ksize);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
TEST_CYCLE()
{
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
}
}
else
{
cv::Mat dst;
cv::Laplacian(src, dst, -1, ksize);
TEST_CYCLE()
{
cv::Laplacian(src, dst, -1, ksize);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, Laplacian, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)),
testing::Values(KernelSize(1), KernelSize(3))));
//////////////////////////////////////////////////////////////////////
// Erode
GPU_PERF_TEST(Erode, cv::gpu::DeviceInfo, cv::Size, MatType)
PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat buf;
cv::gpu::erode(src, dst, ker, buf);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::erode(src, dst, ker, buf);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::erode(d_src, d_dst, ker, d_buf);
TEST_CYCLE()
{
cv::gpu::erode(d_src, d_dst, ker, d_buf);
}
}
else
{
cv::Mat dst;
cv::erode(src, dst, ker);
TEST_CYCLE()
{
cv::erode(src, dst, ker);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, Erode, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4))));
//////////////////////////////////////////////////////////////////////
// Dilate
GPU_PERF_TEST(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType)
PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat buf;
cv::gpu::dilate(src, dst, ker, buf);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::dilate(src, dst, ker, buf);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
TEST_CYCLE()
{
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
}
}
else
{
cv::Mat dst;
cv::dilate(src, dst, ker);
TEST_CYCLE()
{
cv::dilate(src, dst, ker);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, Dilate, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4))));
//////////////////////////////////////////////////////////////////////
// MorphologyEx
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
#define ALL_MORPH_OPS testing::Values(MorphOp(cv::MORPH_OPEN), MorphOp(cv::MORPH_CLOSE), MorphOp(cv::MORPH_GRADIENT), MorphOp(cv::MORPH_TOPHAT), MorphOp(cv::MORPH_BLACKHAT))
#define ALL_MORPH_OPS ValuesIn(MorphOp::all())
GPU_PERF_TEST(MorphologyEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp)
DEF_PARAM_TEST(Sz_Type_Op, cv::Size, MatType, MorphOp);
PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4), ALL_MORPH_OPS))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int morphOp = GET_PARAM(3);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int morphOp = GET_PARAM(2);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::GpuMat buf1;
cv::gpu::GpuMat buf2;
cv::gpu::morphologyEx(src, dst, morphOp, ker, buf1, buf2);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::morphologyEx(src, dst, morphOp, ker, buf1, buf2);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf1;
cv::gpu::GpuMat d_buf2;
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
TEST_CYCLE()
{
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
}
}
else
{
cv::Mat dst;
cv::morphologyEx(src, dst, morphOp, ker);
TEST_CYCLE()
{
cv::morphologyEx(src, dst, morphOp, ker);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, MorphologyEx, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),
ALL_MORPH_OPS));
//////////////////////////////////////////////////////////////////////
// Filter2D
GPU_PERF_TEST(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC1, CV_8UC4, CV_32FC1, CV_32FC4), Values(3, 5, 7, 9, 11, 13, 15)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
declare.time(20.0);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Size size = GET_PARAM(0);
int type = GET_PARAM(1);
int ksize = GET_PARAM(2);
cv::Mat src_host(size, type);
fill(src_host, 0.0, 255.0);
cv::Mat src(size, type);
fillRandom(src);
cv::Mat kernel(ksize, ksize, CV_32FC1);
fill(kernel, 0.0, 1.0);
fillRandom(kernel, 0.0, 1.0);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
cv::gpu::filter2D(src, dst, -1, kernel);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::filter2D(src, dst, -1, kernel);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
TEST_CYCLE()
{
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
}
}
else
{
cv::Mat dst;
cv::filter2D(src, dst, -1, kernel);
TEST_CYCLE()
{
cv::filter2D(src, dst, -1, kernel);
}
}
}
INSTANTIATE_TEST_CASE_P(Filters, Filter2D, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
#endif
} // namespace

File diff suppressed because it is too large Load Diff

View File

@ -1,75 +1,136 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//M*/
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
using namespace std;
using namespace testing;
GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size)
namespace {
DEF_PARAM_TEST_1(Image, string);
struct GreedyLabeling
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
struct dot
{
int x;
int y;
cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE);
static dot make(int i, int j)
{
dot d; d.x = i; d.y = j;
return d;
}
};
// cv::threshold(image, image, 150, 255, CV_THRESH_BINARY);
struct InInterval
{
InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {};
const int lo, hi;
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
bool operator() (const unsigned char a, const unsigned char b) const
{
int d = a - b;
return lo <= d && d <= hi;
}
};
cv::gpu::GpuMat components;
components.create(image.rows, image.cols, CV_32SC1);
GreedyLabeling(cv::Mat img)
: image(img), _labels(image.size(), CV_32SC1, cv::Scalar::all(-1)) {stack = new dot[image.cols * image.rows];}
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
~GreedyLabeling(){delete[] stack;}
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
void operator() (cv::Mat labels) const
{
labels.setTo(cv::Scalar::all(-1));
InInterval inInt(0, 2);
int cc = -1;
int* dist_labels = (int*)labels.data;
int pitch = labels.step1();
unsigned char* source = (unsigned char*)image.data;
int width = image.cols;
int height = image.rows;
for (int j = 0; j < image.rows; ++j)
for (int i = 0; i < image.cols; ++i)
{
if (dist_labels[j * pitch + i] != -1) continue;
dot* top = stack;
dot p = dot::make(i, j);
cc++;
dist_labels[j * pitch + i] = cc;
while (top >= stack)
{
int* dl = &dist_labels[p.y * pitch + p.x];
unsigned char* sp = &source[p.y * image.step1() + p.x];
dl[0] = cc;
//right
if( p.x < (width - 1) && dl[ +1] == -1 && inInt(sp[0], sp[+1]))
*top++ = dot::make(p.x + 1, p.y);
//left
if( p.x > 0 && dl[-1] == -1 && inInt(sp[0], sp[-1]))
*top++ = dot::make(p.x - 1, p.y);
//bottom
if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()]))
*top++ = dot::make(p.x, p.y + 1);
//top
if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()]))
*top++ = dot::make(p.x, p.y - 1);
p = *--top;
}
}
}
cv::Mat image;
cv::Mat _labels;
dot* stack;
};
PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/aloe-disp.png"))
{
declare.time(1.0);
TEST_CYCLE()
cv::Mat image = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
if (runOnGpu)
{
cv::gpu::labelComponents(mask, components);
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
cv::gpu::GpuMat components;
components.create(image.rows, image.cols, CV_32SC1);
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
TEST_CYCLE()
{
cv::gpu::labelComponents(mask, components);
}
}
else
{
GreedyLabeling host(image);
host(host._labels);
declare.time(1.0);
TEST_CYCLE()
{
host(host._labels);
}
}
}
INSTANTIATE_TEST_CASE_P(Labeling, ConnectedComponents, testing::Combine(ALL_DEVICES, testing::Values(cv::Size(261, 262))));
#endif
} // namespace

View File

@ -1,20 +0,0 @@
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
perf::TestBase::Init(argc, argv);
return RUN_ALL_TESTS();
}
#else
int main()
{
printf("OpenCV was built without CUDA support\n");
return 0;
}
#endif

View File

@ -1,141 +1,169 @@
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
using namespace std;
using namespace testing;
namespace {
//////////////////////////////////////////////////////////////////////
// SetTo
GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType)
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int type = CV_MAKE_TYPE(depth, channels);
cv::gpu::GpuMat src(size, type);
cv::Scalar val(1, 2, 3, 4);
src.setTo(val);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::GpuMat d_src(size, type);
d_src.setTo(val);
TEST_CYCLE()
{
d_src.setTo(val);
}
}
else
{
cv::Mat src(size, type);
src.setTo(val);
TEST_CYCLE()
{
src.setTo(val);
}
}
}
INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// SetToMasked
GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src_host(size, type);
fill(src_host, 0, 255);
cv::Mat src(size, type);
fillRandom(src);
cv::Mat mask_host(size, CV_8UC1);
fill(mask_host, 0, 2);
cv::Mat mask(size, CV_8UC1);
fillRandom(mask, 0, 2);
cv::gpu::GpuMat src(src_host);
cv::Scalar val(1, 2, 3, 4);
cv::gpu::GpuMat mask(mask_host);
src.setTo(val, mask);
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
TEST_CYCLE()
d_src.setTo(val, d_mask);
TEST_CYCLE()
{
d_src.setTo(val, d_mask);
}
}
else
{
src.setTo(val, mask);
TEST_CYCLE()
{
src.setTo(val, mask);
}
}
}
INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// CopyToMasked
GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(1, 3, 4)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
cv::Size size = GET_PARAM(0);
int depth = GET_PARAM(1);
int channels = GET_PARAM(2);
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int type = CV_MAKE_TYPE(depth, channels);
cv::Mat src_host(size, type);
fill(src_host, 0, 255);
cv::Mat src(size, type);
fillRandom(src);
cv::Mat mask_host(size, CV_8UC1);
fill(mask_host, 0, 2);
cv::Mat mask(size, CV_8UC1);
fillRandom(mask, 0, 2);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat mask(mask_host);
cv::gpu::GpuMat dst;
src.copyTo(dst, mask);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
cv::gpu::GpuMat d_dst;
d_src.copyTo(d_dst, d_mask);
TEST_CYCLE()
{
d_src.copyTo(d_dst, d_mask);
}
}
else
{
cv::Mat dst;
src.copyTo(dst, mask);
TEST_CYCLE()
{
src.copyTo(dst, mask);
}
}
}
INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// ConvertTo
GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth)
DEF_PARAM_TEST(Sz_2Depth, cv::Size, MatDepth, MatDepth);
PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U, CV_16U, CV_32F, CV_64F), Values(CV_8U, CV_16U, CV_32F, CV_64F)))
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
cv::Size size = GET_PARAM(0);
int depth1 = GET_PARAM(1);
int depth2 = GET_PARAM(2);
cv::Size size = GET_PARAM(1);
int depth1 = GET_PARAM(2);
int depth2 = GET_PARAM(3);
cv::Mat src(size, depth1);
fillRandom(src);
cv::Mat src_host(size, depth1);
fill(src_host, 0, 255);
cv::gpu::GpuMat src(src_host);
cv::gpu::GpuMat dst;
src.convertTo(dst, depth2, 0.5, 1.0);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
TEST_CYCLE()
{
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
}
}
else
{
cv::Mat dst;
src.convertTo(dst, depth2, 0.5, 1.0);
TEST_CYCLE()
{
src.convertTo(dst, depth2, 0.5, 1.0);
}
}
}
INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)),
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F))));
#endif
} // namespace

View File

@ -1,85 +1,131 @@
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
using namespace std;
using namespace testing;
namespace {
///////////////////////////////////////////////////////////////
// HOG
GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo)
DEF_PARAM_TEST_1(Image, string);
PERF_TEST_P(Image, ObjDetect_HOG, Values<string>("gpu/hog/road.png"))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage(GetParam(), cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::Mat img_host = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
cv::gpu::GpuMat img(img_host);
std::vector<cv::Rect> found_locations;
cv::gpu::HOGDescriptor hog;
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
hog.detectMultiScale(img, found_locations);
TEST_CYCLE()
if (runOnGpu)
{
cv::gpu::GpuMat d_img(img);
cv::gpu::HOGDescriptor d_hog;
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
d_hog.detectMultiScale(d_img, found_locations);
TEST_CYCLE()
{
d_hog.detectMultiScale(d_img, found_locations);
}
}
else
{
cv::HOGDescriptor hog;
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
hog.detectMultiScale(img, found_locations);
TEST_CYCLE()
{
hog.detectMultiScale(img, found_locations);
}
}
}
INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES);
///////////////////////////////////////////////////////////////
// HaarClassifier
GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo)
typedef pair<string, string> pair_string;
DEF_PARAM_TEST_1(ImageAndCascade, pair_string);
PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/perf/haarcascade_frontalface_alt.xml")))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::Mat img_host = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
cv::gpu::CascadeClassifier_GPU cascade;
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml")));
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat objects_buffer;
cascade.detectMultiScale(img, objects_buffer);
TEST_CYCLE()
if (runOnGpu)
{
cascade.detectMultiScale(img, objects_buffer);
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_objects_buffer;
d_cascade.detectMultiScale(d_img, d_objects_buffer);
TEST_CYCLE()
{
d_cascade.detectMultiScale(d_img, d_objects_buffer);
}
}
else
{
cv::CascadeClassifier cascade;
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml")));
std::vector<cv::Rect> rects;
cascade.detectMultiScale(img, rects);
TEST_CYCLE()
{
cascade.detectMultiScale(img, rects);
}
}
}
INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES);
///////////////////////////////////////////////////////////////
// LBP cascade
//===================== LBP cascade ==========================//
GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo)
PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
Values<pair_string>(make_pair("gpu/haarcascade/group_1_640x480_VGA.pgm", "gpu/lbpcascade/lbpcascade_frontalface.xml")))
{
cv::gpu::DeviceInfo devInfo = GetParam();
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat img = readImage(GetParam().first, cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::Mat img_host = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_host.empty());
cv::gpu::GpuMat img(img_host);
cv::gpu::GpuMat gpu_rects;
cv::gpu::CascadeClassifier_GPU cascade;
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
cascade.detectMultiScale(img, gpu_rects);
TEST_CYCLE()
if (runOnGpu)
{
cascade.detectMultiScale(img, gpu_rects);
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_gpu_rects;
d_cascade.detectMultiScale(d_img, d_gpu_rects);
TEST_CYCLE()
{
d_cascade.detectMultiScale(d_img, d_gpu_rects);
}
}
else
{
cv::CascadeClassifier cascade;
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
std::vector<cv::Rect> rects;
cascade.detectMultiScale(img, rects);
TEST_CYCLE()
{
cascade.detectMultiScale(img, rects);
}
}
}
INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES);
#endif
} // namespace

View File

@ -11,6 +11,10 @@
#include "cvconfig.h"
#ifdef HAVE_CUDA
#include <cuda_runtime.h>
#endif
#include "opencv2/ts/ts.hpp"
#include "opencv2/ts/ts_perf.hpp"
@ -18,8 +22,12 @@
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "perf_utility.hpp"
#include "utility.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined

View File

@ -1,77 +0,0 @@
#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__
#define __OPENCV_PERF_GPU_UTILITY_HPP__
void fill(cv::Mat& m, double a, double b);
using perf::MatType;
using perf::MatDepth;
CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING)
struct CvtColorInfo
{
int scn;
int dcn;
int code;
explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
};
void PrintTo(const CvtColorInfo& info, std::ostream* os);
#define IMPLEMENT_PARAM_CLASS(name, type) \
class name \
{ \
public: \
name ( type arg = type ()) : val_(arg) {} \
operator type () const {return val_;} \
private: \
type val_; \
}; \
inline void PrintTo( name param, std::ostream* os) \
{ \
*os << #name << " = " << testing::PrintToString(static_cast< type >(param)); \
}
IMPLEMENT_PARAM_CLASS(Channels, int)
namespace cv { namespace gpu
{
void PrintTo(const cv::gpu::DeviceInfo& info, std::ostream* os);
}}
#define GPU_PERF_TEST(name, ...) \
struct name : perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > \
{ \
public: \
name() {} \
protected: \
void PerfTestBody(); \
}; \
TEST_P(name, perf){ RunPerfTestBody(); } \
void name :: PerfTestBody()
#define GPU_PERF_TEST_1(name, param_type) \
struct name : perf::TestBaseWithParam< param_type > \
{ \
public: \
name() {} \
protected: \
void PerfTestBody(); \
}; \
TEST_P(name, perf){ RunPerfTestBody(); } \
void name :: PerfTestBody()
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz1080p, cv::Size(1800, 1500))
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
const std::vector<cv::gpu::DeviceInfo>& devices();
#define ALL_DEVICES testing::ValuesIn(devices())
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__

File diff suppressed because it is too large Load Diff

View File

@ -4,12 +4,19 @@ using namespace std;
using namespace cv;
using namespace cv::gpu;
void fill(Mat& m, double a, double b)
bool runOnGpu = true;
void fillRandom(Mat& m, double a, double b)
{
RNG rng(123456789);
rng.fill(m, RNG::UNIFORM, Scalar::all(a), Scalar::all(b));
}
Mat readImage(const string& fileName, int flags)
{
return imread(perf::TestBase::getDataPath(fileName), flags);
}
void PrintTo(const CvtColorInfo& info, ostream* os)
{
static const char* str[] =
@ -184,37 +191,3 @@ void PrintTo(const CvtColorInfo& info, ostream* os)
*os << str[info.code];
}
void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
{
*os << info.name();
}
Mat readImage(const string& fileName, int flags)
{
return imread(perf::TestBase::getDataPath(fileName), flags);
}
const vector<DeviceInfo>& devices()
{
static vector<DeviceInfo> devs;
static bool first = true;
if (first)
{
int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
devs.push_back(info);
}
first = false;
}
return devs;
}

View File

@ -0,0 +1,45 @@
#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__
#define __OPENCV_PERF_GPU_UTILITY_HPP__
#include "opencv2/core/core.hpp"
#include "opencv2/core/gpumat.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/ts/ts_perf.hpp"
extern bool runOnGpu;
void fillRandom(cv::Mat& m, double a = 0.0, double b = 255.0);
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
using perf::MatType;
using perf::MatDepth;
CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
#define ALL_BORDER_MODES testing::ValuesIn(BorderMode::all())
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
#define ALL_INTERPOLATIONS testing::ValuesIn(Interpolation::all())
CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING)
struct CvtColorInfo
{
int scn;
int dcn;
int code;
explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
};
void PrintTo(const CvtColorInfo& info, std::ostream* os);
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
#define DEF_PARAM_TEST(name, ...) typedef ::perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > name
#define DEF_PARAM_TEST_1(name, param_type) typedef ::perf::TestBaseWithParam< param_type > name
DEF_PARAM_TEST_1(Sz, cv::Size);
typedef perf::Size_MatType Sz_Type;
DEF_PARAM_TEST(Sz_Depth, cv::Size, MatDepth);
DEF_PARAM_TEST(Sz_Depth_Cn, cv::Size, MatDepth, int);
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz720p, perf::sz1080p)
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__

View File

@ -1,136 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// StereoBM
GPU_PERF_TEST_1(StereoBM, cv::gpu::DeviceInfo)
{
cv::Mat img_l = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_l.empty());
cv::Mat img_r = readImage("gpu/perf/aloeR.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img_r.empty());
cv::StereoBM bm(0, 256);
cv::Mat dst;
bm(img_l, img_r, dst);
declare.time(5.0);
TEST_CYCLE()
{
bm(img_l, img_r, dst);
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, StereoBM, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// ProjectPoints
IMPLEMENT_PARAM_CLASS(Count, int)
GPU_PERF_TEST(ProjectPoints, cv::gpu::DeviceInfo, Count)
{
int count = GET_PARAM(1);
cv::Mat src(1, count, CV_32FC3);
fill(src, -100, 100);
cv::Mat rvec = cv::Mat::ones(1, 3, CV_32FC1);
cv::Mat tvec = cv::Mat::ones(1, 3, CV_32FC1);
cv::Mat camera_mat = cv::Mat::ones(3, 3, CV_32FC1);
cv::Mat dst;
cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
TEST_CYCLE()
{
cv::projectPoints(src, rvec, tvec, camera_mat, cv::noArray(), dst);
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, ProjectPoints, testing::Combine(
ALL_DEVICES,
testing::Values<Count>(5000, 10000, 20000)));
//////////////////////////////////////////////////////////////////////
// SolvePnPRansac
GPU_PERF_TEST(SolvePnPRansac, cv::gpu::DeviceInfo, Count)
{
int count = GET_PARAM(1);
cv::Mat object(1, count, CV_32FC3);
fill(object, -100, 100);
cv::Mat camera_mat(3, 3, CV_32FC1);
fill(camera_mat, 0.5, 1);
camera_mat.at<float>(0, 1) = 0.f;
camera_mat.at<float>(1, 0) = 0.f;
camera_mat.at<float>(2, 0) = 0.f;
camera_mat.at<float>(2, 1) = 0.f;
cv::Mat dist_coef(1, 8, CV_32F, cv::Scalar::all(0));
std::vector<cv::Point2f> image_vec;
cv::Mat rvec_gold(1, 3, CV_32FC1);
fill(rvec_gold, 0, 1);
cv::Mat tvec_gold(1, 3, CV_32FC1);
fill(tvec_gold, 0, 1);
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, dist_coef, image_vec);
cv::Mat image(1, count, CV_32FC2, &image_vec[0]);
cv::Mat rvec;
cv::Mat tvec;
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
declare.time(10.0);
TEST_CYCLE()
{
cv::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, SolvePnPRansac, testing::Combine(
ALL_DEVICES,
testing::Values<Count>(5000, 10000, 20000)));
//////////////////////////////////////////////////////////////////////
// ReprojectImageTo3D
GPU_PERF_TEST(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth)
{
cv::Size size = GET_PARAM(1);
int depth = GET_PARAM(2);
cv::Mat src(size, depth);
fill(src, 5.0, 30.0);
cv::Mat Q(4, 4, CV_32FC1);
fill(Q, 0.1, 1.0);
cv::Mat dst;
cv::reprojectImageTo3D(src, dst, Q);
TEST_CYCLE()
{
cv::reprojectImageTo3D(src, dst, Q);
}
}
INSTANTIATE_TEST_CASE_P(Calib3D, ReprojectImageTo3D, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values<MatDepth>(CV_8U, CV_16S)));
#endif

File diff suppressed because it is too large Load Diff

View File

@ -1 +0,0 @@
#include "perf_cpu_precomp.hpp"

View File

@ -1,32 +0,0 @@
#ifdef __GNUC__
# pragma GCC diagnostic ignored "-Wmissing-declarations"
# pragma GCC diagnostic ignored "-Wmissing-prototypes" //OSX
#endif
#ifndef __OPENCV_PERF_CPU_PRECOMP_HPP__
#define __OPENCV_PERF_CPU_PRECOMP_HPP__
#include <cstdio>
#include <iostream>
#include "cvconfig.h"
#include "opencv2/ts/ts.hpp"
#include "opencv2/ts/ts_perf.hpp"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/gpu/gpu.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/video/video.hpp"
#include "opencv2/calib3d/calib3d.hpp"
#include "opencv2/nonfree/nonfree.hpp"
#include "opencv2/legacy/legacy.hpp"
#include "perf_utility.hpp"
#ifdef GTEST_CREATE_SHARED_LIBRARY
#error no modules except ts should have GTEST_CREATE_SHARED_LIBRARY defined
#endif
#endif

View File

@ -1,187 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// SURF
GPU_PERF_TEST_1(SURF, cv::gpu::DeviceInfo)
{
cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::SURF surf;
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
surf(img, cv::noArray(), keypoints, descriptors);
declare.time(50.0);
TEST_CYCLE()
{
keypoints.clear();
surf(img, cv::noArray(), keypoints, descriptors);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, SURF, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// FAST
GPU_PERF_TEST_1(FAST, cv::gpu::DeviceInfo)
{
cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
std::vector<cv::KeyPoint> keypoints;
cv::FAST(img, keypoints, 20);
TEST_CYCLE()
{
keypoints.clear();
cv::FAST(img, keypoints, 20);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, FAST, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// ORB
GPU_PERF_TEST_1(ORB, cv::gpu::DeviceInfo)
{
cv::Mat img = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::ORB orb(4000);
std::vector<cv::KeyPoint> keypoints;
cv::Mat descriptors;
orb(img, cv::noArray(), keypoints, descriptors);
TEST_CYCLE()
{
keypoints.clear();
orb(img, cv::noArray(), keypoints, descriptors);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, ORB, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_match
IMPLEMENT_PARAM_CLASS(DescriptorSize, int)
GPU_PERF_TEST(BruteForceMatcher_match, cv::gpu::DeviceInfo, DescriptorSize, NormType)
{
int desc_size = GET_PARAM(1);
int normType = GET_PARAM(2);
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
cv::Mat query(3000, desc_size, type);
fill(query, 0.0, 10.0);
cv::Mat train(3000, desc_size, type);
fill(train, 0.0, 10.0);
cv::BFMatcher matcher(normType);
std::vector<cv::DMatch> matches;
matcher.match(query, train, matches);
declare.time(20.0);
TEST_CYCLE()
{
matcher.match(query, train, matches);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_match, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_knnMatch
IMPLEMENT_PARAM_CLASS(K, int)
GPU_PERF_TEST(BruteForceMatcher_knnMatch, cv::gpu::DeviceInfo, DescriptorSize, K, NormType)
{
int desc_size = GET_PARAM(1);
int k = GET_PARAM(2);
int normType = GET_PARAM(3);
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
cv::Mat query(3000, desc_size, type);
fill(query, 0.0, 10.0);
cv::Mat train(3000, desc_size, type);
fill(train, 0.0, 10.0);
cv::BFMatcher matcher(normType);
std::vector< std::vector<cv::DMatch> > matches;
matcher.knnMatch(query, train, matches, k);
declare.time(30.0);
TEST_CYCLE()
{
matcher.knnMatch(query, train, matches, k);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_knnMatch, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(K(2), K(3)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
//////////////////////////////////////////////////////////////////////
// BruteForceMatcher_radiusMatch
GPU_PERF_TEST(BruteForceMatcher_radiusMatch, cv::gpu::DeviceInfo, DescriptorSize, NormType)
{
int desc_size = GET_PARAM(1);
int normType = GET_PARAM(2);
int type = normType == cv::NORM_HAMMING ? CV_8U : CV_32F;
cv::Mat query(3000, desc_size, type);
fill(query, 0.0, 1.0);
cv::Mat train(3000, desc_size, type);
fill(train, 0.0, 1.0);
cv::BFMatcher matcher(normType);
std::vector< std::vector<cv::DMatch> > matches;
matcher.radiusMatch(query, train, matches, 2.0);
declare.time(30.0);
TEST_CYCLE()
{
matcher.radiusMatch(query, train, matches, 2.0);
}
}
INSTANTIATE_TEST_CASE_P(Features2D, BruteForceMatcher_radiusMatch, testing::Combine(
ALL_DEVICES,
testing::Values(DescriptorSize(64), DescriptorSize(128), DescriptorSize(256)),
testing::Values(NormType(cv::NORM_L1), NormType(cv::NORM_L2), NormType(cv::NORM_HAMMING))));
#endif

View File

@ -1,283 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
IMPLEMENT_PARAM_CLASS(KernelSize, int)
//////////////////////////////////////////////////////////////////////
// Blur
GPU_PERF_TEST(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat dst;
cv::blur(src, dst, cv::Size(ksize, ksize));
declare.time(20.0);
TEST_CYCLE()
{
cv::blur(src, dst, cv::Size(ksize, ksize));
}
}
INSTANTIATE_TEST_CASE_P(Filters, Blur, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7))));
//////////////////////////////////////////////////////////////////////
// Sobel
GPU_PERF_TEST(Sobel, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat dst;
cv::Sobel(src, dst, -1, 1, 1, ksize);
declare.time(20.0);
TEST_CYCLE()
{
cv::Sobel(src, dst, -1, 1, 1, ksize);
}
}
INSTANTIATE_TEST_CASE_P(Filters, Sobel, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
//////////////////////////////////////////////////////////////////////
// Scharr
GPU_PERF_TEST(Scharr, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat dst;
cv::Scharr(src, dst, -1, 1, 0);
declare.time(20.0);
TEST_CYCLE()
{
cv::Scharr(src, dst, -1, 1, 0);
}
}
INSTANTIATE_TEST_CASE_P(Filters, Scharr, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1))));
//////////////////////////////////////////////////////////////////////
// GaussianBlur
GPU_PERF_TEST(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat dst;
cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
declare.time(20.0);
TEST_CYCLE()
{
cv::GaussianBlur(src, dst, cv::Size(ksize, ksize), 0.5);
}
}
INSTANTIATE_TEST_CASE_P(Filters, GaussianBlur, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
//////////////////////////////////////////////////////////////////////
// Laplacian
GPU_PERF_TEST(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat dst;
cv::Laplacian(src, dst, -1, ksize);
declare.time(20.0);
TEST_CYCLE()
{
cv::Laplacian(src, dst, -1, ksize);
}
}
INSTANTIATE_TEST_CASE_P(Filters, Laplacian, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)),
testing::Values(KernelSize(1), KernelSize(3))));
//////////////////////////////////////////////////////////////////////
// Erode
GPU_PERF_TEST(Erode, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
cv::Mat dst;
cv::erode(src, dst, ker);
declare.time(20.0);
TEST_CYCLE()
{
cv::erode(src, dst, ker);
}
}
INSTANTIATE_TEST_CASE_P(Filters, Erode, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4))));
//////////////////////////////////////////////////////////////////////
// Dilate
GPU_PERF_TEST(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
cv::Mat dst;
cv::dilate(src, dst, ker);
declare.time(20.0);
TEST_CYCLE()
{
cv::dilate(src, dst, ker);
}
}
INSTANTIATE_TEST_CASE_P(Filters, Dilate, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4))));
//////////////////////////////////////////////////////////////////////
// MorphologyEx
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)
#define ALL_MORPH_OPS testing::Values(MorphOp(cv::MORPH_OPEN), MorphOp(cv::MORPH_CLOSE), MorphOp(cv::MORPH_GRADIENT), MorphOp(cv::MORPH_TOPHAT), MorphOp(cv::MORPH_BLACKHAT))
GPU_PERF_TEST(MorphologyEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int morphOp = GET_PARAM(3);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat dst;
cv::Mat ker = cv::getStructuringElement(cv::MORPH_RECT, cv::Size(3, 3));
cv::morphologyEx(src, dst, morphOp, ker);
declare.time(20.0);
TEST_CYCLE()
{
cv::morphologyEx(src, dst, morphOp, ker);
}
}
INSTANTIATE_TEST_CASE_P(Filters, MorphologyEx, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),
ALL_MORPH_OPS));
//////////////////////////////////////////////////////////////////////
// Filter2D
GPU_PERF_TEST(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KernelSize)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int ksize = GET_PARAM(3);
cv::Mat src(size, type);
fill(src, 0.0, 255.0);
cv::Mat kernel(ksize, ksize, CV_32FC1);
fill(kernel, 0.0, 1.0);
cv::Mat dst;
cv::filter2D(src, dst, -1, kernel);
declare.time(20.0);
TEST_CYCLE()
{
cv::filter2D(src, dst, -1, kernel);
}
}
INSTANTIATE_TEST_CASE_P(Filters, Filter2D, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1), MatType(CV_32FC4)),
testing::Values(KernelSize(3), KernelSize(5), KernelSize(7), KernelSize(9), KernelSize(11), KernelSize(13), KernelSize(15))));
#endif

View File

@ -1,771 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// Remap
GPU_PERF_TEST(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
int borderMode = GET_PARAM(4);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat xmap(size, CV_32FC1);
fill(xmap, 0, size.width);
cv::Mat ymap(size, CV_32FC1);
fill(ymap, 0, size.height);
cv::Mat dst;
cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
declare.time(20.0);
TEST_CYCLE()
{
cv::remap(src, dst, xmap, ymap, interpolation, borderMode);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Remap, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));
//////////////////////////////////////////////////////////////////////
// Resize
IMPLEMENT_PARAM_CLASS(Scale, double)
GPU_PERF_TEST(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Scale)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
double f = GET_PARAM(4);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat dst;
cv::resize(src, dst, cv::Size(), f, f, interpolation);
declare.time(20.0);
TEST_CYCLE()
{
cv::resize(src, dst, cv::Size(), f, f, interpolation);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Resize, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR),
Interpolation(cv::INTER_CUBIC), Interpolation(cv::INTER_AREA)),
testing::Values(Scale(0.5), Scale(0.3), Scale(2.0))));
GPU_PERF_TEST(ResizeArea, cv::gpu::DeviceInfo, cv::Size, MatType, Scale)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = cv::INTER_AREA;
double f = GET_PARAM(3);
cv::Mat src_host(size, type);
fill(src_host, 0, 255);
cv::Mat src(src_host);
cv::Mat dst;
cv::resize(src, dst, cv::Size(), f, f, interpolation);
declare.time(1.0);
TEST_CYCLE()
{
cv::resize(src, dst, cv::Size(), f, f, interpolation);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, ResizeArea, testing::Combine(
ALL_DEVICES,
testing::Values(perf::sz1080p, cv::Size(4096, 2048)),
testing::Values(MatType(CV_8UC1)/*, MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)*/),
testing::Values(Scale(0.2),Scale(0.1),Scale(0.05))));
//////////////////////////////////////////////////////////////////////
// WarpAffine
GPU_PERF_TEST(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
int borderMode = GET_PARAM(4);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat dst;
const double aplha = CV_PI / 4;
double mat[2][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},
{std::sin(aplha), std::cos(aplha), 0}};
cv::Mat M(2, 3, CV_64F, (void*) mat);
cv::warpAffine(src, dst, M, size, interpolation, borderMode);
declare.time(20.0);
TEST_CYCLE()
{
cv::warpAffine(src, dst, M, size, interpolation, borderMode);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, WarpAffine, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));
//////////////////////////////////////////////////////////////////////
// WarpPerspective
GPU_PERF_TEST(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, BorderMode)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int interpolation = GET_PARAM(3);
int borderMode = GET_PARAM(4);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat dst;
const double aplha = CV_PI / 4;
double mat[3][3] = { {std::cos(aplha), -std::sin(aplha), src.cols / 2},
{std::sin(aplha), std::cos(aplha), 0},
{0.0, 0.0, 1.0}};
cv::Mat M(3, 3, CV_64F, (void*) mat);
cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
declare.time(20.0);
TEST_CYCLE()
{
cv::warpPerspective(src, dst, M, size, interpolation, borderMode);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, WarpPerspective, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
testing::Values(Interpolation(cv::INTER_NEAREST), Interpolation(cv::INTER_LINEAR), Interpolation(cv::INTER_CUBIC)),
testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));
//////////////////////////////////////////////////////////////////////
// CopyMakeBorder
GPU_PERF_TEST(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, BorderMode)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
int borderType = GET_PARAM(3);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat dst;
cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType);
TEST_CYCLE()
{
cv::copyMakeBorder(src, dst, 5, 5, 5, 5, borderType);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, CopyMakeBorder, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4)),
testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_CONSTANT), BorderMode(cv::BORDER_REFLECT), BorderMode(cv::BORDER_WRAP))));
//////////////////////////////////////////////////////////////////////
// Threshold
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV))
GPU_PERF_TEST(Threshold, cv::gpu::DeviceInfo, cv::Size, MatDepth, ThreshOp)
{
cv::Size size = GET_PARAM(1);
int depth = GET_PARAM(2);
int threshOp = GET_PARAM(3);
cv::Mat src(size, depth);
fill(src, 0, 255);
cv::Mat dst;
cv::threshold(src, dst, 100.0, 255.0, threshOp);
TEST_CYCLE()
{
cv::threshold(src, dst, 100.0, 255.0, threshOp);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Threshold, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)),
ALL_THRESH_OPS));
//////////////////////////////////////////////////////////////////////
// Integral
GPU_PERF_TEST(Integral, cv::gpu::DeviceInfo, cv::Size)
{
cv::Size size = GET_PARAM(1);
cv::Mat src(size, CV_8UC1);
fill(src, 0, 255);
cv::Mat dst;
cv::integral(src, dst);
TEST_CYCLE()
{
cv::integral(src, dst);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Integral, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
//////////////////////////////////////////////////////////////////////
// HistEven_OneChannel
GPU_PERF_TEST(HistEven_OneChannel, cv::gpu::DeviceInfo, cv::Size, MatDepth)
{
cv::Size size = GET_PARAM(1);
int depth = GET_PARAM(2);
cv::Mat src(size, depth);
fill(src, 0, 255);
int hbins = 30;
float hranges[] = {0.0f, 180.0f};
cv::Mat hist;
int histSize[] = {hbins};
const float* ranges[] = {hranges};
int channels[] = {0};
cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);
TEST_CYCLE()
{
cv::calcHist(&src, 1, channels, cv::Mat(), hist, 1, histSize, ranges);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, HistEven_OneChannel, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_16S))));
//////////////////////////////////////////////////////////////////////
// EqualizeHist
GPU_PERF_TEST(EqualizeHist, cv::gpu::DeviceInfo, cv::Size)
{
cv::Size size = GET_PARAM(1);
cv::Mat src(size, CV_8UC1);
fill(src, 0, 255);
cv::Mat dst;
cv::equalizeHist(src, dst);
TEST_CYCLE()
{
cv::equalizeHist(src, dst);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, EqualizeHist, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES));
//////////////////////////////////////////////////////////////////////
// Canny
IMPLEMENT_PARAM_CLASS(AppertureSize, int)
IMPLEMENT_PARAM_CLASS(L2gradient, bool)
GPU_PERF_TEST(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient)
{
int apperture_size = GET_PARAM(1);
bool useL2gradient = GET_PARAM(2);
cv::Mat image = readImage("perf/1280x1024.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(image.empty());
cv::Mat dst;
cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);
TEST_CYCLE()
{
cv::Canny(image, dst, 50.0, 100.0, apperture_size, useL2gradient);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Canny, testing::Combine(
ALL_DEVICES,
testing::Values(AppertureSize(3), AppertureSize(5)),
testing::Values(L2gradient(false), L2gradient(true))));
//////////////////////////////////////////////////////////////////////
// MeanShiftFiltering
GPU_PERF_TEST_1(MeanShiftFiltering, cv::gpu::DeviceInfo)
{
cv::Mat img = readImage("gpu/meanshift/cones.png");
ASSERT_FALSE(img.empty());
cv::Mat dst;
cv::pyrMeanShiftFiltering(img, dst, 50, 50);
declare.time(15.0);
TEST_CYCLE()
{
cv::pyrMeanShiftFiltering(img, dst, 50, 50);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, MeanShiftFiltering, ALL_DEVICES);
//////////////////////////////////////////////////////////////////////
// Convolve
IMPLEMENT_PARAM_CLASS(KSize, int)
IMPLEMENT_PARAM_CLASS(Ccorr, bool)
GPU_PERF_TEST(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr)
{
cv::Size size = GET_PARAM(1);
int templ_size = GET_PARAM(2);
bool ccorr = GET_PARAM(3);
ASSERT_FALSE(ccorr);
cv::Mat image(size, CV_32FC1);
image.setTo(1.0);
cv::Mat templ(templ_size, templ_size, CV_32FC1);
templ.setTo(1.0);
cv::Mat dst;
cv::filter2D(image, dst, image.depth(), templ);
declare.time(10.0);
TEST_CYCLE()
{
cv::filter2D(image, dst, image.depth(), templ);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Convolve, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(KSize(3), KSize(9), KSize(17), KSize(27), KSize(32), KSize(64)),
testing::Values(Ccorr(false), Ccorr(true))));
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate_8U
CV_ENUM(TemplateMethod, cv::TM_SQDIFF, cv::TM_SQDIFF_NORMED, cv::TM_CCORR, cv::TM_CCORR_NORMED, cv::TM_CCOEFF, cv::TM_CCOEFF_NORMED)
#define ALL_TEMPLATE_METHODS testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_SQDIFF_NORMED), TemplateMethod(cv::TM_CCORR), TemplateMethod(cv::TM_CCORR_NORMED), TemplateMethod(cv::TM_CCOEFF), TemplateMethod(cv::TM_CCOEFF_NORMED))
IMPLEMENT_PARAM_CLASS(TemplateSize, cv::Size)
GPU_PERF_TEST(MatchTemplate_8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod)
{
cv::Size size = GET_PARAM(1);
cv::Size templ_size = GET_PARAM(2);
int cn = GET_PARAM(3);
int method = GET_PARAM(4);
cv::Mat image(size, CV_MAKE_TYPE(CV_8U, cn));
fill(image, 0, 255);
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_8U, cn));
fill(templ, 0, 255);
cv::Mat dst;
cv::matchTemplate(image, templ, dst, method);
TEST_CYCLE()
{
cv::matchTemplate(image, templ, dst, method);
}
};
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_8U, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))),
testing::Values(Channels(1), Channels(3), Channels(4)),
ALL_TEMPLATE_METHODS));
////////////////////////////////////////////////////////////////////////////////
// MatchTemplate_32F
GPU_PERF_TEST(MatchTemplate_32F, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Channels, TemplateMethod)
{
cv::Size size = GET_PARAM(1);
cv::Size templ_size = GET_PARAM(2);
int cn = GET_PARAM(3);
int method = GET_PARAM(4);
cv::Mat image(size, CV_MAKE_TYPE(CV_32F, cn));
fill(image, 0, 255);
cv::Mat templ(templ_size, CV_MAKE_TYPE(CV_32F, cn));
fill(templ, 0, 255);
cv::Mat dst;
cv::matchTemplate(image, templ, dst, method);
TEST_CYCLE()
{
cv::matchTemplate(image, templ, dst, method);
}
};
INSTANTIATE_TEST_CASE_P(ImgProc, MatchTemplate_32F, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(TemplateSize(cv::Size(5, 5)), TemplateSize(cv::Size(16, 16)), TemplateSize(cv::Size(30, 30))),
testing::Values(Channels(1), Channels(3), Channels(4)),
testing::Values(TemplateMethod(cv::TM_SQDIFF), TemplateMethod(cv::TM_CCORR))));
//////////////////////////////////////////////////////////////////////
// MulSpectrums
CV_FLAGS(DftFlags, 0, cv::DFT_INVERSE, cv::DFT_SCALE, cv::DFT_ROWS, cv::DFT_COMPLEX_OUTPUT, cv::DFT_REAL_OUTPUT)
GPU_PERF_TEST(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags)
{
cv::Size size = GET_PARAM(1);
int flag = GET_PARAM(2);
cv::Mat a(size, CV_32FC2);
fill(a, 0, 100);
cv::Mat b(size, CV_32FC2);
fill(b, 0, 100);
cv::Mat dst;
cv::mulSpectrums(a, b, dst, flag);
TEST_CYCLE()
{
cv::mulSpectrums(a, b, dst, flag);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, MulSpectrums, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS))));
//////////////////////////////////////////////////////////////////////
// Dft
GPU_PERF_TEST(Dft, cv::gpu::DeviceInfo, cv::Size, DftFlags)
{
cv::Size size = GET_PARAM(1);
int flag = GET_PARAM(2);
cv::Mat src(size, CV_32FC2);
fill(src, 0, 100);
cv::Mat dst;
cv::dft(src, dst, flag);
declare.time(10.0);
TEST_CYCLE()
{
cv::dft(src, dst, flag);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, Dft, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(DftFlags(0), DftFlags(cv::DFT_ROWS), DftFlags(cv::DFT_INVERSE))));
//////////////////////////////////////////////////////////////////////
// CornerHarris
IMPLEMENT_PARAM_CLASS(BlockSize, int)
IMPLEMENT_PARAM_CLASS(ApertureSize, int)
GPU_PERF_TEST(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize)
{
int type = GET_PARAM(1);
int borderType = GET_PARAM(2);
int blockSize = GET_PARAM(3);
int apertureSize = GET_PARAM(4);
cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
cv::Mat dst;
double k = 0.5;
cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderType);
TEST_CYCLE()
{
cv::cornerHarris(img, dst, blockSize, apertureSize, k, borderType);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, CornerHarris, testing::Combine(
ALL_DEVICES,
testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)),
testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)),
testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7))));
//////////////////////////////////////////////////////////////////////
// CornerMinEigenVal
GPU_PERF_TEST(CornerMinEigenVal, cv::gpu::DeviceInfo, MatType, BorderMode, BlockSize, ApertureSize)
{
int type = GET_PARAM(1);
int borderType = GET_PARAM(2);
int blockSize = GET_PARAM(3);
int apertureSize = GET_PARAM(4);
cv::Mat img = readImage("gpu/stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
img.convertTo(img, type, type == CV_32F ? 1.0 / 255.0 : 1.0);
cv::Mat dst;
cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderType);
TEST_CYCLE()
{
cv::cornerMinEigenVal(img, dst, blockSize, apertureSize, borderType);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, CornerMinEigenVal, testing::Combine(
ALL_DEVICES,
testing::Values(MatType(CV_8UC1), MatType(CV_32FC1)),
testing::Values(BorderMode(cv::BORDER_REFLECT101), BorderMode(cv::BORDER_REPLICATE), BorderMode(cv::BORDER_REFLECT)),
testing::Values(BlockSize(3), BlockSize(5), BlockSize(7)),
testing::Values(ApertureSize(0), ApertureSize(3), ApertureSize(5), ApertureSize(7))));
//////////////////////////////////////////////////////////////////////
// PyrDown
GPU_PERF_TEST(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat dst;
cv::pyrDown(src, dst);
TEST_CYCLE()
{
cv::pyrDown(src, dst);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, PyrDown, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4))));
//////////////////////////////////////////////////////////////////////
// PyrUp
GPU_PERF_TEST(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat dst;
cv::pyrUp(src, dst);
TEST_CYCLE()
{
cv::pyrUp(src, dst);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, PyrUp, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4))));
//////////////////////////////////////////////////////////////////////
// CvtColor
GPU_PERF_TEST(CvtColor, cv::gpu::DeviceInfo, cv::Size, MatDepth, CvtColorInfo)
{
cv::Size size = GET_PARAM(1);
int depth = GET_PARAM(2);
CvtColorInfo info = GET_PARAM(3);
cv::Mat src(size, CV_MAKETYPE(depth, info.scn));
fill(src, 0, 255);
cv::Mat dst;
cv::cvtColor(src, dst, info.code, info.dcn);
TEST_CYCLE()
{
cv::cvtColor(src, dst, info.code, info.dcn);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, CvtColor, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F)),
testing::Values(CvtColorInfo(4, 4, cv::COLOR_RGBA2BGRA),
CvtColorInfo(4, 1, cv::COLOR_BGRA2GRAY),
CvtColorInfo(1, 4, cv::COLOR_GRAY2BGRA),
CvtColorInfo(3, 3, cv::COLOR_BGR2XYZ),
CvtColorInfo(3, 3, cv::COLOR_XYZ2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2YCrCb),
CvtColorInfo(3, 3, cv::COLOR_YCrCb2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2YUV),
CvtColorInfo(3, 3, cv::COLOR_YUV2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2HSV),
CvtColorInfo(3, 3, cv::COLOR_HSV2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2HLS),
CvtColorInfo(3, 3, cv::COLOR_HLS2BGR),
CvtColorInfo(3, 3, cv::COLOR_BGR2Lab),
CvtColorInfo(3, 3, cv::COLOR_RGB2Lab),
CvtColorInfo(3, 3, cv::COLOR_BGR2Luv),
CvtColorInfo(3, 3, cv::COLOR_RGB2Luv),
CvtColorInfo(3, 3, cv::COLOR_Lab2BGR),
CvtColorInfo(3, 3, cv::COLOR_Lab2RGB),
CvtColorInfo(3, 3, cv::COLOR_Luv2BGR),
CvtColorInfo(3, 3, cv::COLOR_Luv2RGB),
CvtColorInfo(1, 3, cv::COLOR_BayerBG2BGR),
CvtColorInfo(1, 3, cv::COLOR_BayerGB2BGR),
CvtColorInfo(1, 3, cv::COLOR_BayerRG2BGR),
CvtColorInfo(1, 3, cv::COLOR_BayerGR2BGR),
CvtColorInfo(4, 4, cv::COLOR_RGBA2mRGBA))));
//////////////////////////////////////////////////////////////////////
// HoughLines
IMPLEMENT_PARAM_CLASS(DoSort, bool)
GPU_PERF_TEST(HoughLines, cv::gpu::DeviceInfo, cv::Size, DoSort)
{
declare.time(30.0);
const cv::Size size = GET_PARAM(1);
const float rho = 1.0f;
const float theta = CV_PI / 180.0f;
const int threshold = 300;
cv::RNG rng(123456789);
cv::Mat src(size, CV_8UC1, cv::Scalar::all(0));
const int numLines = rng.uniform(500, 2000);
for (int i = 0; i < numLines; ++i)
{
cv::Point p1(rng.uniform(0, src.cols), rng.uniform(0, src.rows));
cv::Point p2(rng.uniform(0, src.cols), rng.uniform(0, src.rows));
cv::line(src, p1, p2, cv::Scalar::all(255), 2);
}
std::vector<cv::Vec2f> lines;
cv::HoughLines(src, lines, rho, theta, threshold);
TEST_CYCLE()
{
cv::HoughLines(src, lines, rho, theta, threshold);
}
}
INSTANTIATE_TEST_CASE_P(ImgProc, HoughLines, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(DoSort(false), DoSort(true))));
#endif

View File

@ -1,158 +0,0 @@
/*M///////////////////////////////////////////////////////////////////////////////////////
//
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
//
// By downloading, copying, installing or using the software you agree to this license.
// If you do not agree to this license, do not download, install,
// copy or use the software.
//
//
// License Agreement
// For Open Source Computer Vision Library
//
// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
// Copyright (C) 2008-2011, Willow Garage Inc., all rights reserved.
// Third party copyrights are property of their respective owners.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// * Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
//
// * Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
//
// * The name of the copyright holders may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// This software is provided by the copyright holders and contributors "as is" and
// any express or implied warranties, including, but not limited to, the implied
// warranties of merchantability and fitness for a particular purpose are disclaimed.
// In no event shall the Intel Corporation or contributors be liable for any direct,
// indirect, incidental, special, exemplary, or consequential damages
// (including, but not limited to, procurement of substitute goods or services;
// loss of use, data, or profits; or business interruption) however caused
// and on any theory of liability, whether in contract, strict liability,
// or tort (including negligence or otherwise) arising in any way out of
// the use of this software, even if advised of the possibility of such damage.
//M*/
#include "perf_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
struct GreedyLabeling
{
struct dot
{
int x;
int y;
static dot make(int i, int j)
{
dot d; d.x = i; d.y = j;
return d;
}
};
struct InInterval
{
InInterval(const int& _lo, const int& _hi) : lo(-_lo), hi(_hi) {};
const int lo, hi;
bool operator() (const unsigned char a, const unsigned char b) const
{
int d = a - b;
return lo <= d && d <= hi;
}
};
GreedyLabeling(cv::Mat img)
: image(img), _labels(image.size(), CV_32SC1, cv::Scalar::all(-1)) {stack = new dot[image.cols * image.rows];}
~GreedyLabeling(){delete[] stack;}
void operator() (cv::Mat labels) const
{
labels.setTo(cv::Scalar::all(-1));
InInterval inInt(0, 2);
int cc = -1;
int* dist_labels = (int*)labels.data;
int pitch = labels.step1();
unsigned char* source = (unsigned char*)image.data;
int width = image.cols;
int height = image.rows;
for (int j = 0; j < image.rows; ++j)
for (int i = 0; i < image.cols; ++i)
{
if (dist_labels[j * pitch + i] != -1) continue;
dot* top = stack;
dot p = dot::make(i, j);
cc++;
dist_labels[j * pitch + i] = cc;
while (top >= stack)
{
int* dl = &dist_labels[p.y * pitch + p.x];
unsigned char* sp = &source[p.y * image.step1() + p.x];
dl[0] = cc;
//right
if( p.x < (width - 1) && dl[ +1] == -1 && inInt(sp[0], sp[+1]))
*top++ = dot::make(p.x + 1, p.y);
//left
if( p.x > 0 && dl[-1] == -1 && inInt(sp[0], sp[-1]))
*top++ = dot::make(p.x - 1, p.y);
//bottom
if( p.y < (height - 1) && dl[+pitch] == -1 && inInt(sp[0], sp[+image.step1()]))
*top++ = dot::make(p.x, p.y + 1);
//top
if( p.y > 0 && dl[-pitch] == -1 && inInt(sp[0], sp[-image.step1()]))
*top++ = dot::make(p.x, p.y - 1);
p = *--top;
}
}
}
cv::Mat image;
cv::Mat _labels;
dot* stack;
};
}
GPU_PERF_TEST(ConnectedComponents, cv::gpu::DeviceInfo, cv::Size)
{
cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
cv::Mat image = readImage("gpu/labeling/aloe-disp.png", cv::IMREAD_GRAYSCALE);
GreedyLabeling host(image);
host(host._labels);
declare.time(1.0);
TEST_CYCLE()
{
host(host._labels);
}
}
INSTANTIATE_TEST_CASE_P(Labeling, ConnectedComponents, testing::Combine(ALL_DEVICES, testing::Values(cv::Size(261, 262))));
#endif

View File

@ -1,20 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
int main(int argc, char **argv)
{
testing::InitGoogleTest(&argc, argv);
perf::TestBase::Init(argc, argv);
return RUN_ALL_TESTS();
}
#else
int main()
{
printf("OpenCV was built without CUDA support\n");
return 0;
}
#endif

View File

@ -1,124 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////////////////////
// SetTo
GPU_PERF_TEST(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
cv::Scalar val(1, 2, 3, 4);
src.setTo(val);
TEST_CYCLE()
{
src.setTo(val);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, SetTo, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// SetToMasked
GPU_PERF_TEST(SetToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat mask(size, CV_8UC1);
fill(mask, 0, 2);
cv::Scalar val(1, 2, 3, 4);
src.setTo(val, mask);
TEST_CYCLE()
{
src.setTo(val, mask);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, SetToMasked, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// CopyToMasked
GPU_PERF_TEST(CopyToMasked, cv::gpu::DeviceInfo, cv::Size, MatType)
{
cv::Size size = GET_PARAM(1);
int type = GET_PARAM(2);
cv::Mat src(size, type);
fill(src, 0, 255);
cv::Mat mask(size, CV_8UC1);
fill(mask, 0, 2);
cv::Mat dst;
src.copyTo(dst, mask);
TEST_CYCLE()
{
src.copyTo(dst, mask);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, CopyToMasked, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatType(CV_8UC1), MatType(CV_8UC3), MatType(CV_8UC4),
MatType(CV_16UC1), MatType(CV_16UC3), MatType(CV_16UC4),
MatType(CV_32FC1), MatType(CV_32FC3), MatType(CV_32FC4),
MatType(CV_64FC1), MatType(CV_64FC3), MatType(CV_64FC4))));
//////////////////////////////////////////////////////////////////////
// ConvertTo
GPU_PERF_TEST(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth)
{
cv::Size size = GET_PARAM(1);
int depth1 = GET_PARAM(2);
int depth2 = GET_PARAM(3);
cv::Mat src(size, depth1);
fill(src, 0, 255);
cv::Mat dst;
src.convertTo(dst, depth2, 0.5, 1.0);
TEST_CYCLE()
{
src.convertTo(dst, depth2, 0.5, 1.0);
}
}
INSTANTIATE_TEST_CASE_P(MatOp, ConvertTo, testing::Combine(
ALL_DEVICES,
GPU_TYPICAL_MAT_SIZES,
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F)),
testing::Values(MatDepth(CV_8U), MatDepth(CV_16U), MatDepth(CV_32F), MatDepth(CV_64F))));
#endif

View File

@ -1,74 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
///////////////////////////////////////////////////////////////
// HOG
GPU_PERF_TEST_1(HOG, cv::gpu::DeviceInfo)
{
cv::Mat img = readImage("gpu/hog/road.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
std::vector<cv::Rect> found_locations;
cv::HOGDescriptor hog;
hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
hog.detectMultiScale(img, found_locations);
TEST_CYCLE()
{
hog.detectMultiScale(img, found_locations);
}
}
INSTANTIATE_TEST_CASE_P(ObjDetect, HOG, ALL_DEVICES);
///////////////////////////////////////////////////////////////
// HaarClassifier
GPU_PERF_TEST_1(HaarClassifier, cv::gpu::DeviceInfo)
{
cv::Mat img = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::CascadeClassifier cascade;
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/perf/haarcascade_frontalface_alt.xml")));
std::vector<cv::Rect> rects;
cascade.detectMultiScale(img, rects);
TEST_CYCLE()
{
cascade.detectMultiScale(img, rects);
}
}
INSTANTIATE_TEST_CASE_P(ObjDetect, HaarClassifier, ALL_DEVICES);
//===================== LBP cascade ==========================//
GPU_PERF_TEST_1(LBPClassifier, cv::gpu::DeviceInfo)
{
cv::Mat img = readImage("gpu/haarcascade/group_1_640x480_VGA.pgm", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
cv::CascadeClassifier cascade;
ASSERT_TRUE(cascade.load(perf::TestBase::getDataPath("gpu/lbpcascade/lbpcascade_frontalface.xml")));
std::vector<cv::Rect> rects;
cascade.detectMultiScale(img, rects);
TEST_CYCLE()
{
cascade.detectMultiScale(img, rects);
}
}
INSTANTIATE_TEST_CASE_P(ObjDetect, LBPClassifier, ALL_DEVICES);
#endif

View File

@ -1,220 +0,0 @@
#include "perf_cpu_precomp.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
void fill(Mat& m, double a, double b)
{
RNG rng(123456789);
rng.fill(m, RNG::UNIFORM, a, b);
}
void PrintTo(const CvtColorInfo& info, ostream* os)
{
static const char* str[] =
{
"BGR2BGRA",
"BGRA2BGR",
"BGR2RGBA",
"RGBA2BGR",
"BGR2RGB",
"BGRA2RGBA",
"BGR2GRAY",
"RGB2GRAY",
"GRAY2BGR",
"GRAY2BGRA",
"BGRA2GRAY",
"RGBA2GRAY",
"BGR2BGR565",
"RGB2BGR565",
"BGR5652BGR",
"BGR5652RGB",
"BGRA2BGR565",
"RGBA2BGR565",
"BGR5652BGRA",
"BGR5652RGBA",
"GRAY2BGR565",
"BGR5652GRAY",
"BGR2BGR555",
"RGB2BGR555",
"BGR5552BGR",
"BGR5552RGB",
"BGRA2BGR555",
"RGBA2BGR555",
"BGR5552BGRA",
"BGR5552RGBA",
"GRAY2BGR555",
"BGR5552GRAY",
"BGR2XYZ",
"RGB2XYZ",
"XYZ2BGR",
"XYZ2RGB",
"BGR2YCrCb",
"RGB2YCrCb",
"YCrCb2BGR",
"YCrCb2RGB",
"BGR2HSV",
"RGB2HSV",
"",
"",
"BGR2Lab",
"RGB2Lab",
"BayerBG2BGR",
"BayerGB2BGR",
"BayerRG2BGR",
"BayerGR2BGR",
"BGR2Luv",
"RGB2Luv",
"BGR2HLS",
"RGB2HLS",
"HSV2BGR",
"HSV2RGB",
"Lab2BGR",
"Lab2RGB",
"Luv2BGR",
"Luv2RGB",
"HLS2BGR",
"HLS2RGB",
"BayerBG2BGR_VNG",
"BayerGB2BGR_VNG",
"BayerRG2BGR_VNG",
"BayerGR2BGR_VNG",
"BGR2HSV_FULL",
"RGB2HSV_FULL",
"BGR2HLS_FULL",
"RGB2HLS_FULL",
"HSV2BGR_FULL",
"HSV2RGB_FULL",
"HLS2BGR_FULL",
"HLS2RGB_FULL",
"LBGR2Lab",
"LRGB2Lab",
"LBGR2Luv",
"LRGB2Luv",
"Lab2LBGR",
"Lab2LRGB",
"Luv2LBGR",
"Luv2LRGB",
"BGR2YUV",
"RGB2YUV",
"YUV2BGR",
"YUV2RGB",
"BayerBG2GRAY",
"BayerGB2GRAY",
"BayerRG2GRAY",
"BayerGR2GRAY",
//YUV 4:2:0 formats family
"YUV2RGB_NV12",
"YUV2BGR_NV12",
"YUV2RGB_NV21",
"YUV2BGR_NV21",
"YUV2RGBA_NV12",
"YUV2BGRA_NV12",
"YUV2RGBA_NV21",
"YUV2BGRA_NV21",
"YUV2RGB_YV12",
"YUV2BGR_YV12",
"YUV2RGB_IYUV",
"YUV2BGR_IYUV",
"YUV2RGBA_YV12",
"YUV2BGRA_YV12",
"YUV2RGBA_IYUV",
"YUV2BGRA_IYUV",
"YUV2GRAY_420",
//YUV 4:2:2 formats family
"YUV2RGB_UYVY",
"YUV2BGR_UYVY",
"YUV2RGB_VYUY",
"YUV2BGR_VYUY",
"YUV2RGBA_UYVY",
"YUV2BGRA_UYVY",
"YUV2RGBA_VYUY",
"YUV2BGRA_VYUY",
"YUV2RGB_YUY2",
"YUV2BGR_YUY2",
"YUV2RGB_YVYU",
"YUV2BGR_YVYU",
"YUV2RGBA_YUY2",
"YUV2BGRA_YUY2",
"YUV2RGBA_YVYU",
"YUV2BGRA_YVYU",
"YUV2GRAY_UYVY",
"YUV2GRAY_YUY2",
// alpha premultiplication
"RGBA2mRGBA",
"mRGBA2RGBA",
"COLORCVT_MAX"
};
*os << str[info.code];
}
void cv::gpu::PrintTo(const DeviceInfo& info, ostream* os)
{
*os << info.name();
}
Mat readImage(const string& fileName, int flags)
{
return imread(perf::TestBase::getDataPath(fileName), flags);
}
const vector<DeviceInfo>& devices()
{
static vector<DeviceInfo> devs;
static bool first = true;
if (first)
{
int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
devs.push_back(info);
}
first = false;
}
return devs;
}

View File

@ -1,77 +0,0 @@
#ifndef __OPENCV_PERF_GPU_UTILITY_HPP__
#define __OPENCV_PERF_GPU_UTILITY_HPP__
void fill(cv::Mat& m, double a, double b);
using perf::MatType;
using perf::MatDepth;
CV_ENUM(BorderMode, cv::BORDER_REFLECT101, cv::BORDER_REPLICATE, cv::BORDER_CONSTANT, cv::BORDER_REFLECT, cv::BORDER_WRAP)
CV_ENUM(Interpolation, cv::INTER_NEAREST, cv::INTER_LINEAR, cv::INTER_CUBIC, cv::INTER_AREA)
CV_ENUM(NormType, cv::NORM_INF, cv::NORM_L1, cv::NORM_L2, cv::NORM_HAMMING)
struct CvtColorInfo
{
int scn;
int dcn;
int code;
explicit CvtColorInfo(int scn_=0, int dcn_=0, int code_=0) : scn(scn_), dcn(dcn_), code(code_) {}
};
void PrintTo(const CvtColorInfo& info, std::ostream* os);
#define IMPLEMENT_PARAM_CLASS(name, type) \
class name \
{ \
public: \
name ( type arg = type ()) : val_(arg) {} \
operator type () const {return val_;} \
private: \
type val_; \
}; \
inline void PrintTo( name param, std::ostream* os) \
{ \
*os << #name << " = " << testing::PrintToString(static_cast< type >(param)); \
}
IMPLEMENT_PARAM_CLASS(Channels, int)
namespace cv { namespace gpu
{
void PrintTo(const cv::gpu::DeviceInfo& info, std::ostream* os);
}}
#define GPU_PERF_TEST(name, ...) \
struct name : perf::TestBaseWithParam< std::tr1::tuple< __VA_ARGS__ > > \
{ \
public: \
name() {} \
protected: \
void PerfTestBody(); \
}; \
TEST_P(name, perf){ RunPerfTestBody(); } \
void name :: PerfTestBody()
#define GPU_PERF_TEST_1(name, param_type) \
struct name : perf::TestBaseWithParam< param_type > \
{ \
public: \
name() {} \
protected: \
void PerfTestBody(); \
}; \
TEST_P(name, perf){ RunPerfTestBody(); } \
void name :: PerfTestBody()
#define GPU_TYPICAL_MAT_SIZES testing::Values(perf::szSXGA, perf::sz1080p, cv::Size(1800, 1500))
cv::Mat readImage(const std::string& fileName, int flags = cv::IMREAD_COLOR);
const std::vector<cv::gpu::DeviceInfo>& devices();
#define ALL_DEVICES testing::ValuesIn(devices())
#define GET_PARAM(k) std::tr1::get< k >(GetParam())
#endif // __OPENCV_PERF_GPU_UTILITY_HPP__

View File

@ -1,466 +0,0 @@
#include "perf_cpu_precomp.hpp"
#ifdef HAVE_CUDA
//////////////////////////////////////////////////////
// GoodFeaturesToTrack
IMPLEMENT_PARAM_CLASS(MinDistance, double)
GPU_PERF_TEST(GoodFeaturesToTrack, cv::gpu::DeviceInfo, MinDistance)
{
double minDistance = GET_PARAM(1);
cv::Mat image = readImage("gpu/perf/aloe.jpg", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(image.empty());
cv::Mat corners;
cv::goodFeaturesToTrack(image, corners, 8000, 0.01, minDistance);
TEST_CYCLE()
{
cv::goodFeaturesToTrack(image, corners, 8000, 0.01, minDistance);
}
}
INSTANTIATE_TEST_CASE_P(Video, GoodFeaturesToTrack, testing::Combine(
ALL_DEVICES,
testing::Values(MinDistance(0.0), MinDistance(3.0))));
//////////////////////////////////////////////////////
// PyrLKOpticalFlowSparse
IMPLEMENT_PARAM_CLASS(GraySource, bool)
IMPLEMENT_PARAM_CLASS(Points, int)
IMPLEMENT_PARAM_CLASS(WinSize, int)
IMPLEMENT_PARAM_CLASS(Levels, int)
IMPLEMENT_PARAM_CLASS(Iters, int)
GPU_PERF_TEST(PyrLKOpticalFlowSparse, cv::gpu::DeviceInfo, GraySource, Points, WinSize, Levels, Iters)
{
bool useGray = GET_PARAM(1);
int points = GET_PARAM(2);
int win_size = GET_PARAM(3);
int levels = GET_PARAM(4);
int iters = GET_PARAM(5);
cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
ASSERT_FALSE(frame0.empty());
cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", useGray ? cv::IMREAD_GRAYSCALE : cv::IMREAD_COLOR);
ASSERT_FALSE(frame1.empty());
cv::Mat gray_frame;
if (useGray)
gray_frame = frame0;
else
cv::cvtColor(frame0, gray_frame, cv::COLOR_BGR2GRAY);
cv::Mat pts;
cv::goodFeaturesToTrack(gray_frame, pts, points, 0.01, 0.0);
cv::Mat nextPts;
cv::Mat status;
cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
cv::Size(win_size, win_size), levels - 1,
cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
declare.time(20.0);
TEST_CYCLE()
{
cv::calcOpticalFlowPyrLK(frame0, frame1, pts, nextPts, status, cv::noArray(),
cv::Size(win_size, win_size), levels - 1,
cv::TermCriteria(cv::TermCriteria::COUNT + cv::TermCriteria::EPS, iters, 0.01));
}
}
INSTANTIATE_TEST_CASE_P(Video, PyrLKOpticalFlowSparse, testing::Combine(
ALL_DEVICES,
testing::Values(GraySource(true), GraySource(false)),
testing::Values(Points(1000), Points(2000), Points(4000), Points(8000)),
testing::Values(WinSize(9), WinSize(13), WinSize(17), WinSize(21)),
testing::Values(Levels(1), Levels(2), Levels(3)),
testing::Values(Iters(1), Iters(10), Iters(30))));
//////////////////////////////////////////////////////
// FarnebackOpticalFlowTest
GPU_PERF_TEST_1(FarnebackOpticalFlowTest, cv::gpu::DeviceInfo)
{
cv::Mat frame0 = readImage("gpu/opticalflow/frame0.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame0.empty());
cv::Mat frame1 = readImage("gpu/opticalflow/frame1.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(frame1.empty());
cv::Mat flow;
int numLevels = 5;
double pyrScale = 0.5;
int winSize = 13;
int numIters = 10;
int polyN = 5;
double polySigma = 1.1;
int flags = 0;
cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
declare.time(10);
TEST_CYCLE()
{
cv::calcOpticalFlowFarneback(frame0, frame1, flow, pyrScale, numLevels, winSize, numIters, polyN, polySigma, flags);
}
}
INSTANTIATE_TEST_CASE_P(Video, FarnebackOpticalFlowTest, ALL_DEVICES);
//////////////////////////////////////////////////////
// FGDStatModel
namespace cv
{
template<> void Ptr<CvBGStatModel>::delete_obj()
{
cvReleaseBGStatModel(&obj);
}
}
GPU_PERF_TEST(FGDStatModel, cv::gpu::DeviceInfo, std::string)
{
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
cv::Mat frame;
cap >> frame;
ASSERT_FALSE(frame.empty());
IplImage ipl_frame = frame;
cv::Ptr<CvBGStatModel> model(cvCreateFGDStatModel(&ipl_frame));
declare.time(60);
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
ipl_frame = frame;
startTimer();
next();
cvUpdateBGStatModel(&ipl_frame, model);
stopTimer();
}
}
INSTANTIATE_TEST_CASE_P(Video, FGDStatModel, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi"))));
//////////////////////////////////////////////////////
// MOG
IMPLEMENT_PARAM_CLASS(LearningRate, double)
GPU_PERF_TEST(MOG, cv::gpu::DeviceInfo, std::string, Channels, LearningRate)
{
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
int cn = GET_PARAM(2);
double learningRate = GET_PARAM(3);
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
cv::Mat frame;
cv::BackgroundSubtractorMOG mog;
cv::Mat foreground;
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
mog(frame, foreground, learningRate);
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
startTimer(); next();
mog(frame, foreground, learningRate);
stopTimer();
}
}
INSTANTIATE_TEST_CASE_P(Video, MOG, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")),
testing::Values(Channels(1), Channels(3)/*, Channels(4)*/),
testing::Values(LearningRate(0.0), LearningRate(0.01))));
//////////////////////////////////////////////////////
// MOG2
GPU_PERF_TEST(MOG2_update, cv::gpu::DeviceInfo, std::string, Channels)
{
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
int cn = GET_PARAM(2);
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
cv::Mat frame;
cv::BackgroundSubtractorMOG2 mog2;
cv::Mat foreground;
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
mog2(frame, foreground);
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
startTimer(); next();
mog2(frame, foreground);
stopTimer();
}
}
INSTANTIATE_TEST_CASE_P(Video, MOG2_update, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")),
testing::Values(Channels(1), Channels(3)/*, Channels(4)*/)));
GPU_PERF_TEST(MOG2_getBackgroundImage, cv::gpu::DeviceInfo, std::string, Channels)
{
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
int cn = GET_PARAM(2);
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
cv::Mat frame;
cv::BackgroundSubtractorMOG2 mog2;
cv::Mat foreground;
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
mog2(frame, foreground);
}
cv::Mat background;
mog2.getBackgroundImage(background);
TEST_CYCLE()
{
mog2.getBackgroundImage(background);
}
}
INSTANTIATE_TEST_CASE_P(Video, MOG2_getBackgroundImage, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")),
testing::Values(/*Channels(1),*/ Channels(3)/*, Channels(4)*/)));
//////////////////////////////////////////////////////
// GMG
IMPLEMENT_PARAM_CLASS(MaxFeatures, int)
GPU_PERF_TEST(GMG, cv::gpu::DeviceInfo, std::string, Channels, MaxFeatures)
{
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
int cn = GET_PARAM(2);
int maxFeatures = GET_PARAM(3);
cv::VideoCapture cap(inputFile);
ASSERT_TRUE(cap.isOpened());
cv::Mat frame;
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
cv::Mat fgmask;
cv::Mat zeros(frame.size(), CV_8UC1, cv::Scalar::all(0));
cv::BackgroundSubtractorGMG gmg;
gmg.set("maxFeatures", maxFeatures);
gmg.initialize(frame.size(), 0.0, 255.0);
gmg(frame, fgmask);
for (int i = 0; i < 150; ++i)
{
cap >> frame;
if (frame.empty())
{
cap.open(inputFile);
cap >> frame;
}
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
startTimer(); next();
gmg(frame, fgmask);
stopTimer();
}
}
INSTANTIATE_TEST_CASE_P(Video, GMG, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi")),
testing::Values(Channels(1), Channels(3), Channels(4)),
testing::Values(MaxFeatures(20), MaxFeatures(40), MaxFeatures(60))));
//////////////////////////////////////////////////////
// VideoWriter
#ifdef WIN32
GPU_PERF_TEST(VideoWriter, cv::gpu::DeviceInfo, std::string)
{
const double FPS = 25.0;
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
std::string outputFile = cv::tempfile(".avi");
cv::VideoCapture reader(inputFile);
ASSERT_TRUE( reader.isOpened() );
cv::VideoWriter writer;
cv::Mat frame;
declare.time(30);
for (int i = 0; i < 10; ++i)
{
reader >> frame;
ASSERT_FALSE(frame.empty());
if (!writer.isOpened())
writer.open(outputFile, CV_FOURCC('X', 'V', 'I', 'D'), FPS, frame.size());
startTimer(); next();
writer.write(frame);
stopTimer();
}
}
INSTANTIATE_TEST_CASE_P(Video, VideoWriter, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi"))));
#endif // WIN32
//////////////////////////////////////////////////////
// VideoReader
GPU_PERF_TEST(VideoReader, cv::gpu::DeviceInfo, std::string)
{
std::string inputFile = perf::TestBase::getDataPath(std::string("gpu/video/") + GET_PARAM(1));
cv::VideoCapture reader(inputFile);
ASSERT_TRUE( reader.isOpened() );
cv::Mat frame;
reader >> frame;
declare.time(20);
TEST_CYCLE_N(10)
{
reader >> frame;
}
}
INSTANTIATE_TEST_CASE_P(Video, VideoReader, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi"))));
#endif

View File

@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
@ -49,87 +49,128 @@ using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
void print_info()
void printOsInfo()
{
printf("\n");
#if defined _WIN32
# if defined _WIN64
puts("OS: Windows 64");
cout << "OS: Windows x64 \n" << endl;
# else
puts("OS: Windows 32");
cout << "OS: Windows x32 \n" << endl;
# endif
#elif defined linux
# if defined _LP64
puts("OS: Linux 64");
cout << "OS: Linux x64 \n" << endl;
# else
puts("OS: Linux 32");
cout << "OS: Linux x32 \n" << endl;
# endif
#elif defined __APPLE__
# if defined _LP64
puts("OS: Apple 64");
cout << "OS: Apple x64 \n" << endl;
# else
puts("OS: Apple 32");
cout << "OS: Apple x32 \n" << endl;
# endif
#endif
}
int deviceCount = getCudaEnabledDeviceCount();
void printCudaInfo()
{
#ifndef HAVE_CUDA
cout << "OpenCV was built without CUDA support \n" << endl;
#else
int driver;
cudaDriverGetVersion(&driver);
printf("CUDA Driver version: %d\n", driver);
printf("CUDA Runtime version: %d\n", CUDART_VERSION);
printf("CUDA device count: %d\n\n", deviceCount);
cout << "CUDA Driver version: " << driver << '\n';
cout << "CUDA Runtime version: " << CUDART_VERSION << '\n';
cout << endl;
cout << "GPU module was compiled for the following GPU archs:" << endl;
cout << " BIN: " << CUDA_ARCH_BIN << '\n';
cout << " PTX: " << CUDA_ARCH_PTX << '\n';
cout << endl;
int deviceCount = getCudaEnabledDeviceCount();
cout << "CUDA device count: " << deviceCount << '\n';
cout << endl;
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
printf("Device %d:\n", i);
printf(" Name: %s\n", info.name().c_str());
printf(" Compute capability version: %d.%d\n", info.majorVersion(), info.minorVersion());
printf(" Total memory: %d Mb\n", static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0));
printf(" Free memory: %d Mb\n", static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0));
if (info.isCompatible())
puts(" This device is compatible with current GPU module build\n");
else
puts(" This device is NOT compatible with current GPU module build\n");
cout << "Device [" << i << "] \n";
cout << "\t Name: " << info.name() << '\n';
cout << "\t Compute capability: " << info.majorVersion() << '.' << info.minorVersion()<< '\n';
cout << "\t Multi Processor Count: " << info.multiProcessorCount() << '\n';
cout << "\t Total memory: " << static_cast<int>(static_cast<int>(info.totalMemory() / 1024.0) / 1024.0) << " Mb \n";
cout << "\t Free memory: " << static_cast<int>(static_cast<int>(info.freeMemory() / 1024.0) / 1024.0) << " Mb \n";
if (!info.isCompatible())
cout << "\t !!! This device is NOT compatible with current GPU module build \n";
cout << endl;
}
puts("GPU module was compiled for the following GPU archs:");
printf(" BIN: %s\n", CUDA_ARCH_BIN);
printf(" PTX: %s\n\n", CUDA_ARCH_PTX);
#endif
}
enum OutputLevel
{
OutputLevelNone,
OutputLevelCompact,
OutputLevelFull
};
extern OutputLevel nvidiaTestOutputLevel;
int main(int argc, char** argv)
{
TS::ptr()->init("gpu");
InitGoogleTest(&argc, argv);
try
{
CommandLineParser cmd(argc, (const char**)argv,
"{ print_info_only | print_info_only | false | Print information about system and exit }"
"{ device | device | -1 | Device on which tests will be executed (-1 means all devices) }"
"{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }"
);
const char* keys ="{ nvtest_output_level | nvtest_output_level | compact | NVidia test verbosity level }";
printOsInfo();
printCudaInfo();
CommandLineParser parser(argc, (const char**)argv, keys);
if (cmd.get<bool>("print_info_only"))
return 0;
string outputLevel = parser.get<string>("nvtest_output_level", "none");
int device = cmd.get<int>("device");
if (device < 0)
{
DeviceManager::instance().loadAll();
if (outputLevel == "none")
nvidiaTestOutputLevel = OutputLevelNone;
else if (outputLevel == "compact")
nvidiaTestOutputLevel = OutputLevelCompact;
else if (outputLevel == "full")
nvidiaTestOutputLevel = OutputLevelFull;
cout << "Run tests on all supported devices \n" << endl;
}
else
{
DeviceManager::instance().load(device);
print_info();
DeviceInfo info(device);
cout << "Run tests on device " << device << " [" << info.name() << "] \n" << endl;
}
return RUN_ALL_TESTS();
string outputLevel = cmd.get<string>("nvtest_output_level");
if (outputLevel == "none")
nvidiaTestOutputLevel = OutputLevelNone;
else if (outputLevel == "compact")
nvidiaTestOutputLevel = OutputLevelCompact;
else if (outputLevel == "full")
nvidiaTestOutputLevel = OutputLevelFull;
TS::ptr()->init("gpu");
InitGoogleTest(&argc, argv);
return RUN_ALL_TESTS();
}
catch (const exception& e)
{
cerr << e.what() << endl;
return -1;
}
catch (...)
{
cerr << "Unknown error" << endl;
return -1;
}
return 0;
}
#else // HAVE_CUDA

View File

@ -1,7 +1,7 @@
#ifndef __main_test_nvidia_h__
#define __main_test_nvidia_h__
#include<string>
#include <string>
enum OutputLevel
{
@ -10,6 +10,8 @@ enum OutputLevel
OutputLevelFull
};
extern OutputLevel nvidiaTestOutputLevel;
bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel);
bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel);
bool nvidia_NPPST_RectStdDev(const std::string& test_data_path, OutputLevel outputLevel);

View File

@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -329,7 +331,7 @@ TEST_P(ReprojectImageTo3D, Accuracy)
cv::gpu::GpuMat dst;
cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), dst, Q, 3);
cv::Mat dst_gold;
cv::reprojectImageTo3D(disp, dst_gold, Q, false);
@ -343,3 +345,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Calib3D, ReprojectImageTo3D, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -98,3 +100,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -3396,3 +3398,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Core, Reduce, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -984,3 +986,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Features2D, BruteForceMatcher, testing::Combine(
testing::Values(UseMask(false), UseMask(true))));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -552,3 +554,5 @@ INSTANTIATE_TEST_CASE_P(GPU_Filter, Filter2D, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,11 +39,11 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
#include <iostream>
using namespace std;
using namespace cv;
struct CompactPoints : testing::TestWithParam<gpu::DeviceInfo>
@ -85,3 +85,5 @@ TEST_P(CompactPoints, CanCompactizeSmallInput)
}
INSTANTIATE_TEST_CASE_P(GPU_GlobalMotion, CompactPoints, ALL_DEVICES);
#endif // HAVE_CUDA

View File

@ -40,7 +40,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -323,3 +325,5 @@ INSTANTIATE_TEST_CASE_P(GPU_GpuMat, ConvertTo, testing::Combine(
WHOLE_SUBMAT));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -1186,3 +1188,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughLines, testing::Combine(
std::string("../cv/shared/pic6.png"))));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,9 +39,7 @@
// the use of this software, even if advised of the possibility of such damage.
//M*/
#include "precomp.hpp"
#include <string>
#include <iostream>
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
@ -199,4 +197,4 @@ TEST_P(Labeling, ConnectedComponents)
INSTANTIATE_TEST_CASE_P(ConnectedComponents, Labeling, ALL_DEVICES);
#endif
#endif // HAVE_CUDA

View File

@ -39,21 +39,15 @@
//
//M*/
#include <main_test_nvidia.h>
#include "precomp.hpp"
#include "test_precomp.hpp"
OutputLevel nvidiaTestOutputLevel = OutputLevelCompact;
#ifdef HAVE_CUDA
using namespace cvtest;
using namespace testing;
//enum OutputLevel
//{
// OutputLevelNone,
// OutputLevelCompact,
// OutputLevelFull
//};
struct NVidiaTest : TestWithParam<cv::gpu::DeviceInfo>
{
cv::gpu::DeviceInfo devInfo;
@ -73,8 +67,6 @@ struct NVidiaTest : TestWithParam<cv::gpu::DeviceInfo>
struct NPPST : NVidiaTest {};
struct NCV : NVidiaTest {};
OutputLevel nvidiaTestOutputLevel = OutputLevelCompact;
//TEST_P(NPPST, Integral)
//{
// bool res = nvidia_NPPST_Integral_Image(path, nvidiaTestOutputLevel);

View File

@ -39,8 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include <string>
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
namespace {
@ -373,3 +374,5 @@ INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify,
testing::Combine(ALL_DEVICES, testing::Values<int>(0)));
} // namespace
#endif // HAVE_CUDA

View File

@ -39,4 +39,4 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"

View File

@ -57,8 +57,10 @@
#include <limits>
#include <algorithm>
#include <iterator>
#include <stdexcept>
#include "cvconfig.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/calib3d/calib3d.hpp"
@ -72,6 +74,7 @@
#include "utility.hpp"
#include "interpolation.hpp"
#include "main_test_nvidia.h"
#ifdef HAVE_CUDA
#include <cuda.h>

View File

@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@ -39,8 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include <iostream>
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@ -39,7 +39,9 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA
//#define DUMP
@ -865,3 +867,5 @@ TEST_P(VideoReader, Regression)
INSTANTIATE_TEST_CASE_P(GPU_Video, VideoReader, testing::Combine(
ALL_DEVICES,
testing::Values(std::string("768x576.avi"), std::string("1920x1080.avi"))));
#endif // HAVE_CUDA

View File

@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@ -39,7 +39,7 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
#ifdef HAVE_CUDA

View File

@ -39,13 +39,14 @@
//
//M*/
#include "precomp.hpp"
#include "test_precomp.hpp"
using namespace std;
using namespace cv;
using namespace cv::gpu;
using namespace cvtest;
using namespace testing;
using namespace testing::internal;
//////////////////////////////////////////////////////////////////////
// random generators
@ -108,12 +109,12 @@ GpuMat loadMat(const Mat& m, bool useRoi)
//////////////////////////////////////////////////////////////////////
// Image load
Mat readImage(const string& fileName, int flags)
Mat readImage(const std::string& fileName, int flags)
{
return imread(string(cvtest::TS::ptr()->get_data_path()) + fileName, flags);
return imread(TS::ptr()->get_data_path() + fileName, flags);
}
Mat readImageType(const string& fname, int type)
Mat readImageType(const std::string& fname, int type)
{
Mat src = readImage(fname, CV_MAT_CN(type) == 1 ? IMREAD_GRAYSCALE : IMREAD_COLOR);
if (CV_MAT_CN(type) == 4)
@ -134,50 +135,51 @@ bool supportFeature(const DeviceInfo& info, FeatureSet feature)
return TargetArchs::builtWith(feature) && info.supports(feature);
}
const vector<DeviceInfo>& devices()
DeviceManager& DeviceManager::instance()
{
static vector<DeviceInfo> devs;
static bool first = true;
if (first)
{
int deviceCount = getCudaEnabledDeviceCount();
devs.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
devs.push_back(info);
}
first = false;
}
return devs;
static DeviceManager obj;
return obj;
}
vector<DeviceInfo> devices(FeatureSet feature)
void DeviceManager::load(int i)
{
const vector<DeviceInfo>& d = devices();
devices_.clear();
devices_.reserve(1);
vector<DeviceInfo> devs_filtered;
ostringstream msg;
if (TargetArchs::builtWith(feature))
if (i < 0 || i >= getCudaEnabledDeviceCount())
{
devs_filtered.reserve(d.size());
for (size_t i = 0, size = d.size(); i < size; ++i)
{
const DeviceInfo& info = d[i];
if (info.supports(feature))
devs_filtered.push_back(info);
}
msg << "Incorrect device number - " << i;
throw runtime_error(msg.str());
}
return devs_filtered;
DeviceInfo info(i);
if (!info.isCompatible())
{
msg << "Device " << i << " [" << info.name() << "] is NOT compatible with current GPU module build";
throw runtime_error(msg.str());
}
devices_.push_back(info);
}
void DeviceManager::loadAll()
{
int deviceCount = getCudaEnabledDeviceCount();
devices_.clear();
devices_.reserve(deviceCount);
for (int i = 0; i < deviceCount; ++i)
{
DeviceInfo info(i);
if (info.isCompatible())
{
devices_.push_back(info);
}
}
}
//////////////////////////////////////////////////////////////////////
@ -250,7 +252,7 @@ void minMaxLocGold(const Mat& src, double* minVal_, double* maxVal_, Point* minL
namespace
{
template <typename T, typename OutT> string printMatValImpl(const Mat& m, Point p)
template <typename T, typename OutT> std::string printMatValImpl(const Mat& m, Point p)
{
const int cn = m.channels();
@ -269,9 +271,9 @@ namespace
return ostr.str();
}
string printMatVal(const Mat& m, Point p)
std::string printMatVal(const Mat& m, Point p)
{
typedef string (*func_t)(const Mat& m, Point p);
typedef std::string (*func_t)(const Mat& m, Point p);
static const func_t funcs[] =
{

View File

@ -80,14 +80,21 @@ cv::Mat readImageType(const std::string& fname, int type);
//! return true if device supports specified feature and gpu module was built with support the feature.
bool supportFeature(const cv::gpu::DeviceInfo& info, cv::gpu::FeatureSet feature);
//! return all devices compatible with current gpu module build.
const std::vector<cv::gpu::DeviceInfo>& devices();
class DeviceManager
{
public:
static DeviceManager& instance();
//! return all devices compatible with current gpu module build which support specified feature.
std::vector<cv::gpu::DeviceInfo> devices(cv::gpu::FeatureSet feature);
void load(int i);
void loadAll();
#define ALL_DEVICES testing::ValuesIn(devices())
#define DEVICES(feature) testing::ValuesIn(devices(feature))
const std::vector<cv::gpu::DeviceInfo>& values() const { return devices_; }
private:
std::vector<cv::gpu::DeviceInfo> devices_;
};
#define ALL_DEVICES testing::ValuesIn(DeviceManager::instance().values())
//////////////////////////////////////////////////////////////////////
// Additional assertion