What is face detection? How it works, landmarks, liveness, MTCNN and Python

Face detection finds faces in images or video. How it works in AI and cameras, MTCNN, landmarks, liveness and mask detection, and detecting faces in Python.

On the mic
On the mic

Key takeaways

  • Face detection locates faces in an image and returns boxes; it does not identify who the person is.
  • Modern detectors are neural networks trained on many labelled faces; older systems used Haar features.
  • Landmark detection finds points such as eyes and mouth; liveness detection checks the face is real and present.
  • Cameras use face detection for focus, exposure and tracking, often on dedicated chips.
  • In Python, OpenCV and MediaPipe detect faces in a few lines; use consent and privacy safeguards.

Face detection is the computer vision task of finding where faces are in an image or video, usually returning a bounding box and confidence score for each face. It answers "is there a face, and where?", not "whose face is this?", which is face recognition. It is the first step for camera autofocus, filters, face recognition and liveness checks. I built browser-based detection, recognition and liveness in FaceVision, so this page covers how detection works, in AI and cameras, the main technologies including MTCNN, landmarks, liveness, mask detection and a Python example.

What is face detection?

Face detection is identifying the presence and location of human faces in images or video frames. A detector outputs, for each face, a box, a confidence score and sometimes a few key points such as eye centres.

It is different from related tasks: face recognition identifies or verifies a person by comparing faces; landmark detection finds detailed points on the face; and attribute analysis estimates things like expression. Detection comes first in all of them. It must handle different sizes, angles, lighting, skin tones, occlusions such as glasses or hands, and many faces at once, which is why modern detectors are trained on large, diverse datasets.

How does face detection work?

Modern face detection uses a neural network that scans an image at multiple scales and predicts, for many candidate regions, whether a face is present and the exact box around it. Overlapping predictions are merged with non-maximum suppression.

The network learns visual patterns of faces, from edges and textures to eyes and mouth arrangements, from thousands of labelled images. Lightweight architectures make it fast enough for phones and browsers. The output boxes are then used to crop faces for further steps. Quality depends on training data diversity: detectors trained on narrow datasets perform worse on under-represented groups, which is an important fairness consideration.

What is face detection in AI?

In AI, face detection is a computer vision task solved with machine learning, specifically deep learning object detection models trained to find faces. It is one of the most widely deployed applications of AI, in phones, cameras, social apps and security systems.

It belongs to the broader field of object detection, with face-specific models designed for speed and accuracy on faces. In AI pipelines, detection is often followed by alignment, which rotates and crops faces using landmarks, and then embedding models for recognition, or classifiers for emotion and attributes. Because it involves personal data, responsible use includes consent, minimal data retention and clear purpose.

What is face detection technology?

Face detection technology has evolved from hand-crafted methods to deep learning. The landmark early method, the Viola-Jones detector from 2001, used Haar-like features and a cascade of classifiers and made real-time detection possible on ordinary computers.

Since the 2010s, convolutional neural networks have replaced hand-crafted features, with detectors such as MTCNN, RetinaFace, BlazeFace and YOLO-based face models offering much better accuracy on difficult images. Today the technology runs on phone chips, in browsers with WebAssembly and WebGL, and on edge devices in cameras. Haar cascades are still used for simple, low-power tasks but fail on tilted faces and poor lighting.

What is face detection in a camera?

In cameras, face detection finds faces in the live view so the camera can focus on them, set exposure for skin tones, track people as they move, and sometimes trigger the shutter on smiles. Security cameras use it to flag frames with people.

Also asked as: what is face detection in camera

Phone cameras and many digital cameras run detection on dedicated image processors or neural engines, continuously and with very low delay. Modern cameras extend this to eye detection, keeping focus on the nearest eye for sharp portraits, and to body and animal detection. In CCTV systems, face detection can trigger recording or alerts, and some systems add recognition, which raises legal and privacy obligations depending on where it is used.

What is MTCNN face detection?

MTCNN, the Multi-task Cascaded Convolutional Network, is a face detector introduced in 2016 that uses three small neural networks in sequence to propose face regions, refine them and output final boxes with five facial landmarks: eyes, nose and mouth corners.

Its cascade design was efficient for its time and its landmarks made face alignment easy, so it became a popular first stage for face recognition systems. It is still easy to use through Python packages, but newer detectors, such as RetinaFace or MediaPipe's BlazeFace, are generally faster or more accurate today. MTCNN remains a good teaching example of cascaded detection.

What is face landmark detection?

Face landmark detection finds specific points on a face, such as eye corners, eyebrows, nose tip, lips and jawline. Simple models output five points; dense models output hundreds, enough to describe the face's 3D shape.

Landmarks are used to align faces before recognition, apply AR filters and makeup, track eye blinks and gaze, measure head pose, animate avatars from expressions, and support liveness checks. Google's MediaPipe Face Landmarker, for example, outputs 478 3D landmarks with expression scores. Accuracy drops with extreme angles, heavy occlusion and poor lighting, so test on conditions like your users'.

What is face liveness detection?

Face liveness detection checks that a real, live person is in front of the camera, not a printed photo, a screen replay, a mask or a deepfake. It protects face-based login and identity verification from spoofing.

Methods include active checks, asking users to blink, turn their head or smile, and passive checks, which analyse texture, depth, reflections and subtle motion in a single image or short clip. Stronger systems combine several signals and, where available, depth sensors. FaceVision runs detection, recognition and liveness in the browser with ONNX Runtime Web, and its server stores face embeddings only, never images, which reduces the damage if data leaks. Liveness is an arms race, so systems need regular testing against new attacks.

What is face mask detection?

Face mask detection is a classification task that detects faces and then decides whether each person is wearing a mask, and sometimes whether it is worn correctly over nose and mouth. It became common in 2020 for public health compliance.

A typical pipeline detects faces with a face detector, crops each face, and runs a small image classifier trained on masked and unmasked faces. Challenges include masks hiding features that detectors rely on, varied mask types, and angles. It is a popular student project because it combines detection and classification, uses public datasets, and runs in real time on a laptop webcam.

How do I make face detection in Python?

Use OpenCV or MediaPipe. OpenCV's deep learning face detector or MediaPipe's face detection find faces in a few lines; then draw boxes on the image or process each face further.

Also asked as: how to make face detection in python

# pip install mediapipe opencv-python  (download blaze_face_short_range.tflite from the MediaPipe guide)
import cv2, mediapipe as mp
from mediapipe.tasks.python import vision, BaseOptions

det = vision.FaceDetector.create_from_options(
    vision.FaceDetectorOptions(base_options=BaseOptions(model_asset_path="blaze_face_short_range.tflite")))
img = cv2.imread("group.jpg")
res = det.detect(mp.Image(image_format=mp.ImageFormat.SRGB, data=cv2.cvtColor(img, cv2.COLOR_BGR2RGB)))
for d in res.detections:
    b = d.bounding_box
    cv2.rectangle(img, (b.origin_x, b.origin_y), (b.origin_x + b.width, b.origin_y + b.height), (0, 255, 0), 2)
cv2.imwrite("faces.jpg", img)

Get consent before processing people's images, and avoid storing faces you do not need.

Sources

  1. Viola & Jones, Rapid Object Detection using a Boosted Cascade of Simple Features (2001)cs.cmu.edu
  2. Zhang et al., Joint Face Detection and Alignment using Multi-task Cascaded Convolutional Networks (2016)arxiv.org
  3. Bazarevsky et al., BlazeFace: Sub-millisecond Neural Face Detection on Mobile GPUs (2019)arxiv.org
  4. Google AI Edge, MediaPipe Solutions guideai.google.dev
  5. OpenCV, documentationdocs.opencv.org
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way. Email pranjulrathour41@gmail.com.

Keep reading

More on Vision, speech & OCR

All Vision, speech & OCR guides →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. For campus sessions the inviting institution covers the visit end to end: travel (a First AC train ticket for journeys up to five hours, a flight for anything longer), accommodation, meals, and pickup and drop; the honorarium and workshop fees are negotiable on WhatsApp or on the call, and requests are welcome from institutions that can cover the visit this way.

Pranjul Rathour, GenAI engineer in India