A real-time object detection web application built with React, TypeScript, and TensorFlow.js. The app uses your webcam to detect people and phones in real-time, with live analytics and historical data tracking.
- Live Video Streaming: Real-time webcam feed with object detection
- Object Detection: Detects people and phones using COCO-SSD model
- Smart Bounding Boxes:
- Green boxes for people
- Red boxes for phones
- Red boxes for people holding phones
- Live Counters: Real-time tracking of detected objects
- Analytics Dashboard: Historical data with charts and tables
- Responsive Design: Mobile-friendly interface
- Data Persistence: Saves detection history to localStorage
- Frontend: React 18 + TypeScript
- Styling: Tailwind CSS
- Object Detection: TensorFlow.js + COCO-SSD model
- Charts: Recharts
- Build Tool: Vite
- Date Handling: date-fns
- Node.js 16+
- Modern web browser with webcam support
- HTTPS connection (required for webcam access in most browsers)
- Clone the repository:
git clone <repository-url>
cd object-detection-app- Install dependencies:
npm install- Start the development server:
npm run dev- Open your browser and navigate to
http://localhost:3000
- Click "Start Stream" to begin webcam access
- Allow camera permissions when prompted
- The app will automatically detect people and phones in real-time
- View live counters and detection details below the video
- Switch to the Analytics tab to view historical data
- Use time range selectors (1h, 6h, 24h) to filter data
- View charts showing detection trends over time
- Browse detailed detection records in the table
- Use "Generate Sample Data" to see example charts
- Use "Clear Data" to reset all historical data
- Object detection runs at 10 FPS to maintain smooth performance
- Video stream runs at 30 FPS for smooth display
- Detection results are cached and shared between components
- Canvas overlay provides efficient bounding box rendering
- Chrome 80+
- Firefox 75+
- Safari 13+
- Edge 80+
- Ensure you're using HTTPS (required for getUserMedia API)
- Check browser permissions for camera access
- Try refreshing the page and granting permissions again
- Check your internet connection (model is downloaded on first use)
- Clear browser cache and try again
- Ensure TensorFlow.js is properly loaded
- Close other browser tabs to free up memory
- Reduce video resolution if needed
- Check browser console for error messages
src/
├── components/
│ ├── Header.tsx # Navigation component
│ ├── Stream.tsx # Video streaming and detection
│ └── Analytics.tsx # Charts and historical data
├── context/
│ └── DetectionContext.tsx # Shared state management
├── App.tsx # Main app component
├── main.tsx # Entry point
└── index.css # Global styles
npm run dev- Start development servernpm run build- Build for productionnpm run preview- Preview production buildnpm run lint- Run ESLint
To detect additional objects beyond people and phones:
- Update the
runDetectionfunction inStream.tsx - Add new detection logic and bounding box colors
- Update the analytics components to track new classes
- Modify the context interface if needed
This project is licensed under the MIT License.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- TensorFlow.js team for the object detection models
- COCO dataset contributors
- React and TypeScript communities