Measuring the distance between Bounding box and change their colors for certain condition
2 次查看(过去 30 天)
显示 更早的评论
Hi guys
I am using yolov2 for object detection and i want to implement the following issue for my code
i want to make a condition in the time when two or more bounding boxes are near each other for instance 6 feet or less , the color of bounding box need to change its color from green to red. And once these bounding boxes of detected objects get away from each other more than 6 feet the color of these bounding boxes change back from red to green color
6 feet from bounding box to another
Herein my code
close all
clc
load('detectorYolo2.mat');
vidReader = VideoReader('vn_045_00.avi');
vidPlayer = vision.DeployableVideoPlayer;
i = 1;
results = struct('Boxes',[],'Scores',[]);
while(hasFrame(vidReader))
% GET DATA
I = readFrame(vidReader);
fps = 0;
avgfps = [];
tic;
% PROCESS
[bboxes, scores,label] = detect(detectorYolo2,I,'Threshold',0.4);
newt = toc;
% fps
fps = .9*fps + .1*(1/newt);
avgfps = [avgfps, fps]; %#ok<AGROW>
% Select strongest detection
T = 0.0; % Define threshold here
idx = scores >= T;
% Retrieve those scores that surpassed the threshold
s = scores(idx);
% Do the same for the labels as well
lbl = label(idx);
bboxes = bboxes(idx, :); % This logic doesn't change
for ii = 1 : size(bboxes, 1)
annotation = sprintf('%s: (Confidence = %f)', lbl(ii), s(ii)); % Change
I = insertObjectAnnotation(I, 'rectangle', bboxes(ii,:), annotation); % New - Choose the right box
I = insertText(I , [1, 1], sprintf('FPS %2.2f', fps));
end
step(vidPlayer,I);
i = i+1;
end
results = struct2table(results);
release(vidPlayer);
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Segmentation and Analysis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!