MATLAB Answers

Capture and Display image set using .NET library

18 views (last 30 days)
Mandar on 23 May 2014
Commented: Adam Wyatt on 4 Jun 2015
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:
clear all
close all
asm= NET.addAssembly('C:\Programme\IDS\uEye\Develop\DotNet\uEyeDotNet.dll');
cam = uEye.Camera;
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.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 Comment

Adam Wyatt
Adam Wyatt on 4 Jun 2015
I've created a file exchange submission which should significantly aid you all: File ID: #51099

Sign in to comment.

Answers (1)

Adam Wyatt
Adam Wyatt on 9 Dec 2014
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 % 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.
You might also want to ensure you set the camera mode to DiB immediately after initializing (with appropriate error-checks if required):
I'm writing an object to simplify things, I may upload it at some point.


Sign in to comment.

Sign in to answer this question.


Translated by