I want to capture 100 images from my webcam and then store them in a structure. I'm trying to do it like this but i'm getting the error, 'subscripted assignment dimensions mismatch'
.
The code is this:
sep_images=struct('images',[]);
vid=videoinput('winvideo',1,'YUY2_320x240');
set(vid,'FramesPerTrigger',Inf);
set(vid,'ReturnedColorspace','rgb');
vid.FrameGrabInterval=1;
start(vid)
for num_frames= 1:100
im=getsnapshot(vid);
sep_images.images(num_frames)=im;
end
stop(vid);
and it is giving me the error in this statement, sep_images.images(num_frames)=im;
.
If someone has the idea of how to do it? please let me know.
I think you intended the images
field to be a cell.
Initialize like:
sep_images=struct('images',{[]})
Assign like:
sep_images.images{num_frames}=im;
Just remember to access it with curly braces too (i.e. I = sep_images.images{iframe}
).