Preview switching between two videoinputs?
2 views (last 30 days)
Show older comments
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 Comments
Answers (1)
Prasad Mendu
on 8 Jul 2016
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.
See Also
Categories
Find more on MATLAB Support Package for IP Cameras in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!