Capture and Display image set using .NET library

10 views (last 30 days)
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 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
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.

Categories

Find more on MATLAB Support Package for USB Webcams in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!