ForkProngDetector

Roboflow Fork Prong Detector

This project provides a Python script for automated detection and measurement of fork prongs in images using computer vision and machine learning techniques. The script is designed to process images of forks, identify prong tips, determine fork orientation, and calculate distances between prongs in millimeters.

Features

How It Works

  1. Setup:
    • Requires a Roboflow API key set as the environment variable ROBOFLOW_API_KEY.
    • Images should be placed in the data/forks directory.
  2. Processing:
    • For each image, the script preprocesses the image and sends it to the Roboflow inference API to detect fork objects and their edge points.
    • The detected points are analyzed using PCA to align and rotate the fork for consistent analysis.
    • Prong regions are identified, and clustering algorithms are used to find prong tips.
    • The script determines the fork’s orientation and orders the prongs accordingly.
    • Distances between prongs are calculated and converted to millimeters.
    • Annotated visualizations and measurement tables are saved to the data/analysis directory.
  3. Output:
    • Annotated images with detected prongs and measurement tables.
    • Progress and summary information printed to the console.

Requirements

Install dependencies with:

pip install numpy matplotlib scikit-learn Pillow rich inference-sdk

Usage

  1. Set your Roboflow API key:
    export ROBOFLOW_API_KEY=your_api_key_here
    
  2. Place fork images in the data/forks directory.
  3. Run the script:
    python Roboflow.py
    

File Structure

Notes