Camera identified by hardware detection application but doesn't show up in image acquisition tool

7 views (last 30 days)
Hi all,
I am using iDS ueye camera to take microscope pictures at certain intervals using MATLAB. The problem I am facing is, it doesn't show up in image acquisition tool. I tried to check compatibility with hardware detection application and it shows the camera and supported formats.
Thanking you in anticipation.
Chetan

Answers (4)

Adam Wyatt
Adam Wyatt on 9 Dec 2014
There are a couple of methods:
  1. Write a dll C-wrapper that can interface between Matlab and the uEye SDK and then use the loadlibrary functions (see documentation "Call C Shared Libraries").
  2. Similar to above, but write a mex-wrapper and compile into a mex code (see documentation "MEX-File Creation API").
  3. Connect to the .NET library (see documentation "Cell .NET Libraries").
I had previously used the first two methods, but this makes it difficult to maintain, and requires reproducing every feature you want. I am now using the latter method, which provides direct support to all features of the .NET assembly (use the uEye .NET SDK manual for further information and functions).
Using the .NET assembly is not quite as straightforward as with C# because Matlab does not directly support pointers, but there is a workaround as pointed out below.
Remember to "EXIT" your camera before trying to re-initialise the same camera
% Add NET assembly if it does not exist
% May need to change specific location of library
asm = System.AppDomain.CurrentDomain.GetAssemblies;
if ~any(arrayfun(@(n) strncmpi(char(asm.Get(n-1).FullName), ...
'uEyeDotNet', length('uEyeDotNet')), 1:asm.Length))
NET.addAssembly(...
'C:\Program Files\IDS\uEye\Develop\DotNet\signed\uEyeDotNet.dll');
end
% Create camera object handle
cam = uEye.Camera;
% Open 1st available camera
% Returns if unsuccessful
if ~strcmp(char(cam.Init), 'SUCCESS')
error('Could not initialize camera');
end
% Set display mode to bitmap (DiB)
if ~strcmp(char(cam.Display.Mode.Set(uEye.Defines.DisplayMode.DiB)), ...
'SUCCESS')
error('Could not set display mode');
end
% Set colormode to 8-bit RAW
if ~strcmp(char(cam.PixelFormat.Set(uEye.Defines.ColorMode.SensorRaw8)), ...
'SUCCESS')
error('Could not set pixel format');
end
% Set trigger mode to software (single image acquisition)
if ~strcmp(char(cam.Trigger.Set(uEye.Defines.TriggerMode.Software)), 'SUCCESS')
error('Could not set trigger format');
end
% Allocate image memory
[ErrChk, img.ID] = cam.Memory.Allocate(true);
if ~strcmp(char(ErrChk), 'SUCCESS')
error('Could not allocate memory');
end
% Obtain image information
[ErrChk, img.Width, img.Height, img.Bits, img.Pitch] ...
= cam.Memory.Inquire(img.ID);
if ~strcmp(char(ErrChk), 'SUCCESS')
error('Could not get image information');
end
% Acquire image
if ~strcmp(char(cam.Acquisition.Freeze(true)), 'SUCCESS')
error('Could not acquire image');
end
% Extract image
[ErrChk, tmp] = cam.Memory.CopyToArray(img.ID);
if ~strcmp(char(ErrChk), 'SUCCESS')
error('Could not obtain image data');
end
% Reshape image
img.Data = reshape(uint8(tmp), [img.Width, img.Height, img.Bits/8]);
% Draw image
himg = imshow(img.Data, 'Border', 'tight');
% Acquire & draw 100 times
for n=1:100
% Acquire image
if ~strcmp(char(cam.Acquisition.Freeze(true)), 'SUCCESS')
error('Could not acquire image');
end
% Extract image
[ErrChk, tmp] = cam.Memory.CopyToArray(img.ID);
if ~strcmp(char(ErrChk), 'SUCCESS')
error('Could not obtain image data');
end
% Reshape image
img.Data = reshape(uint8(tmp), [img.Width, img.Height, img.Bits/8]);
% Draw image
set(himg, 'CData', img.Data);
drawnow;
end
% Close camera
if ~strcmp(char(cam.Exit), 'SUCCESS')
error('Could not close camera');
end
  2 Comments
Shane
Shane on 14 May 2015
Edited: Shane on 14 May 2015
Adam this worked perfectly!! thank you for this. I am using 2 THORLABS camera/sensors 1545m and the 1645c and changed the code a bit to run them individually successfully. But I did run into a bit of a snag. Is there a way to run both sensors at the same time or at least alternate between 2 sensors using this code for image acquisition and how would I go about doing this?
Thanks Shane
Adam Wyatt
Adam Wyatt on 3 Jun 2015
RTFM - Have you tried it, is quite enlightening!
The first thing to do is create an object to the .NET interface:
cam = uEye.Camera;
This does not really do anything other than load the interface into memory, giving you access to all the functions in the .NET library supplied by the manufacturer.
When you initialise the camera, you can specify the camera ID, or even the device ID. To initialise by camera ID, camID:
cam.Init(camID);
You need to use the camera manager programme to change the camera ID of each camera so that they are unique.
I've actually created an object and even a GUI which I will upload to the file exchange - there are a couple of bugs that I need to fix, well try tomorrow.

Sign in to comment.


Image Analyst
Image Analyst on 11 Nov 2013
Edited: Image Analyst on 11 Nov 2013
What devices show up in imaqtool?
If you're using Windows, what devices show up in Device Manager under the "Imaging Devices" category?

Manuel
Manuel on 17 Dec 2014
Hi Chetan,
I am fazing the same problem. using imaqhwinfo('winvideo') most of the time returns nothing, but the device detection application does.
I do have noticed though that calling imaqreset several times, sometimes causes imaqhwinfo to find the camera ...
Did you have success to use the webcam interface to access the camera? Sadly this fails for me
>> webcamlist
ans =
'XS_4102729676'
>> w = webcam()
Warning: The following error was caught while executing 'matlab.webcam.internal.WebcamController' class destructor:
Attempt to reference field of non-structure array.
> In webcam>webcam.webcam at 158
Error initializing media source.
Adams proposal might be somewhat of a solution, but I don't like the idea of having to copy each frame manually. Would there be a way to use it with matlabs internal videoinput() and ImageWriter() ?
regards, Manuel
  3 Comments
Adam Wyatt
Adam Wyatt on 3 Jun 2015
I don't run the camera according to frame rate, so am not sure exactly how to do it. Basically you just need to use the appropriate functions from the .NET library.

Sign in to comment.


Adam Wyatt
Adam Wyatt on 3 Jun 2015
With regards to copying the data, there is an alternative method, but exactly what use it is I do not know. I've actually managed to use the openGL acquisition method, rather than DiB. Essentially you can use the system .NET classes to create a native window, and then pass a handle to this window to the uEye .NET functions. I'll add a code snippet here tomorrow.
The time taken to copy the data in memory is actually negligible, what is slow is the time taken for Matlab to display the image (in addition to the time taken to acquire and transfer the image to the computer). Therefore one could use openGL to display the image, copy a frame to Matlab, process the data and then add overlays using the .NET classes.

Community Treasure Hunt

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

Start Hunting!