kaushal_23q asked . 2022-01-06

How to configure a hardware-triggered acquisition from a GigE Vision camera?

How can I configure a hardware-triggered acquisition from a GigE Vision camera?

Image Acquisition Toolbox , matlab

Expert Answer

Prashant Kumar answered . 2024-12-21 15:05:43

Image Acquisition Toolbox provides functionality for hardware-triggered acquisition from GigE Vision cameras. This is useful in applications where camera acquisition needs to be synchronized with another device (such as an  instrument or another camera) by means of an external triggering signal. Other applications include controlling the acquisition frame rate with an external signal, or acquiring a multiple-exposure image sequence for high dynamic range (HDR) imaging.
This example shows how to use the videoinput gige interface to configure a camera acquisition to allow external triggering-signal control over the frame rate and over the exposure time.
Requirements and hardware setup
  • MATLAB R2016a or later, Image Acquisition Toolbox, and GigE Vision hardware support package
  • GigE Vision compliant camera with hardware triggering capability; this example uses a Basler acA1300.
  • Gigabit Ethernet adapter, which provides a direct camera network connection, configured as described in the "GigE Vision Quick Start Configuration Guide"
  • External triggering setup, which can provide a triggering signal to  the camera trigger line input. For example, a DAQ device with digital output, an Arduino board, or a function generator instrument can be used to output a custom triggering signal. Refer to the camera usermanual for triggering signal voltage level / current requirements and for correct signal connections to the camera input lines.
Connect to camera Create a videoinput with the desired video format and get access to the camera device specific properties. When using the  videoinput gige adaptor, the camera GenICam features and parameter values are represented as videoinput source properties.
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)');
FrameStart trigger Most GigE Vision cameras support a FrameStart hardware trigger mode, which is used to configure the camera to acquire a frame for each rising edge (or falling edge) signal applied to a camera line input.
 
In this example, a function generator instrument is used to supply a 25 Hz external periodic square wave signal applied to camera 'Line1' input, and the signal frequency effectively controls the camera frame rate.
 
When using the gige adaptor, to configure a hardware triggered acquisition, the videoinput trigger type needs to be set to 'hardware', while the remaining configuration is done via the videoinput source properties, which represent the corresponding camera GenICam features/parameters.
 
% 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)');
Note: Some camera models also support an AcquisitionStart trigger, which, depending on the camera model and configuration, could be used as a start trigger for a multi-frame acquisition, or as an enabler for a FrameStart trigger.
 
  Exposure time control Certain GigE Vision camera models support control of the exposure time each frame by the external signal pulse duration.
 
This configuration can be achieved with a FrameStart hardware trigger mode and a TriggerWidth exposure mode.
Possible applications include high dynamic range (HDR) imaging, where the external triggering signal can be a sequence of pulses of different pulse width durations. For a simple example on how to generate a custom triggering signal using an Arduino board refer to the file attachments.
 
 
 
% 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)');


Not satisfied with the answer ?? ASK NOW

Frequently Asked Questions

MATLAB offers tools for real-time AI applications, including Simulink for modeling and simulation. It can be used for developing algorithms and control systems for autonomous vehicles, robots, and other real-time AI systems.

MATLAB Online™ provides access to MATLAB® from your web browser. With MATLAB Online, your files are stored on MATLAB Drive™ and are available wherever you go. MATLAB Drive Connector synchronizes your files between your computers and MATLAB Online, providing offline access and eliminating the need to manually upload or download files. You can also run your files from the convenience of your smartphone or tablet by connecting to MathWorks® Cloud through the MATLAB Mobile™ app.

Yes, MATLAB provides tools and frameworks for deep learning, including the Deep Learning Toolbox. You can use MATLAB for tasks like building and training neural networks, image classification, and natural language processing.

MATLAB and Python are both popular choices for AI development. MATLAB is known for its ease of use in mathematical computations and its extensive toolbox for AI and machine learning. Python, on the other hand, has a vast ecosystem of libraries like TensorFlow and PyTorch. The choice depends on your preferences and project requirements.

You can find support, discussion forums, and a community of MATLAB users on the MATLAB website, Matlansolutions forums, and other AI-related online communities. Remember that MATLAB's capabilities in AI and machine learning continue to evolve, so staying updated with the latest features and resources is essential for effective AI development using MATLAB.

Without any hesitation the answer to this question is NO. The service we offer is 100% legal, legitimate and won't make you a cheater. Read and discover exactly what an essay writing service is and how when used correctly, is a valuable teaching aid and no more akin to cheating than a tutor's 'model essay' or the many published essay guides available from your local book shop. You should use the work as a reference and should not hand over the exact copy of it.

Matlabsolutions.com provides guaranteed satisfaction with a commitment to complete the work within time. Combined with our meticulous work ethics and extensive domain experience, We are the ideal partner for all your homework/assignment needs. We pledge to provide 24*7 support to dissolve all your academic doubts. We are composed of 300+ esteemed Matlab and other experts who have been empanelled after extensive research and quality check.

Matlabsolutions.com provides undivided attention to each Matlab assignment order with a methodical approach to solution. Our network span is not restricted to US, UK and Australia rather extends to countries like Singapore, Canada and UAE. Our Matlab assignment help services include Image Processing Assignments, Electrical Engineering Assignments, Matlab homework help, Matlab Research Paper help, Matlab Simulink help. Get your work done at the best price in industry.