Calculating frame rate per second for object detection

33 visualizaciones (últimos 30 días)
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);

Respuesta aceptada

Wanbin Song
Wanbin Song el 10 de Nov. de 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');

Más respuestas (0)

Community Treasure Hunt

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

Start Hunting!

Translated by