main
Source: main.js:2
Instance Methods
loadModels()
Loads all required face-api.js models for facial detection, landmarks, recognition, and age/gender. This is called during application startup to ensure the models are cached before any webcam processing.
- See:
- init – the main initialization routine that invokes `loadModels` before starting the camera.
- setStatus – updates UI status while models are being loaded.
handleError(err: Error, fallbackMessage: string)
Centralized error handling for UI actions. Logs the fallback message, the error details, updates the status UI, shows the placeholder, and records the full message in the log.
Parameters
err(Error) — The caught error object.fallbackMessage(string) — User‑friendly message describing the context of the error.
- See:
- init – camera-start failures are routed here.
- startCamera – camera-switch failures are routed here.
buildFaceapiSaveSection(saved2d: Object): object
Build the faceapi section for a save action. After saving, the best match IS the saved face (dist ≈ 0), so we report detectionState: 'matched' unconditionally.
Parameters
saved2d(Object)
Returns
object
buildMediapipeSaveSection(saved3d: Object, id: number): object
Build the mediapipe section for a save action.
Parameters
saved3d(Object)id(number)
Returns
object
Static Methods
setBusy(isBusy: boolean)
Sets the busy flag for the whole UI, disabling/enabling controls during asynchronous operations.
Parameters
isBusy(boolean) — When true, UI controls are disabled to prevent concurrent actions.
- See:
- init – called during startup to manage UI state while models load.
- loadModels – UI is set busy while models are loading.
- saveFace – save actions hold the UI busy while both engines persist data.
- openAnalyzePanel – analysis actions use the same guard against concurrent work.
computeOverall(
faceapiSection: object | null,
mediapipeSection: object | null,
): 'matched' | 'eluded' | 'partial-elusion' | 'unknown'
Compute the overall field of a matchStateChanged payload.
Parameters
faceapiSection(object | null)mediapipeSection(object | null)
Returns
'matched' | 'eluded' | 'partial-elusion' | 'unknown'
init()
Initializes the application: loads the database, renders statistics, sets up the canvas, registers UI event listeners, loads models, ghostyle plugins, and starts the webcam. In production this is the module entry point; Vitest skips the automatic call so individual helpers can be isolated.
Fires
window#gstmxxReady after models, plugins,event: and the camera are ready.
- See:
- loadModels – called within init to load face-api.js models before webcam activation.