Capture from Multiple Webcams
조회 수: 18 (최근 30일)
이전 댓글 표시
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
deepak jayaraj
2013년 6월 28일
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
2017년 7월 17일
편집: Sriram Kollipara
2017년 7월 17일
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.
답변 (7개)
David Tarkowski
2011년 4월 22일
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
David Tarkowski
2011년 5월 11일
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
2011년 5월 30일
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
2014년 9월 3일
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.
댓글 수: 1
rohan gupta
2015년 1월 21일
편집: rohan gupta
2015년 1월 21일
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
2011년 4월 28일
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
Chinmayee
2014년 4월 28일
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
2015년 8월 30일
Remove your logitec webcam softwares .Only keep the drivers .then it will work
댓글 수: 0
jorge alejandro guerrero díaz
2017년 6월 13일
편집: Walter Roberson
2017년 6월 14일
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
Walter Roberson
2017년 6월 17일
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
2017년 6월 19일
thank you i did it, i think it works nice, hope you have a nice day!!!.
Eduardo Aguilar
2018년 2월 22일
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
Piotr Bartczak
2019년 8월 22일
편집: Piotr Bartczak
2019년 8월 22일
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
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
Piotr Bartczak
2019년 8월 23일
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
2019년 8월 23일
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
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!