MediaPipe tutorial: face detection data on Raspberry Pi 5

Learn to extract MediaPipe face boxes and six key points, convert relative coordinates to pixels, and draw custom OpenCV overlays on Raspberry Pi 5.

Player not loading? Watch on YouTube

Paul McWhorter's lesson 39 explains how to inspect MediaPipe face detection results in Python on Raspberry Pi 5. The lesson uses the class-specific Raspberry Pi Bookworm image linked in the description, with libraries and drivers already installed. It builds on the previous lesson's face detector and replaces MediaPipe's drawing helper with custom OpenCV overlays. The focus is accessing detection data for local AI projects that need face positions rather than just a displayed box.

The walkthrough starts by printing results, then results.detections. In the demonstration, detections returns None when no face is visible. McWhorter works through the nested structure to reach detection.location_data.relative_bounding_box and extract xmin, ymin, width and height. He converts these relative values to integer pixel coordinates using the full frame's width and height, then draws a yellow rectangle. The debugging includes correcting a copy-and-paste error in the coordinate scaling.

He next accesses relative_keypoints, iterates through six points, and draws filled blue circles with a radius of 15 pixels. These coordinates also use the full frame dimensions, not the bounding box dimensions.

With a different camera, McWhorter reports about 49 frames per second at 1280 × 720 and about 30 at 1920 × 1080. Those figures describe his demonstrated setup. The homework asks viewers to adapt an earlier Haar cascade face-tracking project to MediaPipe and add a face-obscuring effect.