Skip to content

fix(motion_estimator): restore affine2d error() and check_subset() (#51) - #52

Merged
kalwalt merged 2 commits into
devfrom
fix/51-motion-model-check-subset
Jul 7, 2026
Merged

fix(motion_estimator): restore affine2d error() and check_subset() (#51)#52
kalwalt merged 2 commits into
devfrom
fix/51-motion-model-check-subset

Conversation

@kalwalt

@kalwalt kalwalt commented Jul 7, 2026

Copy link
Copy Markdown
Member

Closes #51. First fix guarded by the new parity suite (Phase 0, #39).

Bug

jsfeatNext's affine2d kernel was missing the error() and check_subset() methods that original jsfeat defines on it. So motion_estimator.ransac() / lmeds() with an affine2d kernel threw TypeError: kernel.check_subset is not a function (then kernel.error is not a function) — affine motion estimation was completely broken, while homography2d worked (it has its own overrides).

Surfaced by the characterization test added in #49, which had to pin the crash to stay green.

Fix

Port both methods onto affine2d from original jsfeat (src/jsfeat_motion_estimator.js):

  • error() — affine reprojection residual sqr(dx) + sqr(dy)
  • check_subset() — returns true

Test

The parity test is flipped from expect(...).toThrow(TypeError) to a full parity check: affine2d RANSAC now returns the same true, the same 3×3 model (to 4 decimals), and the same inlier mask as the oracle on identical seeded data, and rejects the synthetic outliers.

  • npm test57 passed
  • tsc --noEmit → clean

🤖 Generated with Claude Code

jsfeatNext's affine2d kernel was missing the error() and check_subset()
methods that original jsfeat defines on it, so motion_estimator.ransac /
lmeds with an affine2d kernel threw 'kernel.check_subset/error is not a
function'. Port both from jsfeat's affine2d (error = affine reprojection
residual; check_subset = true).

The parity test added in #49 is flipped from pinning the crash to a full
parity check: affine2d RANSAC now matches the oracle's 3x3 model and
inlier mask on identical seeded data, and rejects the synthetic outliers.

npm test: 57 passed; tsc --noEmit: clean.

Closes #51

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kalwalt kalwalt added this to the Parity & Modernization milestone Jul 7, 2026
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@kalwalt kalwalt self-assigned this Jul 7, 2026
@kalwalt kalwalt added bug Something isn't working enhancement New feature or request Typescript all about Typescript code design labels Jul 7, 2026
@kalwalt
kalwalt merged commit 148e6f2 into dev Jul 7, 2026
4 checks passed
@kalwalt
kalwalt deleted the fix/51-motion-model-check-subset branch July 7, 2026 21:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working code design enhancement New feature or request Typescript all about Typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant