how to use imwrite command to save image in folder

i am using webcam in matlab.to save webcam images and video i used this code clc ; % clearing the command window n = input(' Enter the number of photos to be taken: '); intervel = input(' Enter the time(seconds) gap between succeessive photos: '); photosave = input(' Do you want to save the files(y/n): ','s'); disp('Please wait...'); outputFolder = fullfile(cd, 'frames'); if ~exist(outputFolder, 'dir') mkdir(outputFolder); end obj = videoinput('winvideo',1); preview(obj); disp('Press Enter to start after webcam initialization.'); pause; disp('First shot will taken after 1 second'); pause(1); for i=1:n img=getsnapshot(obj); image(img); if(photosave == 'y') outputBaseFileName = sprintf('fr%d.png',i); outputFullFileName = fullfile(outputFolder, outputBaseFileName); imwrite(img,outputFullFileName,'jpg'); end pause(intervel); end closepreview;
disp('The program successfully taken the photos'); disp('Done.');
i got error to run mkdir , imwrite commands
Error using imwrite Unable to open file "C:\Program Files\MATLAB\MATLAB Production Server\R2014a\bin\frames\fr1.png" for writing. You may not have write permission. please tel me how to get write permission

2 commentaires

The question of how to get write permission on a folder depends on your operating system. It's not really a MATLAB question, and is probably better asked on a forum that deals with Windows or Linux issues, as appropriate, though it's possible someone here will offer a suggestions.
Although it probably doesn't matter for this question, your code is unreadable. You can make it readable using the "{} Code" button.
Also, it strikes me as odd that you want to write your image into a folder in the MATLAB tree. Why not write it into one of your own working folders? Then the permissions problem wouldn't arise.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Environment and Settings dans Centre d'aide et File Exchange

Commenté :

le 13 Fév 2015

Community Treasure Hunt

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

Start Hunting!

Translated by