Commit 9b464199 authored by Kirill Kornyakov's avatar Kirill Kornyakov

java tests: Mat.inv and Mat.cross implemented, almost all Mat tests finished…

java tests: Mat.inv and Mat.cross implemented, almost all Mat tests finished except put, get and dispose
parent 2dd965b7
...@@ -50,6 +50,9 @@ public class OpenCVTestCase extends TestCase { ...@@ -50,6 +50,9 @@ public class OpenCVTestCase extends TestCase {
protected static Mat rgbLena; protected static Mat rgbLena;
protected static Mat v1;
protected static Mat v2;
@Override @Override
protected void setUp() throws Exception { protected void setUp() throws Exception {
super.setUp(); super.setUp();
...@@ -89,11 +92,14 @@ public class OpenCVTestCase extends TestCase { ...@@ -89,11 +92,14 @@ public class OpenCVTestCase extends TestCase {
rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4); rgba128.setTo(Scalar.all(128)); rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4); rgba128.setTo(Scalar.all(128));
rgbLena = highgui.imread(OpenCVTestRunner.LENA_PATH); 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) { public static void assertMatEqual(Mat m1, Mat m2) {
OpenCVTestRunner.Log(m1.toString()); //OpenCVTestRunner.Log(m1.toString());
OpenCVTestRunner.Log(m2.toString()); //OpenCVTestRunner.Log(m2.toString());
if (!m1.type().equals(m2.type()) || if (!m1.type().equals(m2.type()) ||
m1.cols() != m2.cols() || m1.rows() != m2.rows()) { m1.cols() != m2.cols() || m1.rows() != m2.rows()) {
......
...@@ -39,15 +39,20 @@ public class MatTest extends OpenCVTestCase { ...@@ -39,15 +39,20 @@ public class MatTest extends OpenCVTestCase {
} }
public void testCopyTo() { public void testCopyTo() {
fail("Not yet implemented"); rgbLena.copyTo(dst);
assertMatEqual(rgbLena, dst);
} }
public void testCross() { 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() { public void testDataAddr() {
fail("Not yet implemented"); assertTrue(0 != gray0.dataAddr());
} }
public void testDepth() { public void testDepth() {
...@@ -60,15 +65,18 @@ public class MatTest extends OpenCVTestCase { ...@@ -60,15 +65,18 @@ public class MatTest extends OpenCVTestCase {
} }
public void testDot() { public void testDot() {
fail("Not yet implemented"); double s = v1.dot(v2);
assertEquals(11.0, s);
} }
public void testDump() { public void testDump() {
fail("Not yet implemented"); assertEquals("[1, 3, 2]", v1.dump());
} }
public void testElemSize() { public void testElemSize() {
fail("Not yet implemented"); assertEquals(1, gray0.elemSize());
assertEquals(4, gray0_32f.elemSize());
assertEquals(3, rgbLena.elemSize());
} }
public void testEmpty() { public void testEmpty() {
...@@ -77,11 +85,8 @@ public class MatTest extends OpenCVTestCase { ...@@ -77,11 +85,8 @@ public class MatTest extends OpenCVTestCase {
} }
public void testEye() { public void testEye() {
fail("Not yet implemented"); Mat eye = Mat.eye(3, 3, CvType.CV_32FC1);
} assertMatEqual(eye, eye.inv());
public void testFinalize() {
fail("Not yet implemented");
} }
public void testGetIntInt() { public void testGetIntInt() {
...@@ -119,10 +124,8 @@ public class MatTest extends OpenCVTestCase { ...@@ -119,10 +124,8 @@ public class MatTest extends OpenCVTestCase {
} }
public void testInv() { public void testInv() {
fail("Not yet implemented"); dst = grayE_32f.inv();
//FIXME: implement Inv method assertMatEqual(grayE_32f, dst);
//dst = grayE_32f.inv();
//assertMatEqual(grayE_32f, dst);
} }
public void testIsContinuous() { public void testIsContinuous() {
...@@ -153,13 +156,13 @@ public class MatTest extends OpenCVTestCase { ...@@ -153,13 +156,13 @@ public class MatTest extends OpenCVTestCase {
} }
public void testMatIntIntCvTypeScalar() { public void testMatIntIntCvTypeScalar() {
Mat gray = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8UC1, new Scalar(127)); dst = new Mat(gray127.rows(), gray127.cols(), CvType.CV_8U, new Scalar(127));
assertFalse(gray.empty()); assertFalse(dst.empty());
assertMatEqual(gray, gray127); assertMatEqual(dst, gray127);
Mat rgb = new Mat(rgba128.rows(), rgba128.cols(), CvType.CV_8UC4, new Scalar(128)); dst = new Mat(rgba128.rows(), rgba128.cols(), CvType.CV_8UC4, Scalar.all(128));
assertFalse(rgb.empty()); assertFalse(dst.empty());
assertMatEqual(rgb, rgba128); assertMatEqual(dst, rgba128);
} }
public void testMatIntIntInt() { public void testMatIntIntInt() {
...@@ -180,10 +183,6 @@ public class MatTest extends OpenCVTestCase { ...@@ -180,10 +183,6 @@ public class MatTest extends OpenCVTestCase {
assertMatEqual(m2, gray0_32f); assertMatEqual(m2, gray0_32f);
} }
public void testMatLong() {
fail("Not yet implemented");
}
public void testPutIntIntByteArray() { public void testPutIntIntByteArray() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
......
...@@ -379,15 +379,18 @@ JNIEXPORT jdouble JNICALL Java_org_opencv_Mat_nDot ...@@ -379,15 +379,18 @@ JNIEXPORT jdouble JNICALL Java_org_opencv_Mat_nDot
} }
JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nCross 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 JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nInv
(JNIEnv* env, jclass cls, jlong self) (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__ JNIEXPORT jlong JNICALL Java_org_opencv_Mat_nCreateMat__
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment