How to handle timer
이전 댓글 표시
I have a program in app designer, for which I have a camera that is showing live feed with a timer. See example below,..
% timer for plotting camera image
function CreateImageTimer(app)
app.timerImage = timer;
app.timerImage.StartDelay=1;
app.timerImage.ExecutionMode='fixedSpacing'; % 'fixedDelay'; %
app.timerImage.Period = 0.001;
app.timerImage.TimerFcn = @(~, ~)PlotImage(app);
app.timerImage.StopFcn = @(~, ~)CleanUpImageTimer(app);
end % end function
function CleanUpImageTimer(app)
delete(app.timerImage)
end % end fucntion
function PlotImage(app)
%tic
if(~isempty(app))
if (isempty(app))
delete(imaqfind);
end % end if
if (app.ButtonCamera.Text=='Stop Camera')
%disp('frame')
%clear('app.frame')
%axesHandlesToChildObjects = findobj(app.Video, 'Type', 'image');
% if ~isempty(axesHandlesToChildObjects)
% delete(axesHandlesToChildObjects);
% end
[app.frame, app.timeStamps]=snapshot(app.VidObj);
app.frame = app.frame; %*(2^16/2^12);
imagesc(app.Video, app.frame);
drawnow
% (more code...)
end
end
I also have a screip to control a translation stage using NET.addAssembly, which I call to move to a certain position.
My issue is that in a scan of different position (or any movement of the translation stage) the camera is still (not taking images), that is the timer seem to not be functioning simultaneously as the translation stage is moving.
Any idea why and how I can have the camera to continuously to take pictures during movement of the trsanslation stage or at least pasue the timer until the stage has reached its end position?
Is this possible?
Get a lot of errors like
Error while evaluating TimerFcn for timer 'timer-23'
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Debugging and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!