In the video below I look at how you can get started with video capture and image processing on the Beaglebone. It is an introductory video that should give people who are new to this topic a starting point to work from. I look at three different distinct challenges:

  • How do you capture video from a USB webcam under Linux – I do this using the capture.c source code that uses Video4Linux to capture a raw stream from the USB camera. This raw stream is then wrapped with a H264 header using FFMPEG.
  • How do you capture image frames from a USB webcam under Linux – I do this using the grabber.c source code that again uses Video4Linux to capture raw video frames in the uncompressed PPM format.
  • How do you use OpenCV to capture and image process frames so that you can build computer vision applications under Linux on the Beaglebone – I do this using the boneCV.cpp program as described below. This code uses the OpenCV library which is available on the Angstrom distribution of the Beaglebone. Finally, I write a small program boneCVtiming.cpp to test the performance of the Beaglebone black for capturing and processing image data.

In this video I use a Logitech C920 and the Beaglebone Black. I would highly recommend both of these devices because of the processing power of the Beaglebone black and the high resolution capability of the C920. However, you should be able to adapt the code to any specific camera.

The Video

[youtube id=”8QouvYMfmQo” width=”600″ height=”350″]

If you use this code or the content of the associated video in your research, please cite:

Molloy, D. [DerekMolloyDCU]. (2013, May, 25). Beaglebone: Video Capture and Image Processing on Embedded Linux using OpenCV [Video file]. Retrieved from

Example OpenCV Images

Here are the two images that were captured during the course of the video:

capture edges

The image on the left is the original image captured on the Beaglebone black using OpenCV, which has been encoded in PNG format. The image on the right is the edge detected version that was processed on the Beaglebone black using the OpenCV Sobel edge detector. Please press on these images for higher resolution versions.

Source Code

The code for this video is available at: but the important code is presented below:

The OpenCV Code is as follows:

 This is the main program discussed in the video. There is also a program to test the performance of the OpenCV Application:

The build script for these files is given in build (note the -lrt for the timing example):

-O2 means optimize for code size and execution time -O3 would optimize even more for execution time (O for optimize)

-Wall enables all possible compiler warning messages – should always be used to give the best possible code.

Make sure that you set the build script to be executable.

Performance and GPU Support

At the end of the video I discussed the performance of OpenCV on the Beaglebone. This would be greatly improved if there was support for the GPU that is present on the Beaglebone; however, a quick check using the code below indicates that GPU support is not available, nor do I think it would be easy to achieve. If you try to perform an operation such as:

You will get the following output error: