FaceNetLivenessSessionBase

abstract class FaceNetLivenessSessionBase<TFace : DetectedFacePose>(val config: FaceNetModelConfig, poses: List<FacePose> = listOf(FacePose.FRONT), val debug: Boolean = false, val matcherName: String = "facenet", val matcherDisplayName: String = "MobileFaceNet", val clock: () -> Long = { Clock.System.now().toEpochMilliseconds() }, randomSeed: Long = clock(), val enablePoseSmoothing: Boolean = true) : FaceMatcherLivenessSession

Base class containing the shared liveness verification and sequential pose capture state machine for FaceNet.

Implements:

  • Sequential capture of the caller-requested poses in order (defaulting to [FacePose.FRONT]).

  • Passive liveness verification on FacePose.FRONT: evaluates MiniFASNetV2 anti-spoofing (livenessScore >= passiveLivenessThreshold) while the user looks straight at the camera.

  • Directional head-pose guidance and capture for FacePose.LOOK_LEFT, FacePose.LOOK_RIGHT, FacePose.LOOK_UP, and FacePose.LOOK_DOWN.

  • High-resolution portrait photo capture for each pose across 2 consecutive valid frames.

  • Dynamic visual feedback via OverlayFrame and segmented ring.

Constructors

Link copied to clipboard
constructor(config: FaceNetModelConfig, poses: List<FacePose> = listOf(FacePose.FRONT), debug: Boolean = false, matcherName: String = "facenet", matcherDisplayName: String = "MobileFaceNet", clock: () -> Long = { Clock.System.now().toEpochMilliseconds() }, randomSeed: Long = clock(), enablePoseSmoothing: Boolean = true)

Types

Link copied to clipboard

Properties

Link copied to clipboard
protected val _state: MutableStateFlow<FaceMatcherLivenessPromptState>
Link copied to clipboard
Link copied to clipboard
val clock: () -> Long
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val sessionTimeoutMs: Long = 25000
Link copied to clipboard

Functions

Link copied to clipboard
open override fun cancel()
Link copied to clipboard
protected abstract suspend fun captureHighResolutionImage(frame: CameraFrame): ByteString?

Captures a high-resolution upright portrait photo from frame.

Link copied to clipboard
protected open suspend fun computeLivenessScore(frame: CameraFrame, face: TFace): Float?

Computes the passive anti-spoofing liveness score (real face probability in [0.0, 1.0]) for face in frame.

Link copied to clipboard
protected open fun createOverlay(frame: CameraFrame, faces: List<TFace>, currentLivenessScore: Float? = null): OverlayFrame?
Link copied to clipboard
protected abstract suspend fun detectFaces(frame: CameraFrame): List<TFace>

Detects faces in frame.

Link copied to clipboard
protected fun failSession(message: String, overlay: OverlayFrame? = null)
Link copied to clipboard
open suspend override fun feedFrame(frame: CameraFrame)
Link copied to clipboard
protected abstract suspend fun initializePipeline()

Initializes platform-specific detector and interpreter pipelines.

Link copied to clipboard
protected abstract fun onSessionClosed()

Releases platform resources when session is closed or cancelled.

Link copied to clipboard
open override fun onTouchEvent(x: Float, y: Float)
Link copied to clipboard
protected fun updateState(message: String?, status: FaceMatcherLivenessPromptState.Status, overlay: OverlayFrame?, capturedImages: Map<FacePose, ByteString>, backgroundColor: Color?)