FaceNetSessionBase

abstract class FaceNetSessionBase<TFace : DetectedFacePose>(referencePortrait: ByteString, val config: FaceNetModelConfig, 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) : FaceMatcherSession

Base class containing the shared biometric verification state machine for FaceNet.

Implements:

  • Single-phase passive verification: confirms both biometric identity match (similarity >= matchThreshold) and passive anti-spoofing liveness (livenessScore >= passiveLivenessThreshold) while the user looks directly at the camera, without requiring directional head-turn challenges.

  • Latching prevention: requires 2 consecutive matching and live frames to prevent accidental triggers.

  • Head pose guidance: detects head pitch, yaw, and roll with contextual user guidance.

  • Timeout handling: 8-second match timeout, 25-second total session timeout.

  • Dynamic visual feedback via OverlayFrame: pulsing ring during positioning, green highlight upon verification.

Constructors

Link copied to clipboard
constructor(referencePortrait: ByteString, config: FaceNetModelConfig, 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<FaceMatcherPromptState>
Link copied to clipboard
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
val matchTimeoutMs: Long = 8000
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val referencePortrait: ByteString
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 computeCameraEmbedding(frame: CameraFrame, face: TFace): FaceEmbedding?

Extracts face crop for face from frame and computes its embedding.

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>, currentSimilarity: Float?, 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, and sets referenceEmbedding.

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: FaceMatcherPromptState.Status, overlay: OverlayFrame?, backgroundColor: Color?)