Opencv on mini2440
From Embedded Nirvana
Cross Compiling Open CV 2.0.0 for mini2440
This page describes the method to cross-compile Open CV 2.0.0 image processing library provided by Intel for real-time image processing on mini2440.
Requirements on build platform:
- arm-linux-gcc 4.3.2 toolchain
- Open CV 2.0.0 : Download
Requirements on host platform (mini2440):
- Qtopia 2.0.0 128M on mini2440 : Download Here
Steps
1. tar -xvf OpenCV-2.0.0.tar.bz2 on your build platform terminal
2. go to OpenCV-2.0.0
3. ./configure --host=arm-linux --disable-shared
4. Run the following script in the terminal :
#!/bin/sh tar -xf OpenCV-2.0.0.tar.bz2 TGT_DIR=/output # Specify which cross-compiler you would be using. export CC=arm-linux-gcc # Specify where your pkgconfig directory is. #If you have installed your toochain correctly then you can find the location of your toolchain using #which arm-linux-gcc export PKG_CONFIG_PATH=/opt/usr/local/arm/4.3.2/arm-none-linux-gnueabi/libc/armv4t/usr/lib/pkgconfig #MAKE OPENCV cd OpenCV-2.0.0 #clean all the object code, if any make uninstall && make clean ./configure --prefix=$TGT_DIR --host=arm-linux CPPFLAGS=-I$TGT_DIR/include LDFLAGS=-L$TGT_DIR/lib --with-python=no --with-ffmpeg=no --with-imageio=no --with-gtk=no --with-carbon=no --with-unicap=no --with-gthread=no make -j3 && make install cd ../../
P.S : I have created my target directory in root as output. Also change the configuration path according to where your toolchain is installed.
The four libraries which will get generated after cross compiling Open CV 2.0.0 are :
- bin
- include
- lib
- share
Download Pre-compiled : OpenCV For ARM
5. Create any .c file and run the following command in the terminal:
root@tanushri-desktop:~/Desktop# export PATH=$PATH:/opt/usr/local/arm/4.3.2/bin root@tanushri-desktop:~/Desktop# arm-linux-g++ -O2 -I/usr/local/include/opencv newtest.c -L/opencv/lib -o newtest2 -lcv -lhighgui -lcxcore -lml -lcvaux -lrt -lpthread -ldl -lz -lpng12 -ljpeg
6. So now, you have cross-compiled an executable which uses the OpenCV library. You can do the following to test your file :
root@tanushri-desktop:~/Desktop# file newtest2
7. To run the binary file on your board, merge the above four directories in / directory of RootFS of mini2440, (as in bin to /bin, include to /include etc.) by copying them using a USB disk or wget
8. You may have to remake the proper softlinks after transferring to the mini2440 RootFS as they are not copied as empty files rather than softlinks.