Conversation
Contributor
There was a problem hiding this comment.
Hey - 我在这里给出了一些整体性的反馈:
- 在
ColorFilterConfig中,建议使用与ColorMatcherParam::method相同的类型(或显式使用cv::ColorConversionCodes枚举),而不是使用带有魔法默认值4的原始int类型,以降低转换代码出错的可能性,并让其更具自说明性。 - 在
PipelineTask::try_add_ocr_node中,带有color_filter的 OCR 节点会被静默地排除在批处理优化之外;添加一条简短注释来解释这一行为,将有助于未来的维护者理解为什么这里需要提前返回。
给 AI 智能体的提示
Please address the comments from this code review:
## Overall Comments
- In `ColorFilterConfig`, consider using the same type as `ColorMatcherParam::method` (or an explicit `cv::ColorConversionCodes` enum) instead of a raw `int` with a magic default `4`, to make the conversion code less error‑prone and self‑documenting.
- In `PipelineTask::try_add_ocr_node`, OCR nodes with `color_filter` are silently excluded from batch optimization; adding a brief comment explaining this behavior would help future maintainers understand why the early return is necessary.帮我变得更有用!请在每条评论上点击 👍 或 👎,我会根据你的反馈改进后续的代码审查。
Original comment in English
Hey - I've left some high level feedback:
- In
ColorFilterConfig, consider using the same type asColorMatcherParam::method(or an explicitcv::ColorConversionCodesenum) instead of a rawintwith a magic default4, to make the conversion code less error‑prone and self‑documenting. - In
PipelineTask::try_add_ocr_node, OCR nodes withcolor_filterare silently excluded from batch optimization; adding a brief comment explaining this behavior would help future maintainers understand why the early return is necessary.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `ColorFilterConfig`, consider using the same type as `ColorMatcherParam::method` (or an explicit `cv::ColorConversionCodes` enum) instead of a raw `int` with a magic default `4`, to make the conversion code less error‑prone and self‑documenting.
- In `PipelineTask::try_add_ocr_node`, OCR nodes with `color_filter` are silently excluded from batch optimization; adding a brief comment explaining this behavior would help future maintainers understand why the early return is necessary.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 adds a color_filter field to the OCR recognition type in the pipeline protocol, allowing OCR nodes to reference a ColorMatch node and apply its color binarization logic before performing OCR recognition. This is useful for improving OCR accuracy on images with specific color patterns by preprocessing them with color-based filtering.
Changes:
- Added
color_filterfield to OCR recognition parameters across the entire codebase (C++, bindings, schema, documentation) - Implemented color filtering logic in OCRer that applies ColorMatch node's color parameters to binarize images before OCR
- Excluded OCR nodes with color_filter from batch optimization to maintain per-node filtering correctness
Reviewed changes
Copilot reviewed 13 out of 14 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| tools/pipeline.schema.json | Added color_filter field definition to OCR recognition schema |
| test/python/pipeline_test.py | Added test case validating color_filter field parsing and retrieval |
| source/binding/Python/maa/pipeline.py | Added color_filter field to JOCR dataclass |
| source/binding/NodeJS/src/apis/pipeline.d.ts | Added color_filter field to OCR TypeScript interface |
| source/MaaFramework/Vision/VisionTypes.h | Added color_filter field to OCRerParam struct |
| source/MaaFramework/Vision/OCRer.h | Added ColorFilterConfig struct and color_filter parameter to OCRer constructor |
| source/MaaFramework/Vision/OCRer.cpp | Implemented apply_color_filter method and integrated it into OCR prediction pipeline |
| source/MaaFramework/Task/PipelineTask.cpp | Excluded OCR nodes with color_filter from batch optimization |
| source/MaaFramework/Task/Component/Recognizer.cpp | Added validation and extraction of ColorMatch node parameters for color filtering |
| source/MaaFramework/Resource/PipelineTypesV2.h | Added color_filter field to JOCR struct for serialization |
| source/MaaFramework/Resource/PipelineParser.cpp | Added parsing logic for color_filter field |
| source/MaaFramework/Resource/PipelineDumper.cpp | Added serialization of color_filter field |
| docs/en_us/3.1-PipelineProtocol.md | Documented color_filter field in English |
| docs/zh_cn/3.1-任务流水线协议.md | Documented color_filter field in Chinese (not shown in diff but verified to exist) |
neko-para
added a commit
to neko-para/maa-support-extension
that referenced
this pull request
Feb 25, 2026
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.
fix #1009
Summary by Sourcery
为 OCR 节点引入可选的基于颜色的预处理功能,并将其配置贯穿管线、绑定层以及文档。
New Features:
ColorMatch参数对图像进行二值化处理。Enhancements:
OCRer组件,包括 ROI 预处理以及将其从批处理优化中排除。color_filter。Documentation:
color_filter,包括其行为和限制。Tests:
color_filter的解析和使用场景。Original summary in English
Summary by Sourcery
Introduce optional color-based preprocessing for OCR nodes and plumb its configuration through the pipeline, bindings, and documentation.
New Features:
Enhancements:
Documentation:
Tests: