1 package org.opencv.test.core;
3 import java.util.ArrayList;
4 import java.util.Arrays;
7 import org.opencv.core.Core;
8 import org.opencv.core.Core.MinMaxLocResult;
9 import org.opencv.core.CvException;
10 import org.opencv.core.CvType;
11 import org.opencv.core.Mat;
12 import org.opencv.core.MatOfDouble;
13 import org.opencv.core.MatOfInt;
14 import org.opencv.core.MatOfPoint;
15 import org.opencv.core.Point;
16 import org.opencv.core.Rect;
17 import org.opencv.core.RotatedRect;
18 import org.opencv.core.Scalar;
19 import org.opencv.core.Size;
20 import org.opencv.core.TermCriteria;
21 import org.opencv.test.OpenCVTestCase;
23 public class CoreTest extends OpenCVTestCase {
25 public void testAbsdiff() {
26 Core.absdiff(gray128, gray255, dst);
28 assertMatEqual(gray127, dst);
31 public void testAddMatMatMat() {
32 Core.add(gray128, gray128, dst);
34 assertMatEqual(gray255, dst);
37 public void testAddMatMatMatMatInt() {
38 Core.add(gray0, gray1, dst, gray1, CvType.CV_32F);
40 assertEquals(CvType.CV_32F, dst.depth());
41 assertMatEqual(gray1_32f, dst, EPS);
44 public void testAddWeightedMatDoubleMatDoubleDoubleMat() {
45 Core.addWeighted(gray1, 120.0, gray127, 1.0, 10.0, dst);
47 assertMatEqual(gray255, dst);
50 public void testAddWeightedMatDoubleMatDoubleDoubleMatInt() {
51 Core.addWeighted(gray1, 126.0, gray127, 1.0, 2.0, dst, CvType.CV_32F);
53 assertEquals(CvType.CV_32F, dst.depth());
54 assertMatEqual(gray255_32f, dst, EPS);
57 public void testBitwise_andMatMatMat() {
58 Core.bitwise_and(gray127, gray3, dst);
60 assertMatEqual(gray3, dst);
63 public void testBitwise_andMatMatMatMat() {
64 Core.bitwise_and(gray3, gray1, dst, gray255);
66 assertMatEqual(gray1, dst);
69 public void testBitwise_notMatMat() {
70 Core.bitwise_not(gray255, dst);
72 assertMatEqual(gray0, dst);
75 public void testBitwise_notMatMatMat() {
76 Core.bitwise_not(gray0, dst, gray1);
78 assertMatEqual(gray255, dst);
81 public void testBitwise_orMatMatMat() {
82 Core.bitwise_or(gray1, gray2, dst);
84 assertMatEqual(gray3, dst);
87 public void testBitwise_orMatMatMatMat() {
88 Core.bitwise_or(gray127, gray3, dst, gray255);
90 assertMatEqual(gray127, dst);
93 public void testBitwise_xorMatMatMat() {
94 Core.bitwise_xor(gray3, gray2, dst);
96 assertMatEqual(gray1, dst);
99 public void testBitwise_xorMatMatMatMat() {
100 Core.bitwise_or(gray127, gray128, dst, gray255);
102 assertMatEqual(gray255, dst);
105 public void testCalcCovarMatrixMatMatMatInt() {
106 Mat covar = new Mat(matSize, matSize, CvType.CV_64FC1);
107 Mat mean = new Mat(1, matSize, CvType.CV_64FC1);
109 Core.calcCovarMatrix(gray0_32f, covar, mean, Core.COVAR_ROWS | Core.COVAR_NORMAL);
111 assertMatEqual(gray0_64f, covar, EPS);
112 assertMatEqual(gray0_64f_1d, mean, EPS);
115 public void testCalcCovarMatrixMatMatMatIntInt() {
116 Mat covar = new Mat(matSize, matSize, CvType.CV_32F);
117 Mat mean = new Mat(1, matSize, CvType.CV_32F);
119 Core.calcCovarMatrix(gray0_32f, covar, mean, Core.COVAR_ROWS | Core.COVAR_NORMAL, CvType.CV_32F);
121 assertMatEqual(gray0_32f, covar, EPS);
122 assertMatEqual(gray0_32f_1d, mean, EPS);
125 public void testCartToPolarMatMatMatMat() {
126 Mat x = new Mat(1, 3, CvType.CV_32F) {
128 put(0, 0, 3.0, 6.0, 5, 0);
131 Mat y = new Mat(1, 3, CvType.CV_32F) {
133 put(0, 0, 4.0, 8.0, 12.0);
136 Mat dst_angle = new Mat();
138 Core.cartToPolar(x, y, dst, dst_angle);
140 Mat expected_magnitude = new Mat(1, 3, CvType.CV_32F) {
142 put(0, 0, 5.0, 10.0, 13.0);
145 Mat expected_angle = new Mat(1, 3, CvType.CV_32F) {
147 put(0, 0, atan2rad(4,3), atan2rad(8,6), atan2rad(12,5));
150 assertMatEqual(expected_magnitude, dst, EPS);
151 assertMatEqual(expected_angle, dst_angle, EPS);
154 public void testCartToPolarMatMatMatMatBoolean() {
155 Mat x = new Mat(1, 3, CvType.CV_32F) {
157 put(0, 0, 3.0, 6.0, 5, 0);
160 Mat y = new Mat(1, 3, CvType.CV_32F) {
162 put(0, 0, 4.0, 8.0, 12.0);
165 Mat dst_angle = new Mat();
167 Core.cartToPolar(x, y, dst, dst_angle, true);
169 Mat expected_magnitude = new Mat(1, 3, CvType.CV_32F) {
171 put(0, 0, 5.0, 10.0, 13.0);
174 Mat expected_angle = new Mat(1, 3, CvType.CV_32F) {
176 put(0, 0, atan2deg(4,3), atan2deg(8,6), atan2deg(12,5));
179 assertMatEqual(expected_magnitude, dst, EPS);
180 assertMatEqual(expected_angle, dst_angle, EPS * 180/Math.PI);
184 public void testCheckRangeMat() {
185 Mat outOfRange = new Mat(2, 2, CvType.CV_64F);
186 outOfRange.put(0, 0, Double.NaN, Double.NEGATIVE_INFINITY, Double.POSITIVE_INFINITY, 0);
188 assertTrue(Core.checkRange(grayRnd_32f));
189 assertTrue(Core.checkRange(new Mat()));
190 assertFalse(Core.checkRange(outOfRange));
194 public void testCheckRangeMatBooleanPointDoubleDouble() {
195 Mat inRange = new Mat(2, 3, CvType.CV_64F) {
197 put(0, 0, 14, 48, 76, 33, 5, 99);
201 assertTrue(Core.checkRange(inRange, true, 5, 100));
203 Mat outOfRange = new Mat(2, 3, CvType.CV_64F) {
205 put(0, 0, -4, 0, 6, 33, 4, 109);
209 assertFalse(Core.checkRange(outOfRange, true, 5, 100));
212 public void testCircleMatPointIntScalar() {
213 Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
214 int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4);
215 Scalar color = new Scalar(128);
217 Core.circle(gray0, center, radius, color);
219 assertTrue(0 != Core.countNonZero(gray0));
222 public void testCircleMatPointIntScalarInt() {
223 Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
224 int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4);
225 Scalar color = new Scalar(128);
227 Core.circle(gray0, center, radius, color, Core.FILLED);
229 assertTrue(0 != Core.countNonZero(gray0));
232 public void testCircleMatPointIntScalarIntIntInt() {
233 Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
234 Point center2 = new Point(gray0.cols(), gray0.rows());
235 int radius = Math.min(gray0.cols() / 4, gray0.rows() / 4);
236 Scalar color128 = new Scalar(128);
237 Scalar color0 = new Scalar(0);
239 Core.circle(gray0, center2, radius * 2, color128, 2, Core.LINE_4, 1/*
245 assertFalse(0 == Core.countNonZero(gray0));
247 Core.circle(gray0, center, radius, color0, 2, Core.LINE_4, 0);
249 assertTrue(0 == Core.countNonZero(gray0));
252 public void testClipLine() {
253 Rect r = new Rect(10, 10, 10, 10);
254 Point pt1 = new Point(5.0, 15.0);
255 Point pt2 = new Point(25.0, 15.0);
257 assertTrue(Core.clipLine(r, pt1, pt2));
259 Point pt1Clipped = new Point(10.0, 15.0);
260 Point pt2Clipped = new Point(19.0, 15.0);
261 assertEquals(pt1Clipped, pt1);
262 assertEquals(pt2Clipped, pt2);
264 pt1 = new Point(5.0, 5.0);
265 pt2 = new Point(25.0, 5.0);
266 pt1Clipped = new Point(5.0, 5.0);
267 pt2Clipped = new Point(25.0, 5.0);
269 assertFalse(Core.clipLine(r, pt1, pt2));
271 assertEquals(pt1Clipped, pt1);
272 assertEquals(pt2Clipped, pt2);
275 public void testCompare() {
276 Core.compare(gray0, gray0, dst, Core.CMP_EQ);
278 assertMatEqual(dst, gray255);
280 Core.compare(gray0, gray1, dst, Core.CMP_EQ);
282 assertMatEqual(dst, gray0);
284 grayRnd.put(0, 0, 0, 0);
286 Core.compare(gray0, grayRnd, dst, Core.CMP_GE);
288 int expected = (int) (grayRnd.total() - Core.countNonZero(grayRnd));
289 assertEquals(expected, Core.countNonZero(dst));
292 public void testCompleteSymmMat() {
293 Core.completeSymm(grayRnd_32f);
295 assertMatEqual(grayRnd_32f, grayRnd_32f.t(), EPS);
298 public void testCompleteSymmMatBoolean() {
299 Mat grayRnd_32f2 = grayRnd_32f.clone();
301 Core.completeSymm(grayRnd_32f, true);
303 assertMatEqual(grayRnd_32f, grayRnd_32f.t(), EPS);
304 Core.completeSymm(grayRnd_32f2, false);
305 assertMatNotEqual(grayRnd_32f2, grayRnd_32f, EPS);
308 public void testConvertScaleAbsMatMat() {
309 Core.convertScaleAbs(gray0, dst);
311 assertMatEqual(gray0, dst, EPS);
313 Core.convertScaleAbs(gray_16u_256, dst);
315 assertMatEqual(gray255, dst, EPS);
318 public void testConvertScaleAbsMatMatDoubleDouble() {
319 Core.convertScaleAbs(gray_16u_256, dst, 2, -513);
321 assertMatEqual(gray1, dst);
324 public void testCountNonZero() {
325 assertEquals(0, Core.countNonZero(gray0));
327 gray0.put(0, 0, 255);
328 gray0.put(gray0.rows() - 1, gray0.cols() - 1, 255);
330 assertEquals(2, Core.countNonZero(gray0));
333 public void testCubeRoot() {
334 float res = Core.cubeRoot(-27.0f);
336 assertEquals(-3.0f, res);
339 public void testDctMatMat() {
340 Mat in = new Mat(1, 4, CvType.CV_32F) {
342 put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682);
345 Mat dst1 = new Mat();
346 Mat dst2 = new Mat();
348 Core.dct(gray0_32f_1d, dst1);
351 truth = new Mat(1, 4, CvType.CV_32F) {
353 put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477);
356 assertMatEqual(gray0_32f_1d, dst1, EPS);
357 assertMatEqual(truth, dst2, EPS);
360 public void testDctMatMatInt() {
361 Mat in = new Mat(1, 4, CvType.CV_32F) {
363 put(0, 0, 247.98576, -61.252407, 94.904533, 14.013477);
366 Mat dst1 = new Mat();
367 Mat dst2 = new Mat();
369 Core.dct(gray0_32f_1d, dst1, Core.DCT_INVERSE);
370 Core.dct(in, dst2, Core.DCT_INVERSE);
372 truth = new Mat(1, 4, CvType.CV_32F) {
374 put(0, 0, 135.22211, 50.811096, 102.27016, 207.6682);
377 assertMatEqual(gray0_32f_1d, dst1, EPS);
378 assertMatEqual(truth, dst2, EPS);
381 public void testDeterminant() {
382 Mat mat = new Mat(2, 2, CvType.CV_32F) {
391 double det = Core.determinant(mat);
393 assertEquals(8.0, det);
396 public void testDftMatMat() {
397 Core.dft(gray0_32f_1d, dst);
399 assertMatEqual(gray0_32f_1d, dst, EPS);
402 public void testDftMatMatIntInt() {
403 Mat src1 = new Mat(2, 4, CvType.CV_32F) {
405 put(0, 0, 1, 2, 3, 4);
406 put(1, 0, 1, 1, 1, 1);
409 Mat src2 = new Mat(2, 4, CvType.CV_32F) {
411 put(0, 0, 1, 2, 3, 4);
412 put(1, 0, 0, 0, 0, 0);
415 Mat dst1 = new Mat();
416 Mat dst2 = new Mat();
418 Core.dft(src1, dst1, Core.DFT_REAL_OUTPUT, 1);
419 Core.dft(src2, dst2, Core.DFT_REAL_OUTPUT, 0);
421 assertMatEqual(dst2, dst1, EPS);
424 public void testDivideDoubleMatMat() {
425 Core.divide(4.0, gray2, dst);
427 assertMatEqual(gray2, dst);
429 Core.divide(4.0, gray0, dst);
431 assertMatEqual(gray0, dst);
434 public void testDivideDoubleMatMatInt() {
435 Core.divide(9.0, gray3, dst, CvType.CV_32F);
437 assertMatEqual(gray3_32f, dst, EPS);
440 public void testDivideMatMatMat() {
441 Core.divide(gray9, gray3, dst);
443 assertMatEqual(gray3, dst);
446 public void testDivideMatMatMatDouble() {
447 Core.divide(gray1, gray2, dst, 6.0);
449 assertMatEqual(gray3, dst);
452 public void testDivideMatMatMatDoubleInt() {
453 Core.divide(gray1, gray2, dst, 6.0, CvType.CV_32F);
455 assertMatEqual(gray3_32f, dst, EPS);
458 public void testEigen() {
459 Mat src = new Mat(3, 3, CvType.CV_32FC1, new Scalar(2.0));
460 Mat eigenVals = new Mat();
461 Mat eigenVecs = new Mat();
463 Core.eigen(src, true, eigenVals, eigenVecs);
465 Mat expectedEigenVals = new Mat(3, 1, CvType.CV_32FC1) {
470 Mat expectedEigenVecs = new Mat(3, 3, CvType.CV_32FC1) {
472 put(0, 0, 0.57735026, 0.57735026, 0.57735032);
473 put(1, 0, 0.70710677, -0.70710677, 0);
474 put(2, 0, -0.40824831, -0.40824831, 0.81649661);
477 assertMatEqual(eigenVals, expectedEigenVals, EPS);
478 assertMatEqual(eigenVecs, expectedEigenVecs, EPS);
481 public void testEllipse2Poly() {
482 Point center = new Point(4, 4);
483 Size axes = new Size(2, 2);
488 MatOfPoint pts = new MatOfPoint();
490 Core.ellipse2Poly(center, axes, angle, arcStart, arcEnd, delta, pts);
510 assertArrayPointsEquals(truth, pts.toArray(), EPS);
513 public void testEllipseMatPointSizeDoubleDoubleDoubleScalar() {
514 Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
515 Size axes = new Size(2, 2);
516 double angle = 30, startAngle = 60, endAngle = 90;
518 Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite);
520 assertTrue(0 != Core.countNonZero(gray0));
523 public void testEllipseMatPointSizeDoubleDoubleDoubleScalarInt() {
524 Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
525 Size axes = new Size(2, 2);
526 double angle = 30, startAngle = 60, endAngle = 90;
528 Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED);
530 assertTrue(0 != Core.countNonZero(gray0));
533 public void testEllipseMatPointSizeDoubleDoubleDoubleScalarIntIntInt() {
534 Point center = new Point(gray0.cols() / 2, gray0.rows() / 2);
535 Size axes = new Size(2, 2);
536 Point center2 = new Point(gray0.cols(), gray0.rows());
537 Size axes2 = new Size(4, 4);
538 double angle = 30, startAngle = 0, endAngle = 30;
540 Core.ellipse(gray0, center, axes, angle, startAngle, endAngle, colorWhite, Core.FILLED, Core.LINE_4, 0);
542 assertTrue(0 != Core.countNonZero(gray0));
544 Core.ellipse(gray0, center2, axes2, angle, startAngle, endAngle, colorBlack, Core.FILLED, Core.LINE_4, 1);
546 assertEquals(0, Core.countNonZero(gray0));
549 public void testEllipseMatRotatedRectScalar() {
551 Mat gray0 = Mat.zeros(matSize, matSize, CvType.CV_8U);
552 Point center = new Point(matSize / 2, matSize / 2);
553 Size size = new Size(matSize / 4, matSize / 2);
554 RotatedRect box = new RotatedRect(center, size, 45);
556 Core.ellipse(gray0, box, new Scalar(1));
558 final byte[] truth = new byte[] {
559 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
560 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
561 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
562 0, 0, 0, 0, 0, 0, 1, 1, 0, 0,
563 0, 0, 0, 0, 1, 1, 0, 1, 0, 0,
564 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,
565 0, 0, 0, 1, 0, 1, 1, 0, 0, 0,
566 0, 0, 0, 1, 1, 0, 0, 0, 0, 0,
567 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
568 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
570 assertMatEqual(new Mat(matSize, matSize, CvType.CV_8U) {
577 public void testEllipseMatRotatedRectScalarInt() {
578 Point center = new Point(matSize / 2, matSize / 2);
579 Size size = new Size(matSize / 4, matSize / 2);
580 RotatedRect box = new RotatedRect(center, size, 45);
582 Core.ellipse(gray0, box, new Scalar(1), Core.FILLED);
583 Core.ellipse(gray0, box, new Scalar(0));
585 assertTrue(0 < Core.countNonZero(gray0));
588 public void testEllipseMatRotatedRectScalarIntInt() {
589 Point center = new Point(matSize / 2, matSize / 2);
590 Size size = new Size(2, matSize * 2 / 3);
591 RotatedRect box = new RotatedRect(center, size, 20);
593 Core.ellipse(gray0, box, new Scalar(9), 1, Core.LINE_AA);
594 Core.ellipse(gray0, box, new Scalar(0), 1, Core.LINE_4);
596 assertTrue(0 < Core.countNonZero(gray0));
599 public void testExp() {
600 Core.exp(gray0_32f, dst);
602 assertMatEqual(gray1_32f, dst, EPS);
605 public void testExtractChannel() {
606 Core.extractChannel(rgba128, dst, 0);
608 assertMatEqual(gray128, dst);
611 public void testFastAtan2() {
614 float res = Core.fastAtan2(50, 50);
616 assertEquals(45, res, eps);
618 float res2 = Core.fastAtan2(80, 20);
620 assertEquals(Math.atan2(80, 20) * 180 / Math.PI, res2, eps);
623 public void testFillConvexPolyMatListOfPointScalar() {
624 MatOfPoint polyline = new MatOfPoint(new Point[]{new Point(1, 1), new Point(5, 0), new Point(6, 8), new Point(0, 9)});
626 Core.fillConvexPoly(gray0, polyline, new Scalar(150));
628 assertTrue(0 < Core.countNonZero(gray0));
629 assertTrue(gray0.total() > Core.countNonZero(gray0));
632 public void testFillConvexPolyMatListOfPointScalarIntInt() {
633 MatOfPoint polyline1 = new MatOfPoint(new Point(2, 1), new Point(5, 1), new Point(5, 7), new Point(2, 7));
634 MatOfPoint polyline2 = new MatOfPoint(new Point(4, 2), new Point(10, 2), new Point(10, 14), new Point(4, 14));
636 // current implementation of fixed-point version of fillConvexPoly
637 // requires image to be at least 2-pixel wider in each direction than
639 Core.fillConvexPoly(gray0, polyline1, colorWhite, Core.LINE_8, 0);
641 assertTrue(0 < Core.countNonZero(gray0));
642 assertTrue(gray0.total() > Core.countNonZero(gray0));
644 Core.fillConvexPoly(gray0, polyline2, colorBlack, Core.LINE_8, 1);
646 assertEquals("see http://code.opencv.org/issues/1284", 0, Core.countNonZero(gray0));
649 public void testFillPolyMatListOfListOfPointScalar() {
651 Mat gray0 = Mat.zeros(matSize, matSize, CvType.CV_8U);
652 MatOfPoint polyline = new MatOfPoint(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
653 List<MatOfPoint> polylines = new ArrayList<MatOfPoint>();
654 polylines.add(polyline);
656 Core.fillPoly(gray0, polylines, new Scalar(1));
658 final byte[] truth = new byte[] {
659 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
660 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
661 0, 0, 0, 0, 1, 0, 0, 0, 0, 0,
662 0, 0, 0, 1, 1, 1, 0, 0, 0, 0,
663 0, 1, 1, 1, 1, 1, 1, 1, 0, 0,
664 0, 1, 1, 0, 0, 0, 1, 1, 0, 0,
665 0, 1, 1, 0, 0, 0, 1, 1, 0, 0,
666 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
667 0, 1, 0, 0, 0, 0, 0, 1, 0, 0,
668 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
670 assertMatEqual(new Mat(gray0.size(), CvType.CV_8U) {
677 public void testFillPolyMatListOfListOfPointScalarIntIntPoint() {
678 MatOfPoint polyline1 = new MatOfPoint(new Point(1, 4), new Point(1, 8), new Point(4, 1), new Point(7, 8), new Point(7, 4));
679 MatOfPoint polyline2 = new MatOfPoint(new Point(0, 3), new Point(0, 7), new Point(3, 0), new Point(6, 7), new Point(6, 3));
681 List<MatOfPoint> polylines1 = new ArrayList<MatOfPoint>();
682 polylines1.add(polyline1);
684 List<MatOfPoint> polylines2 = new ArrayList<MatOfPoint>();
685 polylines2.add(polyline2);
687 Core.fillPoly(gray0, polylines1, new Scalar(1), Core.LINE_8, 0, new Point(0, 0));
689 assertTrue(0 < Core.countNonZero(gray0));
691 Core.fillPoly(gray0, polylines2, new Scalar(0), Core.LINE_8, 0, new Point(1, 1));
693 assertEquals(0, Core.countNonZero(gray0));
696 public void testFlip() {
697 Mat src = new Mat(2, 2, CvType.CV_32F) {
705 Mat dst1 = new Mat();
706 Mat dst2 = new Mat();
708 Core.flip(src, dst1, 0);
709 Core.flip(src, dst2, 1);
711 Mat dst_f1 = new Mat(2, 2, CvType.CV_32F) {
719 Mat dst_f2 = new Mat(2, 2, CvType.CV_32F) {
727 assertMatEqual(dst_f1, dst1, EPS);
728 assertMatEqual(dst_f2, dst2, EPS);
731 public void testGemmMatMatDoubleMatDoubleMat() {
732 Mat m1 = new Mat(2, 2, CvType.CV_32FC1) {
738 Mat m2 = new Mat(2, 2, CvType.CV_32FC1) {
744 Mat dmatrix = new Mat(2, 2, CvType.CV_32FC1) {
746 put(0, 0, 0.001, 0.001);
747 put(1, 0, 0.001, 0.001);
751 Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst);
753 Mat expected = new Mat(2, 2, CvType.CV_32FC1) {
755 put(0, 0, 1.001, 0.001);
756 put(1, 0, 1.001, 0.001);
759 assertMatEqual(expected, dst, EPS);
762 public void testGemmMatMatDoubleMatDoubleMatInt() {
763 Mat m1 = new Mat(2, 2, CvType.CV_32FC1) {
769 Mat m2 = new Mat(2, 2, CvType.CV_32FC1) {
775 Mat dmatrix = new Mat(2, 2, CvType.CV_32FC1) {
777 put(0, 0, 0.001, 0.001);
778 put(1, 0, 0.001, 0.001);
782 Core.gemm(m1, m2, 1.0, dmatrix, 1.0, dst, Core.GEMM_1_T);
784 Mat expected = new Mat(2, 2, CvType.CV_32FC1) {
786 put(0, 0, 2.001, 0.001);
787 put(1, 0, 0.001, 0.001);
790 assertMatEqual(expected, dst, EPS);
793 public void testGetCPUTickCount() {
794 long cpuCountStart = 0, actualTickCount;
796 cpuCountStart = Core.getCPUTickCount();
797 Core.sumElems(gray255);
798 actualTickCount = Core.getCPUTickCount();
800 long expectedTickCount = actualTickCount - cpuCountStart;
801 assertTrue(expectedTickCount > 0);
804 public void testGetNumberOfCPUs() {
805 int cpus = Core.getNumberOfCPUs();
807 assertTrue(Runtime.getRuntime().availableProcessors() <= cpus);
810 public void testGetOptimalDFTSize() {
811 assertEquals(1, Core.getOptimalDFTSize(0));
812 assertEquals(135, Core.getOptimalDFTSize(133));
813 assertEquals(15, Core.getOptimalDFTSize(13));
816 public void testGetTextSize() {
817 String text = "Android all the way";
818 double fontScale = 2;
820 int baseLine[] = new int[1];
822 Core.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, null);
823 Size res = Core.getTextSize(text, Core.FONT_HERSHEY_SCRIPT_SIMPLEX, fontScale, thickness, baseLine);
825 assertEquals(543.0, res.width);
826 assertEquals(44.0, res.height);
827 assertEquals(20, baseLine[0]);
830 public void testGetTickCount() {
831 long startCount, endCount, count;
833 startCount = Core.getTickCount();
834 Core.divide(gray2, gray1, dst);
835 endCount = Core.getTickCount();
837 count = endCount - startCount;
838 assertTrue(count > 0);
841 public void testGetTickFrequency() {
842 double freq1 = Core.getTickFrequency();
843 Core.divide(gray2, gray1, dst);
844 double freq2 = Core.getTickFrequency();
846 assertTrue(0 < freq1);
847 assertEquals(freq1, freq2);
850 public void testHconcat() {
851 List<Mat> mats = Arrays.asList(Mat.eye(3, 3, CvType.CV_8U), Mat.zeros(3, 2, CvType.CV_8U));
853 Core.hconcat(mats, dst);
855 assertMatEqual(Mat.eye(3, 5, CvType.CV_8U), dst);
858 public void testIdctMatMat() {
859 Mat in = new Mat(1, 8, CvType.CV_32F) {
861 put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0);
867 truth = new Mat(1, 8, CvType.CV_32F) {
869 put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115);
872 assertMatEqual(truth, dst, EPS);
875 public void testIdctMatMatInt() {
876 Mat in = new Mat(2, 8, CvType.CV_32F) {
878 put(0, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0);
879 put(1, 0, 1.0, 2.0, 1.0, 0.0, 1.0, 2.0, 3.0, 1.0);
883 Core.idct(in, dst, Core.DCT_ROWS);
885 truth = new Mat(2, 8, CvType.CV_32F) {
887 put(0, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115);
888 put(1, 0, 3.3769724, -1.6215782, 2.3608727, 0.20730907, -0.86502546, 0.028082132, -0.7673766, 0.10917115);
891 assertMatEqual(truth, dst, EPS);
894 public void testIdftMatMat() {
895 Mat in = new Mat(1, 4, CvType.CV_32F) {
897 put(0, 0, 1.0, 2.0, 3.0, 4.0);
903 truth = new Mat(1, 4, CvType.CV_32F) {
905 put(0, 0, 9, -9, 1, 3);
908 assertMatEqual(truth, dst, EPS);
911 public void testIdftMatMatIntInt() {
912 Mat in = new Mat(2, 4, CvType.CV_32F) {
914 put(0, 0, 1.0, 2.0, 3.0, 4.0);
915 put(1, 0, 1.0, 2.0, 3.0, 4.0);
920 Core.idft(in, dst, Core.DFT_REAL_OUTPUT, 1);
922 truth = new Mat(2, 4, CvType.CV_32F) {
924 put(0, 0, 18, -18, 2, 6);
925 put(1, 0, 0, 0, 0, 0);
928 assertMatEqual(truth, dst, EPS);
931 public void testInRange() {
932 gray0.put(1, 1, 100, 150, 200);
934 Core.inRange(gray0, new Scalar(120), new Scalar(160), dst);
936 byte vals[] = new byte[3];
939 assertEquals(0, vals[0]);
940 assertEquals(-1, vals[1]);
941 assertEquals(0, vals[2]);
942 assertEquals(1, Core.countNonZero(dst));
945 public void testInsertChannel() {
946 Core.insertChannel(gray0, rgba128, 0);
947 Core.insertChannel(gray0, rgba128, 1);
948 Core.insertChannel(gray0, rgba128, 2);
949 Core.insertChannel(gray0, rgba128, 3);
951 assertMatEqual(rgba0, rgba128);
954 public void testInvertMatMat() {
955 Mat src = new Mat(2, 2, CvType.CV_32F) {
964 Core.invert(src, dst);
966 truth = new Mat(2, 2, CvType.CV_32F) {
974 assertMatEqual(truth, dst, EPS);
977 public void testInvertMatMatInt() {
978 Mat src = Mat.eye(3, 3, CvType.CV_32FC1);
981 double cond = Core.invert(src, dst, Core.DECOMP_SVD);
983 truth = Mat.eye(3, 3, CvType.CV_32FC1);
985 assertMatEqual(truth, dst, EPS);
986 assertEquals(0.3819660544395447, cond, EPS);
989 public void testKmeansMatIntMatTermCriteriaIntInt() {
990 Mat data = new Mat(4, 5, CvType.CV_32FC1) {
992 put(0, 0, 1, 2, 3, 4, 5);
993 put(1, 0, 2, 3, 4, 5, 6);
994 put(2, 0, 5, 4, 3, 2, 1);
995 put(3, 0, 6, 5, 4, 3, 2);
998 TermCriteria criteria = new TermCriteria(TermCriteria.EPS, 0, EPS);
999 Mat labels = new Mat();
1001 Core.kmeans(data, 2, labels, criteria, 1, Core.KMEANS_PP_CENTERS);
1003 int[] first_center = new int[1];
1004 labels.get(0, 0, first_center);
1005 final int c1 = first_center[0];
1006 Mat expected_labels = new Mat(4, 1, CvType.CV_32S) {
1008 put(0, 0, c1, c1, 1 - c1, 1 - c1);
1011 assertMatEqual(expected_labels, labels);
1014 public void testKmeansMatIntMatTermCriteriaIntIntMat() {
1015 Mat data = new Mat(4, 5, CvType.CV_32FC1) {
1017 put(0, 0, 1, 2, 3, 4, 5);
1018 put(1, 0, 2, 3, 4, 5, 6);
1019 put(2, 0, 5, 4, 3, 2, 1);
1020 put(3, 0, 6, 5, 4, 3, 2);
1023 TermCriteria criteria = new TermCriteria(TermCriteria.EPS, 0, EPS);
1024 Mat labels = new Mat();
1025 Mat centers = new Mat();
1027 Core.kmeans(data, 2, labels, criteria, 6, Core.KMEANS_RANDOM_CENTERS, centers);
1029 int[] first_center = new int[1];
1030 labels.get(0, 0, first_center);
1031 final int c1 = first_center[0];
1032 Mat expected_labels = new Mat(4, 1, CvType.CV_32S) {
1034 put(0, 0, c1, c1, 1 - c1, 1 - c1);
1037 Mat expected_centers = new Mat(2, 5, CvType.CV_32FC1) {
1039 put(c1, 0, 1.5, 2.5, 3.5, 4.5, 5.5);
1040 put(1 - c1, 0, 5.5, 4.5, 3.5, 2.5, 1.5);
1043 assertMatEqual(expected_labels, labels);
1044 assertMatEqual(expected_centers, centers, EPS);
1047 public void testLineMatPointPointScalar() {
1048 int nPoints = Math.min(gray0.cols(), gray0.rows());
1049 Point point1 = new Point(0, 0);
1050 Point point2 = new Point(nPoints, nPoints);
1051 Scalar color = new Scalar(255);
1053 Core.line(gray0, point1, point2, color);
1055 assertTrue(nPoints == Core.countNonZero(gray0));
1058 public void testLineMatPointPointScalarInt() {
1059 int nPoints = Math.min(gray0.cols(), gray0.rows());
1060 Point point1 = new Point(0, 0);
1061 Point point2 = new Point(nPoints, nPoints);
1063 Core.line(gray0, point1, point2, colorWhite, 0);
1065 assertTrue(nPoints == Core.countNonZero(gray0));
1068 public void testLineMatPointPointScalarIntIntInt() {
1069 int nPoints = Math.min(gray0.cols(), gray0.rows());
1070 Point point1 = new Point(3, 4);
1071 Point point2 = new Point(nPoints, nPoints);
1072 Point point1_4 = new Point(3 * 4, 4 * 4);
1073 Point point2_4 = new Point(nPoints * 4, nPoints * 4);
1075 Core.line(gray0, point2, point1, colorWhite, 2, Core.LINE_8, 0);
1077 assertFalse(0 == Core.countNonZero(gray0));
1079 Core.line(gray0, point2_4, point1_4, colorBlack, 2, Core.LINE_8, 2);
1081 assertEquals(0, Core.countNonZero(gray0));
1084 public void testLog() {
1085 Mat in = new Mat(1, 4, CvType.CV_32FC1) {
1087 put(0, 0, 1.0, 10.0, 100.0, 1000.0);
1093 Mat expected = new Mat(1, 4, CvType.CV_32FC1) {
1095 put(0, 0, 0, 2.3025851, 4.6051702, 6.9077554);
1098 assertMatEqual(expected, dst, EPS);
1101 public void testLUTMatMatMat() {
1102 Mat lut = new Mat(1, 256, CvType.CV_8UC1);
1103 lut.setTo(new Scalar(0));
1105 Core.LUT(grayRnd, lut, dst);
1107 assertMatEqual(gray0, dst);
1109 lut.setTo(new Scalar(255));
1111 Core.LUT(grayRnd, lut, dst);
1113 assertMatEqual(gray255, dst);
1116 public void testLUTMatMatMatInt() {
1117 Mat lut = new Mat(1, 256, CvType.CV_8UC1);
1118 // TODO: ban this overload
1121 Core.LUT(grayRnd, lut, dst, 1);
1122 fail("Last parameter for LUT was not supported");
1123 } catch (CvException e) {
1128 public void testMagnitude() {
1129 Mat x = new Mat(1, 4, CvType.CV_32F);
1130 Mat y = new Mat(1, 4, CvType.CV_32F);
1131 x.put(0, 0, 3.0, 5.0, 9.0, 6.0);
1132 y.put(0, 0, 4.0, 12.0, 40.0, 8.0);
1134 Core.magnitude(x, y, dst);
1136 Mat out = new Mat(1, 4, CvType.CV_32F);
1137 out.put(0, 0, 5.0, 13.0, 41.0, 10.0);
1138 assertMatEqual(out, dst, EPS);
1140 Core.magnitude(gray0_32f, gray255_32f, dst);
1142 assertMatEqual(gray255_32f, dst, EPS);
1145 public void testMahalanobis() {
1146 Mat covar = new Mat(matSize, matSize, CvType.CV_32F);
1147 Mat mean = new Mat(1, matSize, CvType.CV_32F);
1148 Core.calcCovarMatrix(grayRnd_32f, covar, mean, Core.COVAR_ROWS | Core.COVAR_NORMAL, CvType.CV_32F);
1149 covar = covar.inv();
1150 Mat line1 = grayRnd_32f.row(0);
1151 Mat line2 = grayRnd_32f.row(1);
1153 double d = Core.Mahalanobis(line1, line1, covar);
1155 assertEquals(0.0, d);
1157 d = Core.Mahalanobis(line1, line2, covar);
1159 assertTrue(d > 0.0);
1162 public void testMax() {
1163 Core.max(gray0, gray255, dst);
1165 assertMatEqual(gray255, dst);
1167 Mat x = new Mat(1, 1, CvType.CV_32F);
1168 Mat y = new Mat(1, 1, CvType.CV_32F);
1172 Core.max(x, y, dst);
1174 Mat truth = new Mat(1, 1, CvType.CV_32F);
1175 truth.put(0, 0, 23.0);
1176 assertMatEqual(truth, dst, EPS);
1179 public void testMeanMat() {
1180 Scalar mean = Core.mean(makeMask(gray128));
1182 assertScalarEqual(new Scalar(64), mean, EPS);
1185 public void testMeanMatMat() {
1186 Mat mask1 = makeMask(gray1.clone());
1187 Mat mask2 = makeMask(gray0, 1);
1189 Scalar mean1 = Core.mean(grayRnd, mask1);
1190 Scalar mean2 = Core.mean(grayRnd, mask2);
1191 Scalar mean = Core.mean(grayRnd, gray1);
1193 assertScalarEqual(mean, new Scalar(0.5 * (mean1.val[0] + mean2.val[0])), EPS);
1196 public void testMeanStdDevMatMatMat() {
1197 MatOfDouble mean = new MatOfDouble();
1198 MatOfDouble stddev = new MatOfDouble();
1200 Core.meanStdDev(rgbLena, mean, stddev);
1202 double expectedMean[] = new double[]
1203 {105.3989906311035, 99.56269836425781, 179.7303047180176};
1204 double expectedDev[] = new double[]
1205 {33.74205485167219, 52.8734582803278, 49.01569488056406};
1207 assertArrayEquals(expectedMean, mean.toArray(), EPS);
1208 assertArrayEquals(expectedDev, stddev.toArray(), EPS);
1211 public void testMeanStdDevMatMatMatMat() {
1212 Mat submat = grayRnd.submat(0, grayRnd.rows() / 2, 0, grayRnd.cols() / 2);
1213 submat.setTo(new Scalar(33));
1214 Mat mask = gray0.clone();
1215 submat = mask.submat(0, mask.rows() / 2, 0, mask.cols() / 2);
1216 submat.setTo(new Scalar(1));
1217 MatOfDouble mean = new MatOfDouble();
1218 MatOfDouble stddev = new MatOfDouble();
1220 Core.meanStdDev(grayRnd, mean, stddev, mask);
1222 double expectedMean[] = new double[] {33d};
1223 double expectedDev[] = new double[] {0d};
1225 assertArrayEquals(expectedMean, mean.toArray(), EPS);
1226 assertArrayEquals(expectedDev, stddev.toArray(), EPS);
1229 public void testMerge() {
1230 Mat src1 = new Mat(2, 2, CvType.CV_32FC1, new Scalar(1));
1231 Mat src2 = new Mat(2, 2, CvType.CV_32FC1, new Scalar(2));
1232 Mat src3 = new Mat(2, 2, CvType.CV_32FC1, new Scalar(3));
1233 List<Mat> listMat = Arrays.asList(src1, src2, src3);
1235 Core.merge(listMat, dst);
1237 truth = new Mat(2, 2, CvType.CV_32FC3, new Scalar(1, 2, 3));
1238 assertMatEqual(truth, dst, EPS);
1241 public void testMin() {
1242 Core.min(gray0, gray255, dst);
1244 assertMatEqual(gray0, dst);
1247 public void testMinMaxLocMat() {
1250 Point minLoc = new Point(gray3.cols() / 4, gray3.rows() / 2);
1251 Point maxLoc = new Point(gray3.cols() / 2, gray3.rows() / 4);
1252 gray3.put((int) minLoc.y, (int) minLoc.x, minVal);
1253 gray3.put((int) maxLoc.y, (int) maxLoc.x, maxVal);
1255 Core.MinMaxLocResult mmres = Core.minMaxLoc(gray3);
1257 assertEquals(minVal, mmres.minVal);
1258 assertEquals(maxVal, mmres.maxVal);
1259 assertPointEquals(minLoc, mmres.minLoc, EPS);
1260 assertPointEquals(maxLoc, mmres.maxLoc, EPS);
1263 public void testMinMaxLocMatMat() {
1264 Mat src = new Mat(4, 4, CvType.CV_8U) {
1266 put(0, 0, 2, 4, 27, 3);
1267 put(1, 0, 0, 8, 7, 130);
1268 put(2, 0, 13, 4, 13, 4);
1269 put(3, 0, 6, 4, 2, 13);
1272 Mat mask = new Mat(4, 4, CvType.CV_8U, new Scalar(0));
1273 mask.submat(1, 3, 1, 4).setTo(new Scalar(1));
1275 MinMaxLocResult res = Core.minMaxLoc(src, mask);
1277 assertEquals(4.0, res.minVal);
1278 assertEquals(130.0, res.maxVal);
1279 assertPointEquals(new Point(1, 2), res.minLoc, EPS);
1280 assertPointEquals(new Point(3, 1), res.maxLoc, EPS);
1283 public void testMixChannels() {
1284 rgba0.setTo(new Scalar(10, 20, 30, 40));
1285 List<Mat> src = Arrays.asList(rgba0);
1286 List<Mat> dst = Arrays.asList(gray3, gray2, gray1, gray0, getMat(CvType.CV_8UC3, 0, 0, 0));
1287 MatOfInt fromTo = new MatOfInt(
1297 Core.mixChannels(src, dst, fromTo);
1299 assertMatEqual(getMat(CvType.CV_8U, 40), dst.get(0));
1300 assertMatEqual(getMat(CvType.CV_8U, 40), dst.get(1));
1301 assertMatEqual(getMat(CvType.CV_8U, 30), dst.get(2));
1302 assertMatEqual(getMat(CvType.CV_8U, 10), dst.get(3));
1303 assertMatEqual(getMat(CvType.CV_8UC3, 30, 20, 10), dst.get(4));
1306 public void testMulSpectrumsMatMatMatInt() {
1307 Mat src1 = new Mat(1, 4, CvType.CV_32F) {
1309 put(0, 0, 1.0, 2.0, 3.0, 4.0);
1312 Mat src2 = new Mat(1, 4, CvType.CV_32F) {
1314 put(0, 0, 1.0, 2.0, 3.0, 4.0);
1318 Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS);
1320 Mat expected = new Mat(1, 4, CvType.CV_32F) {
1322 put(0, 0, 1, -5, 12, 16);
1325 assertMatEqual(expected, dst, EPS);
1328 public void testMulSpectrumsMatMatMatIntBoolean() {
1329 Mat src1 = new Mat(1, 4, CvType.CV_32F) {
1331 put(0, 0, 1.0, 2.0, 3.0, 4.0);
1334 Mat src2 = new Mat(1, 4, CvType.CV_32F) {
1336 put(0, 0, 1.0, 2.0, 3.0, 4.0);
1340 Core.mulSpectrums(src1, src2, dst, Core.DFT_ROWS, true);
1342 Mat expected = new Mat(1, 4, CvType.CV_32F) {
1344 put(0, 0, 1, 13, 0, 16);
1347 assertMatEqual(expected, dst, EPS);
1350 public void testMultiplyMatMatMat() {
1351 Core.multiply(gray0, gray255, dst);
1353 assertMatEqual(gray0, dst);
1356 public void testMultiplyMatMatMatDouble() {
1357 Core.multiply(gray1, gray1, dst, 2.0);
1359 assertMatEqual(gray2, dst);
1363 public void testMultiplyMatMatMatDoubleInt() {
1364 Core.multiply(gray1, gray2, dst, 1.5, CvType.CV_32F);
1366 assertMatEqual(gray3_32f, dst, EPS);
1369 public void testMulTransposedMatMatBoolean() {
1370 Core.mulTransposed(grayE_32f, dst, true);
1372 assertMatEqual(grayE_32f, dst, EPS);
1375 public void testMulTransposedMatMatBooleanMatDouble() {
1376 Core.mulTransposed(grayE_32f, dst, true, gray0_32f, 2);
1379 truth.diag().setTo(new Scalar(2));
1380 assertMatEqual(truth, dst, EPS);
1383 public void testMulTransposedMatMatBooleanMatDoubleInt() {
1384 Mat a = getMat(CvType.CV_32F, 1);
1386 Core.mulTransposed(a, dst, true, gray0_32f, 3, CvType.CV_64F);
1388 assertMatEqual(getMat(CvType.CV_64F, 3 * a.rows()), dst, EPS);
1391 public void testNormalizeMatMat() {
1392 Mat m = gray0.clone();
1393 m.diag().setTo(new Scalar(2));
1395 Core.normalize(m, dst);
1397 assertMatEqual(gray0, dst);
1400 public void testNormalizeMatMatDoubleDoubleInt() {
1401 Mat src = new Mat(1, 4, CvType.CV_32F) {
1403 put(0, 0, 1.0, 2.0, 3.0, 4.0);
1407 Core.normalize(src, dst, 1.0, 2.0, Core.NORM_INF);
1409 Mat expected = new Mat(1, 4, CvType.CV_32F) {
1411 put(0, 0, 0.25, 0.5, 0.75, 1);
1414 assertMatEqual(expected, dst, EPS);
1417 public void testNormalizeMatMatDoubleDoubleIntInt() {
1418 Mat src = new Mat(1, 5, CvType.CV_32F) {
1420 put(0, 0, 0, 1, 2, 3, 4);
1424 Core.normalize(src, dst, 1, 2, Core.NORM_MINMAX, CvType.CV_64F);
1426 Mat expected = new Mat(1, 5, CvType.CV_64F) {
1428 put(0, 0, 1, 1.25, 1.5, 1.75, 2);
1431 assertMatEqual(expected, dst, EPS);
1434 public void testNormalizeMatMatDoubleDoubleIntIntMat() {
1435 Mat src = new Mat(1, 5, CvType.CV_32F) {
1437 put(0, 0, 0, 1, 2, 3, 4);
1440 Mat mask = new Mat(1, 5, CvType.CV_8U) {
1442 put(0, 0, 1, 0, 0, 0, 1);
1447 Core.normalize(src, dst, 1, 2, Core.NORM_MINMAX, CvType.CV_32F, mask);
1449 Mat expected = new Mat(1, 5, CvType.CV_32F) {
1451 put(0, 0, 1, 1, 2, 3, 2);
1454 assertMatEqual(expected, dst, EPS);
1457 public void testNormMat() {
1458 double n = Core.norm(gray1);
1460 assertEquals(10., n);
1463 public void testNormMatInt() {
1464 double n = Core.norm(gray127, Core.NORM_INF);
1466 assertEquals(127., n);
1469 public void testNormMatIntMat() {
1470 double n = Core.norm(gray3, Core.NORM_L1, gray0);
1472 assertEquals(0.0, n);
1475 public void testNormMatMat() {
1476 double n = Core.norm(gray0, gray1);
1478 assertEquals(10.0, n);
1481 public void testNormMatMatInt() {
1482 double n = Core.norm(gray127, gray1, Core.NORM_INF);
1484 assertEquals(126.0, n);
1487 public void testNormMatMatIntMat() {
1488 double n = Core.norm(gray3, gray0, Core.NORM_L1, makeMask(gray0.clone(), 1));
1490 assertEquals(150.0, n);
1493 public void testPCABackProject() {
1494 Mat mean = new Mat(1, 4, CvType.CV_32F) {
1496 put(0, 0, 2, 4, 4, 8);
1499 Mat vectors = new Mat(1, 4, CvType.CV_32F, new Scalar(0)) {
1501 put(0, 0, 0.2, 0.4, 0.4, 0.8);
1504 Mat data = new Mat(3, 1, CvType.CV_32F) {
1506 put(0, 0, -5, 0, -10);
1509 Mat result = new Mat();
1511 Core.PCABackProject(data, mean, vectors, result);
1513 Mat truth = new Mat(3, 4, CvType.CV_32F) {
1515 put(0, 0, 1, 2, 2, 4);
1516 put(1, 0, 2, 4, 4, 8);
1517 put(2, 0, 0, 0, 0, 0);
1520 assertMatEqual(truth, result, EPS);
1523 public void testPCAComputeMatMatMat() {
1524 Mat data = new Mat(3, 4, CvType.CV_32F) {
1526 put(0, 0, 1, 2, 2, 4);
1527 put(1, 0, 2, 4, 4, 8);
1528 put(2, 0, 3, 6, 6, 12);
1531 Mat mean = new Mat();
1532 Mat vectors = new Mat();
1534 Core.PCACompute(data, mean, vectors);
1536 Mat mean_truth = new Mat(1, 4, CvType.CV_32F) {
1538 put(0, 0, 2, 4, 4, 8);
1541 Mat vectors_truth = new Mat(3, 4, CvType.CV_32F, new Scalar(0)) {
1543 put(0, 0, 0.2, 0.4, 0.4, 0.8);
1546 assertMatEqual(mean_truth, mean, EPS);
1547 assertMatEqual(vectors_truth, vectors, EPS);
1550 public void testPCAComputeMatMatMatInt() {
1551 Mat data = new Mat(3, 4, CvType.CV_32F) {
1553 put(0, 0, 1, 2, 2, 4);
1554 put(1, 0, 2, 4, 4, 8);
1555 put(2, 0, 3, 6, 6, 12);
1558 Mat mean = new Mat();
1559 Mat vectors = new Mat();
1561 Core.PCACompute(data, mean, vectors, 1);
1563 Mat mean_truth = new Mat(1, 4, CvType.CV_32F) {
1565 put(0, 0, 2, 4, 4, 8);
1568 Mat vectors_truth = new Mat(1, 4, CvType.CV_32F, new Scalar(0)) {
1570 put(0, 0, 0.2, 0.4, 0.4, 0.8);
1573 assertMatEqual(mean_truth, mean, EPS);
1574 assertMatEqual(vectors_truth, vectors, EPS);
1577 public void testPCAProject() {
1578 Mat mean = new Mat(1, 4, CvType.CV_32F) {
1580 put(0, 0, 2, 4, 4, 8);
1583 Mat vectors = new Mat(1, 4, CvType.CV_32F, new Scalar(0)) {
1585 put(0, 0, 0.2, 0.4, 0.4, 0.8);
1588 Mat data = new Mat(3, 4, CvType.CV_32F) {
1590 put(0, 0, 1, 2, 2, 4);
1591 put(1, 0, 2, 4, 4, 8);
1592 put(2, 0, 0, 0, 0, 0);
1595 Mat result = new Mat();
1597 Core.PCAProject(data, mean, vectors, result);
1599 Mat truth = new Mat(3, 1, CvType.CV_32F) {
1601 put(0, 0, -5, 0, -10);
1604 assertMatEqual(truth, result, EPS);
1607 public void testPerspectiveTransform() {
1608 Mat src = new Mat(matSize, matSize, CvType.CV_32FC2);
1609 Core.randu(src, 0, 256);
1610 Mat transformMatrix = Mat.eye(3, 3, CvType.CV_32F);
1612 Core.perspectiveTransform(src, dst, transformMatrix);
1613 assertMatEqual(src, dst, EPS);
1616 public void testPerspectiveTransform3D() {
1617 Mat src = new Mat(matSize, matSize, CvType.CV_32FC3);
1618 Core.randu(src, 0, 256);
1619 Mat transformMatrix = Mat.eye(4, 4, CvType.CV_32F);
1621 Core.perspectiveTransform(src, dst, transformMatrix);
1623 assertMatEqual(src, dst, EPS);
1626 private static double atan2deg(double y, double x)
1628 double res = Math.atan2(y, x);
1630 res = Math.PI * 2 + res;
1631 return res * 180 / Math.PI;
1634 private static double atan2rad(double y, double x)
1636 double res = Math.atan2(y, x);
1638 res = Math.PI * 2 + res;
1642 public void testPhaseMatMatMat() {
1643 Mat x = new Mat(1, 4, CvType.CV_32F) {
1645 put(0, 0, 10.0, 10.0, 20.0, 5.0);
1648 Mat y = new Mat(1, 4, CvType.CV_32F) {
1650 put(0, 0, 20.0, 15.0, 20.0, 20.0);
1653 Mat gold = new Mat(1, 4, CvType.CV_32F) {
1655 put(0, 0, atan2rad(20, 10), atan2rad(15, 10), atan2rad(20, 20), atan2rad(20, 5));
1659 Core.phase(x, y, dst);
1661 assertMatEqual(gold, dst, EPS);
1664 public void testPhaseMatMatMatBoolean() {
1665 Mat x = new Mat(1, 4, CvType.CV_32F) {
1667 put(0, 0, 10.0, 10.0, 20.0, 5.0);
1670 Mat y = new Mat(1, 4, CvType.CV_32F) {
1672 put(0, 0, 20.0, 15.0, 20.0, 20.0);
1675 Mat gold = new Mat(1, 4, CvType.CV_32F) {
1677 put(0, 0, atan2deg(20, 10), atan2deg(15, 10), atan2deg(20, 20), atan2deg(20, 5));
1681 Core.phase(x, y, dst, true);
1683 assertMatEqual(gold, dst, EPS * 180 / Math.PI);
1686 public void testPolarToCartMatMatMatMat() {
1687 Mat magnitude = new Mat(1, 3, CvType.CV_32F) {
1689 put(0, 0, 5.0, 10.0, 13.0);
1692 Mat angle = new Mat(1, 3, CvType.CV_32F) {
1694 put(0, 0, 0.92729962, 0.92729962, 1.1759995);
1697 Mat xCoordinate = new Mat();
1698 Mat yCoordinate = new Mat();
1700 Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate);
1702 Mat x = new Mat(1, 3, CvType.CV_32F) {
1704 put(0, 0, 3.0, 6.0, 5, 0);
1707 Mat y = new Mat(1, 3, CvType.CV_32F) {
1709 put(0, 0, 4.0, 8.0, 12.0);
1712 assertMatEqual(x, xCoordinate, EPS);
1713 assertMatEqual(y, yCoordinate, EPS);
1716 public void testPolarToCartMatMatMatMatBoolean() {
1717 Mat magnitude = new Mat(1, 3, CvType.CV_32F) {
1719 put(0, 0, 5.0, 10.0, 13.0);
1722 Mat angle = new Mat(1, 3, CvType.CV_32F) {
1724 put(0, 0, 0.92729962, 0.92729962, 1.1759995);
1727 Mat xCoordinate = new Mat();
1728 Mat yCoordinate = new Mat();
1730 Core.polarToCart(magnitude, angle, xCoordinate, yCoordinate, true);
1732 Mat x = new Mat(1, 3, CvType.CV_32F) {
1734 put(0, 0, 4.9993458, 9.9986916, 12.997262);
1737 Mat y = new Mat(1, 3, CvType.CV_32F) {
1739 put(0, 0, 0.080918625, 0.16183725, 0.26680708);
1742 assertMatEqual(x, xCoordinate, EPS);
1743 assertMatEqual(y, yCoordinate, EPS);
1746 public void testPolylinesMatListOfListOfPointBooleanScalar() {
1748 List<MatOfPoint> polyline = new ArrayList<MatOfPoint>();
1749 polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
1751 Core.polylines(img, polyline, true, new Scalar(100));
1753 assertEquals(22, Core.countNonZero(img));
1755 Core.polylines(img, polyline, false, new Scalar(0));
1757 assertEquals(4, Core.countNonZero(img));
1760 public void testPolylinesMatListOfListOfPointBooleanScalarInt() {
1762 List<MatOfPoint> polyline = new ArrayList<MatOfPoint>();
1763 polyline.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
1765 Core.polylines(img, polyline, true, new Scalar(100), 2);
1767 assertEquals(62, Core.countNonZero(img));
1770 public void testPolylinesMatListOfListOfPointBooleanScalarIntIntInt() {
1772 List<MatOfPoint> polyline1 = new ArrayList<MatOfPoint>();
1773 polyline1.add(new MatOfPoint(new Point(1, 1), new Point(7, 1), new Point(7, 6), new Point(1, 6)));
1774 List<MatOfPoint> polyline2 = new ArrayList<MatOfPoint>();
1775 polyline2.add(new MatOfPoint(new Point(2, 2), new Point(14, 2), new Point(14, 12), new Point(2, 12)));
1777 Core.polylines(img, polyline1, true, new Scalar(100), 2, Core.LINE_8, 0);
1779 assertTrue(Core.countNonZero(img) > 0);
1781 Core.polylines(img, polyline2, true, new Scalar(0), 2, Core.LINE_8, 1);
1783 assertEquals(0, Core.countNonZero(img));
1786 public void testPow() {
1787 Core.pow(gray2, 7, dst);
1789 assertMatEqual(gray128, dst);
1792 public void testPutTextMatStringPointIntDoubleScalar() {
1793 String text = "Hello World";
1794 Size labelSize = new Size(175, 22);
1795 Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
1796 Point origin = new Point(10, labelSize.height + 10);
1798 Core.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite);
1800 assertTrue(Core.countNonZero(img) > 0);
1801 // check that border is not corrupted
1802 Core.rectangle(img, new Point(11, 11), new Point(labelSize.width + 10, labelSize.height + 10), colorBlack, Core.FILLED);
1803 assertEquals(0, Core.countNonZero(img));
1806 public void testPutTextMatStringPointIntDoubleScalarInt() {
1807 String text = "Hello World";
1808 Size labelSize = new Size(176, 22);
1809 Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
1810 Point origin = new Point(10, labelSize.height + 10);
1812 Core.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 2);
1814 assertTrue(Core.countNonZero(img) > 0);
1815 // check that border is not corrupted
1816 Core.rectangle(img, new Point(10, 10), new Point(labelSize.width + 10 + 1, labelSize.height + 10 + 1), colorBlack, Core.FILLED);
1817 assertEquals(0, Core.countNonZero(img));
1820 public void testPutTextMatStringPointIntDoubleScalarIntIntBoolean() {
1821 String text = "Hello World";
1822 Size labelSize = new Size(175, 22);
1824 Mat img = new Mat(20 + (int) labelSize.height, 20 + (int) labelSize.width, CvType.CV_8U, colorBlack);
1825 Point origin = new Point(10, 10);
1827 Core.putText(img, text, origin, Core.FONT_HERSHEY_SIMPLEX, 1.0, colorWhite, 1, Core.LINE_8, true);
1829 assertTrue(Core.countNonZero(img) > 0);
1830 // check that border is not corrupted
1831 Core.rectangle(img, new Point(10, 10), new Point(labelSize.width + 9, labelSize.height + 9), colorBlack, Core.FILLED);
1832 assertEquals(0, Core.countNonZero(img));
1835 public void testRandn() {
1836 Core.randn(gray0, 100, 23);
1838 assertEquals(100., Core.mean(gray0).val[0], 23 / 2);
1841 public void testRandShuffleMat() {
1842 Mat original = new Mat(1, 5, CvType.CV_32F) {
1844 put(0, 0, 7, 5, 2, 8, 1);
1847 Mat shuffled = original.clone();
1849 Core.randShuffle(shuffled);
1851 assertMatNotEqual(original, shuffled, EPS);
1852 Mat dst1 = new Mat();
1853 Mat dst2 = new Mat();
1854 Core.sort(original, dst1, Core.SORT_ASCENDING);
1855 Core.sort(shuffled, dst2, Core.SORT_ASCENDING);
1856 assertMatEqual(dst1, dst2, EPS);
1859 public void testRandShuffleMatDouble() {
1860 Mat original = new Mat(1, 5, CvType.CV_32F) {
1862 put(0, 0, 7, 5, 2, 8, 1);
1865 Mat shuffled = original.clone();
1867 Core.randShuffle(shuffled, 10);
1869 assertMatNotEqual(original, shuffled, EPS);
1870 Mat dst1 = new Mat();
1871 Mat dst2 = new Mat();
1872 Core.sort(original, dst1, Core.SORT_ASCENDING);
1873 Core.sort(shuffled, dst2, Core.SORT_ASCENDING);
1874 assertMatEqual(dst1, dst2, EPS);
1877 public void testRandu() {
1878 Core.randu(gray0, 3, 23);
1879 fail("Not yet implemented");
1880 //assertTrue(Core.checkRange(gray0, true, null, 3, 23));
1883 public void testRectangleMatPointPointScalar() {
1884 Point bottomRight = new Point(gray0.cols() / 2, gray0.rows() / 2);
1885 Point topLeft = new Point(0, 0);
1886 Scalar color = new Scalar(128);
1888 Core.rectangle(gray0, bottomRight, topLeft, color);
1890 assertTrue(0 != Core.countNonZero(gray0));
1893 public void testRectangleMatPointPointScalarInt() {
1894 Point bottomRight = new Point(gray0.cols(), gray0.rows());
1895 Point topLeft = new Point(0, 0);
1896 Scalar color = new Scalar(128);
1898 Core.rectangle(gray0, bottomRight, topLeft, color, 2);
1899 Core.rectangle(gray0, bottomRight, topLeft, colorBlack);
1901 assertTrue(0 != Core.countNonZero(gray0));
1904 public void testRectangleMatPointPointScalarIntInt() {
1905 Point bottomRight = new Point(gray0.cols() / 2, gray0.rows() / 2);
1906 Point topLeft = new Point(0, 0);
1907 Scalar color = new Scalar(128);
1909 Core.rectangle(gray0, bottomRight, topLeft, color, 2, Core.LINE_AA, 0);
1910 Core.rectangle(gray0, bottomRight, topLeft, colorBlack, 2, Core.LINE_4, 0);
1912 assertTrue(0 != Core.countNonZero(gray0));
1915 public void testRectangleMatPointPointScalarIntIntInt() {
1916 Point bottomRight1 = new Point(gray0.cols(), gray0.rows());
1917 Point bottomRight2 = new Point(gray0.cols() / 2, gray0.rows() / 2);
1918 Point topLeft = new Point(0, 0);
1919 Scalar color = new Scalar(128);
1921 Core.rectangle(gray0, bottomRight1, topLeft, color, 2, Core.LINE_8, 1);
1923 assertTrue(0 != Core.countNonZero(gray0));
1925 Core.rectangle(gray0, bottomRight2, topLeft, colorBlack, 2, Core.LINE_8, 0);
1927 assertEquals(0, Core.countNonZero(gray0));
1930 public void testReduceMatMatIntInt() {
1931 Mat src = new Mat(2, 2, CvType.CV_32F) {
1938 Core.reduce(src, dst, 0, Core.REDUCE_AVG);
1940 Mat out = new Mat(1, 2, CvType.CV_32F) {
1945 assertMatEqual(out, dst, EPS);
1948 public void testReduceMatMatIntIntInt() {
1949 Mat src = new Mat(2, 2, CvType.CV_32F) {
1956 Core.reduce(src, dst, 1, Core.REDUCE_SUM, CvType.CV_64F);
1958 Mat out = new Mat(2, 1, CvType.CV_64F) {
1963 assertMatEqual(out, dst, EPS);
1966 public void testRepeat() {
1967 Mat src = new Mat(1, 2, CvType.CV_32F, new Scalar(0));
1969 Core.repeat(src, matSize, matSize / 2, dst);
1971 assertMatEqual(gray0_32f, dst, EPS);
1974 public void testScaleAdd() {
1975 Core.scaleAdd(gray3, 2.0, gray3, dst);
1977 assertMatEqual(gray9, dst);
1980 public void testSetIdentityMat() {
1981 Core.setIdentity(gray0_32f);
1983 assertMatEqual(grayE_32f, gray0_32f, EPS);
1986 public void testSetIdentityMatScalar() {
1989 Core.setIdentity(m, new Scalar(5));
1991 truth = new Mat(m.size(), m.type(), new Scalar(0));
1992 truth.diag().setTo(new Scalar(5));
1993 assertMatEqual(truth, m, EPS);
1996 public void testSolveCubic() {
1997 Mat coeffs = new Mat(1, 4, CvType.CV_32F) {
1999 put(0, 0, 1, 6, 11, 6);
2003 assertEquals(3, Core.solveCubic(coeffs, dst));
2005 Mat roots = new Mat(3, 1, CvType.CV_32F) {
2007 put(0, 0, -3, -1, -2);
2010 assertMatEqual(roots, dst, EPS);
2013 public void testSolveMatMatMat() {
2014 Mat a = new Mat(3, 3, CvType.CV_32F) {
2017 put(1, 0, 1, -2, 2);
2021 Mat b = new Mat(3, 1, CvType.CV_32F) {
2027 assertTrue(Core.solve(a, b, dst));
2029 Mat res = new Mat(3, 1, CvType.CV_32F) {
2031 put(0, 0, -12, 2, 10);
2034 assertMatEqual(res, dst, EPS);
2037 public void testSolveMatMatMatInt() {
2038 Mat a = new Mat(3, 3, CvType.CV_32F) {
2041 put(1, 0, 1, -2, 2);
2045 Mat b = new Mat(3, 1, CvType.CV_32F) {
2051 assertTrue(Core.solve(a, b, dst, Core.DECOMP_QR | Core.DECOMP_NORMAL));
2053 Mat res = new Mat(3, 1, CvType.CV_32F) {
2055 put(0, 0, -12, 2, 10);
2058 assertMatEqual(res, dst, EPS);
2061 public void testSolvePolyMatMat() {
2062 Mat coeffs = new Mat(4, 1, CvType.CV_32F) {
2064 put(0, 0, -6, 11, -6, 1);
2067 Mat roots = new Mat();
2069 assertEquals(0.0, Core.solvePoly(coeffs, roots));
2071 truth = new Mat(3, 1, CvType.CV_32FC2) {
2073 put(0, 0, 1, 0, 2, 0, 3, 0);
2076 assertMatEqual(truth, roots, EPS);
2079 public void testSolvePolyMatMatInt() {
2080 Mat coeffs = new Mat(4, 1, CvType.CV_32F) {
2082 put(0, 0, -6, 11, -6, 1);
2085 Mat roots = new Mat();
2087 assertEquals(10.198039027185569, Core.solvePoly(coeffs, roots, 1));
2089 truth = new Mat(3, 1, CvType.CV_32FC2) {
2091 put(0, 0, 1, 0, -1, 2, -2, 12);
2094 assertMatEqual(truth, roots, EPS);
2097 public void testSort() {
2098 Mat submat = gray0.submat(0, gray0.rows() / 2, 0, gray0.cols() / 2);
2099 submat.setTo(new Scalar(1.0));
2101 Core.sort(gray0, dst, Core.SORT_EVERY_ROW);
2103 submat = dst.submat(0, dst.rows() / 2, dst.cols() / 2, dst.cols());
2104 assertTrue(submat.total() == Core.countNonZero(submat));
2106 Core.sort(gray0, dst, Core.SORT_EVERY_COLUMN);
2108 submat = dst.submat(dst.rows() / 2, dst.rows(), 0, dst.cols() / 2);
2110 assertTrue(submat.total() == Core.countNonZero(submat));
2113 public void testSortIdx() {
2114 Mat a = Mat.eye(3, 3, CvType.CV_8UC1);
2117 Core.sortIdx(a, b, Core.SORT_EVERY_ROW | Core.SORT_ASCENDING);
2119 truth = new Mat(3, 3, CvType.CV_32SC1) {
2126 assertMatEqual(truth, b);
2129 public void testSplit() {
2130 Mat m = getMat(CvType.CV_8UC3, 1, 2, 3);
2131 ArrayList<Mat> cois = new ArrayList<Mat>();
2133 Core.split(m, cois);
2135 assertMatEqual(gray1, cois.get(0));
2136 assertMatEqual(gray2, cois.get(1));
2137 assertMatEqual(gray3, cois.get(2));
2140 public void testSqrt() {
2141 Core.sqrt(gray9_32f, dst);
2143 assertMatEqual(gray3_32f, dst, EPS);
2145 Mat rgba144 = new Mat(matSize, matSize, CvType.CV_32FC4, Scalar.all(144));
2146 Mat rgba12 = new Mat(matSize, matSize, CvType.CV_32FC4, Scalar.all(12));
2148 Core.sqrt(rgba144, dst);
2150 assertMatEqual(rgba12, dst, EPS);
2153 public void testSubtractMatMatMat() {
2154 Core.subtract(gray128, gray1, dst);
2156 assertMatEqual(gray127, dst);
2159 public void testSubtractMatMatMatMat() {
2160 Mat mask = makeMask(gray1.clone());
2161 dst = gray128.clone();
2163 Core.subtract(gray128, gray1, dst, mask);
2165 assertMatEqual(makeMask(gray127, 128), dst);
2168 public void testSubtractMatMatMatMatInt() {
2169 Core.subtract(gray3, gray2, dst, gray1, CvType.CV_32F);
2171 assertMatEqual(gray1_32f, dst, EPS);
2174 public void testSumElems() {
2175 Mat src = new Mat(4, 4, CvType.CV_8U, new Scalar(10));
2177 Scalar res1 = Core.sumElems(src);
2179 assertScalarEqual(new Scalar(160), res1, EPS);
2182 public void testSVBackSubst() {
2183 Mat w = new Mat(2, 2, CvType.CV_32FC1, new Scalar(2));
2184 Mat u = new Mat(2, 2, CvType.CV_32FC1, new Scalar(4));
2185 Mat vt = new Mat(2, 2, CvType.CV_32FC1, new Scalar(2));
2186 Mat rhs = new Mat(2, 2, CvType.CV_32FC1, new Scalar(1));
2188 Core.SVBackSubst(w, u, vt, rhs, dst);
2190 Mat truth = new Mat(2, 2, CvType.CV_32FC1, new Scalar(16));
2191 assertMatEqual(truth, dst, EPS);
2194 public void testSVDecompMatMatMatMat() {
2195 Mat src = new Mat(1, 4, CvType.CV_32FC1) {
2197 put(0, 0, 1, 4, 8, 6);
2204 Core.SVDecomp(src, w, u, vt);
2206 Mat truthW = new Mat(1, 1, CvType.CV_32FC1, new Scalar(10.816654));
2207 Mat truthU = new Mat(1, 1, CvType.CV_32FC1, new Scalar(1));
2208 Mat truthVT = new Mat(1, 4, CvType.CV_32FC1) {
2210 put(0, 0, 0.09245003, 0.36980012, 0.73960024, 0.5547002);
2213 assertMatEqual(truthW, w, EPS);
2214 assertMatEqual(truthU, u, EPS);
2215 assertMatEqual(truthVT, vt, EPS);
2218 public void testSVDecompMatMatMatMatInt() {
2219 Mat src = new Mat(1, 4, CvType.CV_32FC1) {
2221 put(0, 0, 1, 4, 8, 6);
2228 Core.SVDecomp(src, w, u, vt, Core.SVD_NO_UV);
2230 Mat truthW = new Mat(1, 1, CvType.CV_32FC1, new Scalar(10.816654));
2231 assertMatEqual(truthW, w, EPS);
2232 assertTrue(u.empty());
2233 assertTrue(vt.empty());
2236 public void testTrace() {
2237 Scalar s = Core.trace(gray1);
2239 assertEquals(new Scalar(matSize), s);
2242 public void testTransform() {
2243 Mat src = new Mat(2, 2, CvType.CV_32F, new Scalar(55));
2244 Mat m = Mat.eye(2, 2, CvType.CV_32FC1);
2246 Core.transform(src, dst, m);
2248 truth = new Mat(2, 2, CvType.CV_32FC2, new Scalar(55, 1));
2249 assertMatEqual(truth, dst, EPS);
2252 public void testTranspose() {
2253 gray0.submat(0, gray0.rows() / 2, 0, gray0.cols()).setTo(new Scalar(1));
2254 Mat destination = getMat(CvType.CV_8U, 0);
2256 Core.transpose(gray0, destination);
2258 Mat subdst = destination.submat(0, destination.rows(), 0, destination.cols() / 2);
2259 assertTrue(subdst.total() == Core.countNonZero(subdst));
2262 public void testVconcat() {
2263 List<Mat> mats = Arrays.asList(Mat.eye(3, 3, CvType.CV_8U), Mat.zeros(2, 3, CvType.CV_8U));
2265 Core.vconcat(mats, dst);
2267 assertMatEqual(Mat.eye(5, 3, CvType.CV_8U), dst);