4

I want to capture a USB webcam with my RPI2. I'm using a Microsoft Lifecam HD-3000.

The problem is that I can't get 30 FPS with a resolution 640x480. I think this is abnormal for a quad-core CPU.

On the RPI2 I get between 14-18 FPS and I'm not even saving the capture to a file.

I tested in console mode with avconv and also in the gui with luvcview.

luvcview -i 30 -s 640x480
or

avconv -f video4linux2 -input_format mjpeg -s 640x480 -r 30 -i /dev/video0 -y t1.avi

or
avconv -f video4linux2 -input_format yuyv422 -s 640x480 -r 30 -i /dev/video0 -y t2.avi

The Microsoft HD-3000 webcam has the following capabilites:

ffmpeg -f v4l2 -list_formats all -i /dev/video0

Raw: yuyv422 : YUV 4:2:2 (YUYV) : 640x480 1280x720 960x544 800x448 640x360 424x240 352x288 320x240 800x600 176x144 160x120 1280x800

Compressed: mjpeg : MJPEG : 640x480 1280x720 960x544 800x448 640x360 800x600 416x240 352x288 176x144 320x240 160x120

I also tested the same webcam on a dual core (Celeron) laptop running Ubuntu 14.04 and I get 30 FPS at 1280x720. So, I don't think the problem is with the webcam.

Is this normal for the RPI2 ? What could cause this low FPS ?

6
  • 2
    Two comments: Even though the RPi2's processor is "Quad Core", it is by no means up to par to a dual-core Intel processor. The Broadcom chip is not meant to be a replacement for a desktop processor (even though the nice look & feel of many OSes on the RPi makes you think otherwise). Second of all, the USB port on the RPi is limited in throughput - not sure if that plays a role here but worthy of consideration. I believe the maximum you can get is 30Mbps (but I could be wrong). 30 fps * 3 bits per pixel * 640*480 pixels is ~30Mbps, excluding overhead, assuming no compression.
    – Phil B.
    Commented Oct 9, 2015 at 2:12
  • 1
    I use Rpi for some basic image processing based automation work and here is what I've noticed. 1. Rpi 1 hardly gives 5 fps at max for 640x480. 2. Rpi 2 gives about 14 - 16 fps at 640x480. and this limitation is mainly due to processing capabilities of rpi and USB 2.0 speed limit. Commented Oct 9, 2015 at 5:27
  • @dastaan - recommend you put your comment in as an answer as this is what the OP is asking about - real life comparables from someone else who tries the same.
    – Phil B.
    Commented Oct 9, 2015 at 11:58
  • 2
    Ditto Phil B.'s first comment. Ghz are not an absolute metric; what a broadcom ARM core in the pi can do in 1000 cycles is substantially less that what an intel desktop core can in 1000 cycles because of advantages in the instruction set; there is also the issue of cache sizes, more and bigger registers, etc. My quad 64 bit 3.4 Ghz i5 is not simply 3.4 / 0.9 = 3.7 times faster than a pi 2. I do a lot of compiling of identical software on both machines and I would say the desktop is more like 20+ times faster...
    – goldilocks
    Commented Oct 9, 2015 at 14:19
  • 2
    ...The pi is like a phone. Will a phone work well with the built in camera? Sure. But just attaching a USB cam to an Android phone is problematic and no doubt disappointing to some people; AFAIK it is just plain impossible with an Apple. It is almost certain to be less optimal and more work for the processor than something intended to match the hardware.
    – goldilocks
    Commented Oct 9, 2015 at 14:19

1 Answer 1

7

Most probably, bottle neck in this case is CPU speed to process the feed.

I use Rpi for some basic image processing based automation work and here is what I've noticed.

  1. Rpi 1 hardly gives 5 fps at max @ 640x480. Blame single core @ 700 Mhz
  2. Rpi 2 gives about 14 - 16 fps at 640x480. (Quad core @ 900 Mhz)
  3. I've used Odriod-C1 (SBC mostly similar to Rpi 2 - Cortex A7 CPU @ 1.5 Ghz, Quad core) and BBB (BeagleBoard Black; single core, Cortex A7 - @ 1 Ghz) with USB cam as well just for the sake of comparison. Odriod seems to be giving the best performance (20 fps @ 640 x 480) and BBB gives you around 10 - 12 fps @ 640 x 480.

I believe from my experiments that upto some point, USB speeds doesn't play a significant part but as soon as you move towards high resolutions, you can't ignore it. Try connecting USB webcam on a ubuntu machine and try capturing @ 1024 x 768 or higher.

It would be also worth to note that Rpi camera module easily performs about 30 fps @ 720p mainly because it uses internal CSI bus and uses GPU core for encoding the feed.

Hope this comparison helps.

5
  • OK, but the CPU is running only at 30 %. Something seems not right... I will look into the USB bandwidth.
    – ssinfod
    Commented Oct 9, 2015 at 12:18
  • I tried the same webcam (Lifecam HD-3000) on my Ubuntu 14.04 and I got 30 fps at 1280x1024.
    – ssinfod
    Commented Oct 9, 2015 at 12:19
  • @user3585723 Try increasing resolution, make sure you're using USB 2.0 port and not 3.0. Commented Oct 9, 2015 at 12:21
  • @user3585723 Regarding 30 % usage, capture might be using single thread and hence other cores would be sitting idle, I don't know internals of how capture works but that's the most likely reason. If I remember correctly, I used to get 100 % CPU usage on Rpi 1 and BBB. Commented Oct 9, 2015 at 12:23
  • Beware specifics of how the metric is reported. 30% of the total power is actually 100% of one core and 20% of another.
    – goldilocks
    Commented Oct 9, 2015 at 14:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.