java tests: added 2 tests for calib3d, implemented assertMatNotEqual
This commit is contained in:
parent
63f8feb2a1
commit
b58dc21074
@ -30,7 +30,8 @@ public class OpenCVTestCase extends TestCase {
|
||||
protected static Mat gray255;
|
||||
protected static Mat grayRnd;
|
||||
|
||||
protected static Mat gray_16u_256;
|
||||
protected static Mat gray_16u_256;
|
||||
protected static Mat gray_16s_1024;
|
||||
|
||||
protected static Mat gray0_32f;
|
||||
protected static Mat gray1_32f;
|
||||
@ -71,6 +72,7 @@ public class OpenCVTestCase extends TestCase {
|
||||
gray255 = new Mat(matSize, matSize, CvType.CV_8U); gray255.setTo(new Scalar(255.0));
|
||||
|
||||
gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U); gray_16u_256.setTo(new Scalar(256));
|
||||
gray_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S); gray_16s_1024.setTo(new Scalar(1024));
|
||||
|
||||
Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0));
|
||||
Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256));
|
||||
@ -119,6 +121,26 @@ public class OpenCVTestCase extends TestCase {
|
||||
}
|
||||
}
|
||||
|
||||
public static void assertMatNotEqual(Mat m1, Mat m2) { //TODO: copypasta (see above)
|
||||
//OpenCVTestRunner.Log(m1.toString());
|
||||
//OpenCVTestRunner.Log(m2.toString());
|
||||
|
||||
if (!m1.type().equals(m2.type()) ||
|
||||
m1.cols() != m2.cols() || m1.rows() != m2.rows()) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
else if (m1.channels() == 1) {
|
||||
assertTrue(CalcPercentageOfDifference(m1, m2) != 0.0);
|
||||
}
|
||||
else {
|
||||
for (int coi = 0; coi < m1.channels(); coi++) {
|
||||
Mat m1c = getCOI(m1, coi);
|
||||
Mat m2c = getCOI(m2, coi);
|
||||
assertTrue(CalcPercentageOfDifference(m1c, m2c) != 0.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static private Mat getCOI(Mat m, int coi) {
|
||||
Mat ch = new Mat(m.rows(), m.cols(), m.depth());
|
||||
|
||||
|
@ -1,9 +1,11 @@
|
||||
package org.opencv.test.calib3d;
|
||||
|
||||
import org.opencv.Point;
|
||||
import org.opencv.Scalar;
|
||||
import org.opencv.Size;
|
||||
import org.opencv.calib3d;
|
||||
import org.opencv.core;
|
||||
import org.opencv.test.OpenCVTestCase;
|
||||
import org.opencv.test.OpenCVTestRunner;
|
||||
|
||||
public class calib3dTest extends OpenCVTestCase {
|
||||
|
||||
@ -88,7 +90,13 @@ public class calib3dTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testFilterSpecklesMatDoubleIntDouble() {
|
||||
fail("Not yet implemented");
|
||||
gray_16s_1024.copyTo(dst);
|
||||
|
||||
Point center = new Point(gray_16s_1024.rows()/2., gray_16s_1024.cols()/2.);
|
||||
core.circle(dst, center, 1, Scalar.all(4096));
|
||||
assertMatNotEqual(gray_16s_1024, dst);
|
||||
calib3d.filterSpeckles(dst, 1024.0, 100, 0.);
|
||||
assertMatEqual(gray_16s_1024, dst);
|
||||
}
|
||||
|
||||
public void testFilterSpecklesMatDoubleIntDoubleMat() {
|
||||
@ -102,7 +110,10 @@ public class calib3dTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testFindChessboardCornersMatSizeMatInt() {
|
||||
fail("Not yet implemented");//CALIB_CB_ADAPTIVE_THRESH + CALIB_CB_NORMALIZE_IMAGE + CALIB_CB_FAST_CHECK
|
||||
Size patternSize = new Size(9, 6);
|
||||
calib3d.findChessboardCorners(grayChess, patternSize, dst, calib3d.CALIB_CB_ADAPTIVE_THRESH
|
||||
+ calib3d.CALIB_CB_NORMALIZE_IMAGE + calib3d.CALIB_CB_FAST_CHECK);
|
||||
assertTrue(!dst.empty());
|
||||
}
|
||||
|
||||
public void testFindFundamentalMatMatMat() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user