OpenCV porting to arm whole process-II.

Source: Internet
Author: User
Tags bz2

In the previous article, we have downloaded the OpenCV source code, installed the Arm-linux cross compiler and CMake, the next is to use the cross compiler to compile the OpenCV source code, but before this, we have to cross compile the OpenCV of the third party dependent library. (Note: For ease of installation, it is recommended that you switch to root). extract OpenCV source

Under/OPT to create a directory arm, will OPENCV source to/opt/arm, into the/opt/arm directory, and then extract the source code.

Unzip Opencv-3.2.0.zip

In this case, there will be an extra opencv-3.2.0 directory to enter the directory. The directory is then created with 2 folder builds (for storing the configured intermediate files) and output (for storing the compiled OPENCV output file).

CD opencv-3.2.0

mkdir build output cross-compilation OpenCV third-party dependent libraries

Description: OpenCV's source code relies on a lot of third-party libraries, so you should also cross-compile these third-party libraries. These third-party libraries are listed below, can be downloaded to their own official website, can also download from here (portal) I packed well. After the decompression will find these Third-party library source code, the following figure:


These libraries are then copied to a single path, uncompressed and decompressed, as shown in the following image: (Note: decompression. tart.gz use command TAR-ZXVF xxx.tar.gz, decompression. tar.bz2 use command TAR-JXVF XXX.TAR.BZ2, decompression. TAR.XZ First Use xz-d xxx.tar.xz, this time will output the corresponding. tar file, then use TAR-XVF Xxx.tar decompression. )


Note: We are going to cross compile these third-party libraries into dynamic or static libraries, where the compilation is done, we need to specify the path with--prefix= at compile time, so the path may be too long for the sake of convenience. So we set it up as an environment variable. For example, I decided to place the results of these third party cross compilation outputs in a folder below the cross compiler. So add the last line to the/etc/profile or/ROOT/.BASHRC or/ETC/BASH.BARHRC file:

Export opencv_3thparty_lib=/usr/local/arm/opt/friendlyarm/toolschain/4.4.3/arm-none-linux-gnueabi/

Then source the file, verify that it was added successfully, and enter the Echo $OPENCV _3thparty_lib at the command line to see if there is a path just added.

1. Cross-compile Libz

CD zlib-1.2.8

CC=ARM-LINUX-GCC./configure--prefix= $OPENCV _3thparty_lib--shared

Open Makefile,vim Makefile, and then change Ar=ar to Ar=arm-linux-ar,ranlib to Arm-linux-ranlib.

Make

Make install

2. Cross-compile Libjpeg

CD jpeg-9b

./configure--host=arm-linux--prefix= $OPENCV _3thparty_lib--enable-shared--enable-static

Make

Make install

3. Cross-compile Libpng

CD libpng-1.6.32

./configure--host=arm-linux--prefix= $OPENCV _3thparty_lib--enable-shared--enable-static

Make

Make install

4. Cross-compile Yasm

CD yasm-1.3.0

CC=ARM-LINUX-GCC./configure--host=arm-linux--prefix= $OPENCV _3thparty_lib--enable-shared--disable-asm

Make

Make install

5. Cross-compile libx264

CD x264-snapshot-20171114-2245

CC=ARM-LINUX-GCC./configure--host=arm-linux--prefix= $OPENCV _3thparty_lib--enable-shared--disable-asm

Make

Make install

6. Cross-compile Libxvid

CD xvidcore-1.3.3

CD Build/generic

./configure--host=arm-linux--prefix= $OPENCV _3thparty_lib--disable-assembly

Make

Make install

7. Cross-compile FFmpeg

CD ffmpeg-3.4

./configure--prefix= $OPENCV _3thparty_lib--enable-shared--disable-static--ENABLE-GPL- Arch=arm--disable-stripping--target-os=linux--enable-libx264--enable-libxvid--CC=ARM-LINUX-GCC --extra-ldflags=-l$opencv_3thparty_lib/lib--extra-cflags=-i$opencv_3thparty_lib/include

Make

Make install

To this end, OPENCV relies on third-party libraries to cross compile and, of course, if you have to use other OPENCV modules, cross-compile the corresponding Third-party libraries, such as TIFF.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.