feat(web): wiring UI per modalita Halcon (M, Y, Z, V, X, R + altri)
UI espone tutti i nuovi flag tramite sezione pieghevole "Modalita Halcon" nel pannello impostazioni. Default off = comportamento backward compat. Flag esposti (checkbox + numerici): - use_polarity (F): 16-bin orientation mod 2pi - use_gpu (R): OpenCL UMat con silent fallback CPU - use_soft_score (Y): score continuo cos(theta_t-theta_s) - subpixel_lm (Z): refinement 0.05 px gradient field - refine_pose_joint: Nelder-Mead 3D (cx,cy,theta) - pyramid_propagate: top-K propagation a full-res - min_recall (M): filtro feature-recall - nms_iou_threshold (A): IoU bbox poligonale - greediness: early-exit kernel - coarse_stride: sub-sampling top-level - search_roi: x,y,w,h area di ricerca Persistenza ricette (V): - Endpoint POST /recipes: training + save .npz in recipes/ - Endpoint GET /recipes: lista - UI: campo nome + bottone "Salva" sotto i flag Server SimpleMatchParams esteso con tutti i campi; pipeline match_simple propaga init-flags al cache key (use_polarity/use_gpu = retrain) e find-flags al m.find(). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,39 @@ function readUserParams() {
|
||||
document.getElementById("p-penalita-scala").value),
|
||||
min_score: parseFloat(document.getElementById("p-min-score").value),
|
||||
max_matches: parseInt(document.getElementById("p-max-matches").value, 10),
|
||||
...readHalconFlags(),
|
||||
};
|
||||
}
|
||||
|
||||
function readHalconFlags() {
|
||||
// Halcon-mode toggle: tutti i flag default-off, esposti via "Modalità Halcon"
|
||||
const $cb = (id) => document.getElementById(id)?.checked ?? false;
|
||||
const $num = (id, def) => {
|
||||
const v = parseFloat(document.getElementById(id)?.value);
|
||||
return Number.isFinite(v) ? v : def;
|
||||
};
|
||||
const $int = (id, def) => {
|
||||
const v = parseInt(document.getElementById(id)?.value, 10);
|
||||
return Number.isFinite(v) ? v : def;
|
||||
};
|
||||
const roiStr = document.getElementById("hc-search-roi")?.value.trim() ?? "";
|
||||
let search_roi = null;
|
||||
if (roiStr) {
|
||||
const p = roiStr.split(/[ ,;]+/).map((x) => parseInt(x, 10));
|
||||
if (p.length === 4 && p.every((v) => Number.isFinite(v))) search_roi = p;
|
||||
}
|
||||
return {
|
||||
use_polarity: $cb("hc-use-polarity"),
|
||||
use_gpu: $cb("hc-use-gpu"),
|
||||
use_soft_score: $cb("hc-soft-score"),
|
||||
subpixel_lm: $cb("hc-subpixel-lm"),
|
||||
refine_pose_joint: $cb("hc-refine-joint"),
|
||||
pyramid_propagate: $cb("hc-pyr-propagate"),
|
||||
min_recall: $num("hc-min-recall", 0),
|
||||
nms_iou_threshold: $num("hc-nms-iou", 0.3),
|
||||
greediness: $num("hc-greediness", 0),
|
||||
coarse_stride: $int("hc-coarse-stride", 1),
|
||||
search_roi: search_roi,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -367,6 +400,44 @@ function setStatus(s) {
|
||||
}
|
||||
|
||||
// ---------- Init ----------
|
||||
// ---------- V: Save recipe ----------
|
||||
async function saveRecipe() {
|
||||
if (!state.model || !state.roi) {
|
||||
alert("Seleziona modello e disegna ROI prima di salvare la ricetta.");
|
||||
return;
|
||||
}
|
||||
const name = document.getElementById("hc-recipe-name").value.trim();
|
||||
if (!name) {
|
||||
alert("Inserisci un nome per la ricetta.");
|
||||
return;
|
||||
}
|
||||
const user = readUserParams();
|
||||
const body = {
|
||||
model_id: state.model.id,
|
||||
scene_id: state.scene?.id || state.model.id,
|
||||
roi: state.roi,
|
||||
tipo: user.tipo,
|
||||
simmetria: user.simmetria,
|
||||
scala: user.scala,
|
||||
precisione: user.precisione,
|
||||
use_polarity: user.use_polarity,
|
||||
use_gpu: user.use_gpu,
|
||||
name: name,
|
||||
};
|
||||
try {
|
||||
const r = await fetch("/recipes", {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
});
|
||||
if (!r.ok) throw new Error(await r.text());
|
||||
const j = await r.json();
|
||||
alert(`Ricetta salvata: ${j.name}\n${j.n_variants} varianti, ${j.size} bytes`);
|
||||
} catch (e) {
|
||||
alert(`Errore salvataggio: ${e.message}`);
|
||||
}
|
||||
}
|
||||
|
||||
window.addEventListener("DOMContentLoaded", async () => {
|
||||
buildAdvancedForm();
|
||||
setupROI();
|
||||
@@ -394,6 +465,8 @@ window.addEventListener("DOMContentLoaded", async () => {
|
||||
e.target.value = ""; // consente re-upload stesso file
|
||||
});
|
||||
document.getElementById("btn-match").addEventListener("click", doMatch);
|
||||
document.getElementById("btn-save-recipe").addEventListener("click",
|
||||
saveRecipe);
|
||||
const slider = document.getElementById("p-min-score");
|
||||
slider.addEventListener("input", (e) => {
|
||||
document.getElementById("v-score").textContent =
|
||||
|
||||
@@ -129,6 +129,67 @@
|
||||
<input type="number" id="p-max-matches" value="25" min="1" max="200">
|
||||
</div>
|
||||
|
||||
<details>
|
||||
<summary>Modalità Halcon</summary>
|
||||
<div class="halcon-grid">
|
||||
<label class="hc-row" title="16-bin orientation polarity-aware (mod 2π)">
|
||||
<input type="checkbox" id="hc-use-polarity">
|
||||
<span>Polarity 16-bin (F)</span>
|
||||
</label>
|
||||
<label class="hc-row" title="Score continuo cos(θ_t-θ_s) invece di bin">
|
||||
<input type="checkbox" id="hc-soft-score">
|
||||
<span>Soft-margin score (Y)</span>
|
||||
</label>
|
||||
<label class="hc-row" title="Sub-pixel refinement gradient field LM">
|
||||
<input type="checkbox" id="hc-subpixel-lm">
|
||||
<span>Sub-pixel LM 0.05 px (Z)</span>
|
||||
</label>
|
||||
<label class="hc-row" title="Refine congiunto Nelder-Mead (cx,cy,θ)">
|
||||
<input type="checkbox" id="hc-refine-joint">
|
||||
<span>Refine pose joint</span>
|
||||
</label>
|
||||
<label class="hc-row" title="Pyramid candidates propagation">
|
||||
<input type="checkbox" id="hc-pyr-propagate">
|
||||
<span>Pyramid propagate</span>
|
||||
</label>
|
||||
<label class="hc-row" title="OpenCL GPU offload (silent fallback CPU)">
|
||||
<input type="checkbox" id="hc-use-gpu">
|
||||
<span>GPU OpenCL (R)</span>
|
||||
</label>
|
||||
|
||||
<div class="hc-row hc-num">
|
||||
<label>Min recall (M)</label>
|
||||
<input type="number" id="hc-min-recall" value="0.0" min="0" max="1" step="0.05">
|
||||
</div>
|
||||
<div class="hc-row hc-num">
|
||||
<label>NMS IoU thr (A)</label>
|
||||
<input type="number" id="hc-nms-iou" value="0.3" min="0" max="1" step="0.05">
|
||||
</div>
|
||||
<div class="hc-row hc-num">
|
||||
<label>Greediness</label>
|
||||
<input type="number" id="hc-greediness" value="0.0" min="0" max="1" step="0.1">
|
||||
</div>
|
||||
<div class="hc-row hc-num">
|
||||
<label>Coarse stride</label>
|
||||
<input type="number" id="hc-coarse-stride" value="1" min="1" max="4" step="1">
|
||||
</div>
|
||||
<div class="hc-row hc-num" style="grid-column:1/-1">
|
||||
<label title="Limita area di ricerca scena: x,y,w,h (vuoto = tutta scena)">
|
||||
Search ROI (x,y,w,h)
|
||||
</label>
|
||||
<input type="text" id="hc-search-roi" placeholder="es. 100,50,800,400">
|
||||
</div>
|
||||
|
||||
<div class="hc-row" style="grid-column:1/-1; border-top:1px solid #444; padding-top:8px">
|
||||
<label>Ricetta pre-trained (V)</label>
|
||||
<div style="display:flex; gap:6px; margin-top:4px">
|
||||
<input type="text" id="hc-recipe-name" placeholder="nome_ricetta" style="flex:1">
|
||||
<button class="btn" id="btn-save-recipe" type="button">💾 Salva</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>Avanzate</summary>
|
||||
<div id="adv-form"></div>
|
||||
|
||||
@@ -156,3 +156,20 @@ footer h2 {
|
||||
}
|
||||
|
||||
#col-model, #col-scene { min-width: 0; }
|
||||
|
||||
/* Halcon-mode panel */
|
||||
.halcon-grid {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 6px 12px;
|
||||
margin-top: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
.hc-row {
|
||||
display: flex; align-items: center; gap: 6px;
|
||||
}
|
||||
.hc-row.hc-num {
|
||||
flex-direction: column; align-items: flex-start;
|
||||
}
|
||||
.hc-row.hc-num label { font-size: 11px; color: #aaa; }
|
||||
.hc-row.hc-num input { width: 100%; }
|
||||
|
||||
Reference in New Issue
Block a user