From 039fd554f2c487397d818eb5345f93a34ba6483b Mon Sep 17 00:00:00 2001 From: Andrey Kamaev Date: Wed, 27 Jul 2011 12:55:43 +0000 Subject: [PATCH] Added several Android tests --- .../src/org/opencv/test/OpenCVTestCase.java | 230 +- .../src/org/opencv/test/calib3d/calib3dTest.java | 729 ++--- .../src/org/opencv/test/core/RectTest.java | 18 +- .../src/org/opencv/test/core/coreTest.java | 2842 ++++++++++---------- 4 files changed, 1966 insertions(+), 1853 deletions(-) diff --git a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java index 9525a44..383e703 100644 --- a/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java +++ b/modules/java/android_test/src/org/opencv/test/OpenCVTestCase.java @@ -8,64 +8,63 @@ import org.opencv.core.Scalar; import org.opencv.core.Core; import org.opencv.highgui.Highgui; - public class OpenCVTestCase extends TestCase { - - protected static int matSize = 10; - protected static double EPS = 0.001; - - protected static Mat dst; - protected static Mat truth; - - //Naming notation: _[depth]_[dimensions]_value - //examples: gray0 - single channel 8U 2d Mat filled with 0 - // grayRnd - single channel 8U 2d Mat filled with random numbers - // gray0_32f_1d - - //TODO: OpenCVTestCase refactorings - // - rename matrices - // - create some masks - // - use truth member everywhere - - protected static Mat gray0; - protected static Mat gray1; - protected static Mat gray2; - protected static Mat gray3; - protected static Mat gray9; - protected static Mat gray127; - protected static Mat gray128; - protected static Mat gray255; - protected static Mat grayRnd; - - protected static Mat gray_16u_256; - protected static Mat gray_16s_1024; - - protected static Mat gray0_32f; - protected static Mat gray1_32f; - protected static Mat gray3_32f; - protected static Mat gray9_32f; - protected static Mat gray255_32f; - protected static Mat grayE_32f; - protected static Mat grayRnd_32f; - - protected static Mat gray0_32f_1d; - - protected static Mat gray0_64f; - protected static Mat gray0_64f_1d; - - protected static Mat rgba0; - protected static Mat rgba128; - - protected static Mat rgbLena; - protected static Mat grayChess; - - protected static Mat v1; - protected static Mat v2; + + protected static int matSize = 10; + protected static double EPS = 0.001; + + protected static Mat dst; + protected static Mat truth; + + // Naming notation: _[depth]_[dimensions]_value + // examples: gray0 - single channel 8U 2d Mat filled with 0 + // grayRnd - single channel 8U 2d Mat filled with random numbers + // gray0_32f_1d + + // TODO: OpenCVTestCase refactorings + // - rename matrices + // - create some masks + // - use truth member everywhere + + protected static Mat gray0; + protected static Mat gray1; + protected static Mat gray2; + protected static Mat gray3; + protected static Mat gray9; + protected static Mat gray127; + protected static Mat gray128; + protected static Mat gray255; + protected static Mat grayRnd; + + protected static Mat gray_16u_256; + protected static Mat gray_16s_1024; + + protected static Mat gray0_32f; + protected static Mat gray1_32f; + protected static Mat gray3_32f; + protected static Mat gray9_32f; + protected static Mat gray255_32f; + protected static Mat grayE_32f; + protected static Mat grayRnd_32f; + + protected static Mat gray0_32f_1d; + + protected static Mat gray0_64f; + protected static Mat gray0_64f_1d; + + protected static Mat rgba0; + protected static Mat rgba128; + + protected static Mat rgbLena; + protected static Mat grayChess; + + protected static Mat v1; + protected static Mat v2; @Override protected void setUp() throws Exception { super.setUp(); - + dst = new Mat(); assertTrue(dst.empty()); truth = new Mat(); @@ -79,99 +78,102 @@ public class OpenCVTestCase extends TestCase { gray127 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(127)); gray128 = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(128)); 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_16s_1024 = new Mat(matSize, matSize, CvType.CV_16S, new Scalar(1024)); - - Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); + 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 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)); 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)); 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)); - 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); - + gray255_32f = new Mat(matSize, matSize, CvType.CV_32F, + new Scalar(255.0)); + 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_64f = new Mat(matSize, matSize, CvType.CV_64F, new Scalar(0.0)); gray0_64f_1d = new Mat(1, matSize, CvType.CV_64F, new Scalar(0.0)); rgba0 = new Mat(matSize, matSize, CvType.CV_8UC4, Scalar.all(0)); rgba128 = new Mat(matSize, matSize, CvType.CV_8UC4, Scalar.all(128)); - + rgbLena = Highgui.imread(OpenCVTestRunner.LENA_PATH); 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); - v2 = new Mat(1, 3, CvType.CV_32F); v2.put(0, 0, 2.0, 1.0, 3.0); + + 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) { - compareMats(m1, m2, true); + compareMats(m1, m2, true); } - + public static void assertMatNotEqual(Mat m1, Mat m2) { - compareMats(m1, m2, false); + compareMats(m1, m2, false); } - + static private void compareMats(Mat m1, Mat m2, boolean isEqualityMeasured) { - //OpenCVTestRunner.Log(m1.toString()); - //OpenCVTestRunner.Log(m2.toString()); - - if (m1.type() != m2.type() || - m1.cols() != m2.cols() || m1.rows() != m2.rows()) { - throw new UnsupportedOperationException(); - } - else if (m1.channels() == 1) { - if (isEqualityMeasured) { - assertTrue(CalcPercentageOfDifference(m1, m2) == 0.0); - } - else { - assertTrue(CalcPercentageOfDifference(m1, m2) != 0.0); - } - } - else { - for (int coi = 0; coi < m1.channels(); coi++) { - Mat m1c = getCOI(m1, coi); - Mat m2c = getCOI(m2, coi); - if (isEqualityMeasured) { - assertTrue(CalcPercentageOfDifference(m1c, m2c) == 0.0); - } - else { - assertTrue(CalcPercentageOfDifference(m1c, m2c) != 0.0); - } - } - } + // OpenCVTestRunner.Log(m1.toString()); + // OpenCVTestRunner.Log(m2.toString()); + + if (m1.type() != m2.type() || m1.cols() != m2.cols() + || m1.rows() != m2.rows()) { + throw new UnsupportedOperationException(); + } else if (m1.channels() == 1) { + if (isEqualityMeasured) { + assertTrue(CalcPercentageOfDifference(m1, m2) == 0.0); + } else { + assertTrue(CalcPercentageOfDifference(m1, m2) != 0.0); + } + } else { + for (int coi = 0; coi < m1.channels(); coi++) { + Mat m1c = getCOI(m1, coi); + Mat m2c = getCOI(m2, coi); + if (isEqualityMeasured) { + assertTrue(CalcPercentageOfDifference(m1c, m2c) == 0.0); + } else { + assertTrue(CalcPercentageOfDifference(m1c, m2c) != 0.0); + } + } + } } - + static private Mat getCOI(Mat m, int coi) { - Mat ch = new Mat(m.rows(), m.cols(), m.depth()); - - for (int i = 0; i < m.rows(); i++) - for (int j = 0; j < m.cols(); j++) - { - double pixel[] = m.get(i, j); - ch.put(i, j, pixel[coi]); - } - - return ch; + Mat ch = new Mat(m.rows(), m.cols(), m.depth()); + + for (int i = 0; i < m.rows(); i++) + for (int j = 0; j < m.cols(); j++) { + double pixel[] = m.get(i, j); + ch.put(i, j, pixel[coi]); + } + + return ch; } static private double CalcPercentageOfDifference(Mat m1, Mat m2) { Mat cmp = new Mat(0, 0, CvType.CV_8U); Core.compare(m1, m2, cmp, Core.CMP_EQ); - double difference = 100.0 * - (1.0 - Double.valueOf(Core.countNonZero(cmp)) / Double.valueOf(cmp.rows() * cmp.cols())); + double difference = 100.0 * (1.0 - Double.valueOf(Core + .countNonZero(cmp)) / Double.valueOf(cmp.rows() * cmp.cols())); return difference; } public void test_1(String label) { - OpenCVTestRunner.Log("================================================"); - OpenCVTestRunner.Log("=============== " + label); + OpenCVTestRunner + .Log("================================================"); + OpenCVTestRunner.Log("=============== " + label); } } diff --git a/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java b/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java index f022177..e6c9cf6 100644 --- a/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java +++ b/modules/java/android_test/src/org/opencv/test/calib3d/calib3dTest.java @@ -10,363 +10,418 @@ import org.opencv.core.Core; import org.opencv.test.OpenCVTestCase; public class calib3dTest extends OpenCVTestCase { - - public void test_1() { - super.test_1("calib3d"); - } - - public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMat() { - fail("Not yet implemented"); - } - - public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMatInt() { - fail("Not yet implemented"); - } - - public void testCalibrationMatrixValues() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMat() { - Mat rvec1 = new Mat(3, 1, CvType.CV_32F); rvec1.put(0, 0, 0.5302828, 0.19925919, 0.40105945); - Mat tvec1 = new Mat(3, 1, CvType.CV_32F); 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 tvec3 = new Mat(); - - Mat outRvec = new Mat(3, 1, CvType.CV_32F); 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); - - assertMatEqual(outRvec, rvec3); - assertMatEqual(outTvec, tvec3); - } - - public void testComposeRTMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); -// Mat dr3dr1; -// Mat dr3dt1; -// Mat dr3dr2; -// Mat dr3dt2; -// Mat dt3dr1; -// Mat dt3dt1; -// Mat dt3dr2; -// Mat dt3dt2; - //, dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2); -// [0.97031879, -0.091774099, 0.38594806; -// 0.15181915, 0.98091727, -0.44186208; -// -0.39509675, 0.43839464, 0.93872648] -// [0, 0, 0; -// 0, 0, 0; -// 0, 0, 0] -// [1.0117353, 0.16348237, -0.083180845; -// -0.1980398, 1.006078, 0.30299222; -// 0.075766489, -0.32784501, 1.0163091] -// [0, 0, 0; -// 0, 0, 0; -// 0, 0, 0] -// [0, 0, 0; -// 0, 0, 0; -// 0, 0, 0] -// [0.69658804, 0.018115902, 0.7172426; -// 0.51114357, 0.68899536, -0.51382649; -// -0.50348526, 0.72453934, 0.47068608] -// [0.18536358, -0.20515044, -0.48834875; -// -0.25120571, 0.29043972, 0.60573936; -// 0.35370794, -0.69923931, 0.45781645] -// [1, 0, 0; -// 0, 1, 0; -// 0, 0, 1] - } - - public void testConvertPointsFromHomogeneous() { - fail("Not yet implemented"); - } - - public void testConvertPointsToHomogeneous() { - fail("Not yet implemented"); - } - - public void testDecomposeProjectionMatrixMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testDecomposeProjectionMatrixMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testDecomposeProjectionMatrixMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testDecomposeProjectionMatrixMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testDecomposeProjectionMatrixMatMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testDrawChessboardCorners() { - fail("Not yet implemented"); - } - - public void testEstimateAffine3DMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testEstimateAffine3DMatMatMatMatDouble() { - fail("Not yet implemented"); - } - - public void testEstimateAffine3DMatMatMatMatDoubleDouble() { - fail("Not yet implemented"); - } - - public void testFilterSpecklesMatDoubleIntDouble() { - gray_16s_1024.copyTo(dst); - Point center = new Point(gray_16s_1024.rows()/2., gray_16s_1024.cols()/2.); - Core.circle(dst, center, 1, Scalar.all(4096)); - - assertMatNotEqual(gray_16s_1024, dst); - Calib3d.filterSpeckles(dst, 1024.0, 100, 0.); - assertMatEqual(gray_16s_1024, dst); - } - - public void testFilterSpecklesMatDoubleIntDoubleMat() { - fail("Not yet implemented"); - } - - public void testFindChessboardCornersMatSizeMat() { - Size patternSize = new Size(9, 6); - Calib3d.findChessboardCorners(grayChess, patternSize, dst); - assertTrue(!dst.empty()); - } - - public void testFindChessboardCornersMatSizeMatInt() { - Size patternSize = new Size(9, 6); - Calib3d.findChessboardCorners(grayChess, patternSize, dst, - Calib3d.CALIB_CB_ADAPTIVE_THRESH + Calib3d.CALIB_CB_NORMALIZE_IMAGE + Calib3d.CALIB_CB_FAST_CHECK); - assertTrue(!dst.empty()); - } - - public void testFindCirclesGridDefaultMatSizeMat() { - fail("Not yet implemented"); - } - - public void testFindCirclesGridDefaultMatSizeMatInt() { - fail("Not yet implemented"); - } - - public void testFindFundamentalMatMatMat() { - fail("Not yet implemented"); - } - - public void testFindFundamentalMatMatMatInt() { - fail("Not yet implemented"); - } - - public void testFindFundamentalMatMatMatIntDouble() { - fail("Not yet implemented"); - } - - public void testFindFundamentalMatMatMatIntDoubleDouble() { - fail("Not yet implemented"); - } - - public void testFindFundamentalMatMatMatIntDoubleDoubleMat() { - fail("Not yet implemented"); - } - - public void testFindHomographyMatMat() { - fail("Not yet implemented"); - } - - public void testFindHomographyMatMatInt() { - fail("Not yet implemented"); - } - - public void testFindHomographyMatMatIntDouble() { - fail("Not yet implemented"); - } - - public void testFindHomographyMatMatIntDoubleMat() { - fail("Not yet implemented"); - } - - public void testGetOptimalNewCameraMatrixMatMatSizeDouble() { - fail("Not yet implemented"); - } - - public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSize() { - fail("Not yet implemented"); - } - - public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRect() { - fail("Not yet implemented"); - } - - public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRectBoolean() { - fail("Not yet implemented"); - } - - public void testGetValidDisparityROI() { - fail("Not yet implemented"); - } - - public void testInitCameraMatrix2DListOfMatListOfMatSize() { - fail("Not yet implemented"); - } - - public void testInitCameraMatrix2DListOfMatListOfMatSizeDouble() { - fail("Not yet implemented"); - } - - public void testMatMulDeriv() { - fail("Not yet implemented"); - } - - public void testProjectPointsMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testProjectPointsMatMatMatMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testProjectPointsMatMatMatMatMatMatMatDouble() { - fail("Not yet implemented"); - } - - public void testRectify3Collinear() { - fail("Not yet implemented"); - } - - public void testReprojectImageTo3DMatMatMat() { - fail("Not yet implemented"); - } - - public void testReprojectImageTo3DMatMatMatBoolean() { - fail("Not yet implemented"); - } - public void testReprojectImageTo3DMatMatMatBooleanInt() { - fail("Not yet implemented"); - } + public void test_1() { + super.test_1("calib3d"); + } + + public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMat() { + fail("Not yet implemented"); + } + + public void testCalibrateCameraListOfMatListOfMatSizeMatMatListOfMatListOfMatInt() { + fail("Not yet implemented"); + } + + public void testCalibrationMatrixValues() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMat() { + Mat rvec1 = new Mat(3, 1, CvType.CV_32F); + rvec1.put(0, 0, 0.5302828, 0.19925919, 0.40105945); + Mat tvec1 = new Mat(3, 1, CvType.CV_32F); + 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 tvec3 = new Mat(); + + Mat outRvec = new Mat(3, 1, CvType.CV_32F); + 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); + + assertMatEqual(outRvec, rvec3); + assertMatEqual(outTvec, tvec3); + } + + public void testComposeRTMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testComposeRTMatMatMatMatMatMatMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + // Mat dr3dr1; + // Mat dr3dt1; + // Mat dr3dr2; + // Mat dr3dt2; + // Mat dt3dr1; + // Mat dt3dt1; + // Mat dt3dr2; + // Mat dt3dt2; + // , dr3dr1, dr3dt1, dr3dr2, dr3dt2, dt3dr1, dt3dt1, dt3dr2, dt3dt2); + // [0.97031879, -0.091774099, 0.38594806; + // 0.15181915, 0.98091727, -0.44186208; + // -0.39509675, 0.43839464, 0.93872648] + // [0, 0, 0; + // 0, 0, 0; + // 0, 0, 0] + // [1.0117353, 0.16348237, -0.083180845; + // -0.1980398, 1.006078, 0.30299222; + // 0.075766489, -0.32784501, 1.0163091] + // [0, 0, 0; + // 0, 0, 0; + // 0, 0, 0] + // [0, 0, 0; + // 0, 0, 0; + // 0, 0, 0] + // [0.69658804, 0.018115902, 0.7172426; + // 0.51114357, 0.68899536, -0.51382649; + // -0.50348526, 0.72453934, 0.47068608] + // [0.18536358, -0.20515044, -0.48834875; + // -0.25120571, 0.29043972, 0.60573936; + // 0.35370794, -0.69923931, 0.45781645] + // [1, 0, 0; + // 0, 1, 0; + // 0, 0, 1] + } + + public void testConvertPointsFromHomogeneous() { + fail("Not yet implemented"); + } + + public void testConvertPointsToHomogeneous() { + fail("Not yet implemented"); + } + + public void testDecomposeProjectionMatrixMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testDecomposeProjectionMatrixMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testDecomposeProjectionMatrixMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testDecomposeProjectionMatrixMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testDecomposeProjectionMatrixMatMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testDrawChessboardCorners() { + fail("Not yet implemented"); + } + + public void testEstimateAffine3DMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testEstimateAffine3DMatMatMatMatDouble() { + fail("Not yet implemented"); + } + + public void testEstimateAffine3DMatMatMatMatDoubleDouble() { + fail("Not yet implemented"); + } + + public void testFilterSpecklesMatDoubleIntDouble() { + gray_16s_1024.copyTo(dst); + Point center = new Point(gray_16s_1024.rows() / 2., + gray_16s_1024.cols() / 2.); + Core.circle(dst, center, 1, Scalar.all(4096)); + + assertMatNotEqual(gray_16s_1024, dst); + Calib3d.filterSpeckles(dst, 1024.0, 100, 0.); + assertMatEqual(gray_16s_1024, dst); + } + + public void testFilterSpecklesMatDoubleIntDoubleMat() { + fail("Not yet implemented"); + } + + public void testFindChessboardCornersMatSizeMat() { + Size patternSize = new Size(9, 6); + Calib3d.findChessboardCorners(grayChess, patternSize, dst); + assertTrue(!dst.empty()); + } + + public void testFindChessboardCornersMatSizeMatInt() { + Size patternSize = new Size(9, 6); + Calib3d.findChessboardCorners(grayChess, patternSize, dst, + Calib3d.CALIB_CB_ADAPTIVE_THRESH + + Calib3d.CALIB_CB_NORMALIZE_IMAGE + + Calib3d.CALIB_CB_FAST_CHECK); + assertTrue(!dst.empty()); + } + + public void testFindCirclesGridDefaultMatSizeMat() { + 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() { + 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() { + fail("Not yet implemented"); + } + + public void testFindFundamentalMatMatMatInt() { + fail("Not yet implemented"); + } + + public void testFindFundamentalMatMatMatIntDouble() { + fail("Not yet implemented"); + } + + public void testFindFundamentalMatMatMatIntDoubleDouble() { + fail("Not yet implemented"); + } + + public void testFindFundamentalMatMatMatIntDoubleDoubleMat() { + fail("Not yet implemented"); + } + + public void testFindHomographyMatMat() { + fail("Not yet implemented"); + } + + public void testFindHomographyMatMatInt() { + fail("Not yet implemented"); + } + + public void testFindHomographyMatMatIntDouble() { + fail("Not yet implemented"); + } + + public void testFindHomographyMatMatIntDoubleMat() { + fail("Not yet implemented"); + } + + public void testGetOptimalNewCameraMatrixMatMatSizeDouble() { + fail("Not yet implemented"); + } + + public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSize() { + fail("Not yet implemented"); + } + + public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRect() { + fail("Not yet implemented"); + } + + public void testGetOptimalNewCameraMatrixMatMatSizeDoubleSizeRectBoolean() { + fail("Not yet implemented"); + } + + public void testGetValidDisparityROI() { + fail("Not yet implemented"); + } + + public void testInitCameraMatrix2DListOfMatListOfMatSize() { + fail("Not yet implemented"); + } + + public void testInitCameraMatrix2DListOfMatListOfMatSizeDouble() { + fail("Not yet implemented"); + } + + public void testMatMulDeriv() { + fail("Not yet implemented"); + } + + public void testProjectPointsMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testProjectPointsMatMatMatMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testProjectPointsMatMatMatMatMatMatMatDouble() { + fail("Not yet implemented"); + } + + public void testRectify3Collinear() { + fail("Not yet implemented"); + } + + public void testReprojectImageTo3DMatMatMat() { + fail("Not yet implemented"); + } + + public void testReprojectImageTo3DMatMatMatBoolean() { + fail("Not yet implemented"); + } + + public void testReprojectImageTo3DMatMatMatBooleanInt() { + fail("Not yet implemented"); + } + + public void testRodriguesMatMat() { + fail("Not yet implemented"); + } - public void testRodriguesMatMat() { - fail("Not yet implemented"); - } + public void testRodriguesMatMatMat() { + fail("Not yet implemented"); + } - public void testRodriguesMatMatMat() { - fail("Not yet implemented"); - } + public void testRQDecomp3x3MatMatMat() { + fail("Not yet implemented"); + } - public void testRQDecomp3x3MatMatMat() { - fail("Not yet implemented"); - } + public void testRQDecomp3x3MatMatMatMat() { + fail("Not yet implemented"); + } - public void testRQDecomp3x3MatMatMatMat() { - fail("Not yet implemented"); - } + public void testRQDecomp3x3MatMatMatMatMat() { + fail("Not yet implemented"); + } - public void testRQDecomp3x3MatMatMatMatMat() { - fail("Not yet implemented"); - } + public void testRQDecomp3x3MatMatMatMatMatMat() { + fail("Not yet implemented"); + } - public void testRQDecomp3x3MatMatMatMatMatMat() { - fail("Not yet implemented"); - } + public void testSolvePnPMatMatMatMatMatMat() { + fail("Not yet implemented"); + } - public void testSolvePnPMatMatMatMatMatMat() { - fail("Not yet implemented"); - } + public void testSolvePnPMatMatMatMatMatMatBoolean() { + fail("Not yet implemented"); + } - public void testSolvePnPMatMatMatMatMatMatBoolean() { - fail("Not yet implemented"); - } + public void testSolvePnPRansacMatMatMatMatMatMat() { + fail("Not yet implemented"); + } - public void testSolvePnPRansacMatMatMatMatMatMat() { - fail("Not yet implemented"); - } + public void testSolvePnPRansacMatMatMatMatMatMatBoolean() { + fail("Not yet implemented"); + } - public void testSolvePnPRansacMatMatMatMatMatMatBoolean() { - fail("Not yet implemented"); - } + public void testSolvePnPRansacMatMatMatMatMatMatBooleanInt() { + fail("Not yet implemented"); + } - public void testSolvePnPRansacMatMatMatMatMatMatBooleanInt() { - fail("Not yet implemented"); - } + public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloat() { + fail("Not yet implemented"); + } - public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloat() { - fail("Not yet implemented"); - } + public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloatInt() { + fail("Not yet implemented"); + } - public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloatInt() { - fail("Not yet implemented"); - } + public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloatIntMat() { + fail("Not yet implemented"); + } - public void testSolvePnPRansacMatMatMatMatMatMatBooleanIntFloatIntMat() { - fail("Not yet implemented"); - } + public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMat() { + fail("Not yet implemented"); + } - public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMat() { - fail("Not yet implemented"); - } + public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteria() { + fail("Not yet implemented"); + } - public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteria() { - fail("Not yet implemented"); - } + public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteriaInt() { + fail("Not yet implemented"); + } - public void testStereoCalibrateListOfMatListOfMatListOfMatMatMatMatMatSizeMatMatMatMatTermCriteriaInt() { - fail("Not yet implemented"); - } + public void testStereoRectifyUncalibratedMatMatMatSizeMatMat() { + fail("Not yet implemented"); + } - public void testStereoRectifyUncalibratedMatMatMatSizeMatMat() { - fail("Not yet implemented"); - } + public void testStereoRectifyUncalibratedMatMatMatSizeMatMatDouble() { + fail("Not yet implemented"); + } - public void testStereoRectifyUncalibratedMatMatMatSizeMatMatDouble() { - fail("Not yet implemented"); - } + public void testValidateDisparityMatMatIntInt() { + fail("Not yet implemented"); + } - public void testValidateDisparityMatMatIntInt() { - fail("Not yet implemented"); - } - - public void testValidateDisparityMatMatIntIntInt() { - fail("Not yet implemented"); - } + public void testValidateDisparityMatMatIntIntInt() { + fail("Not yet implemented"); + } } diff --git a/modules/java/android_test/src/org/opencv/test/core/RectTest.java b/modules/java/android_test/src/org/opencv/test/core/RectTest.java index 192335d..b87385d 100644 --- a/modules/java/android_test/src/org/opencv/test/core/RectTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/RectTest.java @@ -1,5 +1,7 @@ package org.opencv.test.core; +import org.opencv.core.Point; +import org.opencv.core.Rect; import org.opencv.test.OpenCVTestCase; public class RectTest extends OpenCVTestCase { @@ -21,7 +23,21 @@ public class RectTest extends OpenCVTestCase { } 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() { diff --git a/modules/java/android_test/src/org/opencv/test/core/coreTest.java b/modules/java/android_test/src/org/opencv/test/core/coreTest.java index be464c2..0107722 100644 --- a/modules/java/android_test/src/org/opencv/test/core/coreTest.java +++ b/modules/java/android_test/src/org/opencv/test/core/coreTest.java @@ -2,6 +2,9 @@ package org.opencv.test.core; 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.Mat; import org.opencv.core.Point; @@ -11,1430 +14,1467 @@ import org.opencv.core.Core; import org.opencv.test.OpenCVTestCase; public class coreTest extends OpenCVTestCase { - - public void test_1() { - super.test_1("CORE"); - } - - public void testAbsdiff() { - Core.absdiff(gray128, gray255, dst); - assertMatEqual(gray127, dst); - } - - public void testAddMatMatMat() { - Core.add(gray128, gray128, dst); - assertMatEqual(gray255, dst); - } - - public void testAddMatMatMatMat() { - Core.add(gray0, gray1, dst, gray1); - assertMatEqual(gray1, dst); - - dst.setTo(new Scalar(127)); - Core.add(gray0, gray1, dst, gray0); - assertMatEqual(gray127, dst); - } - - public void testAddMatMatMatMatInt() { - Core.add(gray0, gray1, dst, gray1, CvType.CV_32F); - assertTrue(CvType.CV_32F == dst.depth()); - assertMatEqual(gray1_32f, dst); - } - - public void testAddWeightedMatDoubleMatDoubleDoubleMat() { - Core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst); - assertMatEqual(gray255, dst); - } - - public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() { - Core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst, CvType.CV_32F); - assertTrue(CvType.CV_32F == dst.depth()); - assertMatEqual(gray255_32f, dst); - } - - public void testBitwise_andMatMatMat() { - Core.bitwise_and(gray3, gray2, dst); - assertMatEqual(gray2, dst); - } - - public void testBitwise_andMatMatMatMat() { - Core.bitwise_and(gray0, gray1, dst, gray255); - assertMatEqual(gray0, dst); - } - - public void testBitwise_notMatMat() { - Core.bitwise_not(gray255, dst); - assertMatEqual(gray0, dst); - } - - public void testBitwise_notMatMatMat() { - Core.bitwise_not(gray255, dst, gray255); - assertMatEqual(gray0, dst); - } - - public void testBitwise_orMatMatMat() { - Core.bitwise_or(gray3, gray2, dst); - assertMatEqual(gray3, dst); - } - - public void testBitwise_orMatMatMatMat() { - Core.bitwise_or(gray127, gray128, dst, gray255); - assertMatEqual(gray255, dst); - } - - public void testBitwise_xorMatMatMat() { - Core.bitwise_xor(gray3, gray2, dst); - assertMatEqual(gray1, dst); - } - - public void testBitwise_xorMatMatMatMat() { - Core.bitwise_or(gray127, gray128, dst, gray255); - assertMatEqual(gray255, dst); - } - - public void testCalcCovarMatrixMatMatMatInt() { - Mat covar = new Mat(matSize, 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*/); - assertMatEqual(gray0_64f, covar); - assertMatEqual(gray0_64f_1d, mean); - } - - public void testCalcCovarMatrixMatMatMatIntInt() { - Mat covar = new Mat(matSize, 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); - assertMatEqual(gray0_32f, covar); - assertMatEqual(gray0_32f_1d, mean); - } - - public void testCartToPolarMatMatMatMat() { - Mat x = new Mat(1, 3, CvType.CV_32F); - Mat y = new Mat(1, 3, CvType.CV_32F); - x.put(0, 0, 3.0, 6.0, 5,0); - y.put(0, 0, 4.0, 8.0, 12.0); - - Mat magnitude = new Mat(1, 3, CvType.CV_32F); - Mat angle = new Mat(1, 3, CvType.CV_32F); - magnitude.put(0, 0, 5.0, 10.0, 13.0); - angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); - - Mat dst_angle = new Mat(); - Core.cartToPolar(x, y, dst, dst_angle); - assertMatEqual(magnitude, dst); - assertMatEqual(angle, dst_angle); - } - - public void testCartToPolarMatMatMatMatBoolean() { - Mat x = new Mat(1, 3, CvType.CV_32F); - Mat y = new Mat(1, 3, CvType.CV_32F); - x.put(0 ,0, 3.0, 6.0, 5,0); - y.put(0 ,0, 4.0, 8.0, 12.0); - - Mat magnitude = new Mat(1, 3, CvType.CV_32F); - Mat angle = new Mat(1, 3, CvType.CV_32F); - - magnitude.put(0 ,0, 5.0, 10.0, 13.0); - angle.put(0 ,0, 0.92729962, 0.92729962, 1.1759995); - - Mat dst_angle = new Mat(); - Core.cartToPolar(x, y, dst, dst_angle,false); - assertMatEqual(magnitude, dst); - assertMatEqual(angle, dst_angle); - } - - public void testCheckRangeMat() { - fail("Not yet implemented"); - } - - public void testCheckRangeMatBoolean() { - fail("Not yet implemented"); - } - - public void testCheckRangeMatBooleanPoint() { - fail("Not yet implemented"); - } - - public void testCheckRangeMatBooleanPointDouble() { - fail("Not yet implemented"); - } - - public void testCheckRangeMatBooleanPointDoubleDouble() { - fail("Not yet implemented"); - } - - public void testCircleMatPointIntScalar() { - Point center = new Point(gray0.cols() / 2, gray0.rows()/2); - int radius = Math.min(gray0.cols()/4, gray0.rows()/4); - Scalar color = new Scalar(128); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.circle(gray0, center, radius, color); - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testCircleMatPointIntScalarInt() { - Point center = new Point(gray0.cols() / 2, gray0.rows()/2); - int radius = Math.min(gray0.cols()/4, gray0.rows()/4); - Scalar color = new Scalar(128); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.circle(gray0, center, radius, color, -1 /*filled circle*/); - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testCircleMatPointIntScalarIntInt() { - Point center = new Point(gray0.cols() / 2, gray0.rows()/2); - int radius = Math.min(gray0.cols()/4, gray0.rows()/4); - Scalar color = new Scalar(128); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.circle(gray0, center, radius, color, 2, 4/*4-connected line*/); - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testCircleMatPointIntScalarIntIntInt() { - Point center = new Point(gray0.cols() / 2, gray0.rows()/2); - Point center2 = new Point(gray0.cols(), gray0.rows()); - int radius = Math.min(gray0.cols()/4, gray0.rows()/4); - Scalar color128 = new Scalar(128); - Scalar color0 = new Scalar(0); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.circle(gray0, center2, radius*2, color128, 2, 4, 1/*Number of fractional bits*/); - Core.circle(gray0, center, radius, color0, 2, 4, 0); - assertTrue(0 == Core.countNonZero(gray0)); - } - - public void testClipLine() { - Rect r = new Rect(10, 10, 10, 10); - - Point pt1 = new Point(5.0, 15.0); - Point pt2 = new Point(25.0, 15.0); - - Point pt1Clipped = new Point(10.0, 15.0); - Point pt2Clipped = new Point(19.0, 15.0); - - boolean res = Core.clipLine(r, pt1, pt2); - assertEquals(true, res); - assertEquals(pt1Clipped, pt1); - assertEquals(pt2Clipped, pt2); - - pt1 = new Point(5.0, 5.0); - pt2 = new Point(25.0, 5.0); - pt1Clipped = new Point(5.0, 5.0); - pt2Clipped = new Point(25.0, 5.0); - - res = Core.clipLine(r, pt1, pt2); - assertEquals(false, res); - assertEquals(pt1Clipped, pt1); - assertEquals(pt2Clipped, pt2); - } - - - public void testCompare() { + + public void test_1() { + super.test_1("CORE"); + } + + public void testAbsdiff() { + Core.absdiff(gray128, gray255, dst); + assertMatEqual(gray127, dst); + } + + public void testAddMatMatMat() { + Core.add(gray128, gray128, dst); + assertMatEqual(gray255, dst); + } + + public void testAddMatMatMatMat() { + Core.add(gray0, gray1, dst, gray1); + assertMatEqual(gray1, dst); + + dst.setTo(new Scalar(127)); + Core.add(gray0, gray1, dst, gray0); + assertMatEqual(gray127, dst); + } + + public void testAddMatMatMatMatInt() { + Core.add(gray0, gray1, dst, gray1, CvType.CV_32F); + assertTrue(CvType.CV_32F == dst.depth()); + assertMatEqual(gray1_32f, dst); + } + + public void testAddWeightedMatDoubleMatDoubleDoubleMat() { + Core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst); + assertMatEqual(gray255, dst); + } + + public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() { + Core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst, CvType.CV_32F); + assertTrue(CvType.CV_32F == dst.depth()); + assertMatEqual(gray255_32f, dst); + } + + public void testBitwise_andMatMatMat() { + Core.bitwise_and(gray3, gray2, dst); + assertMatEqual(gray2, dst); + } + + public void testBitwise_andMatMatMatMat() { + Core.bitwise_and(gray0, gray1, dst, gray255); + assertMatEqual(gray0, dst); + } + + public void testBitwise_notMatMat() { + Core.bitwise_not(gray255, dst); + assertMatEqual(gray0, dst); + } + + public void testBitwise_notMatMatMat() { + Core.bitwise_not(gray255, dst, gray255); + assertMatEqual(gray0, dst); + } + + public void testBitwise_orMatMatMat() { + Core.bitwise_or(gray3, gray2, dst); + assertMatEqual(gray3, dst); + } + + public void testBitwise_orMatMatMatMat() { + Core.bitwise_or(gray127, gray128, dst, gray255); + assertMatEqual(gray255, dst); + } + + public void testBitwise_xorMatMatMat() { + Core.bitwise_xor(gray3, gray2, dst); + assertMatEqual(gray1, dst); + } + + public void testBitwise_xorMatMatMatMat() { + Core.bitwise_or(gray127, gray128, dst, gray255); + assertMatEqual(gray255, dst); + } + + public void testCalcCovarMatrixMatMatMatInt() { + Mat covar = new Mat(matSize, 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 + */); + assertMatEqual(gray0_64f, covar); + assertMatEqual(gray0_64f_1d, mean); + } + + public void testCalcCovarMatrixMatMatMatIntInt() { + Mat covar = new Mat(matSize, 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); + assertMatEqual(gray0_32f, covar); + assertMatEqual(gray0_32f_1d, mean); + } + + public void testCartToPolarMatMatMatMat() { + Mat x = new Mat(1, 3, CvType.CV_32F); + Mat y = new Mat(1, 3, CvType.CV_32F); + x.put(0, 0, 3.0, 6.0, 5, 0); + y.put(0, 0, 4.0, 8.0, 12.0); + + Mat magnitude = new Mat(1, 3, CvType.CV_32F); + Mat angle = new Mat(1, 3, CvType.CV_32F); + magnitude.put(0, 0, 5.0, 10.0, 13.0); + angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); + + Mat dst_angle = new Mat(); + Core.cartToPolar(x, y, dst, dst_angle); + assertMatEqual(magnitude, dst); + assertMatEqual(angle, dst_angle); + } + + public void testCartToPolarMatMatMatMatBoolean() { + Mat x = new Mat(1, 3, CvType.CV_32F); + Mat y = new Mat(1, 3, CvType.CV_32F); + x.put(0, 0, 3.0, 6.0, 5, 0); + y.put(0, 0, 4.0, 8.0, 12.0); + + Mat magnitude = new Mat(1, 3, CvType.CV_32F); + Mat angle = new Mat(1, 3, CvType.CV_32F); + + magnitude.put(0, 0, 5.0, 10.0, 13.0); + angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); + + Mat dst_angle = new Mat(); + Core.cartToPolar(x, y, dst, dst_angle, false); + assertMatEqual(magnitude, dst); + assertMatEqual(angle, dst_angle); + } + + public void testCheckRangeMat() { + 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() { + 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() { + fail("Not yet implemented"); + } + + public void testCheckRangeMatBooleanPointDouble() { + fail("Not yet implemented"); + } + + public void testCheckRangeMatBooleanPointDoubleDouble() { + fail("Not yet implemented"); + } + + public void testCircleMatPointIntScalar() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); + Scalar color = new Scalar(128); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.circle(gray0, center, radius, color); + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testCircleMatPointIntScalarInt() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); + Scalar color = new Scalar(128); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.circle(gray0, center, radius, color, -1 /* filled circle */); + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testCircleMatPointIntScalarIntInt() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); + Scalar color = new Scalar(128); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.circle(gray0, center, radius, color, 2, 4/* 4-connected line */); + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testCircleMatPointIntScalarIntIntInt() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + Point center2 = new Point(gray0.cols(), gray0.rows()); + int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4); + Scalar color128 = new Scalar(128); + Scalar color0 = new Scalar(0); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.circle(gray0, center2, radius * 2, color128, 2, 4, 1/* + * Number of + * fractional + * bits + */); + Core.circle(gray0, center, radius, color0, 2, 4, 0); + assertTrue(0 == Core.countNonZero(gray0)); + } + + public void testClipLine() { + Rect r = new Rect(10, 10, 10, 10); + + Point pt1 = new Point(5.0, 15.0); + Point pt2 = new Point(25.0, 15.0); + + Point pt1Clipped = new Point(10.0, 15.0); + Point pt2Clipped = new Point(19.0, 15.0); + + boolean res = Core.clipLine(r, pt1, pt2); + assertEquals(true, res); + assertEquals(pt1Clipped, pt1); + assertEquals(pt2Clipped, pt2); + + pt1 = new Point(5.0, 5.0); + pt2 = new Point(25.0, 5.0); + pt1Clipped = new Point(5.0, 5.0); + pt2Clipped = new Point(25.0, 5.0); + + res = Core.clipLine(r, pt1, pt2); + assertEquals(false, res); + assertEquals(pt1Clipped, pt1); + assertEquals(pt2Clipped, pt2); + } + + public void testCompare() { Core.compare(gray0, gray0, dst, Core.CMP_EQ); assertMatEqual(dst, gray255); - + Core.compare(gray0, gray1, dst, Core.CMP_EQ); assertMatEqual(dst, gray0); - + Core.compare(gray0, grayRnd, dst, Core.CMP_EQ); double nBlackPixels = Core.countNonZero(dst); double nNonBlackpixels = Core.countNonZero(grayRnd); assertTrue((nBlackPixels + nNonBlackpixels) == grayRnd.total()); - } - - public void testCompleteSymmMat() { - Core.completeSymm(grayRnd_32f); - Core.transpose(grayRnd_32f, dst); - assertMatEqual(grayRnd_32f, dst); - } - - public void testCompleteSymmMatBoolean() { - Core.completeSymm(grayRnd_32f, true); - Core.transpose(grayRnd_32f, dst); - assertMatEqual(grayRnd_32f, dst); - } - - public void testConvertScaleAbsMatMat() { - Core.convertScaleAbs(gray0, dst); - assertMatEqual(gray0, dst); - - Core.convertScaleAbs(gray_16u_256, dst); - assertMatEqual(gray255, dst); - } - - public void testConvertScaleAbsMatMatDouble() { - Core.convertScaleAbs(gray0, dst, 2); - assertMatEqual(gray0, dst); - - Core.convertScaleAbs(gray_16u_256, dst, 1); - assertMatEqual(gray255, dst); - } - - public void testConvertScaleAbsMatMatDoubleDouble() { - Core.convertScaleAbs(gray_16u_256, dst, 2, 2); - assertMatEqual(gray255, dst); - } - - public void testCountNonZero() { - assertEquals(0, Core.countNonZero(gray0)); - gray0.put(0, 0, 255); - gray0.put(gray0.rows() - 1, gray0.cols() - 1, 255); - assertEquals(2, Core.countNonZero(gray0)); - } - - public void testCubeRoot() { - float res = Core.cubeRoot(27.0f); - assertEquals(3.0f,res); - } - - public void testDctMatMat() { - Core.dct(gray0_32f_1d, dst); - assertMatEqual(gray0_32f_1d, dst); - - Mat in = new Mat(1, 4, CvType.CV_32F); - in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682); - - truth = new Mat(1, 4, CvType.CV_32F); - truth.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477); - - Core.dct(in, dst); - assertMatEqual(truth, dst); - } - - public void testDctMatMatInt() { - Core.dct(gray0_32f_1d, dst); - assertMatEqual(gray0_32f_1d, dst); - - 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); - - 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); - - Core.dct(in, dst); - assertMatEqual(truth, dst); - } - - public void testDeterminant() { - Mat mat = new Mat(2, 2, CvType.CV_32F); - mat.put(0, 0, 4.0); - mat.put(0, 1, 2.0); - mat.put(1, 0, 4.0); - mat.put(1, 1, 4.0); - - double det = Core.determinant(mat); - assertEquals(8.0, det); - } - - public void testDftMatMat() { - Mat src = new Mat(1, 4, CvType.CV_32F); - src.put(0, 0, 0, 0, 0, 0); - - truth = new Mat(1, 4, CvType.CV_32F); - truth.put(0, 0, 0, 0, 0, 0); - Core.dft(src, dst); - assertMatEqual(truth, dst); - } - - public void testDftMatMatInt() { - Mat src = new Mat(1, 4, CvType.CV_32F); - truth = new Mat(1, 4, CvType.CV_32F); - - src.put(0, 0, 1, 2, 3, 4); - truth.put(0, 0, 10, -2, 2, -2); - Core.dft(src, dst, Core.DFT_REAL_OUTPUT); - assertMatEqual(truth, dst); - - Core.dft(src, dst, Core.DFT_INVERSE); - truth.put(0, 0, 9, -9, 1, 3); - assertMatEqual(truth, dst); - } - - public void testDftMatMatIntInt() { - Mat src = new Mat(1, 4, CvType.CV_32F); - src.put(0, 0, 1, 2, 3, 4); - - truth = new Mat(1, 4, CvType.CV_32F); - truth.put(0, 0, 10, -2, 2, -2); - Core.dft(src, dst, Core.DFT_REAL_OUTPUT, 1); - assertMatEqual(truth, dst); - } - - public void testDivideDoubleMatMat() { - Core.divide(4.0, gray2, dst); - assertMatEqual(gray2, dst); - } - - public void testDivideDoubleMatMatInt() { - Core.divide(9.0, gray3, dst, -1); - assertMatEqual(gray3, dst); - } - - public void testDivideMatMatMat() { - Core.divide(gray2, gray1, dst); - assertMatEqual(gray2, dst); - } - - public void testDivideMatMatMatDouble() { - Core.divide(gray2, gray2, dst, 2.0); - assertMatEqual(gray2, dst); - } - - public void testDivideMatMatMatDoubleInt() { - Core.divide(gray3, gray2, dst, 2.0, gray3.depth()); - assertMatEqual(gray3, dst); - } - - public void testEigen() { - fail("Not yet implemented"); - } - - public void testEllipse2Poly() { - fail("Not yet implemented"); - } - - public void testEllipseMatPointSizeDoubleDoubleDoubleScalar() { - fail("Not yet implemented"); - } - - public void testEllipseMatPointSizeDoubleDoubleDoubleScalarInt() { - fail("Not yet implemented"); - } - - public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntInt() { - fail("Not yet implemented"); - } - - public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntIntInt() { - fail("Not yet implemented"); - } - - public void testEllipseMatRotatedRectScalar() { - fail("Not yet implemented"); - } - - public void testEllipseMatRotatedRectScalarInt() { - fail("Not yet implemented"); - } - - public void testEllipseMatRotatedRectScalarIntInt() { - fail("Not yet implemented"); - } - - public void testExp() { - Mat destination = new Mat(matSize, matSize, CvType.CV_32F); destination.setTo(new Scalar(0.0)); - Core.exp(gray0_32f, destination); - assertMatEqual(gray1_32f, destination); - } - - public void testExtractChannel() { - Core.extractChannel(rgba128, dst, 0); - assertMatEqual(gray128, dst); - } - - public void testFastAtan2() { - double delta = 0.01; - float res = Core.fastAtan2(50, 50); - assertEquals(45,res,delta); - - float res2 = Core.fastAtan2(80, 20); - assertEquals(75.96, res2, delta); - } - - public void testFillConvexPolyMatMatScalar() { - fail("Not yet implemented"); - } - - public void testFillConvexPolyMatMatScalarInt() { - fail("Not yet implemented"); - } - - public void testFillConvexPolyMatMatScalarIntInt() { - fail("Not yet implemented"); - } - - public void testFillPolyMatListOfMatScalar() { - fail("Not yet implemented"); - } - - public void testFillPolyMatListOfMatScalarInt() { - fail("Not yet implemented"); - } - - public void testFillPolyMatListOfMatScalarIntInt() { - fail("Not yet implemented"); - } - - public void testFillPolyMatListOfMatScalarIntIntPoint() { - fail("Not yet implemented"); - } - - public void testFlip() { - Mat src = new Mat(2, 2, CvType.CV_32F); - Mat des_f0 = new Mat(2, 2, CvType.CV_32F); - src.put(0, 0, 1.0); - src.put(0, 1, 2.0); - src.put(1, 0, 3.0); - src.put(1, 1, 4.0); - - des_f0.put(0, 0, 3.0); - des_f0.put(0, 1, 4.0); - des_f0.put(1, 0, 1.0); - des_f0.put(1, 1, 2.0); - Core.flip(src, dst, 0); - assertMatEqual(des_f0, dst); - - Mat des_f1 = new Mat(2, 2, CvType.CV_32F); - des_f1.put(0, 0, 2.0); - des_f1.put(0, 1, 1.0); - des_f1.put(1, 0, 4.0); - des_f1.put(1, 1, 3.0); - Core.flip(src, dst, 1); - assertMatEqual(des_f1, dst); - } - - public void testGemmMatMatDoubleMatDoubleMat() { - Mat m1 = new Mat(2, 2, CvType.CV_32FC1); - Mat m2 = new Mat(2, 2, CvType.CV_32FC1); - Mat desired = new Mat(2, 2, CvType.CV_32FC1); - Mat dmatrix = new Mat(2, 2, CvType.CV_32FC1); - - m1.put(0, 0, 1.0, 0.0); - m1.put(1, 0, 1.0, 0.0); - - m2.put(0, 0, 1.0, 0.0); - m2.put(1, 0, 1.0, 0.0); - - dmatrix.put(0, 0, 0.001, 0.001); - dmatrix.put(1, 0, 0.001, 0.001); - - desired.put(0, 0, 1.001, 0.001); - desired.put(1, 0, 1.001, 0.001); - - Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst); - assertMatEqual(desired, dst); - } - - public void testGemmMatMatDoubleMatDoubleMatInt() { - Mat m1 = new Mat(2, 2, CvType.CV_32FC1); - Mat m2 = new Mat(2, 2, CvType.CV_32FC1); - Mat desired = new Mat(2, 2, CvType.CV_32FC1); - Mat dmatrix = new Mat(2, 2, CvType.CV_32FC1); - - m1.put(0, 0, 1.0, 0.0); - m1.put(1, 0, 1.0, 0.0); - - m2.put(0, 0, 1.0, 0.0); - m2.put(1, 0, 1.0, 0.0); - - dmatrix.put(0, 0, 0.001, 0.001); - dmatrix.put(1, 0, 0.001, 0.001); - - desired.put(0, 0, 2.001, 0.001); - desired.put(1, 0, 0.001, 0.001); - - Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst, Core.GEMM_1_T); - assertMatEqual(desired, dst); - } - - public void testGetCPUTickCount() { - fail("Not yet implemented"); - } - - public void testGetOptimalDFTSize() { - int vecsize = Core.getOptimalDFTSize(0); - assertEquals(1, vecsize); - - int largeVecSize = Core.getOptimalDFTSize(133); - assertEquals(135, largeVecSize); - largeVecSize = Core.getOptimalDFTSize(13); - assertEquals(15, largeVecSize); - } - - public void testGetTextSize() { - fail("Not yet implemented"); - } - - public void testGetTickCount() { - fail("Not yet implemented"); - } - - public void testGetTickFrequency() { - double freq = 0.0; - freq = Core.getTickFrequency(); - assertTrue(0.0 != freq); - } - - public void testHconcat() { - Mat e = Mat.eye(3, 3, CvType.CV_8UC1); - Mat eConcat = new Mat(1, 9, CvType.CV_8UC1); - eConcat.put(0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1); - - Core.hconcat(e, dst); - assertMatEqual(eConcat, dst); - } - - public void testIdctMatMat() { - Mat in = new Mat(1, 8, CvType.CV_32F); - 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.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115); - - Core.idct(in, dst); - assertMatEqual(truth, dst); - } - - public void testIdctMatMatInt() { - Mat in = new Mat(1, 8, CvType.CV_32F); - 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.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); - assertMatEqual(truth, dst); - } - - public void testIdftMatMat() { - Mat in = new Mat(1, 4, CvType.CV_32F); - in.put(0, 0, 1.0, 2.0, 3.0, 4.0); - - truth = new Mat(1, 4, CvType.CV_32F); - truth.put(0, 0, 9, -9, 1, 3); - - Core.idft(in, dst); - assertMatEqual(truth, dst); - } - - public void testIdftMatMatInt() { - Mat in = new Mat(1, 4, CvType.CV_32F); - in.put(0, 0, 1.0, 2.0, 3.0, 4.0); - - truth = new Mat(1, 4, CvType.CV_32F); - truth.put(0, 0, 9, -9, 1, 3); - Core.idft(in, dst, Core.DFT_REAL_OUTPUT); - assertMatEqual(truth, dst); - } - - public void testIdftMatMatIntInt() { - Mat in = new Mat(1, 4, CvType.CV_32F); - in.put(0, 0, 1.0, 2.0, 3.0, 4.0); - - truth = new Mat(1, 4, CvType.CV_32F); - truth.put(0, 0, 9, -9, 1, 3); - Core.idft(in, dst, Core.DFT_REAL_OUTPUT, 1); - assertMatEqual(truth, dst); - } - - public void testInRange() { - Core.inRange(gray0, gray0, gray1, dst); - assertMatEqual(gray255, dst); - } - - public void testInsertChannel() { - Core.insertChannel(gray0, rgba128, 0); - Core.insertChannel(gray0, rgba128, 1); - Core.insertChannel(gray0, rgba128, 2); - Core.insertChannel(gray0, rgba128, 3); - assertMatEqual(rgba0, rgba128); - } - - public void testInvertMatMat() { - Mat src = new Mat(2, 2, CvType.CV_32F); - src.put(0, 0, 1.0); - src.put(0, 1, 2.0); - src.put(1, 0, 1.5); - src.put(1, 1, 4.0); - - truth = new Mat(2, 2, CvType.CV_32F); - truth.put(0, 0, 4.0); - truth.put(0, 1, -2.0); - truth.put(1, 0, -1.5); - truth.put(1, 1, 1.0); - - Core.invert(src, dst); - assertMatEqual(truth, dst); - - //TODO: needs epsilon comparison -// Mat m = grayRnd_32f.clone(); -// Mat inv = m.inv(); -// Core.gemm(m, inv, 1.0, new Mat(), 0.0, dst); -// assertMatEqual(grayE_32f, dst); - } - - public void testInvertMatMatInt() { - Mat src = Mat.eye(3, 3, CvType.CV_32FC1); - - truth = Mat.eye(3, 3, CvType.CV_32FC1); - - Core.invert(src, dst, Core.DECOMP_CHOLESKY); - assertMatEqual(truth, dst); - - Core.invert(src, dst, Core.DECOMP_LU); - double det = Core.determinant(src); - assertTrue(det > 0.0); - } - - public void testKmeansMatIntMatTermCriteriaIntInt() { - fail("Not yet implemented"); - } - - public void testKmeansMatIntMatTermCriteriaIntIntMat() { - fail("Not yet implemented"); - } - - public void testLineMatPointPointScalar() { - int nPoints = Math.min(gray0.cols(), gray0.rows()); - - Point point1 = new Point(0, 0); - Point point2 = new Point(nPoints, nPoints); - Scalar color = new Scalar(255); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.line(gray0, point1, point2, color); - assertTrue(nPoints == Core.countNonZero(gray0)); - } - - public void testLineMatPointPointScalarInt() { - int nPoints = Math.min(gray0.cols(), gray0.rows()); - - Point point1 = new Point(0, 0); - Point point2 = new Point(nPoints, nPoints); - Scalar color = new Scalar(255); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.line(gray0, point1, point2, color, 0); - assertTrue(nPoints == Core.countNonZero(gray0)); - } - - public void testLineMatPointPointScalarIntInt() { - fail("Not yet implemented"); - } - - public void testLineMatPointPointScalarIntIntInt() { - fail("Not yet implemented"); - } - - public void testLog() { - Mat in = new Mat(1, 4, CvType.CV_32FC1); - Mat desired = new Mat(1, 4, CvType.CV_32FC1); - in.put(0, 0, 1.0, 10.0, 100.0, 1000.0); - desired.put(0, 0, 0, 2.3025851, 4.6051702, 6.9077554); - - Core.log(in, dst); - assertMatEqual(desired, dst); - } - - public void testLUTMatMatMat() { - Mat lut = new Mat(1, 256, CvType.CV_8UC1); - - lut.setTo(new Scalar(0)); - Core.LUT(grayRnd, lut, dst); - assertMatEqual(gray0, dst); - - lut.setTo(new Scalar(255)); - Core.LUT(grayRnd, lut, dst); - assertMatEqual(gray255, dst); - } - - public void testLUTMatMatMatInt() { - Mat lut = new Mat(1, 256, CvType.CV_8UC1); - lut.setTo(new Scalar(255)); - Core.LUT(grayRnd, lut, dst, 0); - assertMatEqual(gray255, dst); - } - - public void testMagnitude() { - Mat x = new Mat(1, 4, CvType.CV_32F); - Mat y = new Mat(1, 4, CvType.CV_32F); - Mat out = new Mat(1, 4, CvType.CV_32F); - - x.put(0, 0, 3.0, 5.0, 9.0, 6.0); - y.put(0, 0, 4.0, 12.0, 40.0, 8.0); - out.put(0, 0, 5.0, 13.0, 41.0, 10.0); - + } + + public void testCompleteSymmMat() { + Core.completeSymm(grayRnd_32f); + Core.transpose(grayRnd_32f, dst); + assertMatEqual(grayRnd_32f, dst); + } + + public void testCompleteSymmMatBoolean() { + Core.completeSymm(grayRnd_32f, true); + Core.transpose(grayRnd_32f, dst); + assertMatEqual(grayRnd_32f, dst); + } + + public void testConvertScaleAbsMatMat() { + Core.convertScaleAbs(gray0, dst); + assertMatEqual(gray0, dst); + + Core.convertScaleAbs(gray_16u_256, dst); + assertMatEqual(gray255, dst); + } + + public void testConvertScaleAbsMatMatDouble() { + Core.convertScaleAbs(gray0, dst, 2); + assertMatEqual(gray0, dst); + + Core.convertScaleAbs(gray_16u_256, dst, 1); + assertMatEqual(gray255, dst); + } + + public void testConvertScaleAbsMatMatDoubleDouble() { + Core.convertScaleAbs(gray_16u_256, dst, 2, 2); + assertMatEqual(gray255, dst); + } + + public void testCountNonZero() { + assertEquals(0, Core.countNonZero(gray0)); + gray0.put(0, 0, 255); + gray0.put(gray0.rows() - 1, gray0.cols() - 1, 255); + assertEquals(2, Core.countNonZero(gray0)); + } + + public void testCubeRoot() { + float res = Core.cubeRoot(27.0f); + assertEquals(3.0f, res); + } + + public void testDctMatMat() { + Core.dct(gray0_32f_1d, dst); + assertMatEqual(gray0_32f_1d, dst); + + Mat in = new Mat(1, 4, CvType.CV_32F); + in.put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682); + + truth = new Mat(1, 4, CvType.CV_32F); + truth.put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477); + + Core.dct(in, dst); + assertMatEqual(truth, dst); + } + + public void testDctMatMatInt() { + Core.dct(gray0_32f_1d, dst); + assertMatEqual(gray0_32f_1d, dst); + + 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); + + 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); + + Core.dct(in, dst); + assertMatEqual(truth, dst); + } + + public void testDeterminant() { + Mat mat = new Mat(2, 2, CvType.CV_32F); + mat.put(0, 0, 4.0); + mat.put(0, 1, 2.0); + mat.put(1, 0, 4.0); + mat.put(1, 1, 4.0); + + double det = Core.determinant(mat); + assertEquals(8.0, det); + } + + public void testDftMatMat() { + Mat src = new Mat(1, 4, CvType.CV_32F); + src.put(0, 0, 0, 0, 0, 0); + + truth = new Mat(1, 4, CvType.CV_32F); + truth.put(0, 0, 0, 0, 0, 0); + Core.dft(src, dst); + assertMatEqual(truth, dst); + } + + public void testDftMatMatInt() { + Mat src = new Mat(1, 4, CvType.CV_32F); + truth = new Mat(1, 4, CvType.CV_32F); + + src.put(0, 0, 1, 2, 3, 4); + truth.put(0, 0, 10, -2, 2, -2); + Core.dft(src, dst, Core.DFT_REAL_OUTPUT); + assertMatEqual(truth, dst); + + Core.dft(src, dst, Core.DFT_INVERSE); + truth.put(0, 0, 9, -9, 1, 3); + assertMatEqual(truth, dst); + } + + public void testDftMatMatIntInt() { + Mat src = new Mat(1, 4, CvType.CV_32F); + src.put(0, 0, 1, 2, 3, 4); + + truth = new Mat(1, 4, CvType.CV_32F); + truth.put(0, 0, 10, -2, 2, -2); + Core.dft(src, dst, Core.DFT_REAL_OUTPUT, 1); + assertMatEqual(truth, dst); + } + + public void testDivideDoubleMatMat() { + Core.divide(4.0, gray2, dst); + assertMatEqual(gray2, dst); + } + + public void testDivideDoubleMatMatInt() { + Core.divide(9.0, gray3, dst, -1); + assertMatEqual(gray3, dst); + } + + public void testDivideMatMatMat() { + Core.divide(gray2, gray1, dst); + assertMatEqual(gray2, dst); + } + + public void testDivideMatMatMatDouble() { + Core.divide(gray2, gray2, dst, 2.0); + assertMatEqual(gray2, dst); + } + + public void testDivideMatMatMatDoubleInt() { + Core.divide(gray3, gray2, dst, 2.0, gray3.depth()); + assertMatEqual(gray3, dst); + } + + public void testEigen() { + fail("Not yet implemented"); + } + + public void testEllipse2Poly() { + fail("Not yet implemented"); + } + + public void testEllipseMatPointSizeDoubleDoubleDoubleScalar() { + fail("Not yet implemented"); + } + + public void testEllipseMatPointSizeDoubleDoubleDoubleScalarInt() { + fail("Not yet implemented"); + } + + public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntInt() { + fail("Not yet implemented"); + } + + public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntIntInt() { + fail("Not yet implemented"); + } + + public void testEllipseMatRotatedRectScalar() { + fail("Not yet implemented"); + } + + public void testEllipseMatRotatedRectScalarInt() { + fail("Not yet implemented"); + } + + public void testEllipseMatRotatedRectScalarIntInt() { + fail("Not yet implemented"); + } + + public void testExp() { + Mat destination = new Mat(matSize, matSize, CvType.CV_32F); + destination.setTo(new Scalar(0.0)); + Core.exp(gray0_32f, destination); + assertMatEqual(gray1_32f, destination); + } + + public void testExtractChannel() { + Core.extractChannel(rgba128, dst, 0); + assertMatEqual(gray128, dst); + } + + public void testFastAtan2() { + double delta = 0.01; + float res = Core.fastAtan2(50, 50); + assertEquals(45, res, delta); + + float res2 = Core.fastAtan2(80, 20); + assertEquals(75.96, res2, delta); + } + + public void testFillConvexPolyMatMatScalar() { + fail("Not yet implemented"); + } + + public void testFillConvexPolyMatMatScalarInt() { + fail("Not yet implemented"); + } + + public void testFillConvexPolyMatMatScalarIntInt() { + fail("Not yet implemented"); + } + + public void testFillPolyMatListOfMatScalar() { + fail("Not yet implemented"); + } + + public void testFillPolyMatListOfMatScalarInt() { + fail("Not yet implemented"); + } + + public void testFillPolyMatListOfMatScalarIntInt() { + fail("Not yet implemented"); + } + + public void testFillPolyMatListOfMatScalarIntIntPoint() { + fail("Not yet implemented"); + } + + public void testFlip() { + Mat src = new Mat(2, 2, CvType.CV_32F); + Mat des_f0 = new Mat(2, 2, CvType.CV_32F); + src.put(0, 0, 1.0); + src.put(0, 1, 2.0); + src.put(1, 0, 3.0); + src.put(1, 1, 4.0); + + des_f0.put(0, 0, 3.0); + des_f0.put(0, 1, 4.0); + des_f0.put(1, 0, 1.0); + des_f0.put(1, 1, 2.0); + Core.flip(src, dst, 0); + assertMatEqual(des_f0, dst); + + Mat des_f1 = new Mat(2, 2, CvType.CV_32F); + des_f1.put(0, 0, 2.0); + des_f1.put(0, 1, 1.0); + des_f1.put(1, 0, 4.0); + des_f1.put(1, 1, 3.0); + Core.flip(src, dst, 1); + assertMatEqual(des_f1, dst); + } + + public void testGemmMatMatDoubleMatDoubleMat() { + Mat m1 = new Mat(2, 2, CvType.CV_32FC1); + Mat m2 = new Mat(2, 2, CvType.CV_32FC1); + Mat desired = new Mat(2, 2, CvType.CV_32FC1); + Mat dmatrix = new Mat(2, 2, CvType.CV_32FC1); + + m1.put(0, 0, 1.0, 0.0); + m1.put(1, 0, 1.0, 0.0); + + m2.put(0, 0, 1.0, 0.0); + m2.put(1, 0, 1.0, 0.0); + + dmatrix.put(0, 0, 0.001, 0.001); + dmatrix.put(1, 0, 0.001, 0.001); + + desired.put(0, 0, 1.001, 0.001); + desired.put(1, 0, 1.001, 0.001); + + Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst); + assertMatEqual(desired, dst); + } + + public void testGemmMatMatDoubleMatDoubleMatInt() { + Mat m1 = new Mat(2, 2, CvType.CV_32FC1); + Mat m2 = new Mat(2, 2, CvType.CV_32FC1); + Mat desired = new Mat(2, 2, CvType.CV_32FC1); + Mat dmatrix = new Mat(2, 2, CvType.CV_32FC1); + + m1.put(0, 0, 1.0, 0.0); + m1.put(1, 0, 1.0, 0.0); + + m2.put(0, 0, 1.0, 0.0); + m2.put(1, 0, 1.0, 0.0); + + dmatrix.put(0, 0, 0.001, 0.001); + dmatrix.put(1, 0, 0.001, 0.001); + + desired.put(0, 0, 2.001, 0.001); + desired.put(1, 0, 0.001, 0.001); + + Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst, Core.GEMM_1_T); + assertMatEqual(desired, dst); + } + + public void testGetCPUTickCount() { + fail("Not yet implemented"); + } + + public void testGetOptimalDFTSize() { + int vecsize = Core.getOptimalDFTSize(0); + assertEquals(1, vecsize); + + int largeVecSize = Core.getOptimalDFTSize(133); + assertEquals(135, largeVecSize); + largeVecSize = Core.getOptimalDFTSize(13); + assertEquals(15, largeVecSize); + } + + public void testGetTextSize() { + fail("Not yet implemented"); + } + + public void testGetTickCount() { + fail("Not yet implemented"); + } + + public void testGetTickFrequency() { + double freq = 0.0; + freq = Core.getTickFrequency(); + assertTrue(0.0 != freq); + } + + public void testHconcat() { + Mat e = Mat.eye(3, 3, CvType.CV_8UC1); + Mat eConcat = new Mat(1, 9, CvType.CV_8UC1); + eConcat.put(0, 0, 1, 0, 0, 0, 1, 0, 0, 0, 1); + + Core.hconcat(e, dst); + assertMatEqual(eConcat, dst); + } + + public void testIdctMatMat() { + Mat in = new Mat(1, 8, CvType.CV_32F); + 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.put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, + -0.86502546, 0.028082132, -0.7673766, 0.10917115); + + Core.idct(in, dst); + assertMatEqual(truth, dst); + } + + public void testIdctMatMatInt() { + Mat in = new Mat(1, 8, CvType.CV_32F); + 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.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); + assertMatEqual(truth, dst); + } + + public void testIdftMatMat() { + Mat in = new Mat(1, 4, CvType.CV_32F); + in.put(0, 0, 1.0, 2.0, 3.0, 4.0); + + truth = new Mat(1, 4, CvType.CV_32F); + truth.put(0, 0, 9, -9, 1, 3); + + Core.idft(in, dst); + assertMatEqual(truth, dst); + } + + public void testIdftMatMatInt() { + Mat in = new Mat(1, 4, CvType.CV_32F); + in.put(0, 0, 1.0, 2.0, 3.0, 4.0); + + truth = new Mat(1, 4, CvType.CV_32F); + truth.put(0, 0, 9, -9, 1, 3); + Core.idft(in, dst, Core.DFT_REAL_OUTPUT); + assertMatEqual(truth, dst); + } + + public void testIdftMatMatIntInt() { + Mat in = new Mat(1, 4, CvType.CV_32F); + in.put(0, 0, 1.0, 2.0, 3.0, 4.0); + + truth = new Mat(1, 4, CvType.CV_32F); + truth.put(0, 0, 9, -9, 1, 3); + Core.idft(in, dst, Core.DFT_REAL_OUTPUT, 1); + assertMatEqual(truth, dst); + } + + public void testInRange() { + Core.inRange(gray0, gray0, gray1, dst); + assertMatEqual(gray255, dst); + } + + public void testInsertChannel() { + Core.insertChannel(gray0, rgba128, 0); + Core.insertChannel(gray0, rgba128, 1); + Core.insertChannel(gray0, rgba128, 2); + Core.insertChannel(gray0, rgba128, 3); + assertMatEqual(rgba0, rgba128); + } + + public void testInvertMatMat() { + Mat src = new Mat(2, 2, CvType.CV_32F); + src.put(0, 0, 1.0); + src.put(0, 1, 2.0); + src.put(1, 0, 1.5); + src.put(1, 1, 4.0); + + truth = new Mat(2, 2, CvType.CV_32F); + truth.put(0, 0, 4.0); + truth.put(0, 1, -2.0); + truth.put(1, 0, -1.5); + truth.put(1, 1, 1.0); + + Core.invert(src, dst); + assertMatEqual(truth, dst); + + // TODO: needs epsilon comparison + // Mat m = grayRnd_32f.clone(); + // Mat inv = m.inv(); + // Core.gemm(m, inv, 1.0, new Mat(), 0.0, dst); + // assertMatEqual(grayE_32f, dst); + } + + public void testInvertMatMatInt() { + Mat src = Mat.eye(3, 3, CvType.CV_32FC1); + + truth = Mat.eye(3, 3, CvType.CV_32FC1); + + Core.invert(src, dst, Core.DECOMP_CHOLESKY); + assertMatEqual(truth, dst); + + Core.invert(src, dst, Core.DECOMP_LU); + double det = Core.determinant(src); + assertTrue(det > 0.0); + } + + public void testKmeansMatIntMatTermCriteriaIntInt() { + fail("Not yet implemented"); + } + + public void testKmeansMatIntMatTermCriteriaIntIntMat() { + fail("Not yet implemented"); + } + + public void testLineMatPointPointScalar() { + int nPoints = Math.min(gray0.cols(), gray0.rows()); + + Point point1 = new Point(0, 0); + Point point2 = new Point(nPoints, nPoints); + Scalar color = new Scalar(255); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.line(gray0, point1, point2, color); + assertTrue(nPoints == Core.countNonZero(gray0)); + } + + public void testLineMatPointPointScalarInt() { + int nPoints = Math.min(gray0.cols(), gray0.rows()); + + Point point1 = new Point(0, 0); + Point point2 = new Point(nPoints, nPoints); + Scalar color = new Scalar(255); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.line(gray0, point1, point2, color, 0); + assertTrue(nPoints == Core.countNonZero(gray0)); + } + + public void testLineMatPointPointScalarIntInt() { + fail("Not yet implemented"); + } + + public void testLineMatPointPointScalarIntIntInt() { + fail("Not yet implemented"); + } + + public void testLog() { + Mat in = new Mat(1, 4, CvType.CV_32FC1); + Mat desired = new Mat(1, 4, CvType.CV_32FC1); + in.put(0, 0, 1.0, 10.0, 100.0, 1000.0); + desired.put(0, 0, 0, 2.3025851, 4.6051702, 6.9077554); + + Core.log(in, dst); + assertMatEqual(desired, dst); + } + + public void testLUTMatMatMat() { + Mat lut = new Mat(1, 256, CvType.CV_8UC1); + + lut.setTo(new Scalar(0)); + Core.LUT(grayRnd, lut, dst); + assertMatEqual(gray0, dst); + + lut.setTo(new Scalar(255)); + Core.LUT(grayRnd, lut, dst); + assertMatEqual(gray255, dst); + } + + public void testLUTMatMatMatInt() { + Mat lut = new Mat(1, 256, CvType.CV_8UC1); + lut.setTo(new Scalar(255)); + Core.LUT(grayRnd, lut, dst, 0); + assertMatEqual(gray255, dst); + } + + public void testMagnitude() { + Mat x = new Mat(1, 4, CvType.CV_32F); + Mat y = new Mat(1, 4, CvType.CV_32F); + Mat out = new Mat(1, 4, CvType.CV_32F); + + x.put(0, 0, 3.0, 5.0, 9.0, 6.0); + y.put(0, 0, 4.0, 12.0, 40.0, 8.0); + out.put(0, 0, 5.0, 13.0, 41.0, 10.0); + Core.magnitude(x, y, dst); - assertMatEqual(out,dst); - - Core.magnitude(gray0_32f, gray255_32f, dst); - assertMatEqual(gray255_32f, dst); - } - - public void testMahalanobis() { - Mat covar = new Mat(matSize, 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); - covar.inv(); - - Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols()); - Mat line2 = grayRnd_32f.submat(1, 2, 0, grayRnd_32f.cols()); - - double d = 0.0; - d = Core.Mahalanobis(line1, line1, covar); - assertEquals(0.0, d); - - d = Core.Mahalanobis(line1, line2, covar); - assertTrue(d > 0.0); - } - - public void testMax() { - Core.min(gray0, gray255, dst); - assertMatEqual(gray0, dst); - - Mat x = new Mat(1, 1, CvType.CV_32F); - Mat y = new Mat(1, 1, CvType.CV_32F); - Mat dst = new Mat(1, 1, CvType.CV_32F); - x.put(0, 0, 23.0); - y.put(0, 0, 4.0); - dst.put(0, 0, 23.0); - Core.max(x, y, dst); - assertMatEqual(dst, dst); - } - - public void testMeanMat() { - Scalar mean = null; - - mean = Core.mean(gray128); - assertEquals(new Scalar(128), mean); - } - - public void testMeanMatMat() { - fail("Not yet implemented"); - } - - public void testMeanStdDevMatMatMat() { - Mat mean = new Mat(); - Mat stddev = new Mat(); - - Core.meanStdDev(rgba0, mean, stddev); - assertEquals(0, Core.countNonZero(mean)); - assertEquals(0, Core.countNonZero(stddev)); - } - - public void testMeanStdDevMatMatMatMat() { - Mat mean = new Mat(); - Mat stddev = new Mat(); - - Core.meanStdDev(rgba0, mean, stddev, gray255); - assertEquals(0, Core.countNonZero(mean)); - assertEquals(0, Core.countNonZero(stddev)); - - Mat submat = grayRnd.submat(0, grayRnd.rows()/2, 0, grayRnd.cols()/2); - submat.setTo(new Scalar(33)); - - Mat mask = gray0.clone(); - submat = mask.submat(0, mask.rows()/2, 0, mask.cols()/2); - submat.setTo(new Scalar(1)); - - Core.meanStdDev(grayRnd, mean, stddev, mask); - Mat desiredMean = new Mat(1, 1, CvType.CV_64F, new Scalar(33)); - assertMatEqual(desiredMean, mean); - assertEquals(0, Core.countNonZero(stddev)); - - Core.meanStdDev(grayRnd, mean, stddev, gray1); - assertTrue(0 != Core.countNonZero(mean)); - assertTrue(0 != Core.countNonZero(stddev)); - } - - public void testMerge() { - fail("Not yet implemented"); - } - - public void testMin() { - Core.min(gray0, gray255, dst); - assertMatEqual(gray0, dst); - } - - public void testMinMaxLoc() { - double minVal = 1; - double maxVal = 10; - Point minLoc = new Point(gray3.cols()/4, gray3.rows()/2); - Point maxLoc = new Point(gray3.cols()/2, gray3.rows()/4); - gray3.put((int)minLoc.y, (int)minLoc.x, minVal); - gray3.put((int)maxLoc.y, (int)maxLoc.x, maxVal); - - Core.MinMaxLocResult mmres = Core.minMaxLoc(gray3); - - assertTrue(mmres.minVal == minVal); - assertTrue(mmres.maxVal == maxVal); - assertTrue(mmres.minLoc.equals(minLoc)); - assertTrue(mmres.maxLoc.equals(maxLoc)); - } - - - public void testMinMaxLocMat() { - fail("Not yet implemented"); - } - - public void testMinMaxLocMatMat() { - fail("Not yet implemented"); - } - - public void testMixChannels() { - fail("Not yet implemented"); - } - - public void testMulSpectrumsMatMatMatInt() { - Mat src1 = new Mat(1, 4, CvType.CV_32F); - Mat src2 = new Mat(1, 4, CvType.CV_32F); - Mat out = new Mat(1, 4, CvType.CV_32F); - src1.put(0, 0, 1.0, 2.0, 3.0, 4.0); - src2.put(0, 0, 1.0, 2.0, 3.0, 4.0); - out.put(0, 0, 1, -5, 12, 16); - Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS); - assertMatEqual(out, dst); - } - - public void testMulSpectrumsMatMatMatIntBoolean() { - Mat src1 = new Mat(1, 4, CvType.CV_32F); - Mat src2 = new Mat(1, 4, CvType.CV_32F); - Mat out = new Mat(1, 4, CvType.CV_32F); - src1.put(0, 0, 1.0, 2.0, 3.0, 4.0); - src2.put(0, 0, 1.0, 2.0, 3.0, 4.0); - out.put(0, 0, 1, 13, 0, 16); - Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS, true); - assertMatEqual(out, dst); - } - - public void testMultiplyMatMatMat() { - Core.multiply(gray0, gray255, dst); - assertMatEqual(gray0, dst); - } - - public void testMultiplyMatMatMatDouble() { - Core.multiply(gray1, gray0, dst, 2.0); - assertMatEqual(gray0, dst); - - } - - public void testMultiplyMatMatMatDoubleInt() { - Core.multiply(gray1, gray0, dst, 2.0, -1); - assertMatEqual(gray0, dst); - } - - public void testMulTransposedMatMatBoolean() { - Core.mulTransposed(grayE_32f, dst, true); - assertMatEqual(grayE_32f, dst); - } - - public void testMulTransposedMatMatBooleanMat() { - Core.mulTransposed(grayRnd_32f, dst, true, grayRnd_32f); - assertMatEqual(gray0_32f, dst); - - Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F); + assertMatEqual(out, dst); + + Core.magnitude(gray0_32f, gray255_32f, dst); + assertMatEqual(gray255_32f, dst); + } + + public void testMahalanobis() { + Mat covar = new Mat(matSize, 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); + covar.inv(); + + Mat line1 = grayRnd_32f.submat(0, 1, 0, grayRnd_32f.cols()); + Mat line2 = grayRnd_32f.submat(1, 2, 0, grayRnd_32f.cols()); + + double d = 0.0; + d = Core.Mahalanobis(line1, line1, covar); + assertEquals(0.0, d); + + d = Core.Mahalanobis(line1, line2, covar); + assertTrue(d > 0.0); + } + + public void testMax() { + Core.min(gray0, gray255, dst); + assertMatEqual(gray0, dst); + + Mat x = new Mat(1, 1, CvType.CV_32F); + Mat y = new Mat(1, 1, CvType.CV_32F); + Mat dst = new Mat(1, 1, CvType.CV_32F); + x.put(0, 0, 23.0); + y.put(0, 0, 4.0); + dst.put(0, 0, 23.0); + Core.max(x, y, dst); + assertMatEqual(dst, dst); + } + + public void testMeanMat() { + Scalar mean = null; + + mean = Core.mean(gray128); + assertEquals(new Scalar(128), mean); + } + + public void testMeanMatMat() { + fail("Not yet implemented"); + } + + public void testMeanStdDevMatMatMat() { + Mat mean = new Mat(); + Mat stddev = new Mat(); + + Core.meanStdDev(rgba0, mean, stddev); + assertEquals(0, Core.countNonZero(mean)); + assertEquals(0, Core.countNonZero(stddev)); + } + + public void testMeanStdDevMatMatMatMat() { + Mat mean = new Mat(); + Mat stddev = new Mat(); + + Core.meanStdDev(rgba0, mean, stddev, gray255); + assertEquals(0, Core.countNonZero(mean)); + assertEquals(0, Core.countNonZero(stddev)); + + Mat submat = grayRnd.submat(0, grayRnd.rows() / 2, 0, + grayRnd.cols() / 2); + submat.setTo(new Scalar(33)); + + Mat mask = gray0.clone(); + submat = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2); + submat.setTo(new Scalar(1)); + + Core.meanStdDev(grayRnd, mean, stddev, mask); + Mat desiredMean = new Mat(1, 1, CvType.CV_64F, new Scalar(33)); + assertMatEqual(desiredMean, mean); + assertEquals(0, Core.countNonZero(stddev)); + + Core.meanStdDev(grayRnd, mean, stddev, gray1); + assertTrue(0 != Core.countNonZero(mean)); + assertTrue(0 != Core.countNonZero(stddev)); + } + + public void testMerge() { + fail("Not yet implemented"); + } + + public void testMin() { + Core.min(gray0, gray255, dst); + assertMatEqual(gray0, dst); + } + + public void testMinMaxLoc() { + double minVal = 1; + double maxVal = 10; + Point minLoc = new Point(gray3.cols() / 4, gray3.rows() / 2); + Point maxLoc = new Point(gray3.cols() / 2, gray3.rows() / 4); + gray3.put((int) minLoc.y, (int) minLoc.x, minVal); + gray3.put((int) maxLoc.y, (int) maxLoc.x, maxVal); + + Core.MinMaxLocResult mmres = Core.minMaxLoc(gray3); + + assertTrue(mmres.minVal == minVal); + assertTrue(mmres.maxVal == maxVal); + assertTrue(mmres.minLoc.equals(minLoc)); + assertTrue(mmres.maxLoc.equals(maxLoc)); + } + + public void testMinMaxLocMat() { + fail("Not yet implemented"); + } + + public void testMinMaxLocMatMat() { + fail("Not yet implemented"); + } + + public void testMixChannels() { + fail("Not yet implemented"); + } + + public void testMulSpectrumsMatMatMatInt() { + Mat src1 = new Mat(1, 4, CvType.CV_32F); + Mat src2 = new Mat(1, 4, CvType.CV_32F); + Mat out = new Mat(1, 4, CvType.CV_32F); + src1.put(0, 0, 1.0, 2.0, 3.0, 4.0); + src2.put(0, 0, 1.0, 2.0, 3.0, 4.0); + out.put(0, 0, 1, -5, 12, 16); + Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS); + assertMatEqual(out, dst); + } + + public void testMulSpectrumsMatMatMatIntBoolean() { + Mat src1 = new Mat(1, 4, CvType.CV_32F); + Mat src2 = new Mat(1, 4, CvType.CV_32F); + Mat out = new Mat(1, 4, CvType.CV_32F); + src1.put(0, 0, 1.0, 2.0, 3.0, 4.0); + src2.put(0, 0, 1.0, 2.0, 3.0, 4.0); + out.put(0, 0, 1, 13, 0, 16); + Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS, true); + assertMatEqual(out, dst); + } + + public void testMultiplyMatMatMat() { + Core.multiply(gray0, gray255, dst); + assertMatEqual(gray0, dst); + } + + public void testMultiplyMatMatMatDouble() { + Core.multiply(gray1, gray0, dst, 2.0); + assertMatEqual(gray0, dst); + + } + + public void testMultiplyMatMatMatDoubleInt() { + Core.multiply(gray1, gray0, dst, 2.0, -1); + assertMatEqual(gray0, dst); + } + + public void testMulTransposedMatMatBoolean() { + Core.mulTransposed(grayE_32f, dst, true); + assertMatEqual(grayE_32f, dst); + } + + public void testMulTransposedMatMatBooleanMat() { + Core.mulTransposed(grayRnd_32f, dst, true, grayRnd_32f); + assertMatEqual(gray0_32f, dst); + + Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F); grayDelta.setTo(new Scalar(0.0)); - Core.mulTransposed(grayE_32f, dst, true, grayDelta); - assertMatEqual(grayE_32f, dst); - } - - public void testMulTransposedMatMatBooleanMatDouble() { - Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F); - grayDelta.setTo(new Scalar(0.0)); - Core.mulTransposed(grayE_32f, dst, true, grayDelta, 1); - assertMatEqual(grayE_32f, dst); - } - - public void testMulTransposedMatMatBooleanMatDoubleInt() { - Mat a = new Mat(3, 3, CvType.CV_32F); - Mat grayDelta = new Mat(3, 3, CvType.CV_8U); - grayDelta.setTo(new Scalar(0.0001)); - Mat res = new Mat(3, 3, CvType.CV_32F); - a.put(0, 0, 1, 1, 1); - a.put(1, 0, 1, 1, 1); - a.put(2, 0, 1, 1, 1); - res.put(0, 0, 3, 3, 3); - res.put(1, 0, 3, 3, 3); - res.put(2, 0, 3, 3, 3); - - Core.mulTransposed(a, dst, true, grayDelta, 1.0, 1); - assertMatEqual(res, dst); - } - - public void testNormalizeMatMat() { - Core.normalize(gray0, dst); - assertMatEqual(gray0, dst); - } - - public void testNormalizeMatMatDouble() { - Core.normalize(gray0, dst, 0.0); - assertMatEqual(gray0, dst); - } - - public void testNormalizeMatMatDoubleDouble() { - Core.normalize(gray0, dst, 0.0, 1.0); - assertMatEqual(gray0, dst); - } - - public void testNormalizeMatMatDoubleDoubleInt() { - Mat src = new Mat(1, 4, CvType.CV_32F); - Mat out = new Mat(1, 4, CvType.CV_32F); - src.put(0, 0, 1.0, 2.0, 3.0, 4.0); - out.put(0, 0, 0.25, 0.5, 0.75, 1); - Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF); - assertMatEqual(out, dst); - } - - public void testNormalizeMatMatDoubleDoubleIntInt() { - Mat src = new Mat(1, 4, CvType.CV_32F); - Mat out = new Mat(1, 4, CvType.CV_32F); - - src.put(0, 0, 1.0, 2.0, 3.0, 4.0); - out.put(0, 0, 0.25, 0.5, 0.75, 1); - - Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF, -1); - assertMatEqual(out, dst); - } - - public void testNormalizeMatMatDoubleDoubleIntIntMat() { - Mat src = new Mat(1, 4, CvType.CV_32F); - Mat out = new Mat(1, 4, CvType.CV_32F); - Mat mask = new Mat(1, 4, CvType.CV_8U, new Scalar(1)); - - src.put(0, 0, 1.0, 2.0, 3.0, 4.0); - out.put(0, 0, 0.25, 0.5, 0.75, 1); - - Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF, -1, mask); - assertMatEqual(out, dst); - } - - public void testNormMat() { - double n = Core.norm(gray0); - assertTrue(0.0 == n); - } - - public void testNormMatInt() { - double n = Core.norm(gray127, Core.NORM_INF); - assertTrue(127 == n); - } - - public void testNormMatIntMat() { - double n = Core.norm(gray3, Core.NORM_L1, gray0); - assertEquals(0.0, n); - } - - public void testNormMatMat() { - double n = Core.norm(gray255, gray255); - assertEquals(0.0, n); - } - - public void testNormMatMatInt() { - double n = Core.norm(gray127, gray0, Core.NORM_INF); - assertEquals(127.0, n); - } - - public void testNormMatMatIntMat() { - double n = Core.norm(gray3, gray0, Core.NORM_L1, gray0); - assertEquals(0.0, n); - } - - public void testPCABackProject() { - fail("Not yet implemented"); - } - - public void testPCAComputeMatMatMat() { - fail("Not yet implemented"); - } - - public void testPCAComputeMatMatMatInt() { - fail("Not yet implemented"); - } - - public void testPCAProject() { - fail("Not yet implemented"); - } - - public void testPerspectiveTransform() { - //nice example - fail("Not yet implemented"); - } - - public void testPhaseMatMatMat() { - Mat x = new Mat(1, 4, CvType.CV_32F); - Mat y = new Mat(1, 4, CvType.CV_32F); - Mat res = new Mat(1, 4, CvType.CV_32F); - - x.put(0, 0, 10.0, 10.0, 20.0, 5.0); - y.put(0, 0, 20.0, 15.0, 20.0, 20.0); - res.put(0, 0, 1.1071469, 0.98280007, 0.78539175, 1.3258134); - - Core.phase(x, y, dst); - assertMatEqual(res, dst); - } - - public void testPhaseMatMatMatBoolean() { - Mat x = new Mat(1, 4, CvType.CV_32F); - Mat y = new Mat(1, 4, CvType.CV_32F); - Mat res = new Mat(1, 4, CvType.CV_32F); - - x.put(0, 0, 10.0, 10.0, 20.0, 5.0); - y.put(0, 0, 20.0, 15.0, 20.0, 20.0); - res.put(0, 0, 63.434, 56.310, 44.999, 75.963); - - Core.phase(x, y, dst, true); - } - - public void testPolarToCartMatMatMatMat() { - Mat magnitude = new Mat(1, 3, CvType.CV_32F); - Mat angle = new Mat(1, 3, CvType.CV_32F); - Mat x = new Mat(1, 3, CvType.CV_32F); - Mat y = new Mat(1, 3, CvType.CV_32F); - Mat xCoordinate = new Mat(); - Mat yCoordinate = new Mat(); - -// x.put(0, 0, 3.0, 6.0, 5,0); -// y.put(0, 0, 4.0, 8.0, 12.0); -// magnitude.put(0, 0, 5.0, 10.0, 13.0); -// angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); - - magnitude.put(0, 0, 5.0, 10.0, 13.0); - angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); - - x.put(0, 0, 3.0, 6.0, 5,0); - y.put(0, 0, 4.0, 8.0, 12.0); - - //TODO: needs epsilon comparison - Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate); - assertMatEqual(x, xCoordinate); - } - - public void testPolarToCartMatMatMatMatBoolean() { - fail("Not yet implemented"); - } - - public void testPolylinesMatListOfMatBooleanScalar() { - fail("Not yet implemented"); - } - - public void testPolylinesMatListOfMatBooleanScalarInt() { - fail("Not yet implemented"); - } - - public void testPolylinesMatListOfMatBooleanScalarIntInt() { - fail("Not yet implemented"); - } - - public void testPolylinesMatListOfMatBooleanScalarIntIntInt() { - fail("Not yet implemented"); - } - - public void testPow() { - Core.pow(gray3, 2.0, dst); - assertMatEqual(gray9, dst); - } - - public void testPutTextMatStringPointIntDoubleScalar() { - fail("Not yet implemented"); - } - - public void testPutTextMatStringPointIntDoubleScalarInt() { - fail("Not yet implemented"); - } - - public void testPutTextMatStringPointIntDoubleScalarIntInt() { - fail("Not yet implemented"); - } - - public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() { - fail("Not yet implemented"); - } - - public void testRandn() { - Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); + Core.mulTransposed(grayE_32f, dst, true, grayDelta); + assertMatEqual(grayE_32f, dst); + } + + public void testMulTransposedMatMatBooleanMatDouble() { + Mat grayDelta = new Mat(matSize, matSize, CvType.CV_32F); + grayDelta.setTo(new Scalar(0.0)); + Core.mulTransposed(grayE_32f, dst, true, grayDelta, 1); + assertMatEqual(grayE_32f, dst); + } + + public void testMulTransposedMatMatBooleanMatDoubleInt() { + Mat a = new Mat(3, 3, CvType.CV_32F); + Mat grayDelta = new Mat(3, 3, CvType.CV_8U); + grayDelta.setTo(new Scalar(0.0001)); + Mat res = new Mat(3, 3, CvType.CV_32F); + a.put(0, 0, 1, 1, 1); + a.put(1, 0, 1, 1, 1); + a.put(2, 0, 1, 1, 1); + res.put(0, 0, 3, 3, 3); + res.put(1, 0, 3, 3, 3); + res.put(2, 0, 3, 3, 3); + + Core.mulTransposed(a, dst, true, grayDelta, 1.0, 1); + assertMatEqual(res, dst); + } + + public void testNormalizeMatMat() { + Core.normalize(gray0, dst); + assertMatEqual(gray0, dst); + } + + public void testNormalizeMatMatDouble() { + Core.normalize(gray0, dst, 0.0); + assertMatEqual(gray0, dst); + } + + public void testNormalizeMatMatDoubleDouble() { + Core.normalize(gray0, dst, 0.0, 1.0); + assertMatEqual(gray0, dst); + } + + public void testNormalizeMatMatDoubleDoubleInt() { + Mat src = new Mat(1, 4, CvType.CV_32F); + Mat out = new Mat(1, 4, CvType.CV_32F); + src.put(0, 0, 1.0, 2.0, 3.0, 4.0); + out.put(0, 0, 0.25, 0.5, 0.75, 1); + Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF); + assertMatEqual(out, dst); + } + + public void testNormalizeMatMatDoubleDoubleIntInt() { + Mat src = new Mat(1, 4, CvType.CV_32F); + Mat out = new Mat(1, 4, CvType.CV_32F); + + src.put(0, 0, 1.0, 2.0, 3.0, 4.0); + out.put(0, 0, 0.25, 0.5, 0.75, 1); + + Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF, -1); + assertMatEqual(out, dst); + } + + public void testNormalizeMatMatDoubleDoubleIntIntMat() { + Mat src = new Mat(1, 4, CvType.CV_32F); + Mat out = new Mat(1, 4, CvType.CV_32F); + Mat mask = new Mat(1, 4, CvType.CV_8U, new Scalar(1)); + + src.put(0, 0, 1.0, 2.0, 3.0, 4.0); + out.put(0, 0, 0.25, 0.5, 0.75, 1); + + Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF, -1, mask); + assertMatEqual(out, dst); + } + + public void testNormMat() { + double n = Core.norm(gray0); + assertTrue(0.0 == n); + } + + public void testNormMatInt() { + double n = Core.norm(gray127, Core.NORM_INF); + assertTrue(127 == n); + } + + public void testNormMatIntMat() { + double n = Core.norm(gray3, Core.NORM_L1, gray0); + assertEquals(0.0, n); + } + + public void testNormMatMat() { + double n = Core.norm(gray255, gray255); + assertEquals(0.0, n); + } + + public void testNormMatMatInt() { + double n = Core.norm(gray127, gray0, Core.NORM_INF); + assertEquals(127.0, n); + } + + public void testNormMatMatIntMat() { + double n = Core.norm(gray3, gray0, Core.NORM_L1, gray0); + assertEquals(0.0, n); + } + + public void testPCABackProject() { + fail("Not yet implemented"); + } + + public void testPCAComputeMatMatMat() { + fail("Not yet implemented"); + } + + public void testPCAComputeMatMatMatInt() { + fail("Not yet implemented"); + } + + public void testPCAProject() { + fail("Not yet implemented"); + } + + public void testPerspectiveTransform() { + // nice example + fail("Not yet implemented"); + } + + public void testPhaseMatMatMat() { + Mat x = new Mat(1, 4, CvType.CV_32F); + Mat y = new Mat(1, 4, CvType.CV_32F); + Mat res = new Mat(1, 4, CvType.CV_32F); + + x.put(0, 0, 10.0, 10.0, 20.0, 5.0); + y.put(0, 0, 20.0, 15.0, 20.0, 20.0); + res.put(0, 0, 1.1071469, 0.98280007, 0.78539175, 1.3258134); + + Core.phase(x, y, dst); + assertMatEqual(res, dst); + } + + public void testPhaseMatMatMatBoolean() { + Mat x = new Mat(1, 4, CvType.CV_32F); + Mat y = new Mat(1, 4, CvType.CV_32F); + Mat res = new Mat(1, 4, CvType.CV_32F); + + x.put(0, 0, 10.0, 10.0, 20.0, 5.0); + y.put(0, 0, 20.0, 15.0, 20.0, 20.0); + res.put(0, 0, 63.434, 56.310, 44.999, 75.963); + + Core.phase(x, y, dst, true); + } + + public void testPolarToCartMatMatMatMat() { + Mat magnitude = new Mat(1, 3, CvType.CV_32F); + Mat angle = new Mat(1, 3, CvType.CV_32F); + Mat x = new Mat(1, 3, CvType.CV_32F); + Mat y = new Mat(1, 3, CvType.CV_32F); + Mat xCoordinate = new Mat(); + Mat yCoordinate = new Mat(); + + // x.put(0, 0, 3.0, 6.0, 5,0); + // y.put(0, 0, 4.0, 8.0, 12.0); + // magnitude.put(0, 0, 5.0, 10.0, 13.0); + // angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); + + magnitude.put(0, 0, 5.0, 10.0, 13.0); + angle.put(0, 0, 0.92729962, 0.92729962, 1.1759995); + + x.put(0, 0, 3.0, 6.0, 5, 0); + y.put(0, 0, 4.0, 8.0, 12.0); + + // TODO: needs epsilon comparison + Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate); + assertMatEqual(x, xCoordinate); + } + + public void testPolarToCartMatMatMatMatBoolean() { + fail("Not yet implemented"); + } + + public void testPolylinesMatListOfMatBooleanScalar() { + fail("Not yet implemented"); + } + + public void testPolylinesMatListOfMatBooleanScalarInt() { + fail("Not yet implemented"); + } + + public void testPolylinesMatListOfMatBooleanScalarIntInt() { + fail("Not yet implemented"); + } + + public void testPolylinesMatListOfMatBooleanScalarIntIntInt() { + fail("Not yet implemented"); + } + + public void testPow() { + Core.pow(gray3, 2.0, dst); + assertMatEqual(gray9, dst); + } + + public void testPutTextMatStringPointIntDoubleScalar() { + fail("Not yet implemented"); + } + + public void testPutTextMatStringPointIntDoubleScalarInt() { + fail("Not yet implemented"); + } + + public void testPutTextMatStringPointIntDoubleScalarIntInt() { + fail("Not yet implemented"); + } + + public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() { + fail("Not yet implemented"); + } + + public void testRandn() { + Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256)); - + assertTrue(0 == Core.countNonZero(gray0)); Core.randn(gray0, low, high); - assertTrue(0 != Core.countNonZero(gray0)); - } + assertTrue(0 != Core.countNonZero(gray0)); + } - public void testRandShuffleMat() { - fail("Not yet implemented"); - } + public void testRandShuffleMat() { + fail("Not yet implemented"); + } - public void testRandShuffleMatDouble() { - fail("Not yet implemented"); - } + public void testRandShuffleMatDouble() { + fail("Not yet implemented"); + } - public void testRandu() { - Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); + public void testRandu() { + Mat low = new Mat(1, 1, CvType.CV_16UC1, new Scalar(0)); Mat high = new Mat(1, 1, CvType.CV_16UC1, new Scalar(256)); - + assertTrue(0 == Core.countNonZero(gray0)); Core.randu(gray0, low, high); assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testRectangleMatPointPointScalar() { - Point center = new Point(gray0.cols()/2, gray0.rows()/2); - Point origin = new Point(0,0); - Scalar color = new Scalar(128); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.rectangle(gray0, center, origin, color); - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testRectangleMatPointPointScalarInt() { - Point center = new Point(gray0.cols(), gray0.rows()); - Point origin = new Point(0,0); - Scalar color = new Scalar(128); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.rectangle(gray0, center, origin, color, 2); - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testRectangleMatPointPointScalarIntInt() { - Point center = new Point(gray0.cols()/2, gray0.rows()/2); - Point origin = new Point(0,0); - Scalar color = new Scalar(128); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.rectangle(gray0, center, origin, color, 2, 8); - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testRectangleMatPointPointScalarIntIntInt() { - Point center = new Point(gray0.cols(), gray0.rows()); - Point origin = new Point(0,0); - Scalar color = new Scalar(128); - - assertTrue(0 == Core.countNonZero(gray0)); - Core.rectangle(gray0, center, origin, color, 2, 4, 2); - assertTrue(0 != Core.countNonZero(gray0)); - } - - public void testReduceMatMatIntInt() { - Mat src = new Mat(2, 2, CvType.CV_32F); - Mat out = new Mat(1, 2, CvType.CV_32F); - src.put(0, 0, 1 , 0); - src.put(1, 0, 1 , 0); - - out.put(0 , 0, 1, 0); - + } + + public void testRectangleMatPointPointScalar() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + Point origin = new Point(0, 0); + Scalar color = new Scalar(128); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.rectangle(gray0, center, origin, color); + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testRectangleMatPointPointScalarInt() { + Point center = new Point(gray0.cols(), gray0.rows()); + Point origin = new Point(0, 0); + Scalar color = new Scalar(128); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.rectangle(gray0, center, origin, color, 2); + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testRectangleMatPointPointScalarIntInt() { + Point center = new Point(gray0.cols() / 2, gray0.rows() / 2); + Point origin = new Point(0, 0); + Scalar color = new Scalar(128); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.rectangle(gray0, center, origin, color, 2, 8); + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testRectangleMatPointPointScalarIntIntInt() { + Point center = new Point(gray0.cols(), gray0.rows()); + Point origin = new Point(0, 0); + Scalar color = new Scalar(128); + + assertTrue(0 == Core.countNonZero(gray0)); + Core.rectangle(gray0, center, origin, color, 2, 4, 2); + assertTrue(0 != Core.countNonZero(gray0)); + } + + public void testReduceMatMatIntInt() { + Mat src = new Mat(2, 2, CvType.CV_32F); + Mat out = new Mat(1, 2, CvType.CV_32F); + src.put(0, 0, 1, 0); + src.put(1, 0, 1, 0); + + out.put(0, 0, 1, 0); + Core.reduce(src, dst, 0, 2); assertMatEqual(out, dst); - } - - public void testReduceMatMatIntIntInt() { - Mat src = new Mat(2, 2, CvType.CV_32F); - Mat out = new Mat(1, 2, CvType.CV_32F); - src.put(0, 0, 1 , 0); - src.put(1, 0, 1 , 0); - - out.put(0 , 0, 1, 0); - + } + + public void testReduceMatMatIntIntInt() { + Mat src = new Mat(2, 2, CvType.CV_32F); + Mat out = new Mat(1, 2, CvType.CV_32F); + src.put(0, 0, 1, 0); + src.put(1, 0, 1, 0); + + out.put(0, 0, 1, 0); + Core.reduce(src, dst, 0, 2, -1); assertMatEqual(out, dst); - } - - public void testRepeat() { - Mat src = new Mat(1, 3, CvType.CV_32F); - Mat des1 = new Mat(1, 3, CvType.CV_32F); - Mat des2 = new Mat(1, 6, CvType.CV_32F); - src.put(0, 0, 1, 2, 3); - - des1.put(0, 0, 1, 2, 3); - des2.put(0, 0, 1, 2, 3, 1, 2, 3); - - Core.repeat(src, 1, 1, dst); - assertMatEqual(des1, dst); - Core.repeat(src, 1, 2, dst); - assertMatEqual(des2, dst); - } - - public void testScaleAdd() { - Core.scaleAdd(gray3, 2.0, gray3, dst); - assertMatEqual(dst, gray9); - } - - public void testSetIdentityMat() { - Core.setIdentity(gray0_32f); - assertMatEqual(grayE_32f, gray0_32f); - } - - public void testSetIdentityMatScalar() { - Core.gemm(grayE_32f, grayE_32f, 5.0, new Mat(), 0.0, dst); - Core.setIdentity(gray0_32f, new Scalar(5)); - assertMatEqual(dst, gray0_32f); - } - - public void testSolveCubic() { - Mat coeffs = new Mat(1, 4, CvType.CV_32F); - Mat roots = new Mat(3, 1, CvType.CV_32F); - coeffs.put(0, 0, 1, 6, 11, 6); - roots.put(0, 0, -3, -1, -2); - Core.solveCubic(coeffs, dst); - assertMatEqual(roots, dst); - } - - public void testSolveMatMatMat() { - Mat a = new Mat(3, 3, CvType.CV_32F); - Mat b = new Mat(3, 1, CvType.CV_32F); - Mat res = new Mat(3, 1, CvType.CV_32F); - a.put(0, 0, 1, 1, 1); - a.put(1, 0, 1, -2, 2); - a.put(2, 0, 1, 2, 1); - - b.put(0, 0, 0, 4, 2); - res.put(0, 0, -12, 2, 10); - - Core.solve(a, b, dst); - assertMatEqual(res, dst); - } - - public void testSolveMatMatMatInt() { - Mat a = new Mat(3, 3, CvType.CV_32F); - Mat b = new Mat(3, 1, CvType.CV_32F); - Mat res = new Mat(3, 1, CvType.CV_32F); - - a.put(0, 0, 1, 1, 1); - a.put(1, 0, 1, -2, 2); - a.put(2, 0, 1, 2, 1); - - b.put(0, 0, 0, 4, 2); - res.put(0, 0, -12, 2, 10); - - Core.solve(a, b, dst, 3); - assertMatEqual(res, dst); - } - - public void testSolvePolyMatMat() { - Mat coeffs = new Mat(4, 1, CvType.CV_32F); - Mat roots = new Mat(3, 1, CvType.CV_32F); - - coeffs.put(0, 0, -6, 11, -6, 1); - - truth = new Mat(3, 1, CvType.CV_32FC2); - truth.put(0, 0, 1, 0, 2, 0, 3, 0); - - Core.solvePoly(coeffs, roots); - assertMatEqual(truth, roots); - } - - public void testSolvePolyMatMatInt() { - Mat coeffs = new Mat(4, 1, CvType.CV_32F); - Mat roots = new Mat(3, 1, CvType.CV_32F); - - coeffs.put(0, 0, -6, 11, -6, 1); - - truth = new Mat(3, 1, CvType.CV_32FC2); - truth.put(0, 0, 1, 0, -1, 2, -2, 12); - - Core.solvePoly(coeffs, roots, 1); - assertMatEqual(truth, roots); - } - - public void testSort() { - Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2); - submat.setTo(new Scalar(1.0)); - - Core.sort(gray0, dst, 0/*TODO: CV_SORT_EVERY_ROW*/); - submat = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols()); - assertTrue(submat.total() == Core.countNonZero(submat)); - - Core.sort(gray0, dst, 1/*TODO: CV_SORT_EVERY_COLUMN*/); - submat = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2); - assertTrue(submat.total() == Core.countNonZero(submat)); - } - - public void testSortIdx() { - Mat a = Mat.eye(3, 3, CvType.CV_8UC1); - Mat b = new Mat(); - - truth = new Mat(3, 3, CvType.CV_32SC1); - truth.put(0, 0, 1, 2, 0); - truth.put(1, 0, 0, 2, 1); - truth.put(2, 0, 0, 1, 2); - - Core.sortIdx(a, b, 0+0/*TODO: CV_SORT_EVERY_ROW + CV_SORT_ASCENDING*/); - assertMatEqual(truth, b); - } - - public void testSplit() { - ArrayList cois = new ArrayList(); - Core.split(rgba0, cois); - for(Mat coi : cois) { - assertMatEqual(gray0, coi); - } - } - - public void testSqrt() { - Core.sqrt(gray9_32f, dst); - assertMatEqual(gray3_32f, dst); - - Mat rgba144 = new Mat(matSize, matSize, CvType.CV_32FC4); - Mat rgba12 = new Mat(matSize, matSize, CvType.CV_32FC4); - rgba144.setTo(Scalar.all(144)); - rgba12.setTo(Scalar.all(12)); - - Core.sqrt(rgba144, dst); - assertMatEqual(rgba12, dst); - } - - public void testSubtractMatMatMat() { - Core.subtract(gray128, gray1, dst); - assertMatEqual(gray127, dst); - } - - public void testSubtractMatMatMatMat() { - Mat mask = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0)); - Mat submask = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2); - submask.setTo(new Scalar(1)); - - dst = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0)); - Core.subtract(gray3, gray2, dst, mask); - assertTrue(submask.total() == Core.countNonZero(dst)); - } - - public void testSubtractMatMatMatMatInt() { - Core.subtract(gray3, gray2, dst, gray1, CvType.CV_32F); - assertTrue(CvType.CV_32F == dst.depth()); - assertMatEqual(gray1_32f, dst); - } - - public void testSumElems() { - fail("Not yet implemented"); - } - - public void testSVBackSubst() { - fail("Not yet implemented"); - } - - public void testSVDecompMatMatMatMat() { - fail("Not yet implemented"); - } - - public void testSVDecompMatMatMatMatInt() { - fail("Not yet implemented"); - } - - public void testTrace() { - fail("Not yet implemented"); - } - - public void testTransform() { - Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(55)); - Mat m = Mat.eye(2, 2, CvType.CV_32FC1); - - Core.transform(src, dst, m); - truth = new Mat(2, 2, CvType.CV_32FC2, new Scalar(55, 1)); - assertMatEqual(truth, dst); - } - - public void testTranspose() { - 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 subdst = destination.submat(0, destination.rows(), 0, destination.cols() / 2); - subgray0.setTo(new Scalar(1)); - Core.transpose(gray0, destination); - assertTrue(subdst.total() == Core.countNonZero(subdst)); - } + } + + public void testRepeat() { + Mat src = new Mat(1, 3, CvType.CV_32F); + Mat des1 = new Mat(1, 3, CvType.CV_32F); + Mat des2 = new Mat(1, 6, CvType.CV_32F); + src.put(0, 0, 1, 2, 3); + + des1.put(0, 0, 1, 2, 3); + des2.put(0, 0, 1, 2, 3, 1, 2, 3); + + Core.repeat(src, 1, 1, dst); + assertMatEqual(des1, dst); + Core.repeat(src, 1, 2, dst); + assertMatEqual(des2, dst); + } + + public void testScaleAdd() { + Core.scaleAdd(gray3, 2.0, gray3, dst); + assertMatEqual(dst, gray9); + } + + public void testSetIdentityMat() { + Core.setIdentity(gray0_32f); + assertMatEqual(grayE_32f, gray0_32f); + } + + public void testSetIdentityMatScalar() { + Core.gemm(grayE_32f, grayE_32f, 5.0, new Mat(), 0.0, dst); + Core.setIdentity(gray0_32f, new Scalar(5)); + assertMatEqual(dst, gray0_32f); + } + + public void testSolveCubic() { + Mat coeffs = new Mat(1, 4, CvType.CV_32F); + Mat roots = new Mat(3, 1, CvType.CV_32F); + coeffs.put(0, 0, 1, 6, 11, 6); + roots.put(0, 0, -3, -1, -2); + Core.solveCubic(coeffs, dst); + assertMatEqual(roots, dst); + } + + public void testSolveMatMatMat() { + Mat a = new Mat(3, 3, CvType.CV_32F); + Mat b = new Mat(3, 1, CvType.CV_32F); + Mat res = new Mat(3, 1, CvType.CV_32F); + a.put(0, 0, 1, 1, 1); + a.put(1, 0, 1, -2, 2); + a.put(2, 0, 1, 2, 1); + + b.put(0, 0, 0, 4, 2); + res.put(0, 0, -12, 2, 10); + + Core.solve(a, b, dst); + assertMatEqual(res, dst); + } + + public void testSolveMatMatMatInt() { + Mat a = new Mat(3, 3, CvType.CV_32F); + Mat b = new Mat(3, 1, CvType.CV_32F); + Mat res = new Mat(3, 1, CvType.CV_32F); + + a.put(0, 0, 1, 1, 1); + a.put(1, 0, 1, -2, 2); + a.put(2, 0, 1, 2, 1); + + b.put(0, 0, 0, 4, 2); + res.put(0, 0, -12, 2, 10); + + Core.solve(a, b, dst, 3); + assertMatEqual(res, dst); + } + + public void testSolvePolyMatMat() { + Mat coeffs = new Mat(4, 1, CvType.CV_32F); + Mat roots = new Mat(3, 1, CvType.CV_32F); + + coeffs.put(0, 0, -6, 11, -6, 1); + + truth = new Mat(3, 1, CvType.CV_32FC2); + truth.put(0, 0, 1, 0, 2, 0, 3, 0); + + Core.solvePoly(coeffs, roots); + assertMatEqual(truth, roots); + } + + public void testSolvePolyMatMatInt() { + Mat coeffs = new Mat(4, 1, CvType.CV_32F); + Mat roots = new Mat(3, 1, CvType.CV_32F); + + coeffs.put(0, 0, -6, 11, -6, 1); + + truth = new Mat(3, 1, CvType.CV_32FC2); + truth.put(0, 0, 1, 0, -1, 2, -2, 12); + + Core.solvePoly(coeffs, roots, 1); + assertMatEqual(truth, roots); + } + + public void testSort() { + Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2); + submat.setTo(new Scalar(1.0)); + + Core.sort(gray0, dst, 0/* TODO: CV_SORT_EVERY_ROW */); + submat = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols()); + assertTrue(submat.total() == Core.countNonZero(submat)); + + Core.sort(gray0, dst, 1/* TODO: CV_SORT_EVERY_COLUMN */); + submat = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2); + assertTrue(submat.total() == Core.countNonZero(submat)); + } + + public void testSortIdx() { + Mat a = Mat.eye(3, 3, CvType.CV_8UC1); + Mat b = new Mat(); + + truth = new Mat(3, 3, CvType.CV_32SC1); + truth.put(0, 0, 1, 2, 0); + truth.put(1, 0, 0, 2, 1); + truth.put(2, 0, 0, 1, 2); + + Core.sortIdx(a, b, 0 + 0/* TODO: CV_SORT_EVERY_ROW + CV_SORT_ASCENDING */); + assertMatEqual(truth, b); + } + + public void testSplit() { + ArrayList cois = new ArrayList(); + Core.split(rgba0, cois); + for (Mat coi : cois) { + assertMatEqual(gray0, coi); + } + } + + public void testSqrt() { + Core.sqrt(gray9_32f, dst); + assertMatEqual(gray3_32f, dst); + + Mat rgba144 = new Mat(matSize, matSize, CvType.CV_32FC4); + Mat rgba12 = new Mat(matSize, matSize, CvType.CV_32FC4); + rgba144.setTo(Scalar.all(144)); + rgba12.setTo(Scalar.all(12)); + + Core.sqrt(rgba144, dst); + assertMatEqual(rgba12, dst); + } + + public void testSubtractMatMatMat() { + Core.subtract(gray128, gray1, dst); + assertMatEqual(gray127, dst); + } + + public void testSubtractMatMatMatMat() { + Mat mask = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0)); + Mat submask = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2); + submask.setTo(new Scalar(1)); + + dst = new Mat(matSize, matSize, CvType.CV_8U, new Scalar(0)); + Core.subtract(gray3, gray2, dst, mask); + assertTrue(submask.total() == Core.countNonZero(dst)); + } + + public void testSubtractMatMatMatMatInt() { + Core.subtract(gray3, gray2, dst, gray1, CvType.CV_32F); + assertTrue(CvType.CV_32F == dst.depth()); + assertMatEqual(gray1_32f, dst); + } + + public void testSumElems() { + fail("Not yet implemented"); + } + + public void testSVBackSubst() { + fail("Not yet implemented"); + } + + public void testSVDecompMatMatMatMat() { + fail("Not yet implemented"); + } + + public void testSVDecompMatMatMatMatInt() { + fail("Not yet implemented"); + } + + public void testTrace() { + fail("Not yet implemented"); + } + + public void testTransform() { + Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(55)); + Mat m = Mat.eye(2, 2, CvType.CV_32FC1); + + Core.transform(src, dst, m); + truth = new Mat(2, 2, CvType.CV_32FC2, new Scalar(55, 1)); + assertMatEqual(truth, dst); + } + + public void testTranspose() { + 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 subdst = destination.submat(0, destination.rows(), 0, + destination.cols() / 2); + subgray0.setTo(new Scalar(1)); + Core.transpose(gray0, destination); + assertTrue(subdst.total() == Core.countNonZero(subdst)); + } } -- 2.7.4