Expose face presence diagnostics and bound camera readiness recovery

This commit is contained in:
zenord
2026-10-13 17:14:37 +08:00
parent d0c1d7eb3d
commit 62dce32bb7
14 changed files with 348 additions and 44 deletions
+32 -1
View File
@@ -1,6 +1,37 @@
import com.gorios.lanvoice.expression.*
fun main() {
val fence=CameraCallbackFence()
val initial=fence.nextBinding()
check(fence.accepts(initial))
fence.invalidate();check(!fence.accepts(initial))
val recovered=fence.nextBinding()
check(fence.accepts(recovered) && !fence.accepts(initial))
fence.close();check(!fence.accepts(recovered))
check(runCatching { fence.nextBinding() }.isFailure)
val boot=CameraAnalysisDiagnostics()
boot.stage(CameraStage.MODEL_LOADING,100)
check(cameraTimeout(boot.snapshot(),15099)==CameraFailure.NONE)
check(cameraTimeout(boot.snapshot(),15100)==CameraFailure.MODEL_TIMEOUT)
boot.stage(CameraStage.PROVIDER_WAIT,20000)
check(cameraTimeout(boot.snapshot(),28000)==CameraFailure.PROVIDER_TIMEOUT)
boot.stage(CameraStage.WAITING_FRAME,30000)
check(cameraTimeout(boot.snapshot(),34999)==CameraFailure.NONE)
check(canRecoverFirstFrame(boot.snapshot(),cameraTimeout(boot.snapshot(),35000)))
boot.recovering();boot.stage(CameraStage.WAITING_FRAME,35000)
check(!canRecoverFirstFrame(boot.snapshot(),cameraTimeout(boot.snapshot(),40000)))
boot.received(39000)
check(boot.snapshot().stage==CameraStage.WAITING_RESULT)
check(cameraTimeout(boot.snapshot(),44000)==CameraFailure.RESULT_TIMEOUT)
boot.processed(0,FaceCueObservation(reason=FaceCueReason.NO_FACE),10,40000)
check(boot.snapshot().stage==CameraStage.READY && boot.snapshot().processed==1)
check(cameraTimeout(boot.snapshot(),44000)==CameraFailure.FRAME_TIMEOUT)
boot.received(44500)
check(cameraTimeout(boot.snapshot(),45000)==CameraFailure.RESULT_TIMEOUT)
boot.stage(CameraStage.OFF,45000)
check(cameraTimeout(boot.snapshot(),100000)==CameraFailure.NONE)
boot.failed(CameraFailure.FRAME_TIMEOUT)
check(cameraTimeout(boot.snapshot(),100000)==CameraFailure.NONE)
val camera = CameraAnalysisDiagnostics()
check(camera.snapshot().reason == FaceCueReason.NO_FRAME)
var summaries = 0
@@ -29,5 +60,5 @@ fun main() {
send.record(FaceSendReason.STALE)
check(send.snapshot().attempts == 3 && send.snapshot().sent == 1 && send.snapshot().clears == 1 && send.snapshot().failures == 1)
check(send.summary(0) != null && send.summary(9999) == null && send.summary(10000) != null)
println("PASS: enum-only camera/frame/send snapshots, failure counters, 10s rate bound, no-face/stable/stale/clear accounting")
println("PASS: production camera readiness deadlines/one bounded first-frame recovery/no-frame vs no-result/stale/stop; enum-only counters and 10s summaries")
}