perf: avoid masked matchTemplate when no mask is needed#1317
Open
weypro wants to merge 1 commit into
Open
Conversation
Contributor
There was a problem hiding this comment.
你好——我在这里给出了一些总体反馈:
- TemplateMatcherPerformance.cpp 和 TemplateMatcherCorrectness.cpp 都重新实现了若干辅助函数(例如 default_testset_dir、has_pipeline_smoking_dataset、list_png_files、create_green_mask_like_framework、make_real_data_green_mask_template);建议将这些函数抽取到一个共享的测试工具源码中,以避免重复实现,并保持行为一致。
- TemplateMatcher 测试可执行文件在 template_matcher_common_src 中直接列出了 TemplateMatcher.cpp、VisionBase.cpp 和 OptionMgr.cpp,而不是链接到已有的 MaaFramework 目标;将它们改为链接到该库目标可以降低 ODR/编译选项分歧的风险,并让测试自动与框架的构建设置保持同步。
给 AI Agent 的提示
Please address the comments from this code review:
## Overall Comments
- TemplateMatcherPerformance.cpp 和 TemplateMatcherCorrectness.cpp 都重新实现了若干辅助函数(例如 default_testset_dir、has_pipeline_smoking_dataset、list_png_files、create_green_mask_like_framework、make_real_data_green_mask_template);建议将这些函数抽取到一个共享的测试工具源码中,以避免重复实现,并保持行为一致。
- TemplateMatcher 测试可执行文件在 template_matcher_common_src 中直接列出了 TemplateMatcher.cpp、VisionBase.cpp 和 OptionMgr.cpp,而不是链接到已有的 MaaFramework 目标;将它们改为链接到该库目标可以降低 ODR/编译选项分歧的风险,并让测试自动与框架的构建设置保持同步。帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续评审。
Original comment in English
Hey - I've left some high level feedback:
- Both TemplateMatcherPerformance.cpp and TemplateMatcherCorrectness.cpp reimplement several helpers (e.g., default_testset_dir, has_pipeline_smoking_dataset, list_png_files, create_green_mask_like_framework, make_real_data_green_mask_template); consider factoring these into a shared test utility source to avoid duplication and keep behavior consistent.
- The TemplateMatcher test executables list TemplateMatcher.cpp, VisionBase.cpp, and OptionMgr.cpp directly in template_matcher_common_src instead of linking against the existing MaaFramework target; wiring them to the library target would reduce the risk of ODR/flag divergence and keep the tests automatically in sync with framework build settings.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- Both TemplateMatcherPerformance.cpp and TemplateMatcherCorrectness.cpp reimplement several helpers (e.g., default_testset_dir, has_pipeline_smoking_dataset, list_png_files, create_green_mask_like_framework, make_real_data_green_mask_template); consider factoring these into a shared test utility source to avoid duplication and keep behavior consistent.
- The TemplateMatcher test executables list TemplateMatcher.cpp, VisionBase.cpp, and OptionMgr.cpp directly in template_matcher_common_src instead of linking against the existing MaaFramework target; wiring them to the library target would reduce the risk of ODR/flag divergence and keep the tests automatically in sync with framework build settings.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Member
|
🤖 感谢!核心 perf 修复(绕过 all-ones mask 走 unmasked overload)没问题,收益也实在。不过这 PR 其实塞了三样东西,能拆一下吗?
|
72ef426 to
655ed2f
Compare
MistEO
approved these changes
May 15, 2026
Member
MistEO
left a comment
There was a problem hiding this comment.
🤖 单文件这版干净,全 1 mask bypass 没毛病,LGTM
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.
由 Sourcery 提供的总结
通过在掩码实际不会起作用时跳过带 mask 的
matchTemplate调用来优化模板匹配,并基于现有测试数据集为 TemplateMatcher 引入专门的性能与正确性测试可执行程序。新特性:
TemplateMatcherPerformance可执行文件,用于对模板匹配行为以及 OpenCV 使用情况进行基准测试。TemplateMatcherCorrectness可执行文件,用于将 TemplateMatcher 的结果与原生 OpenCVmatchTemplate的预期结果进行对比验证。增强:
cv::matchTemplate,而是回退到无 mask 的重载版本。构建:
BUILD_PERFORMANCE_TESTING选项,将 templatematcher 测试和共享的TestingDataSet子目录接入构建系统,并在启用流水线测试时强制启用WITH_DBG_CONTROLLER。测试:
Original summary in English
Summary by Sourcery
Optimize template matching by skipping masked matchTemplate calls when the mask would be effectively unused, and introduce dedicated performance and correctness test binaries for TemplateMatcher using the existing test dataset.
New Features:
Enhancements:
Build:
Tests: