Summary
Once a marker is detected, isValid() stays true (and the getMarker event keeps firing) indefinitely after the marker has left the camera frame. Tracking is never declared lost: the reported pose freezes at the last good value and never clears.
Surfaced by the new live-webcam Teblid example (webarkit/webarkit-testing#36): the on-screen "Marker tracked" status never returns to "searching" even minutes after the marker is gone.
Root cause (WebARKitTracker.cpp detect→track state machine)
_valid and _isTracking are only updated inside runOpticalFlow() (this->_valid = homoInfo.validHomography;, and cleared on failure).
runOpticalFlow() is gated behind if (_isDetected) { … } — it runs only when the marker is also freshly matched this frame.
- When the marker leaves the frame,
MatchFeatures fails → _isDetected = false → the if (_isDetected) block is skipped → runOpticalFlow never runs, so _valid / _isTracking keep their last true value.
if (_isDetected || _isTracking) is then still true (stale _isTracking), so a pose is recomputed from the stale tracked points and getMarker fires → found, every frame, forever.
So the only code path that could detect loss (optical flow failing / homography going invalid) is unreachable once detection fails. The tracker is stuck "valid" with a frozen pose.
Suggested fixes (any / combination)
- Run optical flow on
_isDetected || _isTracking (not just _isDetected): when detection drops but we were tracking, optical flow runs, fails on the now-absent marker, and clears _isTracking / _valid.
- Gate
_valid on a confidence metric: RunTemplateMatching's TM_SQDIFF_NORMED correlation (already computed but not used to drop tracking), the homography inlier count/ratio, and/or homography sanity (non-degenerate scale/rotation) — as ArtoolkitX OCVT does.
- Add an explicit "tracking lost" transition that resets
_isDetected / _isTracking / _valid and clears output, so consumers receive a clean not found.
Impact
Any continuous (video/webcam) consumer cannot tell when tracking is lost; AR content stays frozen on screen.
Repro
Run the webcam Teblid example (webarkit/webarkit-testing#36), acquire the marker, then remove it from view — "Marker tracked" stays indefinitely (observed >1 min).
Summary
Once a marker is detected,
isValid()staystrue(and thegetMarkerevent keeps firing) indefinitely after the marker has left the camera frame. Tracking is never declared lost: the reported pose freezes at the last good value and never clears.Surfaced by the new live-webcam Teblid example (webarkit/webarkit-testing#36): the on-screen "Marker tracked" status never returns to "searching" even minutes after the marker is gone.
Root cause (WebARKitTracker.cpp detect→track state machine)
_validand_isTrackingare only updated insiderunOpticalFlow()(this->_valid = homoInfo.validHomography;, and cleared on failure).runOpticalFlow()is gated behindif (_isDetected) { … }— it runs only when the marker is also freshly matched this frame.MatchFeaturesfails →_isDetected = false→ theif (_isDetected)block is skipped →runOpticalFlownever runs, so_valid/_isTrackingkeep their lasttruevalue.if (_isDetected || _isTracking)is then still true (stale_isTracking), so a pose is recomputed from the stale tracked points andgetMarkerfires →found, every frame, forever.So the only code path that could detect loss (optical flow failing / homography going invalid) is unreachable once detection fails. The tracker is stuck "valid" with a frozen pose.
Suggested fixes (any / combination)
_isDetected || _isTracking(not just_isDetected): when detection drops but we were tracking, optical flow runs, fails on the now-absent marker, and clears_isTracking/_valid._validon a confidence metric:RunTemplateMatching'sTM_SQDIFF_NORMEDcorrelation (already computed but not used to drop tracking), the homography inlier count/ratio, and/or homography sanity (non-degenerate scale/rotation) — as ArtoolkitX OCVT does._isDetected/_isTracking/_validand clearsoutput, so consumers receive a cleannot found.Impact
Any continuous (video/webcam) consumer cannot tell when tracking is lost; AR content stays frozen on screen.
Repro
Run the webcam Teblid example (webarkit/webarkit-testing#36), acquire the marker, then remove it from view — "Marker tracked" stays indefinitely (observed >1 min).