mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #29074 from varun-jaiswal17:data-layout-wrapper-java
Add missing DataLayout constants in generated bindings for 5.x #29074 - Added DATA_LAYOUT_* constants to missing_consts so they are manually injected into Core.java (same approach used for CV_8U, FILLED etc.) - Added DataLayout entry to type_dict so the generator correctly maps DataLayout ### Tests modules/dnn/misc/java/test/DnnBlobFromImageWithParamsTest.java: New test added: - testDataLayoutConstants: verifies all DATA_LAYOUT_* constants are accessible from Core Pre-existing tests enabled (were commented out earlier): - testBlobFromImageWithParamsNHWCScalarScale: verifies blobFromImageWithParams produces correct output with DATA_LAYOUT_NHWC and per-channel scalar scaling - testBlobFromImageWithParams4chMultiImage: verifies blobFromImagesWithParams correctly handles a batch of images with DATA_LAYOUT_NHWC layout Closes : #27264 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -20,7 +20,10 @@
|
||||
"public" : [
|
||||
["SVD_MODIFY_A", 1], ["SVD_NO_UV", 2], ["SVD_FULL_UV", 4],
|
||||
["FILLED", -1],
|
||||
["REDUCE_SUM", 0], ["REDUCE_AVG", 1], ["REDUCE_MAX", 2], ["REDUCE_MIN", 3]
|
||||
["REDUCE_SUM", 0], ["REDUCE_AVG", 1], ["REDUCE_MAX", 2], ["REDUCE_MIN", 3],
|
||||
["DATA_LAYOUT_UNKNOWN", 0], ["DATA_LAYOUT_ND", 1], ["DATA_LAYOUT_NCHW", 2],
|
||||
["DATA_LAYOUT_NCDHW", 3], ["DATA_LAYOUT_NHWC", 4], ["DATA_LAYOUT_NDHWC", 5],
|
||||
["DATA_LAYOUT_PLANAR", 6], ["DATA_LAYOUT_BLOCK", 7]
|
||||
]
|
||||
}
|
||||
},
|
||||
@@ -166,6 +169,14 @@
|
||||
"suffix": "II",
|
||||
"j_import": "org.opencv.core.Range"
|
||||
},
|
||||
"DataLayout": {
|
||||
"cast_from": "int",
|
||||
"cast_to": "cv::DataLayout",
|
||||
"j_type": "int",
|
||||
"jn_type": "int",
|
||||
"jni_type": "jint",
|
||||
"suffix": "I"
|
||||
},
|
||||
"CvTermCriteria": {
|
||||
"j_type": "TermCriteria",
|
||||
"jn_args": [
|
||||
|
||||
@@ -15,17 +15,28 @@ import org.opencv.test.OpenCVTestCase;
|
||||
|
||||
public class DnnBlobFromImageWithParamsTest extends OpenCVTestCase {
|
||||
|
||||
// test for DATA_LAYOUT_* and DNN_LAYOUT_* access from Core
|
||||
public void testDataLayoutConstants()
|
||||
{
|
||||
assertEquals(0, Core.DATA_LAYOUT_UNKNOWN);
|
||||
assertEquals(1, Core.DATA_LAYOUT_ND);
|
||||
assertEquals(2, Core.DATA_LAYOUT_NCHW);
|
||||
assertEquals(3, Core.DATA_LAYOUT_NCDHW);
|
||||
assertEquals(4, Core.DATA_LAYOUT_NHWC);
|
||||
assertEquals(5, Core.DATA_LAYOUT_NDHWC);
|
||||
assertEquals(6, Core.DATA_LAYOUT_PLANAR);
|
||||
assertEquals(7, Core.DATA_LAYOUT_BLOCK);
|
||||
}
|
||||
|
||||
public void testBlobFromImageWithParamsNHWCScalarScale()
|
||||
{
|
||||
// https://github.com/opencv/opencv/issues/27264
|
||||
/*
|
||||
Mat img = new Mat(10, 10, CvType.CV_8UC4, new Scalar(0, 1, 2, 3));
|
||||
Scalar scalefactor = new Scalar(0.1, 0.2, 0.3, 0.4);
|
||||
|
||||
Image2BlobParams params = new Image2BlobParams();
|
||||
params.set_scalefactor(scalefactor);
|
||||
params.set_datalayout(Core.DATA_LAYOUT_NHWC);
|
||||
return;
|
||||
|
||||
Mat blob = Dnn.blobFromImageWithParams(img, params); // [1, 10, 10, 4]
|
||||
|
||||
@@ -43,7 +54,6 @@ public class DnnBlobFromImageWithParamsTest extends OpenCVTestCase {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void testBlobFromImageWithParamsCustomPaddingLetterBox()
|
||||
@@ -105,7 +115,6 @@ public class DnnBlobFromImageWithParamsTest extends OpenCVTestCase {
|
||||
// https://github.com/opencv/opencv/issues/27264
|
||||
public void testBlobFromImageWithParams4chMultiImage()
|
||||
{
|
||||
/*
|
||||
Mat img = new Mat(10, 10, CvType.CV_8UC4, new Scalar(0, 1, 2, 3));
|
||||
|
||||
Scalar scalefactor = new Scalar(0.1, 0.2, 0.3, 0.4);
|
||||
@@ -113,7 +122,6 @@ public class DnnBlobFromImageWithParamsTest extends OpenCVTestCase {
|
||||
Image2BlobParams param = new Image2BlobParams();
|
||||
param.set_scalefactor(scalefactor);
|
||||
param.set_datalayout(Core.DATA_LAYOUT_NHWC);
|
||||
return;
|
||||
|
||||
List<Mat> images = new ArrayList<>();
|
||||
images.add(img);
|
||||
@@ -137,6 +145,5 @@ public class DnnBlobFromImageWithParamsTest extends OpenCVTestCase {
|
||||
Core.multiply(blob0, Scalar.all(2), blob0);
|
||||
|
||||
assertEquals(0, Core.norm(blob0, blob1, Core.NORM_INF), EPS);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user