Liveness detection basics: stopping a photo from unlocking a face check

Presenting Annapurna on stage
Presenting Annapurna on stage

Originally published at https://pranjulrathour.scult.in/blog/liveness-detection-anti-spoofing-basics. That copy is the canonical version and gets updates first.

A recognition model will happily match a printed photograph of you to your enrolled embedding. It was trained to recognise faces, not to notice paper. Liveness detection is the layer that asks "is there a live person here?" and FaceVision runs it in the browser alongside recognition.

Presenting to a room
Presenting to a room

Two families of liveness

  • Passive — a model looks at a single frame or a short clip for signs of a spoof: paper texture, screen moiré, unnatural depth cues. Frictionless for the user; only as good as its training data.
  • Active — the user is asked to do something: blink, turn their head, follow a dot. Cheap to implement with landmarks, hard to fool with a static photo, defeatable by a video replay unless the challenge is random.

Combine them

A passive check on every frame plus a randomised active challenge at enrolment and for high-value actions covers the common attacks: printed photos, phone screens, and pre-recorded videos. Neither alone does. Keep the challenge short — two actions — or users abandon the flow.

Doing it in the browser

Landmark tracking from the detector already gives you eye openness and head pose, so blink and turn challenges cost nothing extra. A small passive anti-spoofing model in ONNX runs in a worker alongside recognition. Frames stay on the device, which matters: liveness is where you would otherwise be streaming a user's face to a server continuously.

Requirements gathering and user flows, on stage
Requirements gathering and user flows, on stage

Measuring it honestly

  1. Collect real spoof attempts — photos on paper, on a phone, a video on a laptop — from several people and devices.
  2. Report the spoof acceptance rate and the live rejection rate separately. A system that rejects 20% of real users is not "secure", it is unusable.
  3. Re-test whenever you change cameras, lighting assumptions or the model.

Liveness is the part of a face project that shows a reviewer you thought about how it would be attacked. Recognition gets the demo; liveness gets the job.

From my carousels
5 Production AI Apps, All Open Source
5 Production AI Apps, All Open Source, slide 15 Production AI Apps, All Open Source, slide 2
5 Production AI Apps, All Open Source, slide 35 Production AI Apps, All Open Source, slide 4
Full carousel on Instagram and LinkedIn.
Pranjul Rathour
Pranjul Rathour
GenAI engineer, Kanpur · 3x first-prize hackathon winner · campus mentor
I ship production RAG pipelines, fine-tune LLMs and build agentic AI products end to end. I lead engineering at SCULT INDIA for a 14-member team and have mentored 200+ students through TechVerse Enclave.
Open to: GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges.
On stage, at hackathons and on campus
Presenting KrishGyan, farming advice in your voice and language
Presenting KrishGyan, farming advice in your voice and language
Taking questions during a session
Taking questions during a session
Pranjul Rathour
Pranjul Rathour

Comments

Popular posts from this blog

Forming a hackathon team: roles, skills and the mistake most teams make

Hello from Kanpur: what I build, and what I'll write about here

I built 15 free tools, 1,211 prompts and a 50,000-skill library — here's what's inside tools.scult.in