ΛRCHIXROBOTICS // SYSTEM CAPABILITIES
--:--:--
Command Center
ARCHIXROBOTICS INNOVATION 2026 // TECHNICAL DOSSIER REV 2.1

Smart Mood Tracker
& Lie Detector Architecture

A full-stack, AI-integrated biometric health and security monitoring system engineered by SMK Dato' Penggawa Timur students.

Python Flask HTML/CSS/JS Raspberry Pi 5 Local AI
Training Dataset
40,986
Facial expression samples for Random Forest classifier
Sensor Rate
100Hz
Non-blocking MAX30102 I2C daemon polling
Keyboard Navigation

Press keys 1–11 anytime to jump directly to any engineering module.

01 // SYSTEM CAPABILITIES

System Capabilities

Advanced biometric tracking and data analysis seamlessly integrated.

Real-Time Pulse

Live BPM tracking using the MAX30102 sensor connected via I2C on the Raspberry Pi 5 for high-accuracy readings.

Live AI Camera Feed

MJPEG streaming with complex visual AI overlay for face mapping and hand tracking to analyze physical stress.

Deception Detection

Multi-factor lie detection algorithm integrating pulse spikes, facial visual stress, and hand positioning logic.

42-Question Assessment

Engaging emoji-based behavioral and emotional evaluation with automated timer and grading systems.

Data Dashboard

Comprehensive dashboard to view all submissions, sensor history, and access full video replays of sessions.

Secure Access

Multi-Auth login supporting Email, Google, GitHub, and Facebook OAuth alongside 2FA verification.

02 // DUAL-SERVER TOPOLOGY

System Architecture

A dual-server architecture operating over a local network.

graph TB subgraph "Main Server (Laptop - Port 5000)" A["app.py - Flask Backend"] --> B["Authentication System"] A --> C["AI Chat (Local AI)"] A --> D["Data Storage (JSON)"] A --> E["Email Service (SMTP)"] A --> F["Proxy to Raspberry Pi"] end subgraph "Biometric Server (Raspberry Pi 5 - Port 5001)" G["live_detector.py"] --> H["MAX30102 Sensor (I2C)"] G --> I["Pi Camera Module 3"] G --> J["Deception Algorithm"] G --> K["Video Recording"] end subgraph "Frontend (Browser)" L["index.html - Home Page"] M["test.html - Assessment"] N["live.html - Live Monitor"] O["data_dashboard.html"] end L -->|"HTTP API"| A M -->|"Submit Test"| A N -->|"Live Data"| F F -->|"Wi-Fi"| G O -->|"Fetch History"| A
03 // MEDIA PIPELINE

Media Streaming & Recording Pipeline

How live video and two-way voice are captured, delivered, and displayed.

flowchart TD subgraph "Hardware Capture (Raspberry Pi)" CAM["Pi Camera Module 3"] MIC["USB Microphone"] SPK["USB Speaker"] end subgraph "Backend Processing" REC["FFmpeg Video Recorder (.mp4)"] STREAM["Flask Video Stream (/video_feed)"] AUDIO["Two-Way Audio Server"] DATA["Biometric JSON Stream"] end subgraph "Live Monitor Dashboard" VID_DISP["Live Video Feed"] AUDIO_UI["Voice Controls (Push to Talk)"] BIO_UI["BPM & Deception Overlay"] end CAM -->|"Raw Frames"| REC CAM -->|"MJPEG Frames"| STREAM MIC -->|"Student Voice"| AUDIO AUDIO -->|"Teacher Voice"| SPK STREAM -->|"Live Stream"| VID_DISP DATA -->|"Sync Data"| BIO_UI AUDIO_UI -->|"Teacher Audio"| AUDIO AUDIO -->|"Student Audio"| AUDIO_UI

1. FFmpeg Pipeline

FFmpeg acts as the multimedia engine in our pipeline for capturing live streams, extracting audio tracks, and transcoding recorded sessions into compressed .mp4 archives.

2. OpenH264 Codec

openh264-1.8.0-win64.dll bridges OpenCV H.264 licensing gaps so webcam recordings encode efficiently into standard MP4 files locally with zero external server dependency.

04 // SENSOR FUSION

Behavioral Analysis Algorithm

60/40 Stress Fusion & 50/50 Physical + Random Forest Deception Scoring.

1. Stress Score Calculation

  • Pulse Stress (40% Weight): Raw BPM from MAX30102 minus 60 BPM baseline, scaled to 100% (140 BPM max).
  • Visual Stress (60% Weight): Camera facial tension metrics (rigid jaw, tight eyebrows).
flowchart LR S_ML["Visual Stress (60%)"] --> S_T{"Weighted Avg"} S_P["Pulse Stress (40%)"] --> S_T S_T -->|"< 30%"| S_L["LOW STRESS"] S_T -->|"30% - 70%"| S_M["MODERATE"] S_T -->|"> 70%"| S_H["HIGH STRESS"]

2. Deception Score Calculation

  • Heart Rate & Spikes: BPM > 115 (+40), BPM > 95 (+20), or +20% sudden jump (+40).
  • Hand Kinesics: Covering mouth (+50), touching face (+30).
  • ML Fusion: (Physical Score × 0.5) + (ML Score × 0.5).
flowchart TD D_P["Pulse Spikes"] --> D_Phys["Physical Score"] D_K["Hand Kinesics"] --> D_Phys D_Phys --> D_Fuse{"50/50 Fusion"} D_ML["Random Forest ML"] --> D_Fuse D_Fuse -->|">= 80%"| D_H["HIGH RISK"] D_Fuse -->|"50% - 79%"| D_M["MEDIUM RISK"] D_Fuse -->|"< 50%"| D_L["CLEAR"]
05 // PROBLEM SOLVING

Key Engineering Challenges & Solutions

1. Sensor Movement Noise Fix (Rolling-Average Filter)

Solution: 4-second rolling-average filter in Python to smooth microscopic finger wiggles before BPM computation.

if len(IR_HISTORY) > 5:
    avg = sum([v for t, v in IR_HISTORY]) / len(IR_HISTORY)
    if ir < avg * 0.998 and (avg - ir) > 50 and nav_t - LAST_BEAT_TIME > 0.40:
        delta = nav_t - LAST_BEAT_TIME
        new_bpm = 60.0 / delta
live_detector.py (L365-L379)

2. Real-Time Data Synchronization Script

Solution: Custom UTC-timestamped synchronization payload fusing camera visual stress and MAX30102 pulse readings.

payload = {
    "bpm": bpm,
    "stress": stress_status,
    "deception_score": final_score,
    "visual_stress": VISUAL_STRESS
}
history.append({"ts": datetime.utcnow().isoformat() + "Z", **payload})
live_detector.py (L486-L505)

3. Preventing Overfitting via Normalization

Solution: Dynamic personal baseline normalization using the user's last 10 readings, flagging only +20% relative spikes.

if len(history) > 10:
    past_bpms = [h['bpm'] for h in history[-10:] if isinstance(h.get('bpm'), int)]
    if past_bpms and bpm > (sum(past_bpms) / len(past_bpms)) * 1.20:
        deception_score += 30
live_detector.py (get_sensor_data)
06 // CODE ARCHITECTURE DEFENSE

Defending Our Code

Hand-engineered I2C bit-shifting, daemon threading, MJPEG generators, and WSGI-safe polling.

Custom I2C Bit-Shifting (MAX30102)

data = self.bus.read_i2c_block_data(self.address, 0x07, 6)
red = ((data[0] << 16) | (data[1] << 8) | data[2]) & 0x03FFFF
ir  = ((data[3] << 16) | (data[4] << 8) | data[5]) & 0x03FFFF
max30102.py (L41-L51)

Non-Blocking 100Hz Daemon Thread

sensor_thread = threading.Thread(target=sensor_loop, daemon=True)
sensor_thread.start()
# Samples I2C at 100Hz without blocking Flask
live_detector.py (L350-L360)

Custom MJPEG Multipart Generator

ret, buffer = cv2.imencode('.jpg', frame)
yield (b'--frame\r\nContent-Type: image/jpeg\r\n\r\n'
       + buffer.tobytes() + b'\r\n')
app.py (Streaming Route)

Thread-Safe JSON Lock & Validation

with db_lock:
    if len(answers) != 40:
        return jsonify({"error": "Incomplete"}), 400
database.py & app.py
07 // HARDWARE

MAX30102 Sensor Report

Measures heart rate and blood oxygen via Photoplethysmography (PPG) using Red and Infrared LEDs to capture pulsing blood volume changes in capillaries.

Official MAX30102 Docs
08 // CONTROL CENTER

The Live Monitor Dashboard

  1. AI Input Optimization: Live AI processes only video + pulse to stay lag-free on Raspberry Pi 5.
  2. Baseline Calibration: Control questions establish resting heart rate & facial baseline.
  3. Real-Time Inference: Displays live camera, rolling BPM graph, and instant Truth/Deception status.
09 // CLINICAL SCORING

Psychological Analysis (DASS-42)

Clinically validated 42-item assessment for Depression, Anxiety, and Stress (0–3 severity scale).

DASS-42 SEVERITY CUTOFFS

Clinical Source
Severity LevelDepression (0–42)Anxiety (0–42)Stress (0–42)
Normal0 – 90 – 70 – 14
Mild10 – 138 – 915 – 18
Moderate14 – 2010 – 1419 – 25
Severe21 – 2715 – 1926 – 33
Extremely Severe28+20+34+

🔴 Critical

Any scale reaches Severe or Extremely Severe.

🟡 Warning

Highest scale reaches Moderate.

🟢 Stable

Highest scale reaches Mild.

🌟 Excellent

All three scales are Normal.

10 // AI ENGINE

Machine Learning AI Engine

Custom-trained Random Forest Classifier built on 40,986 facial expression samples.

40,986 Data Points

Trained on Real-Life Deception Detection & FER-2013 Kaggle datasets to recognize subtle micro-expressions.

Core ML Stack

Scikit-Learn Random Forest, Google MediaPipe (468 3D facial landmarks), Pandas, and OpenCV.

Training Output

> IMAGES PROCESSED: 40,986
> TRAINING RANDOM FOREST...
> MODEL READY FOR INFERENCE.
11 // FULL BREAKDOWN

Project Deep Dive

1. Mediapipe Visual Stress Detection

Continuously maps micro-expressions via Face Mesh, analyzing facial rigidity and spontaneous cues to compute real-time Visual Stress.

Face Mapping

2. Mediapipe Hand Tracking

Maps palm and digit coordinates so facial-touching or mouth-covering gestures dynamically elevate the deception risk profile.

Hand Tracking

3. MAX30102 Pulse Integration

Interfaced with Raspberry Pi 5 via I2C using PPG to capture pulse data and trigger alerts on >20% baseline deviations.

Pulse Graph

4. Tri-Factor Deception Algorithm

Fuses cardiovascular anomalies, facial stress markers, and defensive hand gestures into a real-time 0–100 risk score.

Algorithm Math

5. School-Wide Analytics & Multi-Auth

Supports Google/GitHub/Facebook OAuth + 2FA OTP, local LLM copilot, FFmpeg MP4 replay, and 35 class-specific counselor dashboards.

Dashboard Analytics