MATLAB Answers

Strange behaviour with imaqregister and imaqreset

28 views (last 30 days)
David K
David K on 23 Oct 2020
Commented: David K on 29 Oct 2020 at 16:11
Hello, I'm trying to debug my code which is dependent on the Image Acquisition toolbox.
Users are reporting that the code fails to find the adapter and I think my functions work in strange ways.
For example, I register the camera using:
imaqregister(PATH_TO_DLL_FILE, 'register');
but when I do imaqhwinfo, the output is
ans =
struct with fields:
InstalledAdaptors: {}
MATLABVersion: '9.9 (R2020b)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '6.3 (R2020b)'
If I then do imaqreset and then imaqhwinfo, the output then becomes
ans =
struct with fields:
InstalledAdaptors: {'NAME OF DLL'}
MATLABVersion: '9.9 (R2020b)'
ToolboxName: 'Image Acquisition Toolbox'
ToolboxVersion: '6.3 (R2020b)'
So even though imaqreset explicitly is described as:
help imaqreset
imaqreset Disconnect and delete all image acquisition objects.
I seem to need to call it to actually get my .dll file recognised. This is exactly the same behaviour when unregistering the camera which means I need two sets of commands
% Register camera
imaqregister(PATH_TO_DLL_FILE, 'register');
imaqreset
imaqhwinfo % Show camera is registered
% Unregister camera
imaqregister(PATH_TO_DLL_FILE, 'unregister');
imaqreset
imaqhwinfo % Show camera is unregistered
This behaviour seems completely at odds with the documentation.
Furthermore, even though this code runs on my computer, when I deliver the code to users with the matlab runtime, they keep get DLL conflict errors or DLL not found errors; it basically means I have no idea what these functions are doing.
I also don't understand why I need to always specify the full path to the DLL. It means I need to have code to handle whether the app isdeployed or not.
I've also tried to handle the case where the camera is already registered ie:
info = imaqhwinfo;
for i = 1:length(info.InstalledAdaptors)
if info.InstalledAdaptors{i} == 'NAME OF DLL'
app.camneraInstalled = true;
end
end
But users still seem to get conflict issues.
Does anyone have an explanation for this strange behaviour? Or tips on how to handle registering cameras (especially if the camera might already be registered).

  0 Comments

Sign in to comment.

Answers (1)

Image Analyst
Image Analyst on 23 Oct 2020
You might delve into my attached InitializeVideoCamera() function and adapt as needed.

  3 Comments

David K
David K on 26 Oct 2020 at 15:48
Hello, thank you for the response. I would probably say the issue I'm having is tucked away in the
RegisterLumeneraVideoAdaptorDLL
function that you call early on in the InitializeVideoCamera.m file.
N.B. Your name is contained within that file so it might be worth removing it.

Sign in to comment.

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!