Thread: Opencv on N900
View Single Post
Posts: 6 | Thanked: 8 times | Joined on Sep 2011
#9
Hallelujah!! I've finally successfully compiled a test app using opencv for the maemo target in QtCreator.

Thank you all for helping out.
For the benefit of others who may encounter the same problem and for the linux newbies (as i'm), I'll try to specify, in detail, the steps I took in order to solve the issue. These steps are a mix of various solutions I found on the web.

On the device (N900):
Install the opencv libs:
1. Open the X Terminal. type "sudo gainroot" for root access.
2, type "apt-get install libcv4 libcvaux4 libhighgui4".

On your desktop (Linux):
download the libcv4 and the libhighgui4 built for maemo, found at
http://maemo.org/packages/package_in...ibcv4/2.0.0-3/
and
http://maemo.org/packages/view/libhighgui4/
Make sure you download the armel packages.

Extract these packages into a folder name "opencv".
Remove the version extension from the .so files that are links to "shared library". for example rename the libcv.so.4 to libcv.so.

Place the opencv folder and its content to the usr/lib folder inside the maemo nokia sdk folder. For example "Path/to/NokiaSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/opencv".

Opencv libs depend on other libs that are not a part of the QtCreator and are installed by default. You will need to copy these from you device (N900). The libs you need are:

libavformat.so libavcodec.so libswscale.so libavutil.so libfaad.so libtheora.so libvorbisenc.so libvorbis.so libogg.so.

You can find these libs in your device (N900) by typing in the X Terminal (under root):
find -name libname.so*
It is most likely you'll find them in usr/lib.

Copy these libs from your device to the opencv folder you created ( "Path/to/NokiaSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr/lib/opencv" ).
Be sure to remove the version from the libs name, just as you did with the opencv libs.

Create a PackageConfig file for the opencv. This file will be used by QtCreator to locate the libs.
PackageConfig files are text files with .pc extension. Create a file opencv.pc (you may use gedit for that) and paste the following in it:


# Package Information for pkg-config

prefix=Path/to/NokiaSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib/opencv
includedir=${prefix}/include/opencv
Name: opencv
Description: Intel(R) Open Source Computer Vision Library
Version: 2.0.0
Libs: -L${libdir} -lcv -lhighgui -lavformat -lavcodec -lswscale -lavutil -lfaad -ltheora -lvorbisenc -lvorbis -logg
Cflags: -I${includedir}


Make sure you update the "prefix" variable according to your path.

Do the same for the opencv header files (the .h files). That is locate the opencv header folder on your device (or your desktop) and past it to the path that is specified in the .pc file you just created. For example "Path/to/NokiaSDK/Maemo/4.6.2/sysroots/fremantle-arm-sysroot-20.2010.36-2-slim/usr//include/opencv".

Open you QtCreator project. In the .pro file add the following:

CONFIG += link_pkgconfig
PKGCONFIG += opencv

These lines tell QtCreator to load the libs you copied using the .pc you created.

That should be it..
 

The Following 3 Users Say Thank You to avieli For This Useful Post: