Unable to detect IDS uEye camera
22 次查看(过去 30 天)
显示 更早的评论
Hi,
I have a matlab 2012b installation with the Image Acquisition Toolbox Version 4.4 and want to record from my IDS uEye camera which should be DirectShow compatible.
Using the detectedDecice Uitility from mathwork ( http://de.mathworks.com/hardware-support/directshow.html ) the camera is detected by the winvideo driver.
But if I run imaghwinfo('winvideo') there is no camera found.
I tried to get this Webcam support package ( http://www.mathworks.com/matlabcentral/fileexchange/45182-matlab-support-package-for-usb-webcams ) but it seems to be available only for Matlab 2014>
Do you have any suggestions on how to access this camera?
Thank you! Manuel
2 个评论
Adam Wyatt
2015-6-4
编辑:Adam Wyatt
2016-12-7
Have a look at my blog for information on how to do this:
sanjoy khawas
2018-8-22
Hi Adam,
Thank you for sharing the code. I am also trying to connect the ueye camera through Matlab by the protocol(using max file) mentioned by you. However, I am able to connect the camera but matlab did not display any images.
The output of the command windows shows --- Number of connected cameras: 1 ============================================================ # CamID DevID Sens On Serial Model Status ============================================================ 0 1 1 558 0 4103146965 UI318xCP-M 0 ============================================================
Initializing first available camera ... Setting colormode to monochrome ... Setting display mode to bitmap (DIB) ...
============================================================ Camera information ============================================================ Camera #: 1 Sensor Name: UI318xCP-M Monochrome: 1 Max Width: 2592 Max Height: 2048 Global Shutter: 1 Pixel Size [um]: 4.800000 ============================================================
Error using uEye_Test Requested 11132555233280x10x64 (6635520.0GB) array exceeds maximum array size preference. Creation of arrays greater than this limit may take a long time and cause MATLAB to become unresponsive. See array size limit or preference panel for more information.
Any ideas or suggestions are highly appreciated.
采纳的回答
Adam Wyatt
2014-12-9
I didn't get far using this route (it was my initial plan and I purchased the IMAQ toolbox just for this purpose). Anyway, the way to go is to connect through the .NET interface, here is an example:
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
1 个评论
Myrtle42
2018-6-7
Thanks for the well-commented example code! I realize this is old but had a similar problem with an IDS camera and tried out this solution. Note: I had to change "strcmp" to "strcmpi" because it was actually outputting the word "Success" not "SUCCESS". Now it works great.
As written, this gives me only 10 fps with a 1920 x 1200 IDS camera (nominal max 180 fps). I realize this is slowed down by the image plotting and moving the data from memory. Could you post an example of how to write images to disk using the NET framework as quickly as possible (using free running)?
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Support Package for IP Cameras 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!