Capture video from multiple webcams simultaneously.
11 次查看(过去 30 天)
显示 更早的评论
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 个评论
Otto Sponring
2019-6-18
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;
回答(1 个)
Harsh
2017-7-20
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.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!