プッシュボタンを押すたびに画像を上書きせずに保存したい。オリジナルを上書きせずに画像を保存する方法を教えてください。私がやりたいことは、プッシュボタンを押すたびに、元の画像を削除せずに一度に 1 つの画像を生成することです。
デジタル カメラと同じように、トリガー ボタンを押すたびに 1 つの画像が保存され、ファイル名はimage1.jpgになります。つまり、もう一度トリガーを押すと、もう一度 1 枚の画像がキャプチャされ、ファイル名はimage2.jpgなどになります。
ここに私のコードがあります:
counter = 1; %initialize filename increment
vid = videoinput('winvideo',2);
set(vid, 'ReturnedColorSpace', 'RGB');
img = getsnapshot(vid);
imshow(img);
savename = strcat('C:\Users\Sony Vaio\Documents\Task\images\image_' ,num2str(counter), '.jpg'); %this is where and what your image will be saved
imwrite(img, savename);
counter = counter +1; %counter should increment each time you push the button
私のコードはファイル名 image1.jpg を保存して上書きし続けます。物事を明確にするために
プッシュボタンを1回押すと、1枚の画像が保存されます。
プッシュボタンを押すたびにブロックコード全体を呼び出すようなものです。皆さんが私を助けてくれることを願っています。私は今本当に困っています:(ありがとう:)