Only saving one iteration of the for loop is being saved to the file, but I need all the iterations to be saved to the file.

1 次查看(过去 30 天)
The code works well, however, only one iteration of my for loop is being saved into the tiff file. When I open the .tiff there are only 30 images. I am not sure if this error is because the for loop is overwriting the first 30 images every time it iterates, or if the way that I am saving my images, that when they save, the first thirty are being written over by the second iteration. Possibly I am using the wrong trigger event?
Below is my code
vid = videoinput('hamamatsu', 1, 'MONO16_BIN4x4_512x512_FastMode');
src = getselectedsource(vid);
%vid.FramesPerTrigger = 10;
% TriggerRepeat is zero based and is always one
% less than the number of triggers.
%vid.TriggerRepeat = 2;
src.ExposureTime = .3;
%when I want to take multiple images, wait awhile and then takee more
%images in the same file.
for i = 1:2
tic
vid.FramesPerTrigger = 30;
fprintf(obj, 'O 0 1'); %on
preview(vid);
%fprintf(obj, 'O 0 1'); %on
start(vid),wait(vid);
toc
for l = 1:2
fprintf(obj, 'O 0 0'); %off
pause (10);
end;
end;
stoppreview(vid);
stop(vid);
alpha = input('What do you want to name you file? ','s');
x = getdata(vid);
filename = [alpha '.tif'];
for slnum = i : size(x, 4)
if slnum == i; mode = 'overwrite'; else mode = 'append'; end
imwrite( x(:,:,slnum), filename, 'writemode', mode);
end
closepreview(vid);
delete(vid);
clear vid;
  3 个评论

请先登录,再进行评论。

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by