全志R16的tinav2.1系统增加opencv2.4.9的库的步骤(分色排版)

来源:互联网 发布:adams数据导出 编辑:程序博客网 时间:2024/06/05 09:57

全志R16的tinav2.1系统增加opencv2.4.9的库的步骤

完成时间:2017/5/11 11:03

版本:V1.0

 

请严重注意:根据本文加载openCV的库,对比结果,RK3128的运算速度是R16的3.16倍。

具体原因,本文就不给出来了!^_请自行找。我可以很负责任的告诉你,性能是可以达到稍微优于RK3128的。

1、验证编译/刷机全志R16的TINAV2.1的系统:

编译环境配置完成之后,就先编译一个全志R16的TINAV2.1的系统,烧录到开发板:SC3817上,验证一下你的编译工具都是正常工作的/配置正确了。

我用的笔记本电脑型号:华硕FX50J(WIN7 64位)。

INTLE酷睿I7-4720HQ

内存:4GB+8GB(LDDR3)

 

虚拟机配置:VMWare12(兼容配置为VMWare8)单CPU4核2GB内存。

编译时间:#### make completed successfully (17:35 (mm:ss)) ####

具体的所需要的时间看你的电脑的配置了CPU+内存大小)

 

 


rootroot@rootroot-virtual-machine:~/wyb$ mv tinaV2.1 opencv2.4.9_tinav2.1_ov5640

rootroot@rootroot-virtual-machine:~/wyb$ cd opencv2.4.9_tinav2.1_ov5640

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ source build/envsetup.sh 

including target/allwinner/azalea-perf1/vendorsetup.sh

including target/allwinner/astar-spk/vendorsetup.sh

including target/allwinner/octopus-dev/vendorsetup.sh

including target/allwinner/tulip-d1/vendorsetup.sh

including target/allwinner/azalea-evb/vendorsetup.sh

including target/allwinner/octopus-sch/vendorsetup.sh

including target/allwinner/azalea-perf2/vendorsetup.sh

including target/allwinner/generic/vendorsetup.sh

including target/allwinner/astar-evb/vendorsetup.sh

including target/allwinner/astar-parrot/vendorsetup.sh

including target/allwinner/azalea-perf3/vendorsetup.sh

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ lunch

 

You're building on Linux

 

Lunch menu... pick a combo:

     1. azalea_perf1-tina

     2. azalea_perf1-dragonboard

     3. astar_spk-tina

     4. astar_spk-dragonboard

     5. octopus_dev-tina

     6. octopus_dev-dragonboard

     7. tulip_d1-tina

     8. tulip_d1-dragonboard

     9. azalea_evb-tina

     10. azalea_evb-dragonboard

     11. octopus_sch-tina

     12. octopus_sch-dragonboard

     13. azalea_perf2-tina

     14. azalea_perf2-dragonboard

     15. astar_evb-tina

     16. astar_parrot-tina

     17. astar_parrot-dragonboard

     18. azalea_perf3-tina

     19. azalea_perf3-dragonboard

 

Which would you like?16

 

============================================

PLATFORM_VERSION_CODENAME=Neptune

PLATFORM_VERSION=2.0.0

TARGET_PRODUCT=astar_parrot

TARGET_BUILD_VARIANT=tina

TARGET_BUILD_TYPE=release

TARGET_BUILD_APPS=

TARGET_ARCH=arm

TARGET_ARCH_VARIANT=armv7-a-neon

TARGET_CPU_VARIANT=cortex-a7

TARGET_2ND_ARCH=

TARGET_2ND_ARCH_VARIANT=

TARGET_2ND_CPU_VARIANT=

HOST_ARCH=x86_64

HOST_OS=linux

HOST_OS_EXTRA=Linux-3.13.0-24-generic-x86_64-with-Ubuntu-14.04-trusty

HOST_BUILD_TYPE=release

BUILD_ID=57513AA3

OUT_DIR=

============================================

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ make -j8

 

 

Creating 4.0 filesystem on /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/linux-astar-parrot/root.squashfs, block size 262144.

Pseudo file "/dev" exists in source filesystem "/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/rootfs/dev".

Ignoring, exclude it (-e/-ef) to override.

[================================================================================================================================================================================================/] 586/586 100%

Exportable Squashfs 4.0 filesystem, xz compressed, data block size 262144

compressed data, compressed metadata, compressed fragments, no xattrs

duplicates are removed

Filesystem size 6045.07 Kbytes (5.90 Mbytes)

36.40% of uncompressed filesystem size (16605.45 Kbytes)

Inode table size 6836 bytes (6.68 Kbytes)

24.69% of uncompressed inode table size (27687 bytes)

Directory table size 7989 bytes (7.80 Kbytes)

48.59% of uncompressed directory table size (16441 bytes)

Number of duplicate files found 7

Number of inodes 827

Number of files 560

Number of fragments 35

Number of symbolic links  196

Number of device nodes 1

Number of fifo nodes 0

Number of socket nodes 0

Number of directories 70

Number of ids (unique uids + gids) 1

Number of uids 1

root (0)

Number of gids 1

root (0)

dd if=/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/linux-astar-parrot/root.squashfs of=/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/rootfs.img bs=128k conv=sync

47+1 records in

48+0 records out

6291456 bytes (6.3 MB) copied, 0.00435745 s, 1.4 GB/s

( cd /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot ; find -maxdepth 1 -type f \! -name 'md5sums'  -printf "%P\n" | sort | xargs md5sum --binary > md5sums )

( cd /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot ; find -maxdepth 1 -type f \! -name 'md5sums'  -printf "%P\n" | sort | xargs openssl dgst -sha256 > sha256sums )

make[5]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/target/allwinner/generic/image'

make[4]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/target/allwinner/astar-parrot'

make[3]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/target/allwinner'

make[2]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

export MAKEFLAGS= ;make -w -r package/index

make[2]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

Generating package index...

Signing key has not been configured

make[2]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

make[1]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

 

#### make completed successfully (17:35 (mm:ss)) ####

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ pack -d

No kernel param, parse it from astar

copying tools file

copying configs file

image/aultls32.fex

image/aultools.fex

image/boot_package.fex

image/cardscript.fex

image/cardscript_secure.fex

image/cardtool.fex

image/env_burn.cfg

image/env.cfg

image/env_dragonboard.cfg

image/image.cfg

image/image_linux.cfg

image/split_xxxx.fex

image/sunxi.fex

image/sys_config.fex

image/sys_partition_dragonboard.fex

image/sys_partition_dump.fex

image/sys_partition.fex

image/sys_partition_nor.fex

image/sys_partition_private.fex

image/test_config.fex

image/toc0.fex

image/toc1.fex

image/usbtool.fex

image/usbtool_test.fex

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640

copying boot resource

copying boot file

uart -> card0

packing for tina linux

normal

load file: boot0_spinor.fex ok

load file: u-boot-spinor.fex ok

load file: sunxi_mbr.fex ok

load file: sys_partition.bin ok

load file: boot-resource.fex ok

load file: env.fex ok

load file: boot.fex ok

load file: rootfs.fex ok

this is not a partition key

merge_package ok

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/host/bin/

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/image

Begin Parse sys_partion.fex

Add partion boot-resource.fex BOOT-RESOURCE_FEX

Add partion very boot-resource.fex BOOT-RESOURCE_FEX

FilePath: boot-resource.fex

FileLength=14000Add partion env.fex ENV_FEX000000000

Add partion very env.fex ENV_FEX000000000

FilePath: env.fex

FileLength=20000Add partion boot.fex BOOT_FEX00000000

Add partion very boot.fex BOOT_FEX00000000

FilePath: boot.fex

FileLength=400000Add partion rootfs.fex ROOTFS_FEX000000

Add partion very rootfs.fex ROOTFS_FEX000000

FilePath: rootfs.fex

FileLength=600000sys_config.fex Len: 0xf667

config.fex Len: 0x9e4c

split_xxxx.fex Len: 0x200

sys_partition.fex Len: 0xba6

sunxi.fex Len: 0x9

boot0_nand.fex Len: 0x8000

boot0_sdcard.fex Len: 0x8000

u-boot.fex Len: 0xd8000

toc1.fex Len: 0x8

toc0.fex Len: 0x8

fes1.fex Len: 0x3180

full_img.fex Len: 0xe30000

boot_package.fex Len: 0x10

usbtool.fex Len: 0x23000

aultools.fex Len: 0x27c29

aultls32.fex Len: 0x2455d

cardtool.fex Len: 0x11a00

cardscript.fex Len: 0x6ea

sunxi_mbr.fex Len: 0x10000

dlinfo.fex Len: 0x4000

boot-resource.fex Len: 0x14000

Vboot-resource.fex Len: 0x4

env.fex Len: 0x20000

Venv.fex Len: 0x4

boot.fex Len: 0x400000

Vboot.fex Len: 0x4

rootfs.fex Len: 0x600000

Vrootfs.fex Len: 0x4

BuildImg 0

Dragon execute image.cfg SUCCESS !

----------image is at----------

 

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/tina_astar-parrot_card0.img

 

pack finish

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

 

 

2、给全志R16的TINAV2.1系统导入openCV2.4.9(Makefile方式):

参考文献:

https://my.oschina.net/u/2306127/blog/382609

玩转智能路由器-WRTnode添加OpenCV支持

 

http://wiki.wrtnode.com/index.php?title=OpenWrt_package_method/zh-cn

!!!!用OpenWrt package方式编译OpenCV

 

 

编辑Makefile文件:

T:\wyb\opencv2.4.9_tinav2.1_ov5640\package\libs\opencv\Makefile

include $(TOPDIR)/rules.mk

 

PKG_NAME:=opencv

 

PKG_VERSION:=2.4.9

 

PKG_RELEASE:=1

 

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).zip

 

PKG_SOURCE_URL:=https://github.com/Itseez/opencv/archive/2.4.9.zip

 

PKG_MD5SUM:=7F958389E71C77ABDF5EFE1DA988B80C

 

#PKG_LICENSE:=BSD

#PKG_LICENSE_FILE:=

 

 

 

PKG_CAT:=unzip

 

include $(BUILD_DIR)/package.mk

include $(BUILD_DIR)/cmake.mk

 

define Package/opencv/Default/description

the Open Source Computer Vision Library for linux

endef

 

define Package/opencv

  SECTION:=libs

  CATEGORY:=Libraries

  TITLE:=opencv-2.4.9 source only

  DEPENDS:=+libpthread +librt +libstdcpp +zlib +libjpeg +libpng

endef

 

PKG_INSTALL:=1

CMAKE_OPTIONS += -DBUILD_opencv_gpu:BOOL=OFF \

    -DBUILD_1349:BOOL=OFF -DBUILD_opencv_stitching:BOOL=OFF \

    -DBUILD_opencv_superres:BOOL=OFF -DBUILD_opencv_ts:BOOL=OFF

 

 

 

 

define Build/InstallDev

$(INSTALL_DIR) $(1)/usr/include

$(CP) $(PKG_INSTALL_DIR)/usr/include/opencv  $(1)/usr/include

$(CP) $(PKG_INSTALL_DIR)/usr/include/opencv2  $(1)/usr/include  

$(INSTALL_DIR) $(1)/usr/lib  

$(CP) $(PKG_INSTALL_DIR)/usr/lib/libopencv* $(1)/usr/lib

endef

 

 

define Package/opencv/install

$(INSTALL_DIR) $(1)/usr/include

$(CP) $(PKG_INSTALL_DIR)/usr/include/* $(1)/usr/include  

$(INSTALL_DIR) $(1)/usr/lib   

$(CP) $(PKG_INSTALL_DIR)/usr/lib/libopencv* $(1)/usr/lib  

endef

 

$(eval $(call BuildPackage,opencv))

 

 

必须在menuconfig选中才能编译进去系统:

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ cp .config bak1_orig.config

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ make menuconfig

Libraries  --->

< > opencv.......................................... opencv-2.4.9 source only (NEW)

选中这里:

<*> opencv.......................................... opencv-2.4.9 source only

 

 

 

 

3、openCV2.4.9的编译错误的处理:

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ cp .config bak2_opencv-2.4.9.config

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ make -j8

 

 

[ 25%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfPizCompressor.cpp.o

[ 25%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfOutputFile.cpp.o

[ 25%] Building CXX object 3rdparty/openexr/CMakeFiles/IlmImf.dir/IlmImf/ImfCRgbaFile.cpp.o

[ 25%] Linking CXX static library ../lib/libIlmImf.a

make[6]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

[ 25%] Built target IlmImf

make[6]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

[ 25%] Generating opencv_core_pch_dephelp.cxx

Scanning dependencies of target opencv_core_pch_dephelp

make[6]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[6]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

[ 25%] Building CXX object modules/core/CMakeFiles/opencv_core_pch_dephelp.dir/opencv_core_pch_dephelp.cxx.o

[ 25%] Linking CXX static library ../../lib/libopencv_core_pch_dephelp.a

make[6]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

[ 25%] Built target opencv_core_pch_dephelp

make[6]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

Scanning dependencies of target pch_Generate_opencv_core

make[6]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[6]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

[ 26%] Generating precomp.hpp

[ 26%] Generating precomp.hpp.gch/opencv_core_Release.gch

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.2.0/../../../../arm-openwrt-linux-muslgnueabi/lib/crt1.o: In function `_start_c':

/home/caiyongheng/tina_test/out/azalea-perf1/compile_dir/toolchain/musl-1.1.14/crt/crt1.c:17: undefined reference to `main'

collect2: error: ld returned 1 exit status

make[6]: *** [modules/core/precomp.hpp.gch/opencv_core_Release.gch] Error 1

make[6]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[5]: *** [modules/core/CMakeFiles/pch_Generate_opencv_core.dir/all] Error 2

make[5]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[4]: *** [all] Error 2

make[4]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[3]: *** [/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9/.built] Error 2

make[3]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/package/libs/opencv'

make[2]: *** [package/libs/opencv/compile] Error 2

make[2]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

make[1]: *** [/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/stamp/.package_compile] Error 2

make[1]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

Build failed - please re-run with -j1 to see the real error message

make: *** [world] ´íÎó 1

 

#### make failed to build some targets (01:53 (mm:ss)) ####

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

需要修改三个地方:

T:\wyb\opencv2.4.9_tinav2.1_ov5640\out\astar-parrot\compile_dir\target\opencv-2.4.9\CMakeCache.txt

 

 

修改一:

//Flags used by the compiler during all build types.

CMAKE_CXX_FLAGS:STRING='-Os -pipe -march=armv7-a -mtune=cortex-a7 -mfpu=neon -fno-caller-saves -fno-plt -mfloat-abi=hard  -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  '

修改为:

//Flags used by the compiler during all build types.

//CMAKE_CXX_FLAGS:STRING='-Os -pipe -march=armv7-a -mtune=cortex-a7 -mfpu=neon -fno-caller-saves -fno-plt -mfloat-abi=hard  -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  '

CMAKE_CXX_FLAGS:STRING=-fPIC

 

 

修改二:

//Flags used by the compiler during all build types.

CMAKE_C_FLAGS:STRING='-Os -pipe -march=armv7-a -mtune=cortex-a7 -mfpu=neon -fno-caller-saves -fno-plt -mfloat-abi=hard  -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  '

修改为:

//Flags used by the compiler during all build types.

//CMAKE_C_FLAGS:STRING='-Os -pipe -march=armv7-a -mtune=cortex-a7 -mfpu=neon -fno-caller-saves -fno-plt -mfloat-abi=hard  -Wformat -Werror=format-security -fstack-protector -D_FORTIFY_SOURCE=1 -Wl,-z,now -Wl,-z,relro  '

CMAKE_C_FLAGS:STRING=-fPIC

 

 

修改三:

//No help, variable specified on the command line.

CMAKE_EXE_LINKER_FLAGS:STRING=-L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/out/astar-parrot/staging_dir/target/usr/lib -L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/out/astar-parrot/staging_dir/target/lib -L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/usr/lib -L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib -znow -zrelro

修改为:

//No help, variable specified on the command line.

//CMAKE_EXE_LINKER_FLAGS:STRING=-L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/out/astar-parrot/staging_dir/target/usr/lib -L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/out/astar-parrot/staging_dir/target/lib -L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/usr/lib -L/home/rootroot/wyb/opencv3.1_r16_tinav2.1/prebuilt/gcc/linux-x86/arm/toolchain-sunxi/toolchain/lib -znow -zrelro

CMAKE_EXE_LINKER_FLAGS:STRING=-pthread -lrt -Wl,--no-as-needed -ldl

 

 

 

 

修改CMakeCache.txt之后继续编译:

rootroot@rootroot-E400:~/wyb/opencv3.1_r16_tinav2.1$ make -j8

 

 

[ 28%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/dxt.cpp.o

[ 28%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/glob.cpp.o

[ 28%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/arithm.cpp.o

[ 28%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/algorithm.cpp.o

[ 28%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9/modules/core/src/system.cpp:167:24: fatal error: sys/sysctl.h: No such file or directory

compilation terminated.

make[6]: *** [modules/core/CMakeFiles/opencv_core.dir/src/system.cpp.o] Error 1

make[6]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[5]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make[5]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[4]: *** [all] Error 2

make[4]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[3]: *** [/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9/.built] Error 2

make[3]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/package/libs/opencv'

make[2]: *** [package/libs/opencv/compile] Error 2

make[2]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

make[1]: *** [/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/stamp/.package_compile] Error 2

make[1]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

Build failed - please re-run with -j1 to see the real error message

make: *** [world] 错误 1

 

#### make failed to build some targets (56 seconds) ####

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

T:\wyb\opencv2.4.9_tinav2.1_ov5640\out\astar-parrot\compile_dir\target\opencv-2.4.9\modules\core\src\system.cpp

关闭头文件:#include <sys/sysctl.h>

 

#if defined __linux__ || defined __APPLE__ || defined __EMSCRIPTEN__

#include <unistd.h>

#include <stdio.h>

#include <sys/types.h>

#if defined ANDROID

#include <sys/sysconf.h>

#else

//#include <sys/sysctl.h>

#endif

#endif

 

 

 

 

修改system.cpp之后继续编译:

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ make -j8

 

 

install -d -m0755 /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/tmp-procps-vmstat/usr/bin

install -m0755 /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/procps-3.2.8/vmstat /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/tmp-procps-vmstat/usr/bin/

[ 26%] Building CXX object modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.o

make[3]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/package/system/fstools'

SHELL= flock /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/tmp/.root-copy.flock -c 'cp -fpR /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/tmp-procps-vmstat/. /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/'

rm -rf /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/tmp-procps-vmstat

touch /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/stamp/.procps-vmstat_installed

if [ -f /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/pkginfo/procps.default.install.clean ]; then rm -f /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/pkginfo/procps.default.install /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/pkginfo/procps.default.install.clean; fi; echo "procps-vmstat" >> /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/pkginfo/procps.default.install

make[3]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/package/utils/ubi-utils'

rm -rf /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/tmp-procps-watch

mkdir -p /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/stamp /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/tmp-procps-watch

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9/modules/core/src/parallel.cpp:60:32: fatal error: sys/sysctl.h: No such file or directory

compilation terminated.

make[6]: *** [modules/core/CMakeFiles/opencv_core.dir/src/parallel.cpp.o] Error 1

make[6]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[5]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2

make[5]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

make[3]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/package/utils/ubi-utils'

make[4]: *** [all] Error 2

make[4]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/opencv-2.4.9'

rm -rf /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/rootfs/tmp-opkg

……

make[3]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/package/kernel/linux'

make[2]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

make[1]: *** [/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/stamp/.package_compile] Error 2

make[1]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

Build failed - please re-run with -j1 to see the real error message

make: *** [world] 错误 1

 

#### make failed to build some targets (12 seconds) ####

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

T:\wyb\opencv2.4.9_tinav2.1_ov5640\out\astar-parrot\compile_dir\target\opencv-2.4.9\modules\core\src\parallel.cpp

关闭头文件:sys/sysctl.h

 

#if defined __linux__ || defined __APPLE__

    #include <unistd.h>

    #include <stdio.h>

    #include <sys/types.h>

    #if defined ANDROID

        #include <sys/sysconf.h>

    #else

        //#include <sys/sysctl.h>

    #endif

#endif

 

 

 

 

修改parallel.cpp之后继续编译:

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ make -j8

 

 

通过了:

dd if=/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/compile_dir/target/linux-astar-parrot/root.squashfs of=/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/rootfs.img bs=128k conv=sync

76+1 records in

77+0 records out

10092544 bytes (10 MB) copied, 0.0311922 s, 324 MB/s

( cd /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot ; find -maxdepth 1 -type f \! -name 'md5sums'  -printf "%P\n" | sort | xargs md5sum --binary > md5sums )

( cd /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot ; find -maxdepth 1 -type f \! -name 'md5sums'  -printf "%P\n" | sort | xargs openssl dgst -sha256 > sha256sums )

make[5]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/target/allwinner/generic/image'

make[4]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/target/allwinner/astar-parrot'

make[3]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/target/allwinner'

make[2]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

export MAKEFLAGS= ;make -w -r package/index

make[2]: Entering directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

Generating package index...

Signing key has not been configured

make[2]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

make[1]: Leaving directory `/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640'

 

#### make completed successfully (03:39 (mm:ss)) ####

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

打包出错:

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ pack -d

No kernel param, parse it from astar

copying tools file

copying configs file

image/aultls32.fex

image/aultools.fex

image/boot_package.fex

image/cardscript.fex

image/cardscript_secure.fex

image/cardtool.fex

image/env_burn.cfg

image/env.cfg

image/env_dragonboard.cfg

image/image.cfg

image/image_linux.cfg

image/split_xxxx.fex

image/sunxi.fex

image/sys_config.fex

image/sys_partition_dragonboard.fex

image/sys_partition_dump.fex

image/sys_partition.fex

image/sys_partition_nor.fex

image/sys_partition_private.fex

image/test_config.fex

image/toc0.fex

image/toc1.fex

image/usbtool.fex

image/usbtool_test.fex

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640

copying boot resource

copying boot file

uart -> card0

packing for tina linux

normal

load file: boot0_spinor.fex ok

load file: u-boot-spinor.fex ok

load file: sunxi_mbr.fex ok

load file: sys_partition.bin ok

load file: boot-resource.fex ok

load file: env.fex ok

load file: boot.fex ok

load file: rootfs.fex ok

error: file size of rootfs.fex(10092544) > part size(8388608)

merge_package fail

ERROR: merge_full_img failed

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

看字面意思是:整合openCV2.4.9之后,根文件系统rootfs现在的大小超过分区表的设置了。

改大即可:

T:\wyb\opencv2.4.9_tinav2.1_ov5640\target\allwinner\astar-parrot\configs\sys_partition.fex

[partition]

    name         = rootfs

    size         = 16384

    downloadfile = "rootfs.fex"

    user_type    = 0x8000

 

[partition]

    name         = rootfs_data

    size         = 98304

    user_type    = 0x8000

 

修改为:

[partition]

    name         = rootfs

    size         = 98304

    downloadfile = "rootfs.fex"

    user_type    = 0x8000

 

[partition]

    name         = rootfs_data

    size         = 98304

    user_type    = 0x8000

 

 

 

 

继续打包:

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ pack -d

No kernel param, parse it from astar

copying tools file

copying configs file

image/aultls32.fex

image/aultools.fex

image/boot_package.fex

image/cardscript.fex

image/cardscript_secure.fex

image/cardtool.fex

image/env_burn.cfg

image/env.cfg

image/env_dragonboard.cfg

image/image.cfg

image/image_linux.cfg

image/split_xxxx.fex

image/sunxi.fex

image/sys_config.fex

image/sys_partition_dragonboard.fex

image/sys_partition_dump.fex

image/sys_partition.fex

image/sys_partition_nor.fex

image/sys_partition_nor - ¸±±¾.fex

image/sys_partition_private.fex

image/sys_partition - ¸±±¾.fex

image/test_config.fex

image/toc0.fex

image/toc1.fex

image/usbtool.fex

image/usbtool_test.fex

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640

copying boot resource

copying boot file

uart -> card0

packing for tina linux

normal

load file: boot0_spinor.fex ok

load file: u-boot-spinor.fex ok

load file: sunxi_mbr.fex ok

load file: sys_partition.bin ok

load file: boot-resource.fex ok

load file: env.fex ok

load file: boot.fex ok

load file: rootfs.fex ok

error: file size of rootfs.fex(10092544) > part size(8388608)

merge_package fail

ERROR: merge_full_img failed

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

 

 

看错误提示:还是rootfs分区的实际大小 大于 分区的预设大小了。

干掉sys_partition_nor.fex:

T:\wyb\opencv2.4.9_tinav2.1_ov5640\target\allwinner\astar-parrot\configs\sys_partition_nor.fex

 

 

 

 

继续打包:

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ pack -d

No kernel param, parse it from astar

copying tools file

copying configs file

image/aultls32.fex

image/aultools.fex

image/boot_package.fex

image/cardscript.fex

image/cardscript_secure.fex

image/cardtool.fex

image/env_burn.cfg

image/env.cfg

image/env_dragonboard.cfg

image/image.cfg

image/image_linux.cfg

image/split_xxxx.fex

image/sunxi.fex

image/sys_config.fex

image/sys_partition_dragonboard.fex

image/sys_partition_dump.fex

image/sys_partition.fex

image/sys_partition_nor - 副本.fex

image/sys_partition_private.fex

image/sys_partition - 副本.fex

image/test_config.fex

image/toc0.fex

image/toc1.fex

image/usbtool.fex

image/usbtool_test.fex

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640

copying boot resource

copying boot file

uart -> card0

packing for tina linux

normal

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/host/bin/

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/image

Begin Parse sys_partion.fex

Add partion boot-resource.fex BOOT-RESOURCE_FEX

Add partion very boot-resource.fex BOOT-RESOURCE_FEX

FilePath: boot-resource.fex

FileLength=14000Add partion env.fex ENV_FEX000000000

Add partion very env.fex ENV_FEX000000000

FilePath: env.fex

FileLength=20000Add partion boot.fex BOOT_FEX00000000

Add partion very boot.fex BOOT_FEX00000000

FilePath: boot.fex

FileLength=400000Add partion rootfs.fex ROOTFS_FEX000000

Add partion very rootfs.fex ROOTFS_FEX000000

FilePath: rootfs.fex

FileLength=9a0000sys_config.fex Len: 0xf667

config.fex Len: 0x9e4c

split_xxxx.fex Len: 0x200

sys_partition.fex Len: 0xba6

sunxi.fex Len: 0x9

boot0_nand.fex Len: 0x8000

boot0_sdcard.fex Len: 0x8000

u-boot.fex Len: 0xd8000

toc1.fex Len: 0x8

toc0.fex Len: 0x8

fes1.fex Len: 0x3180

full_img.fex Len: 0x16

boot_package.fex Len: 0x10

usbtool.fex Len: 0x23000

aultools.fex Len: 0x27c29

aultls32.fex Len: 0x2455d

cardtool.fex Len: 0x11a00

cardscript.fex Len: 0x6ea

sunxi_mbr.fex Len: 0x10000

dlinfo.fex Len: 0x4000

boot-resource.fex Len: 0x14000

Vboot-resource.fex Len: 0x4

env.fex Len: 0x20000

Venv.fex Len: 0x4

boot.fex Len: 0x400000

Vboot.fex Len: 0x4

rootfs.fex Len: 0x9a0000

Vrootfs.fex Len: 0x4

BuildImg 0

Dragon execute image.cfg SUCCESS !

----------image is at----------

 

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/tina_astar-parrot_card0.img

 

pack finish

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$ ll /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/tina_astar-parrot_card0.img

-rwxrwxr-x 1 rootroot rootroot 16224256  5月 10 14:16 /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/tina_astar-parrot_card0.img*

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640$

 

 

 

 

(可选操作):

请严重注意:改大这里之后以上的步骤不执行也可以打包,但是刷机失败,并且看不出来明显的出错信息。

(那就倒大霉了!^_)

打开ext4支持(可选操作,我是在这里设置了):

rootroot@rootroot-E400:~/wyb/opencv3.1_r16_tinav2.1$ make menuconfig

Target Images  --->

[ ] ext4  ----

选中之前:

[ ] ramdisk  ----

    *** Root filesystem archives ***

[ ] cpio.gz

[ ] tar.gz

    *** Root filesystem images ***

[ ] ext4  ----

[ ] jffs2

[*] squashfs  --->

    *** Image Options ***

(4) Boot (SD Card) filesystem partition size (in MB)

选中这里之后:

[*] ext4  --->

 

[ ] ramdisk  ----

    *** Root filesystem archives ***

[ ] cpio.gz

[ ] tar.gz

    *** Root filesystem images ***

[*] ext4  --->

[ ] jffs2

[*] squashfs  --->

[*] GZip images (NEW)

    *** Image Options ***

(4) Boot (SD Card) filesystem partition size (in MB)

(48) Root filesystem partition size (in MB) (NEW)

[ ] Include kernel in root filesystem (NEW)  ----

 

 

 

 

3、验证openCV2.4.9的库移植成功(/usr/lib# ll libopencv*):

 

刷机之后,在系统中查找openCV2.4.9的库:

[   25.970392] wl_android_wifi_on: Success

[   25.975785] p2p0: p2p_dev_addr=96:a1:a2:c6:49:d6

[   26.058014] dhd_open: Exit ret=0

[   29.589441] sndpcm_startup,l:1688,pa_vol:40

 

 

 

BusyBox v1.24.1 () built-in shell (ash)

 

 _____  _              __     _

|_   _||_| ___  _ _   |  |   |_| ___  _ _  _ _

  | |   _ |   ||   |  |  |__ | ||   || | ||_'_|

  | |  | || | || _ |  |_____||_||_|_||___||_,_|

  |_|  |_||_|_||_|_|  Tina is Based on OpenWrt!

 ----------------------------------------------

 Tina Linux (Neptune, 57513AA3)

 ----------------------------------------------

root@TinaLinux:/#

root@TinaLinux:/# cd usr/lib/

root@TinaLinux:/usr/lib#

root@TinaLinux:/usr/lib# ll libopencv*

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_calib3d.so -> libopencv_calib3d.so.2.4

lrwxrwxrwx    1 root     root            26 May 10  2017 libopencv_calib3d.so.2.4 -> libopencv_calib3d.so.2.4.9

-rw-r--r--    1 root     root        868359 May 10  2017 libopencv_calib3d.so.2.4.9

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_contrib.so -> libopencv_contrib.so.2.4

lrwxrwxrwx    1 root     root            26 May 10  2017 libopencv_contrib.so.2.4 -> libopencv_contrib.so.2.4.9

-rw-r--r--    1 root     root       1306701 May 10  2017 libopencv_contrib.so.2.4.9

lrwxrwxrwx    1 root     root            21 May 10  2017 libopencv_core.so -> libopencv_core.so.2.4

lrwxrwxrwx    1 root     root            23 May 10  2017 libopencv_core.so.2.4 -> libopencv_core.so.2.4.9

-rw-r--r--    1 root     root       2842555 May 10  2017 libopencv_core.so.2.4.9

lrwxrwxrwx    1 root     root            27 May 10  2017 libopencv_features2d.so -> libopencv_features2d.so.2.4

lrwxrwxrwx    1 root     root            29 May 10  2017 libopencv_features2d.so.2.4 -> libopencv_features2d.so.2.4.9

-rw-r--r--    1 root     root        986248 May 10  2017 libopencv_features2d.so.2.4.9

lrwxrwxrwx    1 root     root            22 May 10  2017 libopencv_flann.so -> libopencv_flann.so.2.4

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_flann.so.2.4 -> libopencv_flann.so.2.4.9

-rw-r--r--    1 root     root        819205 May 10  2017 libopencv_flann.so.2.4.9

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_highgui.so -> libopencv_highgui.so.2.4

lrwxrwxrwx    1 root     root            26 May 10  2017 libopencv_highgui.so.2.4 -> libopencv_highgui.so.2.4.9

-rw-r--r--    1 root     root       2355964 May 10  2017 libopencv_highgui.so.2.4.9

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_imgproc.so -> libopencv_imgproc.so.2.4

lrwxrwxrwx    1 root     root            26 May 10  2017 libopencv_imgproc.so.2.4 -> libopencv_imgproc.so.2.4.9

-rw-r--r--    1 root     root       2490775 May 10  2017 libopencv_imgproc.so.2.4.9

lrwxrwxrwx    1 root     root            23 May 10  2017 libopencv_legacy.so -> libopencv_legacy.so.2.4

lrwxrwxrwx    1 root     root            25 May 10  2017 libopencv_legacy.so.2.4 -> libopencv_legacy.so.2.4.9

-rw-r--r--    1 root     root       1590782 May 10  2017 libopencv_legacy.so.2.4.9

lrwxrwxrwx    1 root     root            19 May 10  2017 libopencv_ml.so -> libopencv_ml.so.2.4

lrwxrwxrwx    1 root     root            21 May 10  2017 libopencv_ml.so.2.4 -> libopencv_ml.so.2.4.9

-rw-r--r--    1 root     root        641066 May 10  2017 libopencv_ml.so.2.4.9

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_nonfree.so -> libopencv_nonfree.so.2.4

lrwxrwxrwx    1 root     root            26 May 10  2017 libopencv_nonfree.so.2.4 -> libopencv_nonfree.so.2.4.9

-rw-r--r--    1 root     root        274435 May 10  2017 libopencv_nonfree.so.2.4.9

lrwxrwxrwx    1 root     root            26 May 10  2017 libopencv_objdetect.so -> libopencv_objdetect.so.2.4

lrwxrwxrwx    1 root     root            28 May 10  2017 libopencv_objdetect.so.2.4 -> libopencv_objdetect.so.2.4.9

-rw-r--r--    1 root     root        963076 May 10  2017 libopencv_objdetect.so.2.4.9

lrwxrwxrwx    1 root     root            20 May 10  2017 libopencv_ocl.so -> libopencv_ocl.so.2.4

lrwxrwxrwx    1 root     root            22 May 10  2017 libopencv_ocl.so.2.4 -> libopencv_ocl.so.2.4.9

-rw-r--r--    1 root     root       2127699 May 10  2017 libopencv_ocl.so.2.4.9

lrwxrwxrwx    1 root     root            22 May 10  2017 libopencv_photo.so -> libopencv_photo.so.2.4

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_photo.so.2.4 -> libopencv_photo.so.2.4.9

-rw-r--r--    1 root     root        135171 May 10  2017 libopencv_photo.so.2.4.9

lrwxrwxrwx    1 root     root            22 May 10  2017 libopencv_video.so -> libopencv_video.so.2.4

lrwxrwxrwx    1 root     root            24 May 10  2017 libopencv_video.so.2.4 -> libopencv_video.so.2.4.9

-rw-r--r--    1 root     root        315395 May 10  2017 libopencv_video.so.2.4.9

lrwxrwxrwx    1 root     root            26 May 10  2017 libopencv_videostab.so -> libopencv_videostab.so.2.4

lrwxrwxrwx    1 root     root            28 May 10  2017 libopencv_videostab.so.2.4 -> libopencv_videostab.so.2.4.9

-rw-r--r--    1 root     root        274467 May 10  2017 libopencv_videostab.so.2.4.9

root@TinaLinux:/usr/lib#

root@TinaLinux:/usr/lib#

root@TinaLinux:/usr/lib#

root@TinaLinux:/usr/lib#

 

 

 

 

4、编译链的配置:

(一)、复制tinav2.1的SDK自带的编译链到目录T:\citybrand\toolchain

 

rootroot@rootroot-virtual-machine:~$ cd wyb/opencv2.4.9_tinav2.1_ov5640$ cd prebuilt/gcc/linux-x86/arm/toolchain-sunxi/

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$tar zcvf toolchain_r16+tinav2.1_wyb_pack_20170511_1010.tar.gz toolchain/

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$ cd ~

rootroot@rootroot-virtual-machine:~$ mkdir citybrand

rootroot@rootroot-virtual-machine:~$ cd -

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$cp toolchain_r16+tinav2.1_wyb_pack_20170511_1010.tar.gz ~/citybrand/

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/prebuilt/gcc/linux-x86/arm/toolchain-sunxi$ cd ~/citybrand/

rootroot@rootroot-virtual-machine:~/citybrand$ tar zxvf toolchain_r16+tinav2.1_wyb_pack_20170511_1010.tar.gz

 

 

(二)、添加环境变量:

.bashrc的最后输入:

export PATH="$PATH:/home/rootroot/citybrand/toolchain/bin"

export STAGING_DIR="$PATH:/home/rootroot/citybrand/toolchain"

 

 

(三)、重启电脑之后,输入arm-openwrt-linux-gcc -v检查是否可用(确认环境变量是否配置正确)

rootroot@rootroot-virtual-machine:~$ cd wyb/

rootroot@rootroot-virtual-machine:~/wyb$ arm-openwrt-linux-gcc -v

Reading specs from /home/rootroot/citybrand/toolchain/bin/../lib/gcc/arm-openwrt-linux-muslgnueabi/5.2.0/specs

COLLECT_GCC=arm-openwrt-linux-muslgnueabi-gcc.bin

COLLECT_LTO_WRAPPER=/home/rootroot/citybrand/toolchain/bin/../libexec/gcc/arm-openwrt-linux-muslgnueabi/5.2.0/lto-wrapper

Target: arm-openwrt-linux-muslgnueabi

Configured with: /home/caiyongheng/tina_test/out/azalea-perf3/compile_dir/toolchain/gcc-5.2.0/configure --with-bugurl=https://dev.openwrt.org/ --with-pkgversion='OpenWrt GCC 5.2.0 70-1-1' --prefix=/home/caiyongheng/tina_test/out/azalea-perf3/staging_dir/toolchain --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=arm-openwrt-linux-muslgnueabi --with-gnu-ld --enable-target-optspace --disable-libgomp --disable-libmudflap --disable-multilib --disable-nls --without-isl --without-cloog --with-host-libstdcxx=-lstdc++ --with-gmp=/home/caiyongheng/tina_test/out/host --with-mpfr=/home/caiyongheng/tina_test/out/host --with-mpc=/home/caiyongheng/tina_test/out/host --disable-decimal-float --with-diagnostics-color=auto-if-env --disable-libssp --enable-__cxa_atexit --with-arch=armv7-a --with-float=hard --with-headers=/home/caiyongheng/tina_test/out/azalea-perf3/staging_dir/toolchain/include --disable-libsanitizer --enable-languages=c,c++ --enable-shared --enable-threads --with-slibdir=/home/caiyongheng/tina_test/out/azalea-perf3/staging_dir/toolchain/lib --enable-lto --with-libelf=/home/caiyongheng/tina_test/out/host

Thread model: posix

gcc version 5.2.0 (OpenWrt GCC 5.2.0 70-1-1) 

rootroot@rootroot-virtual-machine:~/wyb$

 

 

 

 

5、openCV的测试程序:

头文件参考:https://github.com/WRTnode/openwrt-packages/blob/master/wrtnode/opencv-test/src/cv_test.c

http://blog.csdn.net/noodies/article/details/5798434

编译OpenCV-2.1.0 for tinav2.1(全志R16)

 

// test.cpp

#include <iostream>

 

#include <opencv2/opencv.hpp>

 

#include <opencv/cv.h>

#include <opencv/highgui.h>

 

 

using namespace std;

using namespace cv;

 

int main( int argc, char** argv )

{

Mat m = imread(argv[1],1);

cout<<"cols: "<<m.cols<<endl;

return 0;

}

 

 

 

 

编译出错:

rootroot@rootroot-virtual-machine:~/wyb$

rootroot@rootroot-virtual-machine:~/wyb$ arm-openwrt-linux-g++ -I/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include -L/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib -lopencv_core -lopencv_highgui -lpthread -lrt -o test test.cpp

In file included from /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv/cv.h:69:0,

                 from test.cpp:6:

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:290:1: warning: 'template<class T> class cv::flann::Index_' is deprecated [-Wdeprecated-declarations]

 Index_<T>::Index_(const Mat& dataset, const ::cvflann::IndexParams& params)

 ^

……

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib/libopencv_highgui.so: undefined reference to `jpeg_alloc_huff_table@LIBJPEG_9.0'

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib/libopencv_highgui.so: undefined reference to `deflateParams'

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib/libopencv_highgui.so: undefined reference to `png_set_bgr@PNG12_0'

collect2: error: ld returned 1 exit status

rootroot@rootroot-virtual-machine:~/wyb$

 

 

以前(opencv3.1.0下)是采用了一个简单粗暴的方法,

将头文件和库文件直接拷贝到了编译链里面了。

头文件:

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include

T:\wyb\opencv2.4.9_tinav2.1_ov5640\out\astar-parrot\staging_dir\target\usr\include

T:\citybrand\toolchain\include

 

rootroot@rootroot-virtual-machine:~/wyb$ cd /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include$tar zcvf include+opencv2.4.9_wyb_20170511_1032.tar.gz opencv/ opencv2/

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include$mv include+opencv2.4.9_wyb_20170511_1032.tar.gz ~/citybrand/toolchain/include/

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include$cd ~/citybrand/toolchain/include/

rootroot@rootroot-virtual-machine:~/citybrand/toolchain/include$

rootroot@rootroot-virtual-machine:~/citybrand/toolchain/include$ tar zxvf include+opencv2.4.9_wyb_20170511_1032.tar.gz

rootroot@rootroot-virtual-machine:~/citybrand/toolchain/include$

 

 

库文件:

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib

 

 

(只打包libopencv的库so失败,全部打包了:)

rootroot@rootroot-virtual-machine:~/citybrand/toolchain/include$ cd /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib$

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib$ ll libopencv* | xargs tar zcvf libopencv2.4.9+so_wyb_pack_20170511_1037.tar.gz

tar: 无效选项 -- ">"

Try 'tar --help' or 'tar --usage' for more information.

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib$ find . -name libopencv*

find: 路径必须在表达式之前: libopencv_calib3d.so.2.4

用法: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib$ find . -name lib*

find: 路径必须在表达式之前: libasound.so.2

用法: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib$

 

 

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib$tar zcvf ../libopencv2.4.9+so_wyb_pack_20170511_1041.tar.gz *

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib$ cd ..

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr$cp libopencv2.4.9+so_wyb_pack_20170511_1041.tar.gz ~/citybrand/toolchain/lib

rootroot@rootroot-virtual-machine:~/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr$ cd ~/citybrand/toolchain/lib/

rootroot@rootroot-virtual-machine:~/citybrand/toolchain/lib$

rootroot@rootroot-virtual-machine:~/citybrand/toolchain/lib$ tar zxvf libopencv2.4.9+so_wyb_pack_20170511_1041.tar.gz 

rootroot@rootroot-virtual-machine:~/citybrand/toolchain/lib$ cd ~/wyb

 

 

rootroot@rootroot-virtual-machine:~/wyb$ arm-openwrt-linux-g++ -I/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include -L/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/lib -lopencv_core -lopencv_highgui -lpthread -lrt -o test test.cpp

In file included from /home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv/cv.h:69:0,

                 from test.cpp:6:

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:290:1: warning: 'template<class T> class cv::flann::Index_' is deprecated [-Wdeprecated-declarations]

 Index_<T>::Index_(const Mat& dataset, const ::cvflann::IndexParams& params)

 ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:232:2: note: declared here

  Index_ {

  ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:316:1: warning: 'template<class T> class cv::flann::Index_' is deprecated [-Wdeprecated-declarations]

 Index_<T>::~Index_()

 ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:232:2: note: declared here

  Index_ {

  ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:323:6: warning: 'template<class T> class cv::flann::Index_' is deprecated [-Wdeprecated-declarations]

 void Index_<T>::knnSearch(const vector<ElementType>& query, vector<int>& indices, vector<DistanceType>& dists, int knn, const ::cvflann::SearchParams& searchParams)

      ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:232:2: note: declared here

  Index_ {

  ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:335:6: warning: 'template<class T> class cv::flann::Index_' is deprecated [-Wdeprecated-declarations]

 void Index_<T>::knnSearch(const Mat& queries, Mat& indices, Mat& dists, int knn, const ::cvflann::SearchParams& searchParams)

      ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:232:2: note: declared here

  Index_ {

  ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:354:5: warning: 'template<class T> class cv::flann::Index_' is deprecated [-Wdeprecated-declarations]

 int Index_<T>::radiusSearch(const vector<ElementType>& query, vector<int>& indices, vector<DistanceType>& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)

     ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:232:2: note: declared here

  Index_ {

  ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:365:5: warning: 'template<class T> class cv::flann::Index_' is deprecated [-Wdeprecated-declarations]

 int Index_<T>::radiusSearch(const Mat& query, Mat& indices, Mat& dists, DistanceType radius, const ::cvflann::SearchParams& searchParams)

     ^

/home/rootroot/wyb/opencv2.4.9_tinav2.1_ov5640/out/astar-parrot/staging_dir/target/usr/include/opencv2/flann/flann.hpp:232:2: note: declared here

  Index_ {

  ^

rootroot@rootroot-virtual-machine:~/wyb$

 

 

(确认编译正确:使用file确认使用的是ARM编译器而不是X86编译器)

rootroot@rootroot-virtual-machine:~/wyb$ file test

test: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), not stripped

rootroot@rootroot-virtual-machine:~/wyb$ rm test

rootroot@rootroot-virtual-machine:~/wyb$

rootroot@rootroot-virtual-machine:~/wyb$

 

 

后来想想既然头文件和库文件都拷贝到编译链下面了,那就是不需要引用头文件和库文件了。

重启电脑之后尝试编译,发现少了不少警告信息!!!!(加载头文件依旧有很多警告):

rootroot@rootroot-virtual-machine:~/wyb$ arm-openwrt-linux-g++ -lopencv_core -lopencv_highgui -lpthread -lrt -o test test.cpp

rootroot@rootroot-virtual-machine:~/wyb$

rootroot@rootroot-virtual-machine:~/wyb$ file test

test: ELF 32-bit LSB  executable, ARM, EABI5 version 1 (SYSV), dynamically linked (uses shared libs), not stripped

rootroot@rootroot-virtual-machine:~/wyb$

 

 

后记:

arm-openwrt-linux-g++具体要加载哪些库,请根据实际需要加载。

本例程只加载了opencv_core和opencv_highgui库。(《数据结构》中的折半/排除得到最少的加载项)

 

阅读全文
0 0
原创粉丝点击