필터 지우기
필터 지우기

Why am I getting a timeout when using getsnapshot?

조회 수: 25 (최근 30일)
jonathan
jonathan 2013년 10월 17일
편집: John Kelly 2017년 11월 28일
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;

채택된 답변

Mark Jones
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
  댓글 수: 1
jonathan
jonathan 2013년 10월 25일
It seems that setting the PacketDelay to the correct value fixed the issue. I'm still unsure if my PacketSize is set to the correct value, but setting a high enough delay allows my PacketSize of 9014 to work fine. Here is what I used to determine the PacketDelay:
Thank you for your advice!
Jonathan

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by