Host system: ubuntu9.04 cross compiler version: arm-linux-gcc-4.3.2
Target System: Linux kernel 2.6.3.2 hardware arm-cotex (am3517) Development Board
2012-11-2 re-Compilation: the target system ubuntu_core Linux version 3.0.0-1205-omap4 hardware: omap4460
I 've tried to use arm-linux-gcc-4.3.3 to cross-compile opencv2.0 results are always wrong, the error content see another blog http://blog.csdn.net/dlutxie/article/details/6769200
Since opencv2.0 is lazy on PNG and JPEG graphics libraries, while PNG is lazy on zlib libraries, you should first install the cross compiler and then install zlib, PNG, and JPEG libraries, for details about the installation process, see the link above.
The installation process is as follows:
Xgy @ Ubuntu :~ /Tmp $ tar xvf OpenCV-2.0.0.tar.bz2
Xgy @ Ubuntu :~ /Tmp $ CD OpenCV-2.0.0/
Xgy @ Ubuntu :~ /Tmp/OpenCV-2.0.0 $. /configure -- Host = arm-Linux -- without-GTK -- without-carbon -- without-QuickTime -- without-1394libs -- without-FFMPEG -- without-Python -- without-swig -- enable-shared -- disable -apps cxx = arm-Linux-G ++ cppflags =-I/home/xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/includeldflags =-L/home /xgy/toolchain/ARM/4.3.2/ARM-None-Linux-gnueabi/libc/lib -- prefix =/opt/ARM/opencv
-- Libdir =/opt/ARM/opencv/lib -- export dedir =/opt/ARM/opencv/include
The generated report is as follows:
Xgy @ Ubuntu :~ /Tmp/OpenCV-2.0.0 $ make
Xgy @ Ubuntu :~ /Tmp/OpenCV-2.0.0 $ make install:
Because I want to install opencv under/opt/ARM/opencv, and xgy users have no limit on the writing board for this directory, it cannot be installed, so I used the root user to execute make install and the result showed the same error, this is because the PATH environment variable of the root user does not point to the Cross Compiler (after installing the cross compiler, I only set the PATH environment variable of the xgy user ), to solve this problem, set OPT and its sub-directories to be writable by any user. The command is as follows:
Root @ Ubuntu:/# chmod-r 777/OPT
Switch to the directory and execute make install as follows:
Root @ Ubuntu:/# Su-xgy
Xgy @ Ubuntu :~ $ CD tmp/OpenCV-2.0.0/
Xgy @ Ubuntu :~ /Tmp/OpenCV-2.0.0 $ make install // This way you can install successfully
Next, set the environment variable. First, change the file name.
Xgy @ Ubuntu :~ /Tmp/OpenCV-2.0.0 $ CD/opt/ARM/opencv/lib/pkgconfig/
Xgy @ Ubuntu:/opt/ARM/opencv/lib/pkgconfig $ MV opencv. PC opencvarm. CP
Because an opencv Library Under x86 has been installed in my system, and there is an opencv in a similar directory. PC file. If this parameter is not changed, the two files may have an error! (Related to the path set in pkg_config_path)
Xgy @ Ubuntu:/opt/ARM/opencv/lib/pkgconfig $ cd
Xgy @ Ubuntu :~ $ VI. bashrc
Add export pkg_config_path = $ pkg_config_path:/opt/ARM/opencv/lib/pkgconfig
Switch to the root user, in/etc/lD. so. add/opt/ARM/opencv/lib to the end of the conf file or add it to/etc/lD. so. conf. d/to create a file opencv. CONF file content:/opt/ARM/opencv/lib
Run the ldconfig command to load the dynamic library file.
So far, we can cross-compile programs related to opencv routines on the host machine, but we have not transplanted the compiled opencv Library to the arm-cotex Development Board, next we will do this job:
In/opt/ARM/opencv/lib
Libcvaux. so.4.0.0
Libcv. so.4.0.0
Libcxcore. so.4.0.0
Libhighgui. so.4.0.0
Libml. so.4.0.0
Copy and rename all
*. So.4
Then, copy the five files, zlib, libpgn, and JPEG-related dynamic link libraries that were previously compiled, to the arm-cotex Development Board through TFTP (or other methods, then set the LD_LIBRARY_PATH environment variable to point to the directory containing these libraries. For example, if I copied these libraries to the/mnt/SDA/opencvlib daily directory, set LD_LIBRARY_PATH = $ LD_LIBRARY_PATH: /mnt/SDA/opnecvlib can also be found in/etc/lD. so. add/mnt/SDA/opencvlib to the end of the conf file, but I found no/etc/lD on the Development Board. so. CONF file, so we have to set the environment variable LD_LIBRARY_PATH.
Opencv2.0 has been transplanted !! Celebrate !!
2012-11-2
In the past few days, I have transplanted opencv2.0 again. This is to port it to omap4460. This time, I tried to use arm-Linux-GCC 4.5.1 for compiling and porting, however, an error occurred while running the program. The error details are as follows:
Opencv error: NULL pointer (null array pointer is passed) in cvgetmat, file cxcore/cxarray. cpp, line 2370
Terminate called after throwing an instance of 'cv: exception'
Aborted
Someone on the Internet said that we should change the jpg image to PNG format. I tried it and it was useless. The error path after tracking is: cvloadimage ()-> imread _ ()-> imagedecode:: readheader () (I only track this function) and the function readheader () is a virtual function, which has different implementations for different image formats, since I used to compile and test the same code correctly, the code should be okay. At least it can run before, and now it should be able to run, so I still think that I use this version of the arm-linux-gcc-4.5.1 is wrong, so I re-replace the 4.3.2 compilation, configure configuration is as follows:
. /Configure -- Host = arm-cortex-Linux -- disable-OpenMP -- without-GTK -- without-swig -- without-Python -- without-carbon -- without-ffmpeg-- without-1394libs -- without-QuickTime -- enable-shared cxx = arm-None-Linux-gnueabi-G ++ cc = arm-None-Linux-gnueabi-GCC cxxflags ="
-March = armv7-a-mtune = cortex-a9-mfpu = VFP-mfloat-Abi = softfp "ccflags ="-March = armv7-a-mtune = cortex-a9-mfpu = VFP-mfloat-Abi = softfp "cppflags =-I/opt/toolschain/ARM/4.3.2/ARM-None-Linux-gnueabi/include ldflags =-L/opt/toolschain/ARM/4.3.2/ARM-None- linux-gnueabi/lib/
-- Prefix =/opt/ARM/opencv2.0 -- libdir =/opt/ARM/opencv2.0/lib -- includedir =/opt/ARM/opencv2.0/include
The configuration result is as follows:
If you want to use -- enable-OpenMP, this option seems to enable parallel computing, but the compiler does not support it (you can view it using the arm-Linux-gcc-V command, you have to download a package and compile a library for addition.
In addition, I have changed the-mfpu = VFP to-mfpu = neon speed, but does omap4460 not support neon?
This time we used the A9 Board (omap4460) and FPU Board (am3517) FPU is not used (you can check the assembly code through the disassembly objdump program to see if there are any floating point commands). In the same program, the speed is nearly four times faster (the fastest 3.83 seconds in the past, and now the fastest 0.99 seconds ), however, it is twice slower than I expected, because the same program runs for 0.27 seconds in the vmvm on my computer. I found that the omap3 configuration was used during initialization, I don't know if the frequency of the Board has not been configured yet. In addition, I didn't use the FPU option to re-compile the JPG, PNG, and zlib libraries, but directly used the original compiled library, so it's a little slower than expected. If you have time, try again.
The use of ubuntu_core download and burn into the Development Board Step: http://omappedia.org/wiki/OMAP_Ubuntu_Core
Building opencv for ARM Cortex-A82013-3-8 38 is a good day, and re-compiled an opencv2.0, two days ago encountered a lot of problems today are resolved PC: ubuntu9.04 kernel 2.6.28 GCC: gcc-linaro-arm-linux-gnueabihf-4.7-2013.02-01-20130221_linux Development Board: omap4 ubuntu12.04-desktop kernel 3.2.0-1412omap4 first, I re-compiled the zlib-1.2.7 libpng-1.2.50 jpegsrc. v9 this can refer to: http://www.cppblog.com/runsisi/
Opencv2.0 compilation options are as follows:
. /Configure -- Host = arm-Linux-gnueabi -- disable-OpenMP -- without-GTK -- without-swig -- without-Python -- without-carbon -- without-FFMPEG -- without-1394libs -- without-QuickTime -- enable-shared cxx = arm-Linux-gnueabihf-G ++ cc = arm-Linux-gnueabihf-GCC cppflags =-I/home/xgy/arm-gcc4.7/ARM-Linux-gnueabihf /include
Ldflags =-L/home/xgy/arm-gcc4.7/ARM-Linux-gnueabihf/lib/-- prefix =/opt/ARM/opencv2.0-gcc4.7 -- libdir =/opt/ARM/opencv2.0- gcc4.7/lib -- includedir =/opt/ARM/opencv2.0-gcc4.7/include
The cxxflags option is removed this time, because the following options are available through arm-Linux-gnueabihf-G ++-V:
-- With-arch = armv7-a -- With-tune = cortex-a9 -- With-FPU = vfpv3-d16 -- With-float = hard that means the GCC compiled program runs on the cortex-a9 by default, when I added the cxxflags, the configuration failed.
Make; make install will also encounter some problems. The details are as follows:
../Include/opencv/cxcore. HPP: 169: 13: Error: 'ptrdiff _ t' does not name a type
../Include/opencv/cxoperations. HPP: 1916: 15: Error: 'ptrdiff _ t' does not name a type
../Include/opencv/cxoperations. HPP: 2465: 31: Error: 'ptrdiff _ t' does not name a type
../Include/opencv/cxmat. HPP: 356: 15: Error: Expected '; 'before' delta1'
../Include/opencv/cxmat. HPP: 358: 9: Error: 'delta1' was not declared in this scope
../Include/opencv/cxmat. HPP: 367: 31: Error: 'delta2' was not declared in this scope
To solve this problem, you only need to add: # include <stddef. h> to the opencv2.0.0/include/opencv/cxcore. HPP file !!
Highgui/loadsave. cpp: 333: 28: Error: 'unlink' was not declared in this scope
This problem is also caused by adding # include <unistd. h> to the file, which cannot be remembered.
Undefined reference to 'cvcreatecameracapture _ v4l (INT )'
For more information, see https://code.ros.org/trac/opencv/changeset/5206:
Modify the opencv2.0.0/cvconfig. H. cmake file as follows:
19 19/* v4l2 capturing support */
20 20 # cmakedefine have_camv4l2
21
22/* v4l/v4l2 capturing support via libv4l * // Add this line
23 # cmakedefine have_libv4l // Add this line
21 24
22 25/* carbon indexing wing environment */
Modify opencv2.0.0/src/highgui/cvcap. cpp as follows:
172 172
Return capture;
173 173
# Endif
174 # If defined (have_camv4l) | defined (have_camv4l2) // Delete this row
174 # If defined have_libv4l | (defined (have_camv4l) & defined (have_camv4l2) // Add this line
175 175
Capture = cvcreatecameracapture_v4l (INDEX );
176 176
If (capture)
Modify opencv2.0.0/src/highgui/cvcap_libv4l.cpp as follows:
227 # If! Defined Win32 & defined have_camv4l & defined have_camv4l2 // Delete this row
227 # If! Defined Win32 & defined have_libv4l // Add this line
228 228
229 229
# Define clear (x) memset (& (x), 0, sizeof (x ))
... ...
242 242
# Include <sys/IOCTL. h>
243 243
244 # ifdef have_camv4l // Add this line
244 245
# Include <Linux/videodev. h>
246 # endif // Add this line
247 # ifdef have_camv4l2 // Add this line
245 248
# Include <Linux/videodev2.h>
249 # endif // Add this line
246 250
247 251
# Include <libv4l1. h>
The following error occurs during make install:
Libtool: Install: Error: relink 'libcv. la'
The solution is not found. The library file is in opencv2.0.0/src /. in the libs/* directory, note that it is a hidden file. In the opencv2.0.0/include directory, copy the library and header file directly to the path to be installed.
The following error occurs during application programming:
Undefined reference to 'jpeg _ alloc_huff_table@LIBJPEG_9.0'
Libcxcore. So: Undefined reference to 'gzclose'
Solution: Add-lpng-lpng12-ljpeg-LZ to the compilation options to include these libraries.
OK ,then, port the required opencv2.0library and libraries such as PNG and libz.jpeg to the board, set the environment to execute ldconfig to load the library, and use LDD test to check which libraries the test program is lazy.
./Test OK run successfully!
I don't know why I re-compiled the PNG, JPEG, libz and other libraries. The running speed has reached 0.54 seconds !! 6 times faster than the first one!