Capture video from multiple webcams simultaneously.
12 views (last 30 days)
Show older comments
Hi everyone, I am trying to use the MATLAB to record videos from 4 web-cameras simultaneously. I am new to MATLAB and am only find help to record one video at a time and that too only at 4fps when i know the camera can record at 30FPS. I would like some help with how to proceed with this coding. I am using webcam object now to preview the video like in this link
https://www.mathworks.com/help/supportpkg/usbwebcams/ug/acquire-webcam-images-in-a-loop.html
I am using 4 Genius full HD cameras, My PC runs on windows 10 x64, 8gb RAM and 2GB Nvidia GPU. Any help is appreciated. Please de tell me if any further information is required or if there are any toolboxes that can help.
1 Comment
Otto Sponring
on 18 Jun 2019
Sriram if this is still relevant to you I just wrote a small program and glad to share with you to capture multiple USB camera and live stream.
n=webcamlist;
m=size(n);
sw=m(1);
switch(sw)
case 1
cam1=webcam(1);
cam1.Resolution='640x480';
for i=1:200
if strcmp(s,'space')==1
hold off;
break;
end
img1=snapshot(cam1);
img1 = imresize(img1,0.5);
hold on;
figure(3)=imshow(img1);
hold off;
end
case 2
h=figure;
set(h,'KeyPressFcn',@KeyPressCb);
cam1=webcam(1);
cam2=webcam(2);
cam1.Resolution='640x480';
cam2.Resolution='640x480';
for i=1:200
img1=snapshot(cam1);
img1 = imresize(img1,0.5);
img2=snapshot(cam2);
img2 = imresize(img2,0.5);
hold on;
combImg = imfuse(img1, img2, 'montage');
h=imshow(combImg);
hold off;
end
case 3
cam1=webcam(1);
cam2=webcam(2);
cam3=webcam(3);
cam1.Resolution='640x480';
cam2.Resolution='640x480';
cam3.Resolution='640x480';
for i=1:200
if strcmp(s,'space')==1
hold off;
break;
end
nn=webcamlist;
img1=snapshot(cam1);
img1 = imresize(img1,0.5);
img2=snapshot(cam2);
img2 = imresize(img2,0.5);
img3=snapshot(cam3);
img3 = imresize(img3,0.5);
hold on;
combImg = imfuse(img1, img2, 'montage');
combImg = imfuse(combImg, img3, 'montage');
figure(3)=imshow(combImg);
hold off;
end
end
clear all;
close all;
Answers (1)
Harsh
on 20 Jul 2017
If the webcam object for the camera exposes the 'FrameRate' property, then you can try to configure the value to a desired and allowable value. You can learn more about this here.
On the other hand, to get a more granular access to the image acquisition process and hardware, you can use the Image Acquisition Toolbox with the OS Generic Video Interface.
However, note that the frame rate is a characteristic of the camera. Any rate supported by the device and the acquisition system is supported by the toolbox. You can learn more about this here:
To capture video from multiple webcams simultaneously, one possible work flow is to use four independent webcam objects within a parfor loop using functionality from the Parallel Computing Toolbox.
If you need further help with this, please contact MathWorks Technical Support here: https://www.mathworks.com/support/contact_us/.
Please be sure to provide a detailed description of the issue and attach any relevant files / code / examples required to investigate the issue.
See Also
Categories
Find more on Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) 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!