This project is a result of my current exploration into Artificial Intelligence (AI) and Vibe Coding. It's an experimental web application that demonstrates real-time object detection and distance estimation directly in the browser.
The AI Car Distance Radar uses a webcam feed to detect vehicles (cars, trucks, buses) and estimates their distance from the camera. This is a "vibe coding" experiment—focusing on rapid prototyping and exploring the intersection of modern web technologies and machine learning.
- Real-time Detection: Identifies vehicles instantly using the webcam.
- Distance Estimation: Calculates the approximate distance to detected vehicles based on their relative size in the frame.
- Privacy Focused: All processing happens locally on your device. No video data is sent to a server.
- Responsive Interface: A clean, dark-themed UI designed for clarity.
- HTML5 & CSS3: For the structure and styling.
- JavaScript (ES6+): For the application logic.
- TensorFlow.js: The core machine learning framework for the browser.
- COCO-SSD Model: A pre-trained Object Detection model that can identify 80 different classes of objects (optimized here for vehicles).
- Model Loading: The application downloads the COCO-SSD model upon startup.
- Webcam Access: It requests permission to use your camera (ideally an environment/rear-facing camera if on mobile).
- Inference: Every frame from the video feed is passed through the neural network.
- Distance Calculation: Using a predefined focal length and the known average height of a car, the app estimates the distance:
Distance = (Real Height * Focal Length) / Pixel Height
You can view the live demo here: https://pkwentf.netlify.app/
- Clone the repository:
git clone https://github.com/juergen874/Cardistance.git
- Open
index.htmlin any modern web browser. - Allow camera access when prompted.
Note: For the best experience and security, the application requires an HTTPS connection when served over a network.