From 84176fa027b797246fbed97fd97ef57161ff5f90 Mon Sep 17 00:00:00 2001
From: Kirill Kornyakov <kirill.kornyakov@itseez.com>
Date: Fri, 12 Oct 2012 17:10:58 +0400
Subject: [PATCH] Added perf test for warpPerpsective with large resolutions

---
 modules/imgproc/perf/perf_warp.cpp        | 44 +++++++++++++++++++++++
 modules/ts/include/opencv2/ts/ts_perf.hpp |  2 ++
 2 files changed, 46 insertions(+)

diff --git a/modules/imgproc/perf/perf_warp.cpp b/modules/imgproc/perf/perf_warp.cpp
index cb15bac54..082571ff2 100644
--- a/modules/imgproc/perf/perf_warp.cpp
+++ b/modules/imgproc/perf/perf_warp.cpp
@@ -80,6 +80,50 @@ PERF_TEST_P( TestWarpPerspective, WarpPerspective,
     SANITY_CHECK(dst);
 }
 
+PERF_TEST_P( TestWarpPerspective, WarpPerspectiveLarge,
+             Combine(
+                Values( sz3MP, sz5MP ),
+                ValuesIn( InterType::all() ),
+                ValuesIn( BorderMode::all() )
+             )
+)
+{
+    Size sz;
+    int borderMode, interType;
+    sz         = get<0>(GetParam());
+    borderMode = get<1>(GetParam());
+    interType  = get<2>(GetParam());
+
+    string resolution;
+    if (sz == sz3MP)
+        resolution = "3MP";
+    else if (sz == sz5MP)
+        resolution = "5MP";
+    else
+        FAIL();
+
+    Mat src, img = imread(getDataPath("cv/shared/" + resolution + ".png"));
+    cvtColor(img, src, COLOR_BGR2BGRA, 4);
+
+    int shift = 103;
+    Mat srcVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, 0), Vec2f(sz.width-1, 0),
+                                            Vec2f(sz.width-1, sz.height-1), Vec2f(0, sz.height-1));
+    Mat dstVertices = (Mat_<Vec2f>(1, 4) << Vec2f(0, shift), Vec2f(sz.width-shift/2, 0),
+                                            Vec2f(sz.width-shift, sz.height-shift), Vec2f(shift/2, sz.height-1));
+    Mat warpMat = getPerspectiveTransform(srcVertices, dstVertices);
+
+    Mat dst(sz, CV_8UC4);
+
+    declare.in(src).out(dst);
+
+    TEST_CYCLE()
+        warpPerspective( src, dst, warpMat, sz, interType, borderMode, Scalar::all(150) );
+
+    SANITY_CHECK(dst);
+
+    imwrite("/home/kir/temp/dst" + resolution + ".png", dst);
+}
+
 PERF_TEST_P( TestRemap, remap,
              Combine(
                  Values( TYPICAL_MAT_TYPES ),
diff --git a/modules/ts/include/opencv2/ts/ts_perf.hpp b/modules/ts/include/opencv2/ts/ts_perf.hpp
index 22538ef3a..a50373444 100644
--- a/modules/ts/include/opencv2/ts/ts_perf.hpp
+++ b/modules/ts/include/opencv2/ts/ts_perf.hpp
@@ -49,6 +49,8 @@ const cv::Size sz1440p = szWQHD;
 const cv::Size sz2160p = cv::Size(3840, 2160);//UHDTV1 4K
 const cv::Size sz4320p = cv::Size(7680, 4320);//UHDTV2 8K
 
+const cv::Size sz3MP = cv::Size(2048, 1536);
+const cv::Size sz5MP = cv::Size(2592, 1944);
 const cv::Size sz2K = cv::Size(2048, 2048);
 
 const cv::Size szODD = cv::Size(127, 61);