Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
16 changes: 9 additions & 7 deletions pkgs/o/opencv.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@
-- mcpp.toml. mcpp's default lookup finds <verdir>/*/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 = {
Expand All @@ -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",
},
},
},
Expand Down
15 changes: 15 additions & 0 deletions tests/examples/opencv-module-dnn/mcpp.toml
Original file line number Diff line number Diff line change
@@ -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"] }
27 changes: 27 additions & 0 deletions tests/examples/opencv-module-dnn/tests/opencv_dnn_iface.cpp
Original file line number Diff line number Diff line change
@@ -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<float>(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
14 changes: 14 additions & 0 deletions tests/examples/opencv-module-unifont/mcpp.toml
Original file line number Diff line number Diff line change
@@ -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"] }
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion tests/examples/opencv-module/mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ version = "0.1.0"
default = { path = "../../.." }

[target.'cfg(linux)'.dependencies]
opencv = "0.0.3"
opencv = "0.0.4"
Loading