项目中需要读出网口通信的工业相机的图像数据,此文主要是记个笔记。

在左侧检测到的相机下选择像素格式mono,中间就会显示图像框,单击Start Preview以在当前图像设置中的屏幕上预览图像。


C:/ProgramData/MATLAB/SupportPackages/R2018a/toolbox/imaq/supportpackages/gige/GigEVisionQuickStartConfigurationGuide.pdf
1、
clear
clc
vid = videoinput('gige', 1, 'Mono8');
src = getselectedsource(vid);
vid.FramesPerTrigger = 1;
set(vid,'TriggerRepeat',Inf);
vid.FramesPerTrigger = Inf;
set(vid,'FramesPerTrigger',1);
vid.FrameGrabInterval=1;
% preview(vid); %预览
while (1)
frame=getsnapshot(vid);
figure(1)
imshow(frame);
% title('原始图像');
drawnow;%实时更新图像
end
2、官方的文档里的
v = videoinput('gige', 1, 'Mono8');
s = v.Source;
% Determine optimum streaming parameters as described in the
% "GigE Vision Quick Start Configuration Guide"
s.PacketSize = 9000;
% s.PacketDelay =
% Set exposure time and mode
s.ExposureMode = 'Timed';
s.ExposureTimeAbs = 4000;
% The default videoinput trigger type is 'immediate', which is explicitly
% configured here for clarity.
triggerconfig(v, 'immediate');
% Specify number of frames to acquire
v.FramesPerTrigger = 30;
v.TriggerRepeat = 0;
% Start continuous buffered acquisition and wait for acquisition to complete
start(v);
wait(v, 10);
% Transfer acquired frames from acquisition input buffer into workspace.
data = getdata(v, v.FramesAvailable);
figure;
imaqmontage(data)