MATLAB Answers

T Rockett
0

Using a webcam with Matlab

Asked by T Rockett
on 8 Apr 2015
Latest activity Commented on by T Rockett
on 9 Apr 2015
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 Comments

T Rockett
on 9 Apr 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?
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
on 9 Apr 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

Sign in to comment.

0 Answers