java tests: merged with new CvType, implemented half of the tests for Mat
This commit is contained in:
		| @@ -1,6 +1,8 @@ | |||||||
| package org.opencv.test; | package org.opencv.test; | ||||||
|  |  | ||||||
|  | import org.opencv.CvType; | ||||||
| import org.opencv.Mat; | import org.opencv.Mat; | ||||||
|  | import org.opencv.Scalar; | ||||||
|  |  | ||||||
| public class MatTest extends OpenCVTestCase { | public class MatTest extends OpenCVTestCase { | ||||||
| 	 | 	 | ||||||
| @@ -9,20 +11,26 @@ public class MatTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testChannels() { | 	public void testChannels() { | ||||||
| 		//fail("Not yet implemented"); | 		assertEquals(1, gray0.channels()); | ||||||
| 		//utils.Log(grayRnd.dump()); | 		assertEquals(3, rgbLena.channels()); | ||||||
|  | 		assertEquals(4, rgba0.channels()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testClone() { | 	public void testClone() { | ||||||
| 		fail("Not yet implemented"); | 		dst = gray0.clone(); | ||||||
|  | 		assertMatEqual(gray0, dst); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testCol() { | 	public void testCol() { | ||||||
| 		fail("Not yet implemented"); | 		Mat col = gray0.col(0); | ||||||
|  | 		assertEquals(1, col.cols()); | ||||||
|  | 		assertEquals(gray0.rows(), col.rows()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testColRange() { | 	public void testColRange() { | ||||||
| 		fail("Not yet implemented"); | 		Mat cols = gray0.colRange(0, gray0.cols()/2); | ||||||
|  | 		assertEquals(gray0.cols()/2, cols.cols()); | ||||||
|  | 		assertEquals(gray0.rows(), cols.rows()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testCols() { | 	public void testCols() { | ||||||
| @@ -42,7 +50,8 @@ public class MatTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testDepth() { | 	public void testDepth() { | ||||||
| 		fail("Not yet implemented"); | 		assertEquals(CvType.CV_8U, gray0.depth()); | ||||||
|  | 		assertEquals(CvType.CV_32F, gray0_32f.depth()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testDispose() { | 	public void testDispose() { | ||||||
| @@ -53,11 +62,20 @@ public class MatTest extends OpenCVTestCase { | |||||||
| 		fail("Not yet implemented"); | 		fail("Not yet implemented"); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public void testDump() { | ||||||
|  | 		fail("Not yet implemented"); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	public void testElemSize() { | 	public void testElemSize() { | ||||||
| 		fail("Not yet implemented"); | 		fail("Not yet implemented"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testEmpty() { | 	public void testEmpty() { | ||||||
|  | 		assertTrue(dst.empty()); | ||||||
|  | 		assertTrue(!gray0.empty()); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void testEye() { | ||||||
| 		fail("Not yet implemented"); | 		fail("Not yet implemented"); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| @@ -65,6 +83,10 @@ public class MatTest extends OpenCVTestCase { | |||||||
| 		fail("Not yet implemented"); | 		fail("Not yet implemented"); | ||||||
| 	} | 	} | ||||||
| 	 | 	 | ||||||
|  | 	public void testGetIntInt() { | ||||||
|  | 		fail("Not yet implemented"); | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	public void testGetIntIntByteArray() { | 	public void testGetIntIntByteArray() { | ||||||
| 		fail("Not yet implemented"); | 		fail("Not yet implemented"); | ||||||
| 	} | 	} | ||||||
| @@ -86,47 +108,74 @@ public class MatTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testGetNativeObjAddr() { | 	public void testGetNativeObjAddr() { | ||||||
| 		fail("Not yet implemented"); | 		assertTrue(0 != gray0.getNativeObjAddr()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testHeight() { | 	public void testHeight() { | ||||||
| 		fail("Not yet implemented"); | 		assertEquals(gray0.rows(), gray0.height()); | ||||||
|  | 		assertEquals(rgbLena.rows(), rgbLena.height()); | ||||||
|  | 		assertEquals(rgba128.rows(), rgba128.height()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testInv() { | 	public void testInv() { | ||||||
| 		fail("Not yet implemented"); | 		fail("Not yet implemented"); | ||||||
|  | 		//dst = grayE_32f.inv(); | ||||||
|  | 		//assertMatEqual(grayE_32f, dst); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testIsContinuous() { | 	public void testIsContinuous() { | ||||||
| 		fail("Not yet implemented"); | 		assertTrue(gray0.isContinuous()); | ||||||
|  | 		 | ||||||
|  | 		Mat subMat = gray0.submat(0, 0, gray0.rows()/2, gray0.cols()/2); | ||||||
|  | 		assertFalse(subMat.isContinuous()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testIsSubmatrix() { | 	public void testIsSubmatrix() { | ||||||
| 		fail("Not yet implemented"); | 		assertFalse(gray0.isSubmatrix()); | ||||||
|  | 		Mat subMat = gray0.submat(0, 0, gray0.rows()/2, gray0.cols()/2); | ||||||
|  | 		assertTrue(subMat.isSubmatrix()); | ||||||
|  | 	} | ||||||
|  | 	 | ||||||
|  | 	public void testMat() { | ||||||
|  | 		Mat m = new Mat(); | ||||||
|  | 		assertTrue(null != m); | ||||||
|  | 		assertTrue(m.empty()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testMatIntIntCvType() { | 	public void testMatIntIntCvType() { | ||||||
| 		Mat gray = new Mat(1, 1, Mat.CvType.CV_8UC1); | 		Mat gray = new Mat(1, 1, CvType.CV_8UC1); | ||||||
| 		assertFalse(gray.empty()); | 		assertFalse(gray.empty()); | ||||||
| 		 | 		 | ||||||
| 		Mat rgb = new Mat(1, 1, Mat.CvType.CV_8UC3); | 		Mat rgb = new Mat(1, 1, CvType.CV_8UC3); | ||||||
| 		assertFalse(rgb.empty()); | 		assertFalse(rgb.empty()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testMatIntIntCvTypeDouble() { | 	public void testMatIntIntCvTypeScalar() { | ||||||
| 		fail("Not yet implemented"); | 		Mat gray = new Mat(1, 1, CvType.CV_8UC1, new Scalar(127)); | ||||||
|  | 		assertFalse(gray.empty()); | ||||||
|  | 		assertMatEqual(gray, gray127); | ||||||
|  | 		 | ||||||
|  | 		Mat rgb = new Mat(1, 1, CvType.CV_8UC4, new Scalar(128)); | ||||||
|  | 		assertFalse(rgb.empty()); | ||||||
|  | 		//FIXME: assertMatEqual(rgb, rgba128); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testMatIntIntCvTypeDoubleDouble() { | 	public void testMatIntIntInt() { | ||||||
| 		fail("Not yet implemented"); | 		Mat gray = new Mat(1, 1, CvType.CV_8U); | ||||||
|  | 		assertFalse(gray.empty()); | ||||||
|  | 		 | ||||||
|  | 		Mat rgb = new Mat(1, 1, CvType.CV_8U); | ||||||
|  | 		assertFalse(rgb.empty()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testMatIntIntCvTypeDoubleDoubleDouble() { | 	public void testMatIntIntIntScalar() { | ||||||
| 		fail("Not yet implemented"); | 		Mat m1 = new Mat(1, 1, CvType.CV_8U, new Scalar(127)); | ||||||
| 	} | 		assertFalse(m1.empty()); | ||||||
|  | 		assertMatEqual(m1, gray127); | ||||||
| 		 | 		 | ||||||
| 	public void testMatIntIntCvTypeDoubleDoubleDoubleDouble() { | 		Mat m2 = new Mat(1, 1, CvType.CV_32F, new Scalar(0)); | ||||||
| 		fail("Not yet implemented"); | 		assertFalse(m2.empty()); | ||||||
|  | 		assertMatEqual(m2, gray0_32f); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testMatLong() { | 	public void testMatLong() { | ||||||
| @@ -154,50 +203,52 @@ public class MatTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testRow() { | 	public void testRow() { | ||||||
| 		fail("Not yet implemented"); | 		Mat row = gray0.row(0); | ||||||
|  | 		assertEquals(1, row.rows()); | ||||||
|  | 		assertEquals(gray0.cols(), row.cols()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testRowRange() { | 	public void testRowRange() { | ||||||
| 		fail("Not yet implemented"); | 		Mat rows = gray0.rowRange(0, gray0.rows()/2); | ||||||
|  | 		assertEquals(gray0.rows()/2, rows.rows()); | ||||||
|  | 		assertEquals(gray0.cols(), rows.cols()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testRows() { | 	public void testRows() { | ||||||
| 		assertEquals(matSize, gray0.rows()); | 		assertEquals(matSize, gray0.rows()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testSetToDouble() { | 	public void testSetTo() { | ||||||
| 		fail("Not yet implemented"); | 		gray0.setTo(new Scalar(127)); | ||||||
| 	} | 		assertMatEqual(gray127, gray0); | ||||||
|  |  | ||||||
| 	public void testSetToDoubleDouble() { |  | ||||||
| 		fail("Not yet implemented"); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	public void testSetToDoubleDoubleDouble() { |  | ||||||
| 		fail("Not yet implemented"); |  | ||||||
| 	} |  | ||||||
|  |  | ||||||
| 	public void testSetToDoubleDoubleDoubleDouble() { |  | ||||||
| 		fail("Not yet implemented"); |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testSubmat() { | 	public void testSubmat() { | ||||||
| 		fail("Not yet implemented"); | 		Mat submat = gray0.submat(0, gray0.rows()/2, 0, gray0.cols()/2); | ||||||
|  | 		assertEquals(gray0.rows()/2, submat.rows()); | ||||||
|  | 		assertEquals(gray0.cols()/2, submat.cols()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testToString() { | 	public void testToString() { | ||||||
| 		fail("Not yet implemented"); | 		assertTrue(null != gray0.toString()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testTotal() { | 	public void testTotal() { | ||||||
| 		fail("Not yet implemented"); | 		int nElements = gray0.rows() * gray0.cols(); | ||||||
|  | 		assertEquals(nElements, gray0.total()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testType() { | 	public void testType() { | ||||||
| 		fail("Not yet implemented"); | 		assertEquals(CvType.CV_8UC1, gray0.type()); | ||||||
|  | 		//TODO: assertEquals(CvType.CV_8U, gray0.type()); | ||||||
|  | 		assertEquals(CvType.CV_32FC1, gray0_32f.type()); | ||||||
|  | 		assertEquals(CvType.CV_8UC3, rgbLena.type()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testWidth() { | 	public void testWidth() { | ||||||
| 		fail("Not yet implemented"); | 		assertEquals(gray0.cols(), gray0.width()); | ||||||
|  | 		assertEquals(rgbLena.cols(), rgbLena.width()); | ||||||
|  | 		assertEquals(rgba128.cols(), rgba128.width()); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -2,7 +2,9 @@ package org.opencv.test; | |||||||
|  |  | ||||||
| import junit.framework.TestCase; | import junit.framework.TestCase; | ||||||
|  |  | ||||||
|  | import org.opencv.CvType; | ||||||
| import org.opencv.Mat; | import org.opencv.Mat; | ||||||
|  | import org.opencv.Scalar; | ||||||
| import org.opencv.core; | import org.opencv.core; | ||||||
| import org.opencv.highgui; | import org.opencv.highgui; | ||||||
|  |  | ||||||
| @@ -37,11 +39,11 @@ public class OpenCVTestCase extends TestCase { | |||||||
|     static Mat gray0_64f;     |     static Mat gray0_64f;     | ||||||
|     static Mat gray0_64f_1d; |     static Mat gray0_64f_1d; | ||||||
|         |         | ||||||
|     static Mat rgbLena; |  | ||||||
|      |  | ||||||
|     static Mat rgba0; |     static Mat rgba0; | ||||||
|     static Mat rgba128; |     static Mat rgba128; | ||||||
|      |      | ||||||
|  |     static Mat rgbLena; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     protected void setUp() throws Exception { |     protected void setUp() throws Exception { | ||||||
|         super.setUp(); |         super.setUp(); | ||||||
| @@ -49,30 +51,30 @@ public class OpenCVTestCase extends TestCase { | |||||||
|         dst = new Mat(); |         dst = new Mat(); | ||||||
|         assertTrue(dst.empty()); |         assertTrue(dst.empty()); | ||||||
|  |  | ||||||
|         gray0 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray0.setTo(0.0); |         gray0 = new Mat(matSize, matSize, CvType.CV_8U); gray0.setTo(new Scalar(0.0)); | ||||||
|         gray1 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray1.setTo(1.0); |         gray1 = new Mat(matSize, matSize, CvType.CV_8U); gray1.setTo(new Scalar(1.0)); | ||||||
|         gray2 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray2.setTo(2.0); |         gray2 = new Mat(matSize, matSize, CvType.CV_8U); gray2.setTo(new Scalar(2.0)); | ||||||
|         gray3 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray3.setTo(3.0); |         gray3 = new Mat(matSize, matSize, CvType.CV_8U); gray3.setTo(new Scalar(3.0)); | ||||||
|         gray127 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray127.setTo(127.0); |         gray127 = new Mat(matSize, matSize, CvType.CV_8U); gray127.setTo(new Scalar(127.0)); | ||||||
|         gray128 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray128.setTo(128.0); |         gray128 = new Mat(matSize, matSize, CvType.CV_8U); gray128.setTo(new Scalar(128.0)); | ||||||
|         gray255 = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); gray255.setTo(255.0); |         gray255 = new Mat(matSize, matSize, CvType.CV_8U); gray255.setTo(new Scalar(255.0)); | ||||||
|          |          | ||||||
|         Mat low  = new Mat(1, 1, Mat.CvType.CV_16UC1, 0.0); |         Mat low  = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); | ||||||
|         Mat high = new Mat(1, 1, Mat.CvType.CV_16UC1, 256.0); |         Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256)); | ||||||
|         grayRnd = new Mat(matSize, matSize, Mat.CvType.CV_8UC1); core.randu(grayRnd, low, high); |         grayRnd = new Mat(matSize, matSize, CvType.CV_8U); core.randu(grayRnd, low, high); | ||||||
|          |          | ||||||
|         gray0_32f = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); gray0_32f.setTo(0.0); |         gray0_32f = new Mat(matSize, matSize, CvType.CV_32F); gray0_32f.setTo(new Scalar(0.0)); | ||||||
|         gray255_32f = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); gray255_32f.setTo(255.0); |         gray255_32f = new Mat(matSize, matSize, CvType.CV_32F); gray255_32f.setTo(new Scalar(255.0)); | ||||||
|         grayE_32f = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); grayE_32f = Mat.eye(matSize, matSize, Mat.CvType.CV_32FC1); |         grayE_32f = new Mat(matSize, matSize, CvType.CV_32F); grayE_32f = Mat.eye(matSize, matSize, CvType.CV_32FC1); | ||||||
|         grayRnd_32f = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); core.randu(grayRnd_32f, low, high);         |         grayRnd_32f = new Mat(matSize, matSize, CvType.CV_32F); core.randu(grayRnd_32f, low, high); | ||||||
|          |          | ||||||
|         gray0_32f_1d = new Mat(1, matSize, Mat.CvType.CV_32FC1); gray0_32f_1d.setTo(0.0); |         gray0_32f_1d = new Mat(1, matSize, CvType.CV_32F); gray0_32f_1d.setTo(new Scalar(0.0)); | ||||||
|          |          | ||||||
|         gray0_64f = new Mat(matSize, matSize, Mat.CvType.CV_64FC1); gray0_64f.setTo(0.0); |         gray0_64f = new Mat(matSize, matSize, CvType.CV_64F); gray0_64f.setTo(new Scalar(0.0)); | ||||||
|         gray0_64f_1d = new Mat(1, matSize, Mat.CvType.CV_64FC1); gray0_64f_1d.setTo(0.0); |         gray0_64f_1d = new Mat(1, matSize, CvType.CV_64F); gray0_64f_1d.setTo(new Scalar(0.0)); | ||||||
|  |  | ||||||
|         rgba0 = new Mat(matSize, matSize, Mat.CvType.CV_8UC4); rgba0.setTo(0, 0, 0, 0); |         rgba0 = new Mat(matSize, matSize, CvType.CV_8UC4); rgba0.setTo(Scalar.all(0)); | ||||||
|         rgba128 = new Mat(matSize, matSize, Mat.CvType.CV_8UC4); rgba128.setTo(128, 128, 128, 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); | ||||||
|     } |     } | ||||||
| @@ -82,7 +84,7 @@ public class OpenCVTestCase extends TestCase { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     static public double CalcPercentageOfDifference(Mat m1, Mat m2) { |     static public double CalcPercentageOfDifference(Mat m1, Mat m2) { | ||||||
|         Mat cmp = new Mat(0, 0, Mat.CvType.CV_8UC1); |         Mat cmp = new Mat(0, 0, CvType.CV_8U); | ||||||
|         core.compare(m1, m2, cmp, core.CMP_EQ); |         core.compare(m1, m2, cmp, core.CMP_EQ); | ||||||
|         double num = 100.0 *  |         double num = 100.0 *  | ||||||
|             (1.0 - Double.valueOf(core.countNonZero(cmp)) / Double.valueOf(cmp.rows() * cmp.cols())); |             (1.0 - Double.valueOf(core.countNonZero(cmp)) / Double.valueOf(cmp.rows() * cmp.cols())); | ||||||
| @@ -93,6 +95,5 @@ public class OpenCVTestCase extends TestCase { | |||||||
|     public void test_1(String label) { |     public void test_1(String label) { | ||||||
|     	OpenCVTestRunner.Log("================================================"); |     	OpenCVTestRunner.Log("================================================"); | ||||||
|     	OpenCVTestRunner.Log("=============== " + label); |     	OpenCVTestRunner.Log("=============== " + label); | ||||||
|     	OpenCVTestRunner.Log("================================================"); |  | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package org.opencv.test; | package org.opencv.test; | ||||||
|  |  | ||||||
|  | import org.opencv.CvType; | ||||||
| import org.opencv.Mat; | import org.opencv.Mat; | ||||||
| import org.opencv.Point; | import org.opencv.Point; | ||||||
| import org.opencv.Scalar; | import org.opencv.Scalar; | ||||||
| @@ -74,8 +75,8 @@ public class coreTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testCalcCovarMatrixMatMatMatInt() { | 	public void testCalcCovarMatrixMatMatMatInt() { | ||||||
| 		Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_64FC1); | 		Mat covar = new Mat(matSize, matSize, CvType.CV_64FC1); | ||||||
| 		Mat mean = new Mat(1, matSize, Mat.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 instead of magic numbers | ||||||
| 		assertMatEqual(gray0_64f, covar); | 		assertMatEqual(gray0_64f, covar); | ||||||
| @@ -83,10 +84,10 @@ public class coreTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testCalcCovarMatrixMatMatMatIntInt() { | 	public void testCalcCovarMatrixMatMatMatIntInt() { | ||||||
| 		Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); | 		Mat covar = new Mat(matSize, matSize, CvType.CV_32FC1); | ||||||
| 		Mat mean = new Mat(1, matSize, Mat.CvType.CV_32FC1); | 		Mat mean = new Mat(1, matSize, CvType.CV_32FC1); | ||||||
| 		 | 		 | ||||||
| 		core.calcCovarMatrix(gray0_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //TODO: CV_COVAR_NORMAL instead of magic numbers | 		core.calcCovarMatrix(gray0_32f, covar, mean, 8|1, CvType.CV_32F); //TODO: CV_COVAR_NORMAL instead of magic numbers | ||||||
| 		assertMatEqual(gray0_32f, covar); | 		assertMatEqual(gray0_32f, covar); | ||||||
| 		assertMatEqual(gray0_32f_1d, mean); | 		assertMatEqual(gray0_32f_1d, mean); | ||||||
| 	} | 	} | ||||||
| @@ -128,16 +129,14 @@ public class coreTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testCompare() { | 	public void testCompare() { | ||||||
|         Mat cmp = new Mat(0, 0, Mat.CvType.CV_8UC1); |         core.compare(gray0, gray0, dst, core.CMP_EQ); | ||||||
|  |         assertMatEqual(dst, gray255); | ||||||
| 		 | 		 | ||||||
|         core.compare(gray0, gray0, cmp, core.CMP_EQ); |         core.compare(gray0, gray1, dst, core.CMP_EQ); | ||||||
|         assertMatEqual(cmp, gray255); |         assertMatEqual(dst, gray0); | ||||||
|          |          | ||||||
|         core.compare(gray0, gray1, cmp, core.CMP_EQ); |         core.compare(gray0, grayRnd, dst, core.CMP_EQ); | ||||||
|         assertMatEqual(cmp, gray0); |         double nBlackPixels = core.countNonZero(dst); | ||||||
|          |  | ||||||
|         core.compare(gray0, grayRnd, cmp, core.CMP_EQ); |  | ||||||
|         double nBlackPixels = core.countNonZero(cmp); |  | ||||||
|         double nNonBlackpixels = core.countNonZero(grayRnd); |         double nNonBlackpixels = core.countNonZero(grayRnd); | ||||||
|         assertTrue((nBlackPixels + nNonBlackpixels) == grayRnd.total()); |         assertTrue((nBlackPixels + nNonBlackpixels) == grayRnd.total()); | ||||||
| 	} | 	} | ||||||
| @@ -181,9 +180,9 @@ public class coreTest extends OpenCVTestCase { | |||||||
| 		core.dct(gray0_32f_1d, dst); | 		core.dct(gray0_32f_1d, dst); | ||||||
| 		assertMatEqual(gray0_32f_1d, dst); | 		assertMatEqual(gray0_32f_1d, dst); | ||||||
| 		 | 		 | ||||||
| 		Mat in = new Mat(1, 4, Mat.CvType.CV_32FC1); | 		Mat in = new Mat(1, 4, CvType.CV_32FC1); | ||||||
| 		in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682); | 		in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682); | ||||||
| 		Mat out = new Mat(1, 4, Mat.CvType.CV_32FC1); | 		Mat out = new Mat(1, 4, CvType.CV_32FC1); | ||||||
| 		out.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477); | 		out.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477); | ||||||
| 		 | 		 | ||||||
| 		core.dct(in, dst); | 		core.dct(in, dst); | ||||||
| @@ -281,8 +280,8 @@ public class coreTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testHconcat() { | 	public void testHconcat() { | ||||||
| 		Mat e = new Mat(3, 3, Mat.CvType.CV_8UC1); | 		Mat e = Mat.eye(3, 3, CvType.CV_8UC1); | ||||||
| 		Mat eConcat = new Mat(1, 9, Mat.CvType.CV_8UC1); | 		Mat eConcat = new Mat(1, 9, CvType.CV_8UC1); | ||||||
| 		e.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1); | 		e.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1); | ||||||
| 		eConcat.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1); | 		eConcat.put(0, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1); | ||||||
| 		 | 		 | ||||||
| @@ -359,13 +358,13 @@ public class coreTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testLUTMatMatMat() { | 	public void testLUTMatMatMat() { | ||||||
| 	    Mat lut = new Mat(1, 256, Mat.CvType.CV_8UC1); | 	    Mat lut = new Mat(1, 256, CvType.CV_8UC1); | ||||||
| 	     | 	     | ||||||
| 	    lut.setTo(0); |     	lut.setTo(new Scalar(0)); | ||||||
| 	    core.LUT(grayRnd, lut, dst); | 	    core.LUT(grayRnd, lut, dst); | ||||||
| 	    assertMatEqual(gray0, dst); | 	    assertMatEqual(gray0, dst); | ||||||
| 	     | 	     | ||||||
| 	    lut.setTo(255); | 	    lut.setTo(new Scalar(255)); | ||||||
| 	    core.LUT(grayRnd, lut, dst); | 	    core.LUT(grayRnd, lut, dst); | ||||||
| 	    assertMatEqual(gray255, dst); | 	    assertMatEqual(gray255, dst); | ||||||
| 	} | 	} | ||||||
| @@ -379,9 +378,9 @@ public class coreTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testMahalanobis() {	 | 	public void testMahalanobis() {	 | ||||||
| 		Mat covar = new Mat(matSize, matSize, Mat.CvType.CV_32FC1); | 		Mat covar = new Mat(matSize, matSize, CvType.CV_32FC1); | ||||||
| 		Mat mean = new Mat(1, matSize, Mat.CvType.CV_32FC1);		 | 		Mat mean = new Mat(1, matSize, CvType.CV_32FC1);		 | ||||||
| 		core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1, Mat.CvType.CV_32F); //TODO: CV_COVAR_NORMAL instead of magic numbers | 		core.calcCovarMatrix(grayRnd_32f, covar, mean, 8|1, CvType.CV_32F); //TODO: CV_COVAR_NORMAL instead of magic numbers | ||||||
| 		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()); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Kirill Kornyakov
					Kirill Kornyakov