Losing frames when "getdata"
显示 更早的评论
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 个评论
Ramu Pradip
2021-10-7
I have the same problem as well. Any tips ?
回答(1 个)
Walter Roberson
2013-10-4
0 个投票
Perhaps wait() on the timer after you stop() it.
类别
在 帮助中心 和 File Exchange 中查找有关 Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!