face_verification_core 0.2.0

Cross-platform on-device face liveness and verification core.
Documentation
//! Core types for an on-device face liveness and verification engine.
//!
//! This crate is intentionally UI-agnostic and Flutter-agnostic. It should be
//! usable from Flutter, Tauri, native Rust apps, servers, or any host that can
//! call Rust/WASM.

mod challenge;
mod engine;
mod json_bridge;
mod pose;
mod session;
mod types;
mod verify;

pub use challenge::{ChallengeStep, LivenessChallenge, TouchTarget};
pub use engine::{
    FaceVerificationEngine, ModelAsset, ModelBundle, ModelFormat, ModelRole, ModelValidation,
};
pub use json_bridge::{
    analyze_image_json, generate_challenge_json, new_session_json, tick_session_json,
    validate_model_bundle_json, validate_pose_json, verify_captured_photos_json,
    verify_images_json, SessionTickJsonResult,
};
pub use pose::{compute_yaw, validate_pose};
pub use session::{SessionDecision, VerificationSession};
pub use types::{
    Analyzer, BoundingBox, CapturedPhotoAnalysis, Embedding, FaceAnalysis, FrameAnalysis,
    HandAnalysis, ImageInput, Landmarks, NsfwScores, Point, PoseCheck, VerificationThresholds,
};
pub use verify::{face_distance, verify_captured_photos, VerificationChecks, VerificationResult};

pub const EXPECTED_PHOTO_COUNT: usize = 6;
pub const TICK_MS: u64 = 350;
pub const FRAMES_OK_TO_CAPTURE: u8 = 6;

/// Public error type for the core.
#[derive(Debug, thiserror::Error)]
pub enum FaceVerificationError {
    #[error("model is not loaded: {0}")]
    ModelNotLoaded(&'static str),

    #[error("invalid image input")]
    InvalidImage,

    #[error("invalid embedding input")]
    InvalidEmbedding,

    #[error("invalid json input: {0}")]
    InvalidJson(String),

    #[error("feature is not implemented yet: {0}")]
    NotImplemented(&'static str),

    #[error("invalid model bundle: {0}")]
    InvalidModel(String),
}