Losing frames when "getdata"
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
In a simple user interface I want to include a capture the image from my camera. To do this I have two push button. A start button to start acquiring the live image and a stop button to stop acquiring the image.
The basic problem is that I get the error:
GETDATA timed out before FRAMES were available.
And this is because I interrupt the TimerFcn of the vid. How can I tackle this?
Here is what I do:
function mycam
S.fh = figure('units','pixels',...
'position',[300 300 400 400],...
'menubar','none',...
'name','stopwatch',...
'numbertitle','off');
S.pb(1) = uicontrol('style','push',...
'units','pixels',...
'position',[10 10 85 30],...
'fontsize',14,...
'string','start',...
'CallBack',@switchon);
S.pb(2) = uicontrol('style','push',...
'units','pixels',...
'position',[105 10 85 30],...
'fonts',14,...
'str','stop',...
'Callback',@switchoff);
NumberFrameDisplayPerSecond=20;
vid=videoinput('winvideo',1);
set(vid, 'timerFcn',@updater,...
'TimerPeriod', 1/NumberFrameDisplayPerSecond,...
'FramesPerTrigger',1,...
'TriggerRepeat',Inf);
triggerconfig(vid, 'Manual');
function updater(varargin)
persistent stream
trigger(vid);
IM=getdata(vid,1,'uint8');
if isempty(stream)
stream = imshow(IM);
else
set(stream, 'CData', IM)
end
end
function switchon(varargin)
start(vid)
end
function switchoff(varargin)
stop(vid)
end
end
Thank you
1 Kommentar
Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!