Why am I getting a timeout when using getsnapshot?
44 次查看(过去 30 天)
显示 更早的评论
I'm currently using a GigE camera using a pleora PT1000 IP engine with Matlab 2012a. I've successfuly been able to grab and display images as a realtime video with Matlab's image acquistion toolbox. However, I'm running into a timeout error when I use my code. It's not predictable since the amount of time it took for the error to occur went from anywhere between 9 seconds to 7 minutes with no apparent pattern. When I get the error, all I do is imaqreset and then run the code again to display video until I get the error again. My code is shown below. If anyone has has an idea as to what is going on, help would greatly be appreciated. Thank you.
%Camera setup
vid = videoinput('gige',1,'Mono16'); src = getselectedsource(vid); vid.FramesPerTrigger = inf; vid.FrameGrabInterval = 3; src.PacketSize = '9014'; start(vid);
%image setup
h = imagesc(zeros(480,640)); axis image; axis off;
%Load .mat files of processRAW parameters
load 'gain.mat'; load 'bias.mat'; load 'r.mat'; load 'badmap.mat'; load 'bbimages.mat'; load 't.mat';
tic
while 1,
%Error check so buffer doesn't overflow
if imaqmem('FrameMemoryUsed') < 100000000
%Check memory
imaqmem
%Grab a frame, if timeout occurs display how long process took
try
liveFeed = getsnapshot(vid);
catch
toc
return;
end
%Process image
[S rawData] = processRAW(liveFeed,gain,bias,r,badmap,bbimages);
%Format data for displaying
R = single(S(:,:,1));
R(R<280)=275;
R(R>300)=285;
%Display image, end program if window is closed
try
set(h,'cdata',R);
drawnow;
catch
break;
end
%If buffer nearing capacity, clear the data and continue process
else
flushdata(vid);
liveFeed = getsnapshot(vid);
[S rawData] = processRAW(liveFeed,gain,bias,r,badmap,bbimages);
R = single(S(:,:,1));
R(R<280)=275;
R(R>300)=285;
set(h,'cdata',R);
drawnow;
end
end
%Reset camera
flushdata(vid); stop(vid); delete(vid); imaqreset;
0 个评论
采纳的回答
Mark Jones
2013-10-23
编辑:John Kelly
2017-11-28
Hi Jonathan,
I would encourage you to try setting the camera to use manual triggering when using GETSNAPSHOT in a loop, as shown here:
Also, you may need to properly set the PacketDelay property on the source given the expected bandwidth for the image size and format, and PacketSize in order to avoid reliability issues. Also, you should ensure you have set the receive buffers (descriptors) as high as possible (likely 2048) as described here:
The technical support department can assist you with calculating a proper PacketDelay value.
Mark
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 GigE Vision Hardware 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!