Skip to content

Add edge_match: edge-shape (Chamfer) template matching#380

Merged
JE-Chen merged 1 commit into
devfrom
feat/edge-match-batch
Jun 23, 2026
Merged

Add edge_match: edge-shape (Chamfer) template matching#380
JE-Chen merged 1 commit into
devfrom
feat/edge-match-batch

Conversation

@JE-Chen

@JE-Chen JE-Chen commented Jun 23, 2026

Copy link
Copy Markdown
Member

摘要

新增 edge_match / edge_match_all / chamfer_distance — 以邊緣形狀(Chamfer / 距離轉換)定位模板。強度相關(visual_match)在同一控制項以不同填充 / 漸層 / 主題 / 抗鋸齒繪製時分數下降;ORB 特徵比對(feature_match)需要扁平設計圖示(漢堡選單、單純箭號)缺乏的角點紋理。

本功能改以邊緣形狀比對:對兩圖跑 Canny,對場景邊緣建立距離轉換,把模板邊緣滑過它,以「每個模板邊緣到最近場景邊緣的平均距離」評分(Chamfer)。完美對齊的成本約為 0,與形狀如何填充 / 著色無關。重用 visual_match 的灰階載入器 / resize / NMS / Matchedge_lines 的 Canny 預設。haystack 可注入;Qt-free。

五層

  • 核心:utils/edge_match/edge_matchedge_match_allchamfer_distance
  • Facade:由 je_auto_control 匯出 + __all__
  • Executor:AC_edge_match({found, match})/ AC_edge_match_all({count, matches})。
  • MCP:ac_edge_match / ac_edge_match_all(read-only)。
  • Script Builder:Match Template (edge shape) / Match Template All (edge shape)(Image)。
  • 文件:v168 EN + Zh + toctree。更新日誌:root EN + zh-TW + zh-CN。

測試

test/unit_test/headless/test_edge_match_batch.py — 不同灰階仍以輪廓找到形狀(score>=0.9、位置正確)、chamfer 距離近 0、空白→None、edge_match_all NMS 去重。6 passed。ruff / bandit / radon / float-scan / Qt-free 全乾淨。

Intensity NCC drops when a control is re-filled or re-themed, and ORB needs
corner texture flat-design glyphs lack. Match by edge shape instead: Canny both
images, distance-transform the scene edges, slide the template's edges over it
and score by mean edge-to-edge distance (Chamfer). A perfect outline aligns at
~0 cost regardless of fill. Reuses visual_match's loaders/resize/NMS/Match and
edge_lines's Canny default.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 29 complexity · 0 duplication

Metric Results
Complexity 29
Duplication 0

View in Codacy

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.

@JE-Chen JE-Chen merged commit 0118029 into dev Jun 23, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/edge-match-batch branch June 23, 2026 20:23
@sonarqubecloud

Copy link
Copy Markdown

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