Skip to content

hassan789852/Object-Detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 

Repository files navigation

πŸ“· Flutter Object Detection App

This is a Flutter-based real-time object detection app using TensorFlow Lite.
It processes live camera frames, provides real-time guidance to the user, and captures an image when the object is correctly positioned.


πŸ“Œ Features

βœ”οΈ Real-time Object Detection using TensorFlow Lite
βœ”οΈ Live User Guidance ("Move Closer", "Move Farther", "Object in Position")
βœ”οΈ Automatic Image Capture when object is positioned correctly
βœ”οΈ Stores Image Metadata (date, time, object type)
βœ”οΈ GetX State Management for smooth UI updates βœ”οΈ Performance Optimization by limiting frame processing


πŸš€ How to Run the App

1️⃣ Clone the Repository

git clone <your-repo-url>
cd <your-project-folder>

2️⃣ Install Dependencies

flutter pub get

3️⃣ Run the App on a Physical Device

flutter run

πŸ›‘ Important:

  • This app requires a physical device as it uses the camera for object detection.
  • Ensure you have TensorFlow Lite models in assets/models/.

πŸ“¦ Dependencies Used

The following dependencies are used in this project (pubspec.yaml):

Package Name Version Purpose
flutter latest Core Flutter framework
get ^4.6.5 State management & navigation
camera ^0.10.5+2 Accessing device camera
tflite_flutter ^0.11.0 Running TensorFlow Lite models
image ^4.0.17 Image processing utilities
path_provider ^2.0.15 File system access
image_picker ^1.0.0 Selecting or capturing images
exif ^3.1.4 Extracting metadata from images
intl ^0.19.0 Formatting date/time

⚠️ Challenges Faced & Solutions

🧠 1. Performance Optimization (Device Overheating)

Issue:

  • Continuous processing of camera frames caused the device to overheat and reduced performance.

Solution:

  • Introduced frame skipping mechanism to reduce CPU/GPU workload.
  • Added:
    int frameCounter = 0; // Used to limit FPS processing
  • Optimized Image Processing: Frames are only processed every 5th frame, significantly improving performance.

🧠 2. Model Not Trained Well

Issue:

  • The TensorFlow Lite model sometimes misclassifies objects or fails to detect them accurately.
  • Inconsistent detection caused early or late object positioning messages.

Solution:

  • Adjusted Confidence Threshold:
    We fine-tuned the model threshold (confidence = 0.5) to improve detection accuracy.

🧠 3. Sending Data Between Isolate and Main Thread

Issue:

  • The TensorFlow Lite model runs in a separate isolate to avoid blocking the UI.
  • However, sending camera frames from the main thread to the isolate caused serialization issues.
  • CameraImage objects cannot be sent directly across isolates.

Solution:

  • We used Background Isolate Channels to register the root isolate before running background operations.
  • Implemented a Command-Based Messaging System:
    • The Main Isolate sends "detect" commands to the detector isolate.
    • The Detector Isolate processes the image and sends back "result" commands.
    • Captured Image Handling uses a capture lock (_isCapturing = true) to prevent multiple captures.

πŸ’ͺ This resolved the issue, allowing real-time image processing without UI lag!

πŸ™Œ Contributing

Want to improve the model accuracy or enhance the UI?
Feel free to fork the repo and submit a pull request!

git clone <your-repo-url>
git checkout -b feature-branch
git commit -m "Added new feature"
git push origin feature-branch

πŸ“ License

This project is licensed under the MIT License.


🎯 Your project now has a structured README.md with all required details! πŸš€
Let me know if you need any changes! πŸš€πŸ’‘

Object-Detection

Object-Detection

About

This is a Flutter-based real-time object detection app using TensorFlow Lite

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors