How can I configure a hardware-triggered acquisition from a GigE Vision camera?
Prashant Kumar answered .
2025-11-20
v = videoinput('gige', 1, 'Mono8');
s = v.Source;
% Determine optimum streaming parameters as described in the
% "GigE Vision Quick Start Configuration Guide"
% s.PacketSize =
% s.PacketDelay =
Immediate acquisition By default, an immediate acquisition takes place when videoinput start function is executed, if a hardware triggering configuration is not explicitly specified.
For simplicity, this example performs an acquisition of a finite number of frames, and stores them in MATLAB base workspace.
% 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 and timestamps from acquisition input buffer % into workspace [data, ts] = getdata(v, v.FramesAvailable);
Display acquired frames and plot acquisition timestamps.
figure;
imaqmontage(data)
figure;
plot(ts, '.')
xlabel('Frame index');
ylabel('Timestamp (s)');
% Specify total number of frames to be acquired % One frame is acquired for each external signal pulse. numFrames = 30; v.FramesPerTrigger = 1; v.TriggerRepeat = numFrames - 1; % Specify 'hardware' videoinput trigger type triggerconfig(v, 'hardware', 'DeviceSpecific', 'DeviceSpecific');
Configure camera for FrameStart trigger mode and specify external triggering signal input line and desired trigger condition.
% This requires setting the TriggerSelector first; once a TriggerSelector % value is selected, setting a trigger property (for example, % TriggerMode to 'on') applies only to the specified trigger mode (FrameStart). s.TriggerSelector = 'FrameStart'; s.TriggerSource = 'Line1'; s.TriggerActivation = 'RisingEdge'; s.TriggerMode = 'on'; % Specify a constant exposure time for each frame s.ExposureMode = 'Timed'; s.ExposureTimeAbs = 4000; % Start hardware-triggered buffered continuous acquisition, and wait for % acquisition to complete start(v) wait(v, 10) % Transfer acquired frames and timestamps from acquisition input buffer % into workspace [data2, ts2] = getdata(v, v.FramesAvailable);
Display acquired frames and timestamps
figure;
imaqmontage(data2)
figure;
plot(ts2, '.')
xlabel('Frame index');
ylabel('Timestamp (s)');
% Specify total number of frames to be acquired % One frame is acquired for each external signal pulse. numFrames = 30; v.FramesPerTrigger = 1; v.TriggerRepeat = numFrames - 1; % Specify 'hardware' videoinput trigger type triggerconfig(v, 'hardware', 'DeviceSpecific', 'DeviceSpecific');
Configure camera for FrameStart trigger mode and specify external triggering signal input line and desired trigger condition.
% This requires setting the TriggerSelector first; once a TriggerSelector % value is selected, setting a trigger property (for example, % TriggerMode to 'on') applies only to the specified trigger mode (FrameStart). s.TriggerSelector = 'FrameStart'; s.TriggerSource = 'Line1'; s.TriggerActivation = 'RisingEdge'; s.TriggerMode = 'on'; % For exposure time control configure a TriggerWidth exposure mode s.ExposureMode = 'TriggerWidth'; % Specify camera ExposureOverlapTimeMaxAbs in microseconds s.ExposureOverlapTimeMaxAbs = 5000; % Start hardware-triggered buffered continuous acquisition, and wait for % acquisition to complete start(v) wait(v, 10) % Transfer acquired frames and timestamps from acquisition input buffer % into workspace [data3, ts3] = getdata(v, v.FramesAvailable);
Display acquired frames and timestamps
figure;
imaqmontage(data3)
figure;
plot(ts3, '.')
xlabel('Frame index');
ylabel('Timestamp (s)');
figure;
plot(diff(ts3), '-x');
xlabel('Frame index');
ylabel('diff(Timestamp) (s)');