Search faces (1:N)
Identify an anonymous face against the enrolled corpus.
Prerequisites
- An initialised
SladeIDinstance and a<video>element. - A populated face corpus on the backend. Empty corpora always return no candidates.
- Confirmed compliance posture for 1:N biometric search in your jurisdiction. See Enroll vs verify vs identify.
Full example
import { SladeID } 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.createFaceSession(video, { requireLiveness: true });
session.on('captured', async ({ result }) => {
const search = await sdk.searchFace(result, { topK: 5 });
if (!search.matched) {
console.log('no candidate within threshold');
return;
}
for (const c of search.candidates) {
console.log(`${c.enrollee} (distance ${c.distance.toFixed(3)})`);
}
});
await session.start();candidates are sorted closest-first. matched is true if and only if the top-1 distance is under the server-side threshold.
What can go wrong
matched: false— no candidate cleared the threshold. This is a normal result, not an error.- Empty
candidates— the corpus has no enrollments, or the search query failed before scoring. ChecklogIdagainst the server logs.
Consider consent and data-protection law before deploying 1:N search. Unlike 1:1 verification, the user does not assert an identity in advance, and some jurisdictions require explicit opt-in.