树莓派4B安装opencv错误大全

文章目录

  • 学习记录
    • 设备
    • fatal error: opencv2/xfeatures2d/cuda.hpp: 没有那个文件或目录
      • 完整内容
      • 解决办法:
        • 错误1
        • 错误2
    • fatal error: boostdesc_bgm.i: 没有那个文件或目录
      • 解决办法:
      • 备注
    • fatal error: opencv2/xfeatures2d.hpp: 没有那个文件或目录
      • 完整报错
    • fatal error: opencv2/xfeatures2d/nonfree.hpp: 没有那个文件或目录
      • 完整报错
      • 解决办法
    • cp: 无法创建普通文件'/usr/local/lib/pkgconfig/opencv.pc': 没有那个文件或目录
      • 解决方案
    • g++: error: pkg-config --cflags --libs opencv3: 没有那个文件或目录
      • 解决办法:
    • Package opencv3 was not found in the pkg-config search path.
      • 完整描述
      • 解决方法
    • /usr/bin/ld: warning: libopencv_core.so.3.4, needed by /home/pi/Folder/opencv-3.4.3/build/lib/libopencv_stitching.so, not found (try using -rpath or -rpath-link)
      • 命令
      • 解决方案

学习记录

树莓派4B安装opencv

设备

  1. 树莓派4B(4GB)
  2. 闪迪16GB Micro SD
  3. Linux raspberrypi 4.19.75-v7l+
  4. opencv-3.4.3
  5. opencv_contrib-3.4.3

fatal error: opencv2/xfeatures2d/cuda.hpp: 没有那个文件或目录

完整内容

/home/pi/Folder/opencv-3.4.3/modules/stitching/include/opencv2/stitching/detail/matchers.hpp:52:12: fatal error: opencv2/xfeatures2d/cuda.hpp: 没有那个文件或目录
 #  include "opencv2/xfeatures2d/cuda.hpp"
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

路径:/home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/src

解决办法:

打开对应文件,把相对路径改成绝对路径

错误1

vim /home/pi/Folder/opencv-3.4.3/modules/stitching/include/opencv2/stitching/detail/matchers.hpp

替换后的绝对路径

#include "/home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/include/opencv2/xfeatures2d/cuda.hpp"

错误2

vim /home/pi/Folder/opencv-3.4.3/modules/stitching/src/precomp.hpp

替换内容同上

fatal error: boostdesc_bgm.i: 没有那个文件或目录

路径:/home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/src/boostdesc.cpp:653:20:

解决办法:

下载对应文件,移动到/home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/src目录下

备注

实际缺少多个文件
树莓派4B安装opencv错误大全_第1张图片

fatal error: opencv2/xfeatures2d.hpp: 没有那个文件或目录

完整报错

/home/pi/Folder/opencv-3.4.3/modules/stitching/src/matchers.cpp:52:10: fatal error: opencv2/xfeatures2d.hpp: 没有那个文件或目录
 #include "opencv2/xfeatures2d.hpp"
          ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

打开对应文件

vim /home/pi/Folder/opencv-3.4.3/modules/stitching/src/matchers.cpp

把相对路径换为绝对路径

#include "/home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp"

fatal error: opencv2/xfeatures2d/nonfree.hpp: 没有那个文件或目录

完整报错

/home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp:43:10: fatal error: opencv2/xfeatures2d/nonfree.hpp: 没有那个文件或目录
 #include "opencv2/xfeatures2d/nonfree.hpp"
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

解决办法

打开文件

vim /home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp

修改路径

#include "/home/pi/Folder/opencv_contrib-3.4.3/modules/xfeatures2d/include/opencv2/xfeatures2d/nonfree.hpp"

cp: 无法创建普通文件’/usr/local/lib/pkgconfig/opencv.pc’: 没有那个文件或目录

命令

cp /home/pi/Folder/opencv-3.4.3/build/lib/pkgconfig/opencv.pc /usr/local/lib/pkgconfig/opencv.pc

解决方案

自行创建了/usr/local/lib/pkgconfig/
也不知道是对是错

g++: error: pkg-config --cflags --libs opencv3: 没有那个文件或目录

命令

g++ -ggdb 'pkg-config --cflags --libs opencv3' opencv_version.cpp  -o /tmp/opencv_version && /tmp/opencv_version

解决办法:

把单引号改成倒引号

g++ -ggdb `pkg-config --cflags --libs opencv3` opencv_version.cpp  -o /tmp/opencv_version && /tmp/opencv_version

Package opencv3 was not found in the pkg-config search path.

完整描述

Package opencv3 was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv3.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv3' found
/usr/bin/ld: /tmp/ccYDmS9g.o: in function `main':
。。。

解决方法

pkg-config中opencv.pc复制后要改为opencv3.pc

mv /usr/local/lib/pkgconfig/opencv.pc  /usr/local/lib/pkgconfig/opencv3.pc

/usr/bin/ld: warning: libopencv_core.so.3.4, needed by /home/pi/Folder/opencv-3.4.3/build/lib/libopencv_stitching.so, not found (try using -rpath or -rpath-link)

命令

g++ -ggdb `pkg-config --cflags --libs opencv3` opencv_version.cpp  -o /tmp/opencv_version && /tmp/opencv_version

解决方案

apt-get autoremove libopencv-dev

卸载了一堆库

软件包 libopencv-dev 未安装,所以不会被卸载
下列软件包将被【卸载】:
  alsa-base fonts-freefont-ttf freetype2-doc gdal-data gir1.2-gtk-2.0 gir1.2-harfbuzz-0.0
  gstreamer0.10-alsa ibverbs-providers liba52-0.7.4 libaa1 libaec0 libaom0 libaribb24-0
  libarmadillo9 libarpack2 libass9 libasyncns0 libatk1.0-dev libavc1394-0 libavresample-dev
  libavresample4 libbasicusageenvironment1 libbs2b0 libcaca0 libcaf-openmpi-3
  libcairo-script-interpreter2 libcddb2 libcdparanoia0 libcharls2 libcoarrays-openmpi-dev
  libcodec2-0.8.1 libdap25 libdapclient6v5 libdapserver7v5 libdca0 libde265-0 libdv4 libdvbpsi10
  libdvdnav4 libdvdread4 libebml4v5 libepsilon1 libevent-core-2.1-6 libevent-pthreads-2.1-6
  libexif-dev libexif-doc libfaad2 libfftw3-double3 libflac8 libflite1 libfreexl1 libfribidi-dev
  libfyba0 libgdal20 libgdcm2-dev libgdcm2.8 libgeos-3.7.1 libgeos-c1v5 libgeotiff2 libgl2ps1.4
  libgphoto2-dev libgraphite2-dev libgroupsock8 libgssdp-1.0-3 libgstreamer-plugins-bad1.0-0
  libgupnp-1.0-4 libgupnp-igd-1.0-4 libharfbuzz-dev libharfbuzz-gobject0 libhdf4-0-alt libhdf5-103
  libhdf5-openmpi-103 libhwloc-dev libhwloc-plugins libhwloc5 libibverbs-dev libibverbs1
  libice-dev libiec61883-0 libilmbase-dev libilmbase23 libixml10 libjack-jackd2-0 libkate1
  libkmlbase1 libkmlconvenience1 libkmldom1 libkmlengine1 libkmlregionator1 libkmlxsd1 liblept5
  liblilv-0-0 liblirc-client0 liblivemedia64 liblua5.2-0 liblzo2-2 libmad0 libmariadb3
  libmatroska6v5 libmicrodns0 libminizip1 libmjpegutils-2.1-0 libmms0 libmodplug1 libmpcdec6
  libmpeg2-4 libmpeg2encpp-2.1-0 libmplex2-2.1-0 libmysofa0 libnetcdf-c++4 libnetcdf13 libnice10
  libnl-3-dev libnl-route-3-dev libodbc1 libofa0 libogdi3.2 libopenal-data libopenal1
  libopencv-core-dev libopencv-core3.2 libopencv-flann-dev libopencv-flann3.2
  libopencv-imgcodecs-dev libopencv-imgcodecs3.2 libopencv-imgproc-dev libopencv-imgproc3.2
  libopencv-ml-dev libopencv-ml3.2 libopencv-photo-dev libopencv-photo3.2 libopencv-shape-dev
  libopencv-shape3.2 libopencv-ts-dev libopencv-video-dev libopencv-video3.2 libopenexr-dev
  libopenexr23 libopenmpi-dev libopenmpi3 libpixman-1-dev libplacebo7 libpmix2 libpng-tools
  libportmidi0 libpostproc55 libpq5 libproj13 libprotobuf-lite17 libproxy-tools
  libpthread-stubs0-dev libqhull7 libqt5x11extras5 libresid-builder0c2a librubberband2 libserd-0-0
  libshout3 libsidplay2 libsm-dev libsndio7.0 libsocket++1 libsord-0-0 libsoundtouch1 libspandsp2
  libspatialaudio0 libspatialite7 libspeexdsp1 libsratom-0-0 libsrtp2-1 libsuperlu5
  libswresample-dev libswresample3 libsz2 libtag1v5 libtag1v5-vanilla libtesseract4 libupnp13
  liburiparser1 libusageenvironment3 libva-drm2 libva-wayland2 libvidstab1.1 libvisual-0.4-0
  libvlc-bin libvlc5 libvlccore9 libvo-aacenc0 libvo-amrwbenc0 libvpx5 libvulkan1
  libwebrtc-audio-processing1 libwildmidi2 libx11-dev libx264-155 libx265-165 libxau-dev
  libxcb-render0-dev libxcb-shm0-dev libxcb-xv0 libxcb1-dev libxcomposite-dev libxcursor-dev
  libxdamage-dev libxdmcp-dev libxerces-c3.2 libxext-dev libxfce4util-bin libxfce4util-common
  libxfce4util7 libxfconf-0-2 libxfixes-dev libxi-dev libxinerama-dev libxrandr-dev libxrender-dev
  libzbar0 mariadb-common mysql-common ocl-icd-libopencl1 odbcinst odbcinst1debian2 opencv-data
  openmpi-bin openmpi-common pango1.0-tools pi-package-data proj-bin proj-data
  sound-theme-freedesktop timgm6mb-soundfont vlc-bin vlc-data vlc-l10n vlc-plugin-notify
  vlc-plugin-qt vlc-plugin-samba vlc-plugin-skins2 vlc-plugin-video-splitter
  vlc-plugin-visualization x11proto-composite-dev x11proto-core-dev x11proto-damage-dev
  x11proto-dev x11proto-fixes-dev x11proto-input-dev x11proto-randr-dev x11proto-xext-dev
  x11proto-xinerama-dev xfconf xorg-sgml-doctools xtrans-dev

很明星,我删库了。

你可能感兴趣的:(树莓派)