Clear Filters
Clear Filters

Issue with 2 cameras and the Imager Acquisition Toolbox - video objects vanish!

1 view (last 30 days)
Hello, I have been using the IMAQ toolbox for years and all works fine with 1 camera. Today I have hooked up a 2nd (identical but different serial number) camera and if I use each one seperately all is fine.
I used to just create a single video object (vidobj1) that all my code uses. Now as I have 2 cameras I have created a 2nd videoobject ("vidobj2")
Both these vidobj's are declared as:
properties (Access = public)
% Camera Properties
vidobj1 % 1st Video object
vidobj2 % 2nd Video object
I onoy want to actually take an image sequentially (i.e. with one camera at a time), so for my image capture command, depending on which camID I use (either 1 or 2), I want the appropriate vidobj to be used (all my commands use "vidobj" and I want this to be either vidobj1 or vidobj2. I thus created this function below.
function vidobj =getVidObj(app)
camID=str2num(app.CameraIDDropDown.Value); %either 1 or 2
switch camID
case 1
vidobj=app.vidobj1
case 2
vidobj=app.vidobj2
end
So this works fine for both cameras but only once, it then complains that trhe object no longer exists
My getCameraimage function is like this:
vid=getVidObj(app)
flushdata(vid);
start(vid);
%etc....
But at the flushdata(vid) line it says
Invalid Image Acquisition object.
This object is not associated with any hardware and
should be removed from your workspace using CLEAR.
Error using imaqdevice/flushdata
OBJ contains an invalid video input object at index 1.
Any idea whats happening?
  1 Comment
Jason
Jason on 23 Apr 2024
Just to add, I've observed it happens even before trying to get an image. Its once I call
vid=getVidObj(app)
for the 2nd camID after already called it for the 1st camID.

Sign in to comment.

Accepted Answer

Jason
Jason on 23 Apr 2024
So the issue was I was calling imaqreset when I initalised each video object, not realising it deletes any image acquisition objects that exist in memory and unloads all adaptors loaded by the toolbox!

More Answers (0)

Products


Release

R2023b

Community Treasure Hunt

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

Start Hunting!