OpenCV移植到ARM平臺---Opencv with ffmpeg to ARM移植總結

ARM 650瀏覽

1、? linux環境:vm+fedora10(2.6.27.5)

交叉編譯:4.3.3

ARM板子:TQ2440 ARM9

準備庫: libz? libjpeg libx264libxvid libffmpeg libpng? opencvyasm-0.7.2

版本:

libz: ??zlib-1.2.3

libjpeg:? ?jpegsrc.v6b

libpng:? ?libpng-1.2.18

libyasm:? ?yasm-0.7.2

opencv: ? ?opencv-2.0.0

libx264:? ?x264-snapshot-20110612-2245-stable

libxvid:? ?xvidcore-1.3.2

lffmpeg:? ?ffmpeg-0.5.3

2、? 使用交叉編譯器的兩種方法

①設置環境變量

export PATH=$PATH:/opt/EmbedSky/4.3.3/bin

注: /opt/EmbedSky/4.3.3是交叉編譯器的安裝路徑

②修改/etc/profile文件

在環境變量設置代碼附近添加:pathmunge/opt/EmbedSky/4.3.3/bin

注:兩者的區別在于作用域不同

3、? libz的交叉編譯

進入解壓目錄進行配置安裝

#CC=arm-linux-gcc? ./configure --prefix=/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi–shared
#make
#make install

注:CC 指定交叉編譯器? --prefix 指定安裝路徑(以后的庫文件均安裝在此目錄下,便于以后的編譯連接) –shared 共享庫

4、? libjpeg的交叉編譯

進入解壓目錄進行配置安裝

#./configure --prefix=/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi--enable-shared –enable-static#gedit Makefile(修改Makefile中cc =arm-linux-gcc ar=arm-linux-ar ar2=arm-linux-ranlib rc)
#make
#make install

注:此時系統報錯,在/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/路徑下新建目錄man/man1,然后再次執行makeinstall 安裝成功

5、? libpng的交叉編譯

進入解壓目錄進行配置安裝

#./configure --prefix=/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi--enable-shared --enable-static ?--host=arm-linux
#make
#make install

6、? yasm的交叉編譯

進入解壓目錄進行配置安裝

#./configure --prefix=/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi--enable-shared --enable-static ?--host=arm-linux
#make
#make install

7、? libx264的交叉編譯

進入解壓目錄進行配置安裝

#CC=arm-linux-gcc ./configure --enable-shared--host=arm-linux –disable-asm --prefix=/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi
#make
#make install

8、? libxvid的交叉編譯

進入build/generic目錄進行配置安裝

#./configure --prefix=/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi--host=arm-linux? --disable-assembly
#make
#make install

9、? ffmpeg的交叉編譯

進入解壓目錄進行配置安裝

#./configure --prefix=/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi--enable-shared --disable-static --enable-gpl --enable-cross-compile --arch=arm--disable-stripping --target-os=linux --enable-libx264 --enable-libxvid--cc=arm-linux-gcc
--enable-swscale
#make
#make install

 

10、opencv2.0.0的交叉編譯

進入解壓目錄進行配置安裝

#./configure --host=arm-none-linux-gnueabi --without-gtk--without-carbon --without-quicktime --without-1394libs --with-ffmpeg--without-python --without-swig --enable-static --enable-shared --disable-appsCXX=arm-linux-g++ CPPFLAGS=-I/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/include/LDFLAGS=-L/opt/EmbedSky/4.3.3/arm-none-linux-gnueabi/lib
--with-v4l --prefix=/opt/EmbedSky/arm/opencv-arm CXXFLAGS=-O2 --libdir=/opt/EmbedSky/arm/opencv-arm/lib --includedir=/opt/EmbedSky/arm/opencv-arm/include
#make

此時輸出如下配置信息

Generalconfiguration ================================================



CXX:????????????????????? arm-linux-g++
CXXCPP:?????????????????? arm-linux-g++ -E
CPPFLAGS:???????????????? -I/home/xiaofevg/new/arm/4.3.2/arm-none-linux-gnueabi/include/
CXXFLAGS:???????????????? -O2
LDFLAGS:?????????????????-L/home/xiaofevg/new/arm/4.3.2/arm-none-linux-gnueabi/lib

Install path:????????????/home/xiaofevg/new/arm/4.3.2/arm-none-linux-gnueabi

Debug flags
Optimization flags??????? -DNDEBUG -O2 -fomit-frame-pointer
MMX/SSE/SSE2/SSE3:
OpenMP support:
External BLAS & LAPACK:?? no

HighGUIconfiguration ================================================

Windowing system --------------
Use Carbon / Mac OS X:??? no
Use gtk+ 2.x:???????????? no
Use gthread:????????????? no

Image I/O ---------------------
Use ImageIO / Mac OS X:?? no
Use libjpeg:????????????? yes
Use zlib:???????????????? yes
Use libpng:?????????????? yes
Use libtiff:????????????? no
Use libjasper:??????????? no
Use libIlmImf/OpenEXR:??? no

Video I/O ---------------------
Use QuickTime / Mac OS X: no
Use xine:???????????????? no
Use gstreamer:??????????? no
Use ffmpeg:????????????? no
Use dc1394 & raw1394:???? no
Use dc1394_v2 & raw1394:? no
Use v4l:????????????????? yes
Use v4l2:???????????????? yes
Use unicap:??????????????no

Wrappers forother languages =========================================

SWIG
Python??????????????????? no
Octave??????????????????? no

Additional buildsettings ============================================

Build demo apps?????????? no
Now run make...

由此可知ffmpeg并沒有編譯進Opencv,查看config.log文件,閱讀里面的信息可知libavutil和libx264兩個庫文件沒有找到,由此才產生了以上的結果。在配置命令行中添加LIBS=”-lavutil –lx264”,再次make,此時輸出的配置信息中Use ffmpeg:???? yes,配置帶ffmpeg的Opencv成功。

#make install

11、將opencv-arm/lib中的動態庫文件libcv.so.4.0.0,libcvaux.so.4.0.0,libhighgui.so.4.0.0,

Libcxcore.so.4.0.0,libml.so.4.0.0拷出并且重命名為*.so.4,再和上面編譯出的其他動態庫文件一起拷貝到開發板的/usr/lib目錄下即可。至此Opencv移植完成,將交叉編譯出的二進制代碼拷到板子中,修改權限即可執行。

12、關于交叉編譯Opencv程序時Makefile文件的編寫

OBJ=test1
CC=arm-none-linux-gnueabi-g++
CFLAGS=-I/opt/EmbedSky/arm/opencv-arm/include/opencv/
LDFLAGS=-L/opt/EmbedSky/arm/opencv-arm/lib/-lcv -lcxcore -lpthread -lrt -lcvaux -lm -lpng -ljpeg -lz -lml -lhighgui -ldl-lavcodec -lavdevice -lavformat -lavutil -lswscale -lx264 -lxvidcore
$(OBJ):$(OBJ).o
$(CC) $(OBJ).c -o $(OBJ) $(CFLAGS)$(LDFLAGS)
clean:
rm-f *.o *~ $(OBJ)

當編譯其他程序時,修改test1即可。

七星彩走势图2元网官网