Skip to content

Commit dd25d8c

Browse files
authored
Merge pull request #2046 from shimat/feature/wasm-dnn-smoke-test
Add a dnn smoke check to the wasm E2E test
2 parents 3676d90 + ea4e642 commit dd25d8c

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

test/OpenCvSharp.Tests.Wasm/App.razor

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@
66
for JPEG/PNG/TIFF guards against the codecs building but silently no-op'ing - or hanging - on
77
wasm (#2043). libjpeg-turbo/libpng/libtiff use setjmp/longjmp for error handling, which hung
88
(rather than threw) when OpenCvSharpExtern.a was built with a different Emscripten version than
9-
the one the .NET wasm SDK links it with; see EM_VERSION in .github/workflows/wasm.yml. *@
9+
the one the .NET wasm SDK links it with; see EM_VERSION in .github/workflows/wasm.yml. A
10+
Cv2.Dnn.BlobFromImage call exercises the dnn module's native wrapper without needing a trained
11+
model file on disk, guarding against the OpenCV build config showing dnn as built while the
12+
wasm wrapper actually fails to link or crashes at runtime. *@
1013

1114
<pre id="result" data-status="@status">@status: @detail</pre>
1215

@@ -40,8 +43,17 @@
4043
throw new InvalidOperationException($"ImDecode({ext}) round trip failed: empty={decoded.Empty()}, size={decoded.Size()}");
4144
}
4245

46+
// Exercises the dnn module's native wrapper (cv::dnn::blobFromImage) without loading a trained
47+
// model file - just confirms the wasm build actually links and runs dnn, not merely that OpenCV's
48+
// CMake config reports it as built.
49+
using var blob = Cv2.Dnn.BlobFromImage(mat, size: new Size(64, 64));
50+
if (blob.Empty())
51+
throw new InvalidOperationException("Cv2.Dnn.BlobFromImage produced an empty blob");
52+
53+
var blobShape = string.Join('x', Enumerable.Range(0, blob.Dims).Select(blob.Size));
54+
4355
status = "ok";
44-
detail = $"OpenCV {version}, ORB keypoints: {keypoints.Length}";
56+
detail = $"OpenCV {version}, ORB keypoints: {keypoints.Length}, dnn blob shape: {blobShape}";
4557
}
4658
catch (Exception ex)
4759
{

0 commit comments

Comments
 (0)