face regonition refine

This commit is contained in:
gcw_4spBpAfv
2026-03-10 15:40:05 +08:00
parent d5767156b9
commit ec1f7d2e72
1579 changed files with 4286 additions and 319 deletions

View File

@@ -1,6 +1,7 @@
plugins { plugins {
id 'com.android.application' id 'com.android.application'
id 'org.jetbrains.kotlin.android' id 'org.jetbrains.kotlin.android'
id 'kotlin-kapt'
} }
android { android {
@@ -91,4 +92,9 @@ dependencies {
implementation files('libs/realtime_tts-release-v2.0.16-20260128-d80cafe.aar') implementation files('libs/realtime_tts-release-v2.0.16-20260128-d80cafe.aar')
implementation 'com.google.code.gson:gson:2.8.9' implementation 'com.google.code.gson:gson:2.8.9'
implementation 'com.squareup.okhttp3:okhttp:4.9.3' implementation 'com.squareup.okhttp3:okhttp:4.9.3'
// Room dependencies
implementation 'androidx.room:room-runtime:2.5.2'
kapt 'androidx.room:room-compiler:2.5.2'
implementation 'androidx.room:room-ktx:2.5.2'
} }

View File

@@ -140,13 +140,13 @@ https://tianchi.aliyun.com/dataset/93864
动作 动作
- 认识用户: haru_g_m22 (高兴动作) - 认识用户: haru_g_m22 (高兴动作)
- 不认识: haru_g_m01中性动作 - 不认识: haru_g_m01中性动作
AI问候根据是否认识个性化 AI问候根据是否认识,节日,时间等因素个性化)
启动20秒计时器 启动20秒计时器
[等待回复状态] [等待回复状态]
动作 haru_g_m17 动作 haru_g_m17
├─ 如果用户在20秒内回复 → 进入[对话状态] ├─ 如果用户按下了麦克风按钮 → 进入[对话状态]
│ 动作 :根据对话情绪动态调整 │ 动作 :根据对话情绪动态调整
│ - 开心: haru_g_m22 / haru_g_m21 / haru_g_m18 / haru_g_m09 / haru_g_m08 │ - 开心: haru_g_m22 / haru_g_m21 / haru_g_m18 / haru_g_m09 / haru_g_m08
│ - 悲伤: haru_g_m25 / haru_g_m24 / haru_g_m05 / haru_g_m16 │ - 悲伤: haru_g_m25 / haru_g_m24 / haru_g_m05 / haru_g_m16
@@ -195,3 +195,62 @@ https://tianchi.aliyun.com/dataset/93864
[告别状态] (用户离开后) [告别状态] (用户离开后)
动作 简短告别,用语音,→ 等待3秒 → 回到[空闲状态] 动作 简短告别,用语音,→ 等待3秒 → 回到[空闲状态]
11. ## 用户类型区分
1. guest 用户
- 默认用户ID当没有检测到人脸时使用
- 在 Live2DChatActivity.kt 中初始化为 private var activeUserId: String = "guest"
- 表示未通过人脸识别的临时用户
2. face_ 用户
- 通过人脸识别生成的用户ID格式为 face_<数字>
- 在 FaceDetectionPipeline.kt 中生成: lastFaceIdentityId = match.matchedId?.let { "face_$it" }
- 表示通过人脸识别的正式用户
## 转换逻辑
当系统检测到人脸时,会触发以下流程:
1. 人脸检测 FaceDetectionPipeline 检测到人脸
2. 身份识别 FaceRecognizer 尝试识别用户身份
3. ID生成 :如果是新用户,生成新的 face_<数字> ID
4. 回调更新 :通过 onPresenceChanged 回调将 faceIdentityId 传递给 Live2DChatActivity
5. ID切换 Live2DChatActivity 中的 interactionController.onFacePresenceChanged 会调用 handler.onRememberUser(faceIdentityId, recognized)
6. 更新活跃用户 onRememberUser 方法会将 activeUserId 更新为 faceIdentityId
因此,当检测到人脸时, guest 用户会自动切换为 face_ 用户。
face_profiles 和 user_memory 表之间的关联是通过 ID转换 实现的,没有专门的关联表:
## 关联机制
1. ID转换规则
- face_profiles 表中的 id 字段(数字)→ 转换为 face_<id> 格式
- 例如: id=1 → face_1
- 这个转换在 FaceDetectionPipeline.kt 中实现: lastFaceIdentityId = match.matchedId?.let { "face_$it" }
2. 关联流程
- 系统检测到人脸后,从 face_profiles 表中查找匹配的记录,获取 id
- 将 id 转换为 face_<id> 格式的用户ID
- 这个用户ID被用作 user_memory 表中的 userId 字段
- 通过这个 userId ,两个表就建立了关联
12. 使用 adb shell 直接操作sqlite数据库
1. 进入设备 shell
adb shell
2. 找到应用数据库
# 进入应用数据目录
run-as com.digitalperson
# 进入数据库目录
cd databases
# 查看数据库文件
ls -la
3. 使用 sqlite3 命令查看数据库
bash
# 打开数据库
sqlite3 your_database.db # digital_human.db face_feature.db
# 在 sqlite3 提示符下执行命令:
.tables # 查看所有表
.schema table_name # 查看表结构
SELECT * FROM table_name; # 查询数据
.headers on # 显示列名
.mode column # 列模式显示
.quit # 退出

Binary file not shown.

Binary file not shown.

Some files were not shown because too many files have changed in this diff Show More