enlarge label

This commit is contained in:
anetla 2024-01-21 22:20:43 +01:00
parent aa4fb49423
commit c85341133e

View File

@ -373,7 +373,7 @@
canvas.height = img.height; canvas.height = img.height;
ctx.drawImage(img, 0, 0); ctx.drawImage(img, 0, 0);
ctx.lineWidth = 15; ctx.lineWidth = 15;
ctx.font = "bold 50px Arial"; // Zwiększono rozmiar czcionki ctx.font = "bold 70px Arial"; // Zwiększono rozmiar czcionki
// Draw bounding boxes // Draw bounding boxes
boxes.forEach(([x1, y1, x2, y2, object_type, prob]) => { boxes.forEach(([x1, y1, x2, y2, object_type, prob]) => {
@ -402,7 +402,6 @@
break; break;
} }
const label = `${object_type}`;
// Przypisz różne kolory do różnych klas // Przypisz różne kolory do różnych klas
let boxColor; let boxColor;
@ -429,13 +428,13 @@
boxColor = "#000000"; boxColor = "#000000";
break; break;
} }
const label = `${object_type}`;
ctx.strokeStyle = boxColor; ctx.strokeStyle = boxColor;
ctx.strokeRect(x1, y1, x2 - x1, y2 - y1); ctx.strokeRect(x1, y1, x2 - x1, y2 - y1);
ctx.fillStyle = boxColor; ctx.fillStyle = boxColor;
const width = ctx.measureText(label).width; const width = ctx.measureText(label).width;
ctx.fillRect(x1, y1, width + 10, 25); ctx.fillRect(x1, y1 - 40, width + 10, 70);
ctx.fillStyle = "#000000"; ctx.fillStyle = "#000000";
ctx.fillText(label, x1, y1 + 10 ); // Przesunięcie etykiety ctx.fillText(label, x1, y1 + 10 ); // Przesunięcie etykiety
}); });