How to receive hardware triggers multiple times using Image Acquisition Toolbox?

6 ビュー (過去 30 日間)
Yuhan Yang
Yuhan Yang 2021 年 1 月 21 日
Hi,
I'm using an aliend vision camera. The camera is triggered by an external source. I want the camera to capture 30 frames per trigger. The trigger will repeate 200 times. And the data can be automatically logged into disk.
Here's my script:
vid = videoinput('gentl', 1, 'Mono8');
src = getselectedsource(vid);
src.ExposureTime = 8000;
src.AcquisitionFrameRateMode = 'Basic';
src.AcquisitionFrameRate = 7.6;
src.TriggerSelector = 'AcquisitionStart';
src.TriggerMode = 'on';
src.TriggerSource = 'Line0';
vid.FramesPerTrigger = 30;
triggerconfig(vid, 'hardware', 'DeviceSpecific', 'DeviceSpecific');
vid.TriggerRepeat = 200-1;
% log
vid.LoggingMode = 'disk';
diskLogger = VideoWriter('TEST.avi', 'Grayscale AVI');
vid.DiskLogger = diskLogger;
diskLogger.FrameRate = fr;
% start
start(vid);
wait(vid, inf);
stop(vid)
delete(vid)
clear
However, this script doesn't work as my expectation. The hardware can recognize the first trigger, but then it looks like the acquistion is executed continously until it collectes 200*30 frames.
I tried to change vid.TriggerRepeat to 0 and loop the acquistion 200 times. This method works normally most of time. However, it sometimes produce an error when executing start(vid): can not set ROI. It doesn't happen every time. It just happens sometimes in the middle of the acqusition. That's why I want to use a non-zero vid.TriggerRepeat for multiple triggers, so that I only need to start(vid) once.

回答 (0 件)

製品


リリース

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by