Note that the host where we're working is Ubuntu 12.04 and the cross-compiler used for ARM is arm-none-linux-gnueabi.
BUILD:
In order to cross-compile OpenCV, we will use Cmake to generate makefiles. Install it first.
- $ sudo apt-get install cmake cmake-curses-gui
- $ cd ~
- $ wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.9/opencv-2.4.9.zip
- $ unzip opencv-2.4.9.zip
- $ gedit .bashrc
- export PATH=$PATH:/home/sezerb/Projects/ToolChain/arm-2012.09/bin
- $ mkdir ~/build && cd ~/build
- $ touch toolchain.cmake
- $ gedit toolchain.cmake
Note that since we have added our toolchain to environment PATH before, we've commented out the last line.
OpenCV supports "neon" since version 2.3. Since we are using 2.4.9 now, we can enable/disable neon support from CMake gui later on.
Now it's time to cross-compile OpenCV:
- $ cmake -DCMAKE_TOOLCHAIN_FILE=toolchain.cmake ../opencv-2.4.9/
- ccmake .
Now press 'c' and 'g' to configure and generate makefile.
- $ make
- $ make install
CODING and TESTING:
Create a file named as Main.cpp as below: Create a Makefile as below and please do not forget to update the paths with yours. In terminal, go to the directory where these files located and "$ make". Now, we have a "Main" binary to be executed in our target environment. Before running this binary in our target environment, we need to copy built libraries to our target system. "/lib", "/usr/lib/" and "/usr/local/lib" are directories where you may copy the built opencv libraries in "/install/lib/". We have copied them to "/lib" folder in our target system. If you do not have any of these directories in your target system, you may create a folder such as "/usr/lib" to copy built opencv libraries. Also copy the headers located in "/install/include/" to "/usr/include/" in your target system.
After copying the libraries and header, copy the "Main" executable binary to your target system and run it by typing:
- ./Main
Merhaba Sezer Bey,
YanıtlaSilBen İstanbul Teknik Üniversitesi Elektronik ve Haberleşme Mühendisliği son sınıf öğrencisi Mert Esgi. Bitirme projem olarak Zedboard üzerinde Linaro koşturup üzerinde bir OpenCV uygulaması yapmam gerekiyor. Tutorialınızı takip ederek kütüphaneleri arm-linux-gnueabi ile cross-compile edip main.cpp kodunu errorsüz derledim. Fakat karta atınca, libraryleri düzgün biçimde install etmeme rağmen, executable çalıştırıldığında core lib'i bulamadığı errorünü veriyor. Executable koşturulurken neden librarylere ihtiyaç duyuyor?
Yardımcı olursanız çok sevinirim.
Teşekkürler,
Mert Esgi
Mert mail olarak cevap yazdım sana.
SilAlmadım Sezer Bey, mail adresim: mertes13@gmail.com
SilÇok teşekkürler.
Bu arada sorunu zamanımın azalması sebebiyle bir workaround ile çözdüm. Libopencv-dev'i apt-get ile Linaro'ya kurdum. Böylece kartımda version 2.3.1 OpenCV libraryleri oldu ve kodlarım çalışıyor.
Sil