Inspiration

Fatigue is one of the leading causes of fatal trucking accidents. Each year:

  • Fatigue-related trucking accidents cost an estimated $20 billion a year.
  • Fatigue was identified as the principal cause in 31% of fatal-to-driver trucking accidents.
  • Fatigue causes an estimated 328,000 driving crashes each year.

We wanted to build something that could detect the warning signs of drowsiness before tragedy strikes. Lucid is a Snowflake-powered tool that predicts that a driver will fall asleep 30 to 120 seconds before they snooze, allowing for early preventative measures. Lucid was born from the idea that computer vision and data insight in tandem could help keep everyone on the road safe.

What it does

Lucid uses computer vision to detect early signs of driver fatigue, tracking visual data like head pose, blink rate, yawning, and biometric data like heart rate and heart rate variability in real time. Every 15 seconds, the system analyzes a short video window and computes metrics such as PERCLOS (Percentage of Eye Closure Over Time), yawn frequency, head-down degrees, and heart-rate variability (HRV). These features are fused into a driver state classifier that categorizes the driver as Lucid Drowsy, or Asleep. The data is streamed to a cloud dashboard, where fleet managers can monitor driver alertness and receive fatigue risk alerts.

The goal is to reduce fatigue-related highway accidents through early detection and providing subsequent actionable insight. This is done through short term and long term mechanisms:

  • Short Term: Providing audible and visible hands free alerts to user on car dashboard when drowsiness is detected 30-120 seconds before actually falling asleep.
  • Long Term: Snowflake Cortex allows fleets to make data-driven safety decisions, such as scheduling additional rest stops, adjusting freight routes, or reassigning shifts to reduce fatigue risk. This makes operations more efficient for trucking companies while making the truckers drive safer.

How we built it

We built Lucid using Mediapipe for facial landmark detection and pose estimation, and integrated Node.js, React, and TypeScript to handle the frontend and backend. Video streams are processed and analyzed, and relevant fatigue metrics are stored and visualized using Snowflake’s big-data capabilities. Our system combines the real-time analysis, cloud processing, and visual reporting aspects of drowsiness detection in one unified pipeline.

Computer Vision + AI Stack

  • MediaPipe Face Mesh & Pose for facial landmark extraction and head-pose estimation.
  • Custom drowsiness heuristics combining Eye Aspect Ratio (EAR), Mouth Aspect Ratio (MAR), and adaptive thresholds for blink/yawn detection.
  • Driver state classifier blending PERCLOS, yawn rate, nod detection, and head pitch metrics to infer alertness tiers.
  • Stochastic vitals simulator maintains realistic HR/HRV signals even when telemetry updates intermittently.

Backend Architecture

  • Built with FastAPI (Python) to process video uploads and expose CV endpoints,
  • The WindowAnalyzer orchestrates frame slicing and metrics extraction using OpenCV, NumPy, and MediaPipe.
  • Queries Snowflake Cortex to summarize per-route fatigue patterns and generate AI-written recommendations for shift planning.

Frontend

  • Built with React 18, TypeScript, Vite, and TailwindCSS for rapid iteration and responsive UI.
  • Uses Zustand for lightweight global state management and React-Leaflet to render live maps showing truck positions, routes, and risk markers.
  • Each truck marker links to a detailed driver view with thresholds, alert history, and long-term metrics visualization via Recharts.
  • The API layer proxies requests through a configurable Snowflake REST Gateway, falling back to curated sample telemetry when data is delayed.

Physical Components (3D Printing)

  • People often question where these devices that track a user's front face must be placed. That’s why we 3d printed a dashboard with a specially designed area to hold a phone.
  • Most large trucks use a similar dashboard with a large amount of space below the dash and above the wheel, with an unobstructed view, making it perfect for our use case.
  • We choose to use a phone over other recording devices as it is easily accessible, easy for trucking companies to provide, and easy to set up.

Why Snowflake?

  • Snowflake uniquely serves as the unified data and AI hub, storing real-time metrics and enabling BI-ready analytics and route summaries. For a project that inherently requires large amounts of data that only providers like Snowflake can handle, while also needing AI to power the corresponding recommendations, Snowflake and Snowflake Cortex are the obvious combination.
  • Our route analysis page aggregate metrics per segment, visualizes them, and uses Snowflake Cortex generated summaries for fleet decision-making. This hand in hand correspondence between the metrics themselves and the choices being made was crucial for our project.

Challenges we ran into

We faced several challenges throughout the development of Lucid. Tuning the computer vision pipeline took significantly more time and attention than anticipated, as achieving reliable fatigue detection required careful parameter adjustments and testing. Integrating the Snowflake-powered data delivery backend into our frontend also presented difficulties, particularly in understanding how our data was being modified by our early API implementations and how to improve it. On the hardware side, we experienced many failed 3D prints while prototyping our demo enclosure, which slowed progress and required multiple iterations. Finally, defining a clear and consistent data schema; deciding what measurements to collect, how to structure them, and how to pass them between components, proved to be a more complex design challenge than expected, and changed numerous times throughout the course of the project.

Accomplishments that we're proud of

We’re incredibly proud of what we accomplished over the course of the weekend. Our team built an impressive physical hardware display that brought our concept to life and made our demo stand out. We also delivered a polished, intuitive frontend experience that tied together all aspects of the system seamlessly. Maybe most notably, we’re proud of the technical depth of Lucid, spanning computer vision, backend data infrastructure, frontend design, and mobile hardware integration, which makes it one of the most sophisticated projects we’ve built. Finally, we’re proud of the sheer pace and dedication of our team; we maintained strong focus and output throughout the hackathon, taking only minimal breaks to keep momentum high.

What we learned

We learned a tremendous amount over the course of building Lucid. Through our implementation of Snowflake, we gained a deep understanding of SQL-based data management and how to structure, query, and deliver insights efficiently across multiple components. We also learned how to leverage LLMs and coding agents to accelerate our development process, helping us move faster without sacrificing the attention to detail required for critical components like our computer vision pipeline and backend integration. Finally, collaborating as a four-person team taught us the importance of strong version control, clear communication, and thoughtful coordination to keep progress smooth and aligned across all parts of the project. More specifically with Snowflake, although members had experience using Snowflake Cortex, we used the big data components of Snowflake and realized how much more powerful the tool is for projects that involve large amounts of data and AI.

What's next for Lucid

Our next step for Lucid is to validate the product with real stakeholders in the freight industry. We want to engage directly with drivers, fleet managers, and logistics companies to understand their needs, workflows, and pain points, so we can refine Lucid into something truly practical and valuable. These conversations will guide how the product evolves, from the hardware design to the interface and data insights. Once we’ve validated the concept and refined the experience, we plan to enhance our computer vision accuracy, improve data delivery performance, and explore pilot programs that test Lucid in real-world conditions along active freight routes. We also want to spend more time experimenting with Snowflake Snowpark, venturing out of LLM’s and working with traditional AI models.

Built With

Share this project:

Updates