フィルターのクリア

How to store acquired data of multiple frames from webcam to local storage with any name?

1 回表示 (過去 30 日間)
for i=1:5
data = getsnapshot(vid);
figure(i);
imshow(data);
filename=sprintf('New.png',i);
imwrite(data,filename)
end
I've tried this but it is not working. I've saved 5 frames in variable "data" and now I want to store it in local storage. How should I do it.

採用された回答

Andrey Kiselnikov
Andrey Kiselnikov 2019 年 2 月 5 日
編集済み: Andrey Kiselnikov 2019 年 2 月 5 日
You should decide "what" and "how" do you want to store. You can't store five snapshots in one *.png image. You can store this data (your workspace variables) in *.mat (better choice) format https://www.mathworks.com/help/matlab/ref/save.html, or save it as a five different *.png images.
p.s. In your code there are some mistakes! if you wouldlike to save five snapshots from webcam to a different png files you should use this code
wblist = webcamlist;
cam = webcam(wblist{1})
for i=1:5
filename = sprintf('myimage%02d.png', i);
imwrite(snapshot(cam),filename);
end
  4 件のコメント
Andrey Kiselnikov
Andrey Kiselnikov 2019 年 2 月 5 日
編集済み: Andrey Kiselnikov 2019 年 2 月 5 日
Also, if you would like to use this code example "as is" take this version with clearing of the cam object
if exist('cam') ~= 0
clear cam;
end
wblist = webcamlist;
cam = webcam(wblist{1});
for i=1:5
filename = sprintf('myimage%02d.png', i);
imwrite(snapshot(cam),filename);
end
Talha Anwer
Talha Anwer 2019 年 2 月 5 日
I'm highly thankful for this. That was such a minor issue and I wasn't able to spot that.
You've helped a lot. Thank You again.

サインインしてコメントする。

その他の回答 (0 件)

製品


リリース

R2016a

Community Treasure Hunt

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

Start Hunting!

Translated by