I am trying to extract frames from a video and I have the following code.As I run the code the folder does not show the extracted frames and I don't know why?
    4 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
    Prachi Sharma
 el 7 de Oct. de 2016
  
    
    
    
    
    Comentada: Prachi Sharma
 el 13 de Oct. de 2016
            I have the following code.It does not give any error but the folder that is supposed to hold all the extracted frames does not show any frames.Why?
videoObject=VideoReader('clouds.mp4');
  % Determine how many frames are there .
  numberOfFrames = videoObject.NumberOfFrames;
  vidHeight = videoObject.Height;
  vidWidth = videoObject.Width;
      % Ask user if they want to write the individual frames out to disk.
    promptMessage = sprintf('Do you want to save the individual frames out to individual disk files?');
    button = questdlg(promptMessage, 'Save individual frames?', 'Yes', 'No', 'Yes');
    if strcmp(button, 'Yes')
      writeToDisk=true;
      % Extract out the various parts of the filename.
      [folder, baseFileName, extentions] = fileparts('clouds.mp4');
      % Make up a special new output subfolder for all the separate
      % movie frames that we're going to extract and save to disk.
      folder = pwd;   % Make it a subfolder of the folder where this m-file lives.
      outputFolder = sprintf('%s/Movie Frames from %s', folder, baseFileName);
      % Create the folder if it doesn't exist already.
      if ~exist(outputFolder, 'dir')
        mkdir(outputFolder);
      end
    else
      writeToDisk = false;
      end
      % Loop through the movie, writing all frames out.
    % Each frame will be in a separate file with unique name.
    meanGrayLevels = zeros(numberOfFrames, 1);
    meanRedLevels = zeros(numberOfFrames, 1);
    meanGreenLevels = zeros(numberOfFrames, 1);
    meanBlueLevels = zeros(numberOfFrames, 1);
    for frame = 1 : numberOfFrames
    % Extract the frame from the movie structure.
    thisFrame = read(videoObject, frame);
    % Display it
    hImage = subplot(2, 2, 1);
    image(thisFrame);
    caption = sprintf('Frame %4d of %d.', frame, numberOfFrames);
    title(FRAMES, 'FontSize', 10);
    drawnow; % Force it to refresh the window.
      end
0 comentarios
Respuesta aceptada
  Walter Roberson
      
      
 el 7 de Oct. de 2016
        Your code does not write anything to disk, other creating the folder. You display the frames but you do not imwrite() them to disk.
2 comentarios
Más respuestas (0)
Ver también
Categorías
				Más información sobre Image Preview and Device Configuration en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

