how to display any image for 500 ms

15 visualizaciones (últimos 30 días)
ANKIT MAURYA
ANKIT MAURYA el 20 de Dic. de 2021
Respondida: yanqi liu el 23 de Dic. de 2021
how to write a code to display any image for 500 ms

Respuesta aceptada

Geoff Hayes
Geoff Hayes el 20 de Dic. de 2021
@ANKIT MAURYA - you can try using a timer to stop displaying the image (or in this case, the figure for the image) after 0.5 seconds. For example,
function myTimerExample
close all;
hFig = figure;
sampleImage = uint8(randi(255,300,400,3));
image(sampleImage);
t = timer('TimerFcn', {@timerCallback, hFig}, 'StartDelay', 0.5, 'ExecutionMode', 'SingleShot');
start(t);
function timerCallback(hObject, hEvent, hFigure)
close(hFigure);

Más respuestas (1)

yanqi liu
yanqi liu el 23 de Dic. de 2021
clc; clear all; close all;
% preapare data
xyloObj = VideoReader('traffic.avi');
nFrames = xyloObj.NumberOfFrames;
data = [];
for step = 1 : nFrames
data{step} = read(xyloObj, step);
end
% display by 500 ms
figure(1); clf;
for step = 1 : nFrames
imshow(data{step}, []);
title(sprintf('%03d %s', step, datestr(now,'mmmm dd, yyyy HH:MM:SS.FFF AM')));
pause(500/1000);
end

Productos


Versión

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by