1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-29 15:23:05 +04:00

Add Java wrapper support for List<List<MatShape>>

- Added vector_MatShape and vector_vector_MatShape to gen_dict.json
- Implemented MatShape_to_vector_MatShape, vector_MatShape_to_MatShape, MatShape_to_vector_vector_MatShape, and vector_vector_MatShape_to_MatShape conversion functions in dnn_converters.h/cpp and Converters.java
- Added testGetLayersShapes test to verify List<List<MatShape>> conversion
This commit is contained in:
utibenkei
2025-08-01 23:14:17 +09:00
parent 7a4bd85299
commit 81b66cf972
5 changed files with 175 additions and 22 deletions
@@ -116,4 +116,36 @@ public class DnnListRegressionTest extends OpenCVTestCase {
fail("Net getFLOPS failed: " + e.getMessage());
}
}
public void testGetLayersShapes() {
List<MatOfInt> netInputShapes = new ArrayList();
netInputShapes.add(new MatOfInt(1, 3, 224, 224));
MatOfInt layersIds = new MatOfInt();
List<List<MatOfInt>> inLayersShapes = new ArrayList();
List<List<MatOfInt>> outLayersShapes = new ArrayList();
try {
net.getLayersShapes(netInputShapes, layersIds, inLayersShapes, outLayersShapes);
assertEquals(layersIds.total(), inLayersShapes.size());
assertEquals(layersIds.total(), outLayersShapes.size());
// Layer ID for "conv2d0_pre_relu/conv"
int layerId = 1;
MatOfInt expectedInShape = new MatOfInt(1, 3, 224, 224);
MatOfInt expectedOutShape = new MatOfInt(1, 64, 112, 112);
// Test inLayersShapes
MatOfInt actualInShape = inLayersShapes.get(layerId).get(0);
assertMatEqual(expectedInShape, actualInShape);
// Test outLayersShapes
MatOfInt actualOutShape = outLayersShapes.get(layerId).get(0);
assertMatEqual(expectedOutShape, actualOutShape);
} catch(Exception e) {
fail("Net getLayersShapes failed: " + e.getMessage());
}
}
}