Compiling Program with OpenCV on BeagleBone Ubuntu

I have a beaglebone running ubuntu 11.10 headless using the images supplied here
http://elinux.org/BeagleBoardUbuntu

Ive been trying to compile the program below, its taken from one of the OpenCV samples and modified a bit to just save the captured images instead of displaying them in a window.http://pastebin.com/3CtTVk0Z

I have all of the packages associated with OpenCV installed and this is the output from

pkg-config --cflags --libs opencv

-I/usr/include/opencv -lml -lcvaux -lhighgui -lcv -lcxcore

When i compile the program using…

gcc -I/usr/include/opencv -L/usr/lib -lhighgui opencv_cap.c

I get the output listed here
http://pastebin.com/HyS7WH6C

I can compile this same program using the same gcc line on my main computer and it runs fine. I have no idea how or where something is going amiss and was wondering if anyone has had a similar issue or any insight on how to resolve this problem?

Thanks
-Brandon

Hi Brandon,

Yes there is a reason, they are not needed for the test program i have (at least i think).
influenced by http://linuxconfig.org/introduction-to-computer-vision-with-opencv-on-linux

The one i listed above is the bare essentials for this to “work” on my desktop, compiling with

gcc -I/usr/include/opencv -lml -lcvaux -lhighgui -lcv -lcxcore -L/usr/lib opencv_cap.c

yields the same results. (also added -L/usr/lib)

-Brandon

Also relevant, here is the out put from

ls -lah /usr/lib/libcv*
-rw-r–r-- 1 root root 3.4M 2011-09-15 01:19 /usr/lib/libcv.a
-rw-r–r-- 1 root root 1.9M 2011-09-15 01:19 /usr/lib/libcvaux.a
lrwxrwxrwx 1 root root 15 2011-09-15 01:18 /usr/lib/libcvaux.so → libcvaux.so.2.1
lrwxrwxrwx 1 root root 17 2011-09-15 01:18 /usr/lib/libcvaux.so.2.1 → libcvaux.so.2.1.0
-rw-r–r-- 1 root root 702K 2011-09-15 01:19 /usr/lib/libcvaux.so.2.1.0
lrwxrwxrwx 1 root root 12 2011-09-15 01:18 /usr/lib/libcv.so → libcv.so.2.1
lrwxrwxrwx 1 root root 14 2011-09-15 01:18 /usr/lib/libcv.so.2.1 → libcv.so.2.1.0
-rw-r–r-- 1 root root 1.6M 2011-09-15 01:19 /usr/lib/libcv.so.2.1.0

and

ls -lah /usr/include/opencv/
total 1000K
drwxr-xr-x 2 root root 4.0K 2012-01-05 14:56 .
drwxr-xr-x 50 root root 4.0K 2012-01-05 14:56 …
-rw-r–r-- 1 root root 65K 2010-04-05 20:24 cvaux.h
-rw-r–r-- 1 root root 67K 2010-04-05 20:24 cvaux.hpp
-rw-r–r-- 1 root root 40K 2010-04-05 20:24 cvcompat.h
-rw-r–r-- 1 root root 71K 2010-04-05 20:24 cv.h
-rw-r–r-- 1 root root 46K 2010-04-05 20:24 cv.hpp
-rw-r–r-- 1 root root 6.0K 2011-09-14 23:53 cvinternal.h
-rw-r–r-- 1 root root 12K 2010-04-05 20:24 cvtypes.h
-rw-r–r-- 1 root root 2.5K 2010-04-05 20:24 cvver.h
-rw-r–r-- 1 root root 42K 2010-04-05 20:24 cvvidsurv.hpp
-rw-r–r-- 1 root root 21K 2010-04-05 20:24 cvwimage.h
-rw-r–r-- 1 root root 76K 2010-04-05 20:24 cxcore.h
-rw-r–r-- 1 root root 82K 2011-09-14 23:53 cxcore.hpp
-rw-r–r-- 1 root root 8.6K 2010-04-05 20:24 cxerror.h
-rw-r–r-- 1 root root 6.8K 2010-04-05 20:24 cxflann.h
-rw-r–r-- 1 root root 150K 2010-04-05 20:24 cxmat.hpp
-rw-r–r-- 1 root root 28K 2010-04-05 20:24 cxmisc.h
-rw-r–r-- 1 root root 89K 2010-04-05 20:24 cxoperations.hpp
-rw-r–r-- 1 root root 52K 2010-04-05 20:24 cxtypes.h
-rw-r–r-- 1 root root 19K 2010-04-05 20:24 highgui.h
-rw-r–r-- 1 root root 4.8K 2010-04-05 20:24 highgui.hpp
-rw-r–r-- 1 root root 72K 2010-04-05 20:24 ml.h

Everything seems to be there and in order, im really stumped on this one.

Do you get the same error if you compile using this command

gcc pkg-config --cflags --libs opencv -o my-opencv-prgm my-opencv-prgm.c

from here?

http://opencv.willowgarage.com/wiki/CompileOpenCVUsingLinux

Also, I tested a very similar program with OpenCV 2.1 last year, and it looks like I needed to include the header cv.h.

(I remember running into a similar problem, but it was a while ago and still trying to recall…)

Jake

Tried that, same result.
Including the cv.h header makes just makes gcc list all of the cv.h functions as unable to reference like the the ones in highgui.h

Well I dont know what the problem was with ubuntu but I installed debian and it worked like a charm.
For the interested http://elinux.org/BeagleBoardDebian will get debian up and running.

It might have just been me but when i updated the kernel as listed here http://elinux.org/BeagleBoardDebian#Beagleboard:_Install_Latest_Kernel the board wouldnt boot.
If you want to give it a shot and the kernel update borks your install, on the boot partition you’ll see to files with “_old” on the end (uboot_old and uimage_old, i think, dont quote me on that)

Rename those back to the default names (overwriting the files that are there) and you’ll be good to go.

After that its a matter of doing the usual house keeping, update, upgrade, install sudo and gcc, and then the opencv libs and you’re compiling.

Any questions let me know, the details are kind of fuzzy since i dont have the board in front of me right now

Well I dont know what the problem was with ubuntu but I installed debian and
it worked like a charm.
For the interested http://elinux.org/BeagleBoardDebian will get debian up
and running.

It might have just been me but when i updated the kernel as listed
here http://elinux.org/BeagleBoardDebian#Beagleboard:_Install_Latest_Kernel the
board wouldnt boot.

By chance, do you remember which version failed? That update method
is a rolling release, and right now it's on the v3.1.x's, I usually
catch regressions pretty quick

If you want to give it a shot and the kernel update borks your install, on
the boot partition you'll see to files with "_old" on the end (uboot_old and
uimage_old, i think, dont quote me on that)
Rename those back to the default names (overwriting the files that are
there) and you'll be good to go.

Correct, the install-me.sh update scripts will backup your previous
uImage/uInitrd..

After that its a matter of doing the usual house keeping, update, upgrade,
install sudo and gcc, and then the opencv libs and you're compiling.

Any questions let me know, the details are kind of fuzzy since i dont have
the board in front of me right now

Regards,

linux-image-3.1.8-x7_1.0squeeze_armel

Works for me on my xM B.. (so what board?)

btw, after you run the "Netinstall" there's no point of updating to
the latest kernel, since the NetInstall pulls in the exact same kernel
(well that day anyways). :wink:

Regards,

Sorry, this is on a beagle bone.

I didn’t know that it was an optional step, going through the install procedure it says that its not installing a kernel, so i figured it needed to be done. Learning experience i guess.

The kernel that i have running on it is the 3.1.0-psp3.

Ill try it again some time in the next few days (classes start tomorrow) and see if it was just a fluke, it would sit at the “starting kernel” (i think) message and then nothing.

Ah, sorry my bad.. I tweaked that section, for special BeagleBone considerations

http://elinux.org/BeagleBoardDebian#Beagleboard:_Install_Latest_Kernel

Currently the BeagleBone has to use a different kernel then the
beagle/panda/etc.. :wink:

Should change in the future, maybe v3.3?

Regards,

I made some progress on this problem, not sure if you still care…

I used netbeans on my PC to build the above sample program with the OpenCV libraries added to the project properties. The sample program then builds just fine. However, executing the command(s) at a terminal fails as you stated:

gcc pkg-config --cflags --libs opencv -o my-opencv-prgm my-opencv-prgm.c

Building this way fails on BOTH pandaboard and PC with Ubuntu. BUT, splitting the gcc command into 2 separate calls (just as Netbeans does) the program builds successfully:

gcc -c -g -I/usr/local/include/opencv -MMD -MP -MF build/main.o.d -o build/camtest.o cam-ex.c

gcc -o dist/camtest build/camtest.o -L/usr/local/lib -lopencv_contrib -lopencv_core -lopencv_features2d -lopencv_flann -lopencv_gpu -lopencv_highgui -lopencv_imgproc -lopencv_legacy -lopencv_ml -lopencv_objdetect -lopencv_ts -lopencv_video

I’m not sure why…but hopefully that gives you some insight…

Jake