Files
yola/Pink/.claude/plans/ct-line-detection-fix.md
T
2026-07-17 15:37:35 +08:00

40 lines
1.6 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Plan: 对齐 C++ C/T 线检测逻辑
## 问题
当前 Kotlin 代码跳过条带定位步骤,直接在整张相机画面(960×1280)上用极低阈值检测 C/T 线,导致噪声轮廓大量通过,C 线检测不稳定。
C++ 方案正确:**先找绿色定位块 → 裁剪旋转条带区域 → 在裁剪后的条带上检测 C/T 线**。
## 修改范围
### 1. `StripLocator.kt` — `locate()` 函数(主路径)
**a) 放宽 center distance ratio(第 408 行)**
- `1.65``1.7`(对齐 C++
**b) C/T 线过滤顺序和阈值(第 542-548 行)**
- 当前:Width(0.03~0.25) → Height(0.4~1.1)
- 改为:Height(0.7~1.1) → Width(0.045~0.20)(对齐 C++
**c) 去重逻辑(第 556-569 行)**
- 当前:保留离图像中心最近的 2 个轮廓
- 改为:左右两侧各保留 1 个(最靠近中心线的),对齐 C++
### 2. `StripLocator.kt` — `locateCroppedStrip()` 函数(回退路径)
**a) 过滤顺序和阈值(第 850-856 行)**
- 当前:Width(0.005~0.35) → Height(0.02~1.1)
- 改为:Height(0.15~1.1) → Width(0.01~0.25)
**b) 去重逻辑(第 864-879 行)**
-`locate()`,改为左右各保留 1 个
### 3. `ScanViewModel.kt` — `processFrameInternal()`(第 161-166 行)
- 当前:直接调用 `locateCroppedStrip(rgbMat)`
- 改为:先 try `locate(srcRgba, roiRect, false)`,失败再 fallback 到 `locateCroppedStrip`
## 预期效果
- C/T 线检测在裁剪后的条带区域上进行,过滤阈值合理
- C 线检测更稳定,减少"只检测到 1 条线"的情况
- 即使 `locate()` 失败,fallback 路径也有改善的阈值