[错误记录】Ubuntu20.04下安装OpenCV3.4.5时make报错

最近在Ubuntu20.04下安装OpenCV3.4.5以及OpenCV_contrib3.4.5时,在生成makefile的时候出现几个错误

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

In file included from /home/zixuanma/devkits/opencv-3.4.5 /modules /stitching /include /opencv2/stitching.hpp:49,
     from /home/zixuanma/devkits/opencv-3.4.5/modules/stitching/src/precomp.hpp:59,
     from /home/zixuanma/devkits/opencv-3.4.5/build/modules/stitching/opencv_stitching_ pch_dephelp.cxx:1:
/home/zixuanma/devkits/opencv-3.4.5/modules/stitching/include/opencv2/stitching/detail /matchers.hpp:52:12: fatal error: opencv2/xfeatures2d/cuda.hpp: 没有那个文件或目录
   52 | #  include "opencv2/xfeatures2d/cuda.hpp"
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

 解决方法:把路径改为绝对路径就行

(1)根据报错信息中的路径,找到matchers.hpp

/home/zixuanma/devkits/opencv-3.4.5/modules/stitching/include/opencv2/stitching/detail /matchers.hpp:52:12

(2) 定位到52行:

[错误记录】Ubuntu20.04下安装OpenCV3.4.5时make报错_第1张图片

 (3)在文件夹搜索栏中搜索cuda.hpp会出现几个结果,根据报错信息选择正确的文件

[错误记录】Ubuntu20.04下安装OpenCV3.4.5时make报错_第2张图片

 (4)右键选择打开项目位置

[错误记录】Ubuntu20.04下安装OpenCV3.4.5时make报错_第3张图片

 (5)在文件夹中点击在终端打开,可以得到cuda.hpp的上层文件夹路径:

[错误记录】Ubuntu20.04下安装OpenCV3.4.5时make报错_第4张图片(5)复制下来,补充完成,填写到matchers.hpp的第52行

我的路径是:/home/zixuanma/devkits/opencv-3.4.5/opencv_contrib-3.4.5/modules/xfeatures2d/include/opencv2/xfeatures2d/cuda.hpp

[错误记录】Ubuntu20.04下安装OpenCV3.4.5时make报错_第5张图片

(6)点击保存,重新make,这个问题解决

(7)重新编译,我这里又出现了差不多的错误,方法一样,根据报错信息继续修改就行。

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

 /home/zixuanma/devkits/opencv-3.4.5/opencv_contrib-3.4.5/modules/xfeatures2d/src/boostdesc.cpp:653:20: fatal error: boostdesc_bgm.i: 没有那个文件或目录
  653 |           #include "boostdesc_bgm.i"
      |                    ^~~~~~~~~~~~~~~~~
compilation terminated.

 参考:安装OpenCV时提示缺少boostdesc_bgm.i文件的问题解决方案 

虽然我很讨厌在网盘下载这些资源,但是确实解决问题了

主要是也找不到官网 

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

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

方法和第一个一样

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

In file included from /home/zixuanma/devkits/opencv-3.4.5/modules/stitching/src/matchers.cpp:52:
/home/zixuanma/devkits/opencv-3.4.5/opencv_contrib-3.4.5/modules/xfeatures2d/include/opencv2/xfeatures2d.hpp:43:10: fatal error: opencv2/xfeatures2d/nonfree.hpp: 没有那个文件或目录
   43 | #include "opencv2/xfeatures2d/nonfree.hpp"
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

 

 方法仍然和第一个相同

你可能感兴趣的:(opencv,人工智能,计算机视觉,linux,ubuntu)