Capture session lifecycle
FaceCaptureSession is an EventEmitter with the following shape:
idle → initializing → ready → detecting → hold_steady → capturing → (quality_check) → completed
↘ retry → detecting
↘ errorYou call start(). The session opens the camera, runs detection, emits a 'guidance' event on every frame, fires 'captured' when a frame passes the gates, then 'completed'. Call stop() to tear down early.
Events
| Event | Payload |
|---|---|
started | none |
state_change | FaceCaptureState |
detection | FaceDetectionEvent |
guidance | GuidanceState |
face_quality | FaceQualityResult |
face_quality_failed | FaceQualityResult (a retry attempt failed) |
face_quality_error | { reason } |
captured | face capture result (see note) |
completed | final result |
error | SladeIDError subclass |
stopped | none |
The captured payload is a partial object — { imageBase64, antispoofScore, deviceInfo } — which you pass straight to enrollFace / matchFace / searchFace; the full FaceCaptureResult (including livenessCompleted, challengeResults) is carried by the completed event.
Reading the state
Wire 'guidance' to the UI for prompts (“hold steady”, “move closer”). Wire 'state_change' for higher-level UI changes (showing a countdown, swapping the overlay). Wire 'captured' and 'completed' for the success path; wire 'error' for the failure path.
Used in
- Every capture guide.
- Capture sessions reference.