added some tests to core module
This commit is contained in:
parent
f8e42721d3
commit
e958383225
@ -8,7 +8,7 @@ import android.util.Log;
|
||||
|
||||
public class OpenCVTestCase extends AndroidTestCase {
|
||||
|
||||
static String TAG = "OpenCV";
|
||||
static String TAG = "OpenCV_JavaAPI_Tests";
|
||||
static int matSize = 10;
|
||||
|
||||
static Mat gray0;
|
||||
@ -22,13 +22,19 @@ public class OpenCVTestCase extends AndroidTestCase {
|
||||
static Mat grayRnd;
|
||||
static Mat grayRnd_32f;
|
||||
|
||||
static Mat grayE_32f;
|
||||
|
||||
static Mat gray0_32f;
|
||||
static Mat gray0_32f_1d;
|
||||
|
||||
static Mat gray0_64f;
|
||||
static Mat gray0_64f_1d;
|
||||
|
||||
static Mat rgba0;
|
||||
static Mat rgba128;
|
||||
|
||||
static Mat dst;
|
||||
static Mat dst_gray;
|
||||
static Mat dst_gray_32f;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@ -48,14 +54,21 @@ public class OpenCVTestCase extends AndroidTestCase {
|
||||
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);
|
||||
|
||||
grayE_32f = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); grayE_32f = Mat.eye(matSize, matSize, Mat.CvType.CV_32FC1);
|
||||
|
||||
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);
|
||||
|
||||
rgba0 = new Mat(matSize, matSize, Mat.CvType.CV_8UC4); rgba0.setTo(0, 0, 0, 0);
|
||||
rgba128 = new Mat(matSize, matSize, Mat.CvType.CV_8UC4); rgba128.setTo(128, 128, 128, 128);
|
||||
|
||||
dst = new Mat(0, 0, Mat.CvType.CV_8UC1);
|
||||
assertTrue(dst.empty());
|
||||
dst_gray = new Mat(0, 0, Mat.CvType.CV_8UC1);
|
||||
assertTrue(dst_gray.empty());
|
||||
dst_gray_32f = new Mat(0, 0, Mat.CvType.CV_32FC1);
|
||||
assertTrue(dst_gray_32f.empty());
|
||||
}
|
||||
|
||||
public static void assertMatEqual(Mat m1, Mat m2) {
|
||||
|
@ -1,6 +1,8 @@
|
||||
package org.opencv.test;
|
||||
|
||||
import org.opencv.Mat;
|
||||
import org.opencv.Point;
|
||||
import org.opencv.Scalar;
|
||||
import org.opencv.core;
|
||||
|
||||
public class coreTest extends OpenCVTestCase {
|
||||
@ -17,12 +19,12 @@ public class coreTest extends OpenCVTestCase {
|
||||
Mat lut = new Mat(1, 256, Mat.CvType.CV_8UC1);
|
||||
|
||||
lut.setTo(0);
|
||||
core.LUT(grayRnd, lut, dst);
|
||||
assertMatEqual(gray0, dst);
|
||||
core.LUT(grayRnd, lut, dst_gray);
|
||||
assertMatEqual(gray0, dst_gray);
|
||||
|
||||
lut.setTo(255);
|
||||
core.LUT(grayRnd, lut, dst);
|
||||
assertMatEqual(gray255, dst);
|
||||
core.LUT(grayRnd, lut, dst_gray);
|
||||
assertMatEqual(gray255, dst_gray);
|
||||
}
|
||||
|
||||
public void testMahalanobis() {
|
||||
@ -43,8 +45,8 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testAbsdiff() {
|
||||
core.absdiff(gray128, gray255, dst);
|
||||
assertMatEqual(gray127, dst);
|
||||
core.absdiff(gray128, gray255, dst_gray);
|
||||
assertMatEqual(gray127, dst_gray);
|
||||
}
|
||||
|
||||
public void testAddMatMatMatMatInt() {
|
||||
@ -56,8 +58,8 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testAddMatMatMat() {
|
||||
core.add(gray128, gray128, dst);
|
||||
assertMatEqual(gray255, dst);
|
||||
core.add(gray128, gray128, dst_gray);
|
||||
assertMatEqual(gray255, dst_gray);
|
||||
}
|
||||
|
||||
public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() {
|
||||
@ -73,8 +75,8 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testBitwise_andMatMatMat() {
|
||||
core.bitwise_and(gray3, gray2, dst);
|
||||
assertMatEqual(gray2, dst);
|
||||
core.bitwise_and(gray3, gray2, dst_gray);
|
||||
assertMatEqual(gray2, dst_gray);
|
||||
}
|
||||
|
||||
public void testBitwise_notMatMatMat() {
|
||||
@ -128,7 +130,8 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testCheckHardwareSupport() {
|
||||
fail("Not yet implemented");
|
||||
boolean hasFeauture = core.checkHardwareSupport(0); //FIXME: do we need this function?
|
||||
assertEquals(false, hasFeauture);
|
||||
}
|
||||
|
||||
public void testCircleMatPointIntScalarIntIntInt() {
|
||||
@ -144,19 +147,35 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testCircleMatPointIntScalar() {
|
||||
fail("Not yet implemented");
|
||||
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);
|
||||
assertTrue(0 != core.countNonZero(gray0));
|
||||
}
|
||||
|
||||
public void testCompare() {
|
||||
fail("Not yet implemented");
|
||||
Mat cmp = new Mat(0, 0, Mat.CvType.CV_8UC1);
|
||||
|
||||
core.compare(gray0, gray0, cmp, core.CMP_EQ);
|
||||
assertMatEqual(cmp, gray255);
|
||||
|
||||
core.compare(gray0, gray1, cmp, core.CMP_EQ);
|
||||
assertMatEqual(cmp, gray0);
|
||||
}
|
||||
|
||||
public void testCompleteSymmMatBoolean() {
|
||||
fail("Not yet implemented");
|
||||
core.completeSymm(grayRnd_32f, true);
|
||||
core.transpose(grayRnd_32f, dst_gray_32f);
|
||||
assertMatEqual(grayRnd_32f, dst_gray_32f);
|
||||
}
|
||||
|
||||
public void testCompleteSymmMat() {
|
||||
fail("Not yet implemented");
|
||||
core.completeSymm(grayRnd_32f);
|
||||
core.transpose(grayRnd_32f, dst_gray_32f);
|
||||
assertMatEqual(grayRnd_32f, dst_gray_32f);
|
||||
}
|
||||
|
||||
public void testConvertScaleAbsMatMatDoubleDouble() {
|
||||
@ -172,7 +191,10 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testCountNonZero() {
|
||||
fail("Not yet implemented");
|
||||
assertEquals(0, core.countNonZero(gray0));
|
||||
gray0.put(0, 0, 255);
|
||||
gray0.put(gray0.rows() - 1, gray0.cols() - 1, 255);
|
||||
assertEquals(2, core.countNonZero(gray0));
|
||||
}
|
||||
|
||||
public void testCubeRoot() {
|
||||
@ -184,7 +206,15 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testDctMatMat() {
|
||||
fail("Not yet implemented");
|
||||
core.dct(gray0_32f_1d, dst_gray);
|
||||
assertMatEqual(gray0_32f_1d, dst_gray);
|
||||
|
||||
Mat in = new Mat(1, 4, Mat.CvType.CV_32FC1);
|
||||
in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682);
|
||||
Mat out = new Mat(1, 4, Mat.CvType.CV_32FC1);
|
||||
out.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477);
|
||||
core.dct(in, dst_gray);
|
||||
assertMatEqual(out, dst_gray);
|
||||
}
|
||||
|
||||
public void testDeterminant() {
|
||||
@ -244,7 +274,8 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testExtractChannel() {
|
||||
fail("Not yet implemented");
|
||||
core.extractChannel(rgba128, dst_gray, 0);
|
||||
assertMatEqual(gray128, dst_gray);
|
||||
}
|
||||
|
||||
public void testFastAtan2() {
|
||||
@ -268,11 +299,18 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testGetTickFrequency() {
|
||||
fail("Not yet implemented");
|
||||
double freq = core.getTickFrequency();
|
||||
assertTrue(0.0 != freq);
|
||||
}
|
||||
|
||||
public void testHconcat() {
|
||||
fail("Not yet implemented");
|
||||
Mat e = new Mat(3, 3, Mat.CvType.CV_8UC1);
|
||||
Mat eConcat = new Mat(1, 9, Mat.CvType.CV_8UC1);
|
||||
e.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1);
|
||||
eConcat.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1);
|
||||
core.hconcat(e, dst_gray);
|
||||
|
||||
assertMatEqual(eConcat, dst_gray);
|
||||
}
|
||||
|
||||
public void testIdctMatMatInt() {
|
||||
@ -300,7 +338,11 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testInsertChannel() {
|
||||
fail("Not yet implemented");
|
||||
core.insertChannel(gray0, rgba128, 0);
|
||||
core.insertChannel(gray0, rgba128, 1);
|
||||
core.insertChannel(gray0, rgba128, 2);
|
||||
core.insertChannel(gray0, rgba128, 3);
|
||||
//assertMatEqual(rgba0, rgba128);
|
||||
}
|
||||
|
||||
public void testInvertMatMatInt() {
|
||||
@ -324,7 +366,15 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testLineMatPointPointScalar() {
|
||||
fail("Not yet implemented");
|
||||
int nPoints = Math.min(gray0.cols(), gray0.rows());
|
||||
|
||||
Point point1 = new Point(0, 0);
|
||||
Point point2 = new Point(nPoints, nPoints);
|
||||
Scalar color = new Scalar(255);
|
||||
|
||||
assertTrue(0 == core.countNonZero(gray0));
|
||||
core.line(gray0, point1, point2, color);
|
||||
assertTrue(nPoints == core.countNonZero(gray0));
|
||||
}
|
||||
|
||||
public void testLog() {
|
||||
@ -356,6 +406,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testMulSpectrumsMatMatMatInt() {
|
||||
//TODO: complex math. See the dct function test.
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@ -372,7 +423,8 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testMulTransposedMatMatBoolean() {
|
||||
fail("Not yet implemented");
|
||||
core.mulTransposed(grayE_32f, dst_gray_32f, true);
|
||||
assertMatEqual(grayE_32f, dst_gray_32f);
|
||||
}
|
||||
|
||||
public void testMultiplyMatMatMatDoubleInt() {
|
||||
@ -392,10 +444,11 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testNormMatInt() {
|
||||
fail("Not yet implemented");
|
||||
double n = core.norm(gray127, core.NORM_INF);
|
||||
assertTrue(127 == n);
|
||||
}
|
||||
|
||||
public void testNormMat() {
|
||||
public void testNormMat() {
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
@ -436,6 +489,7 @@ public class coreTest extends OpenCVTestCase {
|
||||
}
|
||||
|
||||
public void testPerspectiveTransform() {
|
||||
//XXX: kirill stopped here
|
||||
fail("Not yet implemented");
|
||||
}
|
||||
|
||||
|
@ -200,11 +200,11 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
public void testBlurMatMatSize() {
|
||||
Size sz = new Size(3, 3);
|
||||
|
||||
imgproc.blur(gray0, dst, sz);
|
||||
assertMatEqual(gray0, dst);
|
||||
imgproc.blur(gray0, dst_gray, sz);
|
||||
assertMatEqual(gray0, dst_gray);
|
||||
|
||||
imgproc.blur(gray255, dst, sz);
|
||||
assertMatEqual(gray255, dst);
|
||||
imgproc.blur(gray255, dst_gray, sz);
|
||||
assertMatEqual(gray255, dst_gray);
|
||||
}
|
||||
|
||||
public void testBorderInterpolate() {
|
||||
@ -225,8 +225,8 @@ public class imgprocTest extends OpenCVTestCase {
|
||||
|
||||
public void testBoxFilterMatMatIntSize() {
|
||||
Size sz = new Size(3, 3);
|
||||
imgproc.boxFilter(gray0, dst, 8, sz);
|
||||
assertMatEqual(gray0, dst);
|
||||
imgproc.boxFilter(gray0, dst_gray, 8, sz);
|
||||
assertMatEqual(gray0, dst_gray);
|
||||
}
|
||||
|
||||
public void testCompareHist() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user