fix(example): 修复注册后不显示已注册状态的问题

问题:注册按钮只更新了显示列表,没有将特征标识和ID存入映射表
修复:
- 添加 _currentFaceKeys 保存当前帧的人脸特征标识
- 注册时将特征标识和生成的ID存入 _faceIdMap
- 下次检测时可以从映射表中找到已注册的ID

Quick task: 260330-ll6
This commit is contained in:
2026-03-30 15:35:42 +08:00
parent cbfeabd57a
commit 1c4f01904e
3 changed files with 52 additions and 6 deletions

View File

@@ -22,6 +22,7 @@
| # | Description | Date | Commit | Directory |
|---|-------------|------|--------|-----------|
| 260330-ld1 | 在example的人脸识别预览页面增加注册按钮和人脸ID显示 | 2026-03-30 | 184c3a9 | [260330-ld1-example-id-id](./quick/260330-ld1-example-id-id/) |
| 260330-ll6 | 修复注册后不显示已注册状态的问题 | 2026-03-30 | - | [260330-ll6-fix-registration](./quick/260330-ll6-fix-registration/) |
---
*State initialized: 2026-03-30*

View File

@@ -0,0 +1,36 @@
# Quick Task 260330-ll6: Summary
## Task
注册完成后并不会显示用户已注册,检查一下注册流程和检测流程。
## Problem Analysis
**问题根源**
1. 检测时,`_getFaceKey()` 生成人脸特征标识
2. 注册按钮只更新了 `_currentFaceIds` 列表,但**没有将特征标识和ID存入 `_faceIdMap`**
3. 下次检测时,`_faceIdMap` 为空,所有人脸都显示"未注册"
## Fix
### `example/lib/main.dart`
1. **添加状态变量**: `_currentFaceKeys` - 保存当前帧的人脸特征标识列表
2. **修改检测流程**: 同时保存特征标识和ID
3. **修改注册流程**: 注册时将特征标识和生成的ID存入 `_faceIdMap`
## Code Changes
```dart
// 新增: 保存当前帧的人脸特征标识
List<String> _currentFaceKeys = [];
// 检测时: 同时保存特征标识
_currentFaceKeys = faceList.map((face) => _getFaceKey(face)).toList();
_currentFaceIds = _currentFaceKeys.map((key) => _faceIdMap[key] ?? '未注册').toList();
// 注册时: 将特征标识和ID存入映射表
_faceIdMap[faceKey] = newId;
```
## Verification
- `flutter analyze lib/main.dart` - No issues found
---
*Completed: 2026-03-30*