移植OpenCV3.1到BBB-Debian

本文讲述将OpenCV及其依赖库的源码编译移植到BeagleBone Black开源板的Debian系统里,下面是其移植全过程命令:

cd /home/guochongxin/bbb-debian

mkdir thirds

cd thirds

mkdir install

wget -c http://zlib.net/zlib-1.2.8.tar.xz

tar xvf zlib-1.2.8.tar.xz

cd zlib-1.2.8/

CC=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/ --shared

make

make install

cd ..

wget -c http://www.ijg.org/files/jpegsrc.v9b.tar.gz

tar xvf jpegsrc.v9b.tar.gz

cd jpeg-9b/

CC=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/ --host=arm-linux-gnueabihf --enable-shared

make

make install

cd ..

wget -c http://prdownloads.sourceforge.net/libpng/libpng-1.6.21.tar.xz

tar xvf libpng-1.6.21.tar.xz

cd libpng-1.6.21/

CC=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/ --host=arm-linux-gnueabihf --with-pkgconfigdir=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/lib/pkgconfig LDFLAGS=-L/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/lib/ CPPFLAGS=-I/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/include/

make

make install

cd ..

wget -c https://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20160131-2245-stable.tar.bz2

tar xvf x264-snapshot-20160131-2245-stable.tar.bz2

cd x264-snapshot-20160131-2245-stable/

./configure --host=arm-linux-gnueabihf --cross-prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf- --enable-shared --prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/

make

make install

cd ..

wget -c http://downloads.xvid.org/downloads/xvidcore-1.3.4.tar.gz

tar xvf xvidcore-1.3.4.tar.gz

cd xvidcore/build/generic

CC=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc ./configure --prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/ --host=arm-linux-gnueabihf --disable-assembly

make

make install

cd ../../../

wget -c ftp://ftp.remotesensing.org/pub/libtiff/tiff-4.0.6.tar.gz

tar xvf tiff-4.0.6.tar.gz

cd tiff-4.0.6/

CC=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc CXX=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-g++ ./configure --prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/ --host=arm-linux-gnueabihf --enable-shared LDFLAGS=-L/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/lib CPPFLAGS=-I/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/include

make

make install

cd ..

wget -c http://ffmpeg.org/releases/ffmpeg-2.8.6.tar.bz2

tar xvf ffmpeg-2.8.6.tar.bz2

cd ffmpeg-2.8.6/

./configure --prefix=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/ --enable-shared --enable-gpl --enable-cross-compile --arch=arm --disable-stripping --target-os=linux --enable-libx264 --enable-libxvid --cc=/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/bin/arm-linux-gnueabihf-gcc --enable-swscale --extra-cflags=-I/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/include --extra-ldflags=-L/home/guochongxin/bbb-debian/gcc-linaro-arm-linux-gnueabihf-4.8-2013.10_linux/arm-linux-gnueabihf/lib --disable-asm

make

make install

cd ..

wget -c https://github.com/Itseez/opencv/archive/3.1.0.zip

unzip 3.1.0.zip

cd opencv-3.1.0

mkdir build install

cd build

cmake-gui .

执行完上述最后一条命令时,需要对OpenCV的编译进行配置,首先会弹出如下对话框:

移植OpenCV3.1到BBB-Debian_第1张图片

按上图设置好相应路径后,点击“Configure”按钮,弹出如下对话框:

移植OpenCV3.1到BBB-Debian_第2张图片

按上图选择相应的项后点击“Next >“按钮,出现如下对话框:

移植OpenCV3.1到BBB-Debian_第3张图片

按上图设置后(Target Root要设置为ffmpeg源码根路径)点击”Finish“按钮后回到如下对话框:

移植OpenCV3.1到BBB-Debian_第4张图片

按上图设置好安装路径,并将下图的gtk选项去掉:

移植OpenCV3.1到BBB-Debian_第5张图片

然后点击“Generate”按钮,生成配置文件,关闭该对话框,接下来执行如下命令:

make

make install

执行完上面这两条命令编译并将目标文件安装到/home/guochongxin/bbb-debian/thirds/opencv-3.1.0/install目录下,将install目录下的所有文件夹和文件全部直接复制到BBB的根文件系统下即可。

参考资料:

http://blog.chinaaet.com/carlpc/p/83917

http://blog.csdn.net/brightming/article/details/50563565

你可能感兴趣的:(移植OpenCV3.1到BBB-Debian)