Speeding up drawnow !

28 vues (au cours des 30 derniers jours)
Dan Matthews
Dan Matthews le 22 Mai 2017
Commenté : Jan le 22 Mai 2017
Hello Image analysis enthusiasts,
I have a GUI which accesses the camera, takes snapshot of the first available frame and updates the figure by setting the CData of the image data in every iteration of the loop. I want to achieve everything within 10-15 ms. Unfortunately, drawnow is very slow and alone takes 70 ms. Here is the sample code:
vid=videoinput('qimaging',1);
img=zeros(1600,1200,1);
h=imshow(img); % creates figure handle
start(vid);
for i=1:10000
image=peekdata(vid,1); % takes 6 milliseconds%
set(h,'CData',image); % takes 1 ms%
drawnow %takes 70 ms%
end
I have two questions: 1) Is there a way to speed up drawnow; I think currently, it updates the other uipanel and uicontrols in the GUI also and hence, it is slower. 2) I am confused if drawnow is really needed as I am already changing the imagedata by using 'set' in every frame. However, if I remove drawnow, my figures don't get updated.
Any help is greatly appreciated. Thanks!
  3 commentaires
Dan Matthews
Dan Matthews le 22 Mai 2017
Hello MathReallyWorks,
Yes, I read that thread before posting my question. The drawnow in that thread was very slow (~500 ms) due to use of imshow instead of updating CData in every frame. I'm already using CData to modify the image data and drawnow to update figures. With this, I complete the display of one frame in 80 ms out of which drawnow alone consumes 70 ms. I wonder if there is a way to further speed this up.
I'm accessing a live video from a camera and want to achieve a high frame rate. Thanks for the answer though !
Jan
Jan le 22 Mai 2017

Connectez-vous pour commenter.

Réponses (0)

Community Treasure Hunt

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

Start Hunting!

Translated by