Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var angle = 0;
- function setup() {
- createCanvas(400, 400);
- }
- function draw() {
- background(255);
- noFill();
- rect(200, 200, 55, 100);
- ellipse(255, 200, 80);
- // Calculate target box coordinate
- x = 180;
- w = 255 - 40 * sin(angle) - 180;
- y = 200 + 40 * cos(angle);
- h = 310 - y;
- rect(x, y, w, h);
- // Calculate IoU
- xmin_max = max(200, x);
- xmin_min = min(200, x);
- xmax_min = min(255, x+w);
- xmax_max = max(255, x+w);
- ymin_max = max(200, y);
- ymin_min = min(200, y);
- ymax_min = min(300, y+h);
- ymax_max = max(300, y+h);
- iou = ((xmax_min - xmin_max) * (ymax_min - ymin_max)) / (w * h + 55 * 100 - (xmax_min - xmin_max) * (ymax_min - ymin_max))
- iou = iou.toFixed(2)
- textSize(32);
- fill(0, 102, 153);
- text('iou = ' + str(iou), 50, 150);
- // Update angle
- if (angle >= (2 * PI)) {
- angle = 0;
- } else {
- angle += (PI / 200);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement