Skip to content

feat(imgproc): implement corner detection pipeline — cornerSubPix, goodFeaturesToTrack, Harris, Shi-Tomasi, preCornerDetect#39

Open
Copilot wants to merge 3 commits intodevfrom
copilot/create-plan-for-issue-24
Open

feat(imgproc): implement corner detection pipeline — cornerSubPix, goodFeaturesToTrack, Harris, Shi-Tomasi, preCornerDetect#39
Copilot wants to merge 3 commits intodevfrom
copilot/create-plan-for-issue-24

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 9, 2026

What was implemented

New module: src/imgproc/feature.rs

Six new corner detection functions (all OpenCV-compatible, single-channel Matrix<T>, returning Result<…>):

Function Description
corner_harris Harris corner response map — det(M) − k·tr(M)²
corner_min_eigen_val Shi-Tomasi response — minimum eigenvalue of the structure tensor
corner_eigen_vals_and_vecs Full 6-channel structure tensor decomposition (λ1, λ2, x1, y1, x2, y2)
good_features_to_track Filtered, NMS corner list with quality threshold + min-distance enforcement; supports both Harris and Shi-Tomasi scoring
corner_sub_pix Iterative sub-pixel refinement via the Forstner/Lucas gradient method
pre_corner_detect Ix²·Iyy + Iy²·Ixx − 2·Ix·Iy·Ixy pre-corner feature map

All functions support the parallel and simd feature flags and use BorderTypes for border extrapolation.

New example: examples/corner_detection.rs

Single file that groups all six corner detectors against a real image (defaults to butterfly.jpg, accepts any image via CLI):

cargo run --example corner_detection
cargo run --example corner_detection -- examples/data/graf1.png

Steps demonstrated:

  1. Harris response map (normalized, saved as PNG)
  2. Shi-Tomasi (min eigenvalue) response map
  3. good_features_to_track — Shi-Tomasi mode, top 200 corners
  4. good_features_to_track — Harris mode, top 200 corners
  5. corner_sub_pix — sub-pixel refinement with before/after Δ printed
  6. pre_corner_detect — feature map saved as PNG
  7. corner_eigen_vals_and_vecs — λ1 channel extracted and saved

Module wiring

  • src/imgproc.rspub use feature::*; added
  • src/lib.rsTermCriteria, TermType, Point2f, Size2i added to prelude

Tests

224 comprehensive unit tests added across src/imgproc/tests.rs:

  • correctness for all six functions
  • error cases (multi-channel input, invalid params)
  • round-trip and numerical checks for corner_sub_pix

Checklist

  • src/imgproc/feature.rs — all six corner detection functions
  • examples/corner_detection.rs — unified example for all detectors
  • src/imgproc.rs / src/lib.rs — public API wired up
  • src/imgproc/tests.rs — 224 tests pass
  • cargo fmt && cargo clippy — zero warnings
  • cargo run --example corner_detection — verified on butterfly.jpg
  • cargo test — all tests pass

Closes #24

…resToTrack, Harris, Shi-Tomasi, preCornerDetect)

Agent-Logs-Url: https://github.com/webarkit/purecv/sessions/3be57b21-2870-4ea6-9b9e-09a0d8c480d8

Co-authored-by: kalwalt <1275858+kalwalt@users.noreply.github.com>
@kalwalt kalwalt added enhancement New feature or request rust-code rust Pull requests that update rust code tests labels Apr 9, 2026
@kalwalt kalwalt linked an issue Apr 9, 2026 that may be closed by this pull request
@kalwalt kalwalt changed the base branch from main to dev April 9, 2026 19:25
… morph/pyramid tests)

Co-authored-by: kalwalt <1275858+kalwalt@users.noreply.github.com>
Copy link
Copy Markdown
Member

@kalwalt kalwalt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot if it is ok, we can merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request imgproc-module rust Pull requests that update rust code rust-code tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MILESTONE-2] Feature: cornerSubPix() method from OpenCV

2 participants