フィルターのクリア

How can I import 2 cameras at the same time?

1 回表示 (過去 30 日間)
Diec Thuan
Diec Thuan 2021 年 9 月 17 日
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 Center および File ExchangeMATLAB 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