radames commited on
Commit
cb43957
1 Parent(s): c18de0d

minor font/border

Browse files
Files changed (1) hide show
  1. index.html +6 -2
index.html CHANGED
@@ -179,6 +179,8 @@
179
  canvas.width = canvasInput.width;
180
  canvas.height = canvasInput.height;
181
 
 
 
182
  const ctx = canvas.getContext("2d");
183
  ctx.drawImage(canvasInput, 0, 0);
184
  const imageURL = canvas.toDataURL();
@@ -195,9 +197,11 @@
195
 
196
  const { output } = results;
197
 
198
- ctx.lineWidth = 2;
199
  ctx.strokeStyle = "#3c8566";
200
  ctx.fillStyle = "#0dff9a";
 
 
201
  for (const [label, bbox] of output) {
202
  const [x, y, w, h] = [
203
  bbox.xmin,
@@ -211,7 +215,7 @@
211
  const text = `${label} ${confidence.toFixed(2)}`;
212
  const width = ctx.measureText(text).width;
213
  ctx.fillStyle = "#3c8566";
214
- ctx.fillRect(x - 2, y - 12, width + 4, 14);
215
  ctx.fillStyle = "#e3fff3";
216
 
217
  ctx.strokeRect(x, y, w, h);
 
179
  canvas.width = canvasInput.width;
180
  canvas.height = canvasInput.height;
181
 
182
+ const scale = canvas.width / canvas.offsetWidth;
183
+
184
  const ctx = canvas.getContext("2d");
185
  ctx.drawImage(canvasInput, 0, 0);
186
  const imageURL = canvas.toDataURL();
 
197
 
198
  const { output } = results;
199
 
200
+ ctx.lineWidth = 1 + 2 * scale;
201
  ctx.strokeStyle = "#3c8566";
202
  ctx.fillStyle = "#0dff9a";
203
+ const fontSize = 14 * scale;
204
+ ctx.font = `${fontSize}px sans-serif`;
205
  for (const [label, bbox] of output) {
206
  const [x, y, w, h] = [
207
  bbox.xmin,
 
215
  const text = `${label} ${confidence.toFixed(2)}`;
216
  const width = ctx.measureText(text).width;
217
  ctx.fillStyle = "#3c8566";
218
+ ctx.fillRect(x - 2, y - fontSize, width + 4, fontSize);
219
  ctx.fillStyle = "#e3fff3";
220
 
221
  ctx.strokeRect(x, y, w, h);