Skip to Content
GuidesCapture a fingerprint

Capture a fingerprint

Capture one or more fingerprints with the contactless flow.

Prerequisites

  • An initialised SladeID instance.
  • A <video> element. The default facingMode: 'auto' opens the rear camera and falls back to the front camera on devices that have no rear. Pass a specific cameraDeviceId (from CameraManager.enumerateCameras()) when you want the user to pick — see Handle multiple cameras.

Steps

  1. Build a step script — use FingerprintSteps.rightHand() for slap-plus-thumb, or pass a custom array.
  2. Create a FingerprintCaptureSession.
  3. Wire 'step_change', 'guidance', and 'completed'.
  4. Call start().

Full example

import { SladeID, FingerprintSteps, type CapturedFingerprint, } from '@sladeid/slade-id-sdk'; const sdk = new SladeID({ middlewareUrl: 'https://id.example.com', clientSecret: '<ClientSecret>', }); const video = document.querySelector<HTMLVideoElement>('#camera')!; const session = sdk.createFingerprintSession(video, { captureSteps: FingerprintSteps.rightHand(), qualityThreshold: 40, qualityPolicy: 'all', }); const captures: CapturedFingerprint[] = []; session.on('step_change', ({ index, step }) => { console.log(`step ${index + 1}: ${step.label}`); }); session.on('captured', (fp) => { captures.push(fp); }); session.on('completed', async () => { const result = await sdk.enrollFingerprint('subject-123', { fingers: captures.flatMap((c) => c.perFinger.map((pf) => ({ position: pf.position, imageBase64: c.imageBase64, nfiq2Score: pf.nfiq2Score, retryCount: 0, })) ), deviceInfo: captures[0].deviceInfo, }); console.log('enrolled', result); }); await session.start();

qualityPolicy: 'all' requires every finger in a slap to clear qualityThreshold. Use 'any' for 1:1 verification where one clean print is enough.

Handle multiple cameras

When a device has more than one camera (an external USB webcam, a virtual camera, an iPad with rear + LiDAR cameras), facingMode: 'auto' may not pick the one your user wants. Enumerate cameras with CameraManager.enumerateCameras() and pass the chosen deviceId via cameraDeviceId. It takes precedence over facingMode — the session opens that camera and does not fall back on failure.

import { CameraManager, SladeID, FingerprintSteps } from '@sladeid/slade-id-sdk'; const cameras = await new CameraManager().enumerateCameras(); // Render `cameras` in a <select> and capture the user's pick as `deviceId`. const session = sdk.createFingerprintSession(video, { captureSteps: FingerprintSteps.rightHand(), cameraDeviceId: deviceId, });

The browser only exposes stable deviceId values after the user has granted camera permission at least once on the origin. Call enumerateCameras() again after the session emits 'started' to refresh labels.

What can go wrong

  • 'degraded' event fires — the SDK could not load its full quality-scoring stack and fell back to a coarser scorer. Captures still succeed; scores are less precise. If this persists in production, contact your Slade ID integration contact.
  • Capture loops endlessly in 'detecting' — the user is too close or too far. The default proximity range is 0.75–1.35 for slap captures and 0.41–2.03 for single-finger. See Tune capture quality to widen.
  • QualityError with code QUALITY_GATE_FAILED — too many retries. Relax qualityThreshold, improve lighting, or switch to qualityPolicy: 'any'.

See also