71 lines
4.0 KiB
Kotlin
71 lines
4.0 KiB
Kotlin
import com.gorios.lanvoice.expression.*
|
|
|
|
fun main() {
|
|
cameraPixelsCheck()
|
|
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(cameraTimeout(boot.snapshot(),35000)==CameraFailure.FRAME_TIMEOUT)
|
|
check(boot.snapshot().profile==CameraProfile.YUV_640 && boot.snapshot().recoveries==0)
|
|
boot.binding(30000)
|
|
boot.nativeState(CameraNativeState.OPEN,30200)
|
|
check(boot.snapshot().nativeState==CameraNativeState.OPEN && boot.snapshot().nativeStateSinceMs==30200L)
|
|
check(boot.snapshot().processed==0 && boot.snapshot().firstFrameMs == -1L) // OPEN is not frame readiness.
|
|
boot.received(39000)
|
|
boot.received(39100)
|
|
check(boot.snapshot().firstFrameMs==39000L && boot.snapshot().bindStartedMs==30000L)
|
|
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(),44100)==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
|
|
for (time in 0L..600_000L step 100) {
|
|
camera.received()
|
|
camera.processed(0, FaceCueObservation(reason = FaceCueReason.NO_FACE), 8)
|
|
if (camera.summary(time) != null) summaries++
|
|
}
|
|
check(summaries == 61) // 10Hz samples, <=1 summary/10s including first.
|
|
check(camera.snapshot().received == 6001 && camera.snapshot().processed == 6001)
|
|
check(camera.snapshot().faceCount == 0 && camera.snapshot().reason == FaceCueReason.NO_FACE)
|
|
camera.processed(1, FaceCueObservation(FaceCue.SMILING, .9f, 900, 0, FaceCueReason.STABLE), 12)
|
|
camera.failed(CameraFailure.ANALYSIS)
|
|
check(camera.snapshot().cue == FaceCue.SMILING && camera.snapshot().failures == 1)
|
|
check(camera.summary(600_001) == null)
|
|
val final = checkNotNull(camera.summary(600_001, force = true))
|
|
check("failure=analysis" in final && "cue=smiling" in final)
|
|
check(listOf("landmark", "blendshape", "image", "prompt", "reply").none { it in final })
|
|
val send = FaceTransmissionDiagnostics()
|
|
check(send.snapshot().reason == FaceSendReason.SHARING_OFF)
|
|
send.record(FaceSendReason.NO_STABLE_CUE)
|
|
check(send.snapshot().attempts == 0)
|
|
send.record(FaceSendReason.SENT, FaceCue.SMILING)
|
|
send.record(FaceSendReason.CLEARED)
|
|
send.record(FaceSendReason.SEND_FAILED)
|
|
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: production camera readiness deadlines/single YUV attempt/native-open is not readiness/no-frame vs no-result/stale/stop; enum-only counters and 10s summaries")
|
|
}
|