Can't saveas in a specific folder => Error using saveas(line 60) Invalid handle

5 views (last 30 days)
Hello,
I have a problem in my code, I want to select a file (video)
Create a folder with the file name
And save some frame of my video in this file with a name which contain : the video name + 'string' + date (video_frameRep_10-21-2021_12-16)
My code :
%Selection d'un fichier
[file, path] = uigetfile({'*.avi';'*.mov';'*.mp4';'*.*'},'Choississez votre fichier :');
import_video = fullfile(path, file);
[path, file, extension] = fileparts(import_video);
video = VideoReader(import_video);
first_frame = read(video,1);
figure;
imshow(first_frame);
drawcircle;
mkdir C:/Users/admin/Documents resultat_Suppression_mouvement_et_balayage
mkdir ('C:/Users/admin/Documents/resultat_Suppression_mouvement_et_balayage', file)
Filename = sprintf('%s_test_%s.jpeg',file, datestr(now,'mm-dd-yyyy_HH-MM'))
Folder = 'C:\Users\admin\Documents\resultat_Suppression_mouvement_et_balayage\nom_fichier'
saveas(first_frame,fullfile(Folder, Filename));
Thanks for help !

Accepted Answer

Cris LaPierre
Cris LaPierre on 22 Oct 2021
saveas saves a figure to a specific file format. The first input to saveas is expected to be a figure handle. You are passing in a numeric or structure array.
You can see examples of how to use saveas here:

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Tags

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!