java tests: Mat.inv and Mat.cross implemented, almost all Mat tests finished except put, get and dispose

pull/13383/head
Kirill Kornyakov 14 years ago
parent 2dd965b7f5
commit 9b464199d6
  1. 10
      modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java
  2. 49
      modules/java/android_test/src/org/opencv/test/core/MatTest.java
  3. 9
      modules/java/src/cpp/Mat.cpp

@ -50,6 +50,9 @@ public class OpenCVTestCase extends TestCase {
protected static Mat rgbLena;
protected static Mat v1;
protected static Mat v2;
@Override
protected void setUp() throws Exception {
super.setUp();
@ -89,11 +92,14 @@ public class OpenCVTestCase extends TestCase {
rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4); rgba128.setTo(Scalar.all(128));
rgbLena = highgui.imread(OpenCVTestRunner.LENA_PATH);
v1 = new Mat(1, 3, CvType.CV_32F); v1.put(0, 0, 1.0, 3.0, 2.0);
v2 = new Mat(1, 3, CvType.CV_32F); v2.put(0, 0, 2.0, 1.0, 3.0);
}
public static void assertMatEqual(Mat m1, Mat m2) {
OpenCVTestRunner.Log(m1.toString());
OpenCVTestRunner.Log(m2.toString());
//OpenCVTestRunner.Log(m1.toString());
//OpenCVTestRunner.Log(m2.toString());
if (!m1.type().equals(m2.type()) ||
m1.cols() != m2.cols() || m1.rows() != m2.rows()) {

@ -39,15 +39,20 @@ public class MatTest extends OpenCVTestCase {
}
public void testCopyTo() {
fail("Not yet implemented");
rgbLena.copyTo(dst);
assertMatEqual(rgbLena, dst);
}
public void testCross() {
fail("Not yet implemented");
Mat answer = new Mat(1, 3, CvType.CV_32F);
answer.put(0, 0, 7.0, 1.0, -5.0);
Mat cross = v1.cross(v2);
assertMatEqual(answer, cross);
}
public void testDataAddr() {
fail("Not yet implemented");
assertTrue(0 != gray0.dataAddr());
}
public void testDepth() {
@ -60,15 +65,18 @@ public class MatTest extends OpenCVTestCase {
}
public void testDot() {
fail("Not yet implemented");
double s = v1.dot(v2);
assertEquals(11.0, s);
}
public void testDump() {
fail("Not yet implemented");
assertEquals("[1, 3, 2]", v1.dump());
}
public void testElemSize() {
fail("Not yet implemented");
assertEquals(1, gray0.elemSize());
assertEquals(4, gray0_32f.elemSize());
assertEquals(3, rgbLena.elemSize());
}
public void testEmpty() {
@ -77,11 +85,8 @@ public class MatTest extends OpenCVTestCase {
}
public void testEye() {
fail("Not yet implemented");
}
public void testFinalize() {
fail("Not yet implemented");
Mat eye = Mat.eye(3, 3, CvType.CV_32FC1);
assertMatEqual(eye, eye.inv());
}
public void testGetIntInt() {
@ -119,10 +124,8 @@ public class MatTest extends OpenCVTestCase {
}
public void testInv() {
fail("Not yet implemented");
//FIXME: implement Inv method
//dst = grayE_32f.inv();
//assertMatEqual(grayE_32f, dst);
dst = grayE_32f.inv();
assertMatEqual(grayE_32f, dst);
}
public void testIsContinuous() {
@ -153,13 +156,13 @@ public class MatTest extends OpenCVTestCase {
}
public void testMatIntIntCvTypeScalar() {
Mat gray = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8UC1, new Scalar(127));
assertFalse(gray.empty());
assertMatEqual(gray, gray127);
dst = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8U, new Scalar(127));
assertFalse(dst.empty());
assertMatEqual(dst, gray127);
Mat rgb = new Mat(rgba128.rows(), rgba128.cols(), CvType.CV_8UC4, new Scalar(128));
assertFalse(rgb.empty());
assertMatEqual(rgb, rgba128);
dst = new Mat(rgba128.rows(), rgba128.cols(), CvType.CV_8UC4, Scalar.all(128));
assertFalse(dst.empty());
assertMatEqual(dst, rgba128);
}
public void testMatIntIntInt() {
@ -180,10 +183,6 @@ public class MatTest extends OpenCVTestCase {
assertMatEqual(m2, gray0_32f);
}
public void testMatLong() {
fail("Not yet implemented");
}
public void testPutIntIntByteArray() {
fail("Not yet implemented");
}

@ -379,15 +379,18 @@ JNIEXPORT jdouble JNICALL Java_org_opencv_Mat_nDot
}
JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nCross
(JNIEnv* env, jclass cls, jlong self, jlong it)
(JNIEnv* env, jclass cls, jlong self, jlong m)
{
return 0; //NYI
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
cv::Mat* _m = (cv::Mat*) m; //TODO: check for NULL
return (jlong) new cv::Mat(me->cross( *_m ));
}
JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nInv
(JNIEnv* env, jclass cls, jlong self)
{
return 0; //NYI
cv::Mat* me = (cv::Mat*) self; //TODO: check for NULL
return (jlong) new cv::Mat(me->inv());
}
JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nCreateMat__

Loading…
Cancel
Save