フィルターのクリア

how can i display video and image simultaneously in GUI-matlab?

4 ビュー (過去 30 日間)
Koohyar
Koohyar 2020 年 10 月 20 日
コメント済み: Zoya Saevna 2021 年 7 月 13 日
Hi everyone,
Anybody knows that how can I display a video and a picture in two different windows simultaneously (with 1 pushbotton and without dilay in GUI)? I used the following code but the imgae (in second window-axes(handles.axes2)) is diplayed after finishing the video. I need to start both at the same time.
Thanks in advance.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
axes(handles.axes1);
vidObj = VideoReader('Try.avi');
numFrames = 0;
while hasFrame(vidObj)
F = readFrame(vidObj);
numFrames = numFrames + 1;
imagesc(F)
drawnow
end
numFrames
axes(handles.axes2);
imshow('index.jpg');

回答 (1 件)

Nitin Kapgate
Nitin Kapgate 2020 年 10 月 27 日
Your code is running sequentially. At first, it displays the complete video frame by frame.
After the video is displayed, the image is displayed at the end. Thus both the video and images are not displayed simultaneously.
You can overcome this by displaying the image at the beginning and then displaying the video.
The modified code should be like this:
function pushbutton1_Callback(hObject, eventdata, handles)
% Display the image first
axes(handles.axes2);
imshow('index.jpg');
% hObject handle to pushbutton1 (see GCBO)
axes(handles.axes1);
vidObj = VideoReader('Try.avi');
numFrames = 0;
% Display the video frame by frame
while hasFrame(vidObj)
F = readFrame(vidObj);
numFrames = numFrames + 1;
imagesc(F)
drawnow
end
numFrames
end
  2 件のコメント
Koohyar
Koohyar 2020 年 10 月 29 日
Nitin Kapgate, many thanks for this, but I need to display two videos in two windows simultaneously with no lag.
Zoya Saevna
Zoya Saevna 2021 年 7 月 13 日
😆😆

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStartup and Shutdown についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by