Running OpenCV on the BB

1,923 views
Skip to first unread message

sm1810

unread,
Jul 30, 2009, 2:38:22 PM7/30/09
to Beagle Board
Hi,
I'm a complete newbie to the beagleboard.
I have worked on computer vision and I needed a portable system for
OCR and text-to-speech. The beagleboard seemed to be a pretty good
option. I've read a lot of the wikis and documentation but I have
worked primarily on Windows, so I'm still pretty clueless, though I'm
more than willing to switch to Linux.

My main issue is that I have developed my C++ programs using OpenCV.
How do I get that working on the beagleboard? What about the OpenCV
libraries and the API? Do I need to translate the code or can I keep
using functions like cvCaptureFromCam(0) ?

I'm really confused!! I'd appreciate any help on this topic.
Thanks,
Sam

Andrey Nechypurenko

unread,
Jul 31, 2009, 4:25:19 AM7/31/09
to discu...@beagleboard.org
Hi Sam,

> How do I get that working on the beagleboard? What about the OpenCV
> libraries and the API? Do I need to translate the code or can I keep
> using functions like cvCaptureFromCam(0) ?

The following thread might be helpful for you:

On Tue, Jul 28, 2009 at 2:20 PM, djlewis<djl...@tcworks.net> wrote:
>
> 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
>
> ---------------------------------------------------------------------------------------
> On Jul 27, 8:10 am, chitresh <saraswat.chitr...@gmail.com> wrote:
>> 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.


HTH,
Andrey.

sm1810

unread,
Jul 31, 2009, 1:01:58 PM7/31/09
to Beagle Board
Hi Andrey,

Thanks so much....you have no idea how much that helped me out!!
Just one stupid question -- it's not imperative to install the python
packages right...I mean I have no intention of using any python
scripts, so I can just skip that step right.

Thanks again :)

Sam

Andrey Nechypurenko

unread,
Aug 3, 2009, 4:57:53 AM8/3/09
to beagl...@googlegroups.com, sm1...@gmail.com
Hi Sam,

> Thanks so much....you have no idea how much that helped me out!!

I am glad that it was helpful for you.

> Just one stupid question -- it's not imperative to install the python
> packages right...I mean I have no intention of using any python
> scripts, so I can just skip that step right.

I am not sure. My guess is that Python might be necessary for some GUI
staff. I would suggest to try without Python and see if it works as
you need.

Regards,
Andrey.

DotDotDog

unread,
Aug 2, 2009, 11:19:29 PM8/2/09
to Beagle Board
Thx for your notes. when i follow your process, i got the error,
cannot find the gcc or arm-angstrom-linux-gnueabi-gcc, What can I do
now? many thanks for your reply.

On Jul 31, 4:25 pm, Andrey Nechypurenko <andreyn...@googlemail.com>
wrote:
> > sample capture.c: openswebcam, saves three files in same folder,
> > no arguments needed.
>
> > // Capture.c
> > //
> > // Example showing how to connect to awebcamand capture

raj

unread,
Aug 3, 2009, 2:22:26 PM8/3/09
to Beagle Board
Hi DotDotDog, It seems u do not have toolchain. if u are on
beagleboard ... just do

opkg list | grep gcc
or
opkg list | grep arm-angstrom-linux-gnueabi

u made find which package is required

DotDotDog

unread,
Aug 3, 2009, 11:01:48 PM8/3/09
to Beagle Board
Thx for your help, I have installed the arm-angstrom-linux-gnueabi-gcc
by opkg.
after running the compile.sh, i got the error this time:
arm-angstrom-linux-gnueabi-gcc: pkg-config --cflags opencv: No such
file or directory
arm-angstrom-linux-gnueabi-gcc: pkg-config --libs opencv: No such file
or directory
arm-angstrom-linux-gnueabi-gcc: error trying to exec 'cc1': execvp: No
such file or directory

I have already opkg install opencv, but I found that there is no /usr/
local/lib generated. How to fix it? where is the opencv lib placed?

Rickey

djlewis

unread,
Aug 4, 2009, 10:21:46 AM8/4/09
to Beagle Board
Hello Rickey,
Which file or directory is missing? Have you installed pkg-config?
Did you follow the doc posted earlier to the letter setting up your
environment variables?

tnx,
Don Lewis

DotDotDog

unread,
Aug 4, 2009, 9:40:21 PM8/4/09
to Beagle Board
I install opencv on BB by "opkg install opencv", but there is no /usr/
local/lib generated, and no /usr/lib/libv4/v4l1compat.so .. i wonder
how to install opencv on BB, and how to set the library.. sigh~~:(

Koen Kooi

unread,
Aug 4, 2009, 10:26:09 PM8/4/09
to beagl...@googlegroups.com

Op 5 aug 2009, om 03:40 heeft DotDotDog het volgende geschreven:

>
> I install opencv on BB by "opkg install opencv", but there is no /usr/
> local/lib generated,

No package will create a /usr/local, since that is reserved for local
installs, not system installs like packages.


> and no /usr/lib/libv4/v4l1compat.so

isn't that part of the libv4l package?

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Beagle Board" group.
> To post to this group, send email to discu...@beagleboard.org.
> To unsubscribe from this group, send email to unsub...@beagleboard.org
> For more options, visit this group at http://groups.google.com/group/beagleboard?hl=en
> -~----------~----~----~----~------~----~------~--~---
>

PGP.sig

janek

unread,
Aug 4, 2009, 11:45:02 PM8/4/09
to Beagle Board
Hi DotDotDog,

There is a number of packages related to opencv and you don't need
all of them.
Try to install opencv-samples like this:'opkg install opencv-samples'
You can verify installed packages by: 'opkg list_installed | more'
By default your opencv include files are in '/usr/include/opencv'
directory (highgui.h, ...)
and opencv library files are in '\usr\lib\' directory (libcv,
libcvaux2, ...)
The sample applications are located here /usr/share/opencv/samples/c
and you can run them from here as they are precompiled already
If you do 'cd /usr/share/opencv/samples/c'
and execute for example 'image' you will see a famous picture of Lena

good luck

Jan

Rickey Leung

unread,
Aug 10, 2009, 6:49:46 AM8/10/09
to beagl...@googlegroups.com
Dear Jan,

I used the " opkg install opencv-samples" command to install opencv sample.
My Devkit8000 displays:

root@beagleboard:/usr/lib# opkg install opencv-samples
Installing opencv-samples (1.0.0+cvs20081115-r2.1) to root...
Downloading
http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base/opencv
-samples_1.0.0+cvs20081115-r2.1_armv7a.ipk
Installing libcxcore2 (1.0.0+cvs20081115-r1.1) to root...
Downloading
http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base/libcxc
ore2_1.0.0+cvs20081115-r1.1_armv7a.ipk
Collected errors:
* Package libcxcore2 wants to install file /usr/lib/libcxcore.so.2
But that file is already provided by package * opencv
* Package libcxcore2 wants to install file /usr/lib/libcxcore.so.2.0.0
But that file is already provided by package * opencv

It's because I run "opkg install opencv" before, so that the libxccore
cannot be installed again. Rught?

But after this, I can't find and folder mentioned in your email, no
"/usr/share/opencv", no "/usr/include/opencv", how come? so trouble to
develop software in Devkit8000.

Please help, many thanks.

Rickey

Koen Kooi

unread,
Aug 10, 2009, 7:03:59 AM8/10/09
to beagl...@googlegroups.com

Op 10 aug 2009, om 12:49 heeft Rickey Leung het volgende geschreven:
>
> But after this, I can't find and folder mentioned in your email, no
> "/usr/share/opencv", no "/usr/include/opencv", how come? so trouble to
> develop software in Devkit8000.

As mentioned before in an opencv thread: you need to install the
development packages (e.g. opencv-samples-dev) if you want the headers
as well.

regards,

Koen

PGP.sig

DotDotDog

unread,
Aug 10, 2009, 9:59:07 PM8/10/09
to Beagle Board
Koen,

I got the following msg when running "opkg install opencv-samples-
dev":

root@beagleboard:~# opkg install opencv-samples-dev
Installing opencv-samples-dev (1.0.0+cvs20081115-r2.1) to root...
Downloading
http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base/opencv-samples-dev_1.0.0+cvs20081115-r2.1_armv7a.ipk
libcxcore-dev: unsatisfied recommendation for python-dev
libtiff-dev: unsatisfied recommendation for libgcc-dev
libglib-2.0-dev: unsatisfied recommendation for gobject-2.0-dev
libglib-2.0-dev: unsatisfied recommendation for gmodule-2.0-dev
libglib-2.0-dev: unsatisfied recommendation for libgcc-dev
......
......

but still no "opencv" folder generated. what's the problem then?

Rickey
>  PGP.sig
> < 1KViewDownload

janek

unread,
Aug 11, 2009, 12:49:18 AM8/11/09
to Beagle Board
Hi DotDotDog

opencv is a library (not an application), so will not see a folder
called "opencv"
See my previous email for location of header and lib files and example
precompiled opencv applications

good luck

Jan

On Aug 11, 11:59 am, DotDotDog <dotdot...@gmail.com> wrote:
> Koen,
>
> I got the following msg when running "opkg install opencv-samples-
> dev":
>
> root@beagleboard:~# opkg install opencv-samples-dev
> Installing opencv-samples-dev (1.0.0+cvs20081115-r2.1) to root...
> Downloadinghttp://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base...
> libcxcore-dev: unsatisfied recommendation for python-dev
> libtiff-dev: unsatisfied recommendation for libgcc-dev
> libglib-2.0-dev: unsatisfied recommendation for gobject-2.0-dev
> libglib-2.0-dev: unsatisfied recommendation for gmodule-2.0-dev
> libglib-2.0-dev: unsatisfied recommendation for libgcc-dev
> ......
> ......
>
> but still no "opencv" folder generated. what's the problem then?
>
> Rickey
>
> On Aug 10, 7:03 pm, Koen Kooi <k...@beagleboard.org> wrote:
>
>
>
> > Op 10 aug 2009, om 12:49 heeft Rickey Leung het volgende geschreven:
>
> > > But after this, I can't find and folder mentioned in your email, no
> > > "/usr/share/opencv", no "/usr/include/opencv", how come? so trouble to
> > > develop software in Devkit8000.
>
> > As mentioned before in an opencv thread: you need to install the  
> > development packages (e.g. opencv-samples-dev) if you want the headers  
> > as well.
>
> > regards,
>
> > Koen
>
> >  PGP.sig
> > < 1KViewDownload- Hide quoted text -
>
> - Show quoted text -

Glen Duncan

unread,
Aug 11, 2009, 1:43:54 AM8/11/09
to beagl...@googlegroups.com
On Mon, Aug 10, 2009 at 9:59 PM, DotDotDog <dotd...@gmail.com> wrote:

Koen,

I got the following msg when running "opkg install opencv-samples-
dev":

root@beagleboard:~# opkg install opencv-samples-dev
Installing opencv-samples-dev (1.0.0+cvs20081115-r2.1) to root...
Downloading
http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base/opencv-samples-dev_1.0.0+cvs20081115-r2.1_armv7a.ipk
libcxcore-dev
: unsatisfied recommendation for python-dev
libtiff-dev: unsatisfied recommendation for libgcc-dev
libglib-2.0-dev: unsatisfied recommendation for gobject-2.0-dev
libglib-2.0-dev: unsatisfied recommendation for gmodule-2.0-dev
libglib-2.0-dev: unsatisfied recommendation for libgcc-dev
......
......

but still no "opencv" folder generated. what's the problem then?

Notice the first error. Looks like you need python and python-dev. You may have to install the others in turn.

DotDotDog

unread,
Aug 11, 2009, 6:03:07 AM8/11/09
to Beagle Board
Yes, I installed the python-dev, but still got problem when compiling
the Capture.c:

root@beagleboard:~# gcc 'pkg-config --cflags opencv' -g -o Capture
Capture.c 'pkg-config --libs opencv'
gcc: pkg-config --cflags opencv: No such file or directory
gcc: pkg-config --libs opencv: No such file or directory

Rickey


On Aug 11, 1:43 pm, Glen Duncan <playas...@gmail.com> wrote:
> On Mon, Aug 10, 2009 at 9:59 PM, DotDotDog <dotdot...@gmail.com> wrote:
>
> > Koen,
>
> > I got the following msg when running "opkg install opencv-samples-
> > dev":
>
> > root@beagleboard:~# opkg install opencv-samples-dev
> > Installing opencv-samples-dev (1.0.0+cvs20081115-r2.1) to root...
> > Downloading
>
> >http://www.angstrom-distribution.org/feeds/2008/ipk/glibc/armv7a/base...

Koen Kooi

unread,
Aug 11, 2009, 7:58:29 AM8/11/09
to beagl...@googlegroups.com

Op 11 aug 2009, om 12:03 heeft DotDotDog het volgende geschreven:

>
> Yes, I installed the python-dev, but still got problem when compiling
> the Capture.c:
>
> root@beagleboard:~# gcc 'pkg-config --cflags opencv' -g -o Capture
> Capture.c 'pkg-config --libs opencv'
> gcc: pkg-config --cflags opencv: No such file or directory
> gcc: pkg-config --libs opencv: No such file or directory

You're using straight quotes instead of backticks, try $(pkg-config --
cflags opencv) to avoid all the quote/tick/etc problems

regards,

Koen

PGP.sig
Reply all
Reply to author
Forward
0 new messages