Skip to content

Optional centered marker origin (setOriginCentered) — webarkit-testing#38#49

Merged
kalwalt merged 1 commit into
webarkit:devfrom
kalwalt:fix/center-origin-38
Jun 16, 2026
Merged

Optional centered marker origin (setOriginCentered) — webarkit-testing#38#49
kalwalt merged 1 commit into
webarkit:devfrom
kalwalt:fix/center-origin-38

Conversation

@kalwalt

@kalwalt kalwalt commented Jun 16, 2026

Copy link
Copy Markdown
Member

Summary

Adds an opt-in option so the tracked pose origin is the marker centre instead of the reference image's top-left corner. With it on, AR content placed at (0,0,0) sits in the middle of the marker.

Implements the library half of webarkit/webarkit-testing#38.

Why opt-in / default OFF

Verified the full ArtoolkitX OCVT chain — it never centres (TrackingPointSelector uses raw top-left pixels; ARTrackable2d only negates Y,Z columns + scales translation; even the example drawCube only lifts +Z). So WebARKit's current corner origin already matches ArtoolkitX. Centring is a WebARKit convenience → default OFF preserves parity and existing behaviour.

How

When enabled, the 3D object points are offset by (_pattern.size.width/2, _pattern.size.height/2) just before solvePnP:

if (_centerOrigin) {
    const float cx = _pattern.size.width * 0.5f, cy = _pattern.size.height * 0.5f;
    for (auto& p : objPoints) { p.x -= cx; p.y -= cy; }
}

Offsetting the object points moves only the solved translation; the rotation is unchanged (orientation unaffected). Applied to the solvePnP 3D points only — the 2D imgPoints and the matching/template/homography paths stay in raw image space.

API

setOriginCentered(bool) threaded through WebARKitTracker (pimpl) and WebARKitManager (default false). The emscripten binding + JS wiring live in the companion webarkit-testing PR.

Testing

Verified against the static + webcam Teblid examples: true → cube/axes centred on the marker, correct orientation; false/default → back to the corner (no behaviour change).

Refs webarkit/webarkit-testing#38

🤖 Generated with Claude Code

Add an opt-in option so the tracked pose origin is the marker centre instead of the reference image's top-left corner -- AR content at (0,0,0) then sits in the middle of the marker. Default OFF (matches ArtoolkitX, which never centres at any layer, and preserves existing behaviour).

When enabled, the 3D object points are offset by (_pattern.size/2) just before solvePnP: this moves only the solved translation, leaves the rotation unchanged, and the 2D matching/template/homography paths untouched. Exposed as setOriginCentered(bool) via the tracker and manager.

Refs webarkit/webarkit-testing#38

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kalwalt

kalwalt commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

Companion JS/binding + examples + build PR: webarkit/webarkit-testing#40

@kalwalt kalwalt self-assigned this Jun 16, 2026
@kalwalt kalwalt added enhancement New feature or request C/C++ code concerning the C/C++ code design and improvements Emscripten labels Jun 16, 2026
@kalwalt kalwalt added this to the Markerless tracking milestone Jun 16, 2026
@kalwalt kalwalt moved this from To do to Review in progress in New markerless image tracking Jun 16, 2026
@kalwalt kalwalt moved this from Review in progress to Reviewer approved in New markerless image tracking Jun 16, 2026
@kalwalt kalwalt merged commit 15dc93f into webarkit:dev Jun 16, 2026
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in New markerless image tracking Jun 16, 2026
kalwalt added a commit to webarkit/webarkit-testing that referenced this pull request Jun 16, 2026
webarkit/WebARKitLib#49 merged into dev (rebased to 15dc93f). Re-point the submodule from the fork-branch commit to the canonical dev tip; source identical, build/ and dist/ unchanged.

Refs #38, webarkit/WebARKitLib#49

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kalwalt added a commit to webarkit/webarkit-testing that referenced this pull request Jun 16, 2026
Expose the library's new setOriginCentered option to JS and use it in the examples so AR content anchors at the marker CENTRE instead of the reference top-left corner. Opt-in; default off (ArtoolkitX parity).

- emscripten/WebARKitJS.cpp/.h + bindings.cpp: bind setOriginCentered - src/WebARKitController.js: setOriginCentered(centered) - examples/worker_threejs.js + worker_teblid_webcam_threejs.js: call setOriginCentered(true) after init - rebuild build/ + dist/, bump WebARKitLib submodule (fe588e5) - docs/design-center-origin-option.md: design + decision log + ArtoolkitX investigation

Verified on the static + webcam examples: true -> content centred; false/default -> corner (unchanged). Depends on webarkit/WebARKitLib#49.

Closes #38

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kalwalt added a commit to webarkit/webarkit-testing that referenced this pull request Jun 16, 2026
webarkit/WebARKitLib#49 merged into dev (rebased to 15dc93f). Re-point the submodule from the fork-branch commit to the canonical dev tip; source identical, build/ and dist/ unchanged.

Refs #38, webarkit/WebARKitLib#49

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kalwalt kalwalt deleted the fix/center-origin-38 branch June 16, 2026 16:27
kalwalt added a commit to webarkit/webarkit-testing that referenced this pull request Jun 21, 2026
Expose the library's new setOriginCentered option to JS and use it in the examples so AR content anchors at the marker CENTRE instead of the reference top-left corner. Opt-in; default off (ArtoolkitX parity).

- emscripten/WebARKitJS.cpp/.h + bindings.cpp: bind setOriginCentered - src/WebARKitController.js: setOriginCentered(centered) - examples/worker_threejs.js + worker_teblid_webcam_threejs.js: call setOriginCentered(true) after init - rebuild build/ + dist/, bump WebARKitLib submodule (fe588e5) - docs/design-center-origin-option.md: design + decision log + ArtoolkitX investigation

Verified on the static + webcam examples: true -> content centred; false/default -> corner (unchanged). Depends on webarkit/WebARKitLib#49.

Closes #38

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
kalwalt added a commit to webarkit/webarkit-testing that referenced this pull request Jun 21, 2026
webarkit/WebARKitLib#49 merged into dev (rebased to 15dc93f). Re-point the submodule from the fork-branch commit to the canonical dev tip; source identical, build/ and dist/ unchanged.

Refs #38, webarkit/WebARKitLib#49

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C/C++ code concerning the C/C++ code design and improvements Emscripten enhancement New feature or request

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant