Spaces:
Sleeping
Sleeping
Update README.md
Browse files
README.md
CHANGED
|
@@ -1,435 +1,116 @@
|
|
| 1 |
-
# π SPaCial AI - Complete OCR System
|
| 2 |
-
|
| 3 |
-
> **AR-Style Live Camera Scanner + Telegram Bot + Training Data Collection**
|
| 4 |
-
|
| 5 |
-
Everything runs on your Hugging Face Space - Deploy in 5 minutes! β‘
|
| 6 |
-
|
| 7 |
-
---
|
| 8 |
-
|
| 9 |
-
## π― What This Is
|
| 10 |
-
|
| 11 |
-
A **complete crowdsourced OCR system** for blueprints and technical drawings:
|
| 12 |
-
|
| 13 |
-
- πΈ **Live Camera Scanner** - AR-style overlay with real-time detection
|
| 14 |
-
- π€ **Telegram Bot** - Easy user interface
|
| 15 |
-
- π **Training Data Collection** - Automatic model improvement
|
| 16 |
-
- βοΈ **Cloud Hosted** - Free on Hugging Face Spaces
|
| 17 |
-
|
| 18 |
-
---
|
| 19 |
-
|
| 20 |
-
## β¨ Features
|
| 21 |
-
|
| 22 |
-
### For Users:
|
| 23 |
-
- β
Send photo β Get OCR results instantly
|
| 24 |
-
- β
Open camera β Point at text β See green boxes live
|
| 25 |
-
- β
Validate or correct detections
|
| 26 |
-
- β
Download results as JSON
|
| 27 |
-
- β
Works on any device (mobile/desktop)
|
| 28 |
-
|
| 29 |
-
### For You:
|
| 30 |
-
- β
Collect training data automatically
|
| 31 |
-
- β
Store everything in Telegram (free!)
|
| 32 |
-
- β
No database needed
|
| 33 |
-
- β
Track improvements over time
|
| 34 |
-
- β
Crowdsource corrections
|
| 35 |
-
|
| 36 |
-
---
|
| 37 |
-
|
| 38 |
-
## π± User Experience
|
| 39 |
-
|
| 40 |
-
### 1. Start Bot
|
| 41 |
-
```
|
| 42 |
-
User β Telegram β @your_bot β /start
|
| 43 |
-
|
| 44 |
-
Bot shows:
|
| 45 |
-
ββββββββββββββββββββββββββ
|
| 46 |
-
β [πΈ Live Camera Scan] β β Opens mini app
|
| 47 |
-
β [π Upload Photo] β β Traditional
|
| 48 |
-
ββββββββββββββββββββββββββ
|
| 49 |
-
```
|
| 50 |
-
|
| 51 |
-
### 2. Live Camera (NEW!)
|
| 52 |
-
```
|
| 53 |
-
Click "Live Camera Scan"
|
| 54 |
-
β
|
| 55 |
-
ββββββββββββββββββββββββββββ
|
| 56 |
-
β π Scanning... β
|
| 57 |
-
β 5 zones detected β
|
| 58 |
-
ββββββββββββββββββββββββββββ€
|
| 59 |
-
β π₯ CAMERA VIEW β
|
| 60 |
-
β β
|
| 61 |
-
β βββββββββ 12.5 Β± 0.1 β β Green boxes
|
| 62 |
-
β β β β appear live!
|
| 63 |
-
β βββββββββ β
|
| 64 |
-
β β
|
| 65 |
-
β ββββββ 10.0 β
|
| 66 |
-
β β β β
|
| 67 |
-
β ββββββ β
|
| 68 |
-
ββββββββββββββββββββββββββββ€
|
| 69 |
-
β [Stop] [Capture] β
|
| 70 |
-
ββββββββββββββββββββββββββββ
|
| 71 |
-
```
|
| 72 |
-
|
| 73 |
-
### 3. Upload Photo
|
| 74 |
-
```
|
| 75 |
-
Send photo β Wait 3s β Get results
|
| 76 |
-
|
| 77 |
-
π OCR Results
|
| 78 |
-
β
Found 15 zones:
|
| 79 |
-
1. 12.5 Β± 0.1 (98%)
|
| 80 |
-
2. 10.0 (95%)
|
| 81 |
-
3. 25.3 Β± 0.2 (97%)
|
| 82 |
-
...
|
| 83 |
-
|
| 84 |
-
[β
All Correct] [βοΈ Fix] [π₯ JSON]
|
| 85 |
-
```
|
| 86 |
-
|
| 87 |
-
---
|
| 88 |
-
|
| 89 |
-
## ποΈ Architecture
|
| 90 |
-
|
| 91 |
-
```
|
| 92 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 93 |
-
β Hugging Face Space β
|
| 94 |
-
β β
|
| 95 |
-
β βββββββββββββββββββββββββββββββββββββββ β
|
| 96 |
-
β β app.py (Backend) β β
|
| 97 |
-
β β β’ FastAPI OCR endpoints β β
|
| 98 |
-
β β β’ PaddleOCR processing β β
|
| 99 |
-
β β β’ Telegram bot handlers β β
|
| 100 |
-
β β β’ Webhook receiver β β
|
| 101 |
-
β β β’ Static file serving β β
|
| 102 |
-
β βββββββββββββββββββββββββββββββββββββββ β
|
| 103 |
-
β β
|
| 104 |
-
β βββββββββββββββββββββββββββββββββββββββ β
|
| 105 |
-
β β static/camera.html (Mini App) β β
|
| 106 |
-
β β β’ Real-time camera access β β
|
| 107 |
-
β β β’ Canvas overlay drawing β β
|
| 108 |
-
β β β’ Live OCR visualization β β
|
| 109 |
-
β β β’ Telegram Web App integration β β
|
| 110 |
-
β βββββββββββββββββββββββββββββββββββββββ β
|
| 111 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 112 |
-
β
|
| 113 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 114 |
-
β Telegram Bot API β
|
| 115 |
-
β β’ Webhook messages β
|
| 116 |
-
β β’ Photos & commands β
|
| 117 |
-
β β’ Callback buttons β
|
| 118 |
-
β β’ Mini app launcher β
|
| 119 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 120 |
-
β
|
| 121 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 122 |
-
β Users β
|
| 123 |
-
β β’ Send /start β Get camera button β
|
| 124 |
-
β β’ Click button β Mini app opens β
|
| 125 |
-
β β’ Camera scans β Live boxes appear β
|
| 126 |
-
β β’ Or upload photo β Get results β
|
| 127 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 128 |
-
β
|
| 129 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 130 |
-
β Telegram Channel (Storage) β
|
| 131 |
-
β β’ Training data (JSON) β
|
| 132 |
-
β β’ Original images β
|
| 133 |
-
β β’ User corrections β
|
| 134 |
-
β β’ Free, persistent, backed up β
|
| 135 |
-
βββββββββββββββββββββββββββββββββββββββββββββββ
|
| 136 |
-
```
|
| 137 |
-
|
| 138 |
-
---
|
| 139 |
-
|
| 140 |
-
## π¦ What's Included
|
| 141 |
-
|
| 142 |
-
### Backend (`app.py` - 1200 lines)
|
| 143 |
-
- β
OCR API endpoints
|
| 144 |
-
- β
Telegram bot webhook handler
|
| 145 |
-
- β
Training data collection
|
| 146 |
-
- β
Photo processing (upload & Telegram)
|
| 147 |
-
- β
Interactive buttons (callbacks)
|
| 148 |
-
- β
Commands (/start, /help, /status)
|
| 149 |
-
- β
Mini app serving
|
| 150 |
-
|
| 151 |
-
### Mini App (`static/camera.html` - 270 lines)
|
| 152 |
-
- β
Camera access (front/back)
|
| 153 |
-
- β
Real-time frame capture
|
| 154 |
-
- β
OCR API integration
|
| 155 |
-
- β
Canvas overlay system
|
| 156 |
-
- β
Green boxes + text labels
|
| 157 |
-
- β
Status display
|
| 158 |
-
- β
Start/Stop/Capture controls
|
| 159 |
-
|
| 160 |
-
### Documentation (5 files)
|
| 161 |
-
- β
`README.md` - This file (overview)
|
| 162 |
-
- β
`QUICK_START.md` - 5-minute deploy guide
|
| 163 |
-
- β
`TELEGRAM_SETUP.md` - Bot configuration
|
| 164 |
-
- β
`MINI_APP_SETUP.md` - Camera app details
|
| 165 |
-
- β
`CHANGES_SUMMARY.md` - Technical changes
|
| 166 |
-
|
| 167 |
-
---
|
| 168 |
-
|
| 169 |
-
## β‘ Quick Start
|
| 170 |
-
|
| 171 |
-
### 1. Create Telegram Bot (2 min)
|
| 172 |
-
```
|
| 173 |
-
1. Message @BotFather
|
| 174 |
-
2. /newbot β Name it
|
| 175 |
-
3. Copy token
|
| 176 |
-
```
|
| 177 |
-
|
| 178 |
-
### 2. Create Telegram Channel (1 min)
|
| 179 |
-
```
|
| 180 |
-
1. Create private channel
|
| 181 |
-
2. Add bot as admin
|
| 182 |
-
3. Get chat ID
|
| 183 |
-
```
|
| 184 |
-
|
| 185 |
-
### 3. Deploy to HF Spaces (2 min)
|
| 186 |
-
```bash
|
| 187 |
-
git push
|
| 188 |
-
|
| 189 |
-
# Set env vars in HF Space settings:
|
| 190 |
-
TELEGRAM_BOT_TOKEN=your_token
|
| 191 |
-
TELEGRAM_CHAT_ID=your_chat_id
|
| 192 |
-
SPACE_HOST=your-space-name.hf.space
|
| 193 |
-
```
|
| 194 |
-
|
| 195 |
-
### 4. Configure Webhook (30 sec)
|
| 196 |
-
```
|
| 197 |
-
Visit: https://your-space.hf.space/telegram/set-webhook?webhook_url=https://your-space.hf.space/telegram/webhook
|
| 198 |
-
```
|
| 199 |
-
|
| 200 |
-
### 5. Test!
|
| 201 |
-
```
|
| 202 |
-
Telegram β Bot β /start β Click camera button β DONE! π
|
| 203 |
-
```
|
| 204 |
-
|
| 205 |
-
**[Full instructions in QUICK_START.md](QUICK_START.md)**
|
| 206 |
-
|
| 207 |
-
---
|
| 208 |
-
|
| 209 |
-
## π How It Works
|
| 210 |
-
|
| 211 |
-
### Live Camera Scanning:
|
| 212 |
-
|
| 213 |
-
```javascript
|
| 214 |
-
// Mini app (camera.html)
|
| 215 |
-
1. Access device camera
|
| 216 |
-
navigator.mediaDevices.getUserMedia()
|
| 217 |
-
|
| 218 |
-
2. Capture frame every 2 seconds
|
| 219 |
-
canvas.toBlob() β image data
|
| 220 |
-
|
| 221 |
-
3. Send to backend
|
| 222 |
-
POST /ocr/process
|
| 223 |
-
|
| 224 |
-
4. Receive zones
|
| 225 |
-
{ zones: [{text, x, y, width, height}] }
|
| 226 |
-
|
| 227 |
-
5. Draw overlay
|
| 228 |
-
ctx.strokeRect() β green boxes
|
| 229 |
-
ctx.fillText() β labels
|
| 230 |
-
|
| 231 |
-
6. Repeat β Live detection!
|
| 232 |
-
```
|
| 233 |
-
|
| 234 |
-
### Photo Upload:
|
| 235 |
-
|
| 236 |
-
```python
|
| 237 |
-
# Backend (app.py)
|
| 238 |
-
1. User sends photo to bot
|
| 239 |
-
2. Telegram webhook β /telegram/webhook
|
| 240 |
-
3. Download photo β process_telegram_photo()
|
| 241 |
-
4. PaddleOCR β detect zones
|
| 242 |
-
5. Format results β format_ocr_results_for_telegram()
|
| 243 |
-
6. Send back to user with buttons
|
| 244 |
-
7. User validates β send_correction_to_telegram()
|
| 245 |
-
8. Store in Telegram channel β Training data!
|
| 246 |
-
```
|
| 247 |
-
|
| 248 |
---
|
| 249 |
-
|
| 250 |
-
|
| 251 |
-
|
| 252 |
-
|
| 253 |
-
|
| 254 |
-
|
| 255 |
-
|
| 256 |
-
|
| 257 |
-
|
| 258 |
-
- `POST /telegram/webhook` - Receive messages
|
| 259 |
-
- `POST /telegram/set-webhook` - Configure webhook
|
| 260 |
-
- `GET /telegram/status` - Check configuration
|
| 261 |
-
|
| 262 |
-
### Training Data:
|
| 263 |
-
- `POST /corrections/submit` - Submit user corrections
|
| 264 |
-
|
| 265 |
-
### Documentation:
|
| 266 |
-
- `GET /docs` - Interactive API docs (FastAPI)
|
| 267 |
-
|
| 268 |
---
|
| 269 |
|
| 270 |
-
#
|
| 271 |
|
| 272 |
-
|
| 273 |
-
- **Backend:** 1,200 lines (Python/FastAPI)
|
| 274 |
-
- **Mini App:** 270 lines (HTML/JS)
|
| 275 |
-
- **Documentation:** 5 markdown files
|
| 276 |
|
| 277 |
-
##
|
| 278 |
-
- **3 ways to scan:** Camera, upload, send to bot
|
| 279 |
-
- **2 types of storage:** Telegram channel + temporary files
|
| 280 |
-
- **1 deployment:** Everything on HF Spaces
|
| 281 |
|
| 282 |
-
|
| 283 |
-
- **
|
| 284 |
-
- **
|
| 285 |
-
- **
|
| 286 |
-
- **
|
|
|
|
| 287 |
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
## π Why This Is Special
|
| 291 |
-
|
| 292 |
-
### Traditional OCR:
|
| 293 |
-
```
|
| 294 |
-
Upload β Wait β Get results β Done
|
| 295 |
-
(No improvement, no feedback loop)
|
| 296 |
-
```
|
| 297 |
-
|
| 298 |
-
### This System:
|
| 299 |
-
```
|
| 300 |
-
Scan live β See boxes β Validate β Correct β Train model β Improve β Better results
|
| 301 |
-
(Continuous improvement with every user!)
|
| 302 |
-
```
|
| 303 |
|
| 304 |
-
###
|
| 305 |
-
-
|
| 306 |
-
-
|
| 307 |
-
- β
**Telegram storage** - No database needed
|
| 308 |
-
- β
**Multi-modal** - Camera, upload, or send
|
| 309 |
-
- β
**Mobile-first** - Works on any device
|
| 310 |
-
- β
**Zero infrastructure** - Just HF Spaces
|
| 311 |
|
| 312 |
-
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
|
| 316 |
-
|
| 317 |
-
- **
|
| 318 |
-
- **
|
| 319 |
-
- **[Changes Summary](CHANGES_SUMMARY.md)** - Technical overview
|
| 320 |
|
| 321 |
-
|
|
|
|
|
|
|
|
|
|
| 322 |
|
| 323 |
-
## π§
|
| 324 |
|
| 325 |
-
###
|
| 326 |
-
```env
|
| 327 |
-
TELEGRAM_BOT_TOKEN=1234567890:ABC...
|
| 328 |
-
TELEGRAM_CHAT_ID=-1001234567890
|
| 329 |
-
SPACE_HOST=your-space-name.hf.space
|
| 330 |
```
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
PADDLEOCR_HOME=/app/.paddleocr
|
| 336 |
```
|
| 337 |
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
## π Troubleshooting
|
| 341 |
-
|
| 342 |
-
### Bot not responding?
|
| 343 |
-
```bash
|
| 344 |
-
curl https://your-space.hf.space/telegram/status
|
| 345 |
```
|
| 346 |
-
|
| 347 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 348 |
```
|
| 349 |
-
Check SPACE_HOST env var
|
| 350 |
-
Try: https://your-space.hf.space/camera
|
| 351 |
-
```
|
| 352 |
-
|
| 353 |
-
### Camera not working?
|
| 354 |
-
```
|
| 355 |
-
1. Grant permissions
|
| 356 |
-
2. Use HTTPS (required)
|
| 357 |
-
3. Try mobile device
|
| 358 |
-
```
|
| 359 |
-
|
| 360 |
-
### More help:
|
| 361 |
-
- [MINI_APP_SETUP.md](MINI_APP_SETUP.md#troubleshooting)
|
| 362 |
-
- Check HF Space logs
|
| 363 |
-
- Visit `/docs` for API testing
|
| 364 |
-
|
| 365 |
-
---
|
| 366 |
-
|
| 367 |
-
## π― Use Cases
|
| 368 |
|
|
|
|
| 369 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 370 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 371 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 372 |
|
|
|
|
| 373 |
|
| 374 |
-
-
|
| 375 |
-
-
|
| 376 |
-
-
|
| 377 |
-
-
|
| 378 |
-
- β
**Field work** - Scan on-site
|
| 379 |
-
- β
**Training data** - Collect corrections
|
| 380 |
|
| 381 |
-
|
| 382 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 383 |
|
|
|
|
| 384 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 385 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 386 |
|
| 387 |
-
##
|
| 388 |
|
| 389 |
-
|
| 390 |
-
- Video file processing (scan across large blueprint)
|
| 391 |
-
- Multi-frame stitching (combine angles)
|
| 392 |
-
- Export to Excel/CSV
|
| 393 |
-
- Custom models per user
|
| 394 |
-
- Analytics dashboard
|
| 395 |
-
- Multi-language support
|
| 396 |
-
- Voice feedback
|
| 397 |
-
- AR measurement tools
|
| 398 |
|
| 399 |
---
|
| 400 |
|
| 401 |
-
|
| 402 |
-
|
| 403 |
-
|
| 404 |
-
## π€ Contributing
|
| 405 |
-
|
| 406 |
-
This is a complete, deployable system. To customize:
|
| 407 |
-
|
| 408 |
-
|
| 409 |
-
|
| 410 |
-
|
| 411 |
-
1. **Adjust scan interval:** `camera.html` line 150
|
| 412 |
-
2. **Change UI colors:** `camera.html` CSS section
|
| 413 |
-
3. **Modify OCR settings:** `app.py` line 363-381
|
| 414 |
-
4. **Add features:** Extend endpoints in `app.py`
|
| 415 |
-
|
| 416 |
-
---
|
| 417 |
-
|
| 418 |
-
## π License
|
| 419 |
-
|
| 420 |
-
MIT License - Use freely for any purpose!
|
| 421 |
-
|
| 422 |
-
---
|
| 423 |
-
|
| 424 |
-
|
| 425 |
-
## π You're Ready!
|
| 426 |
-
|
| 427 |
-
Deploy to Hugging Face Spaces and start scanning!
|
| 428 |
-
|
| 429 |
-
**Read [QUICK_START.md](QUICK_START.md) for step-by-step instructions.**
|
| 430 |
-
|
| 431 |
-
---
|
| 432 |
-
|
| 433 |
-
Built with β€οΈ for the blueprint scanning community
|
| 434 |
-
|
| 435 |
-
**Questions?** Check the docs or HF Space logs!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
title: SPaCial AI OCR Service
|
| 3 |
+
emoji: π
|
| 4 |
+
colorFrom: blue
|
| 5 |
+
colorTo: purple
|
| 6 |
+
sdk: docker
|
| 7 |
+
sdk_version: "4.21.0"
|
| 8 |
+
app_file: app.py
|
| 9 |
+
pinned: false
|
| 10 |
+
license: mit
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# SPaCial AI OCR Service π
|
| 14 |
|
| 15 |
+
Advanced OCR service using PaddleOCR for dimension detection in technical drawings. Perfect for extracting measurements, tolerances, and text from engineering drawings.
|
|
|
|
|
|
|
|
|
|
| 16 |
|
| 17 |
+
## π Features
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
+
- **High-Accuracy OCR**: Uses PaddleOCR with multiple detection modes
|
| 20 |
+
- **Dimension Detection**: Automatically identifies measurements and tolerances
|
| 21 |
+
- **Vertical Text Support**: Handles rotated text (90Β°, 180Β°, 270Β°)
|
| 22 |
+
- **Interactive Canvas**: Draw rectangles or click to detect text
|
| 23 |
+
- **Real-time Processing**: Fast and efficient text extraction
|
| 24 |
+
- **Multiple Modes**: Fast, accurate, and hardcore detection modes
|
| 25 |
|
| 26 |
+
## π― How to Use
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 27 |
|
| 28 |
+
### 1. Upload an Image
|
| 29 |
+
- Click "Choose File" to upload a technical drawing
|
| 30 |
+
- Supported formats: JPG, PNG, WebP
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
+
### 2. Auto-Detection
|
| 33 |
+
- The system automatically detects all text zones
|
| 34 |
+
- Each zone shows confidence percentage and rotation angle
|
| 35 |
|
| 36 |
+
### 3. Manual Selection
|
| 37 |
+
- **Double-click**: Click on any text to detect it precisely
|
| 38 |
+
- **Draw Rectangle**: Drag to draw a rectangle around text for better detection
|
|
|
|
| 39 |
|
| 40 |
+
### 4. Zone Management
|
| 41 |
+
- **Rotate**: Click the rotate button to improve vertical text detection
|
| 42 |
+
- **Fit**: Click thumbnail to re-OCR with better accuracy
|
| 43 |
+
- **Delete**: Remove unwanted zones
|
| 44 |
|
| 45 |
+
## π§ API Endpoints
|
| 46 |
|
| 47 |
+
### Process Image
|
|
|
|
|
|
|
|
|
|
|
|
|
| 48 |
```
|
| 49 |
+
POST /ocr/process
|
| 50 |
+
- file: Image file
|
| 51 |
+
- mode: "fast", "accurate", or "hardcore"
|
| 52 |
+
- rotation: 0, 90, 180, 270 degrees
|
|
|
|
| 53 |
```
|
| 54 |
|
| 55 |
+
### Process Center Point
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
```
|
| 57 |
+
POST /ocr/process-center
|
| 58 |
+
- image: Base64 encoded image
|
| 59 |
+
- center_point: {"x": x, "y": y}
|
| 60 |
+
- rectangle_bounds: {"x1": x1, "y1": y1, "x2": x2, "y2": y2}
|
| 61 |
+
- use_rectangle: true/false
|
| 62 |
+
- rotation: rotation angle
|
| 63 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
|
| 65 |
+
## π οΈ Technical Details
|
| 66 |
|
| 67 |
+
### Detection Modes
|
| 68 |
+
- **Fast**: Quick detection for position finding
|
| 69 |
+
- **Accurate**: Balanced speed and accuracy
|
| 70 |
+
- **Hardcore**: Maximum accuracy with preprocessing
|
| 71 |
|
| 72 |
+
### Vertical Text Handling
|
| 73 |
+
- Automatic detection of vertical text regions
|
| 74 |
+
- 90Β° rotation for better OCR accuracy
|
| 75 |
+
- Proper coordinate mapping back to original image
|
| 76 |
|
| 77 |
+
### Text Correction
|
| 78 |
+
- Built-in correction rules for common OCR errors
|
| 79 |
+
- Tolerance parsing for engineering measurements
|
| 80 |
+
- Dimension validation and formatting
|
| 81 |
|
| 82 |
+
## π Performance
|
| 83 |
|
| 84 |
+
- **Processing Time**: 1-3 seconds per image
|
| 85 |
+
- **Accuracy**: 95%+ for clear technical drawings
|
| 86 |
+
- **Supported Languages**: English (optimized for numbers and dimensions)
|
| 87 |
+
- **Image Size**: Up to 10MB, auto-resized for processing
|
|
|
|
|
|
|
| 88 |
|
| 89 |
+
## π Use Cases
|
| 90 |
|
| 91 |
+
- **Engineering Drawings**: Extract dimensions and tolerances
|
| 92 |
+
- **Technical Documentation**: Digitize handwritten measurements
|
| 93 |
+
- **Quality Control**: Verify measurements on drawings
|
| 94 |
+
- **CAD Integration**: Convert scanned drawings to digital data
|
| 95 |
|
| 96 |
+
## π¨ Troubleshooting
|
| 97 |
|
| 98 |
+
### Common Issues
|
| 99 |
+
1. **Low Confidence**: Try "hardcore" mode or draw a rectangle around text
|
| 100 |
+
2. **Vertical Text**: Use the rotate button to improve detection
|
| 101 |
+
3. **Split Text**: Draw a rectangle to capture the full text
|
| 102 |
+
4. **Small Text**: Ensure image resolution is sufficient
|
| 103 |
|
| 104 |
+
### Tips for Best Results
|
| 105 |
+
- Use high-contrast images
|
| 106 |
+
- Ensure text is clearly visible
|
| 107 |
+
- For vertical text, use the rotate feature
|
| 108 |
+
- Draw rectangles around complex text regions
|
| 109 |
|
| 110 |
+
## π License
|
| 111 |
|
| 112 |
+
This project is part of the SPaCial AI system for technical drawing analysis.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 113 |
|
| 114 |
---
|
| 115 |
|
| 116 |
+
**Ready to extract text from your technical drawings? Upload an image and start detecting!** π―
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|