How do I obtain the distance from the bounding boxes in YOLO v2/v3 in MATLAB?

44 views (last 30 days)
Hello,
I currently trained my dataset on both YOLO v2 and v3; however, I am not sure on how to obtain the distance using the corners of the bounding boxes?
Is there a specific function or loop that I need to use?
I appreciate all the feedback.

Answers (2)

Vineet Joshi
Vineet Joshi on 28 Oct 2021
Hi
The standard bounding box format in YOLOv2/v3 is a four dimentional vector described as follows.
[x y width height]
Using this you can find the coordinate of the four corners of the bounding box.
Once you have all four coordinates you can use the pdist function to find the distances.
The following resources will help.
Hope this helps
Thanks

yanqi liu
yanqi liu on 28 Oct 2021
sir, may be use the dice to compute Sørensen-Dice similarity coefficient for image segmentation
clc; clear all; close all;
RGB = imread('yellowlily.jpg');
region1 = [350 700 425 120]; % [x y w h] format
BW1 = false(size(RGB,1),size(RGB,2));
BW1(region1(2):region1(2)+region1(4),region1(1):region1(1)+region1(3)) = true;
region2 = [800 1124 120 230];
BW2 = false(size(RGB,1),size(RGB,2));
BW2(region2(2):region2(2)+region2(4),region2(1):region2(1)+region2(3)) = true;
region3 = [20 1320 480 200; 1010 290 180 240];
BW3 = false(size(RGB,1),size(RGB,2));
BW3(region3(1,2):region3(1,2)+region3(1,4),region3(1,1):region3(1,1)+region3(1,3)) = true;
BW3(region3(2,2):region3(2,2)+region3(2,4),region3(2,1):region3(2,1)+region3(2,3)) = true;
imshow(RGB)
hold on
visboundaries(BW1,'Color','r');
visboundaries(BW2,'Color','g');
visboundaries(BW3,'Color','b');
title('Seed Regions')
L = imseggeodesic(RGB,BW1,BW2,BW3,'AdaptiveChannelWeighting',true);
L_groundTruth = double(imread('yellowlily-segmented.png'));
similarity = dice(L, L_groundTruth)
similarity = 3×1
0.9396 0.7247 0.9139

Products


Release

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!