IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 人工智能 -> 嵌入式开发板 aarch64 opencv库 交叉编译 -> 正文阅读

[人工智能]嵌入式开发板 aarch64 opencv库 交叉编译

在x86的ubuntu系统上为嵌入式开发板交叉编译opencv库
源码目录:/home/xxx/opencv-3.4.6

  • 操作步骤一

创建文件,写入交叉编译工具链信息
/home/xxx/opencv-3.4.6/arm_toochain.cmake

set(CMAKE_SYSTEM_NAME linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(tools /home/xxxxx/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux)
set(CMAKE_C_COMPILER ${tools}/bin/aarch64-xxxxx-linux-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-xxxxx-linux-g++)
set(CMAKE_FIND_ROOT_PATH /home/xxxxx/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/lib)
  • 操作步骤二

cmake命令

cd /home/xxx/opencv-3.4.6/
mkdir build
mkdir build_install
cd build
cmake \
-DCMAKE_TOOLCHAIN_FILE=../arm_linux_setup.cmake \
-DCMAKE_INSTALL_PREFIX=/home/xxx/opencv-3.4.6/build_install \
-DBUILD_ZLIB=ON \
-DBUILD_opencv_python2=OFF \
-DBUILD_opencv_python3=OFF ..
  • 操作步骤三
make -j4
make install

出现错误解决办法
错误1

[ 45%] Linking CXX executable ../../bin/opencv_version
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_mutexattr_destroy'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_key_create'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `dladdr'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_getspecific'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `dlopen'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_mutex_trylock'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_key_delete'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `dlclose'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `dlsym'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_mutexattr_settype'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_setspecific'
/home/liujt/Documents/Disk2/Program/aarch64-xxxxx-linux/install/aarch64-xxxxx-linux/host_bin/../lib/gcc/aarch64-linux-gnu/7.3.0/../../../../aarch64-linux-gnu/bin/ld: ../../lib/libopencv_core.so: undefined reference to `pthread_mutexattr_init'
collect2: error: ld returned 1 exit status
apps/version/CMakeFiles/opencv_version.dir/build.make:95: recipe for target 'bin/opencv_version' failed
make[2]: *** [bin/opencv_version] Error 1
CMakeFiles/Makefile2:4699: recipe for target 'apps/version/CMakeFiles/opencv_version.dir/all' failed
make[1]: *** [apps/version/CMakeFiles/opencv_version.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

解决办法

在/home/xxx/opencv-3.4.6/CMakeLists.txt 文件中加入flags信息
include(cmake/OpenCVMinDepVersions.cmake)

SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-pthread -ldl")  # 添加入这一行
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-pthread -ldl")  # 添加入这一行

if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)

错误2

[ 55%] Building CXX object modules/video/CMakeFiles/opencv_video.dir/src/tvl1flow.cpp.obj
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp: In member function 'virtual bool cv::JpegDecoder::readHeader()':
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:224:58: error: invalid conversion from 'uchar* {aka unsigned char*}' to 'const JOCTET* {aka const char*}' [-fpermissive]
             state->source.pub.next_input_byte = m_buf.ptr();
                                                 ~~~~~~~~~^~
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp: In member function 'virtual bool cv::JpegDecoder::readData(cv::Mat&)':
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:456:56: error: invalid conversion from 'JSAMPROW {aka char*}' to 'const uchar* {aka const unsigned char*}' [-fpermissive]
                         icvCvt_RGB2BGR_8u_C3R( buffer[0], 0, data, 0, cvSize(m_width,1) );
                                                ~~~~~~~~^
In file included from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_base.hpp:46:0,
                 from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.hpp:46,
                 from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:43:
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/utils.hpp:93:6: note:   initializing argument 1 of 'void cv::icvCvt_BGR2RGB_8u_C3R(const uchar*, int, uchar*, int, cv::Size)'
 void icvCvt_BGR2RGB_8u_C3R( const uchar* bgr, int bgr_step,
      ^~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:458:59: error: invalid conversion from 'JSAMPROW {aka char*}' to 'const uchar* {aka const unsigned char*}' [-fpermissive]
                         icvCvt_CMYK2BGR_8u_C4C3R( buffer[0], 0, data, 0, cvSize(m_width,1) );
                                                   ~~~~~~~~^
In file included from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_base.hpp:46:0,
                 from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.hpp:46,
                 from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:43:
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/utils.hpp:116:6: note:   initializing argument 1 of 'void cv::icvCvt_CMYK2BGR_8u_C4C3R(const uchar*, int, uchar*, int, cv::Size)'
 void icvCvt_CMYK2BGR_8u_C4C3R( const uchar* cmyk, int cmyk_step,
      ^~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:465:60: error: invalid conversion from 'JSAMPROW {aka char*}' to 'const uchar* {aka const unsigned char*}' [-fpermissive]
                         icvCvt_CMYK2Gray_8u_C4C1R( buffer[0], 0, data, 0, cvSize(m_width,1) );
                                                    ~~~~~~~~^
In file included from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_base.hpp:46:0,
                 from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.hpp:46,
                 from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:43:
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/utils.hpp:118:6: note:   initializing argument 1 of 'void cv::icvCvt_CMYK2Gray_8u_C4C1R(const uchar*, int, uchar*, int, cv::Size)'
 void icvCvt_CMYK2Gray_8u_C4C1R( const uchar* ycck, int ycck_step,
      ^~~~~~~~~~~~~~~~~~~~~~~~~
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp: In function 'boolean cv::empty_output_buffer(j_compress_ptr)':
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:512:34: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<unsigned char> >::value_type* {aka unsigned char*}' to 'JOCTET* {aka char*}' [-fpermissive]
     dest->pub.next_output_byte = &(*dest->buf)[0];
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp: In member function 'virtual bool cv::JpegEncoder::write(const cv::Mat&, const std::vector<int>&)':
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:584:37: error: invalid conversion from '__gnu_cxx::__alloc_traits<std::allocator<unsigned char> >::value_type* {aka unsigned char*}' to 'JOCTET* {aka char*}' [-fpermissive]
         dest.pub.next_output_byte = &out_buf[0];
/home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:701:43: error: invalid conversion from 'uchar** {aka unsigned char**}' to 'JSAMPARRAY {aka char**}' [-fpermissive]
             jpeg_write_scanlines( &cinfo, &ptr, 1 );
                                           ^~~~
In file included from /home/xxxxx/opencv-3.4.6/modules/imgcodecs/src/grfmt_jpeg.cpp:75:0:
/home/xxxxx/opencv-3.4.6/3rdparty/libjpeg-turbo/src/jpeglib.h:953:20: note:   initializing argument 2 of 'JDIMENSION jpeg_write_scanlines(j_compress_ptr, JSAMPARRAY, JDIMENSION)'
 EXTERN(JDIMENSION) jpeg_write_scanlines(j_compress_ptr cinfo,
                    ^~~~~~~~~~~~~~~~~~~~
modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/build.make:254: recipe for target 'modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_jpeg.cpp.obj' failed
make[2]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/src/grfmt_jpeg.cpp.obj] Error 1
CMakeFiles/Makefile2:2810: recipe for target 'modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all' failed
make[1]: *** [modules/imgcodecs/CMakeFiles/opencv_imgcodecs.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

解决办法

在/home/xxx/opencv-3.4.6/CMakeLists.txt 文件中增加flags信息
include(cmake/OpenCVMinDepVersions.cmake)

SET(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} "-pthread -ldl -fpermissive")  # 这一行添加-fpermissive
SET(CMAKE_C_FLAGS ${CMAKE_C_FLAGS} "-pthread -ldl") 

if(CMAKE_GENERATOR MATCHES Xcode AND XCODE_VERSION VERSION_GREATER 4.3)
  人工智能 最新文章
2022吴恩达机器学习课程——第二课(神经网
第十五章 规则学习
FixMatch: Simplifying Semi-Supervised Le
数据挖掘Java——Kmeans算法的实现
大脑皮层的分割方法
【翻译】GPT-3是如何工作的
论文笔记:TEACHTEXT: CrossModal Generaliz
python从零学(六)
详解Python 3.x 导入(import)
【答读者问27】backtrader不支持最新版本的
上一篇文章      下一篇文章      查看所有文章
加:2022-04-27 11:19:34  更:2022-04-27 11:21:42 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/26 8:41:40-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码