toradex arm imx6 opencv-3.4.0编译移植测试

核心板采用toradex imx6, 内核:Linux version 3.14.52

host linux编译器: gcc-7.2.1,来自https://www.linaro.org/downloads/


1.ffmpeg相关

(1).编译x264

(2).编译xvidcore

(3).编译ffmpeg


2.编译opencv,cmake文件:

set(MY_TOOLCHAIN_PATH"/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf")

 

set(ENV{PKG_CONFIG_PATH}    ${MY_TOOLCHAIN_PATH}/lib/pkgconfig)

set(ENV{LD_LIBRARY_PATH}    ${MY_TOOLCHAIN_PATH}/lib)

set(ENV{C_INCLUDE_PATH}     ${MY_TOOLCHAIN_PATH}/include)

set(ENV{CPLUS_INCLUDE_PATH}${MY_TOOLCHAIN_PATH}/include)

 

set(CMAKE_SYSTEM_NAME      Linux )

set(CMAKE_SYSTEM_PROCESSOR arm )

set(CMAKE_C_COMPILER      arm-linux-gnueabihf-gcc )

set( CMAKE_CXX_COMPILER     arm-linux-gnueabihf-g++ )

set(CMAKE_FIND_ROOT_PATH  ${MY_TOOLCHAIN_PATH} )

set(ARM_LINUX_SYSROOT     ${MY_TOOLCHAIN_PATH} CACHE PATH "ARM cross compilation systemroot")

 

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER )

set( CMAKE_FIND_ROOT_PATH_MODE_LIBRARYONLY )

set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY )

 

 

set(CMAKE_CXX_FLAGS           ""                    CACHE STRING "c++flags")

set(CMAKE_C_FLAGS             ""                    CACHE STRING "cflags")

set(CMAKE_SHARED_LINKER_FLAGS""                    CACHESTRING "shared linker flags")

set(CMAKE_MODULE_LINKER_FLAGS""                    CACHESTRING "module linker flags")

set(CMAKE_EXE_LINKER_FLAGS    "-Wl,-z,nocopyreloc"  CACHE STRING "executable linkerflags")

 

set(MY_FLAGS1" -I${MY_TOOLCHAIN_PATH}/include -L${MY_TOOLCHAIN_PATH}/lib ")

set(MY_FLAGS2" -lxvidcore -lx264 -lswscale -lswresample -lavformat ")

set(MY_FLAGS3" -lavutil -lavcodec -lavdevice -lavfilter -lpostproc ")

 

set(CMAKE_CXX_FLAGS"${CMAKE_CXX_FLAGS}  ${MY_FLAGS1}${MY_FLAGS2} ${MY_FLAGS3}")

set(CMAKE_C_FLAGS   "${CMAKE_C_FLAGS}    ${MY_FLAGS1} ${MY_FLAGS2}${MY_FLAGS3}")



cmake指令:

cmake-DCMAKE_TOOLCHAIN_FILE=../toolchain.make \

    -DCMAKE_BUILD_TYPE=Release \

    -DCMAKE_INSTALL_PREFIX=./install \

    -DBUILD_PNG=ON \

    -DBUILD_TIFF=ON \

    -DBUILD_TBB=ON \

    -DBUILD_JPEG=ON \

    -DBUILD_JASPER=ON \

    -DBUILD_ZLIB=ON \

    -DBUILD_opencv_java=OFF \

    -DBUILD_opencv_python=OFF \

    -DBUILD_opencv_python2=OFF \

    -DBUILD_opencv_python3=OFF \

    -DBUILD_TESTS=OFF \

    -DBUILD_PERF_TESTS=OFF \

    -DBUILD_EXAMPLES=OFF \

    -DWITH_GSTREAMER=OFF \

    -DINSTALL_TESTS=OFF \

    -DBUILD_opencv_nonfree=ON \

    -DWITH_GTK=OFF \

    -DWITH_OPENCL=ON \

    -DWITH_OPENMP=ON \

    -DWITH_FFMPEG=ON \

    -DWITH_IPP=ON \

    -DWITH_CUDA=OFF \

    -DWITH_VTK=OFF \

    -DWITH_TBB=OFF \

    -DWITH_1394=OFF \

    -DWITH_OPENEXR=OFF \

    -DINSTALL_C_EXAMPLES=OFF \

    -DOPENCV_TEST_DATA_PATH=/home/wyt/toradex/opencv-3.3.1/opencv_extra-3.3.1/testdata\

   -DOPENCV_EXTRA_MODULES_PATH=/home/wyt/toradex/opencv-3.3.1/opencv_contrib-3.3.1/modules\

    ../


期间会下载很多东东,需要科学上网(fan-qiang),可以联系我qq80101277, youtube 25M不限速不限流量,每月5元


3.host linux设置:

CROSS_COMPILE=arm-none-linux-gnueabi-

exportPKG_CONFIG_PATH=/opt/gcc-linaro-7.2.1-2017.11-x86_64_arm-linux-gnueabihf/lib/pkgconfig:$PKG_CONFIG_PATH

exportPKG_CONFIG_PATH=/home/wyt/toradex/opencv-3.3.1/build/install/lib/pkgconfig:$PKG_CONFIG_PATH


4.target linux

根据需要拷贝toolchain的libstdc++.so.6.0.24


5.ffmpeg测试:

ffmpeg -irtsp://admin:[email protected]:554/h264/1/main/av_stream -vcodec copy./out.avi


6.opencv arm端测试

读取rtsp码流,1280x720分辨率,实测动目标检测470ms每帧,后期优化tbb和ipp应该可以更高




你可能感兴趣的:(arm开发)