File size: 2,583 Bytes
de0b8da
 
c59f824
6d19b5c
de0b8da
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
---
title: Angle Measurement v2
sdk: gradio
sdk_version : 4.44.1
app_file : angle_detection_app.py
colorFrom: indigo
colorTo: gray
pinned: true
---
# Angle Detection App

This app detects bends in images and measures angles between them. It's particularly useful for analyzing geometric patterns and measuring angles in technical drawings or diagrams.

## Features

- Upload images in various formats (JPEG, PNG, HEIC)
- Automatic bend detection
- Angle measurement between bends
- Adjustable parameters for fine-tuning detection
- Real-time visualization with bend points and angle measurements

## Usage

1. Upload an image using the file uploader
2. Adjust the algorithm parameters if needed:
   - Blur Kernel Size: Controls image smoothing
   - Canny Thresholds: Edge detection sensitivity
   - Dilation Kernel Size: Edge thickening
   - Hough Threshold: Line detection sensitivity
   - Line Length/Gap: Minimum line length and maximum gap between line segments
   - Bend Threshold: Distance threshold for bend detection
3. Click "Process Image" to analyze the image
4. View the results with detected bends and measured angles

## Example Images

The app includes example images to help you get started. Try them out to see how the angle detection works with different types of images.

## Technical Details

The app uses OpenCV for image processing and edge detection, with the following main steps:
1. Image preprocessing (grayscale conversion and blur)
2. Edge detection using Canny algorithm
3. Line detection using Hough transform
4. Bend point identification
5. Angle calculation between consecutive bends

## Local Deployment

1. Install dependencies:
```bash
pip install -r requirements.txt
```

2. Run the app:
```bash
python angle_detection_app.py
```

3. Open your browser and navigate to the URL shown in the terminal (typically http://127.0.0.1:7860)

## Hugging Face Spaces Deployment

1. Create a new Space on Hugging Face:
   - Go to https://huggingface.co/spaces
   - Click "New Space"
   - Choose "Gradio" as the SDK
   - Give your space a name

2. Push your code to the Space:
```bash
git clone https://huggingface.co/spaces/YOUR_USERNAME/YOUR_SPACE_NAME
cd YOUR_SPACE_NAME
# Copy your files here
git add .
git commit -m "Initial commit"
git push
```

## Docker Deployment

1. Build the Docker image:
```bash
docker build -t angle-detection-app .
```

2. Run the container:
```bash
docker run -p 7860:7860 angle-detection-app
```

3. Access the app at http://localhost:7860

## Requirements

- Python 3.8+
- See requirements.txt for Python package dependencies