Skip to content

Conversation

AS1100K
Copy link
Member

@AS1100K AS1100K commented Aug 29, 2025

image
$ cargo run -p fast_detector --release -- --image-path "path/to/image.png" --min-distance 10 --threshold 30

Benchmark

Before:
FastCornerDetect/fast_native_cpu/1920x1080
                        time:   [1.3061 ms 1.3108 ms 1.3156 ms]

After:
FastCornerDetect/fast_native_cpu/1920x1080
                        time:   [2.3718 ms 2.3799 ms 2.3888 ms]

TODOs

  • Add Docs
  • Add Tests

@AS1100K

This comment was marked as outdated.

@AS1100K
Copy link
Member Author

AS1100K commented Aug 29, 2025

Nvm, corner_peaks function is pretty much useless so we can avoid the concept of KdTree entirely

- Replace free functions with FastDetector struct and methods - Update
benchmarks, tests, and example to use FastDetector - Improve mask
handling and keypoint extraction logic
- Rename `corner_fast` to `compute_corner_response` - Rename
`get_keypoints` to `extract_keypoints` - Add and expand doc comments for
public methods and struct fields - Refactor internal logic for clarity
and parallelism - Update examples and benchmarks to use new method names
@AS1100K AS1100K marked this pull request as ready for review August 29, 2025 20:03
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a newer FAST (Features from Accelerated Segment Test) corner detector, replacing the previous function-based implementation with a stateful FastDetector struct. The new implementation includes corner response computation, non-maximum suppression, and configurable minimum distance between keypoints.

Key changes:

  • Replaced the simple fast_feature_detector function with a comprehensive FastDetector struct
  • Added corner response computation and keypoint extraction as separate steps
  • Introduced minimum distance filtering to reduce clustering of detected keypoints

Reviewed Changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
examples/fast_detector/src/main.rs Updated to use new FastDetector API with additional parameters and separate computation steps
examples/fast_detector/README.md Updated documentation to reflect new command-line interface and parameters
examples/fast_detector/Cargo.toml Removed unnecessary "gstreamer" feature dependency
crates/kornia-imgproc/src/features/fast.rs Complete rewrite implementing stateful FastDetector with corner response computation and keypoint extraction
crates/kornia-imgproc/benches/bench_features.rs Updated benchmark to use new FastDetector API and added detector clearing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if consecutive_count == n {
curr_response = 0;
circle_intensities.iter().for_each(|m| {
curr_response = curr_response.saturating_add(m.saturating_sub(curr_pixel));
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The corner response calculation is incorrect. When m < curr_pixel, m.saturating_sub(curr_pixel) returns 0, which doesn't contribute to the response. For darker pixels, the calculation should use curr_pixel.saturating_sub(*m) to get the actual intensity difference.

Suggested change
curr_response = curr_response.saturating_add(m.saturating_sub(curr_pixel));
curr_response = curr_response.saturating_add((i16::from(*m) - i16::from(curr_pixel)).abs() as u8);

Copilot uses AI. Check for mistakes.

Comment on lines +287 to +290
(yy as isize - y as isize)
.abs()
.max((xx as isize - x as isize).abs())
< min_distance as isize
Copy link
Preview

Copilot AI Aug 29, 2025

Choose a reason for hiding this comment

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

The distance calculation uses Chebyshev distance (max of absolute differences) but the condition should be <= min_distance instead of < min_distance to properly suppress points exactly at the minimum distance.

Suggested change
(yy as isize - y as isize)
.abs()
.max((xx as isize - x as isize).abs())
< min_distance as isize
<= min_distance as isize

Copilot uses AI. Check for mistakes.

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

Successfully merging this pull request may close these issues.

1 participant