Skip to content

kavindu-udara/react-object-detection-webapp

Repository files navigation

Object Detection with TensorFlow.js and React

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.

Features

  • 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.

Technologies Used

  • 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.

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/object-detection.git
    cd object-detection
    
    
  2. Install dependencies:
    npm install
    
  3. Start the development server:
    npm start
    
  4. Open your browser and navigate to
    http://localhost:3000
    

Usage

  1. Click the Enable Webcam button to start the webcam feed.
  2. The app will load the COCO-SSD model and begin detecting objects in the video feed.
  3. Detected objects will be highlighted with randomly colored bounding boxes and labels.
  4. Click Disable Webcam to stop the webcam feed.

Project Structure

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

Key Functions

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.

Known Issues

  • Ensure your browser supports WebGL for optimal performance.
  • Webcam access requires user permission. Make sure to allow access when prompted.

Future Improvements

  • Add support for image uploads for object detection.
  • Display detection confidence thresholds.
  • Improve UI/UX for better user interaction.

About

Object Detection with TensorFlow.js and React

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published