Merged
Conversation
Contributor
There was a problem hiding this comment.
Hey - 我在这里提供了一些整体性的反馈:
- 在
match_template.go中,循环for y := range th、for range tw、for i := range numWorkers和for range numWorkers试图对整数进行 range 操作,代码将无法编译;这些循环应该改写为常规的索引循环(例如for y := 0; y < th; y++、for i := 0; i < numWorkers; i++以及相应的计数循环)。 - 在
GetImageStats(以及GetAreaStats)中,用于将标准差归零的方差阈值从1e-3改成了1e-6;请考虑这个更严格的阈值是否会在无意中增加被视为有效的低方差区域数量,并与之前的实现相比改变匹配行为。
给 AI 代理的提示
Please address the comments from this code review:
## Overall Comments
- In `match_template.go` the loops `for y := range th`, `for range tw`, `for i := range numWorkers`, and `for range numWorkers` attempt to range over integers and will not compile; these should be rewritten as conventional index loops (e.g., `for y := 0; y < th; y++`, `for i := 0; i < numWorkers; i++`, and corresponding counted loops).
- The variance threshold used to zero out the standard deviation was changed from `1e-3` to `1e-6` in `GetImageStats` (and `GetAreaStats`); consider whether this tighter threshold might unintentionally increase the number of low-variance regions treated as valid and alter matching behavior compared to the previous implementation.帮我变得更有用!请在每条评论上点 👍 或 👎,我会根据你的反馈改进后续的代码评审。
Original comment in English
Hey - I've left some high level feedback:
- In
match_template.gothe loopsfor y := range th,for range tw,for i := range numWorkers, andfor range numWorkersattempt to range over integers and will not compile; these should be rewritten as conventional index loops (e.g.,for y := 0; y < th; y++,for i := 0; i < numWorkers; i++, and corresponding counted loops). - The variance threshold used to zero out the standard deviation was changed from
1e-3to1e-6inGetImageStats(andGetAreaStats); consider whether this tighter threshold might unintentionally increase the number of low-variance regions treated as valid and alter matching behavior compared to the previous implementation.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `match_template.go` the loops `for y := range th`, `for range tw`, `for i := range numWorkers`, and `for range numWorkers` attempt to range over integers and will not compile; these should be rewritten as conventional index loops (e.g., `for y := 0; y < th; y++`, `for i := 0; i < numWorkers; i++`, and corresponding counted loops).
- The variance threshold used to zero out the standard deviation was changed from `1e-3` to `1e-6` in `GetImageStats` (and `GetAreaStats`); consider whether this tighter threshold might unintentionally increase the number of low-variance regions treated as valid and alter matching behavior compared to the previous implementation.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the Go Agent’s template-matching implementation by moving normalized cross-correlation (NCC) and template-matching helpers out of map-tracker into the shared pkg/minicv package, and updating map tracking inference to use the new minicv APIs.
Changes:
- Add
minicv.ComputeNCC,minicv.MatchTemplate, andminicv.MatchTemplateInAreaas reusable template-matching utilities. - Extend
minicv.IntegralArraywithGetAreaStatsto compute mean/std for sub-rectangles efficiently. - Remove duplicated template-matching logic from
map-trackerand switchinfer.gocall sites to the new minicv functions.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
agent/go-service/pkg/minicv/stats_utils.go |
Adjust variance clamping logic and add IntegralArray.GetAreaStats for area mean/std. |
agent/go-service/pkg/minicv/match_template.go |
Introduce shared NCC + template matching (full-image and bounded-area) utilities. |
agent/go-service/map-tracker/utils.go |
Remove map-tracker-local template matching helpers now provided by minicv. |
agent/go-service/map-tracker/infer.go |
Update inference flow to call minicv.MatchTemplate* functions. |
Comments suppressed due to low confidence (1)
agent/go-service/pkg/minicv/match_template.go:2
- New file is missing the repository’s standard copyright header comment seen at the top of other
agent/go-serviceGo files. Add the same header for consistency.
package minicv
Member
Author
|
此 PR 未影响现有逻辑表现,属于可兼容的、非破坏性变更,将立即合并。 |
MistEO
pushed a commit
that referenced
this pull request
Mar 9, 2026
## 概要 此 PR 分离了 Go Agent 的归一化互相关系数计算函数和两个模板匹配函数到 minicv 包。 ## Summary by Sourcery 将 Go 模板匹配和归一化互相关(NCC)逻辑从 map-tracker 中抽取出来,迁移到共享的 minicv 包中,并更新 map-tracker 以使用新的 API。 增强内容: - 在 minicv 包中引入可复用的 NCC 计算和模板匹配辅助方法,包括区域限制匹配和基于积分图的统计工具。 - 调整 map-tracker 的推理代码,使其调用新的 minicv 模板匹配函数,而不是本地实现。 - 通过对极小方差进行钳制(clamp),提升 minicv 统计工具中方差计算的数值稳定性。 <details> <summary>Original summary in English</summary> ## Summary by Sourcery Extract Go template matching and normalized cross-correlation logic from the map-tracker into the shared minicv package and update map-tracker to use the new APIs. Enhancements: - Introduce reusable NCC computation and template matching helpers in the minicv package, including area-restricted matching and integral-based stats utilities. - Adjust map-tracker inference code to call the new minicv template matching functions instead of local implementations. - Improve numerical stability of variance calculations in minicv stats utilities by clamping very small variances. </details>
MistEO
pushed a commit
that referenced
this pull request
Mar 9, 2026
## 概要 此 PR 分离了 Go Agent 的归一化互相关系数计算函数和两个模板匹配函数到 minicv 包。 ## Summary by Sourcery 将 Go 模板匹配和归一化互相关(NCC)逻辑从 map-tracker 中抽取出来,迁移到共享的 minicv 包中,并更新 map-tracker 以使用新的 API。 增强内容: - 在 minicv 包中引入可复用的 NCC 计算和模板匹配辅助方法,包括区域限制匹配和基于积分图的统计工具。 - 调整 map-tracker 的推理代码,使其调用新的 minicv 模板匹配函数,而不是本地实现。 - 通过对极小方差进行钳制(clamp),提升 minicv 统计工具中方差计算的数值稳定性。 <details> <summary>Original summary in English</summary> ## Summary by Sourcery Extract Go template matching and normalized cross-correlation logic from the map-tracker into the shared minicv package and update map-tracker to use the new APIs. Enhancements: - Introduce reusable NCC computation and template matching helpers in the minicv package, including area-restricted matching and integral-based stats utilities. - Adjust map-tracker inference code to call the new minicv template matching functions instead of local implementations. - Improve numerical stability of variance calculations in minicv stats utilities by clamping very small variances. </details>
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.
概要
此 PR 分离了 Go Agent 的归一化互相关系数计算函数和两个模板匹配函数到 minicv 包。
Summary by Sourcery
将 Go 模板匹配和归一化互相关(NCC)逻辑从 map-tracker 中抽取出来,迁移到共享的 minicv 包中,并更新 map-tracker 以使用新的 API。
增强内容:
Original summary in English
Summary by Sourcery
Extract Go template matching and normalized cross-correlation logic from the map-tracker into the shared minicv package and update map-tracker to use the new APIs.
Enhancements: