OpenCV简介
OpenCV的全称是:Open Source Computer Vision Library。OpenCV是一个基于BSD许可(开源)发行的跨平台计算机视觉库,可以运行在Linux、Windows和Mac OS操作系统上。它轻量级而且高效——由一系列C函数和少量C++类构成,同时提供了Python、Ruby、matlab等语言的接口,实现了图像处理和计算机视觉方面的很多通用算法。
解压OpenCV2.4.11
本次移植的OpenCV版本为OpenCV-2.4.11。将opencv-2.4.11.zip压缩文件拷贝到Ubuntu的”/home/tronlong/AM437x”目录下,进入文件所在路径,执行如下命令,将opencv-2.4.11.zip解压,文件会解压在当前目录。
Host# unzip opencv-2.4.11.zip
配置和编译OpenCV2.4.11
进入源码目录,新建build目录用于存放工作文件。依次执行如下命令:
Host# cd opencv-2.4.11
Host# mkdir build
Host# cd build
在build目录下,新建配置文件arm-linux-gnueabihf.cmake。
如使用V01.00.00.03版本LinuxProcessor-SDK,请写入如下内容:
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
# which C and C++ compiler to use
SET(CMAKE_C_COMPILER/home/tronlong/ti-processor-sdk-linux-am437x-evm-01.00.00.03/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /home/tronlong/ti-processor-sdk-linux-am437x-evm-01.00.00.03/linux-devkit/sysroots/i686-arago-linux/usr/bin/arm-linux-gnueabihf-g++)
#here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /home/tronlong/ti-processor-sdk-linux-am437x-evm-01.00.00.03/linux-devkit/sysroots/cortexa9t2hf-vfp-neon-linux-gnueabi/usr/lib)
#adjust the default behaviour of the FIND_XXX() commands:
#search headers and libraries in the target environment, search
#programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
如使用V03.03.00.04版本LinuxProcessor-SDK,请写入如下内容:
# the name of the target operating system
SET(CMAKE_SYSTEM_NAME Linux)
# which C and C++ compiler to use
SET(CMAKE_C_COMPILER/home/tronlong/ti-processor-sdk-linux-am437x-evm-03.03.00.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-gcc)
SET(CMAKE_CXX_COMPILER /home/tronlong/ti-processor-sdk-linux-am437x-evm-03.03.00.04/linux-devkit/sysroots/x86_64-arago-linux/usr/bin/arm-linux-gnueabihf-g++)
#here is the target environment located
SET(CMAKE_FIND_ROOT_PATH /home/tronlong/ti-processor-sdk-linux-am437x-evm-03.03.00.04/linux-devkit/sysroots/armv7ahf-neon-linux-gnueabi/usr/lib)
#adjust the default behaviour of the FIND_XXX() commands:
#search headers and libraries in the target environment, search
#programs in the host environment
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH)
红色内容请修改为对应平台LinuxProcessor-SDK安装包实际的交叉编译工具链和系统库文件路径。从文档拷贝上述内容时,指令可能会出现换行现象,拷贝时请仔细核对。
执行如下命令安装编译插件:
Host# sudo apt-get install cmake
在build目录下执行如下命令进行配置并生成makefile:
Host# cmake -DWITH_OPENCL=OFF -DWITH_OPENMP=OFF-DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DCMAKE_INSTALL_PREFIX=/home/tronlong/AM437x/opencv-2.4.11-DCMAKE_TOOLCHAIN_FILE=arm-linux-gnueabihf.cmake ..
执行make指令,编译适用于AM437x平台的OpenCV库文件,结果如下图所示:
Host# make
执行如下指令将OpenCV库文件安装到”opencv-2.4.11/lib”目录中。
Host# make install
安装完成后如下图所示:
更多回帖