Preview switching between two videoinputs?

조회 수: 3 (최근 30일)
Mark Lowder
Mark Lowder 2016년 6월 27일
댓글: Mark Lowder 2016년 7월 12일
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?

답변 (1개)

Prasad Mendu
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.
  댓글 수: 1
Mark Lowder
Mark Lowder 2016년 7월 12일
Thanks for the answer. I've looked at those pages, but the issue is that at the moment, I'm not even all that concerned about triggering them at the same exact time - merely having them both run at the same time would be nice. After a bit of digging, it looks like the issue is that the frame rate for the previews dies once the second camera is connected, and the same issue extends into recording absent any preview. In the camera's native software, both can record at the same time without a loss to performance. Is there any reason Matlab would do worse? I've considered the possibility that it is a bandwidth issue resulting from too high of a resolution, but I also can't seem to downsample that as the only listed AcceptableFormats for the video source are all 2560*1920.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile 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!

Translated by