Added several Android tests
This commit is contained in:
		| @@ -8,7 +8,6 @@ import org.opencv.core.Scalar; | |||||||
| import org.opencv.core.Core; | import org.opencv.core.Core; | ||||||
| import org.opencv.highgui.Highgui; | import org.opencv.highgui.Highgui; | ||||||
|  |  | ||||||
|  |  | ||||||
| public class OpenCVTestCase extends TestCase { | public class OpenCVTestCase extends TestCase { | ||||||
|  |  | ||||||
|     protected static int matSize = 10; |     protected static int matSize = 10; | ||||||
| @@ -81,19 +80,24 @@ public class OpenCVTestCase extends TestCase { | |||||||
|         gray255 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); |         gray255 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(255)); | ||||||
|  |  | ||||||
|         gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U, new Scalar(256)); |         gray_16u_256 = new Mat(matSize, matSize, CvType.CV_16U, new Scalar(256)); | ||||||
|         gray_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S, new Scalar(1024)); |         gray_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S, new Scalar( | ||||||
|  |                 1024)); | ||||||
|  |  | ||||||
|         Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); |         Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); | ||||||
|         Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256)); |         Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256)); | ||||||
|         grayRnd = new Mat(matSize, matSize, CvType.CV_8U); Core.randu(grayRnd, low, high); |         grayRnd = new Mat(matSize, matSize, CvType.CV_8U); | ||||||
|  |         Core.randu(grayRnd, low, high); | ||||||
|  |  | ||||||
|         gray0_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(0.0)); |         gray0_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(0.0)); | ||||||
|         gray1_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(1.0)); |         gray1_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(1.0)); | ||||||
|         gray3_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(3.0)); |         gray3_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(3.0)); | ||||||
|         gray9_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(9.0)); |         gray9_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(9.0)); | ||||||
|         gray255_32f = new Mat(matSize, matSize, CvType.CV_32F, new Scalar(255.0)); |         gray255_32f = new Mat(matSize, matSize, CvType.CV_32F, | ||||||
|         grayE_32f = new Mat(matSize, matSize, CvType.CV_32F); grayE_32f = Mat.eye(matSize, matSize, CvType.CV_32FC1); |                 new Scalar(255.0)); | ||||||
|         grayRnd_32f = new Mat(matSize, matSize, CvType.CV_32F); Core.randu(grayRnd_32f, low, high); |         grayE_32f = new Mat(matSize, matSize, CvType.CV_32F); | ||||||
|  |         grayE_32f = Mat.eye(matSize, matSize, CvType.CV_32FC1); | ||||||
|  |         grayRnd_32f = new Mat(matSize, matSize, CvType.CV_32F); | ||||||
|  |         Core.randu(grayRnd_32f, low, high); | ||||||
|  |  | ||||||
|         gray0_32f_1d = new Mat(1, matSize, CvType.CV_32F, new Scalar(0.0)); |         gray0_32f_1d = new Mat(1, matSize, CvType.CV_32F, new Scalar(0.0)); | ||||||
|  |  | ||||||
| @@ -106,8 +110,10 @@ public class OpenCVTestCase extends TestCase { | |||||||
|         rgbLena = Highgui.imread(OpenCVTestRunner.LENA_PATH); |         rgbLena = Highgui.imread(OpenCVTestRunner.LENA_PATH); | ||||||
|         grayChess = Highgui.imread(OpenCVTestRunner.CHESS_PATH, 0); |         grayChess = Highgui.imread(OpenCVTestRunner.CHESS_PATH, 0); | ||||||
|  |  | ||||||
| 		v1 = new Mat(1, 3, CvType.CV_32F); v1.put(0, 0, 1.0, 3.0, 2.0); |         v1 = new Mat(1, 3, CvType.CV_32F); | ||||||
| 		v2 = new Mat(1, 3, CvType.CV_32F); v2.put(0, 0, 2.0, 1.0, 3.0); |         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) { | ||||||
| @@ -122,26 +128,22 @@ public class OpenCVTestCase extends TestCase { | |||||||
|         // OpenCVTestRunner.Log(m1.toString()); |         // OpenCVTestRunner.Log(m1.toString()); | ||||||
|         // OpenCVTestRunner.Log(m2.toString()); |         // OpenCVTestRunner.Log(m2.toString()); | ||||||
|  |  | ||||||
|     	if (m1.type() != m2.type() ||  |         if (m1.type() != m2.type() || m1.cols() != m2.cols() | ||||||
|     	    m1.cols() != m2.cols() || m1.rows() != m2.rows()) { |                 || m1.rows() != m2.rows()) { | ||||||
|             throw new UnsupportedOperationException(); |             throw new UnsupportedOperationException(); | ||||||
|     	} |         } else if (m1.channels() == 1) { | ||||||
|     	else if (m1.channels() == 1) { |  | ||||||
|             if (isEqualityMeasured) { |             if (isEqualityMeasured) { | ||||||
|                 assertTrue(CalcPercentageOfDifference(m1, m2) == 0.0); |                 assertTrue(CalcPercentageOfDifference(m1, m2) == 0.0); | ||||||
|     		} |             } else { | ||||||
|     		else { |  | ||||||
|                 assertTrue(CalcPercentageOfDifference(m1, m2) != 0.0); |                 assertTrue(CalcPercentageOfDifference(m1, m2) != 0.0); | ||||||
|             } |             } | ||||||
|     	} |         } else { | ||||||
|     	else { |  | ||||||
|             for (int coi = 0; coi < m1.channels(); coi++) { |             for (int coi = 0; coi < m1.channels(); coi++) { | ||||||
|                 Mat m1c = getCOI(m1, coi); |                 Mat m1c = getCOI(m1, coi); | ||||||
|                 Mat m2c = getCOI(m2, coi); |                 Mat m2c = getCOI(m2, coi); | ||||||
|                 if (isEqualityMeasured) { |                 if (isEqualityMeasured) { | ||||||
|                     assertTrue(CalcPercentageOfDifference(m1c, m2c) == 0.0); |                     assertTrue(CalcPercentageOfDifference(m1c, m2c) == 0.0); | ||||||
|         		} |                 } else { | ||||||
|         		else { |  | ||||||
|                     assertTrue(CalcPercentageOfDifference(m1c, m2c) != 0.0); |                     assertTrue(CalcPercentageOfDifference(m1c, m2c) != 0.0); | ||||||
|                 } |                 } | ||||||
|             } |             } | ||||||
| @@ -152,8 +154,7 @@ public class OpenCVTestCase extends TestCase { | |||||||
|         Mat ch = new Mat(m.rows(), m.cols(), m.depth()); |         Mat ch = new Mat(m.rows(), m.cols(), m.depth()); | ||||||
|  |  | ||||||
|         for (int i = 0; i < m.rows(); i++) |         for (int i = 0; i < m.rows(); i++) | ||||||
|     		for (int j = 0; j < m.cols(); j++) |             for (int j = 0; j < m.cols(); j++) { | ||||||
|     		{ |  | ||||||
|                 double pixel[] = m.get(i, j); |                 double pixel[] = m.get(i, j); | ||||||
|                 ch.put(i, j, pixel[coi]); |                 ch.put(i, j, pixel[coi]); | ||||||
|             } |             } | ||||||
| @@ -164,14 +165,15 @@ public class OpenCVTestCase extends TestCase { | |||||||
|     static private double CalcPercentageOfDifference(Mat m1, Mat m2) { |     static private double CalcPercentageOfDifference(Mat m1, Mat m2) { | ||||||
|         Mat cmp = new Mat(0, 0, CvType.CV_8U); |         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 difference = 100.0 *  |         double difference = 100.0 * (1.0 - Double.valueOf(Core | ||||||
|             (1.0 - Double.valueOf(Core.countNonZero(cmp)) / Double.valueOf(cmp.rows() * cmp.cols())); |                 .countNonZero(cmp)) / Double.valueOf(cmp.rows() * cmp.cols())); | ||||||
|  |  | ||||||
|         return difference; |         return difference; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void test_1(String label) { |     public void test_1(String label) { | ||||||
|     	OpenCVTestRunner.Log("================================================"); |         OpenCVTestRunner | ||||||
|  |                 .Log("================================================"); | ||||||
|         OpenCVTestRunner.Log("=============== " + label); |         OpenCVTestRunner.Log("=============== " + label); | ||||||
|     } |     } | ||||||
| } | } | ||||||
|   | |||||||
| @@ -28,16 +28,22 @@ public class calib3dTest extends OpenCVTestCase { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void testComposeRTMatMatMatMatMatMat() { |     public void testComposeRTMatMatMatMatMatMat() { | ||||||
| 		Mat rvec1 = new Mat(3, 1, CvType.CV_32F); rvec1.put(0, 0, 0.5302828,  0.19925919, 0.40105945); |         Mat rvec1 = new Mat(3, 1, CvType.CV_32F); | ||||||
| 		Mat tvec1 = new Mat(3, 1, CvType.CV_32F); tvec1.put(0, 0, 0.81438506, 0.43713298, 0.2487897); |         rvec1.put(0, 0, 0.5302828, 0.19925919, 0.40105945); | ||||||
| 		Mat rvec2 = new Mat(3, 1, CvType.CV_32F); rvec2.put(0, 0, 0.77310503, 0.76209372, 0.30779448); |         Mat tvec1 = new Mat(3, 1, CvType.CV_32F); | ||||||
| 		Mat tvec2 = new Mat(3, 1, CvType.CV_32F); tvec2.put(0, 0, 0.70243168, 0.4784472,  0.79219002); |         tvec1.put(0, 0, 0.81438506, 0.43713298, 0.2487897); | ||||||
|  |         Mat rvec2 = new Mat(3, 1, CvType.CV_32F); | ||||||
|  |         rvec2.put(0, 0, 0.77310503, 0.76209372, 0.30779448); | ||||||
|  |         Mat tvec2 = new Mat(3, 1, CvType.CV_32F); | ||||||
|  |         tvec2.put(0, 0, 0.70243168, 0.4784472, 0.79219002); | ||||||
|  |  | ||||||
|         Mat rvec3 = new Mat(); |         Mat rvec3 = new Mat(); | ||||||
|         Mat tvec3 = new Mat(); |         Mat tvec3 = new Mat(); | ||||||
|  |  | ||||||
| 		Mat outRvec = new Mat(3, 1, CvType.CV_32F); outRvec.put(0, 0, 1.418641, 0.88665926, 0.56020796); |         Mat outRvec = new Mat(3, 1, CvType.CV_32F); | ||||||
| 		Mat outTvec = new Mat(3, 1, CvType.CV_32F); outTvec.put(0, 0, 1.4560841, 1.0680628, 0.81598103); |         outRvec.put(0, 0, 1.418641, 0.88665926, 0.56020796); | ||||||
|  |         Mat outTvec = new Mat(3, 1, CvType.CV_32F); | ||||||
|  |         outTvec.put(0, 0, 1.4560841, 1.0680628, 0.81598103); | ||||||
|  |  | ||||||
|         Calib3d.composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3); |         Calib3d.composeRT(rvec1, tvec1, rvec2, tvec2, rvec3, tvec3); | ||||||
|  |  | ||||||
| @@ -156,7 +162,8 @@ public class calib3dTest extends OpenCVTestCase { | |||||||
|  |  | ||||||
|     public void testFilterSpecklesMatDoubleIntDouble() { |     public void testFilterSpecklesMatDoubleIntDouble() { | ||||||
|         gray_16s_1024.copyTo(dst); |         gray_16s_1024.copyTo(dst); | ||||||
| 		Point center = new Point(gray_16s_1024.rows()/2., gray_16s_1024.cols()/2.);		 |         Point center = new Point(gray_16s_1024.rows() / 2., | ||||||
|  |                 gray_16s_1024.cols() / 2.); | ||||||
|         Core.circle(dst, center, 1, Scalar.all(4096)); |         Core.circle(dst, center, 1, Scalar.all(4096)); | ||||||
|  |  | ||||||
|         assertMatNotEqual(gray_16s_1024, dst); |         assertMatNotEqual(gray_16s_1024, dst); | ||||||
| @@ -177,16 +184,64 @@ public class calib3dTest extends OpenCVTestCase { | |||||||
|     public void testFindChessboardCornersMatSizeMatInt() { |     public void testFindChessboardCornersMatSizeMatInt() { | ||||||
|         Size patternSize = new Size(9, 6); |         Size patternSize = new Size(9, 6); | ||||||
|         Calib3d.findChessboardCorners(grayChess, patternSize, dst, |         Calib3d.findChessboardCorners(grayChess, patternSize, dst, | ||||||
| 			Calib3d.CALIB_CB_ADAPTIVE_THRESH + Calib3d.CALIB_CB_NORMALIZE_IMAGE + Calib3d.CALIB_CB_FAST_CHECK); |                 Calib3d.CALIB_CB_ADAPTIVE_THRESH | ||||||
|  |                         + Calib3d.CALIB_CB_NORMALIZE_IMAGE | ||||||
|  |                         + Calib3d.CALIB_CB_FAST_CHECK); | ||||||
|         assertTrue(!dst.empty()); |         assertTrue(!dst.empty()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void testFindCirclesGridDefaultMatSizeMat() { |     public void testFindCirclesGridDefaultMatSizeMat() { | ||||||
| 		fail("Not yet implemented"); |         int size = 300; | ||||||
|  |         Mat img = new Mat(size, size, CvType.CV_8U); | ||||||
|  |         img.setTo(new Scalar(255)); | ||||||
|  |         Mat centers = new Mat(); | ||||||
|  |  | ||||||
|  |         assertFalse(Calib3d | ||||||
|  |                 .findCirclesGridDefault(img, new Size(5, 5), centers)); | ||||||
|  |  | ||||||
|  |         for (int i = 0; i < 5; i++) | ||||||
|  |             for (int j = 0; j < 5; j++) { | ||||||
|  |                 Point pt = new Point(size * (2 * i + 1) / 10, size | ||||||
|  |                         * (2 * j + 1) / 10); | ||||||
|  |                 Core.circle(img, pt, 10, new Scalar(0), -1); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |         org.opencv.highgui.Highgui.imwrite("/mnt/sdcard/test3.png", img); | ||||||
|  |  | ||||||
|  |         assertTrue(Calib3d.findCirclesGridDefault(img, new Size(5, 5), centers)); | ||||||
|  |          | ||||||
|  |         assertEquals(25, centers.rows()); | ||||||
|  |         assertEquals(1, centers.cols()); | ||||||
|  |         assertEquals(CvType.CV_32FC2, centers.type()); | ||||||
|  |  | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void testFindCirclesGridDefaultMatSizeMatInt() { |     public void testFindCirclesGridDefaultMatSizeMatInt() { | ||||||
| 		fail("Not yet implemented"); |         int size = 300; | ||||||
|  |         Mat img = new Mat(size, size, CvType.CV_8U); | ||||||
|  |         img.setTo(new Scalar(255)); | ||||||
|  |         Mat centers = new Mat(); | ||||||
|  |  | ||||||
|  |         assertFalse(Calib3d.findCirclesGridDefault(img, new Size(3, 5), | ||||||
|  |                 centers, Calib3d.CALIB_CB_CLUSTERING | ||||||
|  |                         | Calib3d.CALIB_CB_ASYMMETRIC_GRID)); | ||||||
|  |  | ||||||
|  |         int step = size * 2 / 15; | ||||||
|  |         int offsetx = size / 6; | ||||||
|  |         int offsety = (size - 4 * step) / 2; | ||||||
|  |         for (int i = 0; i < 3; i++) | ||||||
|  |             for (int j = 0; j < 5; j++) { | ||||||
|  |                 Point pt = new Point(offsetx + (2 * i + j % 2) * step, offsety | ||||||
|  |                         + step * j); | ||||||
|  |                 Core.circle(img, pt, 10, new Scalar(0), -1); | ||||||
|  |             } | ||||||
|  |  | ||||||
|  |         assertTrue(Calib3d.findCirclesGridDefault(img, new Size(3, 5), centers, | ||||||
|  |                 Calib3d.CALIB_CB_CLUSTERING | Calib3d.CALIB_CB_ASYMMETRIC_GRID)); | ||||||
|  |          | ||||||
|  |         assertEquals(15, centers.rows()); | ||||||
|  |         assertEquals(1, centers.cols()); | ||||||
|  |         assertEquals(CvType.CV_32FC2, centers.type()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void testFindFundamentalMatMatMat() { |     public void testFindFundamentalMatMatMat() { | ||||||
|   | |||||||
| @@ -1,5 +1,7 @@ | |||||||
| package org.opencv.test.core; | package org.opencv.test.core; | ||||||
|  |  | ||||||
|  | import org.opencv.core.Point; | ||||||
|  | import org.opencv.core.Rect; | ||||||
| import org.opencv.test.OpenCVTestCase; | import org.opencv.test.OpenCVTestCase; | ||||||
|  |  | ||||||
| public class RectTest extends OpenCVTestCase { | public class RectTest extends OpenCVTestCase { | ||||||
| @@ -21,7 +23,21 @@ public class RectTest extends OpenCVTestCase { | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testContains() { | 	public void testContains() { | ||||||
| 		fail("Not yet implemented"); | 		Rect r = new Rect(0,0,10,10); | ||||||
|  | 		Point p_inner = new Point(5,5); | ||||||
|  | 		Point p_outer = new Point(5,55); | ||||||
|  | 		Point p_bl = new Point(0,0); | ||||||
|  | 		Point p_br = new Point(10,0); | ||||||
|  | 		Point p_tl = new Point(0,10); | ||||||
|  | 		Point p_tr = new Point(10,10); | ||||||
|  | 		 | ||||||
|  | 		assertTrue(r.contains(p_inner)); | ||||||
|  | 		assertTrue(r.contains(p_bl)); | ||||||
|  | 		 | ||||||
|  | 		assertFalse(r.contains(p_outer)); | ||||||
|  | 		assertFalse(r.contains(p_br)); | ||||||
|  | 		assertFalse(r.contains(p_tl)); | ||||||
|  | 		assertFalse(r.contains(p_tr)); | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	public void testEqualsObject() { | 	public void testEqualsObject() { | ||||||
|   | |||||||
| @@ -2,6 +2,9 @@ package org.opencv.test.core; | |||||||
|  |  | ||||||
| import java.util.ArrayList; | import java.util.ArrayList; | ||||||
|  |  | ||||||
|  | import org.hamcrest.core.IsInstanceOf; | ||||||
|  | import org.junit.internal.runners.statements.ExpectException; | ||||||
|  | import org.opencv.core.CvException; | ||||||
| import org.opencv.core.CvType; | import org.opencv.core.CvType; | ||||||
| import org.opencv.core.Mat; | import org.opencv.core.Mat; | ||||||
| import org.opencv.core.Point; | import org.opencv.core.Point; | ||||||
| @@ -96,7 +99,10 @@ 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*/);  |         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); | ||||||
|     } |     } | ||||||
| @@ -105,7 +111,10 @@ 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/*TODO: CV_COVAR_NORMAL*/, CvType.CV_32F); |         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); | ||||||
|     } |     } | ||||||
| @@ -146,11 +155,29 @@ public class coreTest extends OpenCVTestCase { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void testCheckRangeMat() { |     public void testCheckRangeMat() { | ||||||
| 		fail("Not yet implemented"); |         Mat outOfRange = new Mat(2, 2, CvType.CV_64F); | ||||||
|  |         outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY, | ||||||
|  |                 Double.POSITIVE_INFINITY, 0); | ||||||
|  |          | ||||||
|  |         assertTrue(Core.checkRange(grayRnd_32f)); | ||||||
|  |         assertTrue(Core.checkRange(new Mat())); | ||||||
|  |         assertFalse(Core.checkRange(outOfRange)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void testCheckRangeMatBoolean() { |     public void testCheckRangeMatBoolean() { | ||||||
| 		fail("Not yet implemented"); |         Mat outOfRange = new Mat(2, 2, CvType.CV_64F); | ||||||
|  |         outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY, | ||||||
|  |                 Double.POSITIVE_INFINITY, 0); | ||||||
|  |  | ||||||
|  |         assertFalse(Core.checkRange(outOfRange, true)); | ||||||
|  |          | ||||||
|  |         try { | ||||||
|  |             Core.checkRange(outOfRange, false); | ||||||
|  |             fail("Core.checkRange should throw the CvException"); | ||||||
|  |         } catch (Exception e) { | ||||||
|  |             if (!(e instanceof CvException)) | ||||||
|  |                 fail("Core.checkRange should throw the CvException"); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     public void testCheckRangeMatBooleanPoint() { |     public void testCheckRangeMatBooleanPoint() { | ||||||
| @@ -203,7 +230,11 @@ public class coreTest extends OpenCVTestCase { | |||||||
|         Scalar color0 = new Scalar(0); |         Scalar color0 = new Scalar(0); | ||||||
|  |  | ||||||
|         assertTrue(0 == Core.countNonZero(gray0)); |         assertTrue(0 == Core.countNonZero(gray0)); | ||||||
| 		Core.circle(gray0, center2, radius*2, color128, 2, 4, 1/*Number of fractional bits*/); |         Core.circle(gray0, center2, radius * 2, color128, 2, 4, 1/* | ||||||
|  |                                                                   * Number of | ||||||
|  |                                                                   * fractional | ||||||
|  |                                                                   * bits | ||||||
|  |                                                                   */); | ||||||
|         Core.circle(gray0, center, radius, color0, 2, 4, 0); |         Core.circle(gray0, center, radius, color0, 2, 4, 0); | ||||||
|         assertTrue(0 == Core.countNonZero(gray0)); |         assertTrue(0 == Core.countNonZero(gray0)); | ||||||
|     } |     } | ||||||
| @@ -233,7 +264,6 @@ public class coreTest extends OpenCVTestCase { | |||||||
|         assertEquals(pt2Clipped, pt2); |         assertEquals(pt2Clipped, pt2); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| 	 |  | ||||||
|     public void testCompare() { |     public void testCompare() { | ||||||
|         Core.compare(gray0, gray0, dst, Core.CMP_EQ); |         Core.compare(gray0, gray0, dst, Core.CMP_EQ); | ||||||
|         assertMatEqual(dst, gray255); |         assertMatEqual(dst, gray255); | ||||||
| @@ -311,10 +341,12 @@ public class coreTest extends OpenCVTestCase { | |||||||
|         assertMatEqual(gray0_32f_1d, dst); |         assertMatEqual(gray0_32f_1d, dst); | ||||||
|  |  | ||||||
|         Mat in = new Mat(1, 8, CvType.CV_32F); |         Mat in = new Mat(1, 8, CvType.CV_32F); | ||||||
| 		in.put(0, 0, 0.203056, 0.980407, 0.35312, -0.106651, 0.0399382, 0.871475, -0.648355, 0.501067); |         in.put(0, 0, 0.203056, 0.980407, 0.35312, -0.106651, 0.0399382, | ||||||
|  |                 0.871475, -0.648355, 0.501067); | ||||||
|  |  | ||||||
|         truth = new Mat(1, 8, CvType.CV_32F); |         truth = new Mat(1, 8, CvType.CV_32F); | ||||||
| 		truth.put(0, 0, 0.77571625, 0.37270021, 0.18529896, 0.012146413, -0.32499927, -0.99302113, 0.55979407, -0.6251272); |         truth.put(0, 0, 0.77571625, 0.37270021, 0.18529896, 0.012146413, | ||||||
|  |                 -0.32499927, -0.99302113, 0.55979407, -0.6251272); | ||||||
|  |  | ||||||
|         Core.dct(in, dst); |         Core.dct(in, dst); | ||||||
|         assertMatEqual(truth, dst); |         assertMatEqual(truth, dst); | ||||||
| @@ -427,7 +459,8 @@ 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); | ||||||
|         assertMatEqual(gray1_32f, destination); |         assertMatEqual(gray1_32f, destination); | ||||||
|     } |     } | ||||||
| @@ -584,7 +617,8 @@ public class coreTest extends OpenCVTestCase { | |||||||
|         in.put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0); |         in.put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0); | ||||||
|  |  | ||||||
|         truth = new Mat(1, 8, CvType.CV_32F); |         truth = new Mat(1, 8, CvType.CV_32F); | ||||||
| 		truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115); |         truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, | ||||||
|  |                 -0.86502546, 0.028082132, -0.7673766, 0.10917115); | ||||||
|  |  | ||||||
|         Core.idct(in, dst); |         Core.idct(in, dst); | ||||||
|         assertMatEqual(truth, dst); |         assertMatEqual(truth, dst); | ||||||
| @@ -595,7 +629,8 @@ public class coreTest extends OpenCVTestCase { | |||||||
|         in.put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0); |         in.put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0); | ||||||
|  |  | ||||||
|         truth = new Mat(1, 8, CvType.CV_32F); |         truth = new Mat(1, 8, CvType.CV_32F); | ||||||
| 		truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115); |         truth.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, | ||||||
|  |                 -0.86502546, 0.028082132, -0.7673766, 0.10917115); | ||||||
|  |  | ||||||
|         Core.idct(in, dst, Core.DCT_ROWS); |         Core.idct(in, dst, Core.DCT_ROWS); | ||||||
|         assertMatEqual(truth, dst); |         assertMatEqual(truth, dst); | ||||||
| @@ -769,7 +804,10 @@ 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/*TODO: CV_COVAR_NORMAL*/, CvType.CV_32F); |         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()); | ||||||
| @@ -825,7 +863,8 @@ public class coreTest extends OpenCVTestCase { | |||||||
|         assertEquals(0, Core.countNonZero(mean)); |         assertEquals(0, Core.countNonZero(mean)); | ||||||
|         assertEquals(0, Core.countNonZero(stddev)); |         assertEquals(0, Core.countNonZero(stddev)); | ||||||
|  |  | ||||||
| 		Mat submat = grayRnd.submat(0, grayRnd.rows()/2, 0, grayRnd.cols()/2); |         Mat submat = grayRnd.submat(0, grayRnd.rows() / 2, 0, | ||||||
|  |                 grayRnd.cols() / 2); | ||||||
|         submat.setTo(new Scalar(33)); |         submat.setTo(new Scalar(33)); | ||||||
|  |  | ||||||
|         Mat mask = gray0.clone(); |         Mat mask = gray0.clone(); | ||||||
| @@ -867,7 +906,6 @@ public class coreTest extends OpenCVTestCase { | |||||||
|         assertTrue(mmres.maxLoc.equals(maxLoc)); |         assertTrue(mmres.maxLoc.equals(maxLoc)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|     public void testMinMaxLocMat() { |     public void testMinMaxLocMat() { | ||||||
|         fail("Not yet implemented"); |         fail("Not yet implemented"); | ||||||
|     } |     } | ||||||
| @@ -1430,8 +1468,10 @@ public class coreTest extends OpenCVTestCase { | |||||||
|  |  | ||||||
|     public void testTranspose() { |     public void testTranspose() { | ||||||
|         Mat subgray0 = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols()); |         Mat subgray0 = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols()); | ||||||
| 		Mat destination = new Mat(matSize, matSize, CvType.CV_8U); destination.setTo(new Scalar(0)); |         Mat destination = new Mat(matSize, matSize, CvType.CV_8U); | ||||||
| 		Mat subdst = destination.submat(0, destination.rows(), 0, destination.cols() / 2); |         destination.setTo(new Scalar(0)); | ||||||
|  |         Mat subdst = destination.submat(0, destination.rows(), 0, | ||||||
|  |                 destination.cols() / 2); | ||||||
|         subgray0.setTo(new Scalar(1)); |         subgray0.setTo(new Scalar(1)); | ||||||
|         Core.transpose(gray0, destination); |         Core.transpose(gray0, destination); | ||||||
|         assertTrue(subdst.total() == Core.countNonZero(subdst)); |         assertTrue(subdst.total() == Core.countNonZero(subdst)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andrey Kamaev
					Andrey Kamaev