Environment: the ARM development board is ok6410, and the host is ubuntu10.04.
1. Preparation: Use the optical disc arm-linux-4.4.1.tar.gz tool to decompress the tool to the/usr/local/ARM directory (Add/usr/local/ARM/bin to the environment variable). Download The opencv2.2 source code; install cmake build-essential; install necessary libraries: libgtk2.0-dev libavcodec-dev libavformat-dev libswscale-dev libjpeg62-dev libtiff4-dev libjasper-Dev
2. Description of the main directories used:
Cross-compilation tool chain/usr/local/ARM
Location of the compiled opencv Library/usr/local/opencv-arm
Install opencv directory/usr/local/ARM-Linux
Opencv source code ~ /Tiaozhansai/OpenCV-2.2.0
3. Run sudo cmake-Gui on the terminal
Select the source code Directory:/home/Xin/tiaozhansai/OpenCV-2.2.0
Select the build Directory:/usr/local/opencv-arm/
Click Configure, keep generator as UNIX makefiles, select specify options for cross-compiling, and click Next,
Operating System fill in arm-Linux
C compilers fill in/usr/local/ARM/4.4.1/bin/ARM-Linux-gcc
C ++ compilers fill in/usr/local/ARM/4.4.1/bin/ARM-Linux-G ++
Enter/usr/local/ARM/4.4.1/as the target root of the library/
Click Finish.
Modify the default configuration. The default installation directory is/usr/local. To find the generated library file, change the cmake_install_prefix variable to/usr/local/ARM-Linux and click Generate to generate the makefile.
4. In the/usr/local/opencv-arm directory, $ sudo make
(1), 80% error:
.... /Home/Xin/tiaozhansai/OpenCV-2.2.0/modules/ml/src/Gbt. cpp: 474: Error: 'expl' was not declared in this scope
Modify 14 rows in Gbt. cpp, 16 rows: Comment out
// # If android
# Define expl (x) exp (X)
// # Endif
Eliminate errors.
(2) Error 83%:
Linking cxx executable.../../bin/opencv_createsamples
.../../Lib/libopencv_core.so: Undefined reference to 'clock _ gettime'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ assumerrorhandler'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ {realloc'
.../../Lib/libopencv_core.so: Undefined reference to 'pthread _ key_create
Solution: Modify cmakecache.txt, cmake_exe_linker_flags, and add-lpthread-LRT to re-compile and eliminate errors.
(3) Error 83%:
Linking cxx executable.../../bin/opencv_createsamples
.../../Lib/libopencv_highgui.so: Undefined reference to '_ assumerrorhandler'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ {realloc'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ Your malloc'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ Your memcpy'
.../../Lib/libopencv_highgui.so: Undefined reference to 'too open'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ blank free'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ warninghandler'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ too memcmp'
.../../Lib/libopencv_highgui.so: Undefined reference to '_ blank memset'
Solution: Modify cmakecache.txt, with_tiff: bool = on, and change it to off (the TIFF image format is no longer supported. Here I have installed libtiff4-dev before, but the compilation error, I don't understand why), re-compile, error elimination.
(4) Error 96%:
Cmakefiles/opencv_test.dir/src/highguitest. OBJ: In function 'cv _ highguitest: Run (INT )':
Highguitest. cpp :(. Text. _ zn14cv_highguitest3runei + 0x18): warning: the use of 'tmpnam 'is dangerous, better use 'mkstemp'
.../../Lib/libopencv_features2d.so: Undefined reference to 'cv: sift (double, bool, bool, Int, INT )'
Solution: Under opencv2.2.0/modules/features2d/src/sift. cpp
# Ifdef _ arm __
# Define arm_no_sift
# Endif
Comment out # define arm_no_sift. error elimination,
Successful!
$ Sudo make install
5. Copy the opencv library to ok6410 and Test
(1) borrow a test program from a blog to test whether the compilation is successful.
Create test. cpp:
// Test. cpp
# Include <cv. h>
# Include <cxcore. h>
# Include
Int main ()
{
Cvcapture * capture = NULL;
Iplimage * frame = NULL;
If (! (Capture = cvcapturefromcam (-1 )))
{
Fprintf (stderr, "can not open camera./N ");
Return-1;
}
Cvnamedwindow ("video", 1 );
While (frame = cvqueryframe (capture ))
{
Cvshowimage ("video", frame );
}
Cvdestroywindow ("video ");
Cvreleasecapture (& capture );
Return 0;
}
Compile test. CPP: $ arm-Linux-G ++-I/usr/local/ARM-Linux/include/opencv/-L/usr/local/ARM-Linux/lib/-LCV-lcxcore -lhighgui-lpthread-LRT-O test. CPP
Error:/usr/local/ARM/4.4.1/bin /.. /lib/GCC/ARM-None-Linux-gnueabi/4.4.1 /.. /.. /.. /.. /ARM-None-Linux-gnueabi/bin/ld: cannot find-LCV
Google found that the dynamic library libcv. So was not found.
The find Command finds that this library does not exist in the/usr/local/ARM-Linux/lib/directory, and the libraries under this directory are in the form of libopencv, I guess opencv2.2 has made a lot of changes compared with 2.1. According to the online research, opencv2.2 re-organizes the database structure and replaces cxcore, CV, and cvaux with more detailed and smaller modules, highgui and ML library.
So, try to change the command: $ arm-Linux-G ++-I/usr/local/ARM-Linux/include/opencv/-L/usr/local/ARM-Linux/lib/-lopencv_core-lopencv_highgui -lpthread-LRT-O test. CPP
The result is still a report error. This time I noticed that it is... /ARM-None-Linux-gnueabi /.. Find the dynamic library in this directory. That is to say, although I have specified the header file and the search path of the library file, it does not go to the path I specified. So I copied all the header files under/usr/local/opencv-arm/include/opencv/and the dynamic libraries under/usr/local/opencv-arm/lib to/usr/ local/ARM/4.4.1/ARM-None-Linux-gnueabi directory, then compile:
$ Arm-Linux-G ++-lopencv_core-lopencv_highgui-lpthread-LRT-O test. cpp
Successful!
(2) copy the Library File S and the compiled test program to the Development Board for testing.
An error occurred while copying data with an SD card:
CP: cannot create '.../../lib/libopencv_calib3d.so': Read-Only File System
CP: cannot create '.../../lib/libopencv_contrib.so': Read-Only File System
CP: cannot create '.../../lib/libopencv_core.so': Read-Only File System
This is related to the cramfs file system, which is a read-only file system. You can solve this problem by burning the yaffs file system.