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 _pose → transMat → trans, 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
- Populate
pose3d in the live path (write it in/after cameraPoseFromPoints).
- 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
Summary
WebARKit::getPoseMatrix()(the cv::Mat / 4×4 pose, bound to JS) returns a zero matrix at runtime. It is wired toWebARKitPatternTrackingInfo::pose3d, but the live tracking path never writespose3d.Discovered during the #50 dead-code audit while confirming the matrix getters as intentional public API.
Detail — the chain
getPoseMatrix()→manager::getPoseMatrix()→tracker::getPoseMatrix():pose3dis initialised to zeros in the ctor (WebARKitPattern.cpp):In the live
processFramepath the pose flows through_pose→transMat→trans, notpose3d:pose3dis written only bycomputePose()/invertPose(), both of which are dead (onlycameraPoseFromPointsis used;computePose's sole call site is commented). Sopose3dkeeps its zero value forever.getPoseMatrix2()(thefloat[3][4]/trans) is the one actually used by the examples (viaWebARKitController.getPoseMatrix()→getPoseMatrix2()), which is why this has gone unnoticed: nothing readsgetPoseMatrix()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
pose3din the live path (write it in/aftercameraPoseFromPoints).getPoseMatrix()derive its 4×4 from the livetrans/_posedata (single source of truth).Either way the dead
computePose/invertPose/computeGLviewMatrix()(no-arg) become removable (tracked in #50).Related
docs/audit-dead-code-issue50.mdin webarkit-testing.getPoseMatrix/getPoseMatrix2naming (separate discussion).