Can you use dotnet assembly to run more than 2 devices?

9 views (last 30 days)
I found this bit of code from Adam W. in another post and changed it to fit a Thorlabs camera 1545m and 1645c. I can get one camera to work but have had no luck getting both cameras to go at the the same time. I asked Adam directly in post and message but no response so any input or documentation would be helpful or even if this is possible. Thank you in advance for any of your time.
asm = System.AppDomain.CurrentDomain.GetAssemblies;
if ~any(arrayfun(@(n) strncmpi(char(asm.Get(n-1).FullName), ...
'uc480DotNet', length('uc480DotNet')), 1:asm.Length))
NET.addAssembly(...
'C:\Program Files (x86)\Thorlabs\Scientific Imaging\DCx Camera Support\Develop\DotNet\uc480DotNet.dll');
end
pause(5)
cam = uc480.Camera;
if ~strcmp(char(cam.Init), 'SUCCESS')
error('Could not initialize camera');
end
if ~strcmp(char(cam.Display.Mode.Set(uc480.Defines.DisplayMode.DiB)), ...
'SUCCESS')
error('Could not set display mode');
end
if ~strcmp(char(cam.PixelFormat.Set(uc480.Defines.ColorMode.SensorRaw8)), ...
'SUCCESS')
error('Could not set pixel format');
end
if ~strcmp(char(cam.Trigger.Set(uc480.Defines.TriggerMode.Software)), 'SUCCESS')
error('Could not set trigger format');
end
[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
img.Data = reshape(uint8(tmp), [img.Width, img.Height, img.Bits/8]);
% Draw image
himg = imshow(img.Data, 'Border', 'tight');
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
t = himg.CData();
imwrite(t, 'thortest.jpg')
%Close camera
if ~strcmp(char(cam.Exit), 'SUCCESS')
error('Could not close camera');
end

Answers (0)

Categories

Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!