Skip to content

Add color_match: colour-aware (HSV) template matching#394

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

Add color_match: colour-aware (HSV) template matching#394
JE-Chen merged 1 commit into
devfrom
feat/color-match-batch

Conversation

@JE-Chen

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

Copy link
Copy Markdown
Member

摘要

新增 match_color / match_color_all — 在 HSV 色相/飽和度通道上做色彩感知樣板比對。visual_match 每個比對器都先轉灰階,故形狀相同的紅色與綠色狀態指示燈對 match_template 無法區分;color_region已知顏色的 blob 卻無法以外觀對多色字形做樣板比對。

本功能以色彩距離度量(TM_SQDIFF_NORMED,而非相關——相關會把絕對色相正規化掉,使紅→綠邊與黑→藍邊同分)在 H/S 通道比對,定位灰階比對會塌掉的色彩辨識目標。重用 color_region 的 RGB 載入器與 visual_match 的 resize/NMS/Match;haystack 可注入。註:平坦純色 patch 無通道變異,純色 blob 請用 find_color_region;本功能適用於有色彩結構的目標。Qt-free。

五層

  • 核心:utils/color_match/match_colormatch_color_all
  • Facade / Executor AC_match_color + AC_match_color_all / MCP ac_match_color + ac_match_color_all / Script Builder(Image)。
  • 文件:v179 EN + Zh + toctree。更新日誌:root EN + zh-TW + zh-CN。

測試

test_color_match_batch.py — 找到色彩目標、辨別色彩(高門檻排除同形狀藍黃干擾)、空白→None、wiring + facade。5 passed。ruff / bandit / radon / float-scan / Qt-free 全乾淨。

Every visual_match matcher grayscales first, so red vs green of identical shape
is indistinguishable; color_region finds known-colour blobs but can't
template-match a multi-colour glyph. Match on HSV hue/saturation with a
colour-distance metric (TM_SQDIFF_NORMED, not correlation which normalises away
the absolute hue). Reuses color_region's RGB loaders and visual_match's
resize/NMS/Match.
@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 20 complexity · 1 duplication

Metric Results
Complexity 20
Duplication 1

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 8410eab into dev Jun 23, 2026
16 checks passed
@JE-Chen JE-Chen deleted the feat/color-match-batch branch June 23, 2026 23:26
@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