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

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.

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.

Measuring it honestly
- Collect real spoof attempts — photos on paper, on a phone, a video on a laptop — from several people and devices.
- 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.
- 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.
![]() | 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. Email: pranjulrathour41@gmail.com |
![]() Presenting KrishGyan, farming advice in your voice and language | ![]() Taking questions during a session | ![]() Pranjul Rathour |








Comments
Post a Comment