Skip to content

Derive the hand-written overrides from the generator#96

Merged
ViralBShah merged 1 commit into
masterfrom
vs/generate-overrides
Jun 6, 2026
Merged

Derive the hand-written overrides from the generator#96
ViralBShah merged 1 commit into
masterfrom
vs/generate-overrides

Conversation

@ViralBShah

Copy link
Copy Markdown
Member

Motivation

The three files under src/overrides/ existed only to paper over gaps in the wrapper generator. Since OpenCV.jl already owns its fork of the Julia-specific generator (the upstream opencv_contrib copy is effectively unmaintained), the lower-risk home for this logic is the generator itself. Each gap is now closed there, the overrides are deleted, and their behaviour is produced by julia gen/regenerate.jl.

Net: −156 / +54 lines of hand-maintained code; src/overrides/ is gone.

Changes

Covariance — deletes covariance.jl (62 lines).
gen3_julia_cxx.py emits the covariant AbstractVector{<:InputArray} for vector-of-array parameters instead of the invariant Array{InputArray, 1}, so a natural Vector{Array{Float32,3}} dispatches without an OpenCV.InputArray[…] cast. Applied to the type annotation only; default-value lookups still key off the unrelaxed type. (issues #18, #60)

Defaults — deletes defaults.jl (22 lines).
Six defval.txt entries let the generator emit the keyword-default overloads for ORB_create and SimpleBlobDetector_create. The diff is surgical — only those two overloads appear.

GUI / Cascade callbacks — moved out of convenience.jl.
Relocated to gen/binding_templates_jl/manual_cxx.jl, emitted verbatim into cv_cxx_wrap.jl as a "Manual Wrapping" section — the Julia counterpart of the existing C++ block in cv_core.cpp. No C++/JLL change (those symbols are already compiled); behaviour preserved exactly.

VideoWriter_fourcc string form — moved to the hand-written src/videoio.jl (not an override).

⚠️ Behaviour change to note

ORB_create()'s default scoreType is now the OpenCV-faithful ORB_HARRIS_SCORE. The deleted override hard-coded ORB_FAST_SCORE, which was a bug — but this does change descriptor behaviour for callers who relied on the implicit default.

Caveat

The GUI callbacks (createButton / setMouseCallback / createTrackbar) reference jl_cpp_cv2, which is defined nowhere and untested — they would UndefVarError if called. They are relocated with exact parity; fixing/removing them is left to separate work, since the highgui C++ side can't be rebuilt/tested here.

Verification

  • julia gen/regenerate.jl is byte-for-byte idempotent → the CI git diff --exit-code guard stays green.
  • Full test suite: 310/310 pass.
  • The #60 calibrate* hasmethod tests are updated to the generated keyword-form arity (they previously asserted the override's args... reduced-arity shape), preserving their concrete-element-dispatch intent. Stale src/overrides/ / src/patches*.jl references in README.md and test_imgproc.jl are corrected.

🤖 Generated with Claude Code

The three files under src/overrides/ existed to paper over gaps in the
wrapper generator. Each gap is now closed in the generator itself, so the
overrides are deleted and their behaviour is produced by `regenerate.jl`.

- Covariance (deletes covariance.jl): gen3_julia_cxx.py now emits the
  covariant `AbstractVector{<:InputArray}` for vector-of-array parameters
  instead of the invariant `Array{InputArray, 1}`, so a natural
  `Vector{Array{Float32,3}}` dispatches without an `InputArray[…]` cast.
  The relaxation is applied to the type annotation only; default-value
  lookups still key off the unrelaxed type (issues #18, #60).

- Defaults (deletes defaults.jl): six defval.txt entries let the generator
  emit the keyword-default overloads for ORB_create and
  SimpleBlobDetector_create. Note: ORB_create's `scoreType` now defaults to
  the OpenCV-faithful ORB_HARRIS_SCORE; the override had hard-coded
  ORB_FAST_SCORE, which was a bug.

- GUI/Cascade callbacks (moved out of convenience.jl): relocated to
  gen/binding_templates_jl/manual_cxx.jl, emitted verbatim into
  cv_cxx_wrap.jl as a "Manual Wrapping" section — the Julia counterpart of
  the existing C++ block in cv_core.cpp. No C++/JLL change; the compiled
  symbols already exist. Behaviour is preserved exactly.

- VideoWriter_fourcc string form: moved to the hand-written src/videoio.jl
  (not an override).

src/overrides/ is removed. The #60 calibrate hasmethod tests are updated to
the generated keyword-form arity (preserving their concrete-element intent),
and stale comments in README.md / test_imgproc.jl are corrected.
Regeneration stays deterministic; the full suite passes (310/310).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.45%. Comparing base (30e41b7) to head (43565d3).

Additional details and impacted files
@@            Coverage Diff             @@
##           master      #96      +/-   ##
==========================================
+ Coverage   84.67%   91.45%   +6.78%     
==========================================
  Files          13       11       -2     
  Lines         274      234      -40     
==========================================
- Hits          232      214      -18     
+ Misses         42       20      -22     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ViralBShah ViralBShah merged commit a481269 into master Jun 6, 2026
11 checks passed
@ViralBShah ViralBShah deleted the vs/generate-overrides branch June 6, 2026 03:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant