之前在3399pro开发板上编译了opencv4.5.1的源码,将编译后的文件导出,在新的开发板上进行移植安装,本文记录了移植安装过程中出现的问题及解决方法。 (2021.05.18更新)
1、环境配置
在移植安装之前配置新板子的开发环境,参考博客
https://blog.csdn.net/sinat_37322535/article/details/113972933?spm=1001.2014.3001.5501
2、移植安装
进入到opencv的build 目录下进行安装
cd ./build
make install
正常情况下会安装成功,但我这边报了4个错;
错误1:
No rule to make target '/lib/libjpeg.so', needed by 'lib/libopencv_imgcodecs.so.4.5.1'.
解决办法:
whereis libjpeg.so #找到libjpeg.so位置,我的是在/usr/lib/libjpeg.so
sudo ln -s /usr/lib/libjpeg.so /lib/
继续make install
错误2:
modules/videoio/CMakeFiles/opencv_videoio.dir/src/cap_gstreamer.cpp.o]
解决办法:
sudo aptitude install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
2021.05.18新增2个问题,在此记录一下
问题3:
/home/syl/software/opencv/modules/python/src2/cv2.cpp:17:10: fatal error: Python.h: No such file or directory
#include
解决方法:
sudo apt-get install python-dev
sudo apt-get install python3.7-dev
问题4:
/home/syl/software/opencv/modules/python/src2/cv2.cpp:33:10: fatal error: numpy/ndarrayobject.h: No such file or directory
#include
解决方法:
sudo apt-get install python-numpy
接着make install
安装成功!
3、测试
安装完成后测试python-opencv播放摄像头正常,但通过c+±opencv播放摄像头报错如下:
错误一:
#执行命令
g++ main.cpp -o c++-opencv `pkg-config --cflags --libs opencv`
报错:
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
解决方法:
cd /usr/local/lib/pkgconfig
sudo touch opencv.pc #拷贝同目录下opencv4.pc的内容
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
错误二:
执行命令:./c++-opencv
报错:
main.cpp:2:10: fatal error: opencv2/opencv.hpp: No such file or directory
#include
解决方法:
1、whereis libopencv_gapi.so.4.5
# libopencv_gapi.so.4: /usr/local/lib/libopencv_gapi.so.4.5
2、vim /etc/ld.so.conf.d/opencv.conf
写入/usr/local/lib/lib后保存
3、ldconfig