Installing OpenCV on ARM board



Installing OpenCV on ARM boardAbstractThis document described the steps of installing OpenCV on the ARM board which is running an embedded linux, so that you can run those powerful OpenCV routines on the arm board.Actually, we not just compiling the OpenCV source code with cross-platform compiler “arm-linux-gcc” and then generated the OpenCV library and include files compatible with the embedded linux system on ARM, such libraries files should also be copied to be arm board. Our own OpenCV program is actually compiled on the ubuntu system with cross-compilers linked with such libraries, and then the generated executable binaries will be copied to the arm board to run. Software and hardware requirementsARM board: Friendly ARM installed with embedded pile source: Ubuntu 10.04 or higher OpenCV 2.0.0;arm-linux-gcc 4.3.2 or higherInstallation stepsInstall Ubuntu 10.04 on your computer as a virtual machine or a secondary operating system.Change your role to rootSet the root password: Go to System> Administration> Users and Groups. Select “root”. Click Unlock, enter the password for the account you are logged into as, and hit close. Then, click Properties, select “Set password by hand”, and set the root password.Enable the root login: Go to System> Administration> Login Window. Click Security tab. Check “Allow local administrator login”. Click on OK.Log out, then enter root for user name and the password you set in the first step and click Login.Install arm-linux-gcc cross compiler. Get the arm-linux-gcc-4.3.2.tgz from the CD come with FriendlyARM or from the internet, , then extract it into directory”/” the architecture is like this “/usr/local/arm/4.3.2/…”Having finished the above operations, you should be able to see the installed files in the /usr/local/arm directoryThen add the installing directory of the arm-linux-gcc to system bash so that the arm-linux-gcc/arm-linux-g++ command can be recognized. Open the bashrc file, type in terminal: # vi /etc/bash.bashrcIn In the opened bashrc file, go to the last line and add: export PATH=$PATH:/usr/local/arm/4.3.2/bin/then close and save itTest that the arm-linux-gcc is already included in the default path, in the terminal, type : # arm-linux-gcc -vAnd you should be able to see a set of information about the cross compiler. Now the compiler is ready for useObtaining OpenCV source codeCurrent version of OpenCV library at the time of writing is a version 2.0.0. You can download an OpenCV source code by pointing your web browser to OpenCV- , or use the wget command to acquire a source code directly on the command line:#wget Extract OpenCV source code# tar xvjf OpenCV-2.0.0.tar.bz2 Then place OpenCV-2.0.0 into your directory(here is: /root/Desktop). Navigate to OpenCV-2.0.0 directory containing a source code:# cd root/Desktop/OpenCV-2.0.0/Create and navigate to a new directory where OpenCV is compiler by toolchain arm-linux-gcc-4.3.2. I this case, the directory name is same as project type, "output":~/Desktop/OpenCV-2.0.0# mkdir outputCompilation and installation of OpenCV binaries~/Desktop/OpenCV-2.0.0#export PKG_CONFIG_PATH=/ usr/local/arm/4.3.2/arm-none-linux gnueabi/libc/armv4t/usr/lib/pkgconfig~/Desktop/OpenCV-2.0.0#./configure --prefix=/root/Desktop/armOpenCV/output --host=arm-linux CPPFLAGS=-I/root/Desktop/ OpenCV-2.0.0/output/include LDFLAGS=-L/root/Desktop/ OpenCV-2.0.0/output/lib --with-python=no --with-ffmpeg=no --with-imageio=no --with-gtk=no --with-carbon=no --with-unicap=no --with-gthread=no~/Desktop/OpenCV-2.0.0#make –j3~/Desktop/OpenCV-2.0.0#make installYou should see 4 folders namely bin, include, lib, share in /root/Desktop/OpenCV-2.0.0/output Copying OpenCV library above to targetI use the FriendlyARM Mini2440 board, so I’ll be writing using it as the target device. If you use some other ARM based board, the basic procedure should more or less remain the sameOS : linuxOn the Mini2440 board, go to /usr and make the following two directories mkdir /usr/includemkdir /usr/libUsing a pendrive(USB) or FTP, copy all the files from /root/Desktop/OpenCV-2.0.0/output/include/opencv of host to /usr/include of target and /root/Desktop/OpenCV-2.0.0/output /lib of host to /usr/lib of targetCross compile example OpenCV for armNow you are ready to compile your OpenCV programs by this command:arm-linux-g++ -O2 -I/root/Desktop/OpenCV-2.0.0/include/opencv -L/root/Desktop/OpenCV-2.0.0/src/.libs -lcv -lhighgui -lcxcore -lml -lcvaux -lrt -lpthread -ldl <your_file>e.g. arm-linux-g++ -O2 -I/root/Desktop/OpenCV-2.0.0/include/opencv -L/root/Desktop/OpenCV-2.0.0/src/.libs -lcv -lhighgui -lcxcore -lml -lcvaux -lrt -lpthread -ldl -o facedetect facedetect.cppBut it is so complex to remember, so you can make a shortcut for it# vi /etc/bash.bashrcAdd this line to the that file: alias armOpenCV="arm-linux-g++ -O2 -I/root/Desktop/OpenCV-2.0.0 /include/opencv -L/root/Desktop/OpenCV-2.0.0/src/.libs -lcv -lh ighgui -lcxcore -lml -lcvaux -lrt -lpthread -ldl"Save it. Then close the terminal console and open it again. So, we can use the following command instead of the old one:# armOpenCV <your_file># armOpenCV –o facedetect facedetect.cppCommunication between the arm-board and PC(running ubuntu)Install mincom (an application for controlling serial port on ubuntu) on your unbutu system either by typing “sudo apt-get install minicom” in the terminal or install it from the synaptic package manager.Connect the FriendlyARM system with your PC via serial port and then open the minicom program from terminal. If everything goes smoothly, you should be able to see the following:The working directory in the arm board is “/home/plg”, now you can cd to it and transfer your files into the arm board for running.When transferring the files, press “ctrl+A+S”, then choose “zmodem”, you will see a window to let you choose the file you want to upload to the board. Use “space” to choose the file you want to upload or enter subdirectories and “enter” to confirm your operation. You can use this method to upload to the arm board the compiled opencv libraries, the generated binary from the opencv programs you wrote and some other files like the input images. To run a program in the arm system, first of all you need to change its running mode so that you can have the right to run it, for example, using “chmod 777 exampleBinary”, and then use “./exampleBinary” to run the binary program. ................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download