Why am I getting a timeout when using getsnapshot?
Afficher commentaires plus anciens
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;
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur GigE Vision Hardware dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!