Skip to content

Quickstart

Get face recognition working in your app in under 5 minutes.

  1. Start the server

    Terminal window
    git clone https://github.com/drinkredwine/openbiometrics
    cd openbiometrics/engine && pip install -e . && python download_models.py
    cd ../api && uvicorn app.main:app --port 8000

    API docs at http://localhost:8000/docs (Swagger UI).

  2. Install the SDK

    Terminal window
    npm install openbiometrics
  3. Detect your first face

    import { OpenBiometrics } from 'openbiometrics';
    import { readFileSync } from 'fs';
    const ob = new OpenBiometrics({
    apiKey: 'any-value',
    baseUrl: 'http://localhost:8000',
    });
    const photo = readFileSync('photo.jpg');
    const result = await ob.faces.detect(photo);
    for (const face of result.faces) {
    console.log(`Age: ${face.demographics?.age}`);
    console.log(`Quality: ${face.quality?.overall_score.toFixed(0)}/100`);
    }
  4. Verify two faces

    const id_photo = readFileSync('id_card.jpg');
    const selfie = readFileSync('selfie.jpg');
    const { is_match, similarity } = await ob.faces.verify(id_photo, selfie);
    console.log(is_match ? 'Identity confirmed' : 'Mismatch');
  5. Build a watchlist

    await ob.watchlists.enroll(photo1, { label: 'Alice' });
    await ob.watchlists.enroll(photo2, { label: 'Bob' });
    const { matches } = await ob.watchlists.identify(unknownPhoto);
    for (const match of matches) {
    console.log(`${match.label}: ${(match.similarity * 100).toFixed(1)}%`);
    }