}\r
};\r
\r
+struct CV_GpuNormTest : CvTest \r
+{\r
+ CV_GpuNormTest() : CvTest("GPU-Norm", "norm") {}\r
+\r
+ void run(int)\r
+ {\r
+ try\r
+ {\r
+ RNG rng(0);\r
+\r
+ int rows = rng.uniform(1, 500);\r
+ int cols = rng.uniform(1, 500);\r
+\r
+ for (int cn = 1; cn <= 4; ++cn)\r
+ {\r
+ test(NORM_L1, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
+ test(NORM_L1, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_L1, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
+ test(NORM_L1, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_L1, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_L1, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
+\r
+ test(NORM_L2, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
+ test(NORM_L2, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_L2, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
+ test(NORM_L2, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_L2, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_L2, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
+\r
+ test(NORM_INF, rows, cols, CV_8U, cn, Scalar::all(0), Scalar::all(10));\r
+ test(NORM_INF, rows, cols, CV_8S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_INF, rows, cols, CV_16U, cn, Scalar::all(0), Scalar::all(10));\r
+ test(NORM_INF, rows, cols, CV_16S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_INF, rows, cols, CV_32S, cn, Scalar::all(-10), Scalar::all(10));\r
+ test(NORM_INF, rows, cols, CV_32F, cn, Scalar::all(0), Scalar::all(1));\r
+ }\r
+ }\r
+ catch (const cv::Exception& e)\r
+ {\r
+ ts->printf(CvTS::CONSOLE, e.what());\r
+ if (!check_and_treat_gpu_exception(e, ts)) throw;\r
+ return;\r
+ }\r
+ }\r
+\r
+ void gen(Mat& mat, int rows, int cols, int type, Scalar low, Scalar high)\r
+ {\r
+ mat.create(rows, cols, type);\r
+ RNG rng(0);\r
+ rng.fill(mat, RNG::UNIFORM, low, high);\r
+ }\r
+\r
+ void test(int norm_type, int rows, int cols, int depth, int cn, Scalar low, Scalar high)\r
+ {\r
+ int type = CV_MAKE_TYPE(depth, cn);\r
+\r
+ Mat src;\r
+ gen(src, rows, cols, type, low, high);\r
+\r
+ double gold = norm(src, norm_type);\r
+ double mine = norm(GpuMat(src), norm_type);\r
+\r
+ if (abs(gold - mine) > 1e-3)\r
+ {\r
+ ts->printf(CvTS::CONSOLE, "failed test: gold=%f, mine=%f, norm_type=%d, rows=%d, "\r
+ "cols=%d, depth=%d, cn=%d\n", gold, mine, norm_type, rows, cols, depth, cn);\r
+ ts->set_failed_test_info(CvTS::FAIL_INVALID_OUTPUT);\r
+ }\r
+ }\r
+};\r
+\r
/////////////////////////////////////////////////////////////////////////////\r
/////////////////// tests registration /////////////////////////////////////\r
/////////////////////////////////////////////////////////////////////////////\r
CV_GpuCornerHarrisTest CV_GpuCornerHarris_test;\r
CV_GpuCornerMinEigenValTest CV_GpuCornerMinEigenVal_test;\r
CV_GpuColumnSumTest CV_GpuColumnSum_test;\r
-\r
+CV_GpuNormTest CV_GpuNormTest_test;\r