GETDATA timed out before FRAMES were available

9 views (last 30 days)
Hello everyone.
I'm using three Basler line scan cameras to acquire three images simultaneously using the imaq toolbox and gigE toolbox. I use the "FramesAqcuiredFcn" callback to see when a frame is available so I can get a frame using the "getdata()" function. The question is why I receive timeout error and frame unavailability messages regardless of using callback function which assures(?) a frame has arrived?!
I tried increasing the timeout property of the cameras significantly but it did not work. Below is the part of the code for configuring the camera and capturing a photo.
Thanks in advance.
% Creating first camera object
% "app" is an object of an UI class
% In "createCamera1()" properties of camera are set
% "frameAvailable1() is a callback for getting first camera image
[app.cameraVid1, app.cameraSrc1] = createCamera1();
app.cameraVid1.FramesAcquiredFcnCount = 1;
app.cameraVid1.FramesAcquiredFcn = @(~, ~)frameAvailable1(app);
app.cameraVid1.IgnoreDroppedFrames = 'on';
% Setting camera properties
function createCamera1()
vid = videoinput('gige', 1, 'Mono8');
src = getselectedsource(vid);
vid.FramesPerTrigger = 1;
triggerconfig(vid, 'hardware', 'DeviceSpecific', 'DeviceSpecific');
vid.TriggerRepeat = Inf;
vid.ROIPosition = [0 0 4096 2048];
vid.Timeout = 10; % also tried 50, 100 and 1000
% seting other props ...
end
% Frame available callback
function frameAvailable1(app)
try
app.cameraImg1 = getdata(app.cameraVid1, 1, 'double');
flushdata(app.cameraVid1);
% Set a global variable to show first image arrived
app.img1Availble = 1;
% Call a specific function when all three images arrived
if app.img1Availble = 1 && app.img2Availble = 1 && app.img2Availble = 1
allImagesArrived(app);
app.img1Availble = 0;
app.img2Availble = 0;
app.img3Availble = 0;
end
catch
% Show some messages
end
end

Answers (2)

Voss
Voss on 23 Dec 2021
It may be because this line:
if app.img1Availble = 1 && app.img2Availble = 1 && app.img2Availble = 1
contains syntax errors that trigger the catch block.
You need to use == for comparison rather than = which is for assignment. (And also you don't need to check the same condition twice.)
if app.img1Availble == 1 && app.img2Availble == 1 && app.img3Availble == 1
  1 Comment
armin davoudi
armin davoudi on 27 Dec 2021
My mistake! but it's not the point and it did not work with the correct syntax you mentioned.Thank you

Sign in to comment.


Image Analyst
Image Analyst on 23 Dec 2021
Where is frameAvailable1(app) actually being called?
And you're only setting img1Availble after the image has been snapped, not before like you imply here: "see when a frame is available so I can get a frame using the "getdata()" function" -- you're trying to get it, and only then (after it succeeds) are you setting the available flag.
(By the way, "Availble" should really be spelled "Available".)
  2 Comments
armin davoudi
armin davoudi on 27 Dec 2021
Thanks for the reply. FrameAvailable1(app) is a callback and will be called automatically when a frame is available. Each camera has its callback in which the image will be taken and a flag is set indicating a frame is captured. after all three images arrived(with checking their flags), the processing algorithms will be executed. When the frameAvailable1 is called by the imaq toolbox a frame should be available(right?), however, a timeout error occurs on getdata() line and tells no frame is available! Probably I should double check the frameAvailable property of the videoInputObject.
Image Analyst
Image Analyst on 27 Dec 2021
I don't know. I had weird problem with the camera timing out and I had to work with an exprt developer on the Image Aquisition team. Basically we were having timing problems using get snapshot() and had to use getdata() instead and we also discovered a previously unknown bug - a memory leak. It just kept using up memory until it failed and couldn't snap pictures anymore. Here is what we found:
After investigating the issue, it seems that the Figure's Renderer property has been set to "painters" and that is causing the memory leak. Does switching the property to "opengl" resolve the issue?
After I set my renderer to opengl, the memory leak went away and I was able to snap pictures again. That bug will be fixed in some future version, now that they know about it. But I'm still going to use opengl anyway.

Sign in to comment.

Categories

Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!