Fixed Java API tests

This commit is contained in:
Andrey Kamaev 2012-07-03 12:44:32 +00:00
parent 5615ec7c97
commit efdc055fb1
8 changed files with 66 additions and 80 deletions

View File

@ -25,10 +25,10 @@ import org.opencv.highgui.Highgui;
public class OpenCVTestCase extends TestCase {
//change to 'true' to unblock fail on fail("Not yet implemented")
public static final boolean passNYI = true;
protected static final int matSize = 10;
//change to 'true' to unblock fail on fail("Not yet implemented")
public static final boolean passNYI = true;
protected static final int matSize = 10;
protected static final double EPS = 0.001;
protected static final double weakEPS = 0.5;
@ -185,11 +185,11 @@ public class OpenCVTestCase extends TestCase {
}
public static void fail(String msg) {
if(msg == "Not yet implemented" && passNYI)
return;
TestCase.fail(msg);
if(msg == "Not yet implemented" && passNYI)
return;
TestCase.fail(msg);
}
public static <E extends Number> void assertListEquals(List<E> list1, List<E> list2) {
if (list1.size() != list2.size()) {
throw new UnsupportedOperationException();
@ -220,7 +220,7 @@ public class OpenCVTestCase extends TestCase {
}
for (int i = 0; i < ar1.length; i++)
assertEquals(ar1[i].doubleValue(), ar2[i].doubleValue(), epsilon);
assertEquals(ar1[i].doubleValue(), ar2[i].doubleValue(), epsilon);
//assertTrue(Math.abs(ar1[i].doubleValue() - ar2[i].doubleValue()) <= epsilon);
}
@ -230,7 +230,7 @@ public class OpenCVTestCase extends TestCase {
}
for (int i = 0; i < ar1.length; i++)
assertEquals(ar1[i], ar2[i], epsilon);
assertEquals(ar1[i], ar2[i], epsilon);
//assertTrue(Math.abs(ar1[i].doubleValue() - ar2[i].doubleValue()) <= epsilon);
}
@ -341,9 +341,9 @@ public class OpenCVTestCase extends TestCase {
}
public static void assertListDMatchEquals(List<DMatch> expected, List<DMatch> actual, double epsilon) {
DMatch expectedArray[] = expected.toArray(new DMatch[0]);
DMatch actualArray[] = actual.toArray(new DMatch[0]);
assertArrayDMatchEquals(expectedArray, actualArray, epsilon);
DMatch expectedArray[] = expected.toArray(new DMatch[0]);
DMatch actualArray[] = actual.toArray(new DMatch[0]);
assertArrayDMatchEquals(expectedArray, actualArray, epsilon);
}
public static void assertPointEquals(Point expected, Point actual, double eps) {

View File

@ -17,15 +17,15 @@ import android.util.Log;
/**
* This only class is Android specific.
*
*
* @see <a href="http://opencv.itseez.com">OpenCV</a>
*/
public class OpenCVTestRunner extends InstrumentationTestRunner {
static { System.loadLibrary("opencv_java"); }
public static String LENA_PATH;
static { System.loadLibrary("opencv_java"); }
public static String LENA_PATH;
public static String CHESS_PATH;
public static String LBPCASCADE_FRONTALFACE_PATH;
public static Context context;

View File

@ -84,11 +84,11 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.098605f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 1, 0, 0.484352f),
new DMatch(4, 0, 0, 1.083795f)
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.066820f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 0, 0, 1.141826f),
new DMatch(4, 0, 0, 1.084099f)
};
super.setUp();
@ -166,7 +166,7 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
}
public void testKnnMatchMatMatListOfListOfDMatchInt() {
final int k = 3;
final int k = 3;
Mat train = getTrainDescriptors();
Mat query = getQueryDescriptors();
List<MatOfDMatch> matches = new ArrayList<MatOfDMatch>();
@ -181,12 +181,12 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
assertEquals(query.rows(), matches.size());
for(int i = 0; i<matches.size(); i++)
{
MatOfDMatch vdm = matches.get(i);
//Log.d("knn", "vdm["+i+"]="+vdm.dump());
MatOfDMatch vdm = matches.get(i);
//Log.d("knn", "vdm["+i+"]="+vdm.dump());
assertTrue(Math.min(k, train.rows()) >= vdm.total());
for(DMatch dm : vdm.toArray())
{
assertEquals(dm.queryIdx, i);
assertEquals(dm.queryIdx, i);
}
}
}
@ -206,7 +206,6 @@ public class BruteForceDescriptorMatcherTest extends OpenCVTestCase {
matcher.add(Arrays.asList(train));
matcher.match(query, matches);
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
}

View File

@ -84,11 +84,11 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
new DMatch(0, 1, 0, 6.9202342f),
new DMatch(1, 1, 0, 6.1675916f),
new DMatch(2, 1, 0, 2.6798589f),
new DMatch(3, 1, 0, 2.6545324f),
new DMatch(4, 0, 0, 6.1294847f)
new DMatch(0, 1, 0, 6.9202332f),
new DMatch(1, 0, 0, 6.0567350f),
new DMatch(2, 1, 0, 2.6798587f),
new DMatch(3, 0, 0, 5.8991642f),
new DMatch(4, 0, 0, 6.1321812f)
};
super.setUp();
}
@ -183,7 +183,6 @@ public class BruteForceL1DescriptorMatcherTest extends OpenCVTestCase {
matcher.add(Arrays.asList(train));
matcher.match(query, matches);
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
}

View File

@ -31,7 +31,7 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
}
};
}
/*
private float sqr(float val){
return val * val;
@ -89,11 +89,11 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
new DMatch(0, 0, 0, 1.1018577f),
new DMatch(1, 0, 0, 1.2069331f),
new DMatch(2, 1, 0, 0.2446168f),
new DMatch(3, 1, 0, 0.2345972f),
new DMatch(4, 0, 0, 1.1746116f)
new DMatch(0, 0, 0, 1.1018578f),
new DMatch(1, 0, 0, 1.1381058f),
new DMatch(2, 1, 0, 0.2446168f),
new DMatch(3, 0, 0, 1.3037685f),
new DMatch(4, 0, 0, 1.1752719f)
};
super.setUp();
@ -189,7 +189,9 @@ public class BruteForceSL2DescriptorMatcherTest extends OpenCVTestCase {
matcher.add(Arrays.asList(train));
matcher.match(query, matches);
OpenCVTestRunner.Log(matches);
OpenCVTestRunner.Log(matches);
OpenCVTestRunner.Log(matches);
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
}

View File

@ -158,11 +158,11 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
matSize = 100;
truth = new DMatch[] {
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.098605f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 1, 0, 0.484352f),
new DMatch(4, 0, 0, 1.083795f)
new DMatch(0, 0, 0, 1.049694f),
new DMatch(1, 0, 0, 1.066820f),
new DMatch(2, 1, 0, 0.494587f),
new DMatch(3, 0, 0, 1.141826f),
new DMatch(4, 0, 0, 1.084099f)
};
super.setUp();
@ -283,9 +283,8 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
assertArrayDMatchEquals(truth, matches.toArray(), EPS);
// OpenCVTestRunner.Log("matches found: " + matches.size());
// for (DMatch m : matches)
// OpenCVTestRunner.Log(m.toString());
// OpenCVTestRunner.Log(matches.toString());
// OpenCVTestRunner.Log(matches);
}
public void testMatchMatMatListOfDMatchMat() {
@ -330,7 +329,7 @@ public class FlannBasedDescriptorMatcherTest extends OpenCVTestCase {
matcher.read(filenameR);
matcher.write(filenameW);
assertEquals(ymlParamsModified, readFile(filenameW));
}

View File

@ -47,25 +47,18 @@ public class SURFDescriptorExtractorTest extends OpenCVTestCase {
Mat truth = new Mat(1, 128, CvType.CV_32FC1) {
{
put(0, 0,
/*
0, 0, 0, 0, 0.011540107, 0.0029440077, 0.095483348, 0.018144149, 0.00014820647, 0, 0.00014820647, 0, 0, 0, 0, 0, 0, -0.00014820647,
0, 0.00014820647, 0.10196275, 0.0099145742, 0.57075155, 0.047922116, 0, 0, 0, 0, 0, 0, 0, 0, 0.0029440068, -0.011540107, 0.018144149,
0.095483348, 0.085385554, -0.054076977, 0.34105155, 0.47911066, 0.023395451, -0.11012388, 0.088196531, 0.50863767, 0.0031790689,
-0.019882837, 0.0089476965, 0.054817006, -0.0033560959, -0.0011770058, 0.0033560959, 0.0011770058, 0.019882834, 0.0031790687,
0.054817006, 0.0089476984, 0, 0, 0, 0, -0.0011770058, 0.0033560959, 0.0011770058, 0.0033560959
*/
0, 0, 0, 0, 0, 0, 0, 0, 0.045382127, 0.075976953, -0.031969212, 0.035002094, 0.012224297, 0.012286193,
-0.0088025155, 0.0088025155, 0.00017225844, 0.00017225844, 0, 0, 8.2743405e-05, 8.2743405e-05, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 8.2743405e-05, 8.2743405e-05, -0.00017225844, 0.00017225844, 0, 0, 0.31723264,
0.42715758, -0.19872268, 0.23621935, 0.033304065, 0.033918764, -0.021780485, 0.021780485, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.0088025145, 0.0088025145, 0.012224296, 0.012286192, -0.045382123,
0.075976953, 0.031969212, 0.035002094, 0.10047197, 0.21463872, -0.0012294546, 0.18176091, -0.075555265,
0.35627601, 0.01270232, 0.20058797, -0.037658721, 0.037658721, 0.064850949, 0.064850949, -0.27688536,
0.44229308, 0.14888979, 0.14888979, -0.0031531656, 0.0031531656, 0.0068481555, 0.0072466261, -0.034193151,
0.040314503, 0.01108359, 0.023398584, -0.00071876607, 0.00071876607, -0.0031819802, 0.0031819802, 0, 0,
-0.0013680183, 0.0013680183, 0.034193147, 0.040314503, -0.01108359, 0.023398584, 0.006848156, 0.0072466265,
-0.0031531656, 0.0031531656, 0, 0, 0, 0, 0, 0, 0, 0, -0.0013680183, 0.0013680183, 0, 0, 0.00071876607,
0.00071876607, 0.0031819802, 0.0031819802
-0.0041138371, 0.0041138371, 0, 0, 0, 0, 0.0014427509, 0.0014427509, -0.0081971241, 0.034624498, 0.032569118,
0.032569118, -0.007222258, 0.0076424959, 0.0033254174, 0.0033254174, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -0.10815519, 0.38033518, 0.24314292, 0.24314292, -0.068393648, 0.068393648,
0.039715949, 0.039715949, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -8.7263528e-05, 8.7263528e-05, -6.0081031e-05,
6.0081031e-05, -0.00012158759, 0.00012158759, 0.0033254174, 0.0033254174, -0.007222258, 0.0076424964,
0.0081971241, 0.034624498, -0.032569118, 0.032569118, -0.077379324, 0.27552885, 0.14366581, 0.31175563,
-0.013609707, 0.24329227, -0.091054246, 0.17476201, 0.022970313, 0.022970313, -0.035123408, 0.035771687,
0.1907353, 0.3838968, -0.31571922, 0.31571922, 0.0092833797, 0.0092833797, -0.012892088, 0.012957365,
0.029558292, 0.073337689, -0.043703932, 0.043703932, 0.0014427509, 0.0014427509, 0, 0, 0.0041138371,
0.0041138371, 0, 0, -0.02955829, 0.073337704, 0.043703932, 0.043703932, -0.012892087, 0.012957364,
0.0092833797,0.0092833797, 6.0081031e-05, 6.0081031e-05, 0.00012158759, 0.00012158759, -8.7263528e-05,
8.7263528e-05, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
);
}
};

View File

@ -57,17 +57,11 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
matSize = 100;
truth = new KeyPoint[] {
/*
new KeyPoint(55.775577545166016f, 44.224422454833984f, 16, 9.754629f, 8617.863f, 1, -1),
new KeyPoint(44.224422454833984f, 44.224422454833984f, 16, 99.75463f, 8617.863f, 1, -1),
new KeyPoint(44.224422454833984f, 55.775577545166016f, 16, 189.7546f, 8617.863f, 1, -1),
new KeyPoint(55.775577545166016f, 55.775577545166016f, 16, 279.75464f, 8617.863f, 1, -1)
*/
new KeyPoint(55.7755f, 44.2244f, 16, 9.754f, 8617.863f, 0, -1),
new KeyPoint(44.2244f, 44.2244f, 16, 99.754f, 8617.863f, 0, -1),
new KeyPoint(44.2244f, 55.7755f, 16, 189.754f, 8617.863f, 0, -1),
new KeyPoint(55.7755f, 55.7755f, 16, 279.754f, 8617.863f, 0, -1)
};
new KeyPoint(55.775578f, 55.775578f, 16, 80.245735f, 8617.8633f, 0, -1),
new KeyPoint(44.224422f, 55.775578f, 16, 170.24574f, 8617.8633f, 0, -1),
new KeyPoint(44.224422f, 44.224422f, 16, 260.24573f, 8617.8633f, 0, -1),
new KeyPoint(55.775578f, 44.224422f, 16, 350.24573f, 8617.8633f, 0, -1)
};
super.setUp();
}
@ -93,7 +87,7 @@ public class SURFFeatureDetectorTest extends OpenCVTestCase {
assertEquals(3, keypoints.size());
for (MatOfKeyPoint mkp : keypoints) {
List<KeyPoint> lkp = mkp.toList();
List<KeyPoint> lkp = mkp.toList();
order(lkp);
assertListKeyPointEquals(Arrays.asList(truth), lkp, EPS);
}