<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k" -->

---
title: Real-time Face Detection at 30 FPS on CPU using...
description: A beginner-friendly step-by-step guide to building a real-time face detection system running at 30 FPS on CPU using MediaPipe and Python. Covers environment...
canonical: https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Real-time Face Detection at 30 FPS on CPU using Mediapipe in Python: A Step-by-Step Guide. | daily.dev
og:description: A beginner-friendly step-by-step guide to building a real-time face detection system running at 30 FPS on CPU using MediaPipe and Python. Covers environment...
og:url: https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k
og:image: https://api.daily.dev/og/posts/Hwd9gsy0K.png
og:image:alt: Real-time Face Detection at 30 FPS on CPU using Mediapipe in Python: A Step-by-Step Guide.
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Real-time Face Detection at 30 FPS on CPU using Mediapipe in Python: A Step-by-Step Guide.

**[Towards Dev](https://daily.dev/sources/towardsdev)** · 9 min read · 2 upvotes · 0 comments

## Summary

A beginner-friendly step-by-step guide to building a real-time face detection system running at 30 FPS on CPU using MediaPipe and Python. Covers environment setup, webcam capture with OpenCV, configuring the MediaPipe FaceDetection model, extracting bounding box and landmark data, converting normalized coordinates to pixel coordinates, and drawing results on frames. Complete source code is provided.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://towardsdev.com/detecting-face-at-30-fps-on-cpu-on-mediapipe-python-dda264e26f20>

## Questions this post answers

### How do I set up MediaPipe FaceDetection to run in real time on a webcam using Python and OpenCV?

Capture frames with OpenCV's VideoCapture, convert each frame from BGR to RGB with cv.cvtColor, then pass it to mp.solutions.face_detection.FaceDetection configured with model_selection and min_detection_confidence parameters. Calling face_detector.process(rgb_frame) returns detections containing bounding boxes and six facial keypoints, which can be scaled to pixel coordinates and drawn with OpenCV, achieving around 30 FPS on CPU.

_Developers building lightweight vision prototypes track practical MediaPipe and OpenCV walkthroughs like this on daily.dev._

### What do the model_selection and min_detection_confidence parameters control in MediaPipe's FaceDetection?

model_selection chooses between two pretrained face detection models: one faster but less accurate, another slower but more reliable, with little practical difference on higher-end hardware. min_detection_confidence sets the minimum confidence threshold, expressed as a value between 0 and 1, that a detection must meet before being returned; setting it to 0.5 means only detections the model is at least 50% confident about are returned.

_Anyone tuning face detection accuracy versus speed can compare configuration approaches like this on daily.dev._

## Similar posts on daily.dev

- [Building a Real-Time 3D Face Mask with MediaPipe, Threlte and Three.js](https://daily.dev/posts/building-a-real-time-3d-face-mask-with-mediapipe-threlte-and-three-js-pk2vu7lh9) · Codrops · 1 upvotes · 0 comments
- [Face Recognition on One CPU Core: I Tested 28 Video Pipelines and the Biggest Model Didn’t Always Win](https://daily.dev/posts/face-recognition-on-one-cpu-core-i-tested-28-video-pipelines-and-the-biggest-model-didn-t-always-wi-zy7zdtdkx) · Medium · 0 upvotes · 0 comments
- [Traditional Face Detection With Python Quiz – Real Python](https://daily.dev/posts/traditional-face-detection-with-python-quiz-real-python-sbzuvig8k) · Real Python · 0 upvotes · 0 comments
- [The Beginner’s Guide to Computer Vision with Python](https://daily.dev/posts/the-beginner-s-guide-to-computer-vision-with-python-eporx2ra6) · Machine Learning Mastery · 2 upvotes · 0 comments
- [I Ditched My Mouse: How I Control My Computer With Hand Gestures \(In 60 Lines of Python\)](https://daily.dev/posts/i-ditched-my-mouse-how-i-control-my-computer-with-hand-gestures-in-60-lines-of-python--kbg4g2jli) · Towards Data Science · 1 upvotes · 0 comments

---

Tags: [#python](https://daily.dev/tags/python), [#computer-vision](https://daily.dev/tags/computer-vision), [#opencv](https://daily.dev/tags/opencv)

[View this post on daily.dev](https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Real-time Face Detection at 30 FPS on CPU using Mediapipe in Python: A Step-by-Step Guide.","url":"https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k"},"datePublished":"2026-07-29T07:16:57.775Z","dateModified":"2026-09-13T18:41:34.773Z","description":"A beginner-friendly step-by-step guide to building a real-time face detection system running at 30 FPS on CPU using MediaPipe and Python. Covers environment...","image":"https://miro.medium.com/v2/da:true/resize:fit:1152/1*x1VOQSktxIeffn_MPGjkmQ.gif","thumbnailUrl":"https://miro.medium.com/v2/da:true/resize:fit:1152/1*x1VOQSktxIeffn_MPGjkmQ.gif","isAccessibleForFree":true,"articleSection":"Towards Dev","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Towards Dev","logo":"https://media.daily.dev/image/upload/t_logo,f_auto/v1/logos/2c710db2750a4a70835862534cb7c9d4","url":"https://daily.dev/sources/towardsdev"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":2},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"python,computer-vision,opencv","timeRequired":"PT9M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Towards Dev","item":"https://daily.dev/sources/towardsdev"},{"@type":"ListItem","position":3,"name":"Real-time Face Detection at 30 FPS on CPU using Mediapipe in Python: A Step-by-Step Guide."}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/real-time-face-detection-at-30-fps-on-cpu-using-mediapipe-in-python-a-step-by-step-guide--hwd9gsy0k#faq","mainEntity":[{"@type":"Question","name":"How do I set up MediaPipe FaceDetection to run in real time on a webcam using Python and OpenCV?","acceptedAnswer":{"@type":"Answer","text":"Capture frames with OpenCV's VideoCapture, convert each frame from BGR to RGB with cv.cvtColor, then pass it to mp.solutions.face_detection.FaceDetection configured with model_selection and min_detection_confidence parameters. Calling face_detector.process(rgb_frame) returns detections containing bounding boxes and six facial keypoints, which can be scaled to pixel coordinates and drawn with OpenCV, achieving around 30 FPS on CPU. Developers building lightweight vision prototypes track practical MediaPipe and OpenCV walkthroughs like this on daily.dev."}},{"@type":"Question","name":"What do the model_selection and min_detection_confidence parameters control in MediaPipe's FaceDetection?","acceptedAnswer":{"@type":"Answer","text":"model_selection chooses between two pretrained face detection models: one faster but less accurate, another slower but more reliable, with little practical difference on higher-end hardware. min_detection_confidence sets the minimum confidence threshold, expressed as a value between 0 and 1, that a detection must meet before being returned; setting it to 0.5 means only detections the model is at least 50% confident about are returned. Anyone tuning face detection accuracy versus speed can compare configuration approaches like this on daily.dev."}}]}
```

