java tests: added stubs for calib3d, features2d classes, some other updates

This commit is contained in:
Kirill Kornyakov 2011-07-11 15:19:53 +00:00
parent ec866c5acd
commit d227079753
10 changed files with 472 additions and 38 deletions

View File

@ -66,7 +66,7 @@ public class OpenCVTestCase extends TestCase {
gray128 = new Mat(matSize, matSize, CvType.CV_8U); gray128.setTo(new Scalar(128.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); gray255.setTo(new Scalar(256));
gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U); gray_16u_256.setTo(new Scalar(256));
Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0));
Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256));
@ -89,13 +89,42 @@ public class OpenCVTestCase extends TestCase {
rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4); rgba128.setTo(Scalar.all(128));
rgbLena = highgui.imread(OpenCVTestRunner.LENA_PATH);
}
}
public static void assertMatEqual(Mat m1, Mat m2) {
assertTrue(CalcPercentageOfDifference(m1, m2) == 0.0);
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());
for (int i = 0; i < m.rows(); i++)
for (int j = 0; j < m.cols(); j++)
{
double pixel[] = m.get(i, j);
ch.put(i, j, pixel[coi]);
}
return ch;
}
static public double CalcPercentageOfDifference(Mat m1, Mat m2) {
static private double CalcPercentageOfDifference(Mat m1, Mat m2) {
Mat cmp = new Mat(0, 0, CvType.CV_8U);
core.compare(m1, m2, cmp, core.CMP_EQ);
double num = 100.0 *

View File

@ -1,9 +1,6 @@
package org.opencv.test;
import java.io.FileOutputStream;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;
import android.content.Context;
import android.graphics.Bitmap;
@ -16,6 +13,8 @@ import android.util.Log;
/**
* This only class is Android specific.
* The original idea about test order randomization is from marek.defecinski blog.
*
* @see <a href="http://opencv.itseez.com">OpenCV</a>
*/
public class OpenCVTestRunner extends InstrumentationTestRunner {
@ -33,8 +32,9 @@ public class OpenCVTestRunner extends InstrumentationTestRunner {
public void onStart() {
ExportLena();
List<TestCase> testCases = androidTestRunner.getTestCases();
Collections.shuffle(testCases); //shuffle the tests order
//List<TestCase> testCases = androidTestRunner.getTestCases();
//Collections.shuffle(testCases); //shuffle the tests order
super.onStart();
}

View File

@ -0,0 +1,223 @@
package org.opencv.test.calib3d;
import org.opencv.test.OpenCVTestCase;
public class calib3dTest extends OpenCVTestCase {
public void testComposeRTMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testConvertPointsFromHomogeneous() {
fail("Not yet implemented");
}
public void testConvertPointsToHomogeneous() {
fail("Not yet implemented");
}
public void testDecomposeProjectionMatrixMatMatMatMat() {
fail("Not yet implemented");
}
public void testDecomposeProjectionMatrixMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testDecomposeProjectionMatrixMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testDecomposeProjectionMatrixMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testDecomposeProjectionMatrixMatMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testDrawChessboardCorners() {
fail("Not yet implemented");
}
public void testEstimateAffine3DMatMatMatMat() {
fail("Not yet implemented");
}
public void testEstimateAffine3DMatMatMatMatDouble() {
fail("Not yet implemented");
}
public void testEstimateAffine3DMatMatMatMatDoubleDouble() {
fail("Not yet implemented");
}
public void testFilterSpecklesMatDoubleIntDouble() {
fail("Not yet implemented");
}
public void testFilterSpecklesMatDoubleIntDoubleMat() {
fail("Not yet implemented");
}
public void testFindChessboardCornersMatSizeMat() {
fail("Not yet implemented");
}
public void testFindChessboardCornersMatSizeMatInt() {
fail("Not yet implemented");
}
public void testFindFundamentalMatMatMat() {
fail("Not yet implemented");
}
public void testFindFundamentalMatMatMatInt() {
fail("Not yet implemented");
}
public void testFindFundamentalMatMatMatIntDouble() {
fail("Not yet implemented");
}
public void testFindFundamentalMatMatMatIntDoubleDouble() {
fail("Not yet implemented");
}
public void testFindFundamentalMatMatMatIntDoubleDoubleMat() {
fail("Not yet implemented");
}
public void testFindHomographyMatMat() {
fail("Not yet implemented");
}
public void testFindHomographyMatMatInt() {
fail("Not yet implemented");
}
public void testFindHomographyMatMatIntDouble() {
fail("Not yet implemented");
}
public void testFindHomographyMatMatIntDoubleMat() {
fail("Not yet implemented");
}
public void testMatMulDeriv() {
fail("Not yet implemented");
}
public void testProjectPointsMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testProjectPointsMatMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testProjectPointsMatMatMatMatMatMatMatDouble() {
fail("Not yet implemented");
}
public void testReprojectImageTo3DMatMatMat() {
fail("Not yet implemented");
}
public void testReprojectImageTo3DMatMatMatBoolean() {
fail("Not yet implemented");
}
public void testReprojectImageTo3DMatMatMatBooleanInt() {
fail("Not yet implemented");
}
public void testRodriguesMatMat() {
fail("Not yet implemented");
}
public void testRodriguesMatMatMat() {
fail("Not yet implemented");
}
public void testSolvePnPMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testSolvePnPMatMatMatMatMatMatBoolean() {
fail("Not yet implemented");
}
public void testSolvePnPRansacMatMatMatMatMatMat() {
fail("Not yet implemented");
}
public void testSolvePnPRansacMatMatMatMatMatMatBoolean() {
fail("Not yet implemented");
}
public void testSolvePnPRansacMatMatMatMatMatMatBooleanInt() {
fail("Not yet implemented");
}
public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloat() {
fail("Not yet implemented");
}
public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloatInt() {
fail("Not yet implemented");
}
public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloatIntMat() {
fail("Not yet implemented");
}
public void testStereoRectifyUncalibratedMatMatMatSizeMatMat() {
fail("Not yet implemented");
}
public void testStereoRectifyUncalibratedMatMatMatSizeMatMatDouble() {
fail("Not yet implemented");
}
public void testValidateDisparityMatMatIntInt() {
fail("Not yet implemented");
}
public void testValidateDisparityMatMatIntIntInt() {
fail("Not yet implemented");
}
}

View File

@ -120,6 +120,7 @@ public class MatTest extends OpenCVTestCase {
public void testInv() {
fail("Not yet implemented");
//FIXME: implement Inv method
//dst = grayE_32f.inv();
//assertMatEqual(grayE_32f, dst);
}
@ -152,13 +153,13 @@ public class MatTest extends OpenCVTestCase {
}
public void testMatIntIntCvTypeScalar() {
Mat gray = new Mat(1, 1, CvType.CV_8UC1, new Scalar(127));
Mat gray = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8UC1, new Scalar(127));
assertFalse(gray.empty());
assertMatEqual(gray, gray127);
Mat rgb = new Mat(1, 1, CvType.CV_8UC4, new Scalar(128));
Mat rgb = new Mat(rgba128.rows(), rgba128.cols(), CvType.CV_8UC4, new Scalar(128));
assertFalse(rgb.empty());
//FIXME: assertMatEqual(rgb, rgba128);
assertMatEqual(rgb, rgba128);
}
public void testMatIntIntInt() {
@ -170,11 +171,11 @@ public class MatTest extends OpenCVTestCase {
}
public void testMatIntIntIntScalar() {
Mat m1 = new Mat(1, 1, CvType.CV_8U, new Scalar(127));
Mat m1 = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8U, new Scalar(127));
assertFalse(m1.empty());
assertMatEqual(m1, gray127);
Mat m2 = new Mat(1, 1, CvType.CV_32F, new Scalar(0));
Mat m2 = new Mat(gray0_32f.rows(), gray0_32f.cols(), CvType.CV_32F, new Scalar(0));
assertFalse(m2.empty());
assertMatEqual(m2, gray0_32f);
}

View File

@ -13,6 +13,8 @@ public class coreTest extends OpenCVTestCase {
public void test_1() {
super.test_1("CORE");
//System.gc();
}
public void testAbsdiff() {
@ -118,7 +120,7 @@ public class coreTest extends OpenCVTestCase {
}
public void testCheckHardwareSupport() {
//FIXME: do we need this function?
//XXX: core.checkHardwareSupport(feature)
boolean hasFeauture = core.checkHardwareSupport(0);
assertEquals(false, hasFeauture);
}
@ -436,7 +438,7 @@ public class coreTest extends OpenCVTestCase {
core.insertChannel(gray0, rgba128, 1);
core.insertChannel(gray0, rgba128, 2);
core.insertChannel(gray0, rgba128, 3);
//assertMatEqual(rgba0, rgba128);
assertMatEqual(rgba0, rgba128);
}
public void testInvertMatMat() {
@ -769,7 +771,7 @@ public class coreTest extends OpenCVTestCase {
}
public void testSetUseOptimized() {
//XXX: do we need this function?
//XXX: core.setUseOptimized(onoff)
fail("Not yet implemented");
}
@ -870,6 +872,7 @@ public class coreTest extends OpenCVTestCase {
}
public void testSubtractMatMatMatMat() {
fail("Not yet implemented");
Mat mask = new Mat(matSize, matSize, CvType.CV_8U);
mask.setTo(new Scalar(0));
Mat submask = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2);
@ -884,11 +887,12 @@ public class coreTest extends OpenCVTestCase {
}
public void testSubtractMatMatMatMatInt() {
core.subtract(gray3, gray1, dst, gray1, gray255_32f.depth());
OpenCVTestRunner.Log(" 3: dst.depth() = " + String.valueOf(dst.depth()));
OpenCVTestRunner.Log(" 4: core.CV_32F = " + String.valueOf(CvType.CV_32F));
//FIXME: assertTrue(CvType.CV_32F == dst.depth());
//assertMatEqual(gray2, dst);
fail("Not yet implemented");
// core.subtract(gray3, gray1, dst, gray1, gray255_32f.depth());
// OpenCVTestRunner.Log(" 3: dst.depth() = " + String.valueOf(dst.depth()));
// OpenCVTestRunner.Log(" 4: core.CV_32F = " + String.valueOf(CvType.CV_32F));
// //FIXME: assertTrue(CvType.CV_32F == dst.depth());
// //assertMatEqual(gray2, dst);
}
public void testTransform() {
@ -905,7 +909,7 @@ public class coreTest extends OpenCVTestCase {
}
public void testUseOptimized() {
//XXX: do we need this function?
//XXX: core.useOptimized()
fail("Not yet implemented");
}

View File

@ -0,0 +1,57 @@
package org.opencv.test.features2d;
import org.opencv.features2d.KeyPoint;
import org.opencv.test.OpenCVTestCase;
public class KeyPointTest extends OpenCVTestCase {
private KeyPoint keyPoint;
private float x;
private float y;
private float size;
@Override
protected void setUp() throws Exception {
super.setUp();
keyPoint = null;
x = 1.0f;
y = 2.0f;
size = 3.0f;
}
public void test_1() {
super.test_1("FEATURES2D.KeyPoint");
}
public void testKeyPoint() {
keyPoint = new KeyPoint();
assertTrue(null != keyPoint);
}
public void testKeyPointFloatFloatFloat() {
keyPoint = new KeyPoint(x, y, size);
assertTrue(null != keyPoint);
}
public void testKeyPointFloatFloatFloatFloat() {
keyPoint = new KeyPoint(x, y, size, 10.0f);
assertTrue(null != keyPoint);
}
public void testKeyPointFloatFloatFloatFloatFloat() {
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f);
assertTrue(null != keyPoint);
}
public void testKeyPointFloatFloatFloatFloatFloatInt() {
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1);
assertTrue(null != keyPoint);
}
public void testKeyPointFloatFloatFloatFloatFloatIntInt() {
keyPoint = new KeyPoint(x, y, size, 1.0f, 1.0f, 1, 1);
assertTrue(null != keyPoint);
}
}

View File

@ -0,0 +1,31 @@
package org.opencv.test.features2d;
import org.opencv.features2d.MSER;
import org.opencv.test.OpenCVTestCase;
public class MSERTest extends OpenCVTestCase {
private MSER mser;
@Override
protected void setUp() throws Exception {
super.setUp();
mser = null;
}
public void test_1() {
super.test_1("FEATURES2D.MSER");
}
public void testMSER() {
mser = new MSER();
assertTrue(null != mser);
}
public void testMSERIntIntIntDoubleDoubleIntDoubleDoubleInt() {
mser = new MSER(5, 60, 14400, .25f, .2f, 200, 1.01, .003, 5);
assertTrue(null != mser);
}
}

View File

@ -0,0 +1,58 @@
package org.opencv.test.features2d;
import org.opencv.features2d.SURF;
import org.opencv.test.OpenCVTestCase;
public class SURFTest extends OpenCVTestCase {
private SURF surf;
@Override
protected void setUp() throws Exception {
super.setUp();
surf = null;
}
public void test_1() {
super.test_1("FEATURES2D.SURF");
}
public void testDescriptorSize() {
surf = new SURF(500.0, 4, 2, false);
assertEquals(64, surf.descriptorSize());
surf = new SURF(500.0, 4, 2, true);
assertEquals(128, surf.descriptorSize());
}
public void testSURF() {
surf = new SURF();
assertTrue(null != surf);
}
public void testSURFDouble() {
surf = new SURF(500.0);
assertTrue(null != surf);
}
public void testSURFDoubleInt() {
surf = new SURF(500.0, 4);
assertTrue(null != surf);
}
public void testSURFDoubleIntInt() {
surf = new SURF(500.0, 4, 2);
assertTrue(null != surf);
}
public void testSURFDoubleIntIntBoolean() {
}
public void testSURFDoubleIntIntBooleanBoolean() {
surf = new SURF(500.0, 4, 2, false, false);
assertTrue(null != surf);
}
}

View File

@ -0,0 +1,31 @@
package org.opencv.test.features2d;
import org.opencv.features2d.StarDetector;
import org.opencv.test.OpenCVTestCase;
public class StarDetectorTest extends OpenCVTestCase {
private StarDetector star;
@Override
protected void setUp() throws Exception {
super.setUp();
star = null;
}
public void test_1() {
super.test_1("FEATURES2D.StarDetector");
}
public void testStarDetector() {
star = new StarDetector();
assertTrue(null != star);
}
public void testStarDetectorIntIntIntIntInt() {
star = new StarDetector(45, 30, 10, 8, 5);
assertTrue(null != star);
}
}

View File

@ -8,27 +8,27 @@ import org.opencv.test.OpenCVTestRunner;
public class highguiTest extends OpenCVTestCase {
public void testDestroyAllWindows() {
//XXX: do not export this function
fail("Do not export this function");
//XXX: highgui.destroyAllWindows()
fail("Not yet implemented");
}
public void testDestroyWindow() {
//XXX: do not export this function
fail("Do not export this function");
//XXX: highgui.destroyWindow(winname)
fail("Not yet implemented");
}
public void testGetTrackbarPos() {
//XXX: do we need this function?
//XXX: highgui.getTrackbarPos(trackbarname, winname)
fail("Not yet implemented");
}
public void testGetWindowProperty() {
//XXX: do we need this function?
//XXX: highgui.getWindowProperty(winname, prop_id)
fail("Not yet implemented");
}
public void testImdecode() {
//XXX: do we need this function?
//XXX: highgui.imdecode(buf, flags)
fail("Not yet implemented");
}
@ -49,42 +49,42 @@ public class highguiTest extends OpenCVTestCase {
}
public void testImshow() {
//XXX: do we need this function?
//XXX: highgui.imshow(winname, mat)
fail("Not yet implemented");
}
public void testNamedWindowString() {
//XXX: do not export this function
//XXX: highgui.namedWindow(winname)
fail("Do not export this function");
}
public void testNamedWindowStringInt() {
//XXX: do not export this function
//XXX: highgui.namedWindow(winname, flags)
fail("Do not export this function");
}
public void testSetTrackbarPos() {
//XXX: do we need this function?
//XXX: highgui.setTrackbarPos(trackbarname, winname, pos)
fail("Not yet implemented");
}
public void testSetWindowProperty() {
//XXX: do we need this function?
//XXX: highgui.setWindowProperty(winname, prop_id, prop_value)
fail("Not yet implemented");
}
public void testStartWindowThread() {
//XXX: do not export this function
//XXX: highgui.startWindowThread()
fail("Do not export this function");
}
public void testWaitKey() {
//XXX: we need this function if only imshow will be implemented
//XXX: highgui.waitKey()
fail("Not yet implemented");
}
public void testWaitKeyInt() {
//XXX: we need this function if only imshow will be implemented
//XXX: highgui.waitKey(delay)
fail("Not yet implemented");
}