ECE597 OpenCV on the BeagleBoard

I'm retiring this page. There must be more up-to-date information elsewhere.

Introduction
There are currently a dozen examples as well as instructions on using OpenCV, including incomplete references on this wiki: Using OpenCV computer vision library with BeagleBoard and 'Running OpenCV on the BB' on Google Groups. As an 'unstable' package for the BeagleBoard however, the OpenCV packages are currently beyond the last update. For the sake of simplicity, this page will detail natively compiling OpenCV applications on the BeagleBoard.

Installing OpenCV
After running 'opkg update', you should have access to the most current OpenCV packages:


 * opencv - 2.1.0
 * opencv-apps - 2.1.0
 * opencv-dbg - 2.1.0
 * opencv-dev - 2.1.0
 * opencv-doc - 2.1.0
 * opencv-samples - 2.1.0
 * opencv-samples-dbg - 2.1.0
 * opencv-samples-dev - 2.1.0
 * python-opencv

For the purposes of cross-compiling on the BeagleBoard, you will need the OpenCV header in opencv-dev and the libraries from opencv-apps. The 'opencv' package is currently a dummy that the others all list as a dependency.

At the time of this writing, the libraries are not properly installed from opencv-apps. It is possible to check for correct install by looking for the file 'libhighgui.so' in /usr/lib. Installing opencv-apps adds libhighgui.so.2.1 and libhighgui.so.2.1.0, however libhighgui.so is required for the linker to find it. A quick workaround for now is to create a symbolic link between libhighgui.so and libhighgui.so.2.1 ln -s /usr/lib/libhighgui.so.2.1 /usr/lib/libhighgui.so There are several other libraries installed that will need similar treatment as they are used.

Other Required Packages
We'll be using gcc to compile c programs, so make sure you have 'gcc' and 'gcc-symlinks' installed as well.

Using a Webcam with the BeagleBoard
So far, this has been tested with a Logitech Webcam Pro 9000, but should with with any UVC Webcam. You'll want to make sure you install the libv4l-dev package first. When you plug in the webcam, 'dmesg|tail' should show that a UVC Camera was plugged in. If not, check that your kernel module 'kernel-module-uvcvideo' isn't somehow corrupted which has happened in the past, running 'opkg update kernel-module-uvcvideo' should correct it if it is. If the webcam is recognized, then the following demo program will display a video window:


 * 1) include 
 * 2) include 
 * 3) include 
 * 4) include "stdio.h"
 * 5) include "string.h"

int main(int argc, char ** argv) {   char Vid[] = "WebCam";

IplImage * frm; CvCapture * capture;

capture = cvCaptureFromCAM(-1); // the parameter for a cam

if( capture ) { cvNamedWindow (Vid,1);

do { frm = cvQueryFrame( capture );

if( frm ) cvShowImage (Vid, frm);

int k = cvWaitKey( 50 ); if (k == 27 || k == '\r') // Press ESC and Enter break;                    // for out

} while( frm );

cvDestroyWindow( Vid ); // Destroy the window cvReleaseCapture( &capture ); }   else puts( "Cannot Open the Webcam" ); } To compile, make sure to include the OpenCV headers (-I/usr/include/opencv) and link to the highgui library (-lhighgui).

Compile Warnings
The following messages are generated when compiling: In file included from /usr/include/opencv/cxcore.h:70, from /usr/include/opencv/cv.h:58, from onecam.c:1 /usr/include/opencv/cxtypes.h: In function 'cvRound': /usr/include/opencv/cxtypes.h:228: warning: incompatible implicit declaration of built-in function 'lrint' However, it appears they have no effect on general operation.