Add saliency: spectral-residual visual saliency (where to look)#408
Merged
Conversation
When there's no template, colour or text to key on, an agent still needs a cue for where to look. Compute the spectral-residual saliency map (Hou & Zhang 2007) and rank salient boxes in source coordinates. Pure numpy FFT (cv2.saliency is opencv-contrib, forbidden), reusing visual_match's grayscale loader and cv2_utils.blobs.connected_boxes; regions threshold at mean+2*std by default. A coarse attention cue to narrow where a template / OCR pass then looks.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 30 |
| Duplication | 0 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Why
When there's no template, no known colour and no text to OCR, an agent still needs a cue for where to look — the region that stands out (a popup, a badge, a highlighted row).
saliencycomputes the spectral-residual saliency map (Hou & Zhang 2007 — log amplitude minus its local average, reconstructed through the phase) and turns it into ranked salient boxes.saliency_map— the normalised (0–1) saliency map as an ndarraysalient_regions— ranked salient boxes{x, y, width, height, center, score}in source pixel coordinatesmost_salient— the single most salient region (the first place to look)Design
cv2.saliencylives in the forbidden opencv-contrib package, so it's re-implemented over base opencv only.visual_match._haystack_gray(any ndarray / path / PIL image, or the live screen) andcv2_utils.blobs.connected_boxesfor region extraction. cv2/numpy lazily imported.mean + 2·stdof the saliency map by default (scale-invariant; passthresholdto override), then scale back to source pixel coordinates. Saliency is a coarse attention cue, documented as such — it narrows where a template / OCR pass then looks.__all__→AC_salient_regions/AC_most_salient→ read-onlyac_*MCP tools → Script Builder (Image). Qt-free verified.Tests
test/unit_test/headless/test_saliency_batch.py(cv2 viaimportorskip) — map shape/dtype/range,sizeparam, salient regions in-bounds + ranked + scores in [0,1] on a 3-block frame,most_salientmatches the top region, the high-threshold[]/Nonepath, the pure executor path, and 5-layer wiring. 23 passed with the vision siblings. This completes the vision lane HIGH items (image_quality/scale_detect/saliency).