How can I import 2 cameras at the same time?
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
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);
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/741219/image.png)
0 comentarios
Respuestas (0)
Ver también
Categorías
Más información sobre MATLAB Support Package for IP Cameras en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!