feat(web): bottone Auto-tune nella toolbar (Halcon-style)
UI esponev gia' /auto_tune endpoint ma non c'era trigger user-facing. Aggiunto bottone toolbar accanto a MATCH: - Calcola tutti i parametri tecnici dalla ROI selezionata (gradient, feature, piramide, angle_step, simmetria) - Esegue self-validation training+find su template - Applica i valori derivati ai campi della sezione Avanzate - Mostra alert con riepilogo + meta diagnostica (simmetria detected, self-validation result, ecc.) Endpoint /auto_tune ora ritorna anche meta (_self_score, _validation, _symmetry_order, _orient_entropy) per feedback UI invece di filtrarli. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -400,6 +400,53 @@ function setStatus(s) {
|
||||
}
|
||||
|
||||
// ---------- Init ----------
|
||||
// ---------- Auto-tune (Halcon-style) ----------
|
||||
async function doAutoTune() {
|
||||
if (!state.model || !state.roi) {
|
||||
alert("Seleziona modello e disegna ROI prima di Auto-tune.");
|
||||
return;
|
||||
}
|
||||
const status = document.getElementById("status");
|
||||
status.textContent = "Analisi ROI in corso...";
|
||||
try {
|
||||
const r = await fetch("/auto_tune", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({
|
||||
model_id: state.model.id,
|
||||
roi: state.roi,
|
||||
}),
|
||||
});
|
||||
if (!r.ok) throw new Error(await r.text());
|
||||
const t = await r.json();
|
||||
// Applica ai campi avanzati (override automatico)
|
||||
for (const [key] of ADV_PARAMS) {
|
||||
const el = document.getElementById(`adv-${key}`);
|
||||
if (el && t[key] !== undefined) el.value = String(t[key]);
|
||||
}
|
||||
// Espandi la sezione Avanzate per mostrare i valori applicati
|
||||
const advDetails = document.querySelector("#col-params details:last-of-type");
|
||||
if (advDetails) advDetails.open = true;
|
||||
// Feedback diagnostico
|
||||
const lines = [
|
||||
`weak/strong: ${t.weak_grad} / ${t.strong_grad}`,
|
||||
`feature: ${t.num_features}, piramide: ${t.pyramid_levels}`,
|
||||
`angle: [${t.angle_min}..${t.angle_max}]@${t.angle_step}°`,
|
||||
];
|
||||
if (t._symmetry_order > 1) {
|
||||
lines.push(`simmetria rotaz. ${t._symmetry_order}x (conf ${t._symmetry_conf})`);
|
||||
}
|
||||
if (t._self_score !== undefined) {
|
||||
lines.push(`self-validation: ${t._validation}`);
|
||||
}
|
||||
status.textContent = `Auto-tune OK — ${lines[0]}`;
|
||||
alert("Auto-tune completato:\n\n" + lines.join("\n"));
|
||||
} catch (e) {
|
||||
status.textContent = `Auto-tune errore: ${e.message}`;
|
||||
alert(`Errore auto-tune: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
// ---------- V: Save recipe ----------
|
||||
async function saveRecipe() {
|
||||
if (!state.model || !state.roi) {
|
||||
@@ -465,6 +512,7 @@ window.addEventListener("DOMContentLoaded", async () => {
|
||||
e.target.value = ""; // consente re-upload stesso file
|
||||
});
|
||||
document.getElementById("btn-match").addEventListener("click", doMatch);
|
||||
document.getElementById("btn-autotune").addEventListener("click", doAutoTune);
|
||||
document.getElementById("btn-save-recipe").addEventListener("click",
|
||||
saveRecipe);
|
||||
const slider = document.getElementById("p-min-score");
|
||||
|
||||
@@ -26,6 +26,10 @@
|
||||
<div class="picker-list"></div>
|
||||
</div>
|
||||
<button class="btn btn-go" id="btn-match">▶ MATCH</button>
|
||||
<button class="btn" id="btn-autotune"
|
||||
title="Analizza ROI e derivata parametri ottimali (Halcon-style)">
|
||||
⚙ Auto-tune
|
||||
</button>
|
||||
<label class="btn" title="Carica nuovo file nella cartella immagini">
|
||||
⬆ Carica file
|
||||
<input type="file" id="file-upload" accept="image/*" hidden>
|
||||
|
||||
Reference in New Issue
Block a user