From a3843837c160213f5b2bc271cefb4a7b34aa19db Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 19 Jul 2026 13:22:36 +0800 Subject: [PATCH] =?UTF-8?q?feat(pkg):=20opencv=200.0.4=20=E2=80=94=20modul?= =?UTF-8?q?e-level=20dnn/unifont=20features=20(import=20opencv.dnn)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit opencv-m v0.0.4 exposes compat.opencv's optional features through the module package via mcpp#243 dep/feat forwarding. Bump 0.0.3 -> 0.0.4 (v0.0.4 tarball GLOBAL + CN mirror, sha256 a2e95e8b…; byte-identical, mirror-cn verified). Adds two end-to-end workspace members exercising the consumer path (opencv = { features = ["dnn"|"unifont"] } -> import opencv.dnn / the "uni" FontFace): tests/examples/opencv-module-{dnn,unifont}. They reuse the compat.opencv+dnn / +unifont store artifacts already built by the compat-level opencv-dnn / opencv-unifont members, so no extra heavy build. opencv-module repinned to 0.0.4. Member test TUs are import-only (`import std; import opencv.cv[/.dnn];`) — no textual headers, matching the ffmpeg-module member convention (import std works alongside the opencv module packages on gcc16). Validated on mcpp 0.0.99: opencv-m PR#5 green; index CI compat builds green (dnn feature ok, unifont ink=1301, FFmpeg roundtrip). --- mcpp.toml | 2 ++ pkgs/o/opencv.lua | 16 ++++++----- tests/examples/opencv-module-dnn/mcpp.toml | 15 +++++++++++ .../tests/opencv_dnn_iface.cpp | 27 +++++++++++++++++++ .../examples/opencv-module-unifont/mcpp.toml | 14 ++++++++++ .../tests/opencv_unifont_iface.cpp | 20 ++++++++++++++ tests/examples/opencv-module/mcpp.toml | 2 +- 7 files changed, 88 insertions(+), 8 deletions(-) create mode 100644 tests/examples/opencv-module-dnn/mcpp.toml create mode 100644 tests/examples/opencv-module-dnn/tests/opencv_dnn_iface.cpp create mode 100644 tests/examples/opencv-module-unifont/mcpp.toml create mode 100644 tests/examples/opencv-module-unifont/tests/opencv_unifont_iface.cpp diff --git a/mcpp.toml b/mcpp.toml index 8cc3558..426b8e5 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -29,6 +29,8 @@ members = [ "tests/examples/opencv-unifont", "tests/examples/opencv-dnn", "tests/examples/opencv-module", + "tests/examples/opencv-module-dnn", + "tests/examples/opencv-module-unifont", "tests/examples/spdlog", "tests/examples/spdlog-compiled", "tests/examples/tinyhttps", diff --git a/pkgs/o/opencv.lua b/pkgs/o/opencv.lua index 4e6780a..45c0880 100644 --- a/pkgs/o/opencv.lua +++ b/pkgs/o/opencv.lua @@ -2,12 +2,14 @@ -- mcpp.toml. mcpp's default lookup finds /*/mcpp.toml inside -- the GitHub source tarball wrap. -- --- The package is the thin C++23 module layer (import opencv.cv; and 7 +-- The package is the thin C++23 module layer (import opencv.cv; and the -- per-module interfaces) over OpenCV 5's unchanged C++ API; the OpenCV -- sources themselves arrive through its compat.opencv dependency (full -- source build with SIMD dispatch + build.mcpp consumer-side synthesis, --- plus the compat.ffmpeg videoio backend — see pkgs/c/compat.opencv.lua; --- the transitional compat.opencv5 alias is retired as of this bump). +-- plus the compat.ffmpeg videoio backend — see pkgs/c/compat.opencv.lua). +-- Optional features (0.0.4+, mcpp#243 forwarding): `dnn` adds the +-- import opencv.dnn; interface and forwards compat.opencv/dnn; `unifont` +-- forwards compat.opencv/unifont — `opencv = { features = ["dnn"] }`. -- Linux-only for now: compat.opencv carries a linux-x86_64 config snapshot. -- package = { @@ -21,12 +23,12 @@ package = { xpm = { linux = { - ["0.0.3"] = { + ["0.0.4"] = { url = { - GLOBAL = "https://github.com/Sunrisepeak/opencv-m/archive/refs/tags/v0.0.3.tar.gz", - CN = "https://gitcode.com/mcpp-res/opencv/releases/download/v0.0.3/opencv-m-0.0.3.tar.gz", + GLOBAL = "https://github.com/Sunrisepeak/opencv-m/archive/refs/tags/v0.0.4.tar.gz", + CN = "https://gitcode.com/mcpp-res/opencv/releases/download/v0.0.4/opencv-m-0.0.4.tar.gz", }, - sha256 = "92ffae8bc4253538143319fba59d4933831a92bb03394126baae2f0a3d4b0e2b", + sha256 = "a2e95e8b22ae66712e3f78809426e058330073c2679a21c2b2d500faa0b4964f", }, }, }, diff --git a/tests/examples/opencv-module-dnn/mcpp.toml b/tests/examples/opencv-module-dnn/mcpp.toml new file mode 100644 index 0000000..952322b --- /dev/null +++ b/tests/examples/opencv-module-dnn/mcpp.toml @@ -0,0 +1,15 @@ +# Public `opencv` module package `dnn` FEATURE test: `opencv = { features = +# ["dnn"] }` forwards compat.opencv/dnn (mcpp#243) AND compiles opencv-m's +# opencv.dnn interface, so `import opencv.dnn;` is available. Reuses the +# compat.opencv+dnn store artifact built by the opencv-dnn member (same feature +# set — no extra heavy build). Linux-only (compat.opencv linux snapshot); +# off-Linux the test compiles to a no-op main(). +[package] +name = "opencv-module-dnn-tests" +version = "0.1.0" + +[indices] +default = { path = "../../.." } + +[target.'cfg(linux)'.dependencies] +opencv = { version = "0.0.4", features = ["dnn"] } diff --git a/tests/examples/opencv-module-dnn/tests/opencv_dnn_iface.cpp b/tests/examples/opencv-module-dnn/tests/opencv_dnn_iface.cpp new file mode 100644 index 0000000..868b81d --- /dev/null +++ b/tests/examples/opencv-module-dnn/tests/opencv_dnn_iface.cpp @@ -0,0 +1,27 @@ +// The opencv.dnn MODULE interface (not textual headers) must expose the dnn +// surface when opencv is pulled with features=["dnn"] — proves the module-level +// dep/feat forward compiled src/dnn.cppm and built compat.opencv with dnn. +// Linux-only (see mcpp.toml). Not named dnn.cpp (would collide with the dep's +// modules/dnn/src/dnn.cpp — #240 family). Import-only (import std + the opencv +// modules): no textual headers, matching the ffmpeg-module member convention. +#ifdef __linux__ +import std; +import opencv.cv; +import opencv.dnn; + +int main() { + cv::Mat img(32, 32, cv::CV_8UC3, cv::Scalar(10, 20, 30)); + cv::Mat blob = cv::dnn::blobFromImage(img, 1.0 / 255.0, cv::Size(16, 16), + cv::Scalar(), true, false); + if (blob.dims != 4 || blob.size[0] != 1 || blob.size[1] != 3 + || blob.size[2] != 16 || blob.size[3] != 16) return 1; + float v = blob.ptr(0)[0]; + if (v < 0.117f || v > 0.118f) return 2; // 30/255, channels swapped + cv::dnn::Net net; + if (!net.empty()) return 3; + std::println("opencv.dnn module ok: blobFromImage 1x3x16x16 first={}", v); + return 0; +} +#else +int main() { return 0; } +#endif diff --git a/tests/examples/opencv-module-unifont/mcpp.toml b/tests/examples/opencv-module-unifont/mcpp.toml new file mode 100644 index 0000000..113710b --- /dev/null +++ b/tests/examples/opencv-module-unifont/mcpp.toml @@ -0,0 +1,14 @@ +# Public `opencv` module package `unifont` FEATURE test: `opencv = { features = +# ["unifont"] }` forwards compat.opencv/unifont (mcpp#243 — pure forward, no new +# module surface), so FontFace("uni") renders CJK through `import opencv.cv;`. +# Reuses the compat.opencv+unifont store artifact from the opencv-unifont member. +# Linux-only; no-op main elsewhere. +[package] +name = "opencv-module-unifont-tests" +version = "0.1.0" + +[indices] +default = { path = "../../.." } + +[target.'cfg(linux)'.dependencies] +opencv = { version = "0.0.4", features = ["unifont"] } diff --git a/tests/examples/opencv-module-unifont/tests/opencv_unifont_iface.cpp b/tests/examples/opencv-module-unifont/tests/opencv_unifont_iface.cpp new file mode 100644 index 0000000..7147d96 --- /dev/null +++ b/tests/examples/opencv-module-unifont/tests/opencv_unifont_iface.cpp @@ -0,0 +1,20 @@ +// The "uni" FontFace only exists when opencv's unifont feature forwarded +// compat.opencv/unifont — CJK rendering through the module layer must ink. +// Linux-only (see mcpp.toml). Import-only (import std + opencv.cv): no textual +// headers, matching the ffmpeg-module member convention. +#ifdef __linux__ +import std; +import opencv.cv; + +int main() { + cv::FontFace uni("uni"); + cv::Mat img(64, 256, cv::CV_8UC1, cv::Scalar(0)); + cv::putText(img, "中文字体", cv::Point(8, 44), cv::Scalar(255), uni, 28); + int ink = cv::countNonZero(img); + if (ink < 100) { std::println("opencv.unifont: CJK ink {} too low", ink); return 1; } + std::println("opencv.unifont module ok: CJK putText ink={}", ink); + return 0; +} +#else +int main() { return 0; } +#endif diff --git a/tests/examples/opencv-module/mcpp.toml b/tests/examples/opencv-module/mcpp.toml index 4ba1ef5..20c01b5 100644 --- a/tests/examples/opencv-module/mcpp.toml +++ b/tests/examples/opencv-module/mcpp.toml @@ -17,4 +17,4 @@ version = "0.1.0" default = { path = "../../.." } [target.'cfg(linux)'.dependencies] -opencv = "0.0.3" +opencv = "0.0.4"