fix for #2063 ( Mat(Mat m, Rect roi) returns wrong sub-mat)

pull/2/head
Andrey Pavlenko 13 years ago
parent 43f2682e15
commit dc93c21962
  1. 23
      modules/java/android_test/src/org/opencv/test/core/MatTest.java
  2. 2
      modules/java/src/java/core+Mat.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() {

@ -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;
}

Loading…
Cancel
Save