Capture and Display image set using .NET library

조회 수: 10 (최근 30일)
Mandar
Mandar 2014년 5월 23일
댓글: Adam Wyatt 2015년 6월 4일
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
Adam Wyatt 2015년 6월 4일
I've created a file exchange submission which should significantly aid you all: File ID: #51099

댓글을 달려면 로그인하십시오.

답변 (1개)

Adam Wyatt
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.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by