Add color_match: colour-aware (HSV) template matching#394
Merged
Conversation
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.
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 20 |
| Duplication | 1 |
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.



摘要
新增
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_color、match_color_all。AC_match_color+AC_match_color_all/ MCPac_match_color+ac_match_color_all/ Script Builder(Image)。測試
test_color_match_batch.py— 找到色彩目標、辨別色彩(高門檻排除同形狀藍黃干擾)、空白→None、wiring + facade。5 passed。ruff / bandit / radon / float-scan / Qt-free 全乾淨。