How to save multiple photos when taking from camera to a folder

Hi everyone, I want to ask for this code can only save 1 image in a folder, when taking a new photo, it replaces the previous image
Is there a way to save multiple images in a folder?
axes(handles.axes5);
vid= handles.vid;
capcha = getsnapshot(vid);
videoFrame=(capcha);
imshow(videoFrame);
imshow(capcha);
name = 'capcha.jpg';
full = fullfile('C:\Users\dieps\Desktop\BAI GIU XE\HINH ANH XE RA',name);
imwrite(capcha,full);
guidata(hObject,handles);
Thank for all

 Risposta accettata

num_to_take = 50;
imgdir = 'C:\Users\dieps\Desktop\BAI GIU XE\HINH ANH XE RA';
axes(handles.axes5);
vid = handles.vid;
for idx = 1 : num_to_take
capcha = getsnapshot(vid);
imshow(capcha);
drawnow();
full = fullfile(imgdir, sprintf('capcha_%04d.jpg', idx));
imwrite(capcha, full);
end

6 Commenti

Hello guy, your code I can't save a image into a folder (C:\Users\dieps\Desktop\BAI GIU XE\HINH ANH XE RA)
It only takes screenshot on axes5 but not save to folder HINH ANH XE RA.
Hope you can help me because i'm about to graduate.
Im from Viet Nam, nice to meet you.
I had a typing mistake -- I had fulfile() instead of fullfile() . It should have given an error without producing any output, sorry.
If you have ultraview or teamviewer can you guide me?
Sorry, I do not provide remote services or phone calls or video calls or instant messaging as a volunteer.
One thing I would add, though, is
imgdir = 'C:\Users\dieps\Desktop\BAI GIU XE\HINH ANH XE RA';
if ~isfolder(imgdir); mkdir(imgdir); end
That it doesn't work
axes(handles.axes5);
vid= handles.vid;
capcha = getsnapshot(vid);
videoFrame=(capcha);
imshow(videoFrame);
imshow(capcha);
imgdir = 'C:\Users\dieps\Desktop\mohinh\Anh_chup_man_hinh_xe_vao';
name = 'capcha.jpg';
full = fullfile('C:\Users\dieps\Desktop\mohinh\Anh_chup_man_hinh_xe_vao',name);
if ~isfolder(imgdir);
mkdir(imgdir);
end
Can you fix it?
num_to_take = 50;
imgdir = 'C:\Users\dieps\Desktop\BAI GIU XE\HINH ANH XE RA';
if ~isfolder(imgdir);
mkdir(imgdir);
end
axes(handles.axes5);
vid = handles.vid;
for idx = 1 : num_to_take
capcha = getsnapshot(vid);
imshow(capcha);
drawnow();
full = fullfile(imgdir, sprintf('capcha_%04d.jpg', idx));
imwrite(capcha, full);
end

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su MATLAB in Centro assistenza e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by