<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Debasis Panigrahi</title>
    <description>The latest articles on DEV Community by Debasis Panigrahi (@debasis_panigrahi_).</description>
    <link>https://dev.to/debasis_panigrahi_</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4092251%2F291e6e2d-7373-44d7-9ae5-7b034b7d76fd.jpg</url>
      <title>DEV Community: Debasis Panigrahi</title>
      <link>https://dev.to/debasis_panigrahi_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/debasis_panigrahi_"/>
    <language>en</language>
    <item>
      <title>Building a Real-Time Edge AI Driver Attention &amp; Safety Monitoring System</title>
      <dc:creator>Debasis Panigrahi</dc:creator>
      <pubDate>Mon, 24 Aug 2026 11:51:57 +0000</pubDate>
      <link>https://dev.to/debasis_panigrahi_/building-a-real-time-edge-ai-driver-attention-safety-monitoring-system-2in3</link>
      <guid>https://dev.to/debasis_panigrahi_/building-a-real-time-edge-ai-driver-attention-safety-monitoring-system-2in3</guid>
      <description>&lt;p&gt;OverviewDrowsy and distracted driving remains one of the primary contributors to vehicle accidents globally. Traditional edge systems often struggle with false positives—sounding alarms when a vehicle is safely parked, misreading passengers, or failing under harsh nighttime glare and low-light cabin environments.  To solve this, I engineered an edge-first Driver Drowsiness &amp;amp; Attention Monitoring System using Python, MediaPipe, OpenCV, and PyQt6, built with a 3-thread decoupled architecture, low-light adaptive CLAHE, 3D head pose tracking, and vehicle motion gating.  Key Architectural HighlightsAdaptive Low-Light Preprocessing: When ambient cabin illumination drops ($L &amp;lt; 65.0$), the pipeline applies CLAHE across the LAB color space with Gamma correction ($\gamma = 0.6$) and glare suppression to maintain eyelid landmark tracking at night without false closures.  Multi-Signal Attention Classification: Combines Eye Aspect Ratio (EAR), Mouth Aspect Ratio (MAR), and solvePnP 3D Head Pose Estimation (Pitch, Yaw, Roll) to penalize micro-sleeps, yawning escalations ($\ge 3$ yawns in a 5-minute rolling window), and head drooping.  Cabin Multi-Face ROI Isolation: Evaluates up to 4 concurrent faces in the camera frame and gates alerting solely to the primary driver's Region of Interest (ROI), preventing sleeping passengers from triggering alerts.  Optical Flow Vehicle Motion Gating: Peripheral frame differencing evaluates vehicle movement so audible buzzer alarms sound only while in motion, automatically muting when parked or stationary.  Dual-Tier Dismissal &amp;amp; Remote Web Access: Incorporates a local cognitive math verification puzzle alongside a remote Flask admin web panel accessible via local Wi-Fi or mobile hotspot QR codes.  System Pipeline &amp;amp; Core Implementation[Camera Feed / USB] &lt;br&gt;
       │&lt;br&gt;
       ▼&lt;br&gt;
[Thread 1: DirectShow Frame Ingestion]&lt;br&gt;
       │&lt;br&gt;
       ▼&lt;br&gt;
[Thread 2: Computer Vision Pipeline]&lt;br&gt;
  ├── Low-Light CLAHE &amp;amp; Glare Reduction&lt;br&gt;
  ├── MediaPipe FaceMesh (Driver ROI Isolation)&lt;br&gt;
  ├── EAR / MAR / solvePnP Euler Pose Derivation&lt;br&gt;
  ├── Background Optical Flow Motion Detection&lt;br&gt;
  └── Multi-Signal State Machine Classifier&lt;br&gt;
       │&lt;br&gt;
       ▼&lt;br&gt;
[Thread 3: Main PyQt6 UI + Background Flask Daemon]&lt;br&gt;
  ├── Real-time HUD Visualizer &amp;amp; Cognitive Puzzle Modal&lt;br&gt;
  └── Remote LAN/Hotspot Admin Panel (PIN Override &amp;amp; Metrics)&lt;br&gt;
Feature Extraction Code SnippetPythonimport numpy as np&lt;/p&gt;

&lt;p&gt;def calculate_ear(eye_landmarks: np.ndarray) -&amp;gt; float:&lt;br&gt;
    """Computes Eye Aspect Ratio (EAR) from 6 canonical 2D eye landmarks."""&lt;br&gt;
    # Vertical landmark Euclidean distances&lt;br&gt;
    a = np.linalg.norm(eye_landmarks[1] - eye_landmarks[5])&lt;br&gt;
    b = np.linalg.norm(eye_landmarks[2] - eye_landmarks[4])&lt;br&gt;
    # Horizontal landmark Euclidean distance&lt;br&gt;
    c = np.linalg.norm(eye_landmarks[0] - eye_landmarks[3])&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;return float((a + b) / (2.0 * c)) if c &amp;gt; 0 else 0.0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Verification &amp;amp; PerformanceTest Suite: 54/54 passing unit and integration tests covering finite state transitions, motion gating, and remote buzzer endpoints.  Processing Latency: Operates at $\ge 20\text{ FPS}$ on standard CPU hardware with $&amp;lt; 100\text{ms}$ cold start latency using DirectShow capture.  Extensibility: Integrated SQLite persistence for custom user calibration baselines and audit logging. &lt;/p&gt;

</description>
      <category>ai</category>
      <category>architecture</category>
      <category>machinelearning</category>
      <category>python</category>
    </item>
  </channel>
</rss>
