Skip to content

fix(#55): populate pose3d (getPoseMatrix returned zeros) + rename pose getters - #56

Merged
kalwalt merged 1 commit into
webarkit:devfrom
kalwalt:fix/getposematrix-rename-55
Jun 19, 2026
Merged

fix(#55): populate pose3d (getPoseMatrix returned zeros) + rename pose getters#56
kalwalt merged 1 commit into
webarkit:devfrom
kalwalt:fix/getposematrix-rename-55

Conversation

@kalwalt

@kalwalt kalwalt commented Jun 19, 2026

Copy link
Copy Markdown
Member

Fixes #55.

The bug

getPoseMatrix() (the cv::Mat / 4×4 pose, bound to JS) returned an all-zero matrix. It reads _patternTrackingInfo.pose3d, but the live tracking path never wrote pose3d — the pose flows _posetransMattrans (what getPoseMatrix2 returns), while pose3d was touched only by the dead computePose/invertPose. Unnoticed because the examples read getPoseMatrix2, not getPoseMatrix.

The fix

cameraPoseFromPoints now also builds pose3d (the raw 4×4 OpenCV-convention pose) from the same rMat/tvec it already computes, so the CV getter reflects the current frame. No handedness/scale correction is applied to pose3d (that remains getPoseMatrixGL's trans).

The rename (rides along, agreed in #55)

The 2 suffix hid that the two getters differ in both convention and shape:

before returns after
getPoseMatrix raw OpenCV 4×4 pose getPoseMatrixCV
getPoseMatrix2 right-handed/GL pose (trans) getPoseMatrixGL

Hard rename across WebARKitManager + WebARKitTracker (decls, inner impl, outer wrapper). The matching emscripten bindings + WebARKitController wrapper are in the companion webarkit-testing PR.

Testing

Rebuilt (Docker emscripten) and tested both examples:

  • static (1920×1440, pyrLevel 1) and webcam (640×480, pyrLevel 0) both track — 1000 matches, lost→found re-acquisition intact.
  • getPoseMatrixCV() now returns a valid [R|t;0001] (e.g. rotation block + translation + [0,0,0,1]); was all zeros before.

Follow-up

The now-redundant computePose / invertPose / computeGLviewMatrix() (no-arg) become removable — tracked in the #50 cleanup.

🤖 Generated with Claude Code

getPoseMatrix() returned a zero matrix: it reads _patternTrackingInfo.pose3d,
which the live tracking path never wrote (the pose flows _pose -> transMat ->
trans; pose3d was touched only by the dead computePose). cameraPoseFromPoints
now also builds pose3d (the raw 4x4 OpenCV-convention pose) from the same
rMat/tvec, so the CV getter reflects the current frame.

Rename the two pose getters so the distinction is explicit (they differ in
both convention and shape, which the "2" suffix hid):
  getPoseMatrix  -> getPoseMatrixCV  (raw OpenCV 4x4 pose)
  getPoseMatrix2 -> getPoseMatrixGL  (right-handed / GL-corrected pose, trans)

Hard rename across WebARKitManager + WebARKitTracker (decls, inner impl, outer
wrapper). The matching emscripten bindings / controller live in webarkit-testing.

Verified: static (1920x1440) and webcam (640x480) examples both track (1000
matches); getPoseMatrixCV() now returns a valid [R|t;0001] (was all zeros).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kalwalt kalwalt self-assigned this Jun 19, 2026
@kalwalt kalwalt added enhancement New feature or request C/C++ code concerning the C/C++ code design and improvements Emscripten labels Jun 19, 2026
@kalwalt kalwalt moved this from To do to Review in progress in New markerless image tracking Jun 19, 2026
@kalwalt kalwalt added this to the Markerless tracking milestone Jun 19, 2026
@kalwalt
kalwalt merged commit f3f33cc into webarkit:dev Jun 19, 2026
@github-project-automation github-project-automation Bot moved this from Review in progress to Done in New markerless image tracking Jun 19, 2026
kalwalt added a commit to webarkit/webarkit-testing that referenced this pull request Jun 20, 2026
Companion to webarkit/WebARKitLib#56. Bump the submodule to the rename+fix
commit and rebuild build/ + dist/.

- emscripten glue (bindings.cpp, WebARKitJS.{h,cpp}): rename the bound JS API
  getPoseMatrix -> getPoseMatrixCV, getPoseMatrix2 -> getPoseMatrixGL.
- src/WebARKitController.js: getPoseMatrix() -> getPoseMatrixGL() (the GL pose
  the render path uses), add getPoseMatrixCV(); process_raw calls
  getPoseMatrixGL().
- examples/worker_threejs.js: drop a stray debug log.

Verified: static + webcam examples track; getPoseMatrixCV() returns a real
4x4 pose (was zeros).

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
Companion to webarkit/WebARKitLib#56. Bump the submodule to the rename+fix
commit and rebuild build/ + dist/.

- emscripten glue (bindings.cpp, WebARKitJS.{h,cpp}): rename the bound JS API
  getPoseMatrix -> getPoseMatrixCV, getPoseMatrix2 -> getPoseMatrixGL.
- src/WebARKitController.js: getPoseMatrix() -> getPoseMatrixGL() (the GL pose
  the render path uses), add getPoseMatrixCV(); process_raw calls
  getPoseMatrixGL().
- examples/worker_threejs.js: drop a stray debug log.

Verified: static + webcam examples track; getPoseMatrixCV() returns a real
4x4 pose (was zeros).

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