feat: interfaccia web HTML (FastAPI + canvas JS)

Sostituisce GUI cv2/tkinter con webapp standalone:

Server (pm2d/web/server.py):
- FastAPI + uvicorn
- Endpoint: GET /, POST /upload, POST /match, POST /auto_tune,
  GET /image/{id}/raw
- In-memory image store (uuid-based)
- Rendering annotated server-side via opencv (overlay bbox + edges
  template warpati)

Frontend (pm2d/web/static/):
- index.html: layout 3 colonne (MODELLO | SCENA | PARAMETRI) + footer
  legenda
- style.css: tema dark, CSS grid responsive
- app.js: canvas HTML5 per visualizzazione scalata fit,
  ROI selection con drag mouse, form parametri live,
  MATCH button, Auto-tune button

Parametri modificabili INLINE (niente dialog separata).
Enter su qualsiasi campo triggera MATCH.
Legenda match in fondo con pallino colorato + dati.

main.py ora lancia il server webapp. Deprecato ingresso GUI cv2
(pm2d/gui.py resta importable per backward compat).

Test: /match su rings_and_nuts: 3/3 ruote in 1.14s (train 0.36s + find 0.77s).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-24 09:06:25 +02:00
parent 4ddda1ec62
commit fd7585acc5
8 changed files with 1234 additions and 20 deletions
+4 -20
View File
@@ -1,26 +1,10 @@
"""Entry-point standalone Pattern Matching 2D shape-based.
"""Entry-point PM2D — webapp HTML.
Esegui: uv run python main.py
Apri: http://127.0.0.1:8080/
"""
from pathlib import Path
from pm2d.gui import run
from pm2d.web.server import serve
if __name__ == "__main__":
test_dir = Path(__file__).parent / "Test"
run(
initial_dir=str(test_dir) if test_dir.is_dir() else None,
angle_range_deg=(0.0, 360.0),
angle_step_deg=5.0,
scale_range=(1.0, 1.0),
scale_step=0.1,
num_features=96,
weak_grad=30.0,
strong_grad=60.0,
spread_radius=5,
pyramid_levels=3,
min_score=0.55,
max_matches=25,
backend="line",
)
serve(host="127.0.0.1", port=8080)