refactor(motion_estimator): de-duplicate motion_estimator and extract kernels (#47)#69
Merged
kalwalt merged 1 commit intoJul 8, 2026
Conversation
… kernels (#47) Eighth de-duplication step of #47 — the biggest structural win. - NEW src/motion_model/motion_model.ts: motion_model + affine2d + homography2d kernel classes, moved verbatim from the monolith (they were module-local classes there). Kernels instantiate linalg via direct module import instead of the jsfeatNext.linalg static slot. - src/motion_estimator/motion_estimator.ts: replace the type-only stub with the REAL implementation (get_subset, find_inliers, ransac, lmeds); lmeds instantiates math via direct module import. - src/core/core.ts: the temporary any-typed affine2d/homography2d static slots (a known TODO since #62) now have precise typeof types via type-only imports. - src/jsfeatNext.ts: down to ~380 lines — pure aggregator except for optical_flow_lk, the last inline module. Verified behavior-preserving: tsc --noEmit clean; npm test 57/57 (3 parity tests pin ransac/lmeds with identical models AND inlier masks vs original jsfeat on seeded data); UMD bundle smoke-checked (instanceof for estimator and both kernels, affine RANSAC recovers the synthetic model). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Jul 8, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Eighth slice of #47 — the biggest structural win of the series.
What changed
src/motion_model/motion_model.ts— themotion_modelbase plus theaffine2dandhomography2dkernels, verbatim from the monolith (they were module-local classes there; in original jsfeat they live under thejsfeat.motion_modelnamespace). Kernels instantiatelinalgvia direct module import (established pattern).src/motion_estimator/motion_estimator.ts— type-only stub replaced by the real implementation (get_subset,find_inliers,ransac,lmeds);lmedsinstantiatesmathdirectly.src/core/core.ts— the temporaryany-typedaffine2d/homography2dstatic slots (a documented TODO since refactor(math): extract core base class and de-duplicate math module (#47) #62) now have precisetypeoftypes. Noanyslots remain in core.src/jsfeatNext.ts— down to ~380 lines (from ~3,900): pure aggregator except foroptical_flow_lk, the last inline module.Verification
tsc --noEmit→ clean (it caught two missing imports mid-extraction; fixed before commit)npm test→ 57/57 — three parity tests pinransac/lmedsproducing identical models and inlier masks vs original jsfeat on seeded data (incl. the affine2d kernel fixed in fix(motion_estimator): restore affine2d error() and check_subset() (#51) #52)jsfeatNext.motion_estimator,.affine2d,.homography2d,.ransac_params_tall attach exactly as before (motion_modelremains unexposed, as it always was)dist//types/untouched (rebuilt when the integration branch merges todev)Advances #47. One module left:
optical_flow_lk.🤖 Generated with Claude Code