This project demonstrates real-time object detection using TensorFlow.js and the COCO-SSD model in a React application. The app uses a webcam feed to detect objects and overlays bounding boxes with labels on the video.
- Real-time object detection using the COCO-SSD model.
- Randomly colored bounding boxes for detected objects.
- Toggle webcam feed on and off.
- Dynamic canvas rendering for video frames and predictions.
- React: Frontend framework for building the user interface.
- TensorFlow.js: JavaScript library for machine learning.
- COCO-SSD: Pre-trained object detection model.
- WebGL: Backend for TensorFlow.js to accelerate computations.
- Clone the repository:
git clone https://github.com/your-username/object-detection.git cd object-detection
- Install dependencies:
npm install
- Start the development server:
npm start
- Open your browser and navigate to
http://localhost:3000
- Click the Enable Webcam button to start the webcam feed.
- The app will load the COCO-SSD model and begin detecting objects in the video feed.
- Detected objects will be highlighted with randomly colored bounding boxes and labels.
- Click Disable Webcam to stop the webcam feed.
src/
├── [App.tsx](http://_vscodecontentref_/1) # Main React component
├── App.css # Styling for the app
├── index.tsx # Entry point for the React app
└── ... # Other files
loadModel
Loads the COCO-SSD model using TensorFlow.js.
handleWebCam
Handles enabling and disabling the webcam feed.
detectObjects
Processes video frames, detects objects, and draws bounding boxes and labels on the canvas.
- Ensure your browser supports WebGL for optimal performance.
- Webcam access requires user permission. Make sure to allow access when prompted.
- Add support for image uploads for object detection.
- Display detection confidence thresholds.
- Improve UI/UX for better user interaction.