How can I import 2 cameras at the same time?

1 次查看(过去 30 天)
Hey guys, i have 2 cameras including laptop cam and webcam.
But when I code in Command Window, that result just show 1 device while I was open 2 cam.
So, how can i code to show 2 cams at the same time.
My code in editor:
% show webcam
cam1 = videoinput('winvideo', 1,'MJPG_640x480');
% only capture one frame per trigger, we are not recording a video
cam1.FramesPerTrigger = 1;
% output would image in RGB color space
cam1.ReturnedColorspace = 'rgb';
% tell matlab to start the webcam on user request, not automatically
triggerconfig(cam1, 'manual');
% we need this to know the image height and width
vidRes1 = get(cam1, 'VideoResolution');
% image width
imWidth1 = vidRes1(1);
% image height
imHeight1 = vidRes1(2);
% number of bands of our image (should be 3 because it's RGB)
nBands1 = get(cam1, 'NumberOfBands');
% create an empty image container and show it on axPreview
hImage1 = image(zeros(imHeight1, imWidth1, nBands1), 'parent', handles.axes3);
% begin the webcam preview
preview(cam1, hImage1);
handles.vid1=cam1;
guidata(hObject, handles);

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB Support Package for IP Cameras 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by