Preview switching between two videoinputs?
2 ビュー (過去 30 日間)
古いコメントを表示
Hey Everyone,
I'm trying to make a GUI that can record two videos at the same time to later compare for differences between them. I've been using two axes and preview(VidObj, image, 'Parent', handles.Axes) to assign the previews to the appropriate axes in the GUI. The thing is, whichever one I connect second starts to flicker between the two video feeds instead of only previewing the correct video. What's really weird is that I've done the same thing in a different GUI and had no such issue, and the code for this is copy-pasted from there.
Code:
% --- Executes on button press in startStopLeftCamera.
function startStopLeftCamera_Callback(hObject, eventdata, handles)
% hObject handle to startStopLeftCamera (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(handles.startStopLeftCamera,'String'),'Start Left Camera')
% Camera is off. Change button string and start camera.
set(handles.startStopLeftCamera,'String','Stop Left Camera')
start(handles.LeftVideo)
vidres=handles.LeftVideo.VideoResolution;
hImage2 = image(zeros(vidres(2), vidres(1), handles.LeftVideo.NumberOfBands),'Parent',handles.LeftCamera);
axes(handles.LeftCamera)
preview(handles.LeftVideo, hImage2)
else
% Camera is on. Stop camera and change button string.
set(handles.startStopLeftCamera,'String','Start Left Camera')
stoppreview(handles.LeftVideos)
stop(handles.LeftVideo)
end
% --- Executes on button press in startStopRightCamera.
function startStopRightCamera_Callback(hObject, eventdata, handles)
% hObject handle to startStopRightCamera (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
if strcmp(get(handles.startStopRightCamera,'String'),'Start Right Camera')
% Camera is off. Change button string and start camera.
set(handles.startStopRightCamera,'String','Stop Right Camera')
start(handles.RightVideo)
vidres=handles.RightVideo.VideoResolution;
hImage = image(zeros(vidres(2), vidres(1),handles.RightVideo.NumberOfBands),'Parent',handles.RightCamera);
axes(handles.RightCamera)
preview(handles.RightVideo, hImage)
else
% Camera is on. Stop camera and change button string.
set(handles.startStopRightCamera,'String','Start Right Camera')
stoppreview(handles.RightVideo)
stop(handles.RightVideo)
end
Any ideas as to how to keep the previews to the correct axes?
0 件のコメント
回答 (1 件)
Prasad Mendu
2016 年 7 月 8 日
The following links talk about the similar issue and it might be helpful for you to look at those links. One of the links states that to synchronize multiple devices precisely, you generally need to use devices that support hardware triggering.
参考
カテゴリ
Help Center および File Exchange で MATLAB Support Package for IP Cameras についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!