Capture from Multiple Webcams
35 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi everyone, I am trying to use the Image Acquisition Toolbox to capture images from six webcams at the same time. The problem I am having is that only five actually work in MATLAB, even though all six will preview at the same time in other webcam programs. Is there a way to get MATLAB to use MJPEG instead of YUY2? The cameras do support MJPEG, which uses considerably less bandwidth, but it does not show up in matlab.
I am on windows 7 x64, with 12 gb of RAM. The CPU usage is below 30% with all cameras previewing. Are there any limitation I don't know about that would cause only 5 to work at a time? Maybe matlab is limiting memory or cpu usage, even though I have plenty? Any suggestions?
Thanks
4 comentarios
deepak jayaraj
el 28 de Jun. de 2013
Hello, I am not able to connect more than 1 camera to the image acquisition blocks from simulink. It is not even getting recognized. can you please suggest what I should be doing. I am using a Windows 7 PC with 16 GB RAM and 2013 a matlab version
Sriram Kollipara
el 17 de Jul. de 2017
Editada: Sriram Kollipara
el 17 de Jul. de 2017
Hi,
Can you possibly send me the code you are using to do this. If you cannot can you suggest some way or point me some resources that can help. It would be a great help. Email:sriramgs14@gmail.com
Thanks Greg.
Respuestas (7)
David Tarkowski
el 22 de Abr. de 2011
The most likely issue is that you are running into bandwidth limitations somewhere on your PC. My first thought was that it was a USB bandwidth limitation, but if you are able to acquire from five cameras simultaneously, I would guess that you are using at least two or three USB root controllers. This would mean that the culprit is likely not the USB bus, but the bridge between the USB controllers and the rest of the PC. If that is the case, there isn't too much that you can do. If you use an PCIe expansion card like this one (just the first example that I found) that might work, but that is really just a hunch.
We don't generally support JPEG compression from cameras since JPEG is a lossy compression method. This means that data is lost and the returned images are not true representations of the data that was captured by the camera. I can look into adding that in for a future version of the toolbox, but I'll have to think about it.
3 comentarios
David Tarkowski
el 11 de Mayo de 2011
Greg,
The issue is almost certainly the lack of JPEG compression in the toolbox. TinCam is probably using the JPEG compression which uses significantly less bandwidth.
Mohsin
el 30 de Mayo de 2011
Hey im facing the same problem. Using a PCI usb card, I was able to acquire video from 4 cameras on my desktop but on my laptop, I cant seem to get video from more than 2 cameras. I tried a usb hub as well but it wont let me get video from more than 2 cameras though it shows all the four cameras on the image acquisition tool box. can u help? and can u please tell me about the usb root controller thing?
I am working on a core i3 with 3gb ram and 64bit windows 7 ultimate.
thanx
Tunc Askan
el 3 de Sept. de 2014
Here is my case, may be it helps the community ;).
- 16 Logitech HD 920 Webcams running at 15 fps, Full HD, RGB > ~90 MBs data flow per webcam
- Motherboard with Intel X79 Chipset, 64 GB RAM
- Windows 7 64 Bit
- Matlab R2013b & R2014a
Matlab image engine is not able to transfer the acquired video data (nearly 1.4 GBs for my case) directly to HDD during the capture, even if you use SSDs with enough bandwidth (source: Matlab Support). So, if you want to capture frame synchronized videos you need let whole data flow to RAM during the capture. Here is important to check the specs of your motherboard, chipset, USB host controllers etc. in order to avoid a bottleneck (check chipset diagrams). I'm using in my case 3 extra USB host controllers (<http://www.delock.de/produkte/G_89325/merkmale.html>) and two host controllers on the motherboard (bandwidth limited!). And the most important thing is to use the Microsoft USB Webcam driver, not the driver of the webcam! My experience is, you are not able to control the frame rate and capture synchronized through imaq when you don' t use Microsoft drivers. Below you can find an image, which shows the trigger times for 16 webcams.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/175505/image.png)
1 comentario
rohan gupta
el 21 de En. de 2015
Editada: rohan gupta
el 21 de En. de 2015
I am trying to record videos using two logitech c170 webcam at 15fps each. But I am unable to do so. Can you help me with this.
Windows 7 64 Bit
Matlab R2014a
I am using laptop which has 4GB RAM
Mark Jones
el 28 de Abr. de 2011
When all 6 are plugged in, do all 6 at least show up using IMAQHWINFO?
Is it always the same camera that is not accessible and if so, is this camera accessible from MATLAB when it is the only camera plugged in?
3 comentarios
Chinmayee
el 28 de Abr. de 2014
I am working on stereovision. I want to acquire images simultaneously from 2 Logitech webcams connected via USB ports. But I am getting the images with a long delay. How can I reduce the delay between the two captures or make the 2 cams trigger simultaneously?
Chamil Ranathunga
el 30 de Ag. de 2015
Remove your logitec webcam softwares .Only keep the drivers .then it will work
0 comentarios
jorge alejandro guerrero díaz
el 13 de Jun. de 2017
Editada: Walter Roberson
el 14 de Jun. de 2017
do you guys know how can i record video from matlab? i mean i doing it right now but when i use 1280xsomthing it record the video but when i play it, the video runs too fast, i wrote 30 frames per second but it does not work anyways, so can you help me? it works well with less than 900x something!
function control_Callback(~, ~, handles)
% hObject handle to control (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global VidObj cam vid aviobj
if cam == 0
[na,ca]=uiputfile({'*.avi'});
% nom = datestr(now, 'local');
% nombre = strcat(nom, '.avi');% Prepare the new file.
vid = VidObj;
aviobj = VideoWriter(fullfile(ca,na));
vid.LoggingMode = 'disk';
vid.DiskLogger = aviobj;
vid.TriggerRepeat = inf;
start(vid);
set(handles.control, 'String', 'PARAR');
set(handles.control, 'ForegroundColor','black');
set(handles.configuracion, 'enable', 'off');
set(handles.v_previa, 'enable', 'off');
cam = 1;
else
stop(vid);
% aviobj =
close(vid.DiskLogger);
delete(vid);
clear vid;
clear aviobj;
set(handles.control, 'String', 'GRABAR');
set(handles.control,'ForegroundColor', 'red');
set(handles.configuracion, 'enable','on');
set(handles.v_previa, 'enable', 'on');
cam = 0;
end
8 comentarios
Walter Roberson
el 17 de Jun. de 2017
if cam == 0
[na,ca]=uiputfile({'*.avi'});
% nom = datestr(now, 'local');
% nombre = strcat(nom, '.avi');% Prepare the new file.
vid = VidObj;
aviobj = VideoWriter(fullfile(ca,na));
vid.LoggingMode = 'disk';
vid.DiskLogger = aviobj;
vid.TriggerRepeat = inf;
vid.FrameRate = 3.75; %NEW LINE
start(vid);
set(handles.control, 'String', 'PARAR');
set(handles.control, 'ForegroundColor','black');
set(handles.configuracion, 'enable', 'off');
set(handles.v_previa, 'enable', 'off');
cam = 1;
else
stop(vid);
% aviobj =
close(vid.DiskLogger);
delete(vid);
clear vid;
clear aviobj;
set(handles.control, 'String', 'GRABAR');
set(handles.control,'ForegroundColor', 'red');
set(handles.configuracion, 'enable','on');
set(handles.v_previa, 'enable', 'on');
cam = 0;
end
jorge alejandro guerrero díaz
el 19 de Jun. de 2017
thank you i did it, i think it works nice, hope you have a nice day!!!.
Eduardo Aguilar
el 22 de Feb. de 2018
Hi Greg. Actually I wanna connect five microscope to Matlab R2016 but it send me an error when the third microscope start. Could you tell me how you connect your cams please?
0 comentarios
Piotr Bartczak
el 22 de Ag. de 2019
Editada: Piotr Bartczak
el 22 de Ag. de 2019
Hi All,
I was following your topic and got quite nice answers already. Perhaps my case is slighlty different since I am trying to run stereocamera via Matlab toolbox. I believe that the whole problem is related to the USB "hub" that allows video stream of two cameras via one USB 2.0 cable.
Camera type:
Fisheye 180degree Non-Fixed Stereo Webcam OmniVision OV9712 HD 720P Dual Lens USB Camera Module with Two Cameras Boards
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/235030/image.jpeg)
Both cameras can be esaily detected but there is no stream/privew available. I am able to change all camera properties however, after trying to prview it there is no error in the command line and no image in the window.
listCamPC=webcamlist
{'USB2.0 Camera' }
{'Integrated Camera'}
{'USB2.0 Camera' }
SelectedCam="USB2.0 Camera";
cam1 = webcam(SellistCamPC(1))
cam2 = webcam(listCamPC(3))
cam1.Exposure = -5;
cam1.ExposureMode = 'manual';
cam1.WhiteBalanceMode = 'manual';
cam1.Saturation = 0;
preview(cam1);
Can it be related to the same name of both cameras ("USB2.0 Camera") ?
>> cam1.Name="Camera1";
You cannot set the read-only property 'Name' of webcam.
Unfortunately, there is no way of changing it ?
Could you help me with it ?
Ps. both cameras do work properly when using basic webcam viewer, e.g., AMCap
3 comentarios
Piotr Bartczak
el 23 de Ag. de 2019
Thanks Walter !
Are there any USB switch avaiable on the market ?
It would be just great to connect 2-4 web cameras via switch/adapter connected to the laptop's USB port and capture image from each camera.
At this stage images do not need to be synchronized but the main idea is to reduce number of occupied USB ports.
When using different software cameras are called via their index and video streamig is possible. Any similar way to avoid calling webcamera via its name ?
Walter Roberson
el 23 de Ag. de 2019
webcamlist() can return a list of the webcams . webcam() can accept a device number.
However: if your webcams are identical in name, then you will have difficulty in imposing a unique ordering on them. If you unplug one of the webcams and plug it back in, it is not necessarily going to reappear at the same place in the list.
The device appears to be primarily 1280X720 MJPEG 30fps YUY2 9fps (or higher frame rates for lower sizes.) Simulink might be able to handle it; https://www.mathworks.com/help/xpc/io_ref/fromusbvideodevice.html . Other than that, the only MJPEG support that I seem to find appears to be for ipcam . Even if you were able to get a single JPEG frame from the camera, I would worry about the YUYV2 format. I would suggest trying to snapshot() a frame and examine it.
Sites I am looking at estimate that MJPEG 720P is about 10 megabits per second per camera at 10 fps. In theory even 4 of those should not strain USB 2.0
Ver también
Categorías
Más información sobre Image Acquisition Support Packages for Hardware Adaptors (Generic Video Interface) en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!