Skip to content

refactor(motion_estimator): de-duplicate motion_estimator and extract kernels (#47)#69

Merged
kalwalt merged 1 commit into
feat/refactor-jsfeat-nextfrom
refactor/47-dedup-motion_estimator
Jul 8, 2026
Merged

refactor(motion_estimator): de-duplicate motion_estimator and extract kernels (#47)#69
kalwalt merged 1 commit into
feat/refactor-jsfeat-nextfrom
refactor/47-dedup-motion_estimator

Conversation

@kalwalt

@kalwalt kalwalt commented Jul 8, 2026

Copy link
Copy Markdown
Member

Eighth slice of #47 — the biggest structural win of the series.

What changed

  • New src/motion_model/motion_model.ts — the motion_model base plus the affine2d and homography2d kernels, verbatim from the monolith (they were module-local classes there; in original jsfeat they live under the jsfeat.motion_model namespace). Kernels instantiate linalg via 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); lmeds instantiates math directly.
  • src/core/core.ts — the temporary any-typed affine2d/homography2d static slots (a documented TODO since refactor(math): extract core base class and de-duplicate math module (#47) #62) now have precise typeof types. No any slots remain in core.
  • src/jsfeatNext.ts — down to ~380 lines (from ~3,900): pure aggregator except for optical_flow_lk, the last inline module.

Verification

  • tsc --noEmit → clean (it caught two missing imports mid-extraction; fixed before commit)
  • npm test57/57 — three parity tests pin ransac/lmeds producing 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)
  • UMD bundle smoke-checked: instanceof for the estimator and both kernels; affine RANSAC recovers the synthetic ground-truth model
  • Public API unchanged: jsfeatNext.motion_estimator, .affine2d, .homography2d, .ransac_params_t all attach exactly as before (motion_model remains unexposed, as it always was)
  • dist//types/ untouched (rebuilt when the integration branch merges to dev)

Advances #47. One module left: optical_flow_lk.

🤖 Generated with Claude Code

… 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>
@kalwalt kalwalt added this to the Parity & Modernization milestone Jul 8, 2026
@kalwalt kalwalt self-assigned this Jul 8, 2026
@kalwalt kalwalt added enhancement New feature or request Typescript all about Typescript code design javascript tests labels Jul 8, 2026
@kalwalt kalwalt merged commit 2f29664 into feat/refactor-jsfeat-next Jul 8, 2026
4 checks passed
@kalwalt kalwalt deleted the refactor/47-dedup-motion_estimator branch July 10, 2026 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code design enhancement New feature or request javascript tests Typescript all about Typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant