From 05d888316a1f8ae93a15ba804a942b2d6d2f6bfd Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Thu, 14 May 2015 16:25:18 +0300 Subject: [PATCH] added test for http://code.opencv.org/issues/2957 --- modules/imgproc/test/test_contours.cpp | 61 ++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/modules/imgproc/test/test_contours.cpp b/modules/imgproc/test/test_contours.cpp index b0b8c4fbb..b94408d3b 100644 --- a/modules/imgproc/test/test_contours.cpp +++ b/modules/imgproc/test/test_contours.cpp @@ -40,6 +40,7 @@ //M*/ #include "test_precomp.hpp" +#include "opencv2/highgui.hpp" using namespace cv; using namespace std; @@ -429,4 +430,64 @@ TEST(Core_Drawing, polylines) int cnt = countNonZero(img); ASSERT_EQ(cnt, 21); } + +//rotate/flip a quadrant appropriately +static void rot(int n, int *x, int *y, int rx, int ry) +{ + if (ry == 0) { + if (rx == 1) { + *x = n-1 - *x; + *y = n-1 - *y; + } + + //Swap x and y + int t = *x; + *x = *y; + *y = t; + } +} + +static void d2xy(int n, int d, int *x, int *y) +{ + int rx, ry, s, t=d; + *x = *y = 0; + for (s=1; s > contours; + findContours(img, contours, noArray(), RETR_LIST, CHAIN_APPROX_SIMPLE); + printf("ncontours = %d, contour[0].npoints=%d\n", (int)contours.size(), (int)contours[0].size()); + img.setTo(Scalar::all(0)); + + drawContours(img, contours, 0, Scalar::all(255), 1); + //imshow("hilbert", img); + //waitKey(); + ASSERT_EQ(1, (int)contours.size()); + ASSERT_EQ(9832, (int)contours[0].size()); +} + /* End of file. */