Video frames all garbled and not in sequence

21 次查看(过去 30 天)
Hi
I am using imaqtools in particular using gentl driver with Lucid vision camera. Ni Max and Arena records a sequence of frames just fine.
But matlab is having trouble. Initially the frames are in sequence for first few ten frames and then the frames randomly start jumping around e.g., frame 260 appears prior to frame 259 etc.
When I look at frame time, it all seems to be in sequence. Here is my code
Not only that the timing shows that frame interval is about 40ms.
Based on the frame rate that I am providing (40fps), the frame rate should have been ~22ms
% Generated in MATLAB R2022b on 14-Jan-2023 18:07:51
% Connect to Device
% Create connection to the device using the specified adaptor with the specified format.
clearvars;
v = videoinput("gentl", 1, "Mono16");
%% Configure Device-Specific Properties
% Configure properties that are specific to this device.
v.SelectedSource = "1";
%src displays a summary of video object
src = getselectedsource(v);
src.ExposureAuto = 'Off';
src.AcquisitionFrameRateEnable = 'true';
src.AcquisitionFrameRate = 40;
exposuretime =1000;%ms
src.ExposureTime = exposuretime;
%PRF=1000;
numFrames=ceil(231*4*5/src.AcquisitionFrameRate);
v.FramesPerTrigger = 1.5*numFrames;%extra frames for not missing out
set(v, 'Timeout', 600);
%% Record Video for Set Number of Frames
% Record video data for a specified number of frames.
start(v);
%give sufficient time 3x
wait(v,3*1/src.AcquisitionFrameRate*numFrames);
%stop(v);
while get(v,'FramesAvailable')<1 %Wait until at least 1 frame is available
unavailable=1;
end
% Determine the number frames acquired.
framesLogged = v.FramesAcquired;
[recording1,Time,Meta] = getdata(v, framesLogged);
%% Show Recording
% View the recorded video.
implay(recording1);
%% Clean Up
% Delete the videoinput object and clear variables from the workspace.
%stop(v);
delete(v)
clear src v
%%
fid = fopen('2D_scan.bin','w');
fwrite(fid',recording1,"uint16");
  1 个评论
Walter Roberson
Walter Roberson 2024-8-20,19:27
frame 260 appears prior to frame 259 etc
Interesting -- but how can you tell that the frames are out of order?

请先登录,再进行评论。

采纳的回答

gujax
gujax 2024-8-20,20:45
移动:Walter Roberson 2024-8-20,20:58
I was moving my hands and it suddenly would jump back to earlier frames. However, I discovered the issue.
There were two specific ones.
Using gentl driver.
It (Matlab) did not pick up the settings of 'ChannelPacketSize'=9000 but defaulted to 1400. I have no idea why even though I have set it up using device manager. Moreover, other Apps pick up the right value
Because of this I was getting striped images. I couldnt figure it out and thought I should perhaps play with 'packettransferrate_delay' which was set at 0 ns. When I changed it to '8ns' (it increments in units of 8ns) suddenly the stripes went away and I was happy only to realize that now the packets were all jumbled in sequence.
Just forcing the 'ChannelPacketSize' to 9000 solved all the problems.

更多回答(0 个)

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by