Grabbing frames from webcam with a Raspberry pi

I have just received my Raspberry pi.

My objective is to use webcams with the board, so the first step is to connect and test a webcam with the board.

So after installing the official debian image on my pi board, I have plugged a webcam on one of the USB ports. Then I have tried:



It shows an USB video device connected to the board.

The next step ti to look into the devices directory for a video device:



But… nothing!

After looking on the web it seems that the video for linux driver is not included in the official raspberry pi debian image…

So I have two choices, recompiling my  kernel, or trying another image.

I have tested the beta version and the archlinux image.

The second one works, I now have a video device in /dev!

But I’m connected in ssh to the board, so I need a sample tool to test the webcam.

I’have found on the official video for linux documentation API an example.

There is another example on another video for linux API documentation.

Here is the code:


Compile it and test it with :

And you will find some ppm pictures grabbed  from you webcam in the same directory.


With the new firmware version compile with:

3 replies on “Grabbing frames from webcam with a Raspberry pi”

  1. My current Raspbian version is 3.2.27+ and detect my Webcam (sorry i don’t have the model), you code runs perfect, but the OpenCV cannot open the device.

Comments are closed.