opencv自定义平台编译

  • Post author:
  • Post category:其他




1 交叉编译环境设置

以s32v234的QVSDK环境配置为例:

首先指定交叉编译器的环境变量,对于QNX,如下:

export QNX_TARGET=“path/to/your/qnx/installation/target/qnx7”

export QNX_HOST=“path/to/your/qnx/installation/host/linux/x86_64”

export PATH=“path/to/your/qnx/installation/host/linux/x86_64/usr/bin:$PATH”

一个可能的实现:

test "$BASH_SOURCE" = "" && echo "This script only can be run from bash" && return
SCRIPT_SOURCE=$BASH_SOURCE
test "$SCRIPT_SOURCE" = "$0" && echo "Script is being run, should be sourced" && exit 1

HOST_OS=$(uname -s)
SCRIPT_DIR=$(dirname "${SCRIPT_SOURCE}")
QNX_BASE=$(cd "${SCRIPT_DIR}"; pwd)

# ARM Compiler
PATH=$PATH:$QNX_BASE/gcc-arm-none-eabi-7-2017-q4-major:$QNX_BASE/gcc-arm-none-eabi-7-2017-q4-major/bin

# APU Compiler
export APU_TOOLS=$QNX_BASE/APU_Compiler_v1.0

# QNX Compiler
QNX_HOST=$QNX_BASE/qnx-host
QNX_TARGET=$QNX_BASE/qnx-target

QNX_CONFIGURATION=$HOME/.qnx
MAKEFLAGS=-I$QNX_TARGET/usr/include
PATH=$PATH:$QNX_HOST/usr/bin:$QNX_CONFIGURATION/bin:$QNX_BASE/jre/bin:$PATH

export QNX_TARGET QNX_HOST QNX_CONFIGURATION MAKEFLAGS PATH
unset PYTHONPATH

SDK_ROOT=$QNX_BASE/s32v234_sdk
export SDK_ROOT

echo QNX_HOST=$QNX_HOST
echo QNX_TARGET=$QNX_TARGET
echo MAKEFLAGS=$MAKEFLAGS



2 opencv编译选项设置

主要是设定需要对哪些模块进行编译,如下:

##############################################################################
#
#  NXP, Inc.
#  (c) Copyright 2017, NXP.
#  ALL RIGHTS RESERVED.
#
##############################################################################
#
#  CONTENT
#    Generator of OpenCV makefiles for QNX ARM cross-compilation
#
#  AUTHOR
#    Teodor Madan
#
#  DATE
#    2017-5-11
#
#  LANGUAGE
#    bash script
#
##############################################################################

#!/bin/sh

SDK_ROOT=$PWD/../../../../s32v234_sdk
OCV_ROOT=$SDK_ROOT/../opencv_src

export PKG_CONFIG_PATH=$SDK_ROOT/3rdparty/ffmpeg/qnx-arm64/lib/pkgconfig/
DEFAULT_TOOLCHAIN="/build/cmake/toolchains/aarch64-qnx-qcc.cmake"
TOOLCHAIN=$SDK_ROOT$DEFAULT_TOOLCHAIN

if [ $# -gt 0 ]
  then
  TOOLCHAIN=$1
fi

echo "Toolchain file path to be used:"
echo $TOOLCHAIN

cmake  \
  -G "Unix Makefiles" \
  -D CMAKE_INSTALL_PREFIX=$SDK_ROOT/3rdparty/ocv/qnx-arm64					\
  -D CMAKE_TOOLCHAIN_FILE=$TOOLCHAIN								\
  -D FFMPEG_LIB_DIR=$SDK_ROOT/3rdparty/ffmpeg/qnx-arm64/lib					\
  -D FFMPEG_INCLUDE_DIR=$SDK_ROOT/3rdparty/ffmpeg/qnx-arm64/include				\
  -D WITH_PYTHON=OFF 										\
  -D WITH_NEON=OFF 										\
  -D ENABLE_NEON=ON \
  -D BUILD_PERF_TESTS=OFF 									\
  -D BUILD_TESTS=OFF 										\
  -D BUILD_opencv_apps=OFF 									\
  -D CMAKE_BUILD_TYPE=RELEASE 									\
  -D BUILD_SHARED_LIBS=ON 									\
  -D WITH_TIFF=OFF                                   \
  -D WITH_PNG=ON                                   \
  -D WITH_1394=OFF                        \
  -D WITH_AVFOUNDATION=OFF                        \
  -D WITH_CARBON=OFF                        \
  -D WITH_VTK=OFF                       \
  -D WITH_CUDA=OFF                        \
  -D WITH_CUFFT=OFF                       \
  -D WITH_CUBLAS=OFF                        \
  -D WITH_NVCUVID=OFF                       \
  -D WITH_EIGEN=OFF                       \
  -D WITH_VFW=OFF                       \
  -D WITH_FFMPEG=OFF                        \
  -D WITH_GSTREAMER=OFF                       \
  -D WITH_GSTREAMER_0_10=OFF                        \
  -D WITH_GTK=OFF                       \
  -D WITH_GTK_2_X=OFF                       \
  -D WITH_IPP=OFF                       \
  -D WITH_JASPER=OFF                        \
  -D WITH_JPEG=ON                        \
  -D WITH_WEBP=OFF                        \
  -D WITH_OPENEXR=OFF                       \
  -D WITH_OPENGL=OFF                        \
  -D WITH_OPENNI=OFF                        \
  -D WITH_OPENNI2=OFF                       \
  -D WITH_PVAPI=OFF                       \
  -D WITH_GIGEAPI=OFF                       \
  -D WITH_QT=OFF                        \
  -D WITH_WIN32UI=OFF                       \
  -D WITH_QUICKTIME=OFF                       \
  -D WITH_TBB=OFF                       \
  -D WITH_OPENMP=OFF                        \
  -D WITH_CSTRIPES=OFF                        \
  -D WITH_PTHREADS_PF=OFF                       \
  -D WITH_UNICAP=OFF                        \
  -D WITH_V4L=OFF                       \
  -D WITH_LIBV4L=OFF                        \
  -D WITH_DSHOW=OFF                       \
  -D WITH_MSMF=OFF                        \
  -D WITH_XIMEA=OFF                       \
  -D WITH_XINE=OFF                        \
  -D WITH_CLP=OFF                       \
  -D WITH_OPENCL=OFF                        \
  -D WITH_OPENCL_SVM=OFF                        \
  -D WITH_OPENCLAMDFFT=OFF                        \
  -D WITH_OPENCLAMDBLAS=OFF                       \
  -D WITH_DIRECTX=OFF                       \
  -D WITH_INTELPERC=OFF                       \
  -D WITH_IPP_A=OFF                       \
  -D WITH_MATLAB=OFF                        \
  -D WITH_VA=OFF                        \
  -D WITH_VA_INTEL=OFF                        \
  -D WITH_GDAL=OFF                        \
  -D WITH_GPHOTO2=OFF                       \
   $OCV_ROOT

echo "Generating done, building....."

make install -j9

# change library filenames to hardlinks with no version number and remove any symbolic links
#bash ./sym2hard.sh ../linux-arm64/lib d



版权声明:本文为lgmmgl原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。