Calculating frame rate per second for object detection
11 views (last 30 days)
Show older comments
Abdussalam Elhanashi
on 4 Nov 2019
Answered: Wanbin Song
on 10 Nov 2019
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 Comments
Accepted Answer
Wanbin Song
on 10 Nov 2019
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 Comments
More Answers (0)
See Also
Categories
Find more on Feature Detection and Extraction in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!