From dc93c21962737524501e85f296e0d6bfd3186f34 Mon Sep 17 00:00:00 2001 From: Andrey Pavlenko Date: Wed, 20 Jun 2012 07:43:01 +0000 Subject: [PATCH] fix for #2063 ( Mat(Mat m, Rect roi) returns wrong sub-mat) --- .../src/org/opencv/test/core/MatTest.java | 23 ++++++++++++++++++---- modules/java/src/java/core+Mat.java | 2 +- 2 files changed, 20 insertions(+), 5 deletions(-) diff --git a/modules/java/android_test/src/org/opencv/test/core/MatTest.java b/modules/java/android_test/src/org/opencv/test/core/MatTest.java index 105815a..2e4a300 100644 --- a/modules/java/android_test/src/org/opencv/test/core/MatTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/MatTest.java @@ -569,12 +569,27 @@ public class MatTest extends OpenCVTestCase { } public void testMatMatRect() { - dst = new Mat(gray255_32f, new Rect(2, 2, 7, 7)); - - truth = new Mat(7, 7, CvType.CV_32FC1, new Scalar(255)); + Mat m = new Mat(7, 6, CvType.CV_32SC1); + m.put(0, 0, + 0, 1, 2, 3, 4, 5, + 10, 11, 12, 13, 14, 15, + 20, 21, 22, 23, 24, 25, + 30, 31, 32, 33, 34, 35, + 40, 41, 42, 43, 44, 45, + 50, 51, 52, 53, 54, 55, + 60, 61, 62, 63, 64, 65 ); + + dst = new Mat(m, new Rect(1, 2, 3, 4)); + + truth = new Mat(4, 3, CvType.CV_32SC1); + truth.put(0, 0, + 21, 22, 23, + 31, 32, 33, + 41, 42, 43, + 51, 52, 53 ); assertFalse(dst.empty()); - assertMatEqual(truth, dst, EPS); + assertMatEqual(truth, dst); } public void testMatSizeInt() { diff --git a/modules/java/src/java/core+Mat.java b/modules/java/src/java/core+Mat.java index a4a2dd4..e1166ad 100644 --- a/modules/java/src/java/core+Mat.java +++ b/modules/java/src/java/core+Mat.java @@ -108,7 +108,7 @@ public class Mat { public Mat(Mat m, Rect roi) { - nativeObj = n_Mat(m.nativeObj, roi.x, roi.x + roi.width, roi.y, roi.y + roi.height); + nativeObj = n_Mat(m.nativeObj, roi.y, roi.y + roi.height, roi.x, roi.x + roi.width); return; } -- 2.7.4