Commit c1dab7bf authored by Kirill Kornyakov's avatar Kirill Kornyakov

updated some java tests

parent fae67e0b
...@@ -241,7 +241,6 @@ public class MatTest extends OpenCVTestCase { ...@@ -241,7 +241,6 @@ public class MatTest extends OpenCVTestCase {
public void testType() { public void testType() {
assertEquals(CvType.CV_8UC1, gray0.type()); assertEquals(CvType.CV_8UC1, gray0.type());
//TODO: assertEquals(CvType.CV_8U, gray0.type());
assertEquals(CvType.CV_32FC1, gray0_32f.type()); assertEquals(CvType.CV_32FC1, gray0_32f.type());
assertEquals(CvType.CV_8UC3, rgbLena.type()); assertEquals(CvType.CV_8UC3, rgbLena.type());
} }
......
...@@ -7,7 +7,6 @@ import org.opencv.Scalar; ...@@ -7,7 +7,6 @@ import org.opencv.Scalar;
import org.opencv.core; import org.opencv.core;
import org.opencv.test.OpenCVTestCase; import org.opencv.test.OpenCVTestCase;
import org.opencv.test.OpenCVTestRunner;
public class coreTest extends OpenCVTestCase { public class coreTest extends OpenCVTestCase {
...@@ -46,9 +45,9 @@ public class coreTest extends OpenCVTestCase { ...@@ -46,9 +45,9 @@ public class coreTest extends OpenCVTestCase {
} }
public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() { public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() {
core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst);//FIXME: #1224, CvType.CV_32F core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst, CvType.CV_32F);
assertTrue(CvType.CV_32F == dst.depth()); assertTrue(CvType.CV_32F == dst.depth());
//TODO: assertMatEqual(gray255_32f, dst); assertMatEqual(gray255_32f, dst);
} }
public void testBitwise_andMatMatMat() { public void testBitwise_andMatMatMat() {
...@@ -95,7 +94,7 @@ public class coreTest extends OpenCVTestCase { ...@@ -95,7 +94,7 @@ public class coreTest extends OpenCVTestCase {
Mat covar = new Mat(matSize, matSize, CvType.CV_64FC1); Mat covar = new Mat(matSize, matSize, CvType.CV_64FC1);
Mat mean = new Mat(1, matSize, CvType.CV_64FC1); Mat mean = new Mat(1, matSize, CvType.CV_64FC1);
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1); //TODO: CV_COVAR_NORMAL instead of magic numbers core.calcCovarMatrix(gray0_32f, covar, mean, 8|1/*TODO: CV_COVAR_NORMAL*/);
assertMatEqual(gray0_64f, covar); assertMatEqual(gray0_64f, covar);
assertMatEqual(gray0_64f_1d, mean); assertMatEqual(gray0_64f_1d, mean);
} }
...@@ -104,7 +103,7 @@ public class coreTest extends OpenCVTestCase { ...@@ -104,7 +103,7 @@ public class coreTest extends OpenCVTestCase {
Mat covar = new Mat(matSize, matSize, CvType.CV_32F); Mat covar = new Mat(matSize, matSize, CvType.CV_32F);
Mat mean = new Mat(1, matSize, CvType.CV_32F); Mat mean = new Mat(1, matSize, CvType.CV_32F);
core.calcCovarMatrix(gray0_32f, covar, mean, 8|1, CvType.CV_32F); //FIXME: CV_COVAR_NORMAL core.calcCovarMatrix(gray0_32f, covar, mean, 8|1/*TODO: CV_COVAR_NORMAL*/, CvType.CV_32F);
assertMatEqual(gray0_32f, covar); assertMatEqual(gray0_32f, covar);
assertMatEqual(gray0_32f_1d, mean); assertMatEqual(gray0_32f_1d, mean);
} }
...@@ -117,12 +116,6 @@ public class coreTest extends OpenCVTestCase { ...@@ -117,12 +116,6 @@ public class coreTest extends OpenCVTestCase {
fail("Not yet implemented"); fail("Not yet implemented");
} }
public void testCheckHardwareSupport() {
//XXX: core.checkHardwareSupport(feature)
//boolean hasFeauture = core.checkHardwareSupport(0);
//assertEquals(false, hasFeauture);
}
public void testCircleMatPointIntScalar() { public void testCircleMatPointIntScalar() {
Point center = new Point(gray0.cols() / 2, gray0.rows()/2); Point center = new Point(gray0.cols() / 2, gray0.rows()/2);
int radius = Math.min(gray0.cols()/4, gray0.rows()/4); int radius = Math.min(gray0.cols()/4, gray0.rows()/4);
...@@ -300,7 +293,6 @@ public class coreTest extends OpenCVTestCase { ...@@ -300,7 +293,6 @@ public class coreTest extends OpenCVTestCase {
public void testExp() { public void testExp() {
Mat destination = new Mat(matSize, matSize, CvType.CV_32F); destination.setTo(new Scalar(0.0)); Mat destination = new Mat(matSize, matSize, CvType.CV_32F); destination.setTo(new Scalar(0.0));
core.exp(gray0_32f, destination); core.exp(gray0_32f, destination);
OpenCVTestRunner.Log(destination.dump());
assertMatEqual(gray1_32f, destination); assertMatEqual(gray1_32f, destination);
} }
...@@ -381,8 +373,10 @@ public class coreTest extends OpenCVTestCase { ...@@ -381,8 +373,10 @@ public class coreTest extends OpenCVTestCase {
int vecsize = core.getOptimalDFTSize(0); int vecsize = core.getOptimalDFTSize(0);
assertEquals(1, vecsize); assertEquals(1, vecsize);
int largeVecSize = core.getOptimalDFTSize(32768); int largeVecSize = core.getOptimalDFTSize(133);
assertTrue(largeVecSize < 0); //FIXME:fails why?? assertEquals(135, largeVecSize);
largeVecSize = core.getOptimalDFTSize(13);
assertEquals(15, largeVecSize);
} }
public void testGetTickFrequency() { public void testGetTickFrequency() {
...@@ -484,19 +478,13 @@ public class coreTest extends OpenCVTestCase { ...@@ -484,19 +478,13 @@ public class coreTest extends OpenCVTestCase {
} }
public void testLog() { public void testLog() {
//FIXME: why it fails for the above array! Mat in = new Mat(1, 4, CvType.CV_32FC1);
// Mat in = new Mat(1, 4, Mat.CvType.CV_32FC1); Mat desired = new Mat(1, 4, CvType.CV_32FC1);
// Mat des = new Mat(1, 4, Mat.CvType.CV_32FC1); in.put(0, 0, 1.0, 10.0, 100.0, 1000.0);
// in.put(0, 0, 1.0, 2.0, 4.0,3.0); desired.put(0, 0, 0, 2.3025851, 4.6051702, 6.9077554);
// des.put(0,0, 0.0, 0.3010,0.6021,0.4771);
// assertMatEqual(des,dst_gray);
Mat in = new Mat(1, 1, CvType.CV_32F);
Mat des = new Mat(1, 1, CvType.CV_32F);
in.put(0, 0, 1);
des.put(0,0, 0.0);
core.log(in, dst); core.log(in, dst);
assertMatEqual(des, dst); assertMatEqual(desired, dst);
} }
public void testLUTMatMatMat() { public void testLUTMatMatMat() {
...@@ -527,7 +515,7 @@ public class coreTest extends OpenCVTestCase { ...@@ -527,7 +515,7 @@ public class coreTest extends OpenCVTestCase {
core.magnitude(x, y, dst_gray); core.magnitude(x, y, dst_gray);
assertMatEqual(dst,dst_gray); assertMatEqual(dst,dst_gray);
*/ */
//FIXME: fails for the above case, why? //fails for the above case, why?
/*Mat x = new Mat(1, 1, Mat.CvType.CV_32FC1); /*Mat x = new Mat(1, 1, Mat.CvType.CV_32FC1);
Mat y = new Mat(1, 1, Mat.CvType.CV_32FC1); Mat y = new Mat(1, 1, Mat.CvType.CV_32FC1);
Mat dst = new Mat(1, 1, Mat.CvType.CV_32FC1); Mat dst = new Mat(1, 1, Mat.CvType.CV_32FC1);
...@@ -546,7 +534,7 @@ public class coreTest extends OpenCVTestCase { ...@@ -546,7 +534,7 @@ public class coreTest extends OpenCVTestCase {
public void testMahalanobis() { public void testMahalanobis() {
Mat covar = new Mat(matSize, matSize, CvType.CV_32F); Mat covar = new Mat(matSize, matSize, CvType.CV_32F);
Mat mean = new Mat(1, matSize, CvType.CV_32F); Mat mean = new Mat(1, matSize, CvType.CV_32F);
core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1, CvType.CV_32F); //TODO: CV_COVAR_NORMAL instead of magic numbers core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1/*TODO: CV_COVAR_NORMAL*/, CvType.CV_32F);
covar.inv(); covar.inv();
Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols()); Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols());
...@@ -605,7 +593,7 @@ public class coreTest extends OpenCVTestCase { ...@@ -605,7 +593,7 @@ public class coreTest extends OpenCVTestCase {
public void testMulSpectrumsMatMatMatInt() { public void testMulSpectrumsMatMatMatInt() {
//TODO: nice example //nice example
fail("Not yet implemented"); fail("Not yet implemented");
} }
...@@ -638,16 +626,16 @@ public class coreTest extends OpenCVTestCase { ...@@ -638,16 +626,16 @@ public class coreTest extends OpenCVTestCase {
core.mulTransposed(grayRnd_32f, dst, true, grayRnd_32f); core.mulTransposed(grayRnd_32f, dst, true, grayRnd_32f);
assertMatEqual(gray0_32f, dst); assertMatEqual(gray0_32f, dst);
Mat grayDelta = new Mat(matSize, matSize, CvType.CV_8U); Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F);
grayDelta.setTo(new Scalar(0.0001)); grayDelta.setTo(new Scalar(0.0));
core.mulTransposed(grayE_32f, dst, true, grayDelta); core.mulTransposed(grayE_32f, dst, true, grayDelta);
assertMatEqual(grayE_32f, dst); assertMatEqual(grayE_32f, dst);
} }
public void testMulTransposedMatMatBooleanMatDouble() { public void testMulTransposedMatMatBooleanMatDouble() {
Mat grayDelta = new Mat(matSize, matSize, CvType.CV_8U); Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F);
grayDelta.setTo(new Scalar(0.0001)); grayDelta.setTo(new Scalar(0.0));
core.mulTransposed(grayE_32f, dst, true, grayDelta, 1);//FIXME: what scale factor to use?! core.mulTransposed(grayE_32f, dst, true, grayDelta, 1);
assertMatEqual(grayE_32f, dst); assertMatEqual(grayE_32f, dst);
} }
...@@ -710,7 +698,7 @@ public class coreTest extends OpenCVTestCase { ...@@ -710,7 +698,7 @@ public class coreTest extends OpenCVTestCase {
} }
public void testPerspectiveTransform() { public void testPerspectiveTransform() {
//TODO: nice example //nice example
fail("Not yet implemented"); fail("Not yet implemented");
} }
...@@ -785,11 +773,6 @@ public class coreTest extends OpenCVTestCase { ...@@ -785,11 +773,6 @@ public class coreTest extends OpenCVTestCase {
fail("Not yet implemented. Scalar type is not supported"); fail("Not yet implemented. Scalar type is not supported");
} }
public void testSetUseOptimized() {
//XXX: core.setUseOptimized(onoff)
fail("Not yet implemented");
}
public void testSolveCubic() { public void testSolveCubic() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
...@@ -831,19 +814,16 @@ public class coreTest extends OpenCVTestCase { ...@@ -831,19 +814,16 @@ public class coreTest extends OpenCVTestCase {
} }
public void testSort() { public void testSort() {
Mat matrix = new Mat(matSize, matSize, CvType.CV_8U); Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2);
matrix.setTo(new Scalar(0.0)); submat.setTo(new Scalar(1.0));
Mat submatrix = matrix.submat(0, matrix.rows() / 2, 0, matrix.cols() / 2);
submatrix.setTo(new Scalar(1.0));
core.sort(matrix, dst, 0); //FIXME: #define CV_SORT_EVERY_ROW 0
Mat subdst = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols()); core.sort(gray0, dst, 0/*TODO: CV_SORT_EVERY_ROW*/);
assertTrue(subdst.total() == core.countNonZero(subdst)); submat = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols());
assertTrue(submat.total() == core.countNonZero(submat));
core.sort(matrix, dst, 1); //FIXME: #define CV_SORT_EVERY_COLUMN 1 core.sort(gray0, dst, 1/*TODO: CV_SORT_EVERY_COLUMN*/);
Mat subdst1 = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2); submat = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2);
assertTrue(subdst1.total() == core.countNonZero(subdst1)); assertTrue(submat.total() == core.countNonZero(submat));
} }
public void testSortIdx() { public void testSortIdx() {
...@@ -870,15 +850,13 @@ public class coreTest extends OpenCVTestCase { ...@@ -870,15 +850,13 @@ public class coreTest extends OpenCVTestCase {
core.sqrt(gray9_32f, dst); core.sqrt(gray9_32f, dst);
assertMatEqual(gray3_32f, dst); assertMatEqual(gray3_32f, dst);
//TODO: We can't use assertMatEqual with multi-channel mat Mat rgba144 = new Mat(matSize, matSize, CvType.CV_32FC4);
// Mat rgba144 = new Mat(matSize, matSize, Mat.CvType.CV_32FC4); Mat rgba12 = new Mat(matSize, matSize, CvType.CV_32FC4);
// Mat rgba12 = new Mat(matSize, matSize, Mat.CvType.CV_32FC4); rgba144.setTo(Scalar.all(144));
// Mat rgba_dst = new Mat(matSize, matSize, Mat.CvType.CV_32FC4); rgba12.setTo(Scalar.all(12));
// rgba144.setTo(144, 144, 144, 144);
// rgba12.setTo(12, 12, 12, 12); core.sqrt(rgba144, dst);
// rgba_dst.setTo(0, 0, 0, 0); assertMatEqual(rgba12, dst);
// core.sqrt(rgba144, rgba_dst);
// //assertMatEqual(rgba12, rgba_dst);
} }
public void testSubtractMatMatMat() { public void testSubtractMatMatMat() {
...@@ -887,27 +865,19 @@ public class coreTest extends OpenCVTestCase { ...@@ -887,27 +865,19 @@ public class coreTest extends OpenCVTestCase {
} }
public void testSubtractMatMatMatMat() { public void testSubtractMatMatMatMat() {
fail("Not yet implemented"); Mat mask = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0));
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); Mat submask = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2);
submask.setTo(new Scalar(1)); submask.setTo(new Scalar(1));
//FIXME: looks like a bug dst = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0));
OpenCVTestRunner.Log(" submask.total() = " + String.valueOf(submask.total()));
OpenCVTestRunner.Log(" 1: core.countNonZero(dst) = " + String.valueOf(core.countNonZero(dst)));
core.subtract(gray3, gray2, dst, mask); core.subtract(gray3, gray2, dst, mask);
OpenCVTestRunner.Log(" 2: core.countNonZero(dst) = " + String.valueOf(core.countNonZero(dst)));
assertTrue(submask.total() == core.countNonZero(dst)); assertTrue(submask.total() == core.countNonZero(dst));
} }
public void testSubtractMatMatMatMatInt() { public void testSubtractMatMatMatMatInt() {
fail("Not yet implemented"); core.subtract(gray3, gray2, dst, gray1, CvType.CV_32F);
// core.subtract(gray3, gray1, dst, gray1, gray255_32f.depth()); assertTrue(CvType.CV_32F == dst.depth());
// OpenCVTestRunner.Log(" 3: dst.depth() = " + String.valueOf(dst.depth())); assertMatEqual(gray1_32f, dst);
// OpenCVTestRunner.Log(" 4: core.CV_32F = " + String.valueOf(CvType.CV_32F));
// //FIXME: assertTrue(CvType.CV_32F == dst.depth());
// //assertMatEqual(gray2, dst);
} }
public void testTransform() { public void testTransform() {
...@@ -923,11 +893,6 @@ public class coreTest extends OpenCVTestCase { ...@@ -923,11 +893,6 @@ public class coreTest extends OpenCVTestCase {
assertTrue(subdst.total() == core.countNonZero(subdst)); assertTrue(subdst.total() == core.countNonZero(subdst));
} }
public void testUseOptimized() {
//XXX: core.useOptimized()
fail("Not yet implemented");
}
public void testVconcat() { public void testVconcat() {
fail("Not yet implemented"); fail("Not yet implemented");
} }
......
...@@ -7,31 +7,6 @@ import org.opencv.test.OpenCVTestRunner; ...@@ -7,31 +7,6 @@ import org.opencv.test.OpenCVTestRunner;
public class highguiTest extends OpenCVTestCase { public class highguiTest extends OpenCVTestCase {
public void testDestroyAllWindows() {
//XXX: highgui.destroyAllWindows()
fail("Not yet implemented");
}
public void testDestroyWindow() {
//XXX: highgui.destroyWindow(winname)
fail("Not yet implemented");
}
public void testGetTrackbarPos() {
//XXX: highgui.getTrackbarPos(trackbarname, winname)
fail("Not yet implemented");
}
public void testGetWindowProperty() {
//XXX: highgui.getWindowProperty(winname, prop_id)
fail("Not yet implemented");
}
public void testImdecode() {
//XXX: highgui.imdecode(buf, flags)
fail("Not yet implemented");
}
public void testImreadString() { public void testImreadString() {
dst = highgui.imread(OpenCVTestRunner.LENA_PATH); dst = highgui.imread(OpenCVTestRunner.LENA_PATH);
assertTrue(!dst.empty()); assertTrue(!dst.empty());
...@@ -48,44 +23,4 @@ public class highguiTest extends OpenCVTestCase { ...@@ -48,44 +23,4 @@ public class highguiTest extends OpenCVTestCase {
assertTrue(512 == dst.rows()); assertTrue(512 == dst.rows());
} }
public void testImshow() {
//XXX: highgui.imshow(winname, mat)
fail("Not yet implemented");
}
public void testNamedWindowString() {
//XXX: highgui.namedWindow(winname)
fail("Do not export this function");
}
public void testNamedWindowStringInt() {
//XXX: highgui.namedWindow(winname, flags)
fail("Do not export this function");
}
public void testSetTrackbarPos() {
//XXX: highgui.setTrackbarPos(trackbarname, winname, pos)
fail("Not yet implemented");
}
public void testSetWindowProperty() {
//XXX: highgui.setWindowProperty(winname, prop_id, prop_value)
fail("Not yet implemented");
}
public void testStartWindowThread() {
//XXX: highgui.startWindowThread()
fail("Do not export this function");
}
public void testWaitKey() {
//XXX: highgui.waitKey()
fail("Not yet implemented");
}
public void testWaitKeyInt() {
//XXX: highgui.waitKey(delay)
fail("Not yet implemented");
}
} }
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