how to use imwrite command to save image in folder
10 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
David Young
2015 年 2 月 13 日
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.
David Young
2015 年 2 月 13 日
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.
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Environment and Settings についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!