Overview

Automated face-tracking camera system built for DX Hackfest in April 2016. The system uses Windows IoT Core on Raspberry Pi to detect faces in real-time and automatically pan the camera using a stepper motor to keep the detected face centered in frame.

Architecture

Face Detection Pipeline

  • Windows.Media.FaceAnalysis API for real-time face detection
  • MediaCapture API for camera stream acquisition
  • SoftwareBitmap processing at 30 FPS
  • Yellow bounding box overlay on detected faces

Motor Control System

  • ULN2003Driver class for stepper motor control
  • GPIO pin management for 4-phase stepper motor
  • Support for three driving methods: wave drive, full-step, half-step
  • Asynchronous motor control to prevent UI blocking

Tracking Algorithm

  • Calculate face position relative to frame center
  • Compute required rotation angle based on offset
  • Send rotation command to stepper motor
  • Update tracking target after movement completes

Technical Implementation

Stepper Motor Control: Used 28BYJ-48 stepper motor with ULN2003 driver board. Implemented three stepping modes for different torque/precision tradeoffs. Wave drive provides smoothest rotation, full-step offers balanced performance, and half-step mode doubles resolution to 0.088° per step.

Face Detection Performance: Windows.Media.FaceAnalysis API provides hardware-accelerated detection on Raspberry Pi 3. Achieved 15-20 FPS processing rate with single-face tracking. Face detection runs on background thread to maintain smooth camera preview in UI.

GPIO Timing: Stepper motor requires precise timing between phase changes. Used Task.Delay() with calculated intervals based on stepping mode. Full rotation (360°) requires approximately 2048 full steps or 4096 half steps.

Tracking Latency: Total system latency from face detection to motor movement is ~300-500ms. Breakdown: face detection (50-70ms), angle calculation (5ms), motor movement (200-400ms depending on rotation distance).

Technical Challenges

Motor Backlash: 28BYJ-48 motors have mechanical backlash causing positioning errors. Implemented always-rotate-in-same-direction approach for repeated movements to maintain consistent positioning.

Power Supply Stability: Stepper motor current draw caused voltage drops affecting Raspberry Pi stability. Used separate 5V power supply for motor with common ground connection.

Face Detection Jitter: Minor variations in detected face position caused unnecessary micro-adjustments. Added threshold-based deadzone where motor doesn’t activate for small position changes (< 10° offset).

Results

Successfully demonstrated automated face tracking at DX Hackfest 2016. System reliably tracks single face with smooth camera movements. Stepper motor provides precise angular control allowing camera to maintain face in center ~80% of frame area. Works effectively within 1-3 meter range from camera.

Tech Stack

  • Platform: Windows 10 IoT Core, UWP (Universal Windows Platform)
  • Language: C#, XAML
  • Hardware: Raspberry Pi 2/3, 28BYJ-48 stepper motor, ULN2003 driver
  • APIs: Windows.Media.FaceAnalysis, Windows.Media.Capture, Windows.Devices.Gpio
  • Computer Vision: Windows Face Detection API

Source Code

GitHub: github.com/tanchunsiong/Stepper-Motor

Project Created: April 2016


Connect: