117 lines
2.6 KiB
Markdown
117 lines
2.6 KiB
Markdown
# Aggiornamento 2026-05-16 12:08
|
|
|
|
## Obiettivo
|
|
|
|
Implementare lato `flywms_wms_server.py` la prima pipeline WMS/OCR demo con finestre server.
|
|
|
|
## Implementazione server
|
|
|
|
Il server ora:
|
|
|
|
- riceve crop etichetta e metadati;
|
|
- salva `metadata.json`;
|
|
- esegue OCR sul crop etichetta;
|
|
- salva `wms_payload.json`;
|
|
- aggiorna una finestra OpenCV con l'immagine ricevuta;
|
|
- aggiorna una finestra OpenCV con il payload WMS dell'ultimo gaylord;
|
|
- risponde al client con `ACK/NACK` e codice OCR.
|
|
|
|
## OCR
|
|
|
|
Motore implementato:
|
|
|
|
- EasyOCR, se disponibile;
|
|
- fallback demo se OCR non legge nulla o se viene avviato con `--no-ocr`.
|
|
|
|
Sul crop di test, EasyOCR e' disponibile ma non ha letto testo utile; e' stato usato fallback:
|
|
|
|
```text
|
|
UDC-0001
|
|
```
|
|
|
|
Il payload indica esplicitamente:
|
|
|
|
```json
|
|
"ocr_backend": "fake",
|
|
"ocr_fallback_used": true
|
|
```
|
|
|
|
oppure `easyocr-fallback` quando EasyOCR gira ma non trova testo.
|
|
|
|
## Configurazione aggiunta
|
|
|
|
In `flywms_navigation.ini`:
|
|
|
|
```ini
|
|
wms_ui_enabled = true
|
|
wms_ocr_enabled = true
|
|
wms_ocr_mode = easyocr
|
|
wms_fake_ocr_prefix = UDC
|
|
wms_fake_ocr_delay_sec = 0.2
|
|
wms_operator = udrone
|
|
wms_site = demo-magazzino
|
|
```
|
|
|
|
Il server supporta anche:
|
|
|
|
```powershell
|
|
--no-ui
|
|
--no-ocr
|
|
```
|
|
|
|
per test headless.
|
|
|
|
## Client
|
|
|
|
Il client navigazione ora mostra anche il codice OCR ricevuto:
|
|
|
|
```text
|
|
OCR_CODICE UDC-0001
|
|
```
|
|
|
|
La risposta server include nel messaggio:
|
|
|
|
```text
|
|
codice valido su WMS: UDC-0001
|
|
```
|
|
|
|
## Verifiche
|
|
|
|
Compilazione:
|
|
|
|
```powershell
|
|
python -m py_compile flywms_wms_server.py flywms_navigation.py flywms_navigation_gui.py
|
|
```
|
|
|
|
Test OCR diretto sul crop etichetta:
|
|
|
|
```text
|
|
OcrServerResult(text='UDC-0001', raw_text='', confidence=0.0, backend='easyocr-fallback', fallback_used=True)
|
|
```
|
|
|
|
Test end-to-end server/client con server headless:
|
|
|
|
```powershell
|
|
python flywms_wms_server.py --host 127.0.0.1 --port 8088 --received-dir wms_received_test --fake-processing-sec 0.1 --fake-ocr-delay-sec 0 --no-ui --no-ocr
|
|
```
|
|
|
|
Client:
|
|
|
|
```powershell
|
|
python flywms_navigation.py --no-display --max-frames 6 --snapshot-line-tolerance-ratio 0.20 --snapshot-output-dir navigate_snapshots_test --preview-fps 0 --yolo-fps 0 --label-move-sec 0 --label-stabilization-sec 0 --label-return-sec 0 --remote-ack-timeout-sec 5 --wms-enabled --wms-server-url http://127.0.0.1:8088/api/v1/navigation-snapshot
|
|
```
|
|
|
|
Risultato:
|
|
|
|
```text
|
|
[WMS] risposta request_id=... status=ACK message=codice valido su WMS: UDC-0001
|
|
[WMS] ACK request_id=... snapshot=1 codice valido su WMS: UDC-0001
|
|
[CMD] RIPARTI_DESTRA
|
|
```
|
|
|
|
## Note
|
|
|
|
- La finestra server mostra l'ultimo payload ricevuto.
|
|
- Il server salva `wms_payload.json` oltre a `metadata.json`.
|
|
- L'esito `ACK/NACK` resta governato da `wms_fake_ack_mode`.
|