|
|
|
@ -2,6 +2,9 @@ package org.opencv.test.core; |
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
|
|
import org.hamcrest.core.IsInstanceOf; |
|
|
|
|
import org.junit.internal.runners.statements.ExpectException; |
|
|
|
|
import org.opencv.core.CvException; |
|
|
|
|
import org.opencv.core.CvType; |
|
|
|
|
import org.opencv.core.Mat; |
|
|
|
|
import org.opencv.core.Point; |
|
|
|
@ -96,7 +99,10 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
Mat covar = new Mat(matSize, matSize, CvType.CV_64FC1); |
|
|
|
|
Mat mean = new Mat(1, matSize, CvType.CV_64FC1); |
|
|
|
|
|
|
|
|
|
Core.calcCovarMatrix(gray0_32f, covar, mean, 8|1/*TODO: CV_COVAR_NORMAL*/); |
|
|
|
|
Core.calcCovarMatrix(gray0_32f, covar, mean, 8 | 1/* |
|
|
|
|
* TODO: |
|
|
|
|
* CV_COVAR_NORMAL |
|
|
|
|
*/); |
|
|
|
|
assertMatEqual(gray0_64f, covar); |
|
|
|
|
assertMatEqual(gray0_64f_1d, mean); |
|
|
|
|
} |
|
|
|
@ -105,7 +111,10 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
Mat covar = new Mat(matSize, matSize, CvType.CV_32F); |
|
|
|
|
Mat mean = new Mat(1, matSize, CvType.CV_32F); |
|
|
|
|
|
|
|
|
|
Core.calcCovarMatrix(gray0_32f, covar, mean, 8|1/*TODO: CV_COVAR_NORMAL*/, CvType.CV_32F); |
|
|
|
|
Core.calcCovarMatrix(gray0_32f, covar, mean, 8 | 1/* |
|
|
|
|
* TODO: |
|
|
|
|
* CV_COVAR_NORMAL |
|
|
|
|
*/, CvType.CV_32F); |
|
|
|
|
assertMatEqual(gray0_32f, covar); |
|
|
|
|
assertMatEqual(gray0_32f_1d, mean); |
|
|
|
|
} |
|
|
|
@ -113,7 +122,7 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
public void testCartToPolarMatMatMatMat() { |
|
|
|
|
Mat x = new Mat(1, 3, CvType.CV_32F); |
|
|
|
|
Mat y = new Mat(1, 3, CvType.CV_32F); |
|
|
|
|
x.put(0, 0, 3.0, 6.0, 5,0); |
|
|
|
|
x.put(0, 0, 3.0, 6.0, 5, 0); |
|
|
|
|
y.put(0, 0, 4.0, 8.0, 12.0); |
|
|
|
|
|
|
|
|
|
Mat magnitude = new Mat(1, 3, CvType.CV_32F); |
|
|
|
@ -130,27 +139,45 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
public void testCartToPolarMatMatMatMatBoolean() { |
|
|
|
|
Mat x = new Mat(1, 3, CvType.CV_32F); |
|
|
|
|
Mat y = new Mat(1, 3, CvType.CV_32F); |
|
|
|
|
x.put(0 ,0, 3.0, 6.0, 5,0); |
|
|
|
|
y.put(0 ,0, 4.0, 8.0, 12.0); |
|
|
|
|
x.put(0, 0, 3.0, 6.0, 5, 0); |
|
|
|
|
y.put(0, 0, 4.0, 8.0, 12.0); |
|
|
|
|
|
|
|
|
|
Mat magnitude = new Mat(1, 3, CvType.CV_32F); |
|
|
|
|
Mat angle = new Mat(1, 3, CvType.CV_32F); |
|
|
|
|
|
|
|
|
|
magnitude.put(0 ,0, 5.0, 10.0, 13.0); |
|
|
|
|
angle.put(0 ,0, 0.92729962, 0.92729962, 1.1759995); |
|
|
|
|
magnitude.put(0, 0, 5.0, 10.0, 13.0); |
|
|
|
|
angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); |
|
|
|
|
|
|
|
|
|
Mat dst_angle = new Mat(); |
|
|
|
|
Core.cartToPolar(x, y, dst, dst_angle,false); |
|
|
|
|
Core.cartToPolar(x, y, dst, dst_angle, false); |
|
|
|
|
assertMatEqual(magnitude, dst); |
|
|
|
|
assertMatEqual(angle, dst_angle); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testCheckRangeMat() { |
|
|
|
|
fail("Not yet implemented"); |
|
|
|
|
Mat outOfRange = new Mat(2, 2, CvType.CV_64F); |
|
|
|
|
outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY, |
|
|
|
|
Double.POSITIVE_INFINITY, 0); |
|
|
|
|
|
|
|
|
|
assertTrue(Core.checkRange(grayRnd_32f)); |
|
|
|
|
assertTrue(Core.checkRange(new Mat())); |
|
|
|
|
assertFalse(Core.checkRange(outOfRange)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testCheckRangeMatBoolean() { |
|
|
|
|
fail("Not yet implemented"); |
|
|
|
|
Mat outOfRange = new Mat(2, 2, CvType.CV_64F); |
|
|
|
|
outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY, |
|
|
|
|
Double.POSITIVE_INFINITY, 0); |
|
|
|
|
|
|
|
|
|
assertFalse(Core.checkRange(outOfRange, true)); |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
Core.checkRange(outOfRange, false); |
|
|
|
|
fail("Core.checkRange should throw the CvException"); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
if (!(e instanceof CvException)) |
|
|
|
|
fail("Core.checkRange should throw the CvException"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testCheckRangeMatBooleanPoint() { |
|
|
|
@ -166,8 +193,8 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testCircleMatPointIntScalar() { |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows()/2); |
|
|
|
|
int radius = Math.min(gray0.cols()/4, gray0.rows()/4); |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); |
|
|
|
|
int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); |
|
|
|
|
Scalar color = new Scalar(128); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
@ -176,34 +203,38 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testCircleMatPointIntScalarInt() { |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows()/2); |
|
|
|
|
int radius = Math.min(gray0.cols()/4, gray0.rows()/4); |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); |
|
|
|
|
int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); |
|
|
|
|
Scalar color = new Scalar(128); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
|
Core.circle(gray0, center, radius, color, -1 /*filled circle*/); |
|
|
|
|
Core.circle(gray0, center, radius, color, -1 /* filled circle */); |
|
|
|
|
assertTrue(0 != Core.countNonZero(gray0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testCircleMatPointIntScalarIntInt() { |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows()/2); |
|
|
|
|
int radius = Math.min(gray0.cols()/4, gray0.rows()/4); |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); |
|
|
|
|
int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); |
|
|
|
|
Scalar color = new Scalar(128); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
|
Core.circle(gray0, center, radius, color, 2, 4/*4-connected line*/); |
|
|
|
|
Core.circle(gray0, center, radius, color, 2, 4/* 4-connected line */); |
|
|
|
|
assertTrue(0 != Core.countNonZero(gray0)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testCircleMatPointIntScalarIntIntInt() { |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows()/2); |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); |
|
|
|
|
Point center2 = new Point(gray0.cols(), gray0.rows()); |
|
|
|
|
int radius = Math.min(gray0.cols()/4, gray0.rows()/4); |
|
|
|
|
int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); |
|
|
|
|
Scalar color128 = new Scalar(128); |
|
|
|
|
Scalar color0 = new Scalar(0); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
|
Core.circle(gray0, center2, radius*2, color128, 2, 4, 1/*Number of fractional bits*/); |
|
|
|
|
Core.circle(gray0, center2, radius * 2, color128, 2, 4, 1/* |
|
|
|
|
* Number of |
|
|
|
|
* fractional |
|
|
|
|
* bits |
|
|
|
|
*/); |
|
|
|
|
Core.circle(gray0, center, radius, color0, 2, 4, 0); |
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
|
} |
|
|
|
@ -233,7 +264,6 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
assertEquals(pt2Clipped, pt2); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testCompare() { |
|
|
|
|
Core.compare(gray0, gray0, dst, Core.CMP_EQ); |
|
|
|
|
assertMatEqual(dst, gray255); |
|
|
|
@ -289,7 +319,7 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
|
|
|
|
|
public void testCubeRoot() { |
|
|
|
|
float res = Core.cubeRoot(27.0f); |
|
|
|
|
assertEquals(3.0f,res); |
|
|
|
|
assertEquals(3.0f, res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testDctMatMat() { |
|
|
|
@ -311,10 +341,12 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
assertMatEqual(gray0_32f_1d, dst); |
|
|
|
|
|
|
|
|
|
Mat in = new Mat(1, 8, CvType.CV_32F); |
|
|
|
|
in.put(0, 0, 0.203056, 0.980407, 0.35312, -0.106651, 0.0399382, 0.871475, -0.648355, 0.501067); |
|
|
|
|
in.put(0, 0, 0.203056, 0.980407, 0.35312, -0.106651, 0.0399382, |
|
|
|
|
0.871475, -0.648355, 0.501067); |
|
|
|
|
|
|
|
|
|
truth = new Mat(1, 8, CvType.CV_32F); |
|
|
|
|
truth.put(0, 0, 0.77571625, 0.37270021, 0.18529896, 0.012146413, -0.32499927, -0.99302113, 0.55979407, -0.6251272); |
|
|
|
|
truth.put(0, 0, 0.77571625, 0.37270021, 0.18529896, 0.012146413, |
|
|
|
|
-0.32499927, -0.99302113, 0.55979407, -0.6251272); |
|
|
|
|
|
|
|
|
|
Core.dct(in, dst); |
|
|
|
|
assertMatEqual(truth, dst); |
|
|
|
@ -427,7 +459,8 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testExp() { |
|
|
|
|
Mat destination = new Mat(matSize, matSize, CvType.CV_32F); destination.setTo(new Scalar(0.0)); |
|
|
|
|
Mat destination = new Mat(matSize, matSize, CvType.CV_32F); |
|
|
|
|
destination.setTo(new Scalar(0.0)); |
|
|
|
|
Core.exp(gray0_32f, destination); |
|
|
|
|
assertMatEqual(gray1_32f, destination); |
|
|
|
|
} |
|
|
|
@ -440,7 +473,7 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
public void testFastAtan2() { |
|
|
|
|
double delta = 0.01; |
|
|
|
|
float res = Core.fastAtan2(50, 50); |
|
|
|
|
assertEquals(45,res,delta); |
|
|
|
|
assertEquals(45, res, delta); |
|
|
|
|
|
|
|
|
|
float res2 = Core.fastAtan2(80, 20); |
|
|
|
|
assertEquals(75.96, res2, delta); |
|
|
|
@ -584,7 +617,8 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
in.put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0); |
|
|
|
|
|
|
|
|
|
truth = new Mat(1, 8, CvType.CV_32F); |
|
|
|
|
truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115); |
|
|
|
|
truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, |
|
|
|
|
-0.86502546, 0.028082132, -0.7673766, 0.10917115); |
|
|
|
|
|
|
|
|
|
Core.idct(in, dst); |
|
|
|
|
assertMatEqual(truth, dst); |
|
|
|
@ -595,7 +629,8 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
in.put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0); |
|
|
|
|
|
|
|
|
|
truth = new Mat(1, 8, CvType.CV_32F); |
|
|
|
|
truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115); |
|
|
|
|
truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, |
|
|
|
|
-0.86502546, 0.028082132, -0.7673766, 0.10917115); |
|
|
|
|
|
|
|
|
|
Core.idct(in, dst, Core.DCT_ROWS); |
|
|
|
|
assertMatEqual(truth, dst); |
|
|
|
@ -661,11 +696,11 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
Core.invert(src, dst); |
|
|
|
|
assertMatEqual(truth, dst); |
|
|
|
|
|
|
|
|
|
//TODO: needs epsilon comparison
|
|
|
|
|
// Mat m = grayRnd_32f.clone();
|
|
|
|
|
// Mat inv = m.inv();
|
|
|
|
|
// Core.gemm(m, inv, 1.0, new Mat(), 0.0, dst);
|
|
|
|
|
// assertMatEqual(grayE_32f, dst);
|
|
|
|
|
// TODO: needs epsilon comparison
|
|
|
|
|
// Mat m = grayRnd_32f.clone();
|
|
|
|
|
// Mat inv = m.inv();
|
|
|
|
|
// Core.gemm(m, inv, 1.0, new Mat(), 0.0, dst);
|
|
|
|
|
// assertMatEqual(grayE_32f, dst);
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testInvertMatMatInt() { |
|
|
|
@ -760,7 +795,7 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
out.put(0, 0, 5.0, 13.0, 41.0, 10.0); |
|
|
|
|
|
|
|
|
|
Core.magnitude(x, y, dst); |
|
|
|
|
assertMatEqual(out,dst); |
|
|
|
|
assertMatEqual(out, dst); |
|
|
|
|
|
|
|
|
|
Core.magnitude(gray0_32f, gray255_32f, dst); |
|
|
|
|
assertMatEqual(gray255_32f, dst); |
|
|
|
@ -769,7 +804,10 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
public void testMahalanobis() { |
|
|
|
|
Mat covar = new Mat(matSize, matSize, CvType.CV_32F); |
|
|
|
|
Mat mean = new Mat(1, matSize, CvType.CV_32F); |
|
|
|
|
Core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1/*TODO: CV_COVAR_NORMAL*/, CvType.CV_32F); |
|
|
|
|
Core.calcCovarMatrix(grayRnd_32f, covar, mean, 8 | 1/* |
|
|
|
|
* TODO: |
|
|
|
|
* CV_COVAR_NORMAL |
|
|
|
|
*/, CvType.CV_32F); |
|
|
|
|
covar.inv(); |
|
|
|
|
|
|
|
|
|
Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols()); |
|
|
|
@ -825,11 +863,12 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
assertEquals(0, Core.countNonZero(mean)); |
|
|
|
|
assertEquals(0, Core.countNonZero(stddev)); |
|
|
|
|
|
|
|
|
|
Mat submat = grayRnd.submat(0, grayRnd.rows()/2, 0, grayRnd.cols()/2); |
|
|
|
|
Mat submat = grayRnd.submat(0, grayRnd.rows() / 2, 0, |
|
|
|
|
grayRnd.cols() / 2); |
|
|
|
|
submat.setTo(new Scalar(33)); |
|
|
|
|
|
|
|
|
|
Mat mask = gray0.clone(); |
|
|
|
|
submat = mask.submat(0, mask.rows()/2, 0, mask.cols()/2); |
|
|
|
|
submat = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2); |
|
|
|
|
submat.setTo(new Scalar(1)); |
|
|
|
|
|
|
|
|
|
Core.meanStdDev(grayRnd, mean, stddev, mask); |
|
|
|
@ -854,10 +893,10 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
public void testMinMaxLoc() { |
|
|
|
|
double minVal = 1; |
|
|
|
|
double maxVal = 10; |
|
|
|
|
Point minLoc = new Point(gray3.cols()/4, gray3.rows()/2); |
|
|
|
|
Point maxLoc = new Point(gray3.cols()/2, gray3.rows()/4); |
|
|
|
|
gray3.put((int)minLoc.y, (int)minLoc.x, minVal); |
|
|
|
|
gray3.put((int)maxLoc.y, (int)maxLoc.x, maxVal); |
|
|
|
|
Point minLoc = new Point(gray3.cols() / 4, gray3.rows() / 2); |
|
|
|
|
Point maxLoc = new Point(gray3.cols() / 2, gray3.rows() / 4); |
|
|
|
|
gray3.put((int) minLoc.y, (int) minLoc.x, minVal); |
|
|
|
|
gray3.put((int) maxLoc.y, (int) maxLoc.x, maxVal); |
|
|
|
|
|
|
|
|
|
Core.MinMaxLocResult mmres = Core.minMaxLoc(gray3); |
|
|
|
|
|
|
|
|
@ -867,7 +906,6 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
assertTrue(mmres.maxLoc.equals(maxLoc)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void testMinMaxLocMat() { |
|
|
|
|
fail("Not yet implemented"); |
|
|
|
|
} |
|
|
|
@ -1050,7 +1088,7 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testPerspectiveTransform() { |
|
|
|
|
//nice example
|
|
|
|
|
// nice example
|
|
|
|
|
fail("Not yet implemented"); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -1087,18 +1125,18 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
Mat xCoordinate = new Mat(); |
|
|
|
|
Mat yCoordinate = new Mat(); |
|
|
|
|
|
|
|
|
|
// x.put(0, 0, 3.0, 6.0, 5,0);
|
|
|
|
|
// y.put(0, 0, 4.0, 8.0, 12.0);
|
|
|
|
|
// magnitude.put(0, 0, 5.0, 10.0, 13.0);
|
|
|
|
|
// angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
|
|
|
|
|
// x.put(0, 0, 3.0, 6.0, 5,0);
|
|
|
|
|
// y.put(0, 0, 4.0, 8.0, 12.0);
|
|
|
|
|
// magnitude.put(0, 0, 5.0, 10.0, 13.0);
|
|
|
|
|
// angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995);
|
|
|
|
|
|
|
|
|
|
magnitude.put(0, 0, 5.0, 10.0, 13.0); |
|
|
|
|
angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); |
|
|
|
|
|
|
|
|
|
x.put(0, 0, 3.0, 6.0, 5,0); |
|
|
|
|
x.put(0, 0, 3.0, 6.0, 5, 0); |
|
|
|
|
y.put(0, 0, 4.0, 8.0, 12.0); |
|
|
|
|
|
|
|
|
|
//TODO: needs epsilon comparison
|
|
|
|
|
// TODO: needs epsilon comparison
|
|
|
|
|
Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate); |
|
|
|
|
assertMatEqual(x, xCoordinate); |
|
|
|
|
} |
|
|
|
@ -1171,8 +1209,8 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testRectangleMatPointPointScalar() { |
|
|
|
|
Point center = new Point(gray0.cols()/2, gray0.rows()/2); |
|
|
|
|
Point origin = new Point(0,0); |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); |
|
|
|
|
Point origin = new Point(0, 0); |
|
|
|
|
Scalar color = new Scalar(128); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
@ -1182,7 +1220,7 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
|
|
|
|
|
public void testRectangleMatPointPointScalarInt() { |
|
|
|
|
Point center = new Point(gray0.cols(), gray0.rows()); |
|
|
|
|
Point origin = new Point(0,0); |
|
|
|
|
Point origin = new Point(0, 0); |
|
|
|
|
Scalar color = new Scalar(128); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
@ -1191,8 +1229,8 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testRectangleMatPointPointScalarIntInt() { |
|
|
|
|
Point center = new Point(gray0.cols()/2, gray0.rows()/2); |
|
|
|
|
Point origin = new Point(0,0); |
|
|
|
|
Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); |
|
|
|
|
Point origin = new Point(0, 0); |
|
|
|
|
Scalar color = new Scalar(128); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
@ -1202,7 +1240,7 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
|
|
|
|
|
public void testRectangleMatPointPointScalarIntIntInt() { |
|
|
|
|
Point center = new Point(gray0.cols(), gray0.rows()); |
|
|
|
|
Point origin = new Point(0,0); |
|
|
|
|
Point origin = new Point(0, 0); |
|
|
|
|
Scalar color = new Scalar(128); |
|
|
|
|
|
|
|
|
|
assertTrue(0 == Core.countNonZero(gray0)); |
|
|
|
@ -1213,10 +1251,10 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
public void testReduceMatMatIntInt() { |
|
|
|
|
Mat src = new Mat(2, 2, CvType.CV_32F); |
|
|
|
|
Mat out = new Mat(1, 2, CvType.CV_32F); |
|
|
|
|
src.put(0, 0, 1 , 0); |
|
|
|
|
src.put(1, 0, 1 , 0); |
|
|
|
|
src.put(0, 0, 1, 0); |
|
|
|
|
src.put(1, 0, 1, 0); |
|
|
|
|
|
|
|
|
|
out.put(0 , 0, 1, 0); |
|
|
|
|
out.put(0, 0, 1, 0); |
|
|
|
|
|
|
|
|
|
Core.reduce(src, dst, 0, 2); |
|
|
|
|
assertMatEqual(out, dst); |
|
|
|
@ -1225,10 +1263,10 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
public void testReduceMatMatIntIntInt() { |
|
|
|
|
Mat src = new Mat(2, 2, CvType.CV_32F); |
|
|
|
|
Mat out = new Mat(1, 2, CvType.CV_32F); |
|
|
|
|
src.put(0, 0, 1 , 0); |
|
|
|
|
src.put(1, 0, 1 , 0); |
|
|
|
|
src.put(0, 0, 1, 0); |
|
|
|
|
src.put(1, 0, 1, 0); |
|
|
|
|
|
|
|
|
|
out.put(0 , 0, 1, 0); |
|
|
|
|
out.put(0, 0, 1, 0); |
|
|
|
|
|
|
|
|
|
Core.reduce(src, dst, 0, 2, -1); |
|
|
|
|
assertMatEqual(out, dst); |
|
|
|
@ -1335,11 +1373,11 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2); |
|
|
|
|
submat.setTo(new Scalar(1.0)); |
|
|
|
|
|
|
|
|
|
Core.sort(gray0, dst, 0/*TODO: CV_SORT_EVERY_ROW*/); |
|
|
|
|
Core.sort(gray0, dst, 0/* TODO: CV_SORT_EVERY_ROW */); |
|
|
|
|
submat = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols()); |
|
|
|
|
assertTrue(submat.total() == Core.countNonZero(submat)); |
|
|
|
|
|
|
|
|
|
Core.sort(gray0, dst, 1/*TODO: CV_SORT_EVERY_COLUMN*/); |
|
|
|
|
Core.sort(gray0, dst, 1/* TODO: CV_SORT_EVERY_COLUMN */); |
|
|
|
|
submat = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2); |
|
|
|
|
assertTrue(submat.total() == Core.countNonZero(submat)); |
|
|
|
|
} |
|
|
|
@ -1353,14 +1391,14 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
truth.put(1, 0, 0, 2, 1); |
|
|
|
|
truth.put(2, 0, 0, 1, 2); |
|
|
|
|
|
|
|
|
|
Core.sortIdx(a, b, 0+0/*TODO: CV_SORT_EVERY_ROW + CV_SORT_ASCENDING*/); |
|
|
|
|
Core.sortIdx(a, b, 0 + 0/* TODO: CV_SORT_EVERY_ROW + CV_SORT_ASCENDING */); |
|
|
|
|
assertMatEqual(truth, b); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void testSplit() { |
|
|
|
|
ArrayList<Mat> cois = new ArrayList<Mat>(); |
|
|
|
|
Core.split(rgba0, cois); |
|
|
|
|
for(Mat coi : cois) { |
|
|
|
|
for (Mat coi : cois) { |
|
|
|
|
assertMatEqual(gray0, coi); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -1430,8 +1468,10 @@ public class coreTest extends OpenCVTestCase { |
|
|
|
|
|
|
|
|
|
public void testTranspose() { |
|
|
|
|
Mat subgray0 = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols()); |
|
|
|
|
Mat destination = new Mat(matSize, matSize, CvType.CV_8U); destination.setTo(new Scalar(0)); |
|
|
|
|
Mat subdst = destination.submat(0, destination.rows(), 0, destination.cols() / 2); |
|
|
|
|
Mat destination = new Mat(matSize, matSize, CvType.CV_8U); |
|
|
|
|
destination.setTo(new Scalar(0)); |
|
|
|
|
Mat subdst = destination.submat(0, destination.rows(), 0, |
|
|
|
|
destination.cols() / 2); |
|
|
|
|
subgray0.setTo(new Scalar(1)); |
|
|
|
|
Core.transpose(gray0, destination); |
|
|
|
|
assertTrue(subdst.total() == Core.countNonZero(subdst)); |
|
|
|
|