error using imwrite command

조회 수: 31 (최근 30일)
Aqib Hasnain
Aqib Hasnain 2019년 4월 17일
댓글: Walter Roberson 2021년 8월 12일
I am using the imwrite commant for writing the image but i have an error 'you might not have write permission'...How can i resolve it..i am using the following code.
clear cam
cam=webcam;
for i=1:10
A=snapshot(cam);
cam.Resolution='320x240';
imwrite(A,['133MC',num2str(i),'.jpg']);
end
v=VideoWriter('myVideo.avi');
v.FrameRate=2;
open(v)
for i=1:10
K=imreade(['133MC',num2str(i),'.jpg']);
writeVideo(v,K);
end
close(v)
Error is:
Error using imwrite (line 467)
Unable to open file "133MC1.jpg" for writing. You might not have write permission.
Error in Lab3 (line 27)
imwrite(A,['133MC',num2str(i),'.jpg']);

채택된 답변

Jan
Jan 2019년 4월 17일
The error message is clear: Either the file is existing already and you cannot overwrite it (maybe it is open in another program already), or you do not have write permissions in the current folder. What is the output of
cd
? Use a specified folder:
folder = tempdir;
...
imwrite(A, fullfile(folder, ['133MC',num2str(i),'.jpg']));
  댓글 수: 1
Aqib Hasnain
Aqib Hasnain 2019년 4월 17일
Thank You so much...

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

ansha nisar
ansha nisar 2021년 8월 12일

I am using the imwrite commant for writing the image but i have an error 'you might not have write permission'. How can I resolve it?

  댓글 수: 1
Walter Roberson
Walter Roberson 2021년 8월 12일
It looks like the folder C:\Users\user\Desktop\patch might not exist. You may need to create it if that is where you want your images to be written.

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by