Calculating frame rate per second for object detection
26 次查看(过去 30 天)
显示 更早的评论
Hi Guys
Kindly i want to know how to calculate framerate per second for object detection using R-CNN in the following code:-
close all
clear
clc
load('Detector.mat');
vidReader = VideoReader('vs_014_00.avi');
vidPlayer = vision.DeployableVideoPlayer;
i = 1;
results = struct('Boxes',[],'Scores',[]);
while(hasFrame(vidReader))
% GET DATA
I = readFrame(vidReader);
% PROCESS
[bboxes, scores] = detect(detector,I,'Threshold',1);
% Select strongest detection
[~,idx] = max(scores);
results(i).Boxes = bboxes;
results(i).Scores = scores;
% VISUALIZE
annotation = sprintf('%s , (Confidence = %f)',detector.ModelName,scores(idx));
I = insertObjectAnnotation(I,'rectangle',bboxes(idx,:),annotation);
step(vidPlayer,I);
i = i+1;
end
results = struct2table(results);
release(vidPlayer);
0 个评论
采纳的回答
Wanbin Song
2019-11-10
You can add some of code as belows:
Declare some variables before while loop as below:
fps = 0;
avgfps = [];
Include below tic/toc commands and fps inside the loop.
tic;
[bboxes, scores] = detect(detector,I,'Threshold',1);
newt = toc;
% fps
fps = .9*fps + .1*(1/newt);
avgfps = [avgfps, fps];
Include below for fps visualization.
I = insertText(I , [1, 1], sprintf('FPS %2.2f', fps), 'FontSize', 26, 'BoxColor', 'y');
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Feature Detection and Extraction 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!