Hi Guys
I wantt help fpr following code instade of reading the frames of videos i want to read video as normal playing
load('Detector.mat');
vidReader = VideoReader('004.avi');
vidPlayer = vision.DeployableVideoPlayer;
i = 1;
results = struct('Boxes',[],'Scores',[]);
while(hasFrame(vidReader))
I = readFrame(vidReader);
step(vidPlayer,I);
i = i+1;

 Respuesta aceptada

Subhadeep Koley
Subhadeep Koley el 5 de Nov. de 2019

0 votos

Hi, your code is almost correct only you have add some pause() between every frame otherwise you won’t be able to see all the frames. The pause time should be ideally 1/FrameRate for viewing the video in its original speed. Refer to the code below.
vidReader = VideoReader('rhinos.avi'); % Read your video here
vidPlayer = vision.DeployableVideoPlayer;
while(hasFrame(vidReader))
I = readFrame(vidReader);
step(vidPlayer,I);
pause((1/vidReader.FrameRate)); % pause of value (1/FrameRate)
end
Or else if you only want to play the video you can use the function implay().
implay('rhinos.avi'); % Read your video here
And hit the ‘Play’ button.
Hope this helps!

3 comentarios

Abdussalam Elhanashi
Abdussalam Elhanashi el 5 de Nov. de 2019
Editada: Abdussalam Elhanashi el 5 de Nov. de 2019
Thanks Subhadeep Koley Just asking how can implement the this code in fact i am doing an object detection with R-CNN and i want to calculate the frame rate
load('Detector.mat');
vidReader = VideoReader('vn_002_00.avi');
vidPlayer = vision.DeployableVideoPlayer;
i = 1;
results = struct('Boxes',[],'Scores',[]);
while(hasFrame(vidReader))
I = readFrame(vidReader);
% PROCESS
[bboxes, scores, label] = detect(detector,I,'MiniBatchSize', 128);
% Select strongest detection
% New - Find those bounding boxes that surpassed a threshold
T = 0.58; % 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
end
step(vidPlayer,I);
i = i+1;
end
results = struct2table(results);
release(vidPlayer);
Subhadeep Koley
Subhadeep Koley el 5 de Nov. de 2019
In your code, the variable vidReader.FrameRate contains the frame rate of the video read by VideoReader.
Abdussalam Elhanashi
Abdussalam Elhanashi el 5 de Nov. de 2019
Editada: Abdussalam Elhanashi el 5 de Nov. de 2019
Hi Subhadeep Koley thanks for your comment how can i calculate the frame rate per second for object detection when i play the video because when i got the deployable video player it does not show f / s

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by