Video frames all garbled and not in sequence

1 visualización (últimos 30 días)
gujax
gujax el 20 de Ag. de 2024
Movida: Walter Roberson el 20 de Ag. de 2024
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 comentario
Walter Roberson
Walter Roberson el 20 de Ag. de 2024
frame 260 appears prior to frame 259 etc
Interesting -- but how can you tell that the frames are out of order?

Iniciar sesión para comentar.

Respuesta aceptada

gujax
gujax el 20 de Ag. de 2024
Movida: Walter Roberson el 20 de Ag. de 2024
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.

Más respuestas (0)

Productos


Versión

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by