JETSON TX2 désinstalle l'installation originale d'opencv opencv3.2

Blog de référence:
http://blog.csdn.net/u014613745/article/details/78310916
http://blog.csdn.net/public669/article/details/99044895

Parce qu'il est nécessaire d'installer opencv3.2 dans tx2, mais que la version opencv de mon jetpack4.4 est 4.1.1, je dois désinstaller et réinstaller, mais j'ai rencontré un problème dans catkin_make, voici comment le résoudre.

Premièrement, désinstallez l'opencv d'origine

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

Voir la version opencv

pkg-config opencv --modversion

S'il n'y a pas d'affichage, la désinstallation a réussi

Deux, installez opencv3.2

1. Téléchargez opencv

Téléchargez le site officiel d'Opencv: https://opencv.org/releases/
Téléchargez le fichier source et décompressez-le, je vais l'utiliser dans l'espace de travail ros ici. Alors mettez-le dans catkin_ws / src

2. Installez opencv

1. Environnement dépendant de l'installation

sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg-dev libswscale-dev libtiff5-dev
sudo apt-get install libgtk2.0-dev
sudo apt-get install pkg-config

2. Compilez et installez

cd opencv
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local .. 
make -j
sudo make install

Il faut beaucoup de temps pour attendre patiemment

Vous pouvez rencontrer des erreurs lors de l'installation d'opencv:

Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
linked by target "opencv_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev
linked by target "opencv_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev
linked by target "opencv_test_cudev" in directory D:/Cproject/opencv/opencv/sources/modules/cudev/test
linked by target "opencv_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_test_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_perf_core" in directory D:/Cproject/opencv/opencv/sources/modules/core
linked by target "opencv_test_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_perf_cudaarithm" in directory D:/Cproject/opencv/opencv/sources/modules/cudaarithm
linked by target "opencv_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann
linked by target "opencv_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann
linked by target "opencv_test_flann" in directory D:/Cproject/opencv/opencv/sources/modules/flann
linked by target "opencv_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_test_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_perf_imgproc" in directory D:/Cproject/opencv/opencv/sources/modules/imgproc
linked by target "opencv_test_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml
linked by target "opencv_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml
linked by target "opencv_ml" in directory D:/Cproject/opencv/opencv/sources/modules/ml
linked by target "opencv_test_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_perf_video" in directory D:/Cproject/opencv/opencv/sources/modules/video
linked by target "opencv_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_test_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_perf_cudabgsegm" in directory D:/Cproject/opencv/opencv/sources/modules/cudabgsegm
linked by target "opencv_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_test_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_perf_cudafilters" in directory D:/Cproject/opencv/opencv/sources/modules/cudafilters
linked by target "opencv_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_test_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_perf_cudaimgproc" in directory D:/Cproject/opencv/opencv/sources/modules/cudaimgproc
linked by target "opencv_perf_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_test_cudawarping" in directory D:/Cproject/opencv/opencv/sources/modules/cudawarping
linked by target "opencv_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_test_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_perf_imgcodecs" in directory D:/Cproject/opencv/opencv/sources/modules/imgcodecs
linked by target "opencv_perf_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_test_photo" in directory D:/Cproject/opencv/opencv/sources/modules/photo
linked by target "opencv_test_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape
linked by target "opencv_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape
linked by target "opencv_shape" in directory D:/Cproject/opencv/opencv/sources/modules/shape
linked by target "opencv_test_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_perf_videoio" in directory D:/Cproject/opencv/opencv/sources/modules/videoio
linked by target "opencv_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_perf_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_test_cudacodec" in directory D:/Cproject/opencv/opencv/sources/modules/cudacodec
linked by target "opencv_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui
linked by target "opencv_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui
linked by target "opencv_test_highgui" in directory D:/Cproject/opencv/opencv/sources/modules/highgui
linked by target "opencv_perf_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_test_objdetect" in directory D:/Cproject/opencv/opencv/sources/modules/objdetect
linked by target "opencv_ts" in directory D:/Cproject/opencv/opencv/sources/modules/ts
linked by target "opencv_ts" in directory D:/Cproject/opencv/opencv/sources/modules/ts
linked by target "opencv_test_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_perf_features2d" in directory D:/Cproject/opencv/opencv/sources/modules/features2d
linked by target "opencv_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_test_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_perf_calib3d" in directory D:/Cproject/opencv/opencv/sources/modules/calib3d
linked by target "opencv_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_test_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_perf_cudafeatures2d" in directory D:/Cproject/opencv/opencv/sources/modules/cudafeatures2d
linked by target "opencv_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_test_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_perf_cudalegacy" in directory D:/Cproject/opencv/opencv/sources/modules/cudalegacy
linked by target "opencv_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_perf_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_test_cudaobjdetect" in directory D:/Cproject/opencv/opencv/sources/modules/cudaobjdetect
linked by target "opencv_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_test_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_perf_cudaoptflow" in directory D:/Cproject/opencv/opencv/sources/modules/cudaoptflow
linked by target "opencv_perf_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_test_cudastereo" in directory D:/Cproject/opencv/opencv/sources/modules/cudastereo
linked by target "opencv_test_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_perf_stitching" in directory D:/Cproject/opencv/opencv/sources/modules/stitching
linked by target "opencv_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_test_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_perf_superres" in directory D:/Cproject/opencv/opencv/sources/modules/superres
linked by target "opencv_videostab" in directory D:/Cproject/opencv/opencv/sources/modules/videostab
linked by target "opencv_videostab" in directory D:/Cproject/opencv/opencv/sources/modules/videostab
linked by target "opencv_traincascade" in directory D:/Cproject/opencv/opencv/sources/apps/traincascade
linked by target "opencv_createsamples" in directory D:/Cproject/opencv/opencv/sources/apps/createsamples
linked by target "opencv_annotation" in directory D:/Cproject/opencv/opencv/sources/apps/annotation
linked by target "opencv_visualisation" in directory D:/Cproject/opencv/opencv/sources/apps/visualisation
linked by target "opencv_version" in directory D:/Cproject/opencv/opencv/sources/apps/version

La solution ici peut se référer au blog: http://blog.csdn.net/u014613745/article/details/78310916

3. Configurez l'environnement et ajoutez la bibliothèque opencv au chemin

sudo gedit /etc/ld.so.conf

Ajouter au fichier ouvert à ce moment /usr/loacl/lib, enregistrer et quitter

sudo ldconfig
sudo gedit /etc/bash.bashrc 

Ajouter à la fin du fichier ouvert à ce moment PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig export PKG_CONFIG_PATH, enregistrer et quitter

source /etc/bash.bashrc

4. Inspection

pkg-config opencv --modversion

À ce stade, l'installation d'opencv est terminée

Troisièmement, modifiez cv_bridge et cmake

L'étape précédente est terminée, mais j'ai rencontré plusieurs problèmes avec catkin_make dans catkin_ws, l'un est cv_bridge et l'autre est une version opencv. Bien que opencv3 et .2 aient été installés, vous pouvez voir que opencv est détecté lorsque catkin_make La version est 4.1.1 et cv_bridge a signalé une erreur. Plus tard, il a été constaté que opencv est apparu dans usr / include après l'installation d'opencv, et l'opencv que nous avons installé était dans usr / local / include et cv_bridge a signalé une erreur. Ici, vous devez modifier cmake et cv_bridge pour compiler correctement. Descendre.

Voici les erreurs et les solutions que j'ai rencontrées. Cette erreur s'est produite pendant catkin_make. Vous
Insérez la description de l'image ici
devez modifier cmake

cd opt/ros/melodic/share/cv_bridge/cmake
sudo gedit cv_bridgeConfig.cmake

Trouvez l'emplacement ci-dessous. Insérez la description de l'image ici
Vous pouvez voir que le chemin référencé par opencv dans cv_bridgeConfig.cmake est / usr / inclde / opencv. Pour ce chemin, vous pouvez voir que le dossier est opencv4 pas opencv, il suivra donc le chemin dans la ligne suivante pour trouver la référence, et le chemin est aussi / usr / inclde / opencv, mais le chemin de l'opencv que j'ai installé auparavant se trouve dans / usr / local / include, nous devons donc modifier l'adresse de référence d'opencv dans cv_bridgeConfig.cmake, et
définir (_include_dirs "include; / usr" dans cv_bridgeConfig.cmake / include; / usr / local / opencv2 ”) est
remplacé par
set (_include_dirs“ include; / usr / local / include; / usr / local / include / opencv2 ”)
comme indiqué
Insérez la description de l'image ici
dans la figure ci-dessous. Catkin_make peut également rencontrer la figure suivante Le problème:
Insérez la description de l'image ici
c'est la version d'opencv que vous venez d'installer qui n'a pas été reconnue par le système, vous devez apporter les modifications suivantes:
ouvrez le dossier de construction de l'opencv que vous avez installé, et ouvrez / usr / lib / aarch64-linux-gnu / cmke / opencv4
vers opencv Les fichiers correspondants dans le dossier de construction sont copiés dans le dossier opencv4. OpenCVModules-realease.cmake peut ne pas être disponible, et cela semble n'avoir aucun effet.
Insérez la description de l'image ici
Encore une fois dans catkin_ws, catkin_make fera l'affaire

Je suppose que tu aimes

Origine blog.csdn.net/qq_45067735/article/details/108690541
conseillé
Classement