ubuntu(银河麒麟、中标麒麟,优麒麟)安装opencv 遇到问题解决方法
问题:E:could not find OpenJPEG
解决方法:
下载 OpenJPEG:http://www.linuxfromscratch.org/blfs/view/svn/general/openjpeg2.html
mkdir -v build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DBUILD_STATIC_LIBS=OFF ..
make
sudo make install
问题:file cannot create directory: /usr/local/ Maybe need administrative privileges.
解决方法:
http://archive.ubuntu.com/ubuntu/pool/universe/g
这个必须先升级g++,升级的命令如下:
sudo aptju install gcc-c++
sudo apt install ncurses-devel
问题:No package 'gtk+-3.0' found
解决方法:
1、安装gcc/g++/gdb/make等基本编程工具:sudo apt-get install build-essential
2、安装GTK+3.0:sudo apt-get install libgtk-3-dev
3、安装pkg-config:sudo apt-get install pkg-config
问题:E: Unable to locate package libjasper-dev
解决方法:
https://blog.csdn.net/weixin_41053564/article/details/81254410
sudo add-apt-repository "deb http://security.ubuntu.com/ubuntu xenial-security main"
sudo apt update
sudo apt install libjasper1 libjasper-dev
成功的解决了问题,其中libjasper1是libjasper-dev的依赖包
问题:looking for ccache --not found
解决方法:
sudo apt-get install ccache
问题: No package 'gstreamer-base-1.0' found
解决方法:
https://stackoverflow.com/questions/37678324/compiling-opencv-with-gstreamer-cmake-not-finding-gstreamer
sudo apt install libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev
问题: No package 'libavresample' found
解决方法:
sudo apt-get install libavresample-dev
问题: No package 'libgphoto2' found
解决方法:
sudo apt-get install libgphoto2-dev
问题: ant no
解决方法:
没有ant的话opencv编译安装的时候,是不会打包成jar的
1、下载ANT
http://ant.apache.org/
2. 解压下载下来的.tar.gz文件: tar -xf apache-ant-1.9.15-bin.tar.gz (可能会要求输入密码)
3.将解压出来的文件移动到/opt/下:sudo mv apache-ant-1.9.15 /opt/ (sudo 不能省,否则没有权限)
4、安装 ant 依赖库
ant -f fetch.xml -Ddest=system
5.配置环境变量:sudo vim /etc/profile,在原来基础上添加以下蓝体字:
export ANT_HOME=/opt/apache-ant-1.9.15
export PATH=$JAVA_HOME/bin:$ANT_HOME/bin:$PATH
6、使其生效 source /etc/profile
7、验证是否安装成功: ant -version
8、另外一种设置环境变量的内容
export LANG=C
#BootStrap-JDK的安装路径,替换为自己bootstrap-JDK的路径
export ALT_BOOTDIR=/usr/lib/jvm/java-14-openjdk-amd64
#同上,我之前使用的是openjdk编译的,后面运行hotspot时出现问题替换为oracleJDK,读者可以直接替换为OracleJDK
export ALT_JDK_IMPORT_PATH=/usr/lib/jvm/java-14-openjdk-amd64
#要编译的内容,读者可以根据需要自行选择
export BUILD_LANGTOOLS=true
#export BUILD_JAXWS=false
#export BUILD_JAXP=false
#export BUILD_CORBA=false
export BUILD_HOTSPOT=true
export BUILD_JDK=true
export SKIP_COMPARE_IMAGES=true
BUILD_DEPLOY=false
BUILD_INSTALL=false
#编译结果存放的路径,建议存放在openjdk源码中build文件夹
export ALT_OUTPUTDIR=/usr/dev/jvm/openjdk/build
export ALLOW_DOWNLOADS=true
#这两个环境变量需要去掉,不然会出问题
unset JAVA_HOME
unset CLASSPATH
问题: IPPICV: Download failed: 7;"Couldn't connect to server"
解决方法:
1、手动下载 ippicv_linux_20151201.tgz(https://raw.githubusercontent.com/Itseez/opencv_3rdparty/81a676001ca8075ada498583e4166079e5744668/ippicv/ippicv_linux_20151201.tgz)到opencv-3.2.0/3rdparty/ippicv/downloads/目录下再cmake
2、编辑 /home/lc/opencv_source/opencv/3rdparty/ippicv/ippicv.cmake #记得lc换成自己的用户名
将47行的
"https://raw.githubusercontent.com/opencv/opencv_3rdparty/${IPPICV_COMMIT}/ippicv/"
改为步骤1中手动下载的文件的本地路径:
"file:///home/lc/下载/" #(仅供参考,根据自己的路径填写)
编辑完成保存退出
3,重新cmake
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
到了下载ippicv那一步时会自动从本地下载
问题: IPnect to server"
解决方法:
问题:/bin/ant: 1: cd: can't cd to /bin/../share/ant/bin/..
错误: 找不到或无法加载主类 org.apache.tools.ant.launch.Launcher
解决方法:
实际上这个路径根本不存在。
1、cd /usr/bin
2、whereis ant
ant: /usr/bin/ant /usr/share/ant /usr/share/man/man1/ant.1.gz
检查/usr/bin/ant链接
3、 ll /usr/bin/ant
lrwxrwxrwx 1 root root 20 8月 27 2018 /usr/bin/ant -> ../share/ant/bin/ant
显然是链接错误。这个时候重新链接即可:
4、ln -snf /usr/share/ant/bin/ant /bin/ant
问题:
--Could not find OpenBLAS include. Turning OpenBLAS_FOUND off
-- Could not find OpenBLAS lib. Turning OpenBLAS_FOUND off
-- Could NOT find Atlas (missing: Atlas_CBLAS_INCLUDE_DIR Atlas_CLAPACK_INCLUDE_DIR Atlas_CBLAS_LIBRARY Atlas_BLAS_LIBRARY Atlas_LAPACK_LIBRARY)
-- A library with BLAS API not found. Please specify library location.
-- LAPACK requires BLAS
-- A library with LAPACK API not found. Please specify library location.
-- Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY JAVA_INCLUDE_PATH JAVA_INCLUDE_PATH2 JAVA_AWT_INCLUDE_PATH)
-- Could NOT find Matlab (missing: MATLAB_MEX_SCRIPT MATLAB_INCLUDE_DIRS MATLAB_ROOT_DIR MATLAB_LIBRARIES MATLAB_LIBRARY_DIRS MATLAB_MEXEXT MATLAB_ARCH MATLAB_BIN)
-- VTK is not found. Please set -DVTK_DIR in CMake to VTK build directory, or to VTK install subdirectory with VTKConfig.cmake file
CMake Error at cmake/OpenCVModule.cmake:288 (message):
No modules has been found:
/home/program/opencv-3.4.2/opencv_contrib-3.4.0/modules
Call Stack (most recent call first):
cmake/OpenCVModule.cmake:368 (_glob_locations)
modules/CMakeLists.txt:7 (ocv_glob_modules)
解决方法:
sudo apt-get install libopenblas-dev
sudo apt-get upgrade libopenblas-dev
配置openjdk
1、修改/etc/profile文件
sudo vim /etc/profile
2、在尾部新增以下内容:
export JAVA_HOME=/usr/lib/jvm/java-14-openjdk-amd64
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
export PATH=${JAVA_HOME}/bin:$PATH
3、执行命令source /etc/profile,使配置生效;
4、安装完毕,执行命令java -version验证,信息如下:
root@docker:~# java -version
openjdk version "14-ea" 2020-03-17
OpenJDK Runtime Environment (build 14-ea+18)
OpenJDK 64-Bit Server VM (build 14+44, mixed mode)
OpenBLAS在Ubuntu系统上的安装部署步骤
下载 OpenBLAS
cd OpenBLAS
sudo apt-get install gfortran
sudo make FC=gfortran
sudo make install
Altas在Ubuntu系统上的安装部署步骤
https://blog.51cto.com/webseven/1746368
1、下载 https://github.com/Qihoo360/Atlas/releases/download/2.2/Atlas-2.2-debian7.0-x86_64.deb
2、安装 dpkg --instdir=/srv/Altas-2.2 -i Atlas-2.2-debian7.0-x86_64.deb
sudo gdebi Atlas-2.2-debian7.0-x86_64.deb
VTK在Ubuntu系统上的安装部署步骤
1、下载 https://vtk.org/download/
2、安装ccmake 和 VTK 的依赖项:
sudo apt-get install cmake-curses-gui
sudo apt-get install freeglut3-dev
3、用ccmake配置参数
解压文件,进入文件夹,在解压目录下新建build, 在其中使用ccmake配置参数 。
mkdir build
cd build
ccmake ..
主要配置选项:
# 按照VTK tutorial要求,每设置完一项均按'c'进行一次configuration,直到所有项目设置完,
BUILD_SHARED_LIBS = ON
BUILD_TESTING = ON # 默认OFF,如果打开的话,编译时会由于下载测试数据所用url过旧而报错,建议OFF
CMAKE_BUILD_TYPE = Release # 默认Debug运行会较慢
CMAKE_INSTALL_PREFIX = /usr/local # 这里用默认就行,或者改到想要安装的位置
# 以下为高级设置,需先在命令行按't'才可见
VTK_FORBID_DOWNLOADS = ON # 默认OFF,建议打开,否则编译会报错,理由同BUILD_TESTING
# 此时应已经出现'g' generating 的按键选项,按 'g' 即完成配置.
4、安装VTK:(会需要挺长时间)
cmake .
make
sudo make install
5、重装OpenCV:(不需要删掉原有的 /build 文件夹)
cd /...Path to OpenCV build.../build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local –D WITH_VTK=ON -D ENABLE_CXX11=YES ..
# make 时可能会出现一些C++版本的warning,不影响结果
make
sudo make install
http://www.linuxfromscratch.org/blfs/view/cvs/general/opencv.html
https://blog.csdn.net/qq_34106574/article/details/81668193
https://www.cnblogs.com/fx-blog/p/8213704.html
fatal error:boostdesc_bgm.i:没有那个文件或目录
https://blog.csdn.net/u011736771/article/details/85960300
下载后,直接拷贝源码并生存同名文件,放在 opencv_contrib/modules/xfeatures2d/src/ 路径下即可。
https://blog.csdn.net/qq_15737599/article/details/90200152
问题:
-- Checking for module 'gstreamer-base-1.0'
-- No package 'gstreamer-base-1.0' found
-- Checking for module 'gstreamer-video-1.0'
-- No package 'gstreamer-video-1.0' found
-- Checking for module 'gstreamer-app-1.0'
-- No package 'gstreamer-app-1.0' found
-- Checking for module 'gstreamer-riff-1.0'
-- No package 'gstreamer-riff-1.0' found
-- Checking for module 'gstreamer-pbutils-1.0'
-- No package 'gstreamer-pbutils-1.0' found
解决方法:
sudo apt-get -y install libgstreamer-plugins-base1.0-dev
sudo apt-get -y install libgstreamer1.0-dev
问题:
-- No package 'libavresample' found
-- No package 'libgphoto2' found
解决方法:
sudo apt-get -y install libavresample-dev
sudo apt-get -y install libgphoto2-dev
问题:
-- no package libdc1394-2 found
解决方法:
libdc1394-22 libdc1394-22-dev
问题:atal error: features2d/test/test_detectors_regression.impl.hpptest_invariance_utils.hpp
解决方法:
1、进入opencv源码目录~/opencv/modules/features2d/test/,拷贝test_detectors_regression.impl.hpp 及 test_descriptors_regression.impl.hpp 到 ~/opencv_contrib/modules/xfeatures2d/test/下
2、编辑 test_features2d.cpp ,修改include文件地址
// #include "features2d/test/test_detectors_regression.impl.hpp"
// #include "features2d/test/test_descriptors_regression.impl.hpp"
// 修改文件地址如下
#include "test_detectors_regression.impl.hpp"
#include "test_descriptors_regression.impl.hpp"
#include "test_invariance_utils.hpp"
然后修改test_rotation_and_scale_invariance.cpp文件
// #include "features2d/test/test_detectors_invariance.impl.hpp" // main OpenCV repo
// #include "features2d/test/test_descriptors_invariance.impl.hpp" // main OpenCV repo
#include "test_detectors_invariance.impl.hpp" // main OpenCV repo
#include "test_descriptors_invariance.impl.hpp" // main OpenCV repo
问题:
-- Could NOT find Doxygen (missing: DOXYGEN_EXECUTABLE)
解决方法:
sudo apt-get install doxygen
问题:
fatal error: linux/videodev.h: No such file or directory
fatal error: sys/videoio.h: No such file or directory
解决方法:
sudo ln -s /usr/include/libv4l1-videodev.h /usr/include/linux/videodev.
sudo cp /usr/include/opencv2/videoio/videoio_c.h /usr/include/x86_64-linux-gnu/sys
sudo ln -s /usr/include/x86_64-linux-gnu/sys/videoio_c.h /usr/include/x86_64-linux-gnu/sys/videoio.h
/usr/include/目录下创建sys目录,然后touch文件 videoio.h
如果仍然没有成功,那么找到含有"videodev.h"和"videoio.h"头文件的源文件,
将#include <> 改为#include ""
问题:Generate files for Java bindings Traceback (most recent call last):
解决方法:
将opencv-4.4.1/modules/java/generator/gen_java.py源文件中的31行:
assert path[-3:] != '.in', path
修改为:
assert path[-4:] != '.in', path
问题: IPnect to server"
解决方法:
问题: IPnect to server"
解决方法:
问题: IPnect to server"
解决方法:
问题: