Skip to content

feat: add edge-based fish detection to green channel - #14

Merged
Chouffe merged 5 commits into
mainfrom
arthur/green-spike
Oct 22, 2025
Merged

Chouffe merged 5 commits into
mainfrom
arthur/green-spike

Conversation

@Chouffe

@Chouffe Chouffe commented Oct 22, 2025

Copy link
Copy Markdown
Contributor

Summary

Enhances sonar video preprocessing with edge-based fish detection in the green channel, providing a triple-channel visualization for improved fish identification.

Changes

Core Improvements

  • Bidirectional guided filtering: Applies guided filtering in both directions (frame-guided MOG and MOG-guided frame) for more robust edge detection
  • Edge intersection algorithm: Uses Canny edge detection on both guided outputs and computes their intersection to identify high-confidence fish boundaries
  • Triple-channel visualization:
    • Blue: Gaussian-blurred input (static background)
    • Green: Edge intersection (high-confidence fish boundaries)
    • Red: Motion detection (moving regions)
    • Yellow (Green + Red): Moving objects with clear edges → fish with highest confidence

API Improvements

  • Replaced tuple returns with PreprocessingResult dataclass for type safety and clarity
  • Added default parameter values to preprocess_frame() matching CLI defaults
  • Cleaner, more maintainable API with IDE autocomplete support

New CLI Parameters

Both preprocess_sonar_video.py and stabilize_and_preprocess_sonar_video.py now support:

  • --edge-canny-low: Lower threshold for Canny edge detection (default: 200)
  • --edge-canny-high: Upper threshold for Canny edge detection (default: 255)
  • --edge-dilation-size: Dilation size for edge tolerance (default: 2)

Technical Details

The edge detection approach is based on production-proven techniques from the Salmon-Computer-Vision project for fish counting in sonar imagery. The bidirectional filtering and edge intersection logic eliminates spurious edges while preserving true fish boundaries.

Visual Interpretation

Users can now easily identify fish by looking for yellow regions in the output videos, where:

  • Green edges indicate high-confidence object boundaries
  • Red indicates motion
  • Yellow overlap indicates moving objects with clear boundaries (fish)

Testing

Manually tested with sample ARIS sonar videos. The green channel successfully highlights fish edges, and yellow regions correspond to confirmed fish detections.

@Chouffe
Chouffe merged commit 3b05831 into main Oct 22, 2025
2 checks passed
@Chouffe
Chouffe deleted the arthur/green-spike branch October 22, 2025 12:01
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