|
1 | | - |
2 | 1 |  |
3 | 2 |  |
4 | 3 | [](https://github.com/webarkit/WebARKitLib/actions/workflows/test.yml) |
| 4 | + |
5 | 5 | # WebARKitLib |
6 | 6 |
|
7 | | -The C/C++ source code of WebARKit, from Artoolkit5 and extended. |
| 7 | +The C/C++ source of **WebARKit** — a browser-side Augmented Reality tracker. The |
| 8 | +active code (`WebARKit/`) is an emscripten-friendly port of the **OCVT** planar |
| 9 | +image-tracking design from [ArtoolkitX](https://github.com/artoolkitx/artoolkitx), |
| 10 | +built on OpenCV. It is normally compiled to WebAssembly and consumed from the |
| 11 | +[webarkit-testing](https://github.com/webarkit/webarkit-testing) superproject. |
| 12 | + |
| 13 | +> **Two lineages live here, keep them straight:** |
| 14 | +> - **`WebARKit/`** — the WebAR OCVT planar tracker (the design reference is *ArtoolkitX*). This is the code under active development. |
| 15 | +> - **`lib/SRC/**`, `include/AR/**`** — vendored **old ARToolKit5** utility sources/headers, kept only because [jsartoolkitNFT](https://github.com/webarkit/jsartoolkitNFT) needs them (and [ARnft](https://github.com/webarkit/ARnft) in turn consumes jsartoolkitNFT as an npm module). Treated as untouched upstream. (Updated to Eigen 3.4.0 / emsdk 3.1.26.) |
| 16 | +
|
| 17 | +## Code layout (`WebARKit/`) |
| 18 | + |
| 19 | +| Component | Role | |
| 20 | +|---|---| |
| 21 | +| `WebARKitManager` | top-level façade — owns the tracker, drives init/process, exposes the output (homography, pose, GL-view, projection) | |
| 22 | +| `WebARKitTrackers/WebARKitOpticalTracking/WebARKitTracker` | the OCVT tracker core: feature detect/match → homography → optical-flow + template-match tracking | |
| 23 | +| `…/TrackingPointSelector` + `…/TrackedPoint` | bin-based selection of template tracking points (ArtoolkitX-derived) | |
| 24 | +| `…/WebARKitHomographyInfo` + `WebARKitUtils.h` | RANSAC homography estimation/validation (`getHomographyInliers`) | |
| 25 | +| `…/WebARKitConfig` | tuning constants (feature counts, match ratios, pyramid/template sizes, version) | |
| 26 | +| `…/TrackerVisualization` | optional debug-overlay scaffolding (inert until wired) | |
| 27 | +| `WebARKitCamera` | camera intrinsics from a diagonal-FOV estimate | |
| 28 | +| `WebARKitGL` | CV→GL matrix conversion (`arglCameraViewRHf`) + GL projection | |
| 29 | +| `WebARKitPattern` | the reference marker (`WebARKitPattern`) and per-frame pose state (`WebARKitPatternTrackingInfo`) | |
| 30 | +| `WebARKitLog` | logging | |
| 31 | + |
| 32 | +## Pose pipeline (one glance) |
| 33 | + |
| 34 | +``` |
| 35 | +solvePnP (cameraPoseFromPoints) // OpenCV-convention camera pose |
| 36 | + -> getTrackablePose / updateTrackable // CV->GL handedness fix, D*R*D (see #42) |
| 37 | + -> arglCameraViewRHf // right-handed GL modelview |
| 38 | + -> matrixGL_RH // what the examples attach content to |
| 39 | +``` |
| 40 | + |
| 41 | +Pose getters: **`getPoseMatrixCV()`** (raw 4×4 OpenCV pose) and **`getPoseMatrixGL()`** |
| 42 | +(the GL/right-handed pose); projection via `getCameraProjectionMatrix()`. The full |
| 43 | +derivation is in |
| 44 | +[`docs/design-projection-and-pose-artoolkitx-alignment.md`](https://github.com/webarkit/webarkit-testing/blob/dev/docs/design-projection-and-pose-artoolkitx-alignment.md) |
| 45 | +(webarkit-testing). |
| 46 | + |
| 47 | +## Building |
| 48 | + |
| 49 | +This repo isn't built as a single unit — each consumer compiles the **subset it |
| 50 | +needs**: |
| 51 | + |
| 52 | +- **`WebARKit/` (the OCVT tracker)** is built by the |
| 53 | + [webarkit-testing](https://github.com/webarkit/webarkit-testing) superproject, which |
| 54 | + compiles it to WebAssembly with emscripten (emsdk **3.1.26**) inside Docker and wires |
| 55 | + it to JS through `emscripten/WebARKitJS.{cpp,h}` + `bindings.cpp` (which live in |
| 56 | + webarkit-testing). webarkit-testing currently drives that compile with the Node script |
| 57 | + `tools/makem.js` (`npm run build-docker` → `build-es6`); migrating to the CMake config |
| 58 | + (`WebARKit/CMakeLists.txt`) is planned. |
| 59 | +- **The vendored `lib/SRC/**` + `include/AR/**` (old ARToolKit5)** is built by |
| 60 | + [jsartoolkitNFT](https://github.com/webarkit/jsartoolkitNFT) as part of its build — |
| 61 | + not by webarkit-testing. ([ARnft](https://github.com/webarkit/ARnft) consumes |
| 62 | + jsartoolkitNFT as an npm module and doesn't build the emscripten code itself.) |
| 63 | + |
| 64 | +A standalone CMake config also exists for the unit tests (see below). |
| 65 | + |
| 66 | +## Tests |
| 67 | + |
| 68 | +C++ unit tests (GoogleTest) live in [`tests/`](tests/) (`webarkit_test.cc`, |
| 69 | +`CMakeLists.txt`, `pinball.jpg`) and run in CI via |
| 70 | +[`.github/workflows/test.yml`](https://github.com/webarkit/WebARKitLib/actions/workflows/test.yml). |
| 71 | +Build them standalone with CMake: |
| 72 | + |
| 73 | +```bash |
| 74 | +cmake -S tests -B tests/build && cmake --build tests/build && ctest --test-dir tests/build |
| 75 | +``` |
| 76 | + |
| 77 | +## Contributing |
8 | 78 |
|
9 | | -Updated to [Eigen](https://eigen.tuxfamily.org) 3.4.0 and Emscripten emsdk 3.1.26. |
| 79 | +- Branch from `dev`; PR back to `dev`; sign your commits and reference the issue. |
| 80 | +- Library changes are usually paired with a build/bump in webarkit-testing — see that |
| 81 | + repo's "cross-repo PR pair" flow. |
| 82 | +- Don't modify the vendored `lib/SRC/**` / `include/AR/**` (old ARToolKit5) as part of |
| 83 | + WebAR work. |
10 | 84 |
|
11 | | -## Features |
| 85 | +## License |
12 | 86 |
|
13 | | -The library containes the following features: |
14 | | -**Artoolkit5** C/C++ code used by [jsartoolkitNFT](https://github.com/webarkit/jsartoolkitNFT) and [ARnft](https://github.com/webarkit/ARnft) (see lib and include folders). Note that is not the full Artoolkit5 library, but only the code needed by jsartoolkitNFT and ARnft. The code is updated to Eigen 3.4.0 and can be compiled with Emscripten emsdk 3.1.26. |
15 | | -**WebARKit** C++ code, which is our experimental code for WebAR. It is completetly independent from Artoolkit5 and can be used as a standalone library. It can be compiled with Emscripten emsdk 3.1.26. |
| 87 | +LGPL-3.0 (see `LICENSE.txt`). |
0 commit comments