Using a webcam with Matlab

Hello
I am trying to write a program to view images from a webcam. The program is working brilliantly on my new desktop computer, and gives me the desired frame rate (15 fps). However when I try to run my program on an older computer the frame rate does not look as high (visibly jerky), even though the "preview(cam)" function reports 15 fps. I have tried changing the exposure of the camera but this didn't work. I have also tested the camera on the old computer using the Microsoft webcam software and the frame rate looks much smoother.
The main difference between the two computers is the processor: the old one uses an intel i5-2400 with HD graphics 2000, and the new one uses an intel i5-4590 with HD graphics 4600. Both are using windows 7. Also I am using a Microsoft lifecam cinema which has a maximum resolution of 1280x720.
Here is some code that I have been using the view the webcam feed:
cam = videoinput('winvideo', 1, 'MJPG_1280x720');
src = getselectedsource(cam);
src.ExposureMode = 'manual';
src.WhiteBalanceMode = 'manual';
src.FocusMode = 'manual';
set(cam,'TriggerRepeat',inf);
set(cam,'ReturnedColorSpace','rgb');
triggerconfig(cam, 'Manual');
set(cam,'FramesPerTrigger',1);
So my question boils down to: what is causing the camera feed to appear to have a low frame rate in Matlab on my old computer? Is it some combination of older hardware, and some limitation with the way that Matlab interfaces with the camera? What could be the limiting factor in the old computer? Would a new graphics card in the old computer help?
If any one has any ideas, they would be much appreciated.
Many thanks, T

9 comentarios

Thomas Koelen
Thomas Koelen el 8 de Abr. de 2015
Is the sampling time the same on both image aquisitions?
T Rockett
T Rockett el 8 de Abr. de 2015
Yes Thomas, the sample rate is set to 15 fps for both image acquisitions. I didn't show this in the code I posted.
Thomas Koelen
Thomas Koelen el 8 de Abr. de 2015
Do you get higher frames/second on the old pc if you set it to a lower resolution? also compared to the better computer.
Thomas
T Rockett
T Rockett el 8 de Abr. de 2015
I will run a few tests and report back Many thanks for your help so far
T Rockett
T Rockett el 8 de Abr. de 2015
I wrote a small program to measure the frame rate over time. I found that changing the resolution had no effect on the measured frame rate. However when I looked at the video feed, changing the resolution had a noticeable effect on the time that it took for any movement to show up on the screen.
Lowering the resolution to decrease this time lag is undesirable as I want the maximum number of pixels representing the area that I am interested in.
Any ideas on how to get rid of this time lag?
Thomas Koelen
Thomas Koelen el 9 de Abr. de 2015
You can't that are the limits of a slower computer. I'm afraid that this issue can't be solved!
T Rockett
T Rockett el 9 de Abr. de 2015
The main difference between the two computers seems to be the graphics capability, would a new graphics card in the old computer fix this issue?
Thomas Koelen
Thomas Koelen el 9 de Abr. de 2015
Your gpu does not do anything, the difference in CPU might, the 4590 is about 1.3 times as fast as the 2400. That combined with the older computers operating system not being as "clean" as the newer one might be the problem. Also, are you sure the "smooth" video you get on the newer computer is actually that smooth? you could have a look here how big the differences actually are (comparing).
turn off motion blur and set the background speed to 0px/s
T Rockett
T Rockett el 9 de Abr. de 2015
The time lag is small enough to not be very noticeable on the newer computer. However on the older computer it is rather annoying.
Many thanks for your help Thomas

Iniciar sesión para comentar.

Respuestas (0)

Productos

Preguntada:

el 8 de Abr. de 2015

Comentada:

el 9 de Abr. de 2015

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by