필터 지우기
필터 지우기

Why is imaq getdata function only returning a single frame when I know multiple frames have been acquired?

조회 수: 2 (최근 30일)
Problem Description: I have a line scan camera that uses the signal from a rotary encoder to trigger the acquisition of a single frame at ever pulse edge. Both devices are connected to a frame grabber board that is configured via a camera configuration file (.ccf). This same .ccf file is used when I create the video input object within MATLAB. In the Image Acquisition GUI app, everything functions as expected, and I am able to export the images logged to memory to the disk once acquisition is complete (in this case 40,000 frames). I can later load this into my workspace and process the image data accordingly. However, when I attempt to perform the same operation programmatically, the getdata function only returns a single frame instead of the expected 40,000.
Troubleshooting: I added a call to the wait function after calling start to ensure that acquisition would be complete when getdata is requested but I received the following error: WAIT reached its timeout before OBJ stopped running.This stopped execution of the script. To circumvent this, I specified an explicit waittime of 10 min which is far in excess of how long the acquisition actually takes to complete. This seemed to solve the timeout error and control of the command window is returned once acquisition is finished but getdata only returns a single frame.
Code and Software versions: IMAQ toolbox 6.2, IMAQ Toolbox Support Package for Teledyne Dalsa Sapera Hardware 20.1.1
vid = videoinput('dalsa', 2, 'path_to_config_file.ccf');
src = getselectedsource(vid);
vid.FramesPerTrigger = 1;
% TriggerRepeat is zero based and is always one
% less than the number of triggers.
vid.TriggerRepeat = 40000;
preview(vid);
start(vid); wait(vid,600);
stoppreview(vid);
image_data = getdata(vid);

답변 (1개)

Manoj Mirge
Manoj Mirge 2023년 4월 20일
Hi Ziam,
The getdata function on receiving only single input argument of type video input object will return data, which will contain the number of frames specified in the FramesPerTrigger property of the corresponding video input object.
vid=videoinput('dalsa', 2, 'path_to_config_file.ccf')
vid.FramesPerTrigger = 1;
image_data=getdata(vid)
% With current syntax your image_data will contain number of frames specified % in FramesPerTrigger property which is 1.
To get multiple frames we need to specify number of frames as second argument to getdata function.
In your case to get 40000 frames of data you will need to specify that in getdata function.
image_data=getdata(vid,40000);
Furthermore, instead of using wait function in your MATLAB script you can use FramesAcquiredFcn callback to acquire 40000 frames from your video input object.
You can try below code:
vid = videoinput('dalsa', 2, 'path_to_config_file.ccf');
src = getselectedsource(vid);
vid.FramesPerTrigger = 1;
vid.TriggerRepeat = 40000;
vid. FramesAcquiredFcnCount=40000;
vid.FramesAcquiredFcn=@myfun;
start(vid);
function myfun(src,~){
image_data=getdata(src,src.FramesAcquiredFcnCount);
% image data will contain 40000 frames.
}
You can read more about getdata function from the below link:
You can read more about videoinput function from the below link:
Hope this helps.

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by