Jetson tx2 nano nx xavier 安装opencv4.1.1和OpenCV_contirb-4.1.1

学习内容:

JETSON TX2安装opencv4.1.1和OpenCV_contirb-4.1.1

学习时间:

随机

学习产出:

我是下载的网络上的现成的包链接:https://pan.baidu.com/s/1UPIq3weRPdA8zQnqzoNnEQ
提取码:2021
学习目标:

sudo apt-get purge libopencv*
sudo apt autoremove
sudo ap-get update

sudo apt-get install build-essential
sudo apt-get install libglew-dev libtiff5-dev zlib1g-dev libjpeg-dev libavcodec-dev libavformat-dev libavutil-dev libpostproc-dev libswscale-dev libeigen3-dev libtbb-dev libgtk2.0-dev pkg-config libpng-dev

sudo apt-get install libatlas-base-dev gfortran

将源码下载完毕后,将OpenCV-4.1.1和OpenCV_contirb-4.1.1解压后放置在同一主目录opencv4下。
cd opencv-4.1.1
mkdir build
cd build

sudo cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_PNG=OFF -DBUILD_TIFF=OFF -DBUILD_TBB=OFF -DBUILD_JPEG=OFF -DBUILD_JASPER=OFF -DBUILD_ZLIB=OFF -DOPENCV_GENERATE_PKGCONFIG=ON -DCMAKE_INSTALL_PREFIX=/usr/local -DBUILD_TBB=OFF -DBUILD_JPEG=OFF -DBUILD_JASPER=OFF -DBUILD_ZLIB=OFF -DBUILD_EXAMPLES=ON -DBUILD_opencv_java=OFF -DBUILD_opencv_python2=OFF -DBUILD_opencv_python3=ON -DENABLE_PRECOMPILED_HEADERS=OFF -DWITH_OPENCL=OFF -DWITH_OPENMP=OFF -DWITH_FFMPEG=ON -DWITH_GSTREAMER=OFF -DWITH_GSTREAMER_0_10=OFF -DWITH_CUDA=ON-DWITH_GTK=ON -DWITH_VTK=OFF -DWITH_TBB=ON -DWITH_1394=OFF -DWITH_OPENEXR=OFF -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-10.2 -DCUDA_ARCH_BIN=5.3 -DWITH_CUDNN=ON -DOPENCV_DNN_CUDA=ON -DCUDNN_VERSION='8.0' -DCUDNN_INCLUDE_DIR='/usr/include/' -DCUDA_ARCH_PTX="" -DWITH_LIBV4L=ON -DINSTALL_C_EXAMPLES=ON -DOPENCV_ENABLE_NONFREE=ON -DBUILD_TESTS=OFF -DBUILD_PERF_TESTS=OFF -DBUILD_EXAMPLES=OFF -DINSTALL_TESTS=OFF -DOPENCV_EXTRA_MODULES_PATH=../../opencv_contrib-4.1.1/modules ..

/home/nvidia/opencv-4.1.1/opencv_contrib-4.1.1/modules/xfeatures2d/src/boostdesc.cpp:654:20: fatal error: boostdesc_bgm.i: No such file or directory
#include “boostdesc_bgm.i”
^~~~~~~~~~~~~~~~~
compilation terminated.
modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/build.make:91: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o’ failed
make[2]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/src/boostdesc.cpp.o] Error 1
CMakeFiles/Makefile2:9278: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all’ failed
make[1]: *** [modules/xfeatures2d/CMakeFiles/opencv_xfeatures2d.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…

sudo cp ../../boostdesc_bgm.i等/* ../../opencv_contrib-4.1.1/modules/xfeatures2d/src/

sudo make clean
sudo make -j8
/home/nvidia/opencv-4.1.1/opencv_contrib-4.1.1/modules/xfeatures2d/test/test_features2d.cpp:51:10: fatal error: features2d/test/test_detectors_regression.impl.hpp: No such file or directory
#include “features2d/test/test_detectors_regression.impl.hpp”
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/build.make:86: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_features2d.cpp.o’ failed
make[2]: *** [modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_features2d.cpp.o] Error 1
CMakeFiles/Makefile2:9522: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/all’ failed
make[1]: *** [modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…

ljx@ljx-desktop:~/opencv-4.1.1/opencv-4.1.1/modules/features2d/test$ ls
ocl             test_descriptors_invariance.cpp       test_detectors_invariance.cpp       test_drawing.cpp           test_main.cpp                  test_orb.cpp
test_agast.cpp  test_descriptors_invariance.impl.hpp  test_detectors_invariance.impl.hpp  test_fast.cpp              test_matchers_algorithmic.cpp  test_precomp.hpp
test_akaze.cpp  test_descriptors_regression.cpp       test_detectors_regression.cpp       test_invariance_utils.hpp  test_mser.cpp                  test_utils.cpp
test_brisk.cpp  test_descriptors_regression.impl.hpp  test_detectors_regression.impl.hpp  test_keypoints.cpp         test_nearestneighbors.cpp
ljx@ljx-desktop:~/opencv-4.1.1/opencv-4.1.1/modules/features2d/test$ sudo cp test_descriptors_invariance.impl.hpp test_descriptors_regression.impl.hpp test_detectors_invariance.impl.hpp test_detectors_regression.impl.hpp test_invariance_utils.hpp ../../../../opencv_contrib-4.1.1/modules/xfeatures2d/test/

sudo vi test_features2d.cpp

--/*#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"

sudo make clean
sudo make -j8

/home/nvidia/opencv-4.1.1/opencv_contrib-4.1.1/modules/xfeatures2d/test/test_rotation_and_scale_invariance.cpp:7:10: fatal error: features2d/test/test_detectors_invariance.impl.hpp: No such file or directory
#include “features2d/test/test_detectors_invariance.impl.hpp” // main OpenCV repo
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/build.make:182: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_rotation_and_scale_invariance.cpp.o’ failed
make[2]: *** [modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/test/test_rotation_and_scale_invariance.cpp.o] Error 1
CMakeFiles/Makefile2:9522: recipe for target ‘modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/all’ failed
make[1]: *** [modules/xfeatures2d/CMakeFiles/opencv_test_xfeatures2d.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs…
就是更改一下路径打开文件

cd …/…/opencv_contrib-4.1.1/modules/xfeatures2d/test/
sudo vi 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"
++#include "test_descriptors_invariance.impl.hpp"

sudo make -j8

sudo make install

/home/nvidia/opencv-4.1.1/opencv-4.1.1/samples/cpp/example_cmake

sudo cmake .

sudo make

sudo ./opencv_example


一些安装错误修复

looking for ccache --not found

sudo apt-get install ccache

no package 'gtk+-3.0 found'

sudo apt-get install build-essential libgtk-3-dev
`

Could NOT find Jasper (missing: JASPER_LIBRARIES JASPER_INCLUDE_DIR)

deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ xenial-backports main multiverse restricted universe

解决是靠全部更改为老版本的清华源 替换原有 /etc/apt/sources.list

sudo apt update
apt install libjasper1 libjasper-dev

``
Could NOT find JNI (missing: JAVA_AWT_LIBRARY JAVA_JVM_LIBRARY解决了

sudo apt-get install -y openjdk-8-jdk
sudo apt-get install -y default-jdk
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64

Module opencv_ovis disabled because OGRE3D was not found

sudo git clone gits://github.com/ogre3d/OIS.git

CMake Warning (dev) at CMakeLists.txt:148 (add_dependencies):
Policy CMP0046 is not set: Error on non-existent dependency in
add_dependencies. Run “cmake --help-policy CMP0046” for policy details.
Use the cmake_policy command to set the policy and suppress this warning.

The dependency target “X11” of target “OIS” does not exist.
This warning is for project developers. Use -Wno-dev to suppress it.

– Generating done
– Build files have been written to: /home/ljx/OIS/build
sudo cmake --help-policy CMP0046 …
sudo make
sudo make install
sudo git clone https://github.com/OGRECave/ogre.git



`error:
– 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)

git clone git://github.com/xianyi/OpenBLAS
cd OpenBLAS
sudo apt-get install gfortran
sudo make FC=gfortran
sudo make install
CERES support is disabled. Ceres Solver for reconstruction API is required.
安装编译ceres-solver-1.13.0
wget ceres-solver.org/ceres-solver-1.13.0.tar.gz
tar xvf ceres-solver-1.13.0.tar.gz
cd ceres-solver-1.13.0
mkdir build
cd build 
cmake 
make 
sudo make install

学习结束,明天跑yolo

你可能感兴趣的:(嵌入式,TX2,人工智能,opencv,linux,深度学习,无监督学习)