Regarding some clarification about running opencv on beagle board

428 views
Skip to first unread message

chitresh

unread,
Jul 27, 2009, 9:10:23 AM7/27/09
to Beagle Board
I am having some problem regarding using opencv library on beagle
board. I already booted the beagle board and working on Angstrom
environment, I want to use opencv libraries for my project
specification and My problem descriptions are:

1. Which complier / cross compiler will be needed for opencv.

2. From where we ll get that complier and steps to install it.

3. I am using "OpenCV_1.0" version on windows, Is their any other
version needed for beagle board(Angstrom).

4. Please specify the steps to install / compile the opencv on
angstrom.

Please specify the steps to run a example program over this.

If you are using any other open embedded environment instead of
angstrom please tell me the all this steps on that.

djlewis

unread,
Jul 28, 2009, 8:20:08 AM7/28/09
to Beagle Board
I believe opencv is now available for opkg install.
To compile applications for it try...

Building openCV applications on BeagleBoard

assumptions:
1) Already have Angstrom 2.6.29 running by following:
http://elinux.org/BeagleBoardBeginners

2) ffmpeg is already installed

begin:

1) run opkg update ( gets latest list of packages )

2) if you haven't already -
opkg install task-native-sdk cpp gccmakedep

3) add python packages with 'opkg install'
python-distutils, python-compile, python-compiler, python-devel

4)opkg install ffmpeg-dev

5) opkg install opencv
----------------------------------------------------------------

I modified a script to compile source programs and named it
compile.sh

use: ./compile.sh source destination
eg: ./compile capture.c capture

#!/bin/sh
export LD_LIBRARY_PATH=/usr/local/lib
echo `pkg-config --cflags opencv`
echo `pkg-config --libs opencv`
gcc `pkg-config --cflags opencv` -g -o $2 $1 `pkg-config --libs
opencv`
----------------------------------------------------------------

sample capture.c: opens webcam, saves three files in same folder,
no arguments needed.

// Capture.c
//
// Example showing how to connect to a webcam and capture
// video frames
#include </usr/include/opencv/cv.h>
#include </usr/include/opencv/highgui.h>
#include </usr/include/opencv/cxcore.h>
#include "stdio.h"
#include "string.h"

int main(int argc, char ** argv)
{
CvCapture * pCapture = 0;
IplImage * pVideoFrame = 0;
int i;
char filename[50];

//returns the number of available cameras in the system
// int ncams = cvcamGetCamerasCount( );
// fprintf(stderr, "Number of cameras: %d\n", ncams);

// Initialize video capture
// pCapture = cvCaptureFromCAM( CV_CAP_ANY );
pCapture = cvCaptureFromCAM( -1 );
if( !pCapture )
{
fprintf(stderr, "failed to initialize video capture\n");
return -1;
}

// Capture three video frames and write them as files
for(i=0; i<3; i++)
{
pVideoFrame = cvQueryFrame( pCapture );
if( !pVideoFrame )
{
fprintf(stderr, "failed to get a video frame\n");
}

// Write the captured video frame as an image file
sprintf(filename, "VideoFrame%d.jpg", i+1);
if( !cvSaveImage(filename, pVideoFrame) )
{
fprintf(stderr, "failed to write image file %s\n", filename);
}

// IMPORTANT: Don't release or modify the image returned
// from cvQueryFrame() !
}

// Terminate video capture and free capture resources
cvReleaseCapture( &pCapture );

return 0;
}
----------------------------------------------------------
Launch app with:

export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH

(launch on console command line with)
LD_PRELOAD=/usr/lib/libv4/v4l1compat.so ./capture

or

LD_PRELOAD=/usr/lib/libv4/v4lconvert.so ./capture

one of these two should work for your webcam.

I hope this helps,
Don Lewis

---------------------------------------------------------------------------------------
Reply all
Reply to author
Forward
0 new messages