Acquire images in loop and save as different name

조회 수: 1 (최근 30일)
simon
simon 2016년 7월 4일
댓글: Image Analyst 2016년 7월 4일
Hey,
I'm running a for loop where I acquire images from my webcam using snapshot(). Through each iteration of the loop, I'd like to have each image have a different name so I can look at them all at the end, without the previous ones being overwritten.
I do NOT want to save them to the disk, just a different name in the script, and I have no idea how to do this.
Hope you guys can help! :)
Thanks!

채택된 답변

Stephen23
Stephen23 2016년 7월 4일
편집: Stephen23 2016년 7월 4일
Simply put the frames into a cell array:
C = {};
for ... % your loop
C{end+1} = snapshot(...);
end
And then use indexing to access them. Simple!
Creating new variables dynamically is slow and buggy:
  댓글 수: 2
simon
simon 2016년 7월 4일
Thanks, thought I had tried that... Was using these [] instead of these{}... stupid mistake
Thanks again! :)
Image Analyst
Image Analyst 2016년 7월 4일
Sometimes it's tricky to figure out when to use braces, parentheses, or brackets. We try to explain it in the FAQ entry on cell arrays: http://matlab.wikia.com/wiki/FAQ#What_is_a_cell_array.3F

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

추가 답변 (0개)

Community Treasure Hunt

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

Start Hunting!

Translated by