Spaces:
Running
Running
title: Line Follower PID | |
emoji: π | |
colorFrom: blue | |
colorTo: indigo | |
sdk: streamlit | |
sdk_version: "1.41.1" | |
app_file: app.py | |
pinned: false | |
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference | |
# Line Follower UI | |
A real-time line detection application using webcam input, built with Streamlit and OpenCV. | |
## Description | |
This application provides a user-friendly interface for real-time line detection using your webcam. It leverages computer vision techniques to detect lines within a specified color range and offers multiple methods for line estimation. The application is built using Streamlit for the frontend and OpenCV for image processing. | |
Key features: | |
- Real-time webcam video processing | |
- Interactive HSV color range adjustment | |
- Multiple line detection algorithms: | |
- Hough Lines | |
- Adaptive Hough Lines | |
- Rotated Rectangle | |
- Fit Ellipse | |
- RANSAC Line | |
- Customizable region of interest | |
- Confidence estimation for line detection | |
- Display of processed video or binary mask | |
## Installation | |
1. Clone this repository: | |
```bash | |
git clone https://github.com/yourusername/line_follower_ui.git | |
cd line_follower_ui | |
``` | |
2. Install the required dependencies: | |
```bash | |
pip install -r requirements.txt | |
``` | |
## Usage | |
1. Run the Streamlit application: | |
```bash | |
streamlit run app.py | |
``` | |
2. Allow access to your webcam when prompted. | |
3. Use the sidebar controls to: | |
- Adjust HSV color thresholds to isolate your line color | |
- Select the line detection method | |
- Modify the region of interest size | |
- Toggle between the processed image and the binary mask | |
4. Click "Apply Settings" to update the detector with your chosen parameters. | |
## Adjusting HSV Values | |
The HSV color space consists of three components: | |
- **Hue**: The color type (such as red, blue, or yellow) | |
- **Saturation**: The vibrancy of the color (from gray to full color) | |
- **Value**: The brightness of the color (from black to full brightness) | |
To detect a specific color: | |
1. Adjust the Hue sliders to select the color range | |
2. Adjust Saturation to set how pure the color should be | |
3. Adjust Value to set how bright the color should be | |
4. Use the "Show Mask" option to see which pixels are being detected | |
## Line Detection Methods | |
The application offers various line detection methods, each with its own strengths: | |
- **Hough Lines**: Standard method for detecting straight lines | |
- **Adaptive Hough Lines**: Automatically adjusts parameters based on image conditions | |
- **Rotated Rectangle**: Fits a minimum area rectangle to detected contours | |
- **Fit Ellipse**: Fits an ellipse to detected contours, useful for curved lines | |
- **RANSAC Line**: Robust method that handles outliers well, good for noisy images | |
## Requirements | |
- Python 3.7 or higher | |
- Webcam | |
- Dependencies listed in requirements.txt | |
## Troubleshooting | |
- If the webcam doesn't start, make sure you allow browser access to your camera | |
- If you see "Failed to access webcam" error, check if another application is using your camera | |
- For any line detection issues, try adjusting the HSV values or try different detection methods | |
## License | |
This project is licensed under the MIT License - see the LICENSE file for details. | |
## Acknowledgments | |
- OpenCV for image processing capabilities | |
- Streamlit for the web interface | |
- streamlit-webrtc for real-time video processing |