Add methods to reshape Mat in Java by array of shapes and retreive sizes of each dimension.

This commit is contained in:
Dmitry Kurtaev
2018-10-25 10:48:23 +03:00
parent 9a12aa45ad
commit 92f754c675
3 changed files with 90 additions and 0 deletions
+13
View File
@@ -817,6 +817,19 @@ public class MatTest extends OpenCVTestCase {
assertMatEqual(truth, dst);
}
public void testReshapeIntIntArray() {
Mat src = new Mat(6, 5, CvType.CV_8UC3, new Scalar(0));
assertEquals(2, src.dims());
assertEquals(src.rows(), src.size(0));
assertEquals(src.cols(), src.size(1));
int[] newShape = {1, src.channels() * src.cols(), 1, src.rows()};
dst = src.reshape(1, newShape);
assertEquals(newShape.length, dst.dims());
for (int i = 0; i < newShape.length; ++i)
assertEquals(newShape[i], dst.size(i));
}
public void testRow() {
Mat row = gray0.row(0);
assertEquals(1, row.rows());