Why doesn't the frame rate drop with extra processing time per frame?
Afficher commentaires plus anciens
I'm processing images inside a for loop with the trigger set to immediate. In the following code:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate approximately ~450 FPS.
After adding a few functions into the for loop:
start(vid);
frame = getdata(vid);
t_total_Start = tic;
for iframe = 1:Nframe
[frame,lT(iframe)] = getdata(vid);
snapshotbuffer(:,:,iframe) = frame;
% Two functions used to process the frame
function1(frame);
function2(frame);
hvpc.step(frame);
end
release(hvpc);
elapsedTime = toc(t_total_Start);
timePerFrame = elapsedTime / iframe
effectiveFrameRate = 1 / timePerFrame
The effective frame rate is still around 450 FPS, but I expected it to drop because function1 and function2 are now inside the loop. I measured their execution time using tictoc, and they take about 0.5 ms together, so the frame rate should drop to around 370 FPS (1/(1/450 + 0.5e-3) = 370 FPS).
I also tested by replacing function1 and function2 with pause(0.0005), but the frame rate still didn’t drop. I'm wondering why the frame rate isn’t decreasing as expected.
I have another question about timing. Is getdata providing the correct timestamps after adding functions inside the loop? Should I use tic and toc to measure the time for each frame? The timestamps from getdata don’t seem to change, even when I add a pause in the loop.
Thanks!
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Image Data Acquisition dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!