pipeline in linea single thread
This commit is contained in:
166
aggiornamento-2026-05-18-14-58.md
Normal file
166
aggiornamento-2026-05-18-14-58.md
Normal file
@@ -0,0 +1,166 @@
|
||||
# Aggiornamento 2026-05-18 14:58
|
||||
|
||||
## Obiettivo
|
||||
|
||||
Integrare PaddleOCR nel server WMS demo, senza modificare la GUI e senza integrare ancora una interfaccia DearPyGUI.
|
||||
|
||||
## Implementazione
|
||||
|
||||
Creato worker persistente:
|
||||
|
||||
```text
|
||||
C:\devel\flywms\flywms_paddleocr_worker.py
|
||||
```
|
||||
|
||||
Il worker gira con il virtualenv isolato:
|
||||
|
||||
```text
|
||||
C:\devel\yolo-ocr\.venv-paddle-cpu\Scripts\python.exe
|
||||
```
|
||||
|
||||
Il server WMS resta nel suo ambiente Python attuale e comunica col worker via stdin/stdout JSON. Questo evita il problema del Paddle GPU globale:
|
||||
|
||||
```text
|
||||
WinError 127 su cudnn_cnn64_9.dll
|
||||
```
|
||||
|
||||
## Server WMS
|
||||
|
||||
Aggiornato:
|
||||
|
||||
```text
|
||||
C:\devel\flywms\flywms_wms_server.py
|
||||
```
|
||||
|
||||
Nuovo backend OCR:
|
||||
|
||||
```text
|
||||
--ocr-mode paddleocr
|
||||
```
|
||||
|
||||
Backend disponibili:
|
||||
|
||||
```text
|
||||
paddleocr
|
||||
easyocr
|
||||
tesseract
|
||||
fake
|
||||
```
|
||||
|
||||
Il worker PaddleOCR resta caricato tra richieste successive, quindi non ricarica il modello a ogni snapshot.
|
||||
|
||||
## Parametri INI
|
||||
|
||||
Aggiornato:
|
||||
|
||||
```text
|
||||
C:\devel\flywms\flywms_navigation.ini
|
||||
```
|
||||
|
||||
Nuovi parametri:
|
||||
|
||||
```text
|
||||
wms_ocr_mode = paddleocr
|
||||
wms_paddle_python = C:\devel\yolo-ocr\.venv-paddle-cpu\Scripts\python.exe
|
||||
wms_paddle_worker_script = C:\devel\flywms\flywms_paddleocr_worker.py
|
||||
wms_paddle_target_heights = 96
|
||||
wms_paddle_variant_set = fast
|
||||
wms_paddle_expected_digits = 6
|
||||
wms_paddle_min_votes = 2
|
||||
wms_paddle_min_confidence = 0.70
|
||||
```
|
||||
|
||||
Aggiornati anche i timeout, perche' PaddleOCR CPU richiede piu' di 2 secondi:
|
||||
|
||||
```text
|
||||
remote_ack_timeout_sec = 10.0
|
||||
wms_timeout_sec = 12.0
|
||||
```
|
||||
|
||||
## Logica OCR
|
||||
|
||||
La configurazione `fast` prova 3 varianti:
|
||||
|
||||
```text
|
||||
originale
|
||||
CLAHE
|
||||
CLAHE + sharpening
|
||||
```
|
||||
|
||||
Il codice viene accettato solo se:
|
||||
|
||||
- e' numerico;
|
||||
- ha 6 cifre;
|
||||
- ha almeno 2 voti tra le varianti;
|
||||
- supera la confidenza minima.
|
||||
|
||||
In caso contrario il server restituisce:
|
||||
|
||||
```text
|
||||
udc non determinato
|
||||
```
|
||||
|
||||
## Test eseguiti
|
||||
|
||||
Compilazione:
|
||||
|
||||
```text
|
||||
python -m py_compile flywms_wms_server.py flywms_paddleocr_worker.py
|
||||
```
|
||||
|
||||
Test worker diretto:
|
||||
|
||||
```text
|
||||
input: snapshot_0019_track_123_label_payload_orig.jpg
|
||||
output: 182368
|
||||
votes: 3
|
||||
backend: paddleocr
|
||||
```
|
||||
|
||||
Test server locale senza GUI:
|
||||
|
||||
```powershell
|
||||
python C:\devel\flywms\flywms_wms_server.py --no-ui --port 8098 --received-dir C:\devel\flywms\wms_received_test --ocr-mode paddleocr --paddle-variant-set fast --fake-processing-sec 0
|
||||
```
|
||||
|
||||
Richiesta 1:
|
||||
|
||||
```text
|
||||
ocr_text: 182368
|
||||
ocr_backend: paddleocr
|
||||
ocr_fallback_used: false
|
||||
ocr_votes: 3
|
||||
processing_ms: circa 8500 ms
|
||||
```
|
||||
|
||||
Richiesta 2 con worker gia' caldo:
|
||||
|
||||
```text
|
||||
ocr_text: 187184
|
||||
ocr_backend: paddleocr
|
||||
ocr_fallback_used: false
|
||||
ocr_votes: 3
|
||||
processing_ms: circa 3200 ms
|
||||
```
|
||||
|
||||
## Nota prestazionale
|
||||
|
||||
Il primo snapshot paga il caricamento del worker PaddleOCR. Gli snapshot successivi sono piu' veloci ma restano nell'ordine di qualche secondo su CPU.
|
||||
|
||||
Per il demo va bene, ma il timeout del client deve restare piu' alto del vecchio valore da 2 secondi.
|
||||
|
||||
## Prossimo passo
|
||||
|
||||
Avviare il server:
|
||||
|
||||
```powershell
|
||||
python flywms_wms_server.py
|
||||
```
|
||||
|
||||
Poi avviare la navigazione:
|
||||
|
||||
```powershell
|
||||
python flywms_navigation.py --wms-enabled
|
||||
```
|
||||
|
||||
Verificare nella finestra comandi che compaia il codice OCR restituito dal WMS.
|
||||
Reference in New Issue
Block a user