提交 9fbd47ff 编写于 作者: K Kirill Kornyakov

added several tests for java/core module

上级 5d703abd
......@@ -18,6 +18,15 @@ public class OpenCVTestCase extends AndroidTestCase {
static Mat gray127;
static Mat gray128;
static Mat gray255;
static Mat grayRnd;
static Mat grayRnd_32f;
static Mat gray0_32f;
static Mat gray0_32f_1d;
static Mat gray0_64f;
static Mat gray0_64f_1d;
static Mat dst;
......@@ -33,6 +42,17 @@ public class OpenCVTestCase extends AndroidTestCase {
gray127 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray127.setTo(127.0);
gray128 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray128.setTo(128.0);
gray255 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray255.setTo(256.0);
Mat low = new Mat(1, 1, Mat.CvType.CV_16UC1); low.setTo(0);
Mat high = new Mat(1, 1, Mat.CvType.CV_16UC1); high.setTo(256);
grayRnd = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); core.randu(grayRnd, low, high);
grayRnd_32f = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); core.randu(grayRnd_32f, low, high);
gray0_32f = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); gray0_32f.setTo(0.0);
gray0_32f_1d = new Mat(1, matSize, Mat.CvType.CV_32FC1); gray0_32f_1d.setTo(0.0);
gray0_64f = new Mat(matSize, matSize, Mat.CvType.CV_64FC1); gray0_64f.setTo(0.0);
gray0_64f_1d = new Mat(1, matSize, Mat.CvType.CV_64FC1); gray0_64f_1d.setTo(0.0);
dst = new Mat(0, 0, Mat.CvType.CV_8UC1);
assertTrue(dst.empty());
......
package org.opencv.test;
import org.opencv.Mat;
import org.opencv.core;
public class coreTest extends OpenCVTestCase {
......@@ -13,11 +14,32 @@ public class coreTest extends OpenCVTestCase {
}
public void testLUTMatMatMat() {
fail("Not yet implemented");
}
public void testMahalanobis() {
fail("Not yet implemented");
Mat lut = new Mat(1, 256, Mat.CvType.CV_8UC1);
lut.setTo(0);
core.LUT(grayRnd, lut, dst);
assertMatEqual(gray0, dst);
lut.setTo(255);
core.LUT(grayRnd, lut, dst);
assertMatEqual(gray255, dst);
}
public void testMahalanobis() {
Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_32FC1);
Mat mean = new Mat(1, matSize, Mat.CvType.CV_32FC1);
core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //FIXME: CV_COVAR_NORMAL
covar.inv();
Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols());
Mat line2 = grayRnd_32f.submat(1, 2, 0, grayRnd_32f.cols());
double d = 0.0;
d = core.Mahalanobis(line1, line1, covar);
assertEquals(0.0, d);
d = core.Mahalanobis(line1, line2, covar);
assertTrue(d > 0.0);
}
public void testAbsdiff() {
......@@ -80,11 +102,21 @@ public class coreTest extends OpenCVTestCase {
}
public void testCalcCovarMatrixMatMatMatIntInt() {
fail("Not yet implemented");
Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_32FC1);
Mat mean = new Mat(1, matSize, Mat.CvType.CV_32FC1);
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //FIXME: CV_COVAR_NORMAL
assertMatEqual(gray0_32f, covar);
assertMatEqual(gray0_32f_1d, mean);
}
public void testCalcCovarMatrixMatMatMatInt() {
fail("Not yet implemented");
Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_64FC1);
Mat mean = new Mat(1, matSize, Mat.CvType.CV_64FC1);
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1); //FIXME: CV_COVAR_NORMAL
assertMatEqual(gray0_64f, covar);
assertMatEqual(gray0_64f_1d, mean);
}
public void testCartToPolarMatMatMatMatBoolean() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册