提交 b58dc210 编写于 作者: K Kirill Kornyakov

java tests: added 2 tests for calib3d, implemented assertMatNotEqual

上级 63f8feb2
...@@ -30,7 +30,8 @@ public class OpenCVTestCase extends TestCase { ...@@ -30,7 +30,8 @@ public class OpenCVTestCase extends TestCase {
protected static Mat gray255; protected static Mat gray255;
protected static Mat grayRnd; 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 gray0_32f;
protected static Mat gray1_32f; protected static Mat gray1_32f;
...@@ -71,6 +72,7 @@ public class OpenCVTestCase extends TestCase { ...@@ -71,6 +72,7 @@ public class OpenCVTestCase extends TestCase {
gray255 = new Mat(matSize, matSize, CvType.CV_8U); gray255.setTo(new Scalar(255.0)); 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_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 low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0));
Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256)); Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256));
...@@ -119,6 +121,26 @@ public class OpenCVTestCase extends TestCase { ...@@ -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) { static private Mat getCOI(Mat m, int coi) {
Mat ch = new Mat(m.rows(), m.cols(), m.depth()); Mat ch = new Mat(m.rows(), m.cols(), m.depth());
......
package org.opencv.test.calib3d; package org.opencv.test.calib3d;
import org.opencv.Point;
import org.opencv.Scalar;
import org.opencv.Size; import org.opencv.Size;
import org.opencv.calib3d; import org.opencv.calib3d;
import org.opencv.core;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
public class calib3dTest extends OpenCVTestCase { public class calib3dTest extends OpenCVTestCase {
...@@ -88,7 +90,13 @@ public class calib3dTest extends OpenCVTestCase { ...@@ -88,7 +90,13 @@ public class calib3dTest extends OpenCVTestCase {
} }
public void testFilterSpecklesMatDoubleIntDouble() { 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() { public void testFilterSpecklesMatDoubleIntDoubleMat() {
...@@ -102,7 +110,10 @@ public class calib3dTest extends OpenCVTestCase { ...@@ -102,7 +110,10 @@ public class calib3dTest extends OpenCVTestCase {
} }
public void testFindChessboardCornersMatSizeMatInt() { 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() { public void testFindFundamentalMatMatMat() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册