Capture and Display image set using .NET library
6 次查看(过去 30 天)
显示 更早的评论
Hello all,
I am working with a uEye IDS camera. Which can be used with ActiveX and .NET. I want to make use of the .NET libraries available in the DLL file. However i am unable to do so. My code:
clc
clear all
close all
asm= NET.addAssembly('C:\Programme\IDS\uEye\Develop\DotNet\uEyeDotNet.dll');
list=asm.Classes;
cam = uEye.Camera;
cam.Init;
cam.Memory.Allocate;
cam.Acquisition.Capture;
next step would be to display the image set, but, there is no property available there. like, available syntax example from the manufacturer:
uEye.Camera cam = new uEye.Camera();
cam.Memory.Allocate(out s32MemId);
cam.Acquisition.Capture(s32Wait);
cam.DisplayImage.Set(s32MemId, s32DisplayHandle, s32Mode)
I know it isn't the way we program in Matlab. The syntax is something like VB or something no idea.
I can not display anything. I am only able to run my code which has output.
Experts, please help.
回答(1 个)
Adam Wyatt
2014-12-9
I've written a little function that will load the assembly if required - the .NET assembly should be located inside the same folder as this function (I actually have this as part of an object, so have adapted it a little for this purpose):
% Check if required .NET assemblies have been loaded; load if required
function LoadAssembly(varargin)
% Get list of loaded assemblies
asm = System.AppDomain.CurrentDomain.GetAssemblies;
for narg=1:nargin
if ~any(arrayfun(@(n) strncmpi(char(asm.Get(n-1).FullName), ...
varargin{narg}, length(varargin{narg})), 1:asm.Length))
str = which('LoadAssembly');
ind = strfind(str, filesep);
str = str(1:ind(end));
NET.addAssembly(fullfile(str, [varargin{narg} '.dll']));
end
end
end % function LoadAssembly
In this case, call the function with the following, but it can be used more generally. This will replace the first few lines of my original post.
LoadAssembly('uEyeDotNet')
You might also want to ensure you set the camera mode to DiB immediately after initializing (with appropriate error-checks if required):
cam.Display.Mode.Set(uEye.Defines.DisplayMode.DiB)
I'm writing an object to simplify things, I may upload it at some point.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 MATLAB Support Package for USB Webcams 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!