drawnow and refreshing screen
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
I'm using MATLAB 2014b and Windows 7. I have activated vertical sync on my computer. I have defined the following image:
% Create vector white image
img = 255 * ones(600, 600, 3, 'uint8');
% Get handle of the image
handle = imshow(img);
When I run the following code:
tic;
drawnow;
toc;
I expect toc to be aprox. 16 ms since my screen is configured at 60 Hz, so, when I call drawnow, it waits until the next frame to display the image. However, toc is below 10 ms. I can't understand why is this happening.
0 Kommentare
Antworten (2)
Jan
am 26 Okt. 2017
Bearbeitet: Jan
am 26 Okt. 2017
drawnow processes all events waiting to update the interval values of the figure, e.g. rendering of created uicontrol 's or created or changed data of 2D and 3D graphics.
It is not documented, if it triggers an output to the graphic card, and I assume, this does not happen. There is not relation between the time needed by drawnow and the frequency of the monitor, because it updates the contents of the figure, but the syncing with the monitor happens (most likely) as soon as possible afterwards.
2 Kommentare
Jan
am 27 Okt. 2017
@E. Valero: Please take a look into the documentation by your own: https://www.mathworks.com/help/matlab/ref/drawnow.html . There you find:
*drawnow expose* updates figures, but defers callbacks. This syntax
is not recommended. Use the nocallbacks option instead.
There is no hint, that it has anything to do with a screen syncing, but this command is even deprecated.
Again: drawnow cares for the update of the properties of figures and all their children, but does not trigger a syncing with the monitor. There is no other command for syncing also in Matlab.
Image Analyst
am 25 Okt. 2017
It probably just sends a message to the video adapter to refresh the screen and then returns to MATLAB without actually waiting for the video adapter to finishing doing that. This is essentially how message based systems work.
2 Kommentare
Jan
am 27 Okt. 2017
@E. Valero: No. I guess you can do this in the Mex level, but this will still have a certain delay due to leaving the Mex function and re-entering the Matlab level. Then "the exact same moment" is not even meaningful.
Please re-think your problem. What do your want to solve actually?
Siehe auch
Kategorien
Mehr zu Graphics Performance finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!