Please note: this was an early post – the content of this post was turned into a video that is available on this page: Beaglebone: Video Capture and Image Processing  on Embedded Linux using OpenCV

Getting started

Start by plugging in the camera with the power down and then booting, praying that the device is picked up. lsusb is a utility for displaying information about USB buses in the system and the devices connected to them.  lsusb should show:

 

When you cd /dev and do an ls you should see video0 at the bottom:

If so, you are ready to go:

Video4Linux2

Video4Linux or V4L is a video capture application programming interface for Linux, supporting many USB webcams, TV tuners, and other devices. Video4Linux is closely integrated with the Linux kernel. To list the devices:

To list the formats available:

Get the driver detail:

We can list the controls available:

Get all of the information available for the camera:

We can then set an individual value. For example to set the brightness:

If we wish to modify the resolution:

You will notice that the resolution has changed to 1920 x 1080 and the Pixel Format has changed to ‘H264’ which is a feature of the Logitech C920 HD USB Camera.

Using the capture.c and grabber.c programs

 Again, this is better described in the recent video on this page: Beaglebone: Video Capture and Image Processing  on Embedded Linux using OpenCV

The pixel format or type of compression, set by the application

Identifier                              Code                           Byte 0                                        Byte 1                                         Byte 2
V4L2_PIX_FMT_RGB24 ‘RGB3’ r7 r6 r5 r4 r3 r2 r1 r0 g7 g6 g5 g4 g3 g2 g1 g0 b7 b6 b5 b4 b3 b2 b1 b0

http://linuxtv.org/downloads/v4l-dvb-apis/packed-rgb.html#rgb-formats

Video images are typically interlaced. Applications can request to capture or output only the top or bottom field, or both fields interlaced or sequentially stored in one buffer or alternating in separate buffers.

The source video capture code came from:

http://linuxtv.org/downloads/v4l-dvb-apis/capture-example.html

Changed code by setting:

The new code is available at: github.com/derekmolloy/boneCV

OpenCV

OpenCV, which stands for Open (Source) Computer Vision is a substantial library of image processing and computer vision functions. The functions have been highly optimized and so are suitable for robotic type applications and indeed for implementation on boards such as the Beaglebone Black.

opkg update

opkg list |grep opencv

To see what we just installed!

Check that you opencv environment is setup correctly:

My Simple Cpp Code example:

Compile using:

Final Edge Detection Code:

Unfortunately 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:

Performance

See my post on the performance of OpenCV here: Setting the Beaglebone CPU Speed