[错误记录】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.

 Solution: Just change the path to an absolute path

(1) According to the path in the error message, find matchers.hpp

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

(2) Locate to line 52:

 (3) Search for cuda.hpp in the folder search bar and several results will appear, select the correct file according to the error message

 (4) Right click and select Open Project Location

 (5) Click in the folder to open it in the terminal, and you can get the upper folder path of cuda.hpp:

(5) Copy it down, complete the supplement, and fill in line 52 of matchers.hpp

My path is: /home/zixuanma/devkits/opencv-3.4.5/opencv_contrib-3.4.5/modules/xfeatures2d/include/opencv2/xfeatures2d/cuda.hpp

(6) Click Save, re-make, this problem is solved

(7) Recompile, I have a similar error again, the method is the same, just continue to modify according to the error message.

2. fatal error: boostdesc_bgm.i: No such file or directory

 /home/zixuanma/devkits/opencv-3.4.5/opencv_contrib-3.4.5/modules/xfeatures2d/src/boostdesc.cpp:653:20: fatal error: boostdesc_bgm.i: No such file or directory
  653 | #include " boostdesc_bgm.i"
      | ^~~~~~~~~~~~~~~~~
compilation terminated.

 Reference: Solution to the problem of missing boostdesc_bgm.i file when installing OpenCV 

Although I hate downloading these resources on the network disk, it does solve the problem

The main reason is that I can't find the official website 

3. fatal error: opencv2/xfeatures2d.hpp: No such file or directory

/home/zixuanma/devkits/opencv-3.4.5/modules/stitching/src/matchers.cpp:52:10: fatal error: opencv2/xfeatures2d.hpp: No such file or directory
   52 | #include "opencv2/xfeatures2d. hpp"
      | ^~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

The method is the same as the first one

4. fatal error: opencv2/xfeatures2d/nonfree.hpp: No such file or directory

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: No such file or directory
   43 | #include "opencv2/xfeatures2d/nonfree.hpp"
      | ^~~~~~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.

 

 The method is still the same as the first

Guess you like

Origin blog.csdn.net/weixin_51972142/article/details/131022883