From b6a093fba16c3719867ac7c0645c5cf83d6654ee Mon Sep 17 00:00:00 2001 From: Tomoaki Teshima Date: Mon, 16 May 2016 06:45:35 +0900 Subject: [PATCH] accept multiple channels image for threshold on cuda * modify test, too --- modules/cudaarithm/src/cuda/threshold.cu | 4 +++- modules/cudaarithm/test/test_element_operations.cpp | 13 ++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/modules/cudaarithm/src/cuda/threshold.cu b/modules/cudaarithm/src/cuda/threshold.cu index a5b8f07ce3..1249fee04b 100644 --- a/modules/cudaarithm/src/cuda/threshold.cu +++ b/modules/cudaarithm/src/cuda/threshold.cu @@ -101,10 +101,12 @@ double cv::cuda::threshold(InputArray _src, OutputArray _dst, double thresh, dou const int depth = src.depth(); - CV_Assert( src.channels() == 1 && depth <= CV_64F ); + CV_Assert( depth <= CV_64F ); CV_Assert( type <= 4 /*THRESH_TOZERO_INV*/ ); GpuMat dst = getOutputMat(_dst, src.size(), src.type(), stream); + src = src.reshape(1); + dst = dst.reshape(1); if (depth == CV_32F && type == 2 /*THRESH_TRUNC*/) { diff --git a/modules/cudaarithm/test/test_element_operations.cpp b/modules/cudaarithm/test/test_element_operations.cpp index a4a16ea89f..b3a2243500 100644 --- a/modules/cudaarithm/test/test_element_operations.cpp +++ b/modules/cudaarithm/test/test_element_operations.cpp @@ -2532,11 +2532,12 @@ INSTANTIATE_TEST_CASE_P(CUDA_Arithm, AddWeighted, testing::Combine( 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)) -PARAM_TEST_CASE(Threshold, cv::cuda::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi) +PARAM_TEST_CASE(Threshold, cv::cuda::DeviceInfo, cv::Size, MatType, Channels, ThreshOp, UseRoi) { cv::cuda::DeviceInfo devInfo; cv::Size size; int type; + int channel; int threshOp; bool useRoi; @@ -2545,8 +2546,9 @@ PARAM_TEST_CASE(Threshold, cv::cuda::DeviceInfo, cv::Size, MatType, ThreshOp, Us devInfo = GET_PARAM(0); size = GET_PARAM(1); type = GET_PARAM(2); - threshOp = GET_PARAM(3); - useRoi = GET_PARAM(4); + channel = GET_PARAM(3); + threshOp = GET_PARAM(4); + useRoi = GET_PARAM(5); cv::cuda::setDevice(devInfo.deviceID()); } @@ -2554,7 +2556,7 @@ PARAM_TEST_CASE(Threshold, cv::cuda::DeviceInfo, cv::Size, MatType, ThreshOp, Us CUDA_TEST_P(Threshold, Accuracy) { - cv::Mat src = randomMat(size, type); + cv::Mat src = randomMat(size, CV_MAKE_TYPE(type, channel)); double maxVal = randomDouble(20.0, 127.0); double thresh = randomDouble(0.0, maxVal); @@ -2570,7 +2572,8 @@ CUDA_TEST_P(Threshold, Accuracy) INSTANTIATE_TEST_CASE_P(CUDA_Arithm, Threshold, testing::Combine( ALL_DEVICES, DIFFERENT_SIZES, - testing::Values(MatType(CV_8UC1), MatType(CV_16SC1), MatType(CV_32FC1)), + testing::Values(MatDepth(CV_8U), MatDepth(CV_16S), MatDepth(CV_32F)), + ALL_CHANNELS, ALL_THRESH_OPS, WHOLE_SUBMAT));