Skip to content

Commit a384383

Browse files
committed
feat(pkg): opencv 0.0.4 — module-level dnn/unifont features (import opencv.dnn)
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).
1 parent b6640cc commit a384383

7 files changed

Lines changed: 88 additions & 8 deletions

File tree

mcpp.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@ members = [
2929
"tests/examples/opencv-unifont",
3030
"tests/examples/opencv-dnn",
3131
"tests/examples/opencv-module",
32+
"tests/examples/opencv-module-dnn",
33+
"tests/examples/opencv-module-unifont",
3234
"tests/examples/spdlog",
3335
"tests/examples/spdlog-compiled",
3436
"tests/examples/tinyhttps",

pkgs/o/opencv.lua

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22
-- mcpp.toml. mcpp's default lookup finds <verdir>/*/mcpp.toml inside
33
-- the GitHub source tarball wrap.
44
--
5-
-- The package is the thin C++23 module layer (import opencv.cv; and 7
5+
-- The package is the thin C++23 module layer (import opencv.cv; and the
66
-- per-module interfaces) over OpenCV 5's unchanged C++ API; the OpenCV
77
-- sources themselves arrive through its compat.opencv dependency (full
88
-- source build with SIMD dispatch + build.mcpp consumer-side synthesis,
9-
-- plus the compat.ffmpeg videoio backend — see pkgs/c/compat.opencv.lua;
10-
-- the transitional compat.opencv5 alias is retired as of this bump).
9+
-- plus the compat.ffmpeg videoio backend — see pkgs/c/compat.opencv.lua).
10+
-- Optional features (0.0.4+, mcpp#243 forwarding): `dnn` adds the
11+
-- import opencv.dnn; interface and forwards compat.opencv/dnn; `unifont`
12+
-- forwards compat.opencv/unifont — `opencv = { features = ["dnn"] }`.
1113
-- Linux-only for now: compat.opencv carries a linux-x86_64 config snapshot.
1214
--
1315
package = {
@@ -21,12 +23,12 @@ package = {
2123

2224
xpm = {
2325
linux = {
24-
["0.0.3"] = {
26+
["0.0.4"] = {
2527
url = {
26-
GLOBAL = "https://github.com/Sunrisepeak/opencv-m/archive/refs/tags/v0.0.3.tar.gz",
27-
CN = "https://gitcode.com/mcpp-res/opencv/releases/download/v0.0.3/opencv-m-0.0.3.tar.gz",
28+
GLOBAL = "https://github.com/Sunrisepeak/opencv-m/archive/refs/tags/v0.0.4.tar.gz",
29+
CN = "https://gitcode.com/mcpp-res/opencv/releases/download/v0.0.4/opencv-m-0.0.4.tar.gz",
2830
},
29-
sha256 = "92ffae8bc4253538143319fba59d4933831a92bb03394126baae2f0a3d4b0e2b",
31+
sha256 = "a2e95e8b22ae66712e3f78809426e058330073c2679a21c2b2d500faa0b4964f",
3032
},
3133
},
3234
},
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Public `opencv` module package `dnn` FEATURE test: `opencv = { features =
2+
# ["dnn"] }` forwards compat.opencv/dnn (mcpp#243) AND compiles opencv-m's
3+
# opencv.dnn interface, so `import opencv.dnn;` is available. Reuses the
4+
# compat.opencv+dnn store artifact built by the opencv-dnn member (same feature
5+
# set — no extra heavy build). Linux-only (compat.opencv linux snapshot);
6+
# off-Linux the test compiles to a no-op main().
7+
[package]
8+
name = "opencv-module-dnn-tests"
9+
version = "0.1.0"
10+
11+
[indices]
12+
default = { path = "../../.." }
13+
14+
[target.'cfg(linux)'.dependencies]
15+
opencv = { version = "0.0.4", features = ["dnn"] }
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
// The opencv.dnn MODULE interface (not textual headers) must expose the dnn
2+
// surface when opencv is pulled with features=["dnn"] — proves the module-level
3+
// dep/feat forward compiled src/dnn.cppm and built compat.opencv with dnn.
4+
// Linux-only (see mcpp.toml). Not named dnn.cpp (would collide with the dep's
5+
// modules/dnn/src/dnn.cpp — #240 family). Import-only (import std + the opencv
6+
// modules): no textual headers, matching the ffmpeg-module member convention.
7+
#ifdef __linux__
8+
import std;
9+
import opencv.cv;
10+
import opencv.dnn;
11+
12+
int main() {
13+
cv::Mat img(32, 32, cv::CV_8UC3, cv::Scalar(10, 20, 30));
14+
cv::Mat blob = cv::dnn::blobFromImage(img, 1.0 / 255.0, cv::Size(16, 16),
15+
cv::Scalar(), true, false);
16+
if (blob.dims != 4 || blob.size[0] != 1 || blob.size[1] != 3
17+
|| blob.size[2] != 16 || blob.size[3] != 16) return 1;
18+
float v = blob.ptr<float>(0)[0];
19+
if (v < 0.117f || v > 0.118f) return 2; // 30/255, channels swapped
20+
cv::dnn::Net net;
21+
if (!net.empty()) return 3;
22+
std::println("opencv.dnn module ok: blobFromImage 1x3x16x16 first={}", v);
23+
return 0;
24+
}
25+
#else
26+
int main() { return 0; }
27+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Public `opencv` module package `unifont` FEATURE test: `opencv = { features =
2+
# ["unifont"] }` forwards compat.opencv/unifont (mcpp#243 — pure forward, no new
3+
# module surface), so FontFace("uni") renders CJK through `import opencv.cv;`.
4+
# Reuses the compat.opencv+unifont store artifact from the opencv-unifont member.
5+
# Linux-only; no-op main elsewhere.
6+
[package]
7+
name = "opencv-module-unifont-tests"
8+
version = "0.1.0"
9+
10+
[indices]
11+
default = { path = "../../.." }
12+
13+
[target.'cfg(linux)'.dependencies]
14+
opencv = { version = "0.0.4", features = ["unifont"] }
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// The "uni" FontFace only exists when opencv's unifont feature forwarded
2+
// compat.opencv/unifont — CJK rendering through the module layer must ink.
3+
// Linux-only (see mcpp.toml). Import-only (import std + opencv.cv): no textual
4+
// headers, matching the ffmpeg-module member convention.
5+
#ifdef __linux__
6+
import std;
7+
import opencv.cv;
8+
9+
int main() {
10+
cv::FontFace uni("uni");
11+
cv::Mat img(64, 256, cv::CV_8UC1, cv::Scalar(0));
12+
cv::putText(img, "中文字体", cv::Point(8, 44), cv::Scalar(255), uni, 28);
13+
int ink = cv::countNonZero(img);
14+
if (ink < 100) { std::println("opencv.unifont: CJK ink {} too low", ink); return 1; }
15+
std::println("opencv.unifont module ok: CJK putText ink={}", ink);
16+
return 0;
17+
}
18+
#else
19+
int main() { return 0; }
20+
#endif

tests/examples/opencv-module/mcpp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ version = "0.1.0"
1717
default = { path = "../../.." }
1818

1919
[target.'cfg(linux)'.dependencies]
20-
opencv = "0.0.3"
20+
opencv = "0.0.4"

0 commit comments

Comments
 (0)