Skip to content

Commit baa32ff

Browse files
committed
feat: add cross-platform apriltag package
1 parent 985b7ca commit baa32ff

5 files changed

Lines changed: 132 additions & 0 deletions

File tree

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# AprilTag 3.4.5 compat package
2+
3+
- Source: [AprilRobotics/apriltag](https://github.com/AprilRobotics/apriltag), release `v3.4.5`.
4+
- Shape: Form B, C-source compat. The descriptor follows the upstream CMake
5+
library target: detector/pose/thresholding sources, `common/*.c`, all
6+
generated `tag*.c` families, and the `aruco/tag*.c` families. Examples and
7+
the optional Python wrapper are not library sources.
8+
- Platform: Linux, macOS, and Windows. The same source set is used on all
9+
three platforms. The descriptor supplies `_GNU_SOURCE` plus pthread/libm on
10+
Linux, `_DARWIN_C_SOURCE` plus pthread/libm on macOS, and the Windows
11+
CRT/math defines used by the upstream CMake build.
12+
- API/build language: `c_standard = "c99"` for the C sources; the package
13+
manifest remains `language = "c++23"` so it follows mcpp's C++20-and-newer
14+
consumer contract. Platform-specific defines are supplied to the package's
15+
C translation units because the upstream CMake build uses platform CRT
16+
extensions for declarations such as `timespec`, `strdup`, and math constants.
17+
- Archive: `https://github.com/AprilRobotics/apriltag/archive/refs/tags/v3.4.5.tar.gz`.
18+
SHA-256 is
19+
`3749f48220db78c29c375a373861f4e1f4138e5dbae3c298584e96cfcc556515`.
20+
No CN mirror is declared because no mcpp-res upload was available; the
21+
descriptor uses the permitted plain upstream URL fallback.
22+
- Test: `tests/examples/apriltag` is a cross-platform member that creates a detector and the
23+
`tagStandard41h12` family, runs detection on a blank image, checks the empty
24+
result, and destroys every object. This verifies header exposure, all
25+
required symbols, pthread linkage, and the basic runtime lifecycle.

‎mcpp.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ members = [
106106
"tests/examples/glm",
107107
"tests/examples/libaio",
108108
"tests/examples/libserial",
109+
"tests/examples/apriltag",
109110
"tests/examples/libassert",
110111
"tests/examples/libcoro",
111112
"tests/examples/libdrm",

‎pkgs/c/compat.apriltag.lua‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
-- compat.apriltag — AprilTag 3.4.5, a visual fiducial detection library.
2+
--
3+
-- Shape A (C-source compat). The upstream CMake target consists of the
4+
-- detector, pose/thresholding code, all common helpers, and every generated
5+
-- tag family (including the ArUco families). Keep the source globs aligned
6+
-- with that target rather than compiling examples or the Python wrapper.
7+
--
8+
-- The same source set builds on Linux, macOS, and Windows. Platform-specific
9+
-- defines and system libraries mirror the upstream CMake target.
10+
package = {
11+
spec = "1",
12+
namespace = "compat",
13+
name = "apriltag",
14+
description = "AprilTag visual fiducial detection library",
15+
licenses = {"BSD-2-Clause", "MIT"},
16+
repo = "https://github.com/AprilRobotics/apriltag",
17+
type = "package",
18+
19+
xpm = {
20+
linux = {
21+
["3.4.5"] = {
22+
url = "https://github.com/AprilRobotics/apriltag/archive/refs/tags/v3.4.5.tar.gz",
23+
sha256 = "3749f48220db78c29c375a373861f4e1f4138e5dbae3c298584e96cfcc556515",
24+
},
25+
},
26+
macosx = {
27+
["3.4.5"] = {
28+
url = "https://github.com/AprilRobotics/apriltag/archive/refs/tags/v3.4.5.tar.gz",
29+
sha256 = "3749f48220db78c29c375a373861f4e1f4138e5dbae3c298584e96cfcc556515",
30+
},
31+
},
32+
windows = {
33+
["3.4.5"] = {
34+
url = "https://github.com/AprilRobotics/apriltag/archive/refs/tags/v3.4.5.tar.gz",
35+
sha256 = "3749f48220db78c29c375a373861f4e1f4138e5dbae3c298584e96cfcc556515",
36+
},
37+
},
38+
},
39+
40+
mcpp = {
41+
language = "c++23",
42+
import_std = false,
43+
c_standard = "c99",
44+
include_dirs = { "*" },
45+
sources = {
46+
"*/apriltag.c",
47+
"*/apriltag_pose.c",
48+
"*/apriltag_quad_thresh.c",
49+
"*/common/*.c",
50+
"*/tag*.c",
51+
"*/aruco/tag*.c",
52+
},
53+
targets = { ["apriltag"] = { kind = "lib" } },
54+
linux = {
55+
cflags = { "-D_GNU_SOURCE" },
56+
ldflags = { "-lpthread", "-lm" },
57+
},
58+
macosx = {
59+
cflags = { "-D_DARWIN_C_SOURCE" },
60+
ldflags = { "-lpthread", "-lm" },
61+
},
62+
windows = {
63+
cflags = {
64+
"-D_USE_MATH_DEFINES",
65+
"-DWIN32_LEAN_AND_MEAN",
66+
"-D_CRT_SECURE_NO_WARNINGS",
67+
"-D_CRT_NONSTDC_NO_DEPRECATE",
68+
},
69+
},
70+
deps = { },
71+
},
72+
}

‎tests/examples/apriltag/mcpp.toml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "apriltag-tests"
3+
version = "0.1.0"
4+
5+
[dependencies.compat]
6+
apriltag = "3.4.5"
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#include <cassert>
2+
3+
#include <apriltag.h>
4+
#include <common/image_u8.h>
5+
#include <tagStandard41h12.h>
6+
7+
int main() {
8+
apriltag_detector_t* detector = apriltag_detector_create();
9+
assert(detector != nullptr);
10+
assert(detector->nthreads > 0);
11+
12+
apriltag_family_t* family = tagStandard41h12_create();
13+
assert(family != nullptr);
14+
assert(family->ncodes > 0);
15+
apriltag_detector_add_family(detector, family);
16+
17+
image_u8_t* image = image_u8_create(64, 64);
18+
assert(image != nullptr);
19+
zarray_t* detections = apriltag_detector_detect(detector, image);
20+
assert(detections != nullptr);
21+
assert(zarray_size(detections) == 0);
22+
23+
apriltag_detections_destroy(detections);
24+
image_u8_destroy(image);
25+
apriltag_detector_destroy(detector);
26+
tagStandard41h12_destroy(family);
27+
return 0;
28+
}

0 commit comments

Comments
 (0)