Extracting Frames and resizing each frame

Hy, i convert YUV video file to frames but now i want to change size of every frames , how can i do that?
My code is:
clc; clear; close all;
VideoSequence = 'sampleQCIF.yuv';
width = 176;
height = 144;
nframes = 300;
[Y,U,V] = yuvRead(VideoSequence, width, height, nframes);
figure;
c = 0; % counter
for iFrame = 1:10
c = c + 1;
subplot(4,5,c),
imshow(Y(:,:,iFrame));
title(['frame #', num2str(iFrame)]);
end

6 comentarios

Walter Roberson
Walter Roberson el 15 de Feb. de 2019
imresize
Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
I also tried imresize but again blank figure appers in MATLAB without showing any image.
Actually when i convert "akiyo.yuv" into frames. the dimension of those frames was 1x1 and i am unable to open those frames thats why i want to change dimension .
I am using imresize but again same problem, blank fig appears.
Walter Roberson
Walter Roberson el 15 de Feb. de 2019
when you see 1x1 dimension what is class() of that variable ?
Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
i already convert YUV video to frames but unable to open in laptop. any solution?
Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
Name Size Bytes Class Attributes
RGB 1x1 1 uint8
columns 1x1 8 double
grayImage 1x1 1 uint8
rows 1x1 8 double
This is about class.
Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
sorry, my problem is different.
I attached original Matlab code and also output.
This code extract frames from YUV video precisley, but when i save those frames in laptop folder,they are not opening.
kinfly check my attach code and output.

Iniciar sesión para comentar.

Respuestas (2)

KALYAN ACHARJYA
KALYAN ACHARJYA el 15 de Feb. de 2019
Editada: madhan ravi el 15 de Feb. de 2019
Frames are images use the following, read here imresize
frame_resize=imresize(frame_names,scaling_value)
For multiple frames, you can call those and do the same. Also similar question answer is available, please look here, still unable to solve it, let me know.

15 comentarios

Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
I extract YUV video and frames dimension is 1x1. When i try resize image again blank figure appears in Matlab? Please, tell me solution.
Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
sorry, my problem is different.
I attached original Matlab code and also output.
This code extract frames from YUV video precisley, but when i save those frames in laptop folder,they are not opening.
kinfly check my attach code and output
Walter Roberson
Walter Roberson el 15 de Feb. de 2019
You imwrite(iFrame) but iFrame is just your loop counter.
Please show size(Y), class(Y), min(Y(:)), max(Y(:))
Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
I am attaching also main function of YUV read, Kindly check.
This code display frames in matlab figure properly but when i save this and want to open in laptop, so not opening, and frames dimension is also 1 cross 1.
Walter Roberson
Walter Roberson el 15 de Feb. de 2019
You should be imwrite(Y(:,:,iFrame), ....) not imwrite(iFrame, ...)
Iqra Saleem
Iqra Saleem el 15 de Feb. de 2019
when i try to run the code according to your comments then this error occurs, check the attachment
Walter Roberson
Walter Roberson el 15 de Feb. de 2019
Somewhere in your yuvRead.m file, on a line before the "function" line, you have an executable line. That executable line must be removed or commented out.
Iqra Saleem
Iqra Saleem el 16 de Feb. de 2019
I am attaching yuvRead.m file. Kindly check it our and tell me where the exectuable line is.
Walter Roberson
Walter Roberson el 16 de Feb. de 2019
get rid of the clear and close statements .
The only time you should ever have "clear all" is as part of a script that is intended to reset matlab to prepare for new work . In any situation in which do not intend to effectively quit and reenter matlab then you should not have a "clear all"
Iqra Saleem
Iqra Saleem el 16 de Feb. de 2019
i removed clear and close statements, but again the problem arise.
Now i attach the images which are shown in MATLAB and images which are not opening in matlab folder. If you see this you can easily understand.
Walter Roberson
Walter Roberson el 16 de Feb. de 2019
Editada: Walter Roberson el 16 de Feb. de 2019
as I told you 9 hourss ago you need to imwrite Y(:,:,iFrame) not iFrame. Your iFrame variable is your image counter not the content of that image .
Iqra Saleem
Iqra Saleem el 16 de Feb. de 2019
yes, i do the same thing as you said, but again error comes : unable to determine the file format"
check attachments.
Walter Roberson
Walter Roberson el 16 de Feb. de 2019
That error message does not correspond to the code you show.
Iqra Saleem
Iqra Saleem el 17 de Feb. de 2019
oh sorry, now again check attachments.
Walter Roberson
Walter Roberson el 17 de Feb. de 2019
Why did you remove the basefilename / fullfile code ? You are now specifying the name of a folder as the only output location. MATLAB will not be able to automatically figure out what file name to output to by guessing that you want to use the same output file name as the last file you input: you need to tell it the output file name.
I am not going to bother to type in the repaired code for you by reading your code off of your image. If you continue to have problems with this, post your code as code.

Iniciar sesión para comentar.

kousar majeed
kousar majeed el 14 de Jun. de 2019

0 votos

how can i extract the frame and save like 1-1.jpg in the folder with the name frame folder

3 comentarios

projectdir = 'directory_containing_the_videos';
outdir = 'directory_to_receive_frames';
dinfo = dir( fullfile(projectdir, '*.avi'));
videonames = fullfile(projectdir, {dinfo.name});
numvideo = length(videonames);
for vidx = 1 : numvideo
thisfile = videonames{vidx};
vidobj = VideoReader(thisfile);
fidx = 0;
while hasFrame(vidobj)
fidx = fidx + 1;
vidFrame = readFrame(vidObj);
outname = fullfile(outdir, sprintf('%d-%d.jpg', vidx, fidx));
imwrite(vidFrame, outname);
end
clear vidObj
end
kousar majeed
kousar majeed el 14 de Jun. de 2019
vidobj = VideoReader(thisfile);
giving me error in this line
kousar majeed
kousar majeed el 14 de Jun. de 2019
clc;
close all;
clear all;
% assigning the name of sample avi file to a variable
filename = 'Chili.avi.mp4';
%reading a video file
mov = VideoReader(filename);
% Defining Output folder as 'Frames'
opFolder = fullfile(cd, 'Frames');
%if not existing
if ~exist(opFolder, 'dir')
%make directory & execute as indicated in opfolder variable
mkdir(opFolder);
end
%getting no of frames
numFrames = mov.NumberOfFrames;
%setting current status of number of frames written to zero
numFramesWritten = 0;
%for loop to traverse & process from frame '1' to 'last' frames
for t = 1 : numFrames
currFrame = read(mov, t); %reading individual frames
opBaseFileName = sprintf('%3.3d.png', t);
opFullFileName = fullfile(opFolder, opBaseFileName);
imwrite(currFrame, opFullFileName, 'png'); %saving as 'png' file
%indicating the current progress of the file/frame written
progIndication = sprintf('Wrote frame %4d of %d.', t, numFrames);
disp(progIndication);
numFramesWritten = numFramesWritten + 1;
end %end of 'for' loop
progIndication = sprintf('Wrote %d frames to folder "%s"',numFramesWritten, opFolder);
disp(progIndication);
%End of the code
% make another folder with the name of Faces
mkdir Faces
===== upto here i run the video and it save in folder of frame. create another folder with the name of faces.now how can i extract the face using move command to load from frame folder and extract the face and save it into face folder=============

Iniciar sesión para comentar.

Etiquetas

Preguntada:

el 15 de Feb. de 2019

Comentada:

el 14 de Jun. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by