int img_rows, int img_cols, int octave, bool use_mask, int nLayers);\r
\r
void icvInterpolateKeypoint_gpu(const PtrStepf& det, const int4* maxPosBuffer, unsigned int maxCounter,\r
- float* featureX, float* featureY, int* featureLaplacian, float* featureSize, float* featureHessian,\r
+ float* featureX, float* featureY, int* featureLaplacian, int* featureOctave, float* featureSize, float* featureHessian,\r
unsigned int* featureCounter);\r
\r
void icvCalcOrientation_gpu(const float* featureX, const float* featureY, const float* featureSize, float* featureDir, int nFeatures);\r
ensureSizeIsEnough(img_rows * (surf_.nOctaveLayers + 2), img_cols, CV_32FC1, surf_.trace);\r
\r
ensureSizeIsEnough(1, maxCandidates, CV_32SC4, surf_.maxPosBuffer);\r
- ensureSizeIsEnough(SURF_GPU::SF_FEATURE_STRIDE, maxFeatures, CV_32FC1, keypoints);\r
+ ensureSizeIsEnough(SURF_GPU::ROWS_COUNT, maxFeatures, CV_32FC1, keypoints);\r
keypoints.setTo(Scalar::all(0));\r
\r
for (int octave = 0; octave < surf_.nOctaves; ++octave)\r
if (maxCounter > 0)\r
{\r
icvInterpolateKeypoint_gpu(surf_.det, surf_.maxPosBuffer.ptr<int4>(), maxCounter,\r
- keypoints.ptr<float>(SURF_GPU::SF_X), keypoints.ptr<float>(SURF_GPU::SF_Y),\r
- keypoints.ptr<int>(SURF_GPU::SF_LAPLACIAN), keypoints.ptr<float>(SURF_GPU::SF_SIZE),\r
- keypoints.ptr<float>(SURF_GPU::SF_HESSIAN), counters.ptr<unsigned int>());\r
+ keypoints.ptr<float>(SURF_GPU::X_ROW), keypoints.ptr<float>(SURF_GPU::Y_ROW),\r
+ keypoints.ptr<int>(SURF_GPU::LAPLACIAN_ROW), keypoints.ptr<int>(SURF_GPU::OCTAVE_ROW), \r
+ keypoints.ptr<float>(SURF_GPU::SIZE_ROW), keypoints.ptr<float>(SURF_GPU::HESSIAN_ROW), \r
+ counters.ptr<unsigned int>());\r
}\r
}\r
unsigned int featureCounter;\r
keypoints.cols = featureCounter;\r
\r
if (surf_.upright)\r
- keypoints.row(SURF_GPU::SF_DIR).setTo(Scalar::all(90.0));\r
+ keypoints.row(SURF_GPU::ANGLE_ROW).setTo(Scalar::all(90.0));\r
else\r
findOrientation(keypoints);\r
}\r
const int nFeatures = keypoints.cols;\r
if (nFeatures > 0)\r
{\r
- icvCalcOrientation_gpu(keypoints.ptr<float>(SURF_GPU::SF_X), keypoints.ptr<float>(SURF_GPU::SF_Y),\r
- keypoints.ptr<float>(SURF_GPU::SF_SIZE), keypoints.ptr<float>(SURF_GPU::SF_DIR), nFeatures);\r
+ icvCalcOrientation_gpu(keypoints.ptr<float>(SURF_GPU::X_ROW), keypoints.ptr<float>(SURF_GPU::Y_ROW),\r
+ keypoints.ptr<float>(SURF_GPU::SIZE_ROW), keypoints.ptr<float>(SURF_GPU::ANGLE_ROW), nFeatures);\r
}\r
}\r
\r
if (nFeatures > 0)\r
{\r
ensureSizeIsEnough(nFeatures, descriptorSize, CV_32F, descriptors);\r
- compute_descriptors_gpu(descriptors, keypoints.ptr<float>(SURF_GPU::SF_X), keypoints.ptr<float>(SURF_GPU::SF_Y),\r
- keypoints.ptr<float>(SURF_GPU::SF_SIZE), keypoints.ptr<float>(SURF_GPU::SF_DIR), nFeatures);\r
+ compute_descriptors_gpu(descriptors, keypoints.ptr<float>(SURF_GPU::X_ROW), keypoints.ptr<float>(SURF_GPU::Y_ROW),\r
+ keypoints.ptr<float>(SURF_GPU::SIZE_ROW), keypoints.ptr<float>(SURF_GPU::ANGLE_ROW), nFeatures);\r
}\r
}\r
\r
keypointsGPU.release();\r
else\r
{\r
- Mat keypointsCPU(SURF_GPU::SF_FEATURE_STRIDE, static_cast<int>(keypoints.size()), CV_32FC1);\r
+ Mat keypointsCPU(SURF_GPU::ROWS_COUNT, static_cast<int>(keypoints.size()), CV_32FC1);\r
\r
- float* kp_x = keypointsCPU.ptr<float>(SURF_GPU::SF_X);\r
- float* kp_y = keypointsCPU.ptr<float>(SURF_GPU::SF_Y);\r
- int* kp_laplacian = keypointsCPU.ptr<int>(SURF_GPU::SF_LAPLACIAN);\r
- float* kp_size = keypointsCPU.ptr<float>(SURF_GPU::SF_SIZE);\r
- float* kp_dir = keypointsCPU.ptr<float>(SURF_GPU::SF_DIR);\r
- float* kp_hessian = keypointsCPU.ptr<float>(SURF_GPU::SF_HESSIAN);\r
+ float* kp_x = keypointsCPU.ptr<float>(SURF_GPU::X_ROW);\r
+ float* kp_y = keypointsCPU.ptr<float>(SURF_GPU::Y_ROW);\r
+ int* kp_laplacian = keypointsCPU.ptr<int>(SURF_GPU::LAPLACIAN_ROW);\r
+ int* kp_octave = keypointsCPU.ptr<int>(SURF_GPU::OCTAVE_ROW);\r
+ float* kp_size = keypointsCPU.ptr<float>(SURF_GPU::SIZE_ROW);\r
+ float* kp_dir = keypointsCPU.ptr<float>(SURF_GPU::ANGLE_ROW);\r
+ float* kp_hessian = keypointsCPU.ptr<float>(SURF_GPU::HESSIAN_ROW);\r
\r
for (size_t i = 0, size = keypoints.size(); i < size; ++i)\r
{\r
const KeyPoint& kp = keypoints[i];\r
kp_x[i] = kp.pt.x;\r
kp_y[i] = kp.pt.y;\r
+ kp_octave[i] = kp.octave;\r
kp_size[i] = kp.size;\r
kp_dir[i] = kp.angle;\r
kp_hessian[i] = kp.response;\r
}\r
}\r
\r
-namespace\r
-{\r
- int getPointOctave(float size, const SURF_GPU& params)\r
- {\r
- int best_octave = 0;\r
- float min_diff = numeric_limits<float>::max();\r
- for (int octave = 1; octave < params.nOctaves; ++octave)\r
- {\r
- for (int layer = 0; layer < params.nOctaveLayers; ++layer)\r
- {\r
- float diff = std::abs(size - (float)calcSize(octave, layer));\r
- if (min_diff > diff)\r
- {\r
- min_diff = diff;\r
- best_octave = octave;\r
- if (min_diff == 0)\r
- return best_octave;\r
- }\r
- }\r
- }\r
- return best_octave;\r
- }\r
-}\r
-\r
void cv::gpu::SURF_GPU::downloadKeypoints(const GpuMat& keypointsGPU, vector<KeyPoint>& keypoints)\r
{\r
const int nFeatures = keypointsGPU.cols;\r
keypoints.clear();\r
else\r
{\r
- CV_Assert(keypointsGPU.type() == CV_32FC1 && keypointsGPU.rows == SF_FEATURE_STRIDE);\r
+ CV_Assert(keypointsGPU.type() == CV_32FC1 && keypointsGPU.rows == ROWS_COUNT);\r
\r
Mat keypointsCPU(keypointsGPU);\r
\r
keypoints.resize(nFeatures);\r
-\r
- float* kp_x = keypointsCPU.ptr<float>(SF_X);\r
- float* kp_y = keypointsCPU.ptr<float>(SF_Y);\r
- int* kp_laplacian = keypointsCPU.ptr<int>(SF_LAPLACIAN);\r
- float* kp_size = keypointsCPU.ptr<float>(SF_SIZE);\r
- float* kp_dir = keypointsCPU.ptr<float>(SF_DIR);\r
- float* kp_hessian = keypointsCPU.ptr<float>(SF_HESSIAN);\r
+ \r
+ float* kp_x = keypointsCPU.ptr<float>(SURF_GPU::X_ROW);\r
+ float* kp_y = keypointsCPU.ptr<float>(SURF_GPU::Y_ROW);\r
+ int* kp_laplacian = keypointsCPU.ptr<int>(SURF_GPU::LAPLACIAN_ROW);\r
+ int* kp_octave = keypointsCPU.ptr<int>(SURF_GPU::OCTAVE_ROW);\r
+ float* kp_size = keypointsCPU.ptr<float>(SURF_GPU::SIZE_ROW);\r
+ float* kp_dir = keypointsCPU.ptr<float>(SURF_GPU::ANGLE_ROW);\r
+ float* kp_hessian = keypointsCPU.ptr<float>(SURF_GPU::HESSIAN_ROW);\r
\r
for (int i = 0; i < nFeatures; ++i)\r
{\r
kp.pt.x = kp_x[i];\r
kp.pt.y = kp_y[i];\r
kp.class_id = kp_laplacian[i];\r
+ kp.octave = kp_octave[i];\r
kp.size = kp_size[i];\r
kp.angle = kp_dir[i];\r
kp.response = kp_hessian[i];\r
- kp.octave = getPointOctave(kp.size, *this);\r
}\r
}\r
}\r
\r
IMPLEMENT_PARAM_CLASS(Anchor, cv::Point)\r
\r
-PARAM_TEST_CASE(Blur, cv::gpu::DeviceInfo, KSize, Anchor, UseRoi)\r
+PARAM_TEST_CASE(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
cv::Size ksize;\r
cv::Point anchor;\r
bool useRoi;\r
\r
- cv::Mat img;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- ksize = GET_PARAM(1);\r
- anchor = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ ksize = GET_PARAM(3);\r
+ anchor = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
}\r
};\r
\r
-TEST_P(Blur, Gray)\r
-{\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::blur(loadMat(img_gray, useRoi), dst, ksize, anchor);\r
-\r
- cv::Mat dst_gold;\r
- cv::blur(img_gray, dst_gold, ksize, anchor);\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);\r
-}\r
-\r
-TEST_P(Blur, Color)\r
+TEST_P(Blur, Accuracy)\r
{\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::blur(loadMat(img_rgba, useRoi), dst, ksize, anchor);\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::blur(loadMat(src, useRoi), dst, ksize, anchor);\r
\r
cv::Mat dst_gold;\r
- cv::blur(img_rgba, dst_gold, ksize, anchor);\r
+ cv::blur(src, dst_gold, ksize, anchor);\r
\r
EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 1.0);\r
}\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, Blur, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
testing::Values(KSize(3, 3), KSize(5, 5), KSize(7, 7)),\r
testing::Values(Anchor(cv::Point(-1, -1)), Anchor(cv::Point(0, 0)), Anchor(cv::Point(2, 2))),\r
WHOLE_SUBMAT));\r
IMPLEMENT_PARAM_CLASS(Deriv_X, int)\r
IMPLEMENT_PARAM_CLASS(Deriv_Y, int)\r
\r
-PARAM_TEST_CASE(Sobel, cv::gpu::DeviceInfo, KSize, Deriv_X, Deriv_Y, BorderType, UseRoi)\r
+PARAM_TEST_CASE(Sobel, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Deriv_X, Deriv_Y, BorderType, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
cv::Size ksize;\r
int dx;\r
int dy;\r
int borderType;\r
bool useRoi;\r
\r
- cv::Mat img;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- ksize = GET_PARAM(1);\r
- dx = GET_PARAM(2);\r
- dy = GET_PARAM(3);\r
- borderType = GET_PARAM(4);\r
- useRoi = GET_PARAM(5);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ ksize = GET_PARAM(3);\r
+ dx = GET_PARAM(4);\r
+ dy = GET_PARAM(5);\r
+ borderType = GET_PARAM(6);\r
+ useRoi = GET_PARAM(7);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
}\r
};\r
\r
-TEST_P(Sobel, Gray)\r
-{\r
- if (dx == 0 && dy == 0)\r
- return;\r
-\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::Sobel(loadMat(img_gray, useRoi), dst, -1, dx, dy, ksize.width, 1.0, borderType);\r
-\r
- cv::Mat dst_gold;\r
- cv::Sobel(img_gray, dst_gold, -1, dx, dy, ksize.width, 1.0, 0.0, borderType);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(Sobel, Color)\r
+TEST_P(Sobel, Accuracy)\r
{\r
if (dx == 0 && dy == 0)\r
return;\r
\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::Sobel(loadMat(img_rgba, useRoi), dst, -1, dx, dy, ksize.width, 1.0, borderType);\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::Sobel(loadMat(src, useRoi), dst, -1, dx, dy, ksize.width, 1.0, borderType);\r
\r
cv::Mat dst_gold;\r
- cv::Sobel(img_rgba, dst_gold, -1, dx, dy, ksize.width, 1.0, 0.0, borderType);\r
+ cv::Sobel(src, dst_gold, -1, dx, dy, ksize.width, 1.0, 0.0, borderType);\r
\r
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
}\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, Sobel, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
testing::Values(KSize(3, 3), KSize(5, 5), KSize(7, 7)),\r
testing::Values(Deriv_X(0), Deriv_X(1), Deriv_X(2)),\r
testing::Values(Deriv_Y(0), Deriv_Y(1), Deriv_Y(2)),\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// Scharr\r
\r
-PARAM_TEST_CASE(Scharr, cv::gpu::DeviceInfo, Deriv_X, Deriv_Y, BorderType, UseRoi)\r
+PARAM_TEST_CASE(Scharr, cv::gpu::DeviceInfo, cv::Size, MatType, Deriv_X, Deriv_Y, BorderType, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
int dx;\r
int dy;\r
int borderType;\r
bool useRoi;\r
\r
- cv::Mat img;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- dx = GET_PARAM(1);\r
- dy = GET_PARAM(2);\r
- borderType = GET_PARAM(3);\r
- useRoi = GET_PARAM(4);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ dx = GET_PARAM(3);\r
+ dy = GET_PARAM(4);\r
+ borderType = GET_PARAM(5);\r
+ useRoi = GET_PARAM(6);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
}\r
};\r
\r
-TEST_P(Scharr, Gray)\r
-{\r
- if (dx + dy != 1)\r
- return;\r
-\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::Scharr(loadMat(img_gray, useRoi), dst, -1, dx, dy, 1.0, borderType);\r
-\r
- cv::Mat dst_gold;\r
- cv::Scharr(img_gray, dst_gold, -1, dx, dy, 1.0, 0.0, borderType);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
-}\r
-\r
-TEST_P(Scharr, Color)\r
+TEST_P(Scharr, Accuracy)\r
{\r
if (dx + dy != 1)\r
return;\r
\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::Scharr(loadMat(img_rgba, useRoi), dst, -1, dx, dy, 1.0, borderType);\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::Scharr(loadMat(src, useRoi), dst, -1, dx, dy, 1.0, borderType);\r
\r
cv::Mat dst_gold;\r
- cv::Scharr(img_rgba, dst_gold, -1, dx, dy, 1.0, 0.0, borderType);\r
+ cv::Scharr(src, dst_gold, -1, dx, dy, 1.0, 0.0, borderType);\r
\r
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
}\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, Scharr, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
testing::Values(Deriv_X(0), Deriv_X(1)),\r
testing::Values(Deriv_Y(0), Deriv_Y(1)),\r
testing::Values(BorderType(cv::BORDER_REFLECT101),\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// GaussianBlur\r
\r
-PARAM_TEST_CASE(GaussianBlur, cv::gpu::DeviceInfo, KSize, BorderType, UseRoi)\r
+PARAM_TEST_CASE(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, BorderType, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
cv::Size ksize;\r
int borderType;\r
bool useRoi;\r
\r
- cv::Mat img;\r
- double sigma1, sigma2;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- ksize = GET_PARAM(1);\r
- borderType = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ ksize = GET_PARAM(3);\r
+ borderType = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
-\r
- sigma1 = randomDouble(0.1, 1.0);\r
- sigma2 = randomDouble(0.1, 1.0);\r
}\r
};\r
\r
-TEST_P(GaussianBlur, Gray)\r
-{\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::GaussianBlur(loadMat(img_gray, useRoi), dst, ksize, sigma1, sigma2, borderType);\r
-\r
- cv::Mat dst_gold;\r
- cv::GaussianBlur(img_gray, dst_gold, ksize, sigma1, sigma2, borderType);\r
-\r
- EXPECT_MAT_NEAR(dst_gold, dst, 4.0);\r
-}\r
-\r
-TEST_P(GaussianBlur, Color)\r
+TEST_P(GaussianBlur, Accuracy)\r
{\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
+ double sigma1 = randomDouble(0.1, 1.0);\r
+ double sigma2 = randomDouble(0.1, 1.0);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::GaussianBlur(loadMat(img_rgba, useRoi), dst, ksize, sigma1, sigma2, borderType);\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::GaussianBlur(loadMat(src, useRoi), dst, ksize, sigma1, sigma2, borderType);\r
\r
cv::Mat dst_gold;\r
- cv::GaussianBlur(img_rgba, dst_gold, ksize, sigma1, sigma2, borderType);\r
+ cv::GaussianBlur(src, dst_gold, ksize, sigma1, sigma2, borderType);\r
\r
EXPECT_MAT_NEAR(dst_gold, dst, 4.0);\r
}\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, GaussianBlur, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
testing::Values(KSize(3, 3),\r
KSize(5, 5),\r
KSize(7, 7),\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// Laplacian\r
\r
-PARAM_TEST_CASE(Laplacian, cv::gpu::DeviceInfo, KSize, UseRoi)\r
+PARAM_TEST_CASE(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
cv::Size ksize;\r
bool useRoi;\r
\r
- cv::Mat img;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- ksize = GET_PARAM(1);\r
- useRoi = GET_PARAM(2);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ ksize = GET_PARAM(3);\r
+ useRoi = GET_PARAM(4);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
}\r
};\r
\r
-TEST_P(Laplacian, Gray)\r
-{\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::Laplacian(loadMat(img_gray, useRoi), dst, -1, ksize.width);\r
-\r
- cv::Mat dst_gold;\r
- cv::Laplacian(img_gray, dst_gold, -1, ksize.width);\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, cv::Size(3, 3)), getInnerROI(dst, cv::Size(3, 3)), 0.0);\r
-}\r
-\r
-TEST_P(Laplacian, Color)\r
+TEST_P(Laplacian, Accuracy)\r
{\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::Laplacian(loadMat(img_rgba, useRoi), dst, -1, ksize.width);\r
-\r
- cv::Mat dst_gold;\r
- cv::Laplacian(img_rgba, dst_gold, -1, ksize.width);\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, cv::Size(3, 3)), getInnerROI(dst, cv::Size(3, 3)), 0.0);\r
-}\r
-\r
-TEST_P(Laplacian, Gray_32FC1)\r
-{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, CV_BGR2GRAY);\r
- src.convertTo(src, CV_32F, 1.0 / 255.0);\r
-\r
- cv::gpu::GpuMat dst;\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
cv::gpu::Laplacian(loadMat(src, useRoi), dst, -1, ksize.width);\r
\r
cv::Mat dst_gold;\r
cv::Laplacian(src, dst_gold, -1, ksize.width);\r
\r
- EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+ if (type == CV_32FC1)\r
+ EXPECT_MAT_NEAR(dst_gold, dst, 0.0);\r
+ else\r
+ EXPECT_MAT_NEAR(getInnerROI(dst_gold, cv::Size(3, 3)), getInnerROI(dst, cv::Size(3, 3)), 0.0);\r
}\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, Laplacian, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),\r
testing::Values(KSize(1, 1), KSize(3, 3)),\r
WHOLE_SUBMAT));\r
\r
\r
IMPLEMENT_PARAM_CLASS(Iterations, int)\r
\r
-PARAM_TEST_CASE(Erode, cv::gpu::DeviceInfo, Anchor, Iterations, UseRoi)\r
+PARAM_TEST_CASE(Erode, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iterations, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
cv::Point anchor;\r
int iterations;\r
bool useRoi;\r
\r
- cv::Mat img;\r
- cv::Mat kernel;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- anchor = GET_PARAM(1);\r
- iterations = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ anchor = GET_PARAM(3);\r
+ iterations = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
-\r
- kernel = cv::Mat::ones(3, 3, CV_8U);\r
}\r
};\r
\r
-TEST_P(Erode, Gray)\r
-{\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::erode(loadMat(img_gray, useRoi), dst, kernel, anchor, iterations);\r
-\r
- cv::Mat dst_gold;\r
- cv::erode(img_gray, dst_gold, kernel, anchor, iterations);\r
-\r
- cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);\r
-}\r
-\r
-TEST_P(Erode, Color)\r
+TEST_P(Erode, Accuracy)\r
{\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::erode(loadMat(img_rgba, useRoi), dst, kernel, anchor, iterations);\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::erode(loadMat(src, useRoi), dst, kernel, anchor, iterations);\r
\r
cv::Mat dst_gold;\r
- cv::erode(img_rgba, dst_gold, kernel, anchor, iterations);\r
+ cv::erode(src, dst_gold, kernel, anchor, iterations);\r
\r
cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));\r
\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, Erode, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
testing::Values(Anchor(cv::Point(-1, -1)), Anchor(cv::Point(0, 0)), Anchor(cv::Point(2, 2))),\r
testing::Values(Iterations(1), Iterations(2), Iterations(3)),\r
WHOLE_SUBMAT));\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// Dilate\r
\r
-PARAM_TEST_CASE(Dilate, cv::gpu::DeviceInfo, Anchor, Iterations, UseRoi)\r
+PARAM_TEST_CASE(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iterations, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
cv::Point anchor;\r
int iterations;\r
bool useRoi;\r
\r
- cv::Mat img;\r
- cv::Mat kernel;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- anchor = GET_PARAM(1);\r
- iterations = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ anchor = GET_PARAM(3);\r
+ iterations = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
-\r
- kernel = cv::Mat::ones(3, 3, CV_8U);\r
}\r
};\r
\r
-TEST_P(Dilate, Gray)\r
-{\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::dilate(loadMat(img_gray, useRoi), dst, kernel, anchor, iterations);\r
-\r
- cv::Mat dst_gold;\r
- cv::dilate(img_gray, dst_gold, kernel, anchor, iterations);\r
-\r
- cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);\r
-}\r
-\r
-TEST_P(Dilate, Color)\r
+TEST_P(Dilate, Accuracy)\r
{\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::dilate(loadMat(img_rgba, useRoi), dst, kernel, anchor, iterations);\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::dilate(loadMat(src, useRoi), dst, kernel, anchor, iterations);\r
\r
cv::Mat dst_gold;\r
- cv::dilate(img_rgba, dst_gold, kernel, anchor, iterations);\r
+ cv::dilate(src, dst_gold, kernel, anchor, iterations);\r
\r
cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));\r
\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, Dilate, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
testing::Values(Anchor(cv::Point(-1, -1)), Anchor(cv::Point(0, 0)), Anchor(cv::Point(2, 2))),\r
testing::Values(Iterations(1), Iterations(2), Iterations(3)),\r
WHOLE_SUBMAT));\r
CV_ENUM(MorphOp, cv::MORPH_OPEN, cv::MORPH_CLOSE, cv::MORPH_GRADIENT, cv::MORPH_TOPHAT, cv::MORPH_BLACKHAT)\r
#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))\r
\r
-PARAM_TEST_CASE(MorphEx, cv::gpu::DeviceInfo, MorphOp, Anchor, Iterations, UseRoi)\r
+PARAM_TEST_CASE(MorphEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp, Anchor, Iterations, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
int morphOp;\r
cv::Point anchor;\r
int iterations;\r
bool useRoi;\r
\r
- cv::Mat img;\r
- cv::Mat kernel;\r
-\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- morphOp = GET_PARAM(1);\r
- anchor = GET_PARAM(2);\r
- iterations = GET_PARAM(3);\r
- useRoi = GET_PARAM(4);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ morphOp = GET_PARAM(3);\r
+ anchor = GET_PARAM(4);\r
+ iterations = GET_PARAM(5);\r
+ useRoi = GET_PARAM(6);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
-\r
- kernel = cv::Mat::ones(3, 3, CV_8U);\r
}\r
};\r
\r
-TEST_P(MorphEx, Gray)\r
-{\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::morphologyEx(loadMat(img_gray, useRoi), dst, morphOp, kernel, anchor, iterations);\r
-\r
- cv::Mat dst_gold;\r
- cv::morphologyEx(img_gray, dst_gold, morphOp, kernel, anchor, iterations);\r
-\r
- cv::Size border = cv::Size(kernel.cols + (iterations + 1) * kernel.cols + 2, kernel.rows + (iterations + 1) * kernel.rows + 2);\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, border), getInnerROI(dst, border), 0.0);\r
-}\r
-\r
-TEST_P(MorphEx, Color)\r
+TEST_P(MorphEx, Accuracy)\r
{\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);\r
\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::morphologyEx(loadMat(img_rgba, useRoi), dst, morphOp, kernel, anchor, iterations);\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
+ cv::gpu::morphologyEx(loadMat(src, useRoi), dst, morphOp, kernel, anchor, iterations);\r
\r
cv::Mat dst_gold;\r
- cv::morphologyEx(img_rgba, dst_gold, morphOp, kernel, anchor, iterations);\r
+ cv::morphologyEx(src, dst_gold, morphOp, kernel, anchor, iterations);\r
\r
cv::Size border = cv::Size(kernel.cols + (iterations + 1) * kernel.cols + 2, kernel.rows + (iterations + 1) * kernel.rows + 2);\r
\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, MorphEx, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4)),\r
ALL_MORPH_OPS,\r
testing::Values(Anchor(cv::Point(-1, -1)), Anchor(cv::Point(0, 0)), Anchor(cv::Point(2, 2))),\r
testing::Values(Iterations(1), Iterations(2), Iterations(3)),\r
/////////////////////////////////////////////////////////////////////////////////////////////////\r
// Filter2D\r
\r
-PARAM_TEST_CASE(Filter2D, cv::gpu::DeviceInfo, KSize, Anchor, UseRoi)\r
+PARAM_TEST_CASE(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor, UseRoi)\r
{\r
cv::gpu::DeviceInfo devInfo;\r
+ cv::Size size;\r
+ int type;\r
cv::Size ksize;\r
cv::Point anchor;\r
bool useRoi;\r
virtual void SetUp()\r
{\r
devInfo = GET_PARAM(0);\r
- ksize = GET_PARAM(1);\r
- anchor = GET_PARAM(2);\r
- useRoi = GET_PARAM(3);\r
+ size = GET_PARAM(1);\r
+ type = GET_PARAM(2);\r
+ ksize = GET_PARAM(3);\r
+ anchor = GET_PARAM(4);\r
+ useRoi = GET_PARAM(5);\r
\r
cv::gpu::setDevice(devInfo.deviceID());\r
-\r
- img = readImage("stereobp/aloe-L.png");\r
- ASSERT_FALSE(img.empty());\r
-\r
- kernel = cv::Mat::ones(ksize.height, ksize.width, CV_32FC1);\r
}\r
};\r
\r
-TEST_P(Filter2D, Gray)\r
-{\r
- cv::Mat img_gray;\r
- cv::cvtColor(img, img_gray, CV_BGR2GRAY);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::filter2D(loadMat(img_gray, useRoi), dst, -1, kernel, anchor);\r
-\r
- cv::Mat dst_gold;\r
- cv::filter2D(img_gray, dst_gold, -1, kernel, anchor, 0, cv::BORDER_CONSTANT);\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);\r
-}\r
-\r
-TEST_P(Filter2D, Color)\r
-{\r
- cv::Mat img_rgba;\r
- cv::cvtColor(img, img_rgba, CV_BGR2BGRA);\r
-\r
- cv::gpu::GpuMat dst;\r
- cv::gpu::filter2D(loadMat(img_rgba, useRoi), dst, -1, kernel, anchor);\r
-\r
- cv::Mat dst_gold;\r
- cv::filter2D(img_rgba, dst_gold, -1, kernel, anchor, 0, cv::BORDER_CONSTANT);\r
-\r
- EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);\r
-}\r
-\r
-TEST_P(Filter2D, Gray_32FC1)\r
+TEST_P(Filter2D, Accuracy)\r
{\r
- cv::Mat src;\r
- cv::cvtColor(img, src, CV_BGR2GRAY);\r
- src.convertTo(src, CV_32F, 1.0 / 255.0);\r
+ cv::Mat src = randomMat(size, type);\r
+ cv::Mat kernel = cv::Mat::ones(ksize.height, ksize.width, CV_32FC1);\r
\r
- cv::gpu::GpuMat dst;\r
+ cv::gpu::GpuMat dst = createMat(size, type, useRoi);\r
cv::gpu::filter2D(loadMat(src, useRoi), dst, -1, kernel, anchor);\r
\r
cv::Mat dst_gold;\r
- cv::filter2D(src, dst_gold, -1, kernel, anchor);\r
+ cv::filter2D(src, dst_gold, -1, kernel, anchor, 0, type == CV_32FC1 ? cv::BORDER_DEFAULT : cv::BORDER_CONSTANT);\r
\r
- EXPECT_MAT_NEAR(dst_gold, dst, 1e-3);\r
+ if (type == CV_32FC1)\r
+ EXPECT_MAT_NEAR(dst_gold, dst, 1e-1);\r
+ else\r
+ EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);\r
}\r
\r
INSTANTIATE_TEST_CASE_P(GPU_Filter, Filter2D, testing::Combine(\r
ALL_DEVICES,\r
+ DIFFERENT_SIZES,\r
+ testing::Values(MatType(CV_8UC1), MatType(CV_8UC4), MatType(CV_32FC1)),\r
testing::Values(KSize(3, 3), KSize(5, 5), KSize(7, 7), KSize(11, 11), KSize(13, 13), KSize(15, 15)),\r
testing::Values(Anchor(cv::Point(-1, -1)), Anchor(cv::Point(0, 0)), Anchor(cv::Point(2, 2))),\r
WHOLE_SUBMAT));\r