nicknochnack / TFODApp

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fix bounding box canvas rect

ArmaanAS opened this issue · comments

Width and height should be be renamed to a and b as it the position of the bottom right corner.

const [y,x,height,width] = boxes[i]

const [y,x,b,a] = boxes[i]; 

Also we can fix this canvas rect draw as it currently draws a box with the wrong width and height. The function takes the top left x, y and a width, height.

ctx.rect(x*imgWidth, y*imgHeight, width*imgWidth/2, height*imgHeight/2);

ctx.rect(
  x * imgWidth, 
  y * imgHeight, 
  (a - x) * imgWidth, 
  (b - y) * imgHeight
);