Calculating frame rate per second for object detection

조회 수: 26 (최근 30일)
Abdussalam Elhanashi
Abdussalam Elhanashi 2019년 11월 4일
답변: Wanbin Song 2019년 11월 10일
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);

채택된 답변

Wanbin Song
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개)

카테고리

Help CenterFile Exchange에서 Feature Detection and Extraction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by