|
@@ -130,6 +130,7 @@ const state = reactive({
|
|
|
recordingTimer: null,
|
|
recordingTimer: null,
|
|
|
isRecording: false,
|
|
isRecording: false,
|
|
|
lastBlob: null,
|
|
lastBlob: null,
|
|
|
|
|
+ failCount: 0,
|
|
|
uploading: false, // 上传状态
|
|
uploading: false, // 上传状态
|
|
|
})
|
|
})
|
|
|
|
|
|
|
@@ -275,9 +276,13 @@ async function fnRedrawDiscern() {
|
|
|
.withFaceDescriptors()
|
|
.withFaceDescriptors()
|
|
|
|
|
|
|
|
if (!detect || detect.length === 0) {
|
|
if (!detect || detect.length === 0) {
|
|
|
- tagColor.value = 'blue'
|
|
|
|
|
- tagInfo.value = '请将面部完全放置在取景框中央'
|
|
|
|
|
- if (state.isRecording) stopRecording()
|
|
|
|
|
|
|
+ state.failCount++
|
|
|
|
|
+ if (state.failCount >= 3) {
|
|
|
|
|
+ tagColor.value = 'blue'
|
|
|
|
|
+ tagInfo.value = '请将面部完全放置在取景框中央'
|
|
|
|
|
+ if (state.isRecording) stopRecording()
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
// 延迟下一次识别,避免直接递归造成栈/CPU 问题
|
|
// 延迟下一次识别,避免直接递归造成栈/CPU 问题
|
|
|
clearTimeout(state.timer)
|
|
clearTimeout(state.timer)
|
|
|
state.timer = setTimeout(() => fnRedrawDiscern(), 300)
|
|
state.timer = setTimeout(() => fnRedrawDiscern(), 300)
|
|
@@ -297,12 +302,14 @@ async function fnRedrawDiscern() {
|
|
|
|
|
|
|
|
if (best) {
|
|
if (best) {
|
|
|
if (best._distance <= 0.6) {
|
|
if (best._distance <= 0.6) {
|
|
|
|
|
+ state.failCount = 0
|
|
|
tagColor.value = 'green'
|
|
tagColor.value = 'green'
|
|
|
tagInfo.value = '录制中,请确保面部不要离开取景框'
|
|
tagInfo.value = '录制中,请确保面部不要离开取景框'
|
|
|
if (!state.isRecording) startRecording()
|
|
if (!state.isRecording) startRecording()
|
|
|
// 找到一个合格的人脸就可以停止遍历
|
|
// 找到一个合格的人脸就可以停止遍历
|
|
|
break
|
|
break
|
|
|
} else {
|
|
} else {
|
|
|
|
|
+ state.failCount = 3
|
|
|
tagColor.value = 'red'
|
|
tagColor.value = 'red'
|
|
|
tagInfo.value = `人脸匹配失败,请确保为 ${props?.userInfo?.name} 本人操作`
|
|
tagInfo.value = `人脸匹配失败,请确保为 ${props?.userInfo?.name} 本人操作`
|
|
|
if (state.isRecording) restartRecording()
|
|
if (state.isRecording) restartRecording()
|