Skip to content

getPoseMatrix() returns a zero matrix — pose3d is never populated in the live path #55

Description

@kalwalt

Summary

WebARKit::getPoseMatrix() (the cv::Mat / 4×4 pose, bound to JS) returns a zero matrix at runtime. It is wired to WebARKitPatternTrackingInfo::pose3d, but the live tracking path never writes pose3d.

Discovered during the #50 dead-code audit while confirming the matrix getters as intentional public API.

Detail — the chain

getPoseMatrix()manager::getPoseMatrix()tracker::getPoseMatrix():

cv::Mat getPoseMatrix() { return _patternTrackingInfo.pose3d; }

pose3d is initialised to zeros in the ctor (WebARKitPattern.cpp):

pose3d = cv::Mat::zeros(4, 4, CV_64FC1);

In the live processFrame path the pose flows through _posetransMattrans, not pose3d:

_patternTrackingInfo.cameraPoseFromPoints(_pose, objPoints, imgPoints, ...); // writes _pose (local)
_patternTrackingInfo.getTrackablePose(_pose);   // memcpy _pose -> transMat
_patternTrackingInfo.updateTrackable();          // transMat -> trans (handedness + scale, #42)
_patternTrackingInfo.computeGLviewMatrix(_pose); // _pose -> glViewMatrix

pose3d is written only by computePose() / invertPose(), both of which are dead (only cameraPoseFromPoints is used; computePose's sole call site is commented). So pose3d keeps its zero value forever.

getPoseMatrix2() (the float[3][4] / trans) is the one actually used by the examples (via WebARKitController.getPoseMatrix()getPoseMatrix2()), which is why this has gone unnoticed: nothing reads getPoseMatrix() today.

Impact

getPoseMatrix() is part of the public JS API. A downstream user who calls it directly (doing their own pose math rather than using our examples) gets a 4×4 of zeros.

Fix options

  1. Populate pose3d in the live path (write it in/after cameraPoseFromPoints).
  2. Or have getPoseMatrix() derive its 4×4 from the live trans/_pose data (single source of truth).

Either way the dead computePose / invertPose / computeGLviewMatrix() (no-arg) become removable (tracked in #50).

Related

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

C/C++ codeconcerning the C/C++ code design and improvementsEmscriptendocumentationImprovements or additions to documentationenhancementNew feature or request

Type

Projects

Relationships

None yet

Development

No branches or pull requests

Issue actions