Layer 3 — Embedded & Firmware

Wireless Identity Recognition System

Real-time face recognition and 9-class gesture classification. Dual-threaded Python client streams predictions to an ESP32 server over TCP/Wi-Fi.

ESP32Embedded Server
9 gesturesMediaPipe Classes
TCPTransport Protocol
2 threadsPython Client
Wi-FiCommunication Link

Open source · Python / C (ESP32)

github.com/muhammadzareii/iot_fun-main

Overview

The Wireless Identity Recognition System is an edge-IoT project that combines computer vision running on a host machine with an ESP32 microcontroller acting as the network server and actuator dispatcher. The Python client runs two concurrent inference threads — one for face recognition, one for hand gesture classification — and streams results over a TCP socket to the ESP32, which can trigger outputs (relays, displays, actuators) based on the identity and gesture commands received.

The system demonstrates the practical integration layer between a high-compute host (laptop/SBC) and a low-power embedded node: the host does the perception, the embedded node does the action. This is a common pattern in smart building, access control, and human-machine interface systems.

System Architecture

System Architecture Host Machine (Python) Camera OpenCV capture Thread 1: Face Recognition face_recognition library 128-D face encoding → name Thread 2: Gesture MediaPipe Hands 21-landmark → 9 classes Thread-safe result queue Python queue.Queue — latest (identity, gesture) pair TCP Wi-Fi JSON payload ESP32 Server TCP socket listener Parse (identity, gesture) → GPIO / relay / UART output → Display / actuator command Wi-Fi STA mode / AP mode
Fig. 1. System flow: camera feeds both recognition threads simultaneously; results merge in a thread-safe queue; TCP sender dispatches latest result to ESP32 server every ~100 ms.

Face Recognition Module

Face recognition uses the face_recognition Python library, which wraps a pre-trained deep convolutional network (dlib's ResNet-based model) to produce 128-dimensional face encodings. Enrolled faces are stored as a set of reference encodings; at runtime, the encoding of each detected face in the camera frame is compared to all references using Euclidean distance. A distance threshold (typically 0.6) determines match/no-match.

The library handles face detection (HOG-based or CNN), face alignment (landmark-based warping), and encoding in a single pipeline. On a modern CPU this runs at 2–5 FPS for a 720p frame with one face; the thread decouples this from the main application loop, preventing UI lockup.

Gesture Recognition Module

Hand gesture classification uses MediaPipe Hands, which provides 21 3D hand landmarks (wrist + 4 joints per finger) in real time from a single camera. The 21 landmarks (63 coordinates: x, y, z for each) are normalised relative to the wrist position and wrist-to-middle-finger distance, then fed to a classifier.

#Gesture ClassLandmark Signature
0Open palmAll fingers extended, spread
1FistAll fingers curled
2Point (1 finger)Index extended, others curled
3Peace / V signIndex + middle extended
4Three fingersIndex + middle + ring extended
5Four fingersAll except thumb extended
6Thumb upThumb extended, others curled
7Thumb downThumb down, others curled
8OK signThumb + index touching, others extended

ESP32 Server

The ESP32 firmware (C, Arduino framework) runs a TCP server socket. On receiving a JSON payload {"id": "Muhammad", "gesture": "thumb_up"}, it parses the fields and dispatches the appropriate action: toggling a GPIO for relay control, writing to a serial UART for downstream device control, or updating an I²C OLED display with the identity string.

The ESP32 operates in station mode (connects to the existing Wi-Fi network) or access point mode (hosts its own network for direct laptop connection). Connection loss is handled by the client-side reconnect loop with exponential backoff.

System Photos

Face recognition output
Fig. 2. Live face recognition output: bounding box with name label overlaid. The recognition thread runs at 2–5 FPS independent of the main camera loop.
Gesture recognition output
Fig. 3. Hand landmark overlay from MediaPipe Hands. All 21 landmarks are tracked in 3D; the resulting coordinate set is classified into one of 9 gesture classes.