Skip to content

Commit 1e2ae01

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 that exercise 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. Validated on mcpp 0.0.99 locally (opencv-m PR#5 green): DnnModule.BlobFromImageAndNet + UnifontModule.CjkPutTextInks.
1 parent b6640cc commit 1e2ae01

7 files changed

Lines changed: 86 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: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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).
6+
#ifdef __linux__
7+
import opencv.cv;
8+
import opencv.dnn;
9+
#include <cstdio>
10+
11+
int main() {
12+
cv::Mat img(32, 32, cv::CV_8UC3, cv::Scalar(10, 20, 30));
13+
cv::Mat blob = cv::dnn::blobFromImage(img, 1.0 / 255.0, cv::Size(16, 16),
14+
cv::Scalar(), true, false);
15+
if (blob.dims != 4 || blob.size[0] != 1 || blob.size[1] != 3
16+
|| blob.size[2] != 16 || blob.size[3] != 16) return 1;
17+
float v = blob.ptr<float>(0)[0];
18+
if (v < 0.117f || v > 0.118f) return 2; // 30/255, channels swapped
19+
cv::dnn::Net net;
20+
if (!net.empty()) return 3;
21+
std::printf("opencv.dnn module ok: blobFromImage 1x3x16x16 first=%f\n", v);
22+
return 0;
23+
}
24+
#else
25+
int main() { return 0; }
26+
#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: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
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).
4+
#ifdef __linux__
5+
import opencv.cv;
6+
#include <cstdio>
7+
8+
int main() {
9+
cv::FontFace uni("uni");
10+
cv::Mat img(64, 256, cv::CV_8UC1, cv::Scalar(0));
11+
cv::putText(img, "中文字体", cv::Point(8, 44), cv::Scalar(255), uni, 28);
12+
int ink = cv::countNonZero(img);
13+
if (ink < 100) { std::printf("opencv.unifont: CJK ink %d too low\n", ink); return 1; }
14+
std::printf("opencv.unifont module ok: CJK putText ink=%d\n", ink);
15+
return 0;
16+
}
17+
#else
18+
int main() { return 0; }
19+
#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)